Last active
December 8, 2018 15:52
-
-
Save epicdistraction/3fecaec3b9c3c2704584a139463498cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace bpfish { | |
ACTION hodlong::transfer(const name from,const name to, asset quantity, string memo) { | |
// use explicit naming due to code originating from eosio.token::transfer | |
if (from == contract_name || to != contract_name) | |
return; | |
require_auth(from); | |
users transfer_users(contract_name, contract_name.value); | |
auto iterator = transfer_users.find(from.value); | |
eosio_assert(iterator != transfer_users.end(), "User account does not exist"); | |
transfer_users.modify(iterator, contract_name, [&](auto &u) { | |
u.balance += quantity; | |
}); | |
} | |
} | |
extern "C" { | |
[[noreturn]] void apply(uint64_t receiver, uint64_t code, uint64_t action) { | |
if (action == "transfer"_n.value && code == "eosio.token"_n.value) { | |
eosio::execute_action(name(receiver), name(code), &bpfish::hodlong::transfer); | |
} | |
else if (code == receiver) { | |
switch (action) { | |
EOSIO_DISPATCH_HELPER(bpfish::hodlong, (seed)(createobj)(addstats)(adduser)(updateuser)); | |
} | |
} | |
eosio_exit(0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment