Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
fixes for 19.0.1 (#1305)
Browse files Browse the repository at this point in the history
* fixes for 19.0.1

* changelog

* changelog

Co-authored-by: Federico Kunze Küllmer <[email protected]>
  • Loading branch information
ramacarlucho and fedekunze authored Aug 26, 2022
1 parent 524e25c commit c9fe1d1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
recompute eth tx hashes in JSON-RPC APIs to fix old blocks.
* (deps) [#1168](https://github.com/evmos/ethermint/pull/1168) Upgrade cosmos-sdk to v0.46.
* (feemarket) [#1194](https://github.com/evmos/ethermint/pull/1194) Apply feemarket to native cosmos tx.
* (eth) [#1305](https://github.com/evmos/ethermint/pull/1305) Added support for optional params, basic types arrays and `time` type on eip712.

### API Breaking

Expand Down
14 changes: 14 additions & 0 deletions ethereum/eip712/eip712.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"math/big"
"reflect"
"strings"
"time"

sdkmath "cosmossdk.io/math"
"golang.org/x/text/cases"
Expand Down Expand Up @@ -232,6 +233,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()
Expand Down Expand Up @@ -296,6 +302,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,
Expand Down Expand Up @@ -381,6 +392,7 @@ var (
bigIntType = reflect.TypeOf(big.Int{})
cosmIntType = reflect.TypeOf(sdkmath.Int{})
cosmosAnyType = reflect.TypeOf(&codectypes.Any{})
timeType = reflect.TypeOf(time.Time{})
)

// typToEth supports only basic types and arrays of basic types.
Expand Down Expand Up @@ -425,13 +437,15 @@ func typToEth(typ reflect.Type) string {
}
case reflect.Ptr:
if typ.Elem().ConvertibleTo(bigIntType) ||
typ.Elem().ConvertibleTo(timeType) ||
typ.Elem().ConvertibleTo(cosmIntType) {
return str
}
case reflect.Struct:
if typ.ConvertibleTo(hashType) ||
typ.ConvertibleTo(addressType) ||
typ.ConvertibleTo(bigIntType) ||
typ.ConvertibleTo(timeType) ||
typ.ConvertibleTo(cosmIntType) {
return str
}
Expand Down

0 comments on commit c9fe1d1

Please sign in to comment.