0

问题

这是我的功能:

    #[endpoint(registerItem)]
    fn register_item(&self, items_id: &[String])
    {
        // nothing for the moment
    }

在我的 Mandos 测试中,一切都很好(setState、scDeploy 等),直到我像这样测试此端点的调用:

{
  "step": "scCall",
  "tx": {
    "from": "address:owner",
    "to": "sc:equip",
    "function": "registerItem",
    "arguments": [

        "0x70757461696e|0x70757461696e"

    ],
    "gasLimit": "5,000,000",
    "gasPrice": "0"
  },
  "expect": {
    "status": "0",
    "gas": "*",
    "refund": "*"
  }
}

当我运行它时,我得到错误代码 10 又名执行失败。

这是整个日志:

Output: Scenario: init.scen.json ...   FAIL: result code mismatch. Tx . Want: 0. Have: 10 (execution failed). Message: execution failed
Done. Passed: 0. Failed: 1. Skipped: 0.
ERROR: some tests failed

**我尝试过的事情**

我已将字符串数组替换为 int 数组,但没有遇到此问题。我也试过 [str] 但我得到了这个错误:

15 | #[elrond_wasm::derive::contract]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
4

1 回答 1

2

如果它是一个端点,我认为您必须使用 SDK 特殊类型,例如 ManagedVec,以便 Node 可以知道如何对其进行序列化/反序列化。

所以也许试试这个:

    #[endpoint(registerItem)]
    fn register_item(&self, items_id: ManagedVec<ManagedBuffer>)
    {
        // nothing for the moment
    }
于 2022-01-17T09:58:56.900 回答