Issue Title:
v3.1.1: encodeMethodFromString 不支持在 funcParam 中传递数组类型参数 (uint256[24] 或 uint256[])
环境信息
- WeBASE-Front 版本:v3.1.1
- 部署模式:单节点 Docker
- 底层链:FISCO-BCOS 3.x,
- 浏览器/客户端:调用 Rest API
问题概述
在 WeBASE-Front v3.1.1 的交易处理接口中,funcParam 虽然文档(1.5.5+)中宣称“数组类型也需要以字符串形式包裹”(e.g. ["0x1a","[\"addr1\",\"addr2\"]"]),但实际底层编码工具 encodeMethodFromString 不会对单个字符串做二次 JSON 解析,导致任何数组参数都无法被正确打包,始终返回:
code: 201151
errorMessage: "cannot encode in encodeMethodFromString with appropriate interface ABI, make sure params match"
复现步骤
-
ABI 定义(固定长度数组)
-
尝试分步编码 → 发送
请求 /WeBASE-Front/trans/encodeFunction:
{
"groupId":"group0",
"funcName":"verifyAssetZK",
"contractAbi":[ /* 如上 ABI */ ],
"funcParam":[
"[\"0xaaa\",\"0xbbb\",…,\"0xzzz\"]",
"1234567890"
]
}
返回(同样直接走 encodeMethodFromString):
{
"code":201151,
"errorMessage":"cannot encode in encodeMethodFromString with appropriate interface ABI, make sure params match"
}
-
尝试改成动态数组 ABI + 拆平
并将 funcParam 拆成 25 条独立字符串:
"funcParam":[
"111111…", "222222…", …, "xxxxxxx…", // 24 条 proof
"1234567890" // dataHash
]
返回依旧:
{ "code":201151, "errorMessage":"cannot encode in encodeMethodFromString with appropriate interface ABI, make sure params match" }
原因分析
encodeMethodFromString 只支持基本类型的单值参数:
“每个 funcParam 元素必须对应一个基本参数,数组类型不再做二次 JSON.parse”。
因此任何 "[\"…\",\"…\"]" 或者拆平的动态数组都不能被识别为数组类型,均触发 201151 编码错误。
建议
-
恢复对数组字符串二次解析
- 在
encodeMethodFromString 中,若 ABI 声明为 T[] 或 T[n],对该参数字符串先做 JSON.parse,再按数组逻辑打包。
-
文档更新/明示
- 若短期无法支持上述特性,需要在文档中说明“当前版本不支持数组类型
funcParam,请使用原生 calldata 绕过”。
-
临时替代方案
- 推荐增加一个新的接口参数
data,允许直接传入完整 ABI calldata(0x…),后端原生工具完成编码;或支持 rawCallData 选项。
感谢团队审阅,希望能尽快修复这一影响多种场景的数组编码问题!
Issue Title:
v3.1.1:
encodeMethodFromString不支持在funcParam中传递数组类型参数 (uint256[24] 或 uint256[])环境信息
问题概述
在 WeBASE-Front v3.1.1 的交易处理接口中,
funcParam虽然文档(1.5.5+)中宣称“数组类型也需要以字符串形式包裹”(e.g.["0x1a","[\"addr1\",\"addr2\"]"]),但实际底层编码工具encodeMethodFromString不会对单个字符串做二次 JSON 解析,导致任何数组参数都无法被正确打包,始终返回:复现步骤
ABI 定义(固定长度数组)
{ "inputs":[ { "internalType":"uint256[24]","name":"proof","type":"uint256[24]" }, { "internalType":"uint256", "name":"dataHash","type":"uint256" } ], "name":"verifyAssetZK", "outputs":[ { "internalType":"bool","name":"","type":"bool" } ], "stateMutability":"nonpayable", "type":"function" }尝试分步编码 → 发送
请求
/WeBASE-Front/trans/encodeFunction:{ "groupId":"group0", "funcName":"verifyAssetZK", "contractAbi":[ /* 如上 ABI */ ], "funcParam":[ "[\"0xaaa\",\"0xbbb\",…,\"0xzzz\"]", "1234567890" ] }返回(同样直接走 encodeMethodFromString):
{ "code":201151, "errorMessage":"cannot encode in encodeMethodFromString with appropriate interface ABI, make sure params match" }尝试改成动态数组 ABI + 拆平
并将
funcParam拆成 25 条独立字符串:返回依旧:
{ "code":201151, "errorMessage":"cannot encode in encodeMethodFromString with appropriate interface ABI, make sure params match" }原因分析
encodeMethodFromString只支持基本类型的单值参数:因此任何
"[\"…\",\"…\"]"或者拆平的动态数组都不能被识别为数组类型,均触发 201151 编码错误。建议
恢复对数组字符串二次解析
encodeMethodFromString中,若 ABI 声明为T[]或T[n],对该参数字符串先做JSON.parse,再按数组逻辑打包。文档更新/明示
funcParam,请使用原生 calldata 绕过”。临时替代方案
data,允许直接传入完整 ABI calldata(0x…),后端原生工具完成编码;或支持rawCallData选项。感谢团队审阅,希望能尽快修复这一影响多种场景的数组编码问题!