Hi @BoxChen
Thanks for your PR on web3protocol-go at Add array and tuple params support by nishuzumi · Pull Request #1 · web3-protocol/web3protocol-go · GitHub , I can see there is quite some work.
You are looking at adding array/tuple as input to auto mode, that’s a good idea!
I think we should review the specification first here:
-
For tuple arg, I see your example
/functionName/(bool,uint256,bool,uint256[])!(true,123,false,[456,789])
: reusing thereturns=
syntax is a good idea. Question for the values: how to handle the,
,(
,)
,[
,]
special chars in string values? For example, let’s say I have/functionName/(string,uint)!...
and I want to pass thehello "a,")
string as the first parameter,/functionName/(string,uint)!(hello "a,"),1234)
won’t work. I believe the solution is : we add optional double-quotes to the string value (with the support of quote escaping\"
), so that here we have/functionName/(string,uint)!("hello \"a,\")",1234)
. Any other idea? -
For array arg, you propose
/functionName/uint64[]![1,3,5]
: sound good to me. We should also support multidimensional arrays, such as/functionName/uint64[2][2]![[1,2],[3,4]]
. And with the above suggestion of optional double quotes for string values, we would have for example/functionName/string[]![1,abcd,"bla[]"]
, which will send the array of 3 strings1
,abcd
andbla[]
to the smart contract.
And of course we should support recursion, with e.g. array of structs such as /funcName/(uint,bool)[]![(1,false),(2,false)]
, complex mix such as /funcName/((uint,(bool,bool),string[])[],bool)!([(5,(true,true),[boo,baa]),(2,(false,true),[aa,")"])],true)
, …
Any input/ideas on this rough specification? (If you want, I can do the whole writing on this on the ERC, or you can propose a PR, as you want.)
Thanks for working on this, it is a non-trivial item.