diff --git a/CHANGELOG.md b/CHANGELOG.md index d8b7217d94..8168bf0b52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,12 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog +## [v0.19.1] - 2022-08-26 + +### State Machine Breaking + +* (eth) [#1305](https://github.com/evmos/ethermint/pull/1305) Added support for optional params, basic types arrays and `time` type on eip712. + ## [v0.19.0] - 2022-08-15 ### State Machine Breaking diff --git a/ethereum/eip712/eip712.go b/ethereum/eip712/eip712.go index 60b343b76a..50edf84915 100644 --- a/ethereum/eip712/eip712.go +++ b/ethereum/eip712/eip712.go @@ -7,6 +7,7 @@ import ( "math/big" "reflect" "strings" + "time" "golang.org/x/text/cases" "golang.org/x/text/language" @@ -231,6 +232,11 @@ func traverseFields( // then continue as normal } + // If its a nil pointer, do not include in types + if fieldType.Kind() == reflect.Ptr && field.IsNil() { + continue + } + for { if fieldType.Kind() == reflect.Ptr { fieldType = fieldType.Elem() @@ -295,6 +301,11 @@ func traverseFields( ethTyp := typToEth(fieldType) if len(ethTyp) > 0 { + // Support array of uint64 + if isCollection && fieldType.Kind() != reflect.Slice && fieldType.Kind() != reflect.Array { + ethTyp += "[]" + } + if prefix == typeDefPrefix { typeMap[rootType] = append(typeMap[rootType], apitypes.Type{ Name: fieldName, @@ -381,6 +392,7 @@ var ( bigIntType = reflect.TypeOf(big.Int{}) cosmIntType = reflect.TypeOf(sdk.Int{}) cosmosAnyType = reflect.TypeOf(&codectypes.Any{}) + timeType = reflect.TypeOf(time.Time{}) ) // typToEth supports only basic types and arrays of basic types. @@ -425,6 +437,7 @@ func typToEth(typ reflect.Type) string { } case reflect.Ptr: if typ.Elem().ConvertibleTo(bigIntType) || + typ.Elem().ConvertibleTo(timeType) || typ.Elem().ConvertibleTo(cosmIntType) { return str } @@ -432,6 +445,7 @@ func typToEth(typ reflect.Type) string { if typ.ConvertibleTo(hashType) || typ.ConvertibleTo(addressType) || typ.ConvertibleTo(bigIntType) || + typ.ConvertibleTo(timeType) || typ.ConvertibleTo(cosmIntType) { return str }