Skip to content

Commit

Permalink
Improve error handling logic in abci address checking
Browse files Browse the repository at this point in the history
  • Loading branch information
johnletey authored Apr 11, 2024
1 parent eb8b9b3 commit 0bd3e0f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions x/fiattokenfactory/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,21 @@ func (k *Keeper) HandleDeliverTxEvent(ctx sdk.Context, event abci.Event) error {
}

// Check if sender is blacklisted.
_, found := k.GetBlacklisted(ctx, sdk.MustAccAddressFromBech32(sender))
senderBz, err := sdk.AccAddressFromBech32(sender)
if err != nil {
return errors.Wrapf(types.ErrUnauthorized, "failed to parse sender %s", sender)
}
_, found := k.GetBlacklisted(ctx, senderBz)
if found {
return errors.Wrapf(types.ErrUnauthorized, "%s can not send tokens", sender)
}

// Check if recipient is blacklisted.
_, found = k.GetBlacklisted(ctx, sdk.MustAccAddressFromBech32(recipient))
recipientBz, err := sdk.AccAddressFromBech32(recipient)
if err != nil {
return errors.Wrapf(types.ErrUnauthorized, "failed to parse recipient %s", recipient)
}
_, found = k.GetBlacklisted(ctx, recipientBz)
if found {
return errors.Wrapf(types.ErrUnauthorized, "%s can not receive tokens", recipient)
}
Expand Down

0 comments on commit 0bd3e0f

Please sign in to comment.