Fix lint errors
This commit is contained in:
parent
cffaf547a9
commit
f51de891e9
@ -24,6 +24,8 @@ import (
|
||||
"github.com/ethereum/go-ethereum/signer/core/apitypes"
|
||||
)
|
||||
|
||||
const bytesStr = "bytes"
|
||||
|
||||
// WrapTxToTypedData is an ultimate method that wraps Amino-encoded Cosmos Tx JSON data
|
||||
// into an EIP712-compatible TypedData request.
|
||||
func WrapTxToTypedData(
|
||||
@ -33,7 +35,6 @@ func WrapTxToTypedData(
|
||||
data []byte,
|
||||
feeDelegation *FeeDelegationOptions,
|
||||
) (apitypes.TypedData, error) {
|
||||
|
||||
domain := apitypes.TypedDataDomain{
|
||||
Name: "Cosmos Web3",
|
||||
Version: "1.0.0",
|
||||
@ -298,7 +299,7 @@ func traverseFields(
|
||||
}
|
||||
// convert uint8[] to bytes
|
||||
if fieldType.Kind() == reflect.Uint8 {
|
||||
ethTyp = "bytes"
|
||||
ethTyp = bytesStr
|
||||
}
|
||||
}
|
||||
if prefix == typeDefPrefix {
|
||||
@ -448,7 +449,7 @@ func typToEth(typ reflect.Type) string {
|
||||
ethName := typToEth(typ.Elem())
|
||||
if len(ethName) > 0 {
|
||||
if ethName == "uint8" {
|
||||
return "bytes"
|
||||
return bytesStr
|
||||
}
|
||||
return ethName + "[]"
|
||||
}
|
||||
@ -495,7 +496,9 @@ func patchTxData(data map[string]any, schema apitypes.Types, rootType string) er
|
||||
for _, field := range schema[rootType] {
|
||||
encType := field.Type
|
||||
encValue := data[field.Name]
|
||||
if encType[len(encType)-1:] == "]" {
|
||||
|
||||
switch {
|
||||
case encType[len(encType)-1:] == "]":
|
||||
arrayValue, ok := encValue.([]interface{})
|
||||
if !ok {
|
||||
return dataMismatchError(encType, encValue)
|
||||
@ -523,8 +526,7 @@ func patchTxData(data map[string]any, schema apitypes.Types, rootType string) er
|
||||
arrayValue[i] = converted
|
||||
}
|
||||
}
|
||||
|
||||
} else if schema[encType] != nil {
|
||||
case schema[encType] != nil:
|
||||
mapValue, ok := encValue.(map[string]interface{})
|
||||
if !ok {
|
||||
return dataMismatchError(encType, encValue)
|
||||
@ -533,7 +535,7 @@ func patchTxData(data map[string]any, schema apitypes.Types, rootType string) er
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
default:
|
||||
converted, err := handleConversion(encType, encValue)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -545,8 +547,7 @@ func patchTxData(data map[string]any, schema apitypes.Types, rootType string) er
|
||||
}
|
||||
|
||||
func handleConversion(encType string, encValue any) (any, error) {
|
||||
switch encType {
|
||||
case "bytes":
|
||||
if encType == bytesStr {
|
||||
// Protobuf encodes byte strings in base64
|
||||
if v, ok := encValue.(string); ok {
|
||||
return base64.StdEncoding.DecodeString(v)
|
||||
|
@ -5,7 +5,6 @@ import "google/protobuf/duration.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
import "cosmos/base/v1beta1/coin.proto";
|
||||
import "google/protobuf/any.proto";
|
||||
|
||||
option go_package = "github.com/cerc-io/laconicd/x/registry/types";
|
||||
|
||||
|
@ -62,7 +62,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryParams() {
|
||||
}
|
||||
}
|
||||
|
||||
// nolint: all
|
||||
//nolint:all
|
||||
func (s *IntegrationTestSuite) TestGRPCQueryWhoIs() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
@ -182,7 +182,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryLookup() {
|
||||
}
|
||||
}
|
||||
|
||||
// nolint: all
|
||||
//nolint:all
|
||||
func (s *IntegrationTestSuite) TestGRPCQueryRecordExpiryQueue() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
@ -254,7 +254,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryRecordExpiryQueue() {
|
||||
}
|
||||
}
|
||||
|
||||
// nolint: all
|
||||
//nolint:all
|
||||
func (s *IntegrationTestSuite) TestGRPCQueryAuthorityExpiryQueue() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
@ -326,7 +326,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryAuthorityExpiryQueue() {
|
||||
}
|
||||
}
|
||||
|
||||
// nolint: all
|
||||
//nolint:all
|
||||
func (s *IntegrationTestSuite) TestGRPCQueryListRecords() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
|
@ -337,7 +337,10 @@ func (k Keeper) PutRecord(ctx sdk.Context, record types.Record) {
|
||||
func (k Keeper) processAttributes(ctx sdk.Context, attrs map[string]any, id string, prefix string) error {
|
||||
for key, value := range attrs {
|
||||
if subRecord, ok := value.(map[string]any); ok {
|
||||
k.processAttributes(ctx, subRecord, id, key)
|
||||
err := k.processAttributes(ctx, subRecord, id, key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
indexKey := GetAttributesIndexKey(prefix+key, value)
|
||||
if err := k.SetAttributeMapping(ctx, indexKey, id); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user