Skip to content

Commit

Permalink
fix: correctly handle errors
Browse files Browse the repository at this point in the history
  • Loading branch information
johnletey committed May 20, 2024
1 parent 172acc0 commit 12a1746
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/cosmos/cosmos-sdk v0.50.6
github.com/cosmos/gogoproto v1.4.12
github.com/cosmos/ibc-go/v8 v8.2.1
github.com/icza/dyno v0.0.0-20220812133438-f0b6f8a18845
github.com/noble-assets/forwarding/v2 v2.0.0
github.com/strangelove-ventures/interchaintest/v8 v8.2.0
github.com/stretchr/testify v1.9.0
Expand Down Expand Up @@ -139,7 +140,6 @@ require (
github.com/holiman/uint256 v1.2.4 // indirect
github.com/huandu/skiplist v1.2.0 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/icza/dyno v0.0.0-20220812133438-f0b6f8a18845 // indirect
github.com/improbable-eng/grpc-web v0.15.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/ipfs/go-cid v0.4.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ require (
cosmossdk.io/collections v0.4.0
cosmossdk.io/core v0.11.0
cosmossdk.io/depinject v1.0.0-alpha.4
cosmossdk.io/errors v1.0.1
cosmossdk.io/log v1.3.1
cosmossdk.io/store v1.1.0
github.com/cometbft/cometbft v0.38.6
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.50.6
github.com/cosmos/gogoproto v1.4.12
Expand All @@ -30,7 +30,6 @@ require (
4d63.com/gochecknoglobals v0.2.1 // indirect
cloud.google.com/go/storage v1.37.0 // indirect
cosmossdk.io/client/v2 v2.0.0-beta.1.0.20240124105859-5ad1805d0e79 // indirect
cosmossdk.io/errors v1.0.1 // indirect
cosmossdk.io/math v1.3.0 // indirect
cosmossdk.io/x/tx v0.13.2 // indirect
cosmossdk.io/x/upgrade v0.1.1 // indirect
Expand Down Expand Up @@ -79,6 +78,7 @@ require (
github.com/cockroachdb/pebble v1.1.0 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cometbft/cometbft v0.38.6 // indirect
github.com/cometbft/cometbft-db v0.9.1 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-db v1.0.2 // indirect
Expand Down
9 changes: 6 additions & 3 deletions x/forwarding/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ func (k *Keeper) ClearAccount(ctx context.Context, msg *types.MsgClearAccount) (
return &types.MsgClearAccountResponse{}, nil
}

fallback, _ := k.accountKeeper.AddressCodec().StringToBytes(account.Fallback)
fallback, err := k.accountKeeper.AddressCodec().StringToBytes(account.Fallback)
if err != nil {
return nil, sdkerrors.Wrap(err, "failed to decode fallback address")
}
err = k.bankKeeper.SendCoins(ctx, address, fallback, balance)
if err != nil {
return nil, errors.New("failed to clear balance to fallback account")
Expand All @@ -127,8 +130,8 @@ func (k *Keeper) SetAllowedDenoms(ctx context.Context, msg *types.MsgSetAllowedD
return nil, sdkerrors.Wrap(types.ErrInvalidDenoms, err.Error())
}

for _, denom := range k.GetAllowedDenoms(ctx) {
_ = k.AllowedDenoms.Remove(ctx, denom)
if err := k.AllowedDenoms.Clear(ctx, nil); err != nil {
return nil, errors.New("failed to clear allowed denoms from state")
}
for _, denom := range msg.Denoms {
err := k.AllowedDenoms.Set(ctx, denom)
Expand Down

0 comments on commit 12a1746

Please sign in to comment.