diff --git a/examples/types/src/lib.rs b/examples/types/src/lib.rs index 322395e4d2..2fcf447453 100644 --- a/examples/types/src/lib.rs +++ b/examples/types/src/lib.rs @@ -4,8 +4,10 @@ mod tests { #[cfg(feature = "fuel-core-lib")] use fuels::prelude::Config; - use fuels::prelude::Result; - use fuels::types::{Bits256, EvmAddress, Identity}; + use fuels::{ + prelude::Result, + types::{Bits256, EvmAddress, Identity}, + }; #[tokio::test] async fn bytes32() -> Result<()> { diff --git a/packages/fuels-core/src/types/transaction_builders.rs b/packages/fuels-core/src/types/transaction_builders.rs index ed664d2abd..d1da0cd5e2 100644 --- a/packages/fuels-core/src/types/transaction_builders.rs +++ b/packages/fuels-core/src/types/transaction_builders.rs @@ -11,6 +11,7 @@ use fuel_asm::{op, GTFArgs, RegId}; use fuel_crypto::{Message as CryptoMessage, Signature}; use fuel_tx::{ field::{Inputs, Policies as PoliciesField, WitnessLimit, Witnesses}, + input::coin::{CoinPredicate, CoinSigned}, policies::{Policies, PolicyType}, Buildable, Chargeable, ConsensusParameters, Create, Input as FuelInput, Output, Script, StorageSlot, Transaction as FuelTransaction, TransactionFee, TxPointer, UniqueIdentifier, @@ -405,16 +406,19 @@ impl ScriptTransactionBuilder { .collect() } - fn no_spendable_input<'a, I: IntoIterator>(inputs: I) -> bool { - !inputs.into_iter().any(|i| { - matches!( - i, - FuelInput::CoinSigned(_) - | FuelInput::CoinPredicate(_) - | FuelInput::MessageCoinSigned(_) - | FuelInput::MessageCoinPredicate(_) - ) - }) + fn no_base_asset_input<'a, I: IntoIterator>(inputs: I) -> bool { + let has_base_asset = inputs.into_iter().any(|i| match i { + FuelInput::CoinSigned(CoinSigned { asset_id, .. }) + | FuelInput::CoinPredicate(CoinPredicate { asset_id, .. }) + if *asset_id == BASE_ASSET_ID => + { + true + } + FuelInput::MessageCoinSigned(_) | FuelInput::MessageCoinPredicate(_) => true, + _ => false, + }); + + !has_base_asset } async fn set_script_gas_limit_to_gas_used( @@ -424,10 +428,10 @@ impl ScriptTransactionBuilder { ) -> Result<()> { let consensus_params = provider.consensus_parameters(); - // The dry-run validation will check if there is any spendable input present in - // the transaction. If we are dry-running without inputs we have to add a temporary one. - let no_spendable_input = Self::no_spendable_input(tx.inputs()); - if no_spendable_input { + // The dry-run validation will check if there is any base asset input. + // If we are dry-running without inputs we have to add a temporary one. + let no_base_asset_input = Self::no_base_asset_input(tx.inputs()); + if no_base_asset_input { tx.inputs_mut().push(FuelInput::coin_signed( Default::default(), Default::default(), @@ -453,7 +457,7 @@ impl ScriptTransactionBuilder { .await?; // Remove dry-run input and witness. - if no_spendable_input { + if no_base_asset_input { tx.inputs_mut().pop(); tx.witnesses_mut().pop(); tx.set_witness_limit(tx.witness_limit() - WITNESS_STATIC_SIZE as u64);