Skip to content

Commit

Permalink
Moved errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bermuell committed Oct 11, 2023
1 parent 7bc1358 commit 8d62477
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion x/ccv/provider/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func (k Keeper) VerifyConsumerChain(ctx sdk.Context, channelID string, connectio
return errorsmod.Wrapf(ccv.ErrClientNotFound, "cannot find client for consumer chain %s", tmClient.ChainId)
}
if ccvClientId != clientID {
return errorsmod.Wrapf(ccv.ErrInvalidConsumerClient, "CCV channel must be built on top of CCV client. expected %s, got %s", ccvClientId, clientID)
return errorsmod.Wrapf(types.ErrInvalidConsumerClient, "CCV channel must be built on top of CCV client. expected %s, got %s", ccvClientId, clientID)
}

// Verify that there isn't already a CCV channel for the consumer chain
Expand Down
4 changes: 2 additions & 2 deletions x/ccv/provider/keeper/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (k Keeper) CreateConsumerClient(ctx sdk.Context, prop *types.ConsumerAdditi
chainID := prop.ChainId
// check that a client for this chain does not exist
if _, found := k.GetConsumerClientId(ctx, chainID); found {
return errorsmod.Wrap(ccv.ErrDuplicateConsumerChain,
return errorsmod.Wrap(types.ErrDuplicateConsumerChain,
fmt.Sprintf("cannot create client for existent consumer chain: %s", chainID))
}

Expand Down Expand Up @@ -155,7 +155,7 @@ func (k Keeper) HandleConsumerRemovalProposal(ctx sdk.Context, p *types.Consumer
func (k Keeper) StopConsumerChain(ctx sdk.Context, chainID string, closeChan bool) (err error) {
// check that a client for chainID exists
if _, found := k.GetConsumerClientId(ctx, chainID); !found {
return errorsmod.Wrap(ccv.ErrConsumerChainNotFound,
return errorsmod.Wrap(types.ErrConsumerChainNotFound,
fmt.Sprintf("cannot stop non-existent consumer chain: %s", chainID))
}

Expand Down
4 changes: 2 additions & 2 deletions x/ccv/provider/keeper/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ func (k Keeper) EndBlockCCR(ctx sdk.Context) {
"chainID", initTimeoutTimestamp.ChainId)
err := k.StopConsumerChain(ctx, initTimeoutTimestamp.ChainId, false)
if err != nil {
if ccv.ErrConsumerChainNotFound.Is(err) {
if providertypes.ErrConsumerChainNotFound.Is(err) {
// consumer chain not found
continue
}
Expand All @@ -479,7 +479,7 @@ func (k Keeper) EndBlockCCR(ctx sdk.Context) {
)
err := k.StopConsumerChain(ctx, channelToChain.ChainId, true)
if err != nil {
if ccv.ErrConsumerChainNotFound.Is(err) {
if providertypes.ErrConsumerChainNotFound.Is(err) {
// consumer chain not found
continue
}
Expand Down
3 changes: 3 additions & 0 deletions x/ccv/provider/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ var (
ErrInvalidProviderAddress = errorsmod.Register(ModuleName, 13, "invalid provider address")
ErrInvalidConsumerRewardDenom = errorsmod.Register(ModuleName, 14, "invalid consumer reward denom")
ErrInvalidDepositorAddress = errorsmod.Register(ModuleName, 15, "invalid depositor address")
ErrInvalidConsumerClient = errorsmod.Register(ModuleName, 16, "ccv channel is not built on correct client")
ErrDuplicateConsumerChain = errorsmod.Register(ModuleName, 17, "consumer chain already exists")
ErrConsumerChainNotFound = errorsmod.Register(ModuleName, 18, "consumer chain not found")
)
23 changes: 10 additions & 13 deletions x/ccv/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@ import (

// CCV sentinel errors
var (
ErrInvalidPacketData = errorsmod.Register(ModuleName, 2, "invalid CCV packet data")
ErrInvalidVersion = errorsmod.Register(ModuleName, 4, "invalid CCV version")
ErrInvalidChannelFlow = errorsmod.Register(ModuleName, 5, "invalid message sent to channel end")
ErrInvalidGenesis = errorsmod.Register(ModuleName, 9, "invalid genesis state")
ErrDuplicateChannel = errorsmod.Register(ModuleName, 10, "CCV channel already exists")
ErrInvalidVSCMaturedId = errorsmod.Register(ModuleName, 11, "invalid vscId for VSC packet")
ErrInvalidVSCMaturedTime = errorsmod.Register(ModuleName, 12, "invalid maturity time for VSC packet")
ErrInvalidConsumerClient = errorsmod.Register(ModuleName, 14, "ccv channel is not built on correct client")
ErrInvalidHandshakeMetadata = errorsmod.Register(ModuleName, 16, "invalid provider handshake metadata")
ErrChannelNotFound = errorsmod.Register(ModuleName, 17, "channel not found")
ErrClientNotFound = errorsmod.Register(ModuleName, 18, "client not found")
ErrDuplicateConsumerChain = errorsmod.Register(ModuleName, 19, "consumer chain already exists")
ErrConsumerChainNotFound = errorsmod.Register(ModuleName, 20, "consumer chain not found")
ErrInvalidPacketData = errorsmod.Register(ModuleName, 1, "invalid CCV packet data")
ErrInvalidVersion = errorsmod.Register(ModuleName, 2, "invalid CCV version")
ErrInvalidChannelFlow = errorsmod.Register(ModuleName, 3, "invalid message sent to channel end")
ErrInvalidGenesis = errorsmod.Register(ModuleName, 4, "invalid genesis state")
ErrDuplicateChannel = errorsmod.Register(ModuleName, 5, "CCV channel already exists")
ErrInvalidVSCMaturedId = errorsmod.Register(ModuleName, 6, "invalid vscId for VSC packet")
ErrInvalidVSCMaturedTime = errorsmod.Register(ModuleName, 7, "invalid maturity time for VSC packet")
ErrInvalidHandshakeMetadata = errorsmod.Register(ModuleName, 8, "invalid provider handshake metadata")
ErrChannelNotFound = errorsmod.Register(ModuleName, 9, "channel not found")
ErrClientNotFound = errorsmod.Register(ModuleName, 10, "client not found")
)

0 comments on commit 8d62477

Please sign in to comment.