I am having trouble setting a correct message/sale_condition with the contract from the nft-tutorial. My code is as follows;
const price = parseNearAmount('1');
let sale_conditions = {
near: price
};
let args = {
token_id: tokenId,
account_id: marketId,
msg: JSON.stringify({ sale_conditions })
}
let GAS = "200000000000000";
let deposit = parseNearAmount('0.6');
await contract.nft_approve(args, GAS, deposit);
But I keep getting the following error
{"index":0,"kind":{"ExecutionError":"Smart contract panicked: panicked at 'Not valid SaleArgs: Error(\"invalid type: map, expected a string\", line: 1, column: 19)', src/nft_callbacks.rs:78:50"}}
I have checked the arguments and as far as I can tell they are a string format. Any ideas what I am doing wrong?
I assume you are following this tutorial https://docs.near.org/docs/tutorials/contracts/nfts/approvals#marketplace-integrations
I think maybe you need to edit the sale_condition
to the appropriate format
const price = parseNearAmount('1');
let sale_conditions = price; // updated this line to match expected format for cross contract call
let args = {
token_id: tokenId,
account_id: marketId,
msg: JSON.stringify({ sale_conditions })
}
let GAS = "200000000000000";
let deposit = parseNearAmount('0.6');
await contract.nft_approve(args, GAS, deposit);
args will then look something like this:
{token_id: 'someTokenId', account_id: 'someAccountId', msg: '{"sale_conditions":1YoctoNear}'}
The tutorial expects this format for msg
, as it's passed to a cross-contract call to this contract, and sale_conditions
is expected to be of the type: SalePriceInYoctoNear
, which is defined to be a U128
(link to repo)