web3.js
web3.js copied to clipboard
2d array with web3 validator
For below scenario, it will fail in web3 validator
inputs: [
{ internalType: "address[]", name: "addr1", type: "address[]" },
{ internalType: "address[][]", name: "addr2", type: "address[][]" },
],
const addr1 = ['0xaddr']
const addr2 [['0xaddr','0xaddr','0xaddr'],['0xaddr'], ['0xaddr','0xaddr'], ...]
contract.methods.xxMethod(addr1, addr2).estimateGas()
check the jsonSchema
{"type":"array","items":[{"type":"array","$id":"addr1","items":{"format":"address","required":true}},{"type":"array","items":[{"type":"array","$id":"addr2","items":{"for
mat":"address","required":true}}]}],"maxItems":2,"minItems":2}
Also the encodeABI method gave wrong output.
Test in web3.js v1.10.2. Works as expected.
Logs
code: 1100,
errors: [
{
keyword: 'maxItems',
instancePath: '/1',
schemaPath: '#1/maxItems',
params: { limit: 1 },
message: 'must NOT have more than 1 items'
}
]
Environment
web3.js 4.4.0
Hi @ernieyang09 thanks for submitting the issue, the devs will take a look at it as soon as possible!👍
Hi @ernieyang09
Hey, I'm interested in working on this one
Great! Feel free to submit a PR and mention this issue on it #6798 Pls tag me so I can ping the team to look into it once it's done @RaghavenderSingh
Hi @SantiagoDevRel @RaghavenderSingh , I encountered the same issue in my work. Since the project is quite urgent, I took the initiative to debug and identify the problem myself. I have already submitted a PR for it. Here is the link: #6836
@EtlesL Thanks