当我想要使用基于衬底的链中内置的方法和自定义类型时,我得到了以下错误:
2020-04-13 21:03:01 RPC-CORE: submitAndWatchExtrinsic(extrinsic: Extrinsic): ExtrinsicStatus:: 1002: Verification Error: Execution(ApiError("Could not convert parameter `tx` between node and runtime: Error decoding field Call :: Poe.0")): RuntimeApi("Execution(ApiError(\"Could not convert parameter `tx` between node and runtime: Error de
2020-04-13 21:03:01 DRR: Error: 1002: Verification Error: Execution(ApiError("Could not convert parameter `tx` between node and runtime: Error decoding field Call :: Poe.0")): RuntimeApi("Execution(ApiError(\"Could not convert parameter `tx` between node and runtime: Error
de
at RpcCoder._checkError (/c/substrate-mvce/js-cli/node_modules/@polkadot/rpc-provider/coder/index.js:83:13)
at RpcCoder.decodeResponse (/c/substrate-mvce/js-cli/node_modules/@polkadot/rpc-provider/coder/index.js:46:10)
at WsProvider.value (/c/substrate-mvce/js-cli/node_modules/@polkadot/rpc-provider/ws/Provider.js:160:90)
at W3CWebSocket.value [as onmessage] (/c/substrate-mvce/js-cli/node_modules/@polkadot/rpc-provider/ws/Provider.js:140:153)
at W3CWebSocket._dispatchEvent [as dispatchEvent] (/c/substrate-mvce/js-cli/node_modules/yaeti/lib/EventTarget.js:107:17)
at W3CWebSocket.onMessage (/c/substrate-mvce/js-cli/node_modules/websocket/lib/W3CWebSocket.js:234:14)
at WebSocketConnection.<anonymous> (/c/substrate-mvce/js-cli/node_modules/websocket/lib/W3CWebSocket.js:205:19)
at WebSocketConnection.emit (events.js:315:20)
at WebSocketConnection.processFrame (/c/substrate-mvce/js-cli/node_modules/websocket/lib/WebSocketConnection.js:554:26)
at /c/substrate-mvce/js-cli/node_modules/websocket/lib/WebSocketConnection.js:323:40基本上,我尝试使用我在运行时托盘中定义的类型。这些类型是使用@polkadot/typegen包从元数据自动生成的。
复制此文件的完整代码在此处https://github.com/woss/substrate-mvce
发布于 2020-04-14 15:43:49
您在TypeScript中创建并发送到底层节点的有效负载有问题。底层节点似乎无法解析对象。
我发现您肯定在Operation类型定义中遗漏了一个属性:
Operation: {
op: 'Vec<u8>',
desc: 'Vec<u8>',
hashAlgo: 'Vec<u8>',
encodeAlgo: 'Vec<u8>',
prefix: 'Vec<u8>',
ops: 'Vec<Operation>',
},缺少hashBits。
进一步看,预定义的photo规则是否正确地满足运行时定义的对象并不明显。
您需要端到端地检查您是否正确地定义了这些自定义类型,以及您正在生成的有效负载是否有效。
发布于 2020-04-14 20:24:58
是的,hashBits丢失了,但这不是解决方案。在添加了hashBits并修改了定义,使其具有与运行时完全相同的结构(键的位置相同)之后,它就可以正常工作了。这意味着要遵循
pub struct Rule {
version: u32,
description: Vec<u8>,
creator: Vec<u8>,
for_what: ForWhat,
parent: Vec<u8>,
ops: Vec<Operation>,
build_params: Operation,
}这必须是JS应用程序中的内容
{
Rule: {
version: 'u32',
description: 'Vec<u8>',
creator: 'Vec<u8>',
forWhat: 'ForWhat',
parent: 'Vec<u8>',
ops: 'Vec<Operation>',
buildParams: 'Operation',
}
}如果我们想改变键在定义中的顺序,它将失败。
https://stackoverflow.com/questions/61194973
复制相似问题