Skip to content

Commit

Permalink
feat: support batch harvest for grow_bitcoin (#2991)
Browse files Browse the repository at this point in the history
* feat: support batch harvest for grow_bitcoin

* update: se object::borrow_mut_object to check the ObjectID type and the ownership
  • Loading branch information
lispking authored Dec 2, 2024
1 parent f358cba commit acef518
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions apps/grow_bitcoin/sources/grow_bitcoin.move
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module grow_bitcoin::grow_bitcoin {
use std::string::{Self, String};
use std::option;
use std::u64;
use std::vector;
use bitcoin_move::bbn;
use bitcoin_move::bbn::BBNStakeSeal;
use bitcoin_move::types;
Expand Down Expand Up @@ -416,6 +417,19 @@ module grow_bitcoin::grow_bitcoin {
withdraw_token
}

/// Harvest yield farming token from stake
public entry fun batch_harvest(signer:&signer, assets: vector<ObjectID>) {
let len = vector::length(&assets);
let i = 0;
while (i < len) {
let asset_id = *vector::borrow(&assets, i);
let utxo_obj = object::borrow_mut_object<UTXO>(signer, asset_id);
let coin = do_harvest(signer, object::id(utxo_obj));
account_coin_store::deposit(sender(), coin);
i = i + 1;
}
}

/// Harvest yield farming token from stake
public entry fun harvest(signer:&signer, asset: &mut Object<UTXO>) {
let coin = do_harvest(signer, object::id(asset));
Expand Down

0 comments on commit acef518

Please sign in to comment.