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

[txs] change balance_transfer API for Carpe app #995

Merged
merged 1 commit into from
Apr 5, 2022
Merged
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
14 changes: 8 additions & 6 deletions ol/txs/src/commands/transfer_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

#![allow(clippy::never_loop)]

use crate::{entrypoint, submit_tx::{TxError, maybe_submit, tx_params_wrapper}};
use crate::{
entrypoint,
submit_tx::{TxError, maybe_submit, tx_params_wrapper},
tx_params::TxParams,
};
use abscissa_core::{Command, Options, Runnable};

use diem_json_rpc_types::views::TransactionView;
Expand All @@ -29,8 +33,8 @@ impl Runnable for TransferCmd {
exit(1);
},
};

match balance_transfer(destination, self.coins, entry_args.save_path) {
let tx_params = tx_params_wrapper(TxType::Mgmt).unwrap();
match balance_transfer(destination, self.coins, tx_params, entry_args.save_path) {
Ok(_) => println!("Success: Balance transfer posted: {}", self.destination_account),
Err(e) => {
println!("ERROR: execute balance transfer message: {:?}", &e);
Expand All @@ -41,9 +45,7 @@ impl Runnable for TransferCmd {
}

/// create an account by sending coin to it
pub fn balance_transfer(destination: AccountAddress, coins: u64, save_path: Option<PathBuf>) -> Result<TransactionView, TxError>{
let tx_params = tx_params_wrapper(TxType::Mgmt).unwrap();

pub fn balance_transfer(destination: AccountAddress, coins: u64, tx_params: TxParams, save_path: Option<PathBuf>) -> Result<TransactionView, TxError>{
// NOTE: coins here do not have the scaling factor. Rescaling is the responsibility of the Move script. See the script in ol_accounts.move for detail.
let script = transaction_builder::encode_balance_transfer_script_function(
destination,
Expand Down