diff --git a/build/StarcoinFramework/BuildInfo.yaml b/build/StarcoinFramework/BuildInfo.yaml index e131c395..9f795b98 100644 --- a/build/StarcoinFramework/BuildInfo.yaml +++ b/build/StarcoinFramework/BuildInfo.yaml @@ -312,7 +312,7 @@ compiled_package_info: ? address: "0x00000000000000000000000000000001" name: YieldFarmingV2 : StarcoinFramework - source_digest: B85EC5CCB8E021D9974D19AD20C43DBC20D2AE625A72A096A5BAED676B5D9F1F + source_digest: DC60876727975D2C568C06813162A81120B13D4F6A6B636E13364139A16514B3 build_flags: dev_mode: false test_mode: false diff --git a/integration-tests/daospace/stake_to_sbt_plugin.exp b/integration-tests/daospace/stake_to_sbt_plugin.exp index b4c963c6..94e6cab7 100644 --- a/integration-tests/daospace/stake_to_sbt_plugin.exp +++ b/integration-tests/daospace/stake_to_sbt_plugin.exp @@ -8,13 +8,13 @@ task 5 'run'. lines 61-69: task 6 'run'. lines 71-107: { - "gas_used": 652263, + "gas_used": 652577, "status": "Executed" } task 7 'run'. lines 109-120: { - "gas_used": 38208, + "gas_used": 38522, "status": { "MoveAbort": { "location": { @@ -30,19 +30,19 @@ task 7 'run'. lines 109-120: task 9 'run'. lines 124-137: { - "gas_used": 86008, + "gas_used": 86636, "status": "Executed" } task 10 'run'. lines 139-155: { - "gas_used": 419528, + "gas_used": 419842, "status": "Executed" } task 12 'run'. lines 159-172: { - "gas_used": 216758, + "gas_used": 217386, "status": "Executed" } @@ -54,7 +54,7 @@ task 13 'run'. lines 174-190: task 15 'run'. lines 194-209: { - "gas_used": 225723, + "gas_used": 226351, "status": "Executed" } diff --git a/sources/daospaceplugin/StakeToSBTPlugin.move b/sources/daospaceplugin/StakeToSBTPlugin.move index 9790f65b..2be172da 100644 --- a/sources/daospaceplugin/StakeToSBTPlugin.move +++ b/sources/daospaceplugin/StakeToSBTPlugin.move @@ -24,14 +24,14 @@ module StarcoinFramework::StakeToSBTPlugin { struct Stake has key, store { id: u64, token: Token::Token, - stake_time: u64, // The timestamp when user stake - lock_time: u64, + stake_time: u64, // How long where the user locked - weight: u64, + lock_time: u64, // Which multiplier by the user stake - sbt_amount: u128, + weight: u64, // The SBT amount that user swap in the token + sbt_amount: u128, } struct StakeList has key, store { @@ -215,6 +215,7 @@ module StarcoinFramework::StakeToSBTPlugin { public fun query_stake(member: address, id: u64) : (u64, u64, u64, u128, u128) acquires StakeList { + assert!(exists>(member), Errors::not_published(ERR_PLUGIN_NOT_STAKE)); let stake_list = borrow_global_mut>(member); let item_index = find_item(id, &stake_list.items); @@ -234,12 +235,14 @@ module StarcoinFramework::StakeToSBTPlugin { /// Query stake count from stake list public fun query_stake_count(member: address): u64 acquires StakeList { + assert!(exists>(member), Errors::not_published(ERR_PLUGIN_NOT_STAKE)); let stake_list = borrow_global>(member); Vector::length(&stake_list.items) } /// Unstake from staking public fun unstake_by_id(member: address, id: u64) acquires StakeList { + assert!(exists>(member), Errors::not_published(ERR_PLUGIN_NOT_STAKE)); let stake_list = borrow_global_mut>(member); let item_index = find_item(id, &stake_list.items); @@ -276,6 +279,7 @@ module StarcoinFramework::StakeToSBTPlugin { /// Unstake all staking items from member address, /// No care whether the user is member or not public fun unstake_all(member: address) acquires StakeList { + assert!(exists>(member), Errors::not_published(ERR_PLUGIN_NOT_STAKE)); let stake_list = borrow_global_mut>(member); let len = Vector::length(&mut stake_list.items);