Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add return value to decay and alias function (getvoice) #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion include/voice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ class [[eosio::contract("voice.hypha")]] voice : public eosio::contract {


// Runs decaying actions
ACTION decay(const name& owner, symbol symbol);
[[eosio::action]]
asset decay(const name& owner, symbol symbol);

// Alias to decay
[[eosio::action]]
asset getvoice(const name& owner, const symbol symbol);

/**
* Allows `ram_payer` to create an account `owner` with zero balance for
Expand Down
10 changes: 8 additions & 2 deletions src/voice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ namespace hypha {
add_balance( to, quantity, payer );
}

void voice::decay(const name& owner, symbol symbol) {
asset voice::decay(const name& owner, symbol symbol) {
stats statstable( get_self(), symbol.code().raw() );
auto existing = statstable.find( symbol.code().raw() );
check( existing != statstable.end(), "token with symbol does not exist, create token before issue" );
Expand All @@ -162,7 +162,7 @@ namespace hypha {
const auto from = from_acnts.find( symbol.code().raw());
if (from == from_acnts.end()) {
// No balance exists yet, nothing to do
return;
return asset(0, symbol);
}

const DecayResult result = hypha::decay(
Expand All @@ -184,6 +184,12 @@ namespace hypha {
a.last_decay_period = result.newPeriod;
});
}

return asset(result.newBalance, symbol);
}

asset voice::getvoice(const name& owner, const symbol symbol) {
return decay(owner, symbol);
}

void voice::sub_balance( const name& owner, const asset& value ) {
Expand Down