Skip to content

Commit

Permalink
Merge pull request #4 from ignite/chore/remove-redundancy-error-pkg
Browse files Browse the repository at this point in the history
chore: remove redudant error package
  • Loading branch information
Pantani authored Nov 6, 2024
2 parents 49173f0 + 0645ce3 commit 0a82c3e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 177 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ all: tools install lint
## govet: Run go vet.
govet:
@echo Running go vet...
@go vet ./...
@go vet $(shell go list ./... | grep -v '/api')

## govulncheck: Run govulncheck
govulncheck:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ require (
github.com/gorilla/mux v1.8.1
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0
github.com/ignite/modules v0.0.3-0.20241105050027-482388061bf0
github.com/ignite/modules v0.0.3-0.20241106034624-8a3f18117729
github.com/pkg/errors v0.9.1
github.com/spf13/cast v1.6.0
github.com/spf13/cobra v1.8.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -927,8 +927,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
github.com/ianlancetaylor/demangle v0.0.0-20230524184225-eabc099b10ab/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw=
github.com/ignite/modules v0.0.3-0.20241105050027-482388061bf0 h1:qvonR8WK2qH4Le87Y1qt6d6U2E4I09mCDE0BgCCfok4=
github.com/ignite/modules v0.0.3-0.20241105050027-482388061bf0/go.mod h1:Rmv2KTn5jfXL/qkKdaHD4ExJ1eaH1iVQDs+YD4eTV+o=
github.com/ignite/modules v0.0.3-0.20241106034624-8a3f18117729 h1:T3e1/0qilW8g8xIQYlhWdegT3txToTCcWNjnghrfma8=
github.com/ignite/modules v0.0.3-0.20241106034624-8a3f18117729/go.mod h1:Rmv2KTn5jfXL/qkKdaHD4ExJ1eaH1iVQDs+YD4eTV+o=
github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ=
github.com/improbable-eng/grpc-web v0.15.0/go.mod h1:1sy9HKV4Jt9aEs9JSnkWlRJPuPtwNr0l57L4f878wP8=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
Expand Down
6 changes: 4 additions & 2 deletions pkg/errors/critical.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ package errors

import (
"fmt"

sdkerrors "cosmossdk.io/errors"
)

const codespace = "NETWORK-CRITICAL"

var ErrCritical = Register(codespace, 3, "the state of the blockchain is inconsistent or an invariant is broken")
var ErrCritical = sdkerrors.Register(codespace, 3, "the state of the blockchain is inconsistent or an invariant is broken")

// Critical handles and/or returns an error in case a critical error has been encountered:
// - Inconsistent state
// - Broken invariant
func Critical(description string) error {
return Wrap(ErrCritical, description)
return sdkerrors.Wrap(ErrCritical, description)
}

// Criticalf extends a critical error with additional information.
Expand Down
166 changes: 0 additions & 166 deletions pkg/errors/errors.go

This file was deleted.

9 changes: 4 additions & 5 deletions x/profile/keeper/msg_server_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"

"github.com/ignite/network/pkg/errors"
"github.com/ignite/network/x/profile/types"
)

Expand All @@ -23,7 +22,7 @@ func (k msgServer) UpdateValidatorDescription(ctx context.Context, msg *types.Ms

// Check if the validator address is already in the store
validator, err := k.Validator.Get(ctx, msg.Address)
if errors.IsOf(err, collections.ErrNotFound) {
if errorsmod.IsOf(err, collections.ErrNotFound) {
validator = types.Validator{
Address: msg.Address,
Description: types.ValidatorDescription{},
Expand All @@ -48,7 +47,7 @@ func (k msgServer) UpdateValidatorDescription(ctx context.Context, msg *types.Ms
validator.Description.SecurityContact = msg.SecurityContact
}

if errors.IsOf(err, collections.ErrNotFound) {
if errorsmod.IsOf(err, collections.ErrNotFound) {
err = sdk.UnwrapSDKContext(ctx).EventManager().EmitTypedEvent(
&types.EventValidatorCreated{
Address: validator.Address,
Expand Down Expand Up @@ -83,7 +82,7 @@ func (k msgServer) AddValidatorOperatorAddress(ctx context.Context, msg *types.M

// get the current validator to eventually overwrite description and add opAddr
validatorStore, err := k.Validator.Get(ctx, valAddr)
if !errors.IsOf(err, collections.ErrNotFound) {
if !errorsmod.IsOf(err, collections.ErrNotFound) {
validator.Description = validatorStore.Description
validator = validatorStore.AddValidatorOperatorAddress(opAddr)
}
Expand All @@ -100,7 +99,7 @@ func (k msgServer) AddValidatorOperatorAddress(ctx context.Context, msg *types.M
}

sdkCtx := sdk.UnwrapSDKContext(ctx)
if !errors.IsOf(err, collections.ErrNotFound) {
if !errorsmod.IsOf(err, collections.ErrNotFound) {
err = sdkCtx.EventManager().EmitTypedEvent(
&types.EventValidatorOperatorAddressesUpdated{
Address: validator.Address,
Expand Down

0 comments on commit 0a82c3e

Please sign in to comment.