diff --git a/client/chain/chain.go b/client/chain/chain.go index 07b713eb..a37c0b3a 100644 --- a/client/chain/chain.go +++ b/client/chain/chain.go @@ -2,7 +2,6 @@ package chain import ( "context" - sdkmath "cosmossdk.io/math" "encoding/base64" "encoding/hex" "encoding/json" @@ -14,6 +13,8 @@ import ( "sync/atomic" "time" + sdkmath "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" @@ -832,7 +833,7 @@ func (c *chainClient) SyncBroadcastSignedTx(txBytes []byte) (*txtypes.BroadcastT case <-t.C: resultTx, err := c.ctx.Client.Tx(awaitCtx, txHash, false) if err != nil { - if errRes := client.CheckTendermintError(err, txBytes); errRes != nil { + if errRes := client.CheckCometError(err, txBytes); errRes != nil { return &txtypes.BroadcastTxResponse{TxResponse: errRes}, err } @@ -903,7 +904,7 @@ func (c *chainClient) broadcastTx( case <-t.C: resultTx, err := clientCtx.Client.Tx(awaitCtx, txHash, false) if err != nil { - if errRes := client.CheckTendermintError(err, txBytes); errRes != nil { + if errRes := client.CheckCometError(err, txBytes); errRes != nil { return &txtypes.BroadcastTxResponse{TxResponse: errRes}, err } diff --git a/client/chain/chain_test_support.go b/client/chain/chain_test_support.go index 74140cc6..de867442 100644 --- a/client/chain/chain_test_support.go +++ b/client/chain/chain_test_support.go @@ -2,10 +2,11 @@ package chain import ( "context" - sdkmath "cosmossdk.io/math" "errors" "time" + sdkmath "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/client/grpc/cmtservice" "google.golang.org/grpc" diff --git a/client/core/market_test.go b/client/core/market_test.go index bbe37e70..64a58679 100644 --- a/client/core/market_test.go +++ b/client/core/market_test.go @@ -1,9 +1,10 @@ package core import ( - sdkmath "cosmossdk.io/math" "testing" + sdkmath "cosmossdk.io/math" + "github.com/huandu/go-assert" "github.com/shopspring/decimal" ) diff --git a/eip712_cosmos.go b/eip712_cosmos.go index 8107f903..3f3ad3d5 100644 --- a/eip712_cosmos.go +++ b/eip712_cosmos.go @@ -10,14 +10,14 @@ import ( "strings" "time" - sdkmath "cosmossdk.io/math" + "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cosmtypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/math" + ethmath "github.com/ethereum/go-ethereum/common/math" "github.com/pkg/errors" "github.com/InjectiveLabs/sdk-go/typeddata" @@ -53,7 +53,6 @@ func WrapTxToEIP712( timeoutHeight, feeInfo, msgs, memo, - nil, ) txData := make(map[string]interface{}) @@ -65,7 +64,7 @@ func WrapTxToEIP712( domain := typeddata.TypedDataDomain{ Name: "Injective Web3", Version: "1.0.0", - ChainId: math.NewHexOrDecimal256(int64(chainID)), + ChainId: ethmath.NewHexOrDecimal256(int64(chainID)), VerifyingContract: "cosmos", Salt: "0", } @@ -291,7 +290,7 @@ func traverseFields( fieldPrefix := fmt.Sprintf("%s.%s", prefix, fieldName) ethTyp := typToEth(fieldType) - if len(ethTyp) > 0 { + if ethTyp != "" { if isCollection { ethTyp += "[]" } @@ -380,7 +379,7 @@ var ( hashType = reflect.TypeOf(common.Hash{}) addressType = reflect.TypeOf(common.Address{}) bigIntType = reflect.TypeOf(big.Int{}) - cosmIntType = reflect.TypeOf(sdkmath.Int{}) + cosmIntType = reflect.TypeOf(math.Int{}) cosmosAnyType = reflect.TypeOf(&codectypes.Any{}) timeType = reflect.TypeOf(time.Time{}) ) @@ -415,12 +414,12 @@ func typToEth(typ reflect.Type) string { return "uint64" case reflect.Slice: ethName := typToEth(typ.Elem()) - if len(ethName) > 0 { + if ethName != "" { return ethName + "[]" } case reflect.Array: ethName := typToEth(typ.Elem()) - if len(ethName) > 0 { + if ethName != "" { return ethName + "[]" } case reflect.Ptr: @@ -501,7 +500,7 @@ func WrapTxToEIP712V2( domain := typeddata.TypedDataDomain{ Name: "Injective Web3", Version: "1.0.0", - ChainId: math.NewHexOrDecimal256(int64(chainID)), + ChainId: ethmath.NewHexOrDecimal256(int64(chainID)), VerifyingContract: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC", Salt: "0", } diff --git a/typeddata/typed_data.go b/typeddata/typed_data.go index bff47192..e23efe82 100644 --- a/typeddata/typed_data.go +++ b/typeddata/typed_data.go @@ -784,19 +784,19 @@ func (domain *TypedDataDomain) Map() map[string]interface{} { dataMap["chainId"] = domain.ChainId } - if len(domain.Name) > 0 { + if domain.Name != "" { dataMap["name"] = domain.Name } - if len(domain.Version) > 0 { + if domain.Version != "" { dataMap["version"] = domain.Version } - if len(domain.VerifyingContract) > 0 { + if domain.VerifyingContract != "" { dataMap["verifyingContract"] = domain.VerifyingContract } - if len(domain.Salt) > 0 { + if domain.Salt != "" { dataMap["salt"] = domain.Salt } return dataMap