nft_approve msg 的 SaleArgs 参数格式正确

correct format of SaleArgs parameter for nft_approve msg

我无法使用 nft-tutorial 中的合约设置正确的 message/sale_condition。我的代码如下;

    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);

但我不断收到以下错误

{"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"}}

我检查了参数,据我所知它们是字符串格式。知道我做错了什么吗?

我假设您正在学习本教程https://docs.near.org/docs/tutorials/contracts/nfts/approvals#marketplace-integrations

我认为您可能需要将 sale_condition 编辑为适当的格式

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 看起来像这样:

{token_id: 'someTokenId', account_id: 'someAccountId', msg: '{"sale_conditions":1YoctoNear}'}

本教程希望 msg 使用此格式,因为它已传递给对 this contract, and sale_conditions is expected to be of the type: SalePriceInYoctoNear, which is defined to be a U128 (link to repo)

的 cross-contract 调用