I have a contract calling another contract. Now even though I did set the “with_contracts” with an instance, I do get “ContractNotInInputs” error.
Here’s the test interface function:
pub(crate) async fn mint(
contract: &SRC721Edition<WalletUnlocked>,
recipient: Identity,
sub_id: Bits256,
amount: u64,
price: u64,
fee_contract_instance: &OctaneFeeSplitter<WalletUnlocked>,
) -> FuelCallResponse<()> {
contract
.methods()
.mint(recipient, sub_id, amount)
.with_contracts(&[fee_contract_instance])
.append_variable_outputs(1)
.call_params(CallParameters::new(price, AssetId::zeroed(), 1_000_000))
.unwrap()
.call()
.await
.unwrap()
}
Here’s a sample test:
#[tokio::test]
async fn mints_assets_with_fees() {
let (owner_wallet, other_wallet, id, instance_1, _instance_2, _fee_id, fee_instance_1) = setup().await;
let (
asset_id_1,
_asset_id_2,
_asset_id_3,
sub_id_1,
_sub_id_2,
_sub_id_3,
owner_identity,
other_identity,
) = defaults(id, owner_wallet, other_wallet.clone());
constructor(&instance_1, owner_identity, default_name(), default_symbol(), default_metadata_keys(), default_metadata_values(), default_price()).await;
assert_eq!(get_wallet_balance(&other_wallet, &asset_id_1).await, 0);
assert_eq!(total_supply(&instance_1, asset_id_1).await, None);
assert_eq!(total_assets(&instance_1).await, 0);
let fee_amount = 1_000;
set_fee(&fee_instance_1, fee_amount).await;
assert_eq!(fee(&fee_instance_1).await, Some(fee_amount));
mint(&instance_1, other_identity, sub_id_1, 1, 1_000, &fee_instance_1).await;
assert_eq!(get_wallet_balance(&other_wallet, &asset_id_1).await, 1);
assert_eq!(total_supply(&instance_1, asset_id_1).await, Some(1));
assert_eq!(total_assets(&instance_1).await, 1);
}
And here’s the setup:
pub(crate) async fn setup() -> (
WalletUnlocked,
WalletUnlocked,
ContractId,
SRC721Edition<WalletUnlocked>,
SRC721Edition<WalletUnlocked>,
ContractId,
OctaneFeeSplitter<WalletUnlocked>,
) {
let number_of_coins = 1;
let coin_amount = 100_000_000;
let number_of_wallets = 2;
let base_asset = AssetConfig {
id: AssetId::zeroed(),
num_coins: number_of_coins,
coin_amount,
};
let assets = vec![base_asset];
let wallet_config = WalletsConfig::new_multiple_assets(number_of_wallets, assets);
let mut wallets = launch_custom_provider_and_get_wallets(wallet_config, None, None)
.await
.unwrap();
let wallet1 = wallets.pop().unwrap();
let wallet2 = wallets.pop().unwrap();
let id = Contract::load_from(NFT_CONTRACT_BINARY_PATH, LoadConfiguration::default())
.unwrap()
.deploy(&wallet1, TxPolicies::default())
.await
.unwrap();
let instance_1 = SRC721Edition::new(id.clone(), wallet1.clone());
let instance_2 = SRC721Edition::new(id.clone(), wallet2.clone());
let fee_id = Contract::load_from(FEE_SPLITTER_CONTRACT_BINARY_PATH, LoadConfiguration::default())
.unwrap()
.deploy(&wallet1, TxPolicies::default())
.await
.unwrap();
let fee_instance_1 = OctaneFeeSplitter::new(id.clone(), wallet1.clone());
(wallet1, wallet2, id.into(), instance_1, instance_2, fee_id.into(), fee_instance_1)
}
Any help appreciated.