diff --git a/.changelog/v2.0.3/bug-fixes/28-sigverification-ante.md b/.changelog/v2.0.3/bug-fixes/28-sigverification-ante.md new file mode 100644 index 0000000..ca1d239 --- /dev/null +++ b/.changelog/v2.0.3/bug-fixes/28-sigverification-ante.md @@ -0,0 +1 @@ +- Return an error from the custom `SigVerificationDecorator` when forwarding account does not have balance to prevent a panic. ([#28](https://github.com/noble-assets/forwarding/pull/28)) diff --git a/.changelog/v2.0.3/summary.md b/.changelog/v2.0.3/summary.md new file mode 100644 index 0000000..2ce58d4 --- /dev/null +++ b/.changelog/v2.0.3/summary.md @@ -0,0 +1,3 @@ +May 9, 2025 + +This is a non-consensus breaking patch to the v9 Argentum release line. diff --git a/ante.go b/ante.go index 3ab3d47..8a1a75b 100644 --- a/ante.go +++ b/ante.go @@ -73,12 +73,16 @@ func (d SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulat } address := types.GenerateAddress(msg.Channel, msg.Recipient, msg.Fallback) - balance := d.bank.GetAllBalances(ctx, address) - if balance.IsZero() || msg.Signer != address.String() { + if msg.Signer != address.String() { return d.underlying.AnteHandle(ctx, tx, simulate, next) } + balance := d.bank.GetAllBalances(ctx, address) + if balance.IsZero() { + return ctx, types.ErrInvalidAccountBalance.Wrap("account must have balance") + } + return next(ctx, tx, simulate) } diff --git a/types/errors.go b/types/errors.go index 649bfe5..0b65f73 100644 --- a/types/errors.go +++ b/types/errors.go @@ -23,6 +23,7 @@ package types import "cosmossdk.io/errors" var ( - ErrInvalidAuthority = errors.Register(ModuleName, 1, "signer is not authority") - ErrInvalidDenoms = errors.Register(ModuleName, 2, "invalid allowed denoms") + ErrInvalidAuthority = errors.Register(ModuleName, 1, "signer is not authority") + ErrInvalidDenoms = errors.Register(ModuleName, 2, "invalid allowed denoms") + ErrInvalidAccountBalance = errors.Register(ModuleName, 3, "invalid account balance") )