github.com/0xPolygon/supernets2-node@v0.0.0-20230711153321-2fe574524eaa/test/vectors/types.go (about) 1 package vectors 2 3 import ( 4 "math/big" 5 "strings" 6 7 "github.com/0xPolygon/supernets2-node/encoding" 8 "github.com/0xPolygon/supernets2-node/hex" 9 ) 10 11 type argBigInt struct { 12 big.Int 13 } 14 15 func (a argBigInt) MarshalJSON() ([]byte, error) { 16 return []byte(a.Text(hex.Base)), nil 17 } 18 19 func (a *argBigInt) UnmarshalJSON(input []byte) error { 20 str := strings.Trim(string(input), "\"") 21 if strings.ToLower(strings.TrimSpace(str)) == "null" { 22 return nil 23 } 24 25 bi, err := encoding.DecodeUint256orHex(&str) 26 if err != nil { 27 return err 28 } 29 30 a.Int = *bi 31 32 return nil 33 }