From 3fb724270d51d553ae66a31357e79e7d1917e14e Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Wed, 2 Feb 2022 16:25:23 -0500 Subject: [PATCH 1/5] Add rename action which requires authorization by 2/3+1 of the chief delegates and fully replaces any member's eosio account. --- contracts/eden/include/accounts.hpp | 1 + contracts/eden/include/bylaws.hpp | 1 + contracts/eden/include/distributions.hpp | 1 + contracts/eden/include/eden.hpp | 3 +++ contracts/eden/include/eden_dispatcher.hpp | 2 +- contracts/eden/include/elections.hpp | 1 + contracts/eden/include/inductions.hpp | 2 ++ contracts/eden/include/members.hpp | 1 + contracts/eden/include/migrations.hpp | 23 +++++++++++++++++ contracts/eden/src/actions/induct.cpp | 19 ++++++++++++++ contracts/eden/src/bylaws.cpp | 15 +++++++++++ contracts/eden/src/distributions.cpp | 25 +++++++++++++++++++ contracts/eden/src/elections.cpp | 24 ++++++++++++++++++ contracts/eden/src/inductions.cpp | 29 ++++++++++++++++++++++ contracts/eden/src/members.cpp | 29 ++++++++++++++++++++++ contracts/eden/tests/test-eden.cpp | 15 +++++++++++ 16 files changed, 190 insertions(+), 1 deletion(-) diff --git a/contracts/eden/include/accounts.hpp b/contracts/eden/include/accounts.hpp index 339805bf0..87fa35103 100644 --- a/contracts/eden/include/accounts.hpp +++ b/contracts/eden/include/accounts.hpp @@ -75,6 +75,7 @@ namespace eden std::optional get_account(eosio::name owner); void add_balance(eosio::name owner, const eosio::asset& quantity, bool enforce_minimum); void sub_balance(eosio::name owner, const eosio::asset& quantity); + void rename(eosio::name old_account, eosio::name new_account); // this method is used only for administrative purposes, // it should never be used outside genesis or test environments diff --git a/contracts/eden/include/bylaws.hpp b/contracts/eden/include/bylaws.hpp index 6c5f6a5cb..0863ba2ba 100644 --- a/contracts/eden/include/bylaws.hpp +++ b/contracts/eden/include/bylaws.hpp @@ -60,6 +60,7 @@ namespace eden // - Approvals on the pending bylaws are cleared void new_board(); void on_resign(eosio::name member); + void on_rename(eosio::name member, eosio::name new_account); void clear_all(); }; diff --git a/contracts/eden/include/distributions.hpp b/contracts/eden/include/distributions.hpp index 59ce7582a..bd2fee025 100644 --- a/contracts/eden/include/distributions.hpp +++ b/contracts/eden/include/distributions.hpp @@ -126,6 +126,7 @@ namespace eden eosio::asset amount); uint32_t on_election_kick(eosio::name member, uint32_t max_steps); void on_resign(const member& member); + void on_rename(eosio::name old_account, eosio::name new_account); void clear_all(); }; } // namespace eden diff --git a/contracts/eden/include/eden.hpp b/contracts/eden/include/eden.hpp index 8d5166371..6553fa1ef 100644 --- a/contracts/eden/include/eden.hpp +++ b/contracts/eden/include/eden.hpp @@ -147,6 +147,8 @@ namespace eden void resign(eosio::name member); + void rename(eosio::name member, eosio::name newaccount); + void setencpubkey(eosio::name member, const eosio::public_key& key); void electsettime(eosio::time_point_sec election_time); @@ -288,6 +290,7 @@ namespace eden eden_verb(inductcancel, 9, account, id, ricardian_contract(inductcancel_ricardian)), action(inducted, inductee, ricardian_contract(inducted_ricardian)), action(resign, account), + action(rename, old_account, new_account), action(gc, limit, ricardian_contract(gc_ricardian)), action(migrate, limit), action(unmigrate), diff --git a/contracts/eden/include/eden_dispatcher.hpp b/contracts/eden/include/eden_dispatcher.hpp index 25bb76215..cd68ad15d 100644 --- a/contracts/eden/include/eden_dispatcher.hpp +++ b/contracts/eden/include/eden_dispatcher.hpp @@ -44,7 +44,7 @@ namespace eden #define EDEN_GET_SESSION_ACTION_INTERNAL_1(r, type, member) \ f(EDEN_EXTRACT_SESSION_ACTION_INDEX(member), \ BOOST_PP_STRINGIZE(EOSIO_EXTRACT_ACTION_NAME(member)), \ - &type::EOSIO_EXTRACT_ACTION_NAME(member)); + &type::EOSIO_EXTRACT_ACTION_NAME(member)); #define EDEN_GET_SESSION_ACTION_INTERNAL(r, type, member) \ BOOST_PP_IIF(EDEN_MATCH_SESSION_ACTION(member), EDEN_GET_SESSION_ACTION_INTERNAL_1, \ EOSIO_EMPTY) \ diff --git a/contracts/eden/include/elections.hpp b/contracts/eden/include/elections.hpp index f4d8074aa..a1399da44 100644 --- a/contracts/eden/include/elections.hpp +++ b/contracts/eden/include/elections.hpp @@ -292,6 +292,7 @@ namespace eden uint32_t prepare_election(uint32_t max_steps); uint32_t finish_round(uint32_t max_steps); void on_resign(eosio::name member); + void on_rename(eosio::name old_account, eosio::name new_account); // \pre voter and candidate are members of the same group void vote(uint8_t round, eosio::name voter, eosio::name candidate); boost::logic::tribool can_upload_video(uint8_t round, eosio::name voter); diff --git a/contracts/eden/include/inductions.hpp b/contracts/eden/include/inductions.hpp index c1c6c9f91..1ac302626 100644 --- a/contracts/eden/include/inductions.hpp +++ b/contracts/eden/include/inductions.hpp @@ -211,6 +211,8 @@ namespace eden // Should only be used during genesis void endorse_all(const induction& induction); + void on_rename(eosio::name old_account, eosio::name new_account); + // this method is used only for administrative purposes, // it should never be used outside genesis or test environments void clear_all(); diff --git a/contracts/eden/include/members.hpp b/contracts/eden/include/members.hpp index 72fb72f39..23e515b6c 100644 --- a/contracts/eden/include/members.hpp +++ b/contracts/eden/include/members.hpp @@ -124,6 +124,7 @@ namespace eden member_table_type::const_iterator erase(member_table_type::const_iterator iter); void remove(eosio::name account); void remove_if_pending(eosio::name account); + void rename(eosio::name old_account, eosio::name new_account); bool is_new_member(eosio::name account) const; void check_active_member(eosio::name account); void check_pending_member(eosio::name account); diff --git a/contracts/eden/include/migrations.hpp b/contracts/eden/include/migrations.hpp index 89834f224..299ac2d18 100644 --- a/contracts/eden/include/migrations.hpp +++ b/contracts/eden/include/migrations.hpp @@ -38,6 +38,17 @@ namespace eden eosio::name contract; migration_singleton migration_sing; + template + static constexpr bool is_no_migration(const no_migration&) + { + return true; + } + template + static constexpr bool is_no_migration(const T&) + { + return false; + } + public: migrations(eosio::name contract) : contract(contract), migration_sing(contract, default_scope) { @@ -65,5 +76,17 @@ namespace eden return migration_sing.exists() && migration_sing.get().index() > boost::mp11::mp_find::value; } + void on_rename(eosio::name /*old_account*/, eosio::name /*new_account*/) + { + if (migration_sing.exists()) + { + std::visit( + [](const auto& var) { + eosio::check(is_no_migration(var), + "Cannot rename account while a migration is in progress"); + }, + migration_sing.get()); + } + } }; } // namespace eden diff --git a/contracts/eden/src/actions/induct.cpp b/contracts/eden/src/actions/induct.cpp index 1eff90827..94ccbecc7 100644 --- a/contracts/eden/src/actions/induct.cpp +++ b/contracts/eden/src/actions/induct.cpp @@ -237,4 +237,23 @@ namespace eden bylaws.on_resign(account); } + void eden::rename(eosio::name account, eosio::name new_account) + { + eosio::require_auth(new_account); + eosio::require_auth(eosio::permission_level{get_self(), "board.major"_n}); + members members{get_self()}; + members.check_active_member(account); + distributions dist{get_self()}; + dist.on_rename(account, new_account); + elections elections{get_self()}; + elections.on_rename(account, new_account); + inductions inductions{get_self()}; + inductions.on_rename(account, new_account); + members.rename(account, new_account); + bylaws bylaws{get_self()}; + bylaws.on_rename(account, new_account); + migrations migrations{get_self()}; + migrations.on_rename(account, new_account); + } + } // namespace eden diff --git a/contracts/eden/src/bylaws.cpp b/contracts/eden/src/bylaws.cpp index 916755e5a..ba0010297 100644 --- a/contracts/eden/src/bylaws.cpp +++ b/contracts/eden/src/bylaws.cpp @@ -123,5 +123,20 @@ namespace eden } } + void bylaws::on_rename(eosio::name old_account, eosio::name new_account) + { + for (auto key : {proposed, pending}) + { + auto pos = bylaws_tb.find(key.value); + if (pos != bylaws_tb.end()) + { + bylaws_tb.modify(pos, contract, [&](auto& row) { + std::replace(row.approvals().begin(), row.approvals().end(), old_account, + new_account); + }); + } + } + } + void bylaws::clear_all() { clear_table(bylaws_tb); } } // namespace eden diff --git a/contracts/eden/src/distributions.cpp b/contracts/eden/src/distributions.cpp index a952e8071..5503f664d 100644 --- a/contracts/eden/src/distributions.cpp +++ b/contracts/eden/src/distributions.cpp @@ -449,6 +449,31 @@ namespace eden } } + void distributions::on_rename(eosio::name old_account, eosio::name new_account) + { + { + distribution_table_type distribution_tb{contract, default_scope}; + auto iter = distribution_tb.begin(); + eosio::check(iter == distribution_tb.end() || + !std::holds_alternative(iter->value), + "Cannot rename member while a distribution is in progress"); + } + + accounts owned_accounts{contract, "owned"_n}; + setup_distribution(contract, owned_accounts); + auto member_idx = distribution_account_tb.get_index<"byowner"_n>(); + for (auto iter = member_idx.lower_bound(uint128_t(old_account.value) << 64), + end = member_idx.end(); + iter != end && iter->owner() == old_account;) + { + owned_accounts.add_balance("master"_n, iter->balance(), false); + auto next = iter; + ++next; + member_idx.modify(iter, contract, [&](auto& acct) { acct.owner() = new_account; }); + iter = next; + } + } + void distributions::clear_all() { clear_table(distribution_account_tb); diff --git a/contracts/eden/src/elections.cpp b/contracts/eden/src/elections.cpp index 71597ad26..9471fd719 100644 --- a/contracts/eden/src/elections.cpp +++ b/contracts/eden/src/elections.cpp @@ -1020,6 +1020,30 @@ namespace eden } } + void elections::on_rename(eosio::name old_account, eosio::name new_account) + { + eosio::check(!is_election_running(state_sing), "Cannot rename account during an election"); + + // Update the board + election_state_singleton global_state{contract, default_scope}; + if (!global_state.exists()) + { + return; + } + auto value = std::get(global_state.get()); + auto pos = std::find(value.board.begin(), value.board.end(), old_account); + if (pos != value.board.end()) + { + *pos = new_account; + global_state.set(value, contract); + set_board_permission(value.board); + } + if (old_account == value.lead_representative) + { + value.lead_representative = new_account; + } + } + boost::logic::tribool elections::can_upload_video(uint8_t round, eosio::name voter) { auto iter = vote_tb.find(voter.value); diff --git a/contracts/eden/src/inductions.cpp b/contracts/eden/src/inductions.cpp index 26c4d8e02..dc8264a00 100644 --- a/contracts/eden/src/inductions.cpp +++ b/contracts/eden/src/inductions.cpp @@ -435,6 +435,35 @@ namespace eden return pos != invitee_idx.end() && pos->invitee() == invitee; } + void inductions::on_rename(eosio::name old_account, eosio::name new_account) + { + eosio::check(!has_induction(old_account), "Cannot rename: gc required"); + // change all endorsements + auto endorser_idx = endorsement_tb.get_index<"byendorser"_n>(); + for (auto iter = endorser_idx.lower_bound(uint128_t{old_account.value} << 64), + end = endorser_idx.end(); + iter != end && iter->endorser() == old_account;) + { + auto next = iter; + ++next; + endorser_idx.modify(iter, contract, + [&](auto& endorsement) { endorsement.endorser() = new_account; }); + iter = next; + } + // change all inductions with old_account as inviter + auto inviter_idx = induction_tb.get_index<"byinviter"_n>(); + for (auto iter = inviter_idx.lower_bound(combine_names(old_account, ""_n)), + end = inviter_idx.end(); + iter != end && iter->inviter() == old_account;) + { + auto next = iter; + ++next; + inviter_idx.modify(iter, contract, + [&](auto& invitation) { invitation.inviter() = new_account; }); + iter = next; + } + } + void inductions::clear_all() { clear_table(induction_tb); diff --git a/contracts/eden/src/members.cpp b/contracts/eden/src/members.cpp index bd32617eb..b8d5edfab 100644 --- a/contracts/eden/src/members.cpp +++ b/contracts/eden/src/members.cpp @@ -128,6 +128,35 @@ namespace eden } } + void members::rename(eosio::name account, eosio::name new_account) + { + auto iter = member_tb.find(account.value); + std::uint8_t rank = iter->election_rank(); + eosio::check(iter != member_tb.end(), "Unknown member"); + remove_sessions(contract, account); + // Update the members table entry + member_tb.emplace(contract, [&](auto& new_member) { + new_member = *iter; + new_member.account() = new_account; + }); + member_tb.erase(iter); + // update delegate records + auto delegate_idx = member_tb.get_index<"byrep"_n>(); + for (uint8_t i = 0; i <= rank; ++i) + { + for (auto iter = delegate_idx.lower_bound((uint128_t{i} << 64) | account.value), + end = delegate_idx.end(); + iter != end && iter->representative() == account;) + { + auto next = iter; + ++next; + delegate_idx.modify(iter, contract, + [&](auto& member) { member.representative() = new_account; }); + iter = next; + } + } + } + void members::set_nft(eosio::name account, int32_t nft_template_id) { check_pending_member(account); diff --git a/contracts/eden/tests/test-eden.cpp b/contracts/eden/tests/test-eden.cpp index 84b77eef0..4df582adf 100644 --- a/contracts/eden/tests/test-eden.cpp +++ b/contracts/eden/tests/test-eden.cpp @@ -482,6 +482,21 @@ TEST_CASE("board resignation") t.pip.act("pip"_n); } +TEST_CASE("renaming") +{ + eden_tester t; + t.genesis(); + t.run_election(); + t.chain.transact( + {eosio::action{{"eden.gm"_n, "active"_n}, + "eosio"_n, + "linkauth"_n, + std::tuple("eden.gm"_n, "eden.gm"_n, "rename"_n, "board.major"_n)}}); + t.alice.act(100); + test_chain::user_context{t.chain, {{"eden.gm"_n, "board.major"_n}, {"ahab"_n, "active"_n}}} + .act("alice"_n, "ahab"_n); +} + TEST_CASE("auction") { eden_tester t; From 7d76842babd32f6c0eb5cd70f377cecd236a96cd Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Thu, 3 Feb 2022 10:34:45 -0500 Subject: [PATCH 2/5] Add tests for access to funds after rename. --- contracts/eden/include/accounts.hpp | 2 +- contracts/eden/include/elections.hpp | 3 ++- contracts/eden/src/accounts.cpp | 13 +++++++++++++ contracts/eden/src/actions/genesis.cpp | 2 ++ contracts/eden/src/actions/induct.cpp | 2 ++ contracts/eden/src/elections.cpp | 9 +++++++++ contracts/eden/tests/test-eden.cpp | 25 ++++++++++++++++++++----- 7 files changed, 49 insertions(+), 7 deletions(-) diff --git a/contracts/eden/include/accounts.hpp b/contracts/eden/include/accounts.hpp index 87fa35103..6b7dd4c7a 100644 --- a/contracts/eden/include/accounts.hpp +++ b/contracts/eden/include/accounts.hpp @@ -75,7 +75,7 @@ namespace eden std::optional get_account(eosio::name owner); void add_balance(eosio::name owner, const eosio::asset& quantity, bool enforce_minimum); void sub_balance(eosio::name owner, const eosio::asset& quantity); - void rename(eosio::name old_account, eosio::name new_account); + void on_rename(eosio::name old_account, eosio::name new_account); // this method is used only for administrative purposes, // it should never be used outside genesis or test environments diff --git a/contracts/eden/include/elections.hpp b/contracts/eden/include/elections.hpp index a1399da44..c7c087ae4 100644 --- a/contracts/eden/include/elections.hpp +++ b/contracts/eden/include/elections.hpp @@ -270,7 +270,6 @@ namespace eden uint32_t randomize_voters(current_election_state_init_voters_v0& state, uint32_t max_steps); std::vector extract_board(); void finish_election(std::vector&& board, eosio::name winner); - void set_board_permission(const std::vector& board); bool remove_from_board(eosio::name member); public: @@ -281,6 +280,8 @@ namespace eden globals(contract) { } + void set_board_permission(const std::vector& board); + void link_board_permission(); std::optional get_next_election_time(); std::uint8_t election_schedule_version(); void set_time(uint8_t day, const std::string& time); diff --git a/contracts/eden/src/accounts.cpp b/contracts/eden/src/accounts.cpp index 814d00bf0..e320f639b 100644 --- a/contracts/eden/src/accounts.cpp +++ b/contracts/eden/src/accounts.cpp @@ -115,6 +115,19 @@ namespace eden account_tb.modify(record, contract, [&](auto& r) { r.balance() -= quantity; }); } + void accounts::on_rename(eosio::name old_account, eosio::name new_account) + { + auto record = account_tb.find(old_account.value); + if (record != account_tb.end()) + { + account_tb.emplace(contract, [&](auto& new_record) { + new_record = *record; + new_record.owner() = new_account; + }); + account_tb.erase(record); + } + } + void accounts::clear_all() { clear_table(account_tb); } void add_to_pool(eosio::name contract, eosio::name pool, eosio::asset amount) diff --git a/contracts/eden/src/actions/genesis.cpp b/contracts/eden/src/actions/genesis.cpp index 41fc48112..bd101d7cb 100644 --- a/contracts/eden/src/actions/genesis.cpp +++ b/contracts/eden/src/actions/genesis.cpp @@ -131,6 +131,8 @@ namespace eden elections elections{get_self()}; elections.set_time(election_day, election_time); + elections.set_board_permission({}); + elections.link_board_permission(); auto inviter = get_self(); auto total_endorsements = initial_members.size() - 1; diff --git a/contracts/eden/src/actions/induct.cpp b/contracts/eden/src/actions/induct.cpp index 94ccbecc7..39dff64cd 100644 --- a/contracts/eden/src/actions/induct.cpp +++ b/contracts/eden/src/actions/induct.cpp @@ -241,6 +241,8 @@ namespace eden { eosio::require_auth(new_account); eosio::require_auth(eosio::permission_level{get_self(), "board.major"_n}); + accounts accounts{get_self()}; + accounts.on_rename(account, new_account); members members{get_self()}; members.check_active_member(account); distributions dist{get_self()}; diff --git a/contracts/eden/src/elections.cpp b/contracts/eden/src/elections.cpp index 9471fd719..2e8587d2c 100644 --- a/contracts/eden/src/elections.cpp +++ b/contracts/eden/src/elections.cpp @@ -736,6 +736,15 @@ namespace eden .send(); } + void elections::link_board_permission() + { + eosio::action{{contract, "active"_n}, + "eosio"_n, + "linkauth"_n, + std::tuple(contract, contract, "rename"_n, "board.major"_n)} + .send(); + } + void elections::finish_election(std::vector&& board, eosio::name winner) { election_state_singleton results(contract, default_scope); diff --git a/contracts/eden/tests/test-eden.cpp b/contracts/eden/tests/test-eden.cpp index 4df582adf..fd6176c7d 100644 --- a/contracts/eden/tests/test-eden.cpp +++ b/contracts/eden/tests/test-eden.cpp @@ -486,15 +486,26 @@ TEST_CASE("renaming") { eden_tester t; t.genesis(); + auto distribution_time = t.next_election_time(); t.run_election(); - t.chain.transact( - {eosio::action{{"eden.gm"_n, "active"_n}, - "eosio"_n, - "linkauth"_n, - std::tuple("eden.gm"_n, "eden.gm"_n, "rename"_n, "board.major"_n)}}); t.alice.act(100); + t.alice.act("alice"_n, distribution_time, 1, "alice"_n, s2a("0.0001 EOS"), + ""); test_chain::user_context{t.chain, {{"eden.gm"_n, "board.major"_n}, {"ahab"_n, "active"_n}}} .act("alice"_n, "ahab"_n); + + expect(t.alice.trace("alice"_n, s2a("0.0001 EOS")), "insufficient balance"); + t.ahab.act("ahab"_n, s2a("0.0001 EOS")); + + t.chain.start_block(); + expect(t.alice.trace("alice"_n, distribution_time, 1, "alice"_n, + s2a("0.0001 EOS"), ""), + "member alice not found"); + t.ahab.act("ahab"_n, distribution_time, 1, "ahab"_n, s2a("0.0001 EOS"), + ""); + + CHECK(get_eden_membership("pip"_n).representative() == "ahab"_n); + CHECK(get_eden_membership("ahab"_n).representative() == "ahab"_n); } TEST_CASE("auction") @@ -1191,6 +1202,10 @@ TEST_CASE("clearall") eden_tester t; t.genesis(); t.eden_gm.act(); + t.chain.transact({{{"eden.gm"_n, "active"_n}, + "eosio"_n, + "unlinkauth"_n, + std::tuple("eden.gm"_n, "eden.gm"_n, "rename"_n)}}); t.chain.start_block(); t.genesis(); } From d63c4a9861628331bf49df3b7826c3f7c6edb524 Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Tue, 22 Feb 2022 10:29:34 -0500 Subject: [PATCH 3/5] Remove incorrect balance adjustment. --- contracts/eden/src/distributions.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/contracts/eden/src/distributions.cpp b/contracts/eden/src/distributions.cpp index 5503f664d..788510bc4 100644 --- a/contracts/eden/src/distributions.cpp +++ b/contracts/eden/src/distributions.cpp @@ -466,7 +466,6 @@ namespace eden end = member_idx.end(); iter != end && iter->owner() == old_account;) { - owned_accounts.add_balance("master"_n, iter->balance(), false); auto next = iter; ++next; member_idx.modify(iter, contract, [&](auto& acct) { acct.owner() = new_account; }); From d134c5313726371b16c9576ee0ee5b7941ff53d5 Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Tue, 22 Feb 2022 10:31:04 -0500 Subject: [PATCH 4/5] Forbid current inviters from being renamed. An invition implies recent activity, so this is not a significant limitation. --- contracts/eden/src/inductions.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/contracts/eden/src/inductions.cpp b/contracts/eden/src/inductions.cpp index dc8264a00..b5f6d12f0 100644 --- a/contracts/eden/src/inductions.cpp +++ b/contracts/eden/src/inductions.cpp @@ -450,18 +450,10 @@ namespace eden [&](auto& endorsement) { endorsement.endorser() = new_account; }); iter = next; } - // change all inductions with old_account as inviter auto inviter_idx = induction_tb.get_index<"byinviter"_n>(); - for (auto iter = inviter_idx.lower_bound(combine_names(old_account, ""_n)), - end = inviter_idx.end(); - iter != end && iter->inviter() == old_account;) - { - auto next = iter; - ++next; - inviter_idx.modify(iter, contract, - [&](auto& invitation) { invitation.inviter() = new_account; }); - iter = next; - } + auto iter = inviter_idx.lower_bound(combine_names(old_account, ""_n)); + eosio::check(iter == inviter_idx.end() || iter->inviter() != old_account, + "Cannot rename an account that is the inviter of a pending invitation"); } void inductions::clear_all() From f0f1c0c93ff3ea8b247d26b5c3823bb252892c4d Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Wed, 23 Feb 2022 09:04:28 -0500 Subject: [PATCH 5/5] Feedback --- contracts/eden/src/elections.cpp | 1 + contracts/eden/src/members.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/contracts/eden/src/elections.cpp b/contracts/eden/src/elections.cpp index 2e8587d2c..3e252000a 100644 --- a/contracts/eden/src/elections.cpp +++ b/contracts/eden/src/elections.cpp @@ -1050,6 +1050,7 @@ namespace eden if (old_account == value.lead_representative) { value.lead_representative = new_account; + global_state.set(value, contract); } } diff --git a/contracts/eden/src/members.cpp b/contracts/eden/src/members.cpp index b8d5edfab..f8d0fe211 100644 --- a/contracts/eden/src/members.cpp +++ b/contracts/eden/src/members.cpp @@ -131,8 +131,8 @@ namespace eden void members::rename(eosio::name account, eosio::name new_account) { auto iter = member_tb.find(account.value); - std::uint8_t rank = iter->election_rank(); eosio::check(iter != member_tb.end(), "Unknown member"); + std::uint8_t rank = iter->election_rank(); remove_sessions(contract, account); // Update the members table entry member_tb.emplace(contract, [&](auto& new_member) {