Skip to content

Commit

Permalink
feat/#63 add revoke code for new badge
Browse files Browse the repository at this point in the history
  • Loading branch information
danielvo11 committed Dec 9, 2020
1 parent 3015cf8 commit 2c0921b
Show file tree
Hide file tree
Showing 4 changed files with 375 additions and 159 deletions.
21 changes: 20 additions & 1 deletion community/community.abi
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,20 @@
}
]
},
{
"name": "revokebadge",
"base": "",
"fields": [
{
"name": "community_account",
"type": "name"
},
{
"name": "revoke_badge_propose_name",
"type": "name"
}
]
},
{
"name": "setaccess",
"base": "",
Expand Down Expand Up @@ -1319,6 +1333,11 @@
"type": "proposecode",
"ricardian_contract": ""
},
{
"name": "revokebadge",
"type": "revokebadge",
"ricardian_contract": ""
},
{
"name": "setaccess",
"type": "setaccess",
Expand Down Expand Up @@ -1429,7 +1448,7 @@
"key_types": []
},
{
"name": "v1.cert",
"name": "v1.certs",
"type": "v1_cert",
"index_type": "i64",
"key_names": [],
Expand Down
Binary file modified community/community.wasm
Binary file not shown.
24 changes: 23 additions & 1 deletion community/include/community.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ CONTRACT community : public contract
POSITION_DISMISS,
BADGE_CONFIG,
BADGE_ISSUE,
BADGE_REVOKE,
};

enum BadgeIssueType {
Expand Down Expand Up @@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -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<v1_cert, uint64_t, &v1_cert::by_badge_id>>,
eosio::indexed_by<"owner"_n, eosio::const_mem_fun<v1_cert, uint64_t, &v1_cert::by_owner>>> v1_cert_table;

Expand Down
Loading

0 comments on commit 2c0921b

Please sign in to comment.