Skip to content

Commit

Permalink
[txs] Allow invoking balance_transfer function when importing libra (0…
Browse files Browse the repository at this point in the history
  • Loading branch information
ea-open-source authored Apr 5, 2022
1 parent 7efbd1a commit 5fce7d4
Showing 1 changed file with 8 additions and 6 deletions.
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

0 comments on commit 5fce7d4

Please sign in to comment.