Closed 0xfaceDEFI closed 1 year ago
Apologize for the late response.
The error is that the abi
encoder does not know how to match the inputs in the function signature with the struct. If it were a list instead, it matches by index (i.e. input at index 1 is item at index 1) but it needs a name when working with structs.
To fix it, you have to assign a name to the input and a tag to the fields in the struct:
type SwapParams struct {
PoolID [32]byte `abi:"a"`
Kind *big.Int `abi:"b"`
AssertIn string `abi:"c"`
AssertOut string `abi:"d"`
Amount *big.Int `abi:"e"`
UserData []byte `abi:"f"`
}
type FunderParams struct {
Sender string `abi:"a"`
FromInternalBalance bool `abi:"b"`
Recipient string `abi:"c"`
ToInternalBalance bool `abi:"d"`
}
...
encodeData, err := MethodEncode("swap((bytes32 a,uint8 b,address c,address d,uint256 e,bytes f),(address a,bool b,address c,bool d),uint256,uint256)", swapParams, funderParams, 1, 1)
if err != nil {
panic(err)
}
code
result