Skip to content

Commit

Permalink
chore: resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
onikonychev committed Jan 6, 2025
2 parents df0c3bf + 86d6b3f commit 32b62f1
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ documentation.
- [#2129](https://github.com/NibiruChain/nibiru/pull/2129) - fix(evm): issue with infinite recursion in erc20 funtoken contracts
- [#2134](https://github.com/NibiruChain/nibiru/pull/2134) - fix(evm): query of NIBI should use bank state, not the StateDB
- [#2141](https://github.com/NibiruChain/nibiru/pull/2141) - refactor: simplify account retrieval operation in `nibid q evm account`.
- [#2142](https://github.com/NibiruChain/nibiru/pull/2142) - fix(bank): add additional missing methods to the NibiruBankKeeper

#### Nibiru EVM | Before Audit 2 - 2024-12-06

Expand Down
69 changes: 65 additions & 4 deletions x/evm/keeper/bank_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
auth "github.com/cosmos/cosmos-sdk/x/auth/types"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

"github.com/NibiruChain/nibiru/v2/eth"
"github.com/NibiruChain/nibiru/v2/x/evm"
"github.com/NibiruChain/nibiru/v2/x/evm/statedb"
)

var (
_ bankkeeper.Keeper = &NibiruBankKeeper{}
_ bankkeeper.SendKeeper = &NibiruBankKeeper{}
)
var _ bankkeeper.Keeper = &NibiruBankKeeper{}

type NibiruBankKeeper struct {
bankkeeper.BaseKeeper
Expand All @@ -29,6 +27,69 @@ func (evmKeeper *Keeper) NewStateDB(
return stateDB
}

func (bk NibiruBankKeeper) InputOutputCoins(
ctx sdk.Context,
input []banktypes.Input,
output []banktypes.Output,
) error {
return bk.ForceGasInvariant(
ctx,
func(ctx sdk.Context) error {
return bk.BaseKeeper.InputOutputCoins(ctx, input, output)
},
func(ctx sdk.Context) {
for _, input := range input {
if findEtherBalanceChangeFromCoins(input.Coins) {
bk.SyncStateDBWithAccount(ctx, sdk.MustAccAddressFromBech32(input.Address))
}
}
for _, output := range output {
if findEtherBalanceChangeFromCoins(output.Coins) {
bk.SyncStateDBWithAccount(ctx, sdk.MustAccAddressFromBech32(output.Address))
}
}
},
)
}

func (bk NibiruBankKeeper) DelegateCoins(
ctx sdk.Context,
delegatorAddr sdk.AccAddress,
moduleBech32Addr sdk.AccAddress,
coins sdk.Coins,
) error {
return bk.ForceGasInvariant(
ctx,
func(ctx sdk.Context) error {
return bk.BaseKeeper.DelegateCoins(ctx, delegatorAddr, moduleBech32Addr, coins)
},
func(ctx sdk.Context) {
if findEtherBalanceChangeFromCoins(coins) {
bk.SyncStateDBWithAccount(ctx, delegatorAddr)
}
},
)
}

func (bk NibiruBankKeeper) UndelegateCoins(
ctx sdk.Context,
delegatorAddr sdk.AccAddress,
moduleBech32Addr sdk.AccAddress,
coins sdk.Coins,
) error {
return bk.ForceGasInvariant(
ctx,
func(ctx sdk.Context) error {
return bk.BaseKeeper.UndelegateCoins(ctx, delegatorAddr, moduleBech32Addr, coins)
},
func(ctx sdk.Context) {
if findEtherBalanceChangeFromCoins(coins) {
bk.SyncStateDBWithAccount(ctx, delegatorAddr)
}
},
)
}

func (bk NibiruBankKeeper) MintCoins(
ctx sdk.Context,
moduleName string,
Expand Down

0 comments on commit 32b62f1

Please sign in to comment.