diff --git a/community/community.abi b/community/community.abi index 512ba4c..b8ab306 100644 --- a/community/community.abi +++ b/community/community.abi @@ -553,6 +553,20 @@ } ] }, + { + "name": "revokebadge", + "base": "", + "fields": [ + { + "name": "community_account", + "type": "name" + }, + { + "name": "revoke_badge_propose_name", + "type": "name" + } + ] + }, { "name": "setaccess", "base": "", @@ -1319,6 +1333,11 @@ "type": "proposecode", "ricardian_contract": "" }, + { + "name": "revokebadge", + "type": "revokebadge", + "ricardian_contract": "" + }, { "name": "setaccess", "type": "setaccess", @@ -1429,7 +1448,7 @@ "key_types": [] }, { - "name": "v1.cert", + "name": "v1.certs", "type": "v1_cert", "index_type": "i64", "key_names": [], diff --git a/community/community.wasm b/community/community.wasm index 45183be..db52f4b 100755 Binary files a/community/community.wasm and b/community/community.wasm differ diff --git a/community/include/community.hpp b/community/include/community.hpp index 51c5897..1e4f8b7 100644 --- a/community/include/community.hpp +++ b/community/include/community.hpp @@ -61,6 +61,7 @@ CONTRACT community : public contract POSITION_DISMISS, BADGE_CONFIG, BADGE_ISSUE, + BADGE_REVOKE, }; enum BadgeIssueType { @@ -247,6 +248,8 @@ CONTRACT community : public contract ACTION issuebadge(name community_account, name badge_propose_name); + ACTION revokebadge(name community_account, name revoke_badge_propose_name); + ACTION setconfig( name community_creator_name, name cryptobadge_contract_name, @@ -260,6 +263,25 @@ CONTRACT community : public contract ); private: + void create_issue_badge_code( + name community_account, + uint64_t badge_id, + uint8_t issue_type, + uint8_t issue_exec_type, + RightHolder right_issue_sole_executor, + RightHolder right_issue_proposer, + uint8_t issue_approval_type, + RightHolder right_issue_approver, + RightHolder right_issue_voter, + double issue_pass_rule, + uint64_t issue_vote_duration, + name ram_payer + ); + + void create_config_badge_code_for_admin(name community_account, uint64_t badge_id, name ram_payer); + + void create_revoke_badge_code_for_admin(name community_account, uint64_t badge_id, name ram_payer); + bool verify_approver(name community_account, name voter, uint64_t code_id, bool is_ammnend_code); bool verify_voter(name community_account, name voter, uint64_t code_id, bool is_amend_code); @@ -552,7 +574,7 @@ CONTRACT community : public contract } }; - typedef eosio::multi_index<"v1.cert"_n, v1_cert, + typedef eosio::multi_index<"v1.certs"_n, v1_cert, eosio::indexed_by<"badgeid"_n, eosio::const_mem_fun>, eosio::indexed_by<"owner"_n, eosio::const_mem_fun>> v1_cert_table; diff --git a/community/src/community.cpp b/community/src/community.cpp index 491c78c..13b6b42 100644 --- a/community/src/community.cpp +++ b/community/src/community.cpp @@ -32,12 +32,14 @@ const name BA_Create = "ba.create"_n; const name BA_Issue = "ba.issue"_n; const name BA_Claim = "ba.claim"_n; const name BA_Config = "ba.config"_n; +const name BA_Revoke = "ba.revoke"_n; const name BA_Adopt = "ba.adopt"_n; const name BA_Discard = "ba.discard"_n; const name badge_update_action = "updatebadge"_n; const name badge_create_action = "createbadge"_n; const name badge_issue_action = "issuebadge"_n; +const name cert_revoke_action = "revokecert"_n; struct createbadge_params { @@ -73,6 +75,14 @@ struct issuebadge_params bool require_claim; }; +struct revokecert_params +{ + name issuer; + uint64_t cert_id; + name owner; + string reason; +}; + void community::transfer(name from, name to, asset quantity, string memo) { if (from == _self) @@ -504,7 +514,7 @@ ACTION community::execcode(name community_account, name exec_account, uint64_t c packed_params_datastream >> packed_refer_id; check(code_itr->code_type.refer_id == packed_refer_id, "ERR:INVALID_BADGE_POSITION_CODE::Please use correct code to execute badge/position action"); } - else if (execution_data.code_action == "issuebadge"_n) + else if (execution_data.code_action == "issuebadge"_n || execution_data.code_action == "revokebadge"_n) { name packed_proposal_name; packed_params_datastream >> packed_proposal_name; @@ -522,6 +532,18 @@ ACTION community::execcode(name community_account, name exec_account, uint64_t c check(cb_data.issuer == community_account, "ERR::ISSUE_BADGE_PROPOSAL_INVALID::Issuer in issue badge proposal not the same with community account"); check(cb_data.badge_id == code_itr->code_type.refer_id, "ERR:INVALID_BADGE_POSITION_CODE::Please use correct code to execute badge/position action"); } + + if (action.account == _config.cryptobadge_contract_name && action.name == cert_revoke_action) + { + auto cb_data = unpack(&action.data[0], action.data.size()); + + check(cb_data.issuer == community_account, "ERR::REVOKE_BADGE_PROPOSAL_INVALID::Issuer in issue badge proposal not the same with community account"); + + v1_cert_table _badges(_config.cryptobadge_contract_name, cb_data.owner.value); + auto owner_badge_itr = _badges.find(cb_data.cert_id); + check(owner_badge_itr != _badges.end(), "ERR::REVOKE_BADGE_PROPOSAL_INVALID::Certification does not exist"); + check(owner_badge_itr->badge_id == code_itr->code_type.refer_id, "ERR:INVALID_BADGE_POSITION_CODE::Please use correct code to execute badge/position action"); + } } } } @@ -1951,8 +1973,8 @@ ACTION community::createbadge( RightHolder right_issue_approver, RightHolder right_issue_voter, double issue_pass_rule, - uint64_t issue_vote_duration) -{ + uint64_t issue_vote_duration +){ require_auth(community_account); v1_global_table config(_self, _self.value); @@ -1999,6 +2021,80 @@ ACTION community::createbadge( std::make_tuple(cryptobadge_contract, badge_propose_name, ram_payer)) .send(); + create_issue_badge_code( + community_account, + badge_id, + issue_type, + issue_exec_type, + right_issue_sole_executor, + right_issue_proposer, + issue_approval_type, + right_issue_approver, + right_issue_voter, + issue_pass_rule, + issue_vote_duration, + ram_payer + ); + + create_config_badge_code_for_admin(community_account, badge_id, ram_payer); + + create_revoke_badge_code_for_admin(community_account, badge_id, ram_payer); +} + +ACTION community::configbadge( + name community_account, + uint64_t badge_id, + uint8_t issue_type, + name update_badge_proposal_name) +{ + require_auth(community_account); + + v1_global_table config(_self, _self.value); + _config = config.exists() ? config.get() : v1_global{}; + const name ram_payer_system = _config.ram_payer_name; + const name cryptobadge_contract = _config.cryptobadge_contract_name; + + auto ram_payer = community_account; + if (has_auth(ram_payer_system)) + ram_payer = ram_payer_system; + + if (update_badge_proposal_name != name("")) + { + multisig_proposals proptable("eosio.msig"_n, cryptobadge_contract.value); + auto &prop = proptable.get(update_badge_proposal_name.value, "proposal not found"); + transaction trx; + datastream ds(prop.packed_transaction.data(), prop.packed_transaction.size()); + ds >> trx; + for (auto action : trx.actions) + { + if (action.account == cryptobadge_contract && action.name == badge_update_action) + { + auto cb_data = unpack(&action.data[0], action.data.size()); + + check(cb_data.issuer == community_account, "ERR::CREATE_BADGE_PROPOSAL_INVALID::Issuer in update badge proposal not the same with community account"); + check(cb_data.badge_id == badge_id, "ERR::CREATE_BADGE_PROPOSAL_INVALID::Issuer in update badge proposal not the same with config badge id"); + } + } + + action( + permission_level{community_account, "active"_n}, + "eosio.msig"_n, + "approve"_n, + std::make_tuple(cryptobadge_contract, update_badge_proposal_name, permission_level{community_account, "active"_n})) + .send(); + + vector action_permission = {{community_account, "active"_n}}; + if (ram_payer == ram_payer_system) + action_permission.push_back({ram_payer_system, "active"_n}); + + action( + action_permission, + "eosio.msig"_n, + "exec"_n, + std::make_tuple(cryptobadge_contract, update_badge_proposal_name, ram_payer)) + .send(); + } + v1_code_table _codes(_self, community_account.value); v1_code_sole_decision_table _code_execution_rule(_self, community_account.value); @@ -2009,11 +2105,167 @@ ACTION community::createbadge( v1_position_table _positions(_self, community_account.value); - auto getByCodeName = _codes.get_index<"by.code.name"_n>(); - auto ba_create_code = getByCodeName.find(BA_Create.value); + name issue_badge_code_name; + if (issue_type == BadgeIssueType::WITHOUT_CLAIM) + { + issue_badge_code_name = BA_Issue; + } + else if (issue_type == BadgeIssueType::CLAIM_APPROVE_BY_ISSUER) + { + issue_badge_code_name = BA_Claim; + } + else + { + check(false, "ERR::BADGE_ISSUE_TYPE_INVALID::Badge issue type is invalid"); + } - vector code_actions; - code_actions.push_back("issuebadge"_n); + auto getByCodeReferId = _codes.get_index<"by.refer.id"_n>(); + uint128_t issue_badge_reference_id = build_reference_id(badge_id, CodeTypeEnum::BADGE_ISSUE); + auto issue_badge_code_itr = getByCodeReferId.find(issue_badge_reference_id); + uint64_t issue_badge_code_id; + + // save new code to the table + if (issue_badge_code_itr == getByCodeReferId.end()) + { + vector code_actions; + code_actions.push_back("issuebadge"_n); + auto new_issue_badge_code = _codes.emplace(ram_payer, [&](auto &row) { + row.code_id = _codes.available_primary_key(); + row.code_name = issue_badge_code_name; + row.contract_name = get_self(); + row.code_actions = code_actions; + row.code_type = {CodeTypeEnum::BADGE_ISSUE, badge_id}; + }); + issue_badge_code_id = new_issue_badge_code->code_id; + } + else + { + getByCodeReferId.modify(issue_badge_code_itr, ram_payer, [&](auto &row) { + row.code_name = issue_badge_code_name; + row.code_type = {CodeTypeEnum::BADGE_ISSUE, badge_id}; + }); + issue_badge_code_id = issue_badge_code_itr->code_id; + } +} + +ACTION community::issuebadge(name community_account, name badge_propose_name) +{ + require_auth(community_account); + + v1_global_table config(_self, _self.value); + _config = config.exists() ? config.get() : v1_global{}; + const name ram_payer_system = _config.ram_payer_name; + const name cryptobadge_contract = _config.cryptobadge_contract_name; + + auto ram_payer = community_account; + if (has_auth(ram_payer_system)) + ram_payer = ram_payer_system; + + action( + permission_level{community_account, "active"_n}, + "eosio.msig"_n, + "approve"_n, + std::make_tuple(cryptobadge_contract, badge_propose_name, permission_level{community_account, "active"_n})) + .send(); + + vector action_permission = {{community_account, "active"_n}}; + if (ram_payer == ram_payer_system) + action_permission.push_back({ram_payer_system, "active"_n}); + + action( + action_permission, + "eosio.msig"_n, + "exec"_n, + std::make_tuple(cryptobadge_contract, badge_propose_name, ram_payer)) + .send(); +} + +ACTION community::revokebadge(name community_account, name revoke_badge_propose_name) +{ + require_auth(community_account); + + v1_global_table config(_self, _self.value); + _config = config.exists() ? config.get() : v1_global{}; + const name ram_payer_system = _config.ram_payer_name; + const name cryptobadge_contract = _config.cryptobadge_contract_name; + + auto ram_payer = community_account; + if (has_auth(ram_payer_system)) + ram_payer = ram_payer_system; + + action( + permission_level{community_account, "active"_n}, + "eosio.msig"_n, + "approve"_n, + std::make_tuple(cryptobadge_contract, revoke_badge_propose_name, permission_level{community_account, "active"_n})) + .send(); + + vector action_permission = {{community_account, "active"_n}}; + if (ram_payer == ram_payer_system) + action_permission.push_back({ram_payer_system, "active"_n}); + + action( + action_permission, + "eosio.msig"_n, + "exec"_n, + std::make_tuple(cryptobadge_contract, revoke_badge_propose_name, ram_payer)) + .send(); +} + +ACTION community::setconfig( + name community_creator_name, + name cryptobadge_contract_name, + name token_contract_name, + name ram_payer_name, + symbol core_symbol, + uint64_t init_ram_amount, + asset min_active_contract, + asset init_net, + asset init_cpu +){ + require_auth(_self); + + v1_global_table config(_self, _self.value); + _config = config.exists() ? config.get() : v1_global{}; + + _config.community_creator_name = community_creator_name; + _config.cryptobadge_contract_name = cryptobadge_contract_name; + _config.token_contract_name = token_contract_name; + _config.ram_payer_name = ram_payer_name; + _config.core_symbol = core_symbol; + _config.init_ram_amount = init_ram_amount; + _config.init_net = init_net; + _config.init_cpu = init_cpu; + _config.min_active_contract = min_active_contract; + + config.set(_config, _self); +} + +void community::create_issue_badge_code( + name community_account, + uint64_t badge_id, + uint8_t issue_type, + uint8_t issue_exec_type, + RightHolder right_issue_sole_executor, + RightHolder right_issue_proposer, + uint8_t issue_approval_type, + RightHolder right_issue_approver, + RightHolder right_issue_voter, + double issue_pass_rule, + uint64_t issue_vote_duration, + name ram_payer + ) { + v1_code_table _codes(_self, community_account.value); + + v1_code_sole_decision_table _code_execution_rule(_self, community_account.value); + v1_amend_sole_decision_table _amend_execution_rule(_self, community_account.value); + + v1_code_collective_decision_table _code_vote_rule(_self, community_account.value); + v1_ammend_collective_decision_table _amend_vote_rule(_self, community_account.value); + + v1_position_table _positions(_self, community_account.value); + + auto getByCodeName = _codes.get_index<"by.code.name"_n>(); name issue_badge_code_name; if (issue_type == BadgeIssueType::WITHOUT_CLAIM) @@ -2029,6 +2281,9 @@ ACTION community::createbadge( check(false, "ERR::BADGE_ISSUE_TYPE_INVALID::Badge issue type is invalid"); } + vector code_actions; + code_actions.push_back("issuebadge"_n); + auto getByCodeReferId = _codes.get_index<"by.refer.id"_n>(); uint128_t issue_badge_reference_id = build_reference_id(badge_id, CodeTypeEnum::BADGE_ISSUE); @@ -2124,8 +2379,23 @@ ACTION community::createbadge( }); } } +} - code_actions.clear(); +void community::create_config_badge_code_for_admin(name community_account, uint64_t badge_id, name ram_payer) { + v1_code_table _codes(_self, community_account.value); + + v1_code_sole_decision_table _code_execution_rule(_self, community_account.value); + v1_amend_sole_decision_table _amend_execution_rule(_self, community_account.value); + + v1_code_collective_decision_table _code_vote_rule(_self, community_account.value); + v1_ammend_collective_decision_table _amend_vote_rule(_self, community_account.value); + + v1_position_table _positions(_self, community_account.value); + + auto getByCodeName = _codes.get_index<"by.code.name"_n>(); + auto getByCodeReferId = _codes.get_index<"by.refer.id"_n>(); + + vector code_actions; code_actions.push_back("configbadge"_n); uint128_t config_badge_reference_id = build_reference_id(badge_id, CodeTypeEnum::BADGE_CONFIG); @@ -2148,7 +2418,7 @@ ACTION community::createbadge( else { getByCodeReferId.modify(config_badge_code_itr, ram_payer, [&](auto &row) { - row.code_name = issue_badge_code_name; + row.code_name = BA_Config; row.code_exec_type = ExecutionType::SOLE_DECISION; row.code_type = {CodeTypeEnum::BADGE_CONFIG, badge_id}; }); @@ -2181,60 +2451,7 @@ ACTION community::createbadge( } } -ACTION community::configbadge( - name community_account, - uint64_t badge_id, - uint8_t issue_type, - name update_badge_proposal_name) -{ - require_auth(community_account); - - v1_global_table config(_self, _self.value); - _config = config.exists() ? config.get() : v1_global{}; - const name ram_payer_system = _config.ram_payer_name; - const name cryptobadge_contract = _config.cryptobadge_contract_name; - - auto ram_payer = community_account; - if (has_auth(ram_payer_system)) - ram_payer = ram_payer_system; - - if (update_badge_proposal_name != name("")) - { - multisig_proposals proptable("eosio.msig"_n, cryptobadge_contract.value); - auto &prop = proptable.get(update_badge_proposal_name.value, "proposal not found"); - transaction trx; - datastream ds(prop.packed_transaction.data(), prop.packed_transaction.size()); - ds >> trx; - for (auto action : trx.actions) - { - if (action.account == cryptobadge_contract && action.name == badge_update_action) - { - auto cb_data = unpack(&action.data[0], action.data.size()); - - check(cb_data.issuer == community_account, "ERR::CREATE_BADGE_PROPOSAL_INVALID::Issuer in update badge proposal not the same with community account"); - check(cb_data.badge_id == badge_id, "ERR::CREATE_BADGE_PROPOSAL_INVALID::Issuer in update badge proposal not the same with config badge id"); - } - } - - action( - permission_level{community_account, "active"_n}, - "eosio.msig"_n, - "approve"_n, - std::make_tuple(cryptobadge_contract, update_badge_proposal_name, permission_level{community_account, "active"_n})) - .send(); - - vector action_permission = {{community_account, "active"_n}}; - if (ram_payer == ram_payer_system) - action_permission.push_back({ram_payer_system, "active"_n}); - - action( - action_permission, - "eosio.msig"_n, - "exec"_n, - std::make_tuple(cryptobadge_contract, update_badge_proposal_name, ram_payer)) - .send(); - } - +void community::create_revoke_badge_code_for_admin(name community_account, uint64_t badge_id, name ram_payer) { v1_code_table _codes(_self, community_account.value); v1_code_sole_decision_table _code_execution_rule(_self, community_account.value); @@ -2245,108 +2462,63 @@ ACTION community::configbadge( v1_position_table _positions(_self, community_account.value); - name issue_badge_code_name; - if (issue_type == BadgeIssueType::WITHOUT_CLAIM) - { - issue_badge_code_name = BA_Issue; - } - else if (issue_type == BadgeIssueType::CLAIM_APPROVE_BY_ISSUER) - { - issue_badge_code_name = BA_Claim; - } - else - { - check(false, "ERR::BADGE_ISSUE_TYPE_INVALID::Badge issue type is invalid"); - } - + auto getByCodeName = _codes.get_index<"by.code.name"_n>(); auto getByCodeReferId = _codes.get_index<"by.refer.id"_n>(); - uint128_t issue_badge_reference_id = build_reference_id(badge_id, CodeTypeEnum::BADGE_ISSUE); - auto issue_badge_code_itr = getByCodeReferId.find(issue_badge_reference_id); - uint64_t issue_badge_code_id; - // save new code to the table - if (issue_badge_code_itr == getByCodeReferId.end()) + vector code_actions; + code_actions.push_back("revokebadge"_n); + + uint128_t revoke_badge_reference_id = build_reference_id(badge_id, CodeTypeEnum::BADGE_REVOKE); + auto revoke_badge_code_itr = getByCodeReferId.find(revoke_badge_reference_id); + uint64_t revoke_badge_code_id; + + // save revoke badge code to the table + if (revoke_badge_code_itr == getByCodeReferId.end()) { - vector code_actions; - code_actions.push_back("issuebadge"_n); - auto new_issue_badge_code = _codes.emplace(ram_payer, [&](auto &row) { + auto new_revoke_badge_code = _codes.emplace(ram_payer, [&](auto &row) { row.code_id = _codes.available_primary_key(); - row.code_name = issue_badge_code_name; + row.code_name = BA_Revoke; row.contract_name = get_self(); row.code_actions = code_actions; - row.code_type = {CodeTypeEnum::BADGE_ISSUE, badge_id}; + row.amendment_exec_type = ExecutionType::SOLE_DECISION; + row.code_type = {CodeTypeEnum::BADGE_REVOKE, badge_id}; }); - issue_badge_code_id = new_issue_badge_code->code_id; + revoke_badge_code_id = new_revoke_badge_code->code_id; } else { - getByCodeReferId.modify(issue_badge_code_itr, ram_payer, [&](auto &row) { - row.code_name = issue_badge_code_name; - row.code_type = {CodeTypeEnum::BADGE_ISSUE, badge_id}; + getByCodeReferId.modify(revoke_badge_code_itr, ram_payer, [&](auto &row) { + row.code_name = BA_Revoke; + row.code_exec_type = ExecutionType::SOLE_DECISION; + row.code_type = {CodeTypeEnum::BADGE_REVOKE, badge_id}; }); - issue_badge_code_id = issue_badge_code_itr->code_id; + revoke_badge_code_id = revoke_badge_code_itr->code_id; } -} - -ACTION community::issuebadge(name community_account, name badge_propose_name) -{ - require_auth(community_account); - - v1_global_table config(_self, _self.value); - _config = config.exists() ? config.get() : v1_global{}; - const name ram_payer_system = _config.ram_payer_name; - const name cryptobadge_contract = _config.cryptobadge_contract_name; - auto ram_payer = community_account; - if (has_auth(ram_payer_system)) - ram_payer = ram_payer_system; - - action( - permission_level{community_account, "active"_n}, - "eosio.msig"_n, - "approve"_n, - std::make_tuple(cryptobadge_contract, badge_propose_name, permission_level{community_account, "active"_n})) - .send(); - - vector action_permission = {{community_account, "active"_n}}; - if (ram_payer == ram_payer_system) - action_permission.push_back({ram_payer_system, "active"_n}); - - action( - action_permission, - "eosio.msig"_n, - "exec"_n, - std::make_tuple(cryptobadge_contract, badge_propose_name, ram_payer)) - .send(); -} - -ACTION community::setconfig( - name community_creator_name, - name cryptobadge_contract_name, - name token_contract_name, - name ram_payer_name, - symbol core_symbol, - uint64_t init_ram_amount, - asset min_active_contract, - asset init_net, - asset init_cpu) -{ - require_auth(_self); - - v1_global_table config(_self, _self.value); - _config = config.exists() ? config.get() : v1_global{}; + auto revoke_badge_code_sole_decision = _code_execution_rule.find(revoke_badge_code_id); + auto revoke_badge_amend_code_sole_decision = _amend_execution_rule.find(revoke_badge_code_id); + if (revoke_badge_code_sole_decision == _code_execution_rule.end()) + { + _amend_execution_rule.emplace(ram_payer, [&](auto &row) { + row.code_id = revoke_badge_code_id; + row.right_executor = admin_right_holder(); + }); - _config.community_creator_name = community_creator_name; - _config.cryptobadge_contract_name = cryptobadge_contract_name; - _config.token_contract_name = token_contract_name; - _config.ram_payer_name = ram_payer_name; - _config.core_symbol = core_symbol; - _config.init_ram_amount = init_ram_amount; - _config.init_net = init_net; - _config.init_cpu = init_cpu; - _config.min_active_contract = min_active_contract; + _code_execution_rule.emplace(ram_payer, [&](auto &row) { + row.code_id = revoke_badge_code_id; + row.right_executor = admin_right_holder(); + }); + } + else + { + _amend_execution_rule.modify(revoke_badge_amend_code_sole_decision, ram_payer, [&](auto &row) { + row.right_executor = admin_right_holder(); + }); - config.set(_config, _self); + _code_execution_rule.modify(revoke_badge_code_sole_decision, ram_payer, [&](auto &row) { + row.right_executor = admin_right_holder(); + }); + } } bool community::verify_voter(name community_account, name voter, uint64_t code_id, bool is_amend_code) @@ -2432,8 +2604,9 @@ bool community::is_pos_candidate(name community_account, uint64_t pos_id, name o for (int i = 0; i < _required_badge_ids.size(); i++) { v1_cert_table _badges(cryptobadge_contract, owner.value); - auto owner_badge_itr = _badges.find(_required_badge_ids[i]); - if (owner_badge_itr != _badges.end()) + auto get_cert_by_badge_id = _badges.get_index<"badgeid"_n>(); + auto owner_badge_itr = get_cert_by_badge_id.find(_required_badge_ids[i]); + if (owner_badge_itr != get_cert_by_badge_id.end()) { return true; } @@ -2491,8 +2664,9 @@ bool community::is_pos_voter(name community_account, uint64_t pos_id, name owner for (int i = 0; i < _required_badge_ids.size(); i++) { v1_cert_table _badges(cryptobadge_contract, owner.value); - auto owner_badge_itr = _badges.find(_required_badge_ids[i]); - if (owner_badge_itr != _badges.end()) + auto get_cert_by_badge_id = _badges.get_index<"badgeid"_n>(); + auto owner_badge_itr = get_cert_by_badge_id.find(_required_badge_ids[i]); + if (owner_badge_itr != get_cert_by_badge_id.end()) { return true; } @@ -2548,8 +2722,9 @@ bool community::verify_account_right_holder(name community_account, RightHolder for (int i = 0; i < _required_badge_ids.size(); i++) { v1_cert_table _badges(cryptobadge_contract, owner.value); - auto owner_badge_itr = _badges.find(_required_badge_ids[i]); - if (owner_badge_itr != _badges.end()) + auto get_cert_by_badge_id = _badges.get_index<"badgeid"_n>(); + auto owner_badge_itr = get_cert_by_badge_id.find(_required_badge_ids[i]); + if (owner_badge_itr != get_cert_by_badge_id.end()) { return true; } @@ -2726,4 +2901,4 @@ community::RightHolder community::admin_right_holder() #endif EOSIO_ABI_CUSTOM(community, - (setapprotype)(setvoter)(setapprover)(setaccess)(transfer)(createacc)(create)(initcode)(inputmembers)(initadminpos)(execcode)(createcode)(setverify)(createpos)(configpos)(nominatepos)(approvepos)(voteforcode)(voteforpos)(dismisspos)(setexectype)(appointpos)(proposecode)(execproposal)(verifyholder)(createbadge)(issuebadge)(configbadge)(setsoleexec)(setproposer)(setvoterule)(setconfig)) + (setapprotype)(setvoter)(setapprover)(setaccess)(transfer)(createacc)(create)(initcode)(inputmembers)(initadminpos)(execcode)(createcode)(setverify)(createpos)(configpos)(nominatepos)(approvepos)(voteforcode)(voteforpos)(dismisspos)(setexectype)(appointpos)(proposecode)(execproposal)(verifyholder)(createbadge)(issuebadge)(configbadge)(revokebadge)(setsoleexec)(setproposer)(setvoterule)(setconfig))