From 521f558f5d4013d1e7fc3ff4960cc8022efdfaa0 Mon Sep 17 00:00:00 2001 From: Solovyov1796 Date: Sun, 5 May 2024 14:17:37 +0800 Subject: [PATCH] recv both cosmos denom and evm denom from bank keeper --- x/evmutil/keeper/bank_keeper.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/x/evmutil/keeper/bank_keeper.go b/x/evmutil/keeper/bank_keeper.go index 3ef3b0c6..b176c6d1 100644 --- a/x/evmutil/keeper/bank_keeper.go +++ b/x/evmutil/keeper/bank_keeper.go @@ -52,9 +52,17 @@ func (k EvmBankKeeper) GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom st } spendableCoins := k.bk.SpendableCoins(ctx, addr) - ua0gi := spendableCoins.AmountOf(CosmosDenom) - neuron := k.neuronKeeper.GetBalance(ctx, addr) - total := ua0gi.Mul(ConversionMultiplier).Add(neuron) + cosmosDenomFromBank := spendableCoins.AmountOf(CosmosDenom) + evmDenomFromBank := spendableCoins.AmountOf(EvmDenom) + evmDenomFromEvmBank := k.neuronKeeper.GetBalance(ctx, addr) + + var total sdkmath.Int + + if cosmosDenomFromBank.IsPositive() { + total = cosmosDenomFromBank.Mul(ConversionMultiplier).Add(evmDenomFromBank).Add(evmDenomFromEvmBank) + } else { + total = evmDenomFromBank.Add(evmDenomFromEvmBank) + } return sdk.NewCoin(EvmDenom, total) }