Skip to content

Commit 0bd3e0f

Browse files
authored
Improve error handling logic in abci address checking
1 parent eb8b9b3 commit 0bd3e0f

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

x/fiattokenfactory/keeper/abci.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,21 @@ func (k *Keeper) HandleDeliverTxEvent(ctx sdk.Context, event abci.Event) error {
3232
}
3333

3434
// Check if sender is blacklisted.
35-
_, found := k.GetBlacklisted(ctx, sdk.MustAccAddressFromBech32(sender))
35+
senderBz, err := sdk.AccAddressFromBech32(sender)
36+
if err != nil {
37+
return errors.Wrapf(types.ErrUnauthorized, "failed to parse sender %s", sender)
38+
}
39+
_, found := k.GetBlacklisted(ctx, senderBz)
3640
if found {
3741
return errors.Wrapf(types.ErrUnauthorized, "%s can not send tokens", sender)
3842
}
3943

4044
// Check if recipient is blacklisted.
41-
_, found = k.GetBlacklisted(ctx, sdk.MustAccAddressFromBech32(recipient))
45+
recipientBz, err := sdk.AccAddressFromBech32(recipient)
46+
if err != nil {
47+
return errors.Wrapf(types.ErrUnauthorized, "failed to parse recipient %s", recipient)
48+
}
49+
_, found = k.GetBlacklisted(ctx, recipientBz)
4250
if found {
4351
return errors.Wrapf(types.ErrUnauthorized, "%s can not receive tokens", recipient)
4452
}

0 commit comments

Comments
 (0)