abi struct tags only work in lower case
Closed this issue · 2 comments
cyberhorsey commented
package main
import (
"github.com/umbracle/ethgo/abi"
)
var (
t = abi.MustNewType("tuple(tuple(bytes32 camelCase) header)")
)
type Header struct {
Slice []byte `abi:"camelCase"`
}
type Proof struct {
Header Header
}
func main() {
b := Header{
Slice: []byte{01},
}
s := Proof{
Header: b,
}
_, err := t.Encode(s)
if err != nil {
panic(err)
}
}
gives error cannot get key camelCase
, yet removing the capital C works.
cyberhorsey commented
additionally, is there any way to do a bytes, bytes
type?
ie: i have (bytes account, bytes storage = abi.decode(b)
where b
is a bytes[]
in my Solidity contract.
In Ethers, I would do:
ethers.defaultAbiCoder.Encode(["bytes", "bytes"], [account, storage]
ferranbt commented
gives error cannot get key camelCase, yet removing the capital C works.
Merging your PR, thank you for the contribution!
additionally, is there any way to do a bytes, bytes type?
Yes, it should be possible doing something like:
t := abi.MustNewType("tuple(bytes, bytes)")
t.Decode([]byte{...})