Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add assertion in stake to StakeToSBTPlugin::stake while the lock ti… #117

Merged
merged 3 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/StarcoinFramework/BuildInfo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ compiled_package_info:
? address: "0x00000000000000000000000000000001"
name: YieldFarmingV2
: StarcoinFramework
source_digest: 8E7AEB189849D23881D6C14563228D20E8991069B2A727CBB2D0A5FBAA816EC4
source_digest: 2D748C090C62EEE57201E3E4337FA6950DAAE7319771817C003027E781E3A62F
build_flags:
dev_mode: false
test_mode: false
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/daospace/stake_to_sbt_plugin.exp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ task 6 'run'. lines 61-69:

task 7 'run'. lines 71-107:
{
"gas_used": 569616,
"gas_used": 569552,
"status": "Executed"
}

Expand Down Expand Up @@ -52,7 +52,7 @@ task 10 'run'. lines 124-137:

task 11 'run'. lines 139-155:
{
"gas_used": 336881,
"gas_used": 336817,
"status": "Executed"
}

Expand All @@ -64,7 +64,7 @@ task 13 'run'. lines 159-172:

task 14 'run'. lines 174-190:
{
"gas_used": 458402,
"gas_used": 458338,
"status": "Executed"
}

Expand Down
8 changes: 3 additions & 5 deletions sources/daospaceplugin/StakeToSBTPlugin.move
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module StarcoinFramework::StakeToSBTPlugin {
const ERR_PLUGIN_STILL_LOCKED: u64 = 1004;
const ERR_PLUGIN_CONFIG_INIT_REPEATE: u64 = 1005;
const ERR_PLUGIN_ITEM_CANT_FOUND: u64 = 1006;
const ERR_PLUGIN_NO_MATCH_LOCKTIME: u64 = 1007;

struct StakeToSBTPlugin has store, drop{}

Expand Down Expand Up @@ -109,12 +110,9 @@ module StarcoinFramework::StakeToSBTPlugin {
};

let weight_opt = get_sbt_weight<DAOT, TokenT>(lock_time);
let weight = if (Option::is_none(&weight_opt)) {
1
} else {
Option::destroy_some(weight_opt)
};
assert!(Option::is_some(&weight_opt), Errors::invalid_state(ERR_PLUGIN_NO_MATCH_LOCKTIME));
jolestar marked this conversation as resolved.
Show resolved Hide resolved

let weight = Option::destroy_some(weight_opt);
let sbt_amount = compute_token_to_sbt(weight, &token);
DAOSpace::increase_member_sbt(&member_cap, sender_addr, sbt_amount);

Expand Down