diff --git a/src/evm/engine/ether/index.ts b/src/evm/engine/ether/index.ts index 1bb315c..b200816 100644 --- a/src/evm/engine/ether/index.ts +++ b/src/evm/engine/ether/index.ts @@ -246,7 +246,13 @@ export class EthersEvmEngine implements IEVMEngine { method: abi!.name, params: params instanceof EthersResult - ? params.toArray() + ? convertArrayToObjectByAbiAndName( + this.getContractABI(), + "function", + abi!.name, + params.toArray(), + true + ) : params, }, } diff --git a/src/evm/engine/web3/index.ts b/src/evm/engine/web3/index.ts index 4119ba9..8097f01 100644 --- a/src/evm/engine/web3/index.ts +++ b/src/evm/engine/web3/index.ts @@ -318,11 +318,21 @@ export class Web3EvmEngine implements IEVMEngine { } } + const paramsResult = parseEvmReplyData(decodedParams) return { ok: true, data: { method: matchingFunction.name, - params: parseEvmReplyData(decodedParams), + params: + paramsResult instanceof Array + ? convertArrayToObjectByAbiAndName( + this.getContractABI(), + "function", + matchingFunction.name, + paramsResult, + true + ) + : paramsResult, }, } } catch (error) { diff --git a/test/evm/decode.test.ts b/test/evm/decode.test.ts index 1b1429b..9918595 100644 --- a/test/evm/decode.test.ts +++ b/test/evm/decode.test.ts @@ -25,6 +25,23 @@ import { web3Proof, ethersProof } from "./env/proof" const txInput = "0xa31e76710000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000002200000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000001e84800000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a5367757a46505851584e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a347373674f3836327a7500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a457758386353716d4d3900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a644d6e4658505550613300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a7452393954375947326c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a4c4d32744d365157343800000000000000000000000000000000000000000000" +const evmInput_Obj = { + ok: true, + data: { + method: "submitDatasetMetadata", + params: { + title: "SguzFPXQXN", + industry: "4ssgO862zu", + name: "EwX8cSqmM9", + description: "dMnFXPUPa3", + source: "tR99T7YG2l", + accessMethod: "LM2tM6QW48", + sizeInBytes: BigInt(512000000), + isPublic: true, + version: BigInt(1), + }, + }, +} const evmInput = { ok: true, @@ -67,7 +84,7 @@ describe("Encoding and decoding test", () => { describe("decodeTxInput Test", () => { it("web3 correct test(multi params)", () => { const web3Decode = web3Datasets.decodeTxInputToEvmInput(txInput) - assert.deepStrictEqual(web3Decode, evmInput) + assert.deepStrictEqual(web3Decode, evmInput_Obj) }) it("web3 correct test(one param)", () => { @@ -78,7 +95,7 @@ describe("Encoding and decoding test", () => { it("ethers correct test(multi params)", () => { const ethersDecode = ethersDatasets.decodeTxInputToEvmInput(txInput) - assert.deepStrictEqual(ethersDecode, evmInput) + assert.deepStrictEqual(ethersDecode, evmInput_Obj) }) it("ethers correct test(one param)", () => {