Skip to content

Commit

Permalink
check against issued supply instead of current supply (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
cthacker authored Jan 22, 2020
1 parent 876f4c5 commit 3f29ab7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
27 changes: 27 additions & 0 deletions build/dgoods/dgoods.abi
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,28 @@
}
]
},
{
"name": "logsale",
"base": "",
"fields": [
{
"name": "dgood_ids",
"type": "uint64[]"
},
{
"name": "seller",
"type": "name"
},
{
"name": "buyer",
"type": "name"
},
{
"name": "receiver",
"type": "name"
}
]
},
{
"name": "setconfig",
"base": "",
Expand Down Expand Up @@ -469,6 +491,11 @@
"type": "logcall",
"ricardian_contract": ""
},
{
"name": "logsale",
"type": "logsale",
"ricardian_contract": ""
},
{
"name": "setconfig",
"type": "setconfig",
Expand Down
Binary file modified build/dgoods/dgoods.wasm
Binary file not shown.
6 changes: 3 additions & 3 deletions src/dgoods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ ACTION dgoods::issue(const name& to,

if (dgood_stats.max_supply.amount != 0) {
// check cannot issue more than max supply, careful of overflow of uint
check( quantity.amount <= (dgood_stats.max_supply.amount - dgood_stats.current_supply.amount), "Cannot issue more than max supply" );
check( quantity.amount <= (dgood_stats.max_supply.amount - dgood_stats.issued_supply.amount), "Cannot issue more than max supply" );
}

if (dgood_stats.fungible == false) {
Expand Down Expand Up @@ -394,9 +394,9 @@ ACTION dgoods::freezemaxsup(const name& category, const name& token_name) {
const auto& dgood_stats = stats_table.get( token_name.value,
"Token with category and token_name does not exist" );
check(dgood_stats.max_issue_window != time_point_sec(0), "can't freeze max supply unless time based minting");
check(dgood_stats.current_supply.amount != 0, "need to issue at least one token before freezing");
check(dgood_stats.issued_supply.amount != 0, "need to issue at least one token before freezing");
stats_table.modify( dgood_stats, same_payer, [&]( auto& s ) {
s.max_supply = dgood_stats.current_supply;
s.max_supply = dgood_stats.issued_supply;
s.max_issue_window = time_point_sec(0);
});
}
Expand Down

0 comments on commit 3f29ab7

Please sign in to comment.