Skip to content

Commit

Permalink
forbid smart contract transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
zhong solar committed Nov 12, 2018
1 parent d1ec22e commit 77e8007
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dice/dice.abi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"____comment": "This file was generated by eosio-abigen. DO NOT EDIT - 2018-11-12T12:08:28",
"____comment": "This file was generated by eosio-abigen. DO NOT EDIT - 2018-11-12T14:50:10",
"version": "eosio::abi/1.0",
"types": [{
"new_type_name": "symbol_name",
Expand Down
11 changes: 11 additions & 0 deletions dice/dice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,17 @@ class dice : public eosio::contract {
return;
}

auto tx_size = transaction_size();
char tx[tx_size];
auto read_size = read_transaction(tx, tx_size);
eosio_assert( tx_size == read_size, "read_transaction failed");
auto trx = eosio::unpack<eosio::transaction>( tx, read_size );
eosio::action first_action = trx.actions.front();
std::string action_name = eosio::name{first_action.name}.to_string();
std::string _account_name = eosio::name{first_action.account}.to_string();

eosio_assert(first_action.name == N(transfer) && first_action.account == _code, "wrong transaction");

check_symbol_code(t.quantity);
eosio_assert(t.quantity.is_valid(), "Invalid transfer amount.");

Expand Down
Binary file modified dice/dice.wasm
Binary file not shown.

0 comments on commit 77e8007

Please sign in to comment.