Compare commits

...

2 commits

Author SHA1 Message Date
gladcow
53c3ec5b45 change type for vesting_type in create_vesting_balance 2019-10-31 17:00:28 +03:00
gladcow
5457577ec9 Fix create_vesting wallet_api call 2019-10-31 17:00:28 +03:00
3 changed files with 21 additions and 23 deletions

View file

@ -1429,15 +1429,17 @@ class wallet_api
/** Creates a vesting deposit owned by the given account. /** Creates a vesting deposit owned by the given account.
* *
* @param owner_account the name or id of the account * @param owner_account vesting balance owner and creator (the name or id)
* @param amount the amount to deposit * @param amount amount to vest
* @param asset_symbol the symbol of the asset to vest
* @param vesting_type "normal", "gpos" or "son" * @param vesting_type "normal", "gpos" or "son"
* @param broadcast true to broadcast the transaction on the network * @param broadcast true to broadcast the transaction on the network
* @returns the signed transaction registering a vesting object * @returns the signed transaction registering a vesting object
*/ */
signed_transaction create_vesting(string owner_account, signed_transaction create_vesting_balance(string owner_account,
string amount, string amount,
string vesting_type, string asset_symbol,
vesting_balance_type vesting_type,
bool broadcast = false); bool broadcast = false);
/** /**
@ -2118,7 +2120,7 @@ FC_API( graphene::wallet::wallet_api,
(update_witness) (update_witness)
(create_worker) (create_worker)
(update_worker_votes) (update_worker_votes)
(create_vesting) (create_vesting_balance)
(get_vesting_balances) (get_vesting_balances)
(withdraw_vesting) (withdraw_vesting)
(vote_for_committee_member) (vote_for_committee_member)

View file

@ -2107,27 +2107,21 @@ public:
return sign_transaction( tx, broadcast ); return sign_transaction( tx, broadcast );
} }
signed_transaction create_vesting(string owner_account, signed_transaction create_vesting_balance(string owner_account,
string amount, string amount,
string vesting_type, string asset_symbol,
vesting_balance_type vesting_type,
bool broadcast /* = false */) bool broadcast /* = false */)
{ try { { try {
account_object son_account = get_account(owner_account); account_object son_account = get_account(owner_account);
fc::optional<asset_object> asset_obj = get_asset(asset_symbol);
FC_ASSERT(asset_obj, "Invalid asset symbol {asst}", ("asst", asset_symbol));
vesting_balance_create_operation op; vesting_balance_create_operation op;
op.creator = son_account.get_id(); op.creator = son_account.get_id();
op.owner = son_account.get_id(); op.owner = son_account.get_id();
op.amount = asset_object().amount_from_string(amount); op.amount = asset_obj->amount_from_string(amount);
if (vesting_type == "normal") op.balance_type = vesting_type;
op.balance_type = vesting_balance_type::normal;
else if (vesting_type == "gpos")
op.balance_type = vesting_balance_type::gpos;
else if (vesting_type == "son")
op.balance_type = vesting_balance_type::son;
else
{
FC_ASSERT( false, "unknown vesting type value ${vt}", ("vt", vesting_type) );
}
if (op.balance_type == vesting_balance_type::son) if (op.balance_type == vesting_balance_type::son)
op.policy = dormant_vesting_policy_initializer {}; op.policy = dormant_vesting_policy_initializer {};
@ -4271,12 +4265,13 @@ committee_member_object wallet_api::get_committee_member(string owner_account)
return my->get_committee_member(owner_account); return my->get_committee_member(owner_account);
} }
signed_transaction wallet_api::create_vesting(string owner_account, signed_transaction wallet_api::create_vesting_balance(string owner_account,
string amount, string amount,
string vesting_type, string asset_symbol,
vesting_balance_type vesting_type,
bool broadcast /* = false */) bool broadcast /* = false */)
{ {
return my->create_vesting(owner_account, amount, vesting_type, broadcast); return my->create_vesting_balance(owner_account, amount, asset_symbol, vesting_type, broadcast);
} }
signed_transaction wallet_api::create_son(string owner_account, signed_transaction wallet_api::create_son(string owner_account,

View file

@ -78,11 +78,12 @@ public:
BOOST_CHECK(fixture_.generate_block()); BOOST_CHECK(fixture_.generate_block());
// create deposit vesting // create deposit vesting
fixture_.con.wallet_api_ptr->create_vesting(account_name, "50000000", "son", true); fixture_.con.wallet_api_ptr->create_vesting_balance(account_name,
"50", "1.3.0", vesting_balance_type::son, true);
BOOST_CHECK(fixture_.generate_block()); BOOST_CHECK(fixture_.generate_block());
// create pay_vb vesting // create pay_vb vesting
fixture_.con.wallet_api_ptr->create_vesting(account_name, "1000000", "normal", true); fixture_.con.wallet_api_ptr->create_vesting_balance(account_name, "1", "1.3.0", vesting_balance_type::normal, true);
BOOST_CHECK(fixture_.generate_block()); BOOST_CHECK(fixture_.generate_block());
// check deposits are here // check deposits are here