Skip to content

Commit

Permalink
Revert "fix StakeToSBTPlugin install event (#215)"
Browse files Browse the repository at this point in the history
This reverts commit 77a968a.
  • Loading branch information
nkysg committed Mar 2, 2023
1 parent 40e8b19 commit 9fe72ab
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 45 deletions.
12 changes: 6 additions & 6 deletions integration-tests/daospaceplugin/stake_to_sbt_plugin.exp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ processed 17 tasks

task 5 'run'. lines 52-60:
{
"gas_used": 1958252,
"gas_used": 1887227,
"status": "Executed"
}

task 6 'run'. lines 62-98:
{
"gas_used": 1159804,
"gas_used": 1022609,
"status": "Executed"
}

Expand All @@ -26,25 +26,25 @@ task 9 'run'. lines 121-139:

task 10 'run'. lines 141-157:
{
"gas_used": 475573,
"gas_used": 458467,
"status": "Executed"
}

task 12 'run'. lines 161-174:
{
"gas_used": 554865,
"gas_used": 417670,
"status": "Executed"
}

task 13 'run'. lines 176-192:
{
"gas_used": 609447,
"gas_used": 592341,
"status": "Executed"
}

task 15 'run'. lines 196-211:
{
"gas_used": 278963,
"gas_used": 261857,
"status": "Executed"
}

Expand Down
8 changes: 4 additions & 4 deletions integration-tests/starcoin_dao/starcoin_onchain_config.exp
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ processed 42 tasks

task 11 'run'. lines 23-37:
{
"gas_used": 1096577,
"gas_used": 959229,
"status": "Executed"
}

task 12 'run'. lines 39-53:
{
"gas_used": 976335,
"gas_used": 959229,
"status": "Executed"
}

task 13 'run'. lines 55-69:
{
"gas_used": 976335,
"gas_used": 959229,
"status": "Executed"
}

task 14 'run'. lines 71-85:
{
"gas_used": 976335,
"gas_used": 959229,
"status": "Executed"
}

Expand Down
8 changes: 4 additions & 4 deletions integration-tests/starcoin_dao/starcoin_treasury_withdraw.exp
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ processed 44 tasks

task 11 'run'. lines 23-37:
{
"gas_used": 1096577,
"gas_used": 959229,
"status": "Executed"
}

task 12 'run'. lines 39-53:
{
"gas_used": 976335,
"gas_used": 959229,
"status": "Executed"
}

task 13 'run'. lines 55-69:
{
"gas_used": 976335,
"gas_used": 959229,
"status": "Executed"
}

task 14 'run'. lines 71-85:
{
"gas_used": 976335,
"gas_used": 959229,
"status": "Executed"
}

Expand Down
8 changes: 4 additions & 4 deletions integration-tests/starcoin_dao/starcoin_upgrade_module.exp
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ processed 45 tasks

task 11 'run'. lines 23-37:
{
"gas_used": 1096577,
"gas_used": 959229,
"status": "Executed"
}

task 12 'run'. lines 39-53:
{
"gas_used": 976335,
"gas_used": 959229,
"status": "Executed"
}

task 13 'run'. lines 55-69:
{
"gas_used": 976335,
"gas_used": 959229,
"status": "Executed"
}

task 14 'run'. lines 71-85:
{
"gas_used": 976335,
"gas_used": 959229,
"status": "Executed"
}

Expand Down
4 changes: 0 additions & 4 deletions sources/daospace/DAOSpace.move
Original file line number Diff line number Diff line change
Expand Up @@ -967,10 +967,6 @@ module StarcoinFramework::DAOSpace {
EventUtil::init_event<EventT>(&dao_signer);
}

public fun exist_plugin_event<DAOT: store, PluginT: store, EventT: store+drop>(): bool {
EventUtil::exist_event<EventT>(dao_address<DAOT>())
}

