Skip to content

Commit

Permalink
fix(#11): create account if not exist, to enable zero gas fee on chain
Browse files Browse the repository at this point in the history
  • Loading branch information
0xDevVoyager committed Nov 28, 2024
1 parent afd1a43 commit aa5d571
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion x/evm/keeper/meter.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

"github.com/artela-network/aspect-core/djpm"

"github.com/artela-network/artela-rollkit/x/evm/states"
"github.com/artela-network/artela-rollkit/x/evm/types"
)

Expand Down Expand Up @@ -88,7 +89,15 @@ func (k *Keeper) DeductTxCostsFromUserBalance(
// fetch sender account
signerAcc, err := authante.GetSignerAcc(ctx, k.accountKeeper, from.Bytes())
if err != nil {
return errorsmod.Wrapf(err, "account not found for sender %s", from)
// if no gas fee, create an empty account for the address
if !fees.Empty() {
return errorsmod.Wrapf(err, "account not found for sender %s", from)
}
err := k.SetAccount(ctx, from, *states.NewEmptyAccount())
if err != nil {
return errorsmod.Wrapf(err, "account not found for sender %s and failed to create %v", from, err)
}
signerAcc, _ = authante.GetSignerAcc(ctx, k.accountKeeper, from.Bytes())
}

// deduct the full gas cost from the user balance
Expand Down

0 comments on commit aa5d571

Please sign in to comment.