Skip to content

Commit

Permalink
[aptos-cli] Merge max gas and chain id into write options
Browse files Browse the repository at this point in the history
  • Loading branch information
gregnazario authored and aptos-bot committed Apr 21, 2022
1 parent bba1477 commit 32910f4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion crates/aptos/src/account/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl CreateAccount {
let client = RestClient::new(reqwest::Url::clone(&self.write_options.rest_options.url));
let transaction_factory = TransactionFactory::new(self.write_options.chain_id)
.with_gas_unit_price(1)
.with_max_gas_amount(1000);
.with_max_gas_amount(self.write_options.max_gas);
let sender_account = &mut LocalAccount::new(sender_address, sender_key, sequence_number);
let transaction = sender_account.sign_with_transaction_builder(
transaction_factory
Expand Down
5 changes: 5 additions & 0 deletions crates/aptos/src/common/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@ pub struct WriteTransactionOptions {
/// ChainId for the network
#[clap(long)]
pub chain_id: ChainId,
/// Maximum gas to be used to publish the package
///
/// Defaults to 1000 gas units
#[clap(long, default_value_t = 1000)]
pub max_gas: u64,
}

/// Options for compiling a move package dir
Expand Down
12 changes: 2 additions & 10 deletions crates/aptos/src/move_tool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,6 @@ pub struct PublishPackage {
move_options: MovePackageDir,
#[clap(flatten)]
write_options: WriteTransactionOptions,
/// ChainId for the network
#[clap(long)]
chain_id: ChainId,
/// Maximum gas to be used to publish the package
///
/// Defaults to 1000 gas units
#[clap(long, default_value_t = 1000)]
max_gas: u64,
}

impl PublishPackage {
Expand Down Expand Up @@ -160,10 +152,10 @@ impl PublishPackage {

submit_transaction(
self.write_options.rest_options.url.clone(),
self.chain_id,
self.write_options.chain_id,
sender_key,
compiled_payload,
self.max_gas,
self.write_options.max_gas,
)
.await
}
Expand Down

0 comments on commit 32910f4

Please sign in to comment.