Skip to content

Commit

Permalink
Remove decrease SBT when unstake item (#81)
Browse files Browse the repository at this point in the history
* Remove decrease SBT when unstake item

* fix spectest error
  • Loading branch information
welbon committed Aug 10, 2022
1 parent 41ad861 commit d401c37
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build/StarcoinFramework/BuildInfo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ compiled_package_info:
? address: "0x00000000000000000000000000000001"
name: YieldFarmingV2
: StarcoinFramework
source_digest: 6F307AEE1142B5C572B5235CABAE88249D55900EC0E687DD762DF015D0591BB1
source_digest: 0E40C59E95BD4C4EAC7E35CCB4EC85127F72EE5F48D70BEE8FBE34B526A11E42
build_flags:
dev_mode: false
test_mode: false
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/daospace/stake_to_sbt_plugin.exp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ task 7 'run'. lines 70-106:

task 8 'run'. lines 108-119:
{
"gas_used": 38238,
"gas_used": 38208,
"status": {
"Keep": {
"MoveAbort": [
Expand All @@ -44,7 +44,7 @@ task 8 'run'. lines 108-119:

task 10 'run'. lines 123-136:
{
"gas_used": 249960,
"gas_used": 86008,
"status": {
"Keep": "Executed"
}
Expand All @@ -60,7 +60,7 @@ task 11 'run'. lines 138-154:

task 13 'run'. lines 158-171:
{
"gas_used": 288121,
"gas_used": 124169,
"status": {
"Keep": "Executed"
}
Expand All @@ -76,7 +76,7 @@ task 14 'run'. lines 173-189:

task 16 'run'. lines 193-208:
{
"gas_used": 142129,
"gas_used": 133134,
"status": {
"Keep": "Executed"
}
Expand Down
11 changes: 2 additions & 9 deletions sources/daospaceplugin/StakeToSBTPlugin.move
Original file line number Diff line number Diff line change
Expand Up @@ -189,25 +189,18 @@ module StarcoinFramework::StakeToSBTPlugin {
}

/// Unstake a item from a item object
fun unstake_item<DAOT: store, TokenT: store>(member: address, item: Stake<DAOT, TokenT>): Token::Token<TokenT> {
fun unstake_item<DAOT: store, TokenT: store>(_member: address, item: Stake<DAOT, TokenT>): Token::Token<TokenT> {
let Stake<DAOT, TokenT> {
id: _,
token,
lock_time,
stake_time,
weight: _,
sbt_amount,
sbt_amount: _,
} = item;

assert!((Timestamp::now_seconds() - stake_time) > lock_time, Errors::invalid_state(ERR_PLUGIN_STILL_LOCKED));

// Decrease SBT by weight if the sender is a member
if (DAOSpace::is_member<DAOT>(member)) {
let witness = StakeToSBTPlugin {};
let cap = DAOSpace::acquire_member_cap<DAOT, StakeToSBTPlugin>(&witness);
DAOSpace::decrease_member_sbt(&cap, member, sbt_amount);
};

token
}

Expand Down

0 comments on commit d401c37

Please sign in to comment.