Skip to content

Commit b17261e

Browse files
Merge pull request #4 from telosnetwork/developer
removed eosio.token dependency
2 parents 5259520 + 175e1b6 commit b17261e

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

contracts/decide/include/decide.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <eosio/asset.hpp>
1313
#include <eosio/singleton.hpp>
1414

15-
#include <eosio.token/eosio.token.hpp>
15+
// #include <eosio.token/eosio.token.hpp>
1616

1717
#include <cmath>
1818

contracts/decide/include/utility.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ using user_resources = eosiosystem::user_resources;
1515
using del_bandwidth_table = eosiosystem::del_bandwidth_table;
1616
using rex_bal_table = eosiosystem::rex_balance_table;
1717

18+
//eosio.token account table
19+
struct eosio_account {
20+
asset balance;
21+
22+
uint64_t primary_key() const { return balance.symbol.code().raw(); }
23+
24+
EOSLIB_SERIALIZE(eosio_account, (balance))
25+
};
26+
typedef multi_index<name("accounts"), eosio_account> eosio_accounts_table;
27+
1828
//defined in
1929
asset get_staked_tlos(name owner) {
2030
del_bandwidth_table delband(name("eosio"), owner.value);

contracts/decide/src/decide.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,16 @@ ACTION decide::withdraw(name voter, asset quantity) {
126126
//transfer to eosio.token
127127
//inline trx requires telos.decide@active to have telos.decide@eosio.code
128128
//TODO: replace with action handler
129-
token::transfer_action transfer_act("eosio.token"_n, { get_self(), active_permission });
130-
transfer_act.send(get_self(), voter, quantity, std::string("Telos Decide Withdrawal"));
129+
// token::transfer_action transfer_act("eosio.token"_n, { get_self(), active_permission });
130+
// transfer_act.send(get_self(), voter, quantity, std::string("Telos Decide Withdrawal"));
131+
132+
//inline transfer
133+
action(permission_level{get_self(), name("active")}, name("eosio.token"), name("transfer"), make_tuple(
134+
get_self(), //from
135+
voter, //to
136+
quantity, //quantity
137+
std::string("Telos Decide Withdrawal") //memo
138+
)).send();
131139

132140
}
133141

@@ -180,7 +188,10 @@ void decide::catch_transfer(name from, name to, asset quantity, string memo) {
180188
config_singleton configs(get_self(), get_self().value);
181189
auto config = configs.get();
182190

183-
asset total_transferable = (token::get_balance("eosio.token"_n, get_self(), TLOS_SYM.code()) + quantity) - config.total_deposits;
191+
eosio_accounts_table eosio_accounts(name("eosio.token"), get_self().value);
192+
auto& eosio_acct = eosio_accounts.get(TLOS_SYM.code().raw(), "tlos balance not found");
193+
194+
asset total_transferable = (eosio_acct.balance + quantity) - config.total_deposits;
184195

185196
check(total_transferable >= quantity, "Telos Decide lacks the liquid TLOS to make this transfer");
186197
}

0 commit comments

Comments
 (0)