Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: DNM v0.50 EVM Support #1

Draft
wants to merge 16 commits into
base: release/v0.50.x
Choose a base branch
from
Draft
Prev Previous commit
Next Next commit
public: SetSupply, SubUnlockedCoins
  • Loading branch information
Reecepbcups committed Jul 18, 2024
commit 6813ad1599bec81ee586aa97db23d2ccc9869c44
2 changes: 1 addition & 1 deletion x/bank/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (k BaseKeeper) InitGenesis(ctx context.Context, genState *types.GenesisStat
}

for _, supply := range totalSupply {
k.setSupply(ctx, supply)
k.SetSupply(ctx, supply)
}

for _, meta := range genState.DenomMetadata {
Expand Down
10 changes: 6 additions & 4 deletions x/bank/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type Keeper interface {
DelegateCoins(ctx context.Context, delegatorAddr, moduleAccAddr sdk.AccAddress, amt sdk.Coins) error
UndelegateCoins(ctx context.Context, moduleAccAddr, delegatorAddr sdk.AccAddress, amt sdk.Coins) error

SetSupply(ctx context.Context, coin sdk.Coin)

types.QueryServer
}

Expand Down Expand Up @@ -365,7 +367,7 @@ func (k BaseKeeper) MintCoins(ctx context.Context, moduleName string, amounts sd
for _, amount := range amounts {
supply := k.GetSupply(ctx, amount.GetDenom())
supply = supply.Add(amount)
k.setSupply(ctx, supply)
k.SetSupply(ctx, supply)
}

k.logger.Debug("minted coins from module account", "amount", amounts.String(), "from", moduleName)
Expand Down Expand Up @@ -398,7 +400,7 @@ func (k BaseKeeper) BurnCoins(ctx context.Context, moduleName string, amounts sd
for _, amount := range amounts {
supply := k.GetSupply(ctx, amount.GetDenom())
supply = supply.Sub(amount)
k.setSupply(ctx, supply)
k.SetSupply(ctx, supply)
}

k.logger.Debug("burned tokens from module account", "amount", amounts.String(), "from", moduleName)
Expand All @@ -412,8 +414,8 @@ func (k BaseKeeper) BurnCoins(ctx context.Context, moduleName string, amounts sd
return nil
}

// setSupply sets the supply for the given coin
func (k BaseKeeper) setSupply(ctx context.Context, coin sdk.Coin) {
// SetSupply sets the supply for the given coin
func (k BaseKeeper) SetSupply(ctx context.Context, coin sdk.Coin) {
// Bank invariants and IBC requires to remove zero coins.
if coin.IsZero() {
_ = k.Supply.Remove(ctx, coin.Denom)
Expand Down
1 change: 1 addition & 0 deletions x/bank/keeper/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type SendKeeper interface {
SubWei(ctx sdk.Context, addr sdk.AccAddress, amt math.Int) error
AddWei(ctx sdk.Context, addr sdk.AccAddress, amt math.Int) error
AddCoins(ctx context.Context, addr sdk.AccAddress, amt sdk.Coins) error
SubUnlockedCoins(ctx context.Context, addr sdk.AccAddress, amt sdk.Coins) error

GetAuthority() string
}
Expand Down
Loading