Skip to content

Commit

Permalink
fix stake plugin for compatibility (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
pause125 authored Nov 22, 2022
1 parent 87859a9 commit e618173
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 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_CONFIG_INIT_REPEATE: u64 = 1005;
const ERR_PLUGIN_ITEM_CANT_FOUND: u64 = 1006;
const ERR_PLUGIN_NO_MATCH_LOCKTIME: u64 = 1007;
const ERR_DEPRECATED_METHOD: u64 = 1008;

struct StakeToSBTPlugin has store, drop {}

Expand Down Expand Up @@ -120,7 +121,12 @@ module StarcoinFramework::StakeToSBTPlugin {
accept_token(AcceptTokenCap<DAOT, TokenT> {});
}

fun install_event<DAOT: store, EventT: store+drop>() {
/// Deprecated
public fun install_event<DAOT: store>() {
abort Errors::deprecated(ERR_DEPRECATED_METHOD)
}

fun install_event_inner<DAOT: store, EventT: store+drop>() {
if (!DAOSpace::exist_plugin_event<DAOT, StakeToSBTPlugin, EventT>()) {
let witness = StakeToSBTPlugin {};
let plugin_event_cap =
Expand Down Expand Up @@ -158,7 +164,7 @@ module StarcoinFramework::StakeToSBTPlugin {
weight_vec: Vector::empty<LockWeight<DAOT, TokenT>>()
});

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

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

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

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

install_event<DAOT, SBTWeightChangedEvent>();
install_event_inner<DAOT, SBTWeightChangedEvent>();
let witness = StakeToSBTPlugin {};
let plugin_event_cap =
DAOSpace::acquire_plugin_event_cap<DAOT, StakeToSBTPlugin>(&witness);
Expand Down

0 comments on commit e618173

Please sign in to comment.