Skip to content

Commit

Permalink
Merge pull request #96 from Alien-Worlds/DEMZNE-1147_alter-msig-clean…
Browse files Browse the repository at this point in the history
…up-action-to-clean-up-expired-proposals-also

Allows for `cleanup` of expired MSIG proposals.
  • Loading branch information
angelol authored Nov 24, 2022
2 parents 65b1c6c + 86152b7 commit 480a6d0
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions contracts/msigworlds/msigworlds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void multisig::propose(name proposer, name proposal_name, std::vector<permission

auto packed_requested = pack(requested);
auto res = check_transaction_authorization(
trx_pos, size, (const char *)0, 0, packed_requested.data(), packed_requested.size());
trx_pos, size, (const char *)0, 0, packed_requested.data(), packed_requested.size());

check(res > 0, "msigworlds::propose preflight transaction authorization check failed");

Expand Down Expand Up @@ -102,7 +102,7 @@ void multisig::approve(
}

proposals proptable(get_self(), dac_id.value);
auto &prop = proptable.get(proposal_name.value, "proposal not found");
auto & prop = proptable.get(proposal_name.value, "proposal not found");
check(prop.state == PropState::PENDING,
"ERR::PROP_NOT_PENDING::proposal can only be approved while in pending state");

Expand Down Expand Up @@ -186,7 +186,7 @@ void multisig::_unapprove(
}

proposals proptable(get_self(), dac_id.value);
auto &prop = proptable.get(proposal_name.value, "proposal not found");
auto & prop = proptable.get(proposal_name.value, "proposal not found");
check(prop.state == PropState::PENDING,
"ERR::PROP_NOT_PENDING::proposal can only be changed while in pending state.");

Expand All @@ -208,7 +208,7 @@ void multisig::_unapprove(

void multisig::checkauth(name proposal_name, name dac_id) {
proposals proptable(get_self(), dac_id.value);
auto &prop = proptable.get(proposal_name.value, "proposal not found");
auto & prop = proptable.get(proposal_name.value, "proposal not found");
auto table_op = [](auto &&, auto &&) {};
if (trx_is_authorized(
get_approvals_and_adjust_table(get_self(), proposal_name, table_op, dac_id), prop.packed_transaction)) {
Expand All @@ -222,7 +222,7 @@ void multisig::cancel(name proposal_name, name canceler, name dac_id) {
require_auth(canceler);

proposals proptable(get_self(), dac_id.value);
auto &prop = proptable.get(proposal_name.value, "proposal not found");
auto & prop = proptable.get(proposal_name.value, "proposal not found");

if (canceler != prop.proposer) {
check(unpack<transaction_header>(prop.packed_transaction).expiration <
Expand All @@ -243,7 +243,7 @@ void multisig::exec(name proposal_name, name executer, name dac_id) {
require_auth(executer);

proposals proptable(get_self(), dac_id.value);
auto &prop = proptable.get(proposal_name.value, "proposal not found");
auto & prop = proptable.get(proposal_name.value, "proposal not found");
check(prop.state == PropState::PENDING,
"ERR::PROP_EXEC_NOT_PENDING::The same proposal cannot be executed mulitple times.");

Expand Down Expand Up @@ -282,9 +282,10 @@ void multisig::exec(name proposal_name, name executer, name dac_id) {

void multisig::cleanup(name proposal_name, name dac_id) {
proposals proptable(get_self(), dac_id.value);
auto &prop = proptable.get(proposal_name.value, "ERR::PROPOSAL_NOT_FOUND::proposal not found");
check(prop.state != PropState::PENDING,
"ERR::PROPOSAL_CLEANUP_STILL_PENDING::proposal cannot be cleared before being executed or cancelled.");
auto & prop = proptable.get(proposal_name.value, "ERR::PROPOSAL_NOT_FOUND::proposal not found");
check(prop.state != PropState::PENDING || unpack<transaction_header>(prop.packed_transaction).expiration <
eosio::time_point_sec(current_time_point()),
"ERR::PROPOSAL_CLEANUP_STILL_PENDING::proposal cannot be cleared before being executed or cancelled, or until after expiry.");

approvals apptable(get_self(), dac_id.value);
auto apps_it = apptable.require_find(proposal_name.value, "ERR::NO_APPROVALS_FOUND::No approvals were found.");
Expand Down

0 comments on commit 480a6d0

Please sign in to comment.