Add injection of asset amount (call parameter) into wallet within playground contract interface.
CatspersCoffee opened this issue · comments
Antony Burrows commented
Problem Description:
Using the contract interface to send an amount of some asset (in this case BASE_ASSET_ID) via the contract interface call does not seem to have the ability to inject or add an amount (to send in to a contract via call params) via the wallet.
i.e., The below function in Sway has the ability to accept within the call parameters a amount of BASE_ASSET_ID :
#[storage(read, write)]
fn receive_funds() {
if msg_asset_id() == BASE_ASSET_ID {
storage.balance += msg_amount();
}
}
Using fuels-rs
this is done with a simple example:
let contract_instance = MyContract::new(_contract_id.into(), wallet.clone());
let tx_params = TxParameters::default()
.set_gas_price(1)
.set_gas_limit(1_000_000)
.set_maturity(0);
let deposit_amount = 1_000_003;
let call_params = CallParameters::default()
.set_amount(deposit_amount)
.set_asset_id(BASE_ASSET_ID);
let res = contract_instance
.methods()
.receive_funds()
.tx_params(tx_params)
.call_params(call_params).unwrap()
.call()
.await;
However, when using sway-playground, there is no way for the user making the call to this function (receive_funds()) via the contract interface and add an "amount" to the transaction that is being signed.