Skip to content

Commit

Permalink
feat: take dynamic asset id into account with forc-client (#5987)
Browse files Browse the repository at this point in the history
## Description
Base asset ids are dynamic for the newer fuel-core versions. This PR
adds capability to query that and use it for forc-client transactions.
Also adds a flag `max-fee` which is required to be set for newer
versions of fuel-core.
  • Loading branch information
kayagokalp committed May 10, 2024
1 parent 76a6cd3 commit 85b9d97
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions forc-plugins/forc-client/src/op/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,10 @@ pub async fn deploy_pkg(
WalletSelectionMode::ForcWallet
};

let max_fee = command.gas.max_fee.unwrap_or(0);

let tx = TransactionBuilder::create(bytecode.as_slice().into(), salt, storage_slots.clone())
.max_fee_limit(max_fee)
.maturity(command.maturity.maturity.into())
.add_output(Output::contract_created(contract_id, state_root))
.finalize_signed(
Expand Down
6 changes: 2 additions & 4 deletions forc-plugins/forc-client/src/util/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ use anyhow::{Error, Result};
use async_trait::async_trait;
use forc_tracing::println_warning;
use fuel_crypto::{Message, PublicKey, SecretKey, Signature};
use fuel_tx::{
field, Address, AssetId, Buildable, ContractId, Input, Output, TransactionBuilder, Witness,
};
use fuel_tx::{field, Address, Buildable, ContractId, Input, Output, TransactionBuilder, Witness};
use fuels_accounts::{provider::Provider, wallet::Wallet, ViewOnlyAccount};
use fuels_core::types::{
bech32::{Bech32Address, FUEL_BECH32_HRP},
Expand Down Expand Up @@ -143,10 +141,10 @@ impl<Tx: Buildable + field::Witnesses + Send> TransactionBuilderExt<Tx> for Tran
provider: Provider,
signature_witness_index: u16,
) -> Result<&mut Self> {
let asset_id = *provider.base_asset_id();
let wallet = Wallet::from_address(Bech32Address::from(address), Some(provider));

let amount = 1_000_000;
let asset_id = AssetId::BASE;
let inputs: Vec<_> = wallet
.get_spendable_resources(asset_id, amount)
.await?
Expand Down
3 changes: 3 additions & 0 deletions forc-plugins/forc-tx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ pub struct Gas {
/// Gas limit for the transaction.
#[clap(long = "script-gas-limit")]
pub script_gas_limit: Option<u64>,
/// Max fee for the transaction.
#[clap(long)]
pub max_fee: Option<u64>,
}

/// Block until which tx cannot be included.
Expand Down

0 comments on commit 85b9d97

Please sign in to comment.