Skip to content

Commit

Permalink
small ref
Browse files Browse the repository at this point in the history
  • Loading branch information
quasisamurai committed May 26, 2023
1 parent a2bdf5c commit f6ee9f5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 29 deletions.
44 changes: 22 additions & 22 deletions x/interchainqueries/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ import (

// x/interchainqueries module sentinel errors
var (
ErrInvalidQueryID = sdkerrors.Register(ModuleName, 1100, "invalid query id")
ErrEmptyResult = sdkerrors.Register(ModuleName, 1101, "empty result")
ErrInvalidClientID = sdkerrors.Register(ModuleName, 1102, "invalid client id")
ErrInvalidUpdatePeriod = sdkerrors.Register(ModuleName, 1103, "invalid update period")
ErrInvalidConnectionID = sdkerrors.Register(ModuleName, 1104, "invalid connection id")
ErrInvalidQueryType = sdkerrors.Register(ModuleName, 1105, "invalid query type")
ErrInvalidTransactionsFilter = sdkerrors.Register(ModuleName, 1106, "invalid transactions filter")
ErrInvalidSubmittedResult = sdkerrors.Register(ModuleName, 1107, "invalid result")
ErrProtoMarshal = sdkerrors.Register(ModuleName, 1108, "failed to marshal protobuf bytes")
ErrProtoUnmarshal = sdkerrors.Register(ModuleName, 1109, "failed to unmarshal protobuf bytes")
ErrInvalidType = sdkerrors.Register(ModuleName, 1110, "invalid type")
ErrInternal = sdkerrors.Register(ModuleName, 1111, "internal error")
ErrInvalidProof = sdkerrors.Register(ModuleName, 1112, "merkle proof is invalid")
ErrInvalidHeader = sdkerrors.Register(ModuleName, 1113, "header is invalid")
ErrInvalidHeight = sdkerrors.Register(ModuleName, 1114, "height is invalid")
ErrNoQueryResult = sdkerrors.Register(ModuleName, 1115, "no query result")
ErrNotContract = sdkerrors.Register(ModuleName, 1116, "not a contract")
ErrEmptyKeys = sdkerrors.Register(ModuleName, 1117, "keys are empty")
ErrEmptyKeyPath = sdkerrors.Register(ModuleName, 1118, "key path is empty")
ErrEmptyKeyID = sdkerrors.Register(ModuleName, 1119, "key id is empty")
ErrTooManyKVQueryKeys = sdkerrors.Register(ModuleName, 1120, "too many keys")
ErrEmptyQueryTypeGenesis = sdkerrors.Register(ModuleName, 1121, "empty query type")
ErrInvalidQueryID = sdkerrors.Register(ModuleName, 1100, "invalid query id")
ErrEmptyResult = sdkerrors.Register(ModuleName, 1101, "empty result")
ErrInvalidClientID = sdkerrors.Register(ModuleName, 1102, "invalid client id")
ErrInvalidUpdatePeriod = sdkerrors.Register(ModuleName, 1103, "invalid update period")
ErrInvalidConnectionID = sdkerrors.Register(ModuleName, 1104, "invalid connection id")
ErrInvalidQueryType = sdkerrors.Register(ModuleName, 1105, "invalid query type")
ErrInvalidTransactionsFilter = sdkerrors.Register(ModuleName, 1106, "invalid transactions filter")
ErrInvalidSubmittedResult = sdkerrors.Register(ModuleName, 1107, "invalid result")
ErrProtoMarshal = sdkerrors.Register(ModuleName, 1108, "failed to marshal protobuf bytes")
ErrProtoUnmarshal = sdkerrors.Register(ModuleName, 1109, "failed to unmarshal protobuf bytes")
ErrInvalidType = sdkerrors.Register(ModuleName, 1110, "invalid type")
ErrInternal = sdkerrors.Register(ModuleName, 1111, "internal error")
ErrInvalidProof = sdkerrors.Register(ModuleName, 1112, "merkle proof is invalid")
ErrInvalidHeader = sdkerrors.Register(ModuleName, 1113, "header is invalid")
ErrInvalidHeight = sdkerrors.Register(ModuleName, 1114, "height is invalid")
ErrNoQueryResult = sdkerrors.Register(ModuleName, 1115, "no query result")
ErrNotContract = sdkerrors.Register(ModuleName, 1116, "not a contract")
ErrEmptyKeys = sdkerrors.Register(ModuleName, 1117, "keys are empty")
ErrEmptyKeyPath = sdkerrors.Register(ModuleName, 1118, "key path is empty")
ErrEmptyKeyID = sdkerrors.Register(ModuleName, 1119, "key id is empty")
ErrTooManyKVQueryKeys = sdkerrors.Register(ModuleName, 1120, "too many keys")
ErrUnexpectedQueryTypeGenesis = sdkerrors.Register(ModuleName, 1121, "empty query type")
)
12 changes: 5 additions & 7 deletions x/interchainqueries/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,20 @@ func (gs GenesisState) Validate() error {
return sdkerrors.Wrapf(err, "Invalid owner address (%s)", err)
}

if val.QueryType == "" {
return sdkerrors.Wrapf(ErrEmptyQueryTypeGenesis, "Query type is empty, id: %d", val.Id)
}

if val.QueryType == "tx" {
switch val.QueryType {
case "tx":
if err := ValidateTransactionsFilter(val.TransactionsFilter); err != nil {
return sdkerrors.Wrap(ErrInvalidTransactionsFilter, err.Error())
}
}
if val.QueryType == "kv" {
case "kv":
if len(val.Keys) == 0 {
return sdkerrors.Wrap(ErrEmptyKeys, "keys cannot be empty")
}
if err := validateKeys(val.GetKeys()); err != nil {
return err
}
default:
return sdkerrors.Wrapf(ErrUnexpectedQueryTypeGenesis, "Unexpected query type: %s", val.QueryType)
}
}
return nil
Expand Down

0 comments on commit f6ee9f5

Please sign in to comment.