public fun emit_plugin_event<
DAOT: store,
PluginT: store,
Expand Down
33 changes: 10 additions & 23 deletions sources/daospaceplugin/StakeToSBTPlugin.move
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,19 @@ module StarcoinFramework::StakeToSBTPlugin {

/// Accept token with token type by given DAO
public fun accept_token_by_dao<DAOT: store, TokenT: store>(_witness: &DAOT) {
install_event<DAOT>();
accept_token(AcceptTokenCap<DAOT, TokenT> {});
}

fun install_event<DAOT: store, EventT: store+drop>() {
if (!DAOSpace::exist_plugin_event<DAOT, StakeToSBTPlugin, EventT>()) {
let witness = StakeToSBTPlugin {};
let plugin_event_cap =
DAOSpace::acquire_plugin_event_cap<DAOT, StakeToSBTPlugin>(&witness);
DAOSpace::init_plugin_event<DAOT, StakeToSBTPlugin, EventT>(&plugin_event_cap);
}
public fun install_event<DAOT: store>() {
let witness = StakeToSBTPlugin {};
let plugin_event_cap =
DAOSpace::acquire_plugin_event_cap<DAOT, StakeToSBTPlugin>(&witness);

DAOSpace::init_plugin_event<DAOT, StakeToSBTPlugin, SBTTokenAcceptedEvent>(&plugin_event_cap);
DAOSpace::init_plugin_event<DAOT, StakeToSBTPlugin, SBTWeightChangedEvent>(&plugin_event_cap);
DAOSpace::init_plugin_event<DAOT, StakeToSBTPlugin, SBTStakeEvent>(&plugin_event_cap);
DAOSpace::init_plugin_event<DAOT, StakeToSBTPlugin, SBTUnstakeEvent>(&plugin_event_cap);
}

/// Set sbt weight by given DAO
Expand Down Expand Up @@ -158,7 +161,6 @@ module StarcoinFramework::StakeToSBTPlugin {
weight_vec: Vector::empty<LockWeight<DAOT, TokenT>>()
});

install_event<DAOT, SBTTokenAcceptedEvent>();
let witness = StakeToSBTPlugin {};
let plugin_event_cap =
DAOSpace::acquire_plugin_event_cap<DAOT, StakeToSBTPlugin>(&witness);
Expand Down Expand Up @@ -222,7 +224,6 @@ module StarcoinFramework::StakeToSBTPlugin {
});
stake_list.next_id = id;

install_event<DAOT, SBTStakeEvent>();
let witness = StakeToSBTPlugin {};
let plugin_event_cap =
DAOSpace::acquire_plugin_event_cap<DAOT, StakeToSBTPlugin>(&witness);
Expand Down Expand Up @@ -300,7 +301,6 @@ module StarcoinFramework::StakeToSBTPlugin {

Account::deposit<TokenT>(member, unstake_item(member, poped_item));

install_event<DAOT, SBTUnstakeEvent>();
let witness = StakeToSBTPlugin {};
let plugin_event_cap =
DAOSpace::acquire_plugin_event_cap<DAOT, StakeToSBTPlugin>(&witness);
Expand Down Expand Up @@ -431,20 +431,7 @@ module StarcoinFramework::StakeToSBTPlugin {
});
};

install_event<DAOT, SBTWeightChangedEvent>();
let witness = StakeToSBTPlugin {};
let plugin_event_cap =
DAOSpace::acquire_plugin_event_cap<DAOT, StakeToSBTPlugin>(&witness);
DAOSpace::emit_plugin_event<DAOT, StakeToSBTPlugin, SBTWeightChangedEvent>(
&plugin_event_cap,
SBTWeightChangedEvent {
dao_id: DAOSpace::dao_id(DAOSpace::dao_address<DAOT>()),
token_code: Token::token_code<TokenT>(),
lock_time,
weight,
}
);

let modify_config_cap =
DAOSpace::acquire_modify_config_cap<DAOT, StakeToSBTPlugin>(&witness);

Expand Down

0 comments on commit 9fe72ab

Please sign in to comment.