rename denoms

This commit is contained in:
Solovyov1796 2024-05-10 14:31:49 +08:00 committed by 0g-wh
parent 4fabd4d011
commit 986172d3a7
41 changed files with 517 additions and 517 deletions

View File

@ -78,7 +78,7 @@ print-machine-info:
BUILD_DIR := build# build files BUILD_DIR := build# build files
BIN_DIR := $(BUILD_DIR)/bin# for binary dev dependencies BIN_DIR := $(BUILD_DIR)/bin# for binary dev dependencies
BUILD_CACHE_DIR := $(BUILD_DIR)/.cache# caching for non-artifact outputs BUILD_CACHE_DIR := $(BUILD_DIR)/.cache# caching for non-artifact outputs
OUT_DIR := out# for artifact intermediates and outputs OUT_DIR := ./.build# for artifact intermediates and outputs
ROOT_DIR := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))# absolute path to root ROOT_DIR := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))# absolute path to root
export PATH := $(ROOT_DIR)/$(BIN_DIR):$(PATH)# add local bin first in path export PATH := $(ROOT_DIR)/$(BIN_DIR):$(PATH)# add local bin first in path

View File

@ -62,11 +62,11 @@ func (suite *SimulateRequestTestSuite) TestSimulateRequest() {
bank.MsgSend{ bank.MsgSend{
FromAddress: fromAddr, FromAddress: fromAddr,
ToAddress: toAddr, ToAddress: toAddr,
Amount: sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(1e6)), Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e6)),
}, },
}, },
Fee: auth.StdFee{ Fee: auth.StdFee{
Amount: sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(5e4)), Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(5e4)),
Gas: 1e6, Gas: 1e6,
}, },
Memo: "test memo", Memo: "test memo",

View File

@ -68,7 +68,7 @@ func TestAppAnteHandler_AuthorizedMempool(t *testing.T) {
chainID, chainID,
app.NewFundedGenStateWithSameCoins( app.NewFundedGenStateWithSameCoins(
tApp.AppCodec(), tApp.AppCodec(),
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(1e9)), sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e9)),
testAddresses, testAddresses,
), ),
newBep3GenStateMulti(tApp.AppCodec(), deputy), newBep3GenStateMulti(tApp.AppCodec(), deputy),
@ -116,7 +116,7 @@ func TestAppAnteHandler_AuthorizedMempool(t *testing.T) {
banktypes.NewMsgSend( banktypes.NewMsgSend(
tc.address, tc.address,
testAddresses[0], testAddresses[0],
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(1_000_000)), sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1_000_000)),
), ),
}, },
sdk.NewCoins(), // no fee sdk.NewCoins(), // no fee

View File

@ -46,7 +46,7 @@ func TestAuthenticatedMempoolDecorator_AnteHandle_NotCheckTx(t *testing.T) {
banktypes.NewMsgSend( banktypes.NewMsgSend(
testAddresses[0], testAddresses[0],
testAddresses[1], testAddresses[1],
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(100_000_000)), sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100_000_000)),
), ),
}, },
sdk.NewCoins(), // no fee sdk.NewCoins(), // no fee
@ -81,12 +81,12 @@ func TestAuthenticatedMempoolDecorator_AnteHandle_Pass(t *testing.T) {
banktypes.NewMsgSend( banktypes.NewMsgSend(
testAddresses[0], testAddresses[0],
testAddresses[1], testAddresses[1],
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(100)), sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
), ),
banktypes.NewMsgSend( banktypes.NewMsgSend(
testAddresses[2], testAddresses[2],
testAddresses[1], testAddresses[1],
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(100)), sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
), ),
}, },
sdk.NewCoins(), // no fee sdk.NewCoins(), // no fee
@ -122,7 +122,7 @@ func TestAuthenticatedMempoolDecorator_AnteHandle_Reject(t *testing.T) {
banktypes.NewMsgSend( banktypes.NewMsgSend(
testAddresses[0], testAddresses[0],
testAddresses[1], testAddresses[1],
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(100)), sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
), ),
}, },
sdk.NewCoins(), // no fee sdk.NewCoins(), // no fee

View File

@ -59,7 +59,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
banktypes.NewMsgSend( banktypes.NewMsgSend(
testAddresses[0], testAddresses[0],
testAddresses[1], testAddresses[1],
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(100e6)), sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100e6)),
), ),
}, },
checkTx: false, checkTx: false,
@ -129,7 +129,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
[]sdk.Msg{banktypes.NewMsgSend( []sdk.Msg{banktypes.NewMsgSend(
testAddresses[0], testAddresses[0],
testAddresses[3], testAddresses[3],
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(100e6)), sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100e6)),
)}), )}),
}, },
checkTx: false, checkTx: false,
@ -162,7 +162,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
banktypes.NewMsgSend( banktypes.NewMsgSend(
testAddresses[0], testAddresses[0],
testAddresses[3], testAddresses[3],
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(100e6)), sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100e6)),
), ),
&evmtypes.MsgEthereumTx{}, &evmtypes.MsgEthereumTx{},
}, },

View File

@ -157,7 +157,7 @@ func (suite *EIP712TestSuite) SetupTest() {
// Genesis states // Genesis states
evmGs := evmtypes.NewGenesisState( evmGs := evmtypes.NewGenesisState(
evmtypes.NewParams( evmtypes.NewParams(
chaincfg.BaseDenom, // evmDenom chaincfg.EvmDenom, // evmDenom
false, // allowedUnprotectedTxs false, // allowedUnprotectedTxs
true, // enableCreate true, // enableCreate
true, // enableCall true, // enableCall
@ -223,10 +223,10 @@ func (suite *EIP712TestSuite) SetupTest() {
pricefeedtypes.ModuleName: cdc.MustMarshalJSON(&pricefeedGenState), pricefeedtypes.ModuleName: cdc.MustMarshalJSON(&pricefeedGenState),
} }
// funds our test accounts with some auxiliary denom // funds our test accounts with some gas denom
coinsGenState := app.NewFundedGenStateWithSameCoins( coinsGenState := app.NewFundedGenStateWithSameCoins(
tApp.AppCodec(), tApp.AppCodec(),
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(1e9)), sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e9)),
[]sdk.AccAddress{suite.testAddr, suite.testAddr2}, []sdk.AccAddress{suite.testAddr, suite.testAddr2},
) )
@ -376,7 +376,7 @@ func (suite *EIP712TestSuite) deployUSDCERC20(app app.TestApp, ctx sdk.Context)
suite.tApp.FundModuleAccount( suite.tApp.FundModuleAccount(
suite.ctx, suite.ctx,
evmutiltypes.ModuleName, evmutiltypes.ModuleName,
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(0)), sdk.NewCoins(chaincfg.MakeCoinForGasDenom(0)),
) )
contractAddr, err := suite.evmutilKeeper.DeployTestMintableERC20Contract(suite.ctx, "USDC", "USDC", uint8(18)) contractAddr, err := suite.evmutilKeeper.DeployTestMintableERC20Contract(suite.ctx, "USDC", "USDC", uint8(18))
@ -476,7 +476,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
errMsg: "insufficient funds", errMsg: "insufficient funds",
updateTx: func(txBuilder client.TxBuilder, msgs []sdk.Msg) client.TxBuilder { updateTx: func(txBuilder client.TxBuilder, msgs []sdk.Msg) client.TxBuilder {
bk := suite.tApp.GetBankKeeper() bk := suite.tApp.GetBankKeeper()
gasCoins := bk.GetBalance(suite.ctx, suite.testAddr, chaincfg.AuxiliaryDenom) gasCoins := bk.GetBalance(suite.ctx, suite.testAddr, chaincfg.GasDenom)
suite.tApp.GetBankKeeper().SendCoins(suite.ctx, suite.testAddr, suite.testAddr2, sdk.NewCoins(gasCoins)) suite.tApp.GetBankKeeper().SendCoins(suite.ctx, suite.testAddr, suite.testAddr2, sdk.NewCoins(gasCoins))
return txBuilder return txBuilder
}, },
@ -488,7 +488,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
failCheckTx: true, failCheckTx: true,
errMsg: "invalid chain-id", errMsg: "invalid chain-id",
updateTx: func(txBuilder client.TxBuilder, msgs []sdk.Msg) client.TxBuilder { updateTx: func(txBuilder client.TxBuilder, msgs []sdk.Msg) client.TxBuilder {
gasAmt := sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(20)) gasAmt := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(20))
return suite.createTestEIP712CosmosTxBuilder( return suite.createTestEIP712CosmosTxBuilder(
suite.testAddr, suite.testPrivKey, "kavatest_12-1", uint64(sims.DefaultGenTxGas*10), gasAmt, msgs, suite.testAddr, suite.testPrivKey, "kavatest_12-1", uint64(sims.DefaultGenTxGas*10), gasAmt, msgs,
) )
@ -501,7 +501,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
failCheckTx: true, failCheckTx: true,
errMsg: "invalid pubkey", errMsg: "invalid pubkey",
updateTx: func(txBuilder client.TxBuilder, msgs []sdk.Msg) client.TxBuilder { updateTx: func(txBuilder client.TxBuilder, msgs []sdk.Msg) client.TxBuilder {
gasAmt := sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(20)) gasAmt := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(20))
return suite.createTestEIP712CosmosTxBuilder( return suite.createTestEIP712CosmosTxBuilder(
suite.testAddr2, suite.testPrivKey2, ChainID, uint64(sims.DefaultGenTxGas*10), gasAmt, msgs, suite.testAddr2, suite.testPrivKey2, ChainID, uint64(sims.DefaultGenTxGas*10), gasAmt, msgs,
) )
@ -529,7 +529,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
msgs = tc.updateMsgs(msgs) msgs = tc.updateMsgs(msgs)
} }
gasAmt := sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(20)) gasAmt := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(20))
txBuilder := suite.createTestEIP712CosmosTxBuilder( txBuilder := suite.createTestEIP712CosmosTxBuilder(
suite.testAddr, suite.testPrivKey, ChainID, uint64(sims.DefaultGenTxGas*10), gasAmt, msgs, suite.testAddr, suite.testPrivKey, ChainID, uint64(sims.DefaultGenTxGas*10), gasAmt, msgs,
) )
@ -603,7 +603,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx_DepositAndWithdraw() {
} }
// deliver deposit msg // deliver deposit msg
gasAmt := sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(20)) gasAmt := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(20))
txBuilder := suite.createTestEIP712CosmosTxBuilder( txBuilder := suite.createTestEIP712CosmosTxBuilder(
suite.testAddr, suite.testPrivKey, ChainID, uint64(sims.DefaultGenTxGas*10), gasAmt, depositMsgs, suite.testAddr, suite.testPrivKey, ChainID, uint64(sims.DefaultGenTxGas*10), gasAmt, depositMsgs,
) )

View File

@ -31,7 +31,7 @@ func TestEvmMinGasFilter(t *testing.T) {
ctx := tApp.NewContext(true, tmproto.Header{Height: 1, Time: tmtime.Now()}) ctx := tApp.NewContext(true, tmproto.Header{Height: 1, Time: tmtime.Now()})
tApp.GetEvmKeeper().SetParams(ctx, evmtypes.Params{ tApp.GetEvmKeeper().SetParams(ctx, evmtypes.Params{
EvmDenom: chaincfg.BaseDenom, EvmDenom: chaincfg.EvmDenom,
}) })
testCases := []struct { testCases := []struct {

View File

@ -34,7 +34,7 @@ func TestVestingMempoolDecorator_MsgCreateVestingAccount_Unauthorized(t *testing
"MsgCreateVestingAccount", "MsgCreateVestingAccount",
vesting.NewMsgCreateVestingAccount( vesting.NewMsgCreateVestingAccount(
testAddresses[0], testAddresses[1], testAddresses[0], testAddresses[1],
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(100)), sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC).Unix(), time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC).Unix(),
false, false,
), ),
@ -45,7 +45,7 @@ func TestVestingMempoolDecorator_MsgCreateVestingAccount_Unauthorized(t *testing
"MsgCreateVestingAccount", "MsgCreateVestingAccount",
vesting.NewMsgCreatePermanentLockedAccount( vesting.NewMsgCreatePermanentLockedAccount(
testAddresses[0], testAddresses[1], testAddresses[0], testAddresses[1],
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(100)), sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
), ),
true, true,
"MsgTypeURL /cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccount not supported", "MsgTypeURL /cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccount not supported",
@ -64,7 +64,7 @@ func TestVestingMempoolDecorator_MsgCreateVestingAccount_Unauthorized(t *testing
"other messages not affected", "other messages not affected",
banktypes.NewMsgSend( banktypes.NewMsgSend(
testAddresses[0], testAddresses[1], testAddresses[0], testAddresses[1],
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(100)), sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
), ),
false, false,
"", "",

View File

@ -153,7 +153,7 @@ func GenesisStateWithSingleValidator(
balances := []banktypes.Balance{ balances := []banktypes.Balance{
{ {
Address: acc.GetAddress().String(), Address: acc.GetAddress().String(),
Coins: sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(100000000000000)), Coins: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100000000000000)),
}, },
} }
@ -216,7 +216,7 @@ func genesisStateWithValSet(
} }
// set validators and delegations // set validators and delegations
currentStakingGenesis := stakingtypes.GetGenesisStateFromAppState(app.appCodec, genesisState) currentStakingGenesis := stakingtypes.GetGenesisStateFromAppState(app.appCodec, genesisState)
currentStakingGenesis.Params.BondDenom = chaincfg.AuxiliaryDenom // TODO: currentStakingGenesis.Params.BondDenom = chaincfg.GasDenom // TODO:
stakingGenesis := stakingtypes.NewGenesisState( stakingGenesis := stakingtypes.NewGenesisState(
currentStakingGenesis.Params, currentStakingGenesis.Params,
@ -236,13 +236,13 @@ func genesisStateWithValSet(
for range delegations { for range delegations {
// add delegated tokens to total supply // add delegated tokens to total supply
totalSupply = totalSupply.Add(chaincfg.MakeCoinForAuxiliaryDenom(bondAmt)) totalSupply = totalSupply.Add(chaincfg.MakeCoinForGasDenom(bondAmt))
} }
// add bonded amount to bonded pool module account // add bonded amount to bonded pool module account
balances = append(balances, banktypes.Balance{ balances = append(balances, banktypes.Balance{
Address: authtypes.NewModuleAddress(stakingtypes.BondedPoolName).String(), Address: authtypes.NewModuleAddress(stakingtypes.BondedPoolName).String(),
Coins: sdk.Coins{chaincfg.MakeCoinForAuxiliaryDenom(bondAmt)}, Coins: sdk.Coins{chaincfg.MakeCoinForGasDenom(bondAmt)},
}) })
bankGenesis := banktypes.NewGenesisState( bankGenesis := banktypes.NewGenesisState(

View File

@ -44,12 +44,12 @@ func MakeCoinForStandardDenom(amount any) sdk.Coin {
return makeCoin(StandardDenom, toBigInt(amount)) return makeCoin(StandardDenom, toBigInt(amount))
} }
func MakeCoinForAuxiliaryDenom(amount any) sdk.Coin { func MakeCoinForGasDenom(amount any) sdk.Coin {
return makeCoin(AuxiliaryDenom, toBigInt(amount)) return makeCoin(GasDenom, toBigInt(amount))
} }
func MakeCoinForBaseDenom(amount any) sdk.Coin { func MakeCoinForEvmDenom(amount any) sdk.Coin {
return makeCoin(BaseDenom, toBigInt(amount)) return makeCoin(EvmDenom, toBigInt(amount))
} }
func makeCoin(denom string, amount *big.Int) sdk.Coin { func makeCoin(denom string, amount *big.Int) sdk.Coin {

View File

@ -7,31 +7,31 @@ import (
const ( const (
StandardDenom = "a0gi" StandardDenom = "a0gi"
AuxiliaryDenom = "ua0gi" GasDenom = "ua0gi"
BaseDenom = "neuron" EvmDenom = "neuron"
BondDenom = BaseDenom BondDenom = EvmDenom
AuxiliaryDenomUnit = 6 GasDenomUnit = 6
BaseDenomUnit = 18 EvmDenomUnit = 18
AuxiliaryDenomConversionMultiplier = 1e12 GasDenomConversionMultiplier = 1e12
BaseDenomConversionMultiplier = 1e18 EvmDenomConversionMultiplier = 1e18
) )
// RegisterDenoms registers the base and auxiliary denominations to the SDK. // RegisterDenoms registers the base and gas denominations to the SDK.
func RegisterDenoms() { func RegisterDenoms() {
if err := sdk.RegisterDenom(StandardDenom, sdk.OneDec()); err != nil { if err := sdk.RegisterDenom(StandardDenom, sdk.OneDec()); err != nil {
panic(err) panic(err)
} }
if err := sdk.RegisterDenom(AuxiliaryDenom, sdk.NewDecWithPrec(1, AuxiliaryDenomUnit)); err != nil { if err := sdk.RegisterDenom(GasDenom, sdk.NewDecWithPrec(1, GasDenomUnit)); err != nil {
panic(err) panic(err)
} }
if err := sdk.RegisterDenom(BaseDenom, sdk.NewDecWithPrec(1, BaseDenomUnit)); err != nil { if err := sdk.RegisterDenom(EvmDenom, sdk.NewDecWithPrec(1, EvmDenomUnit)); err != nil {
panic(err) panic(err)
} }
} }

View File

@ -17,15 +17,15 @@ func TestRegisterDenoms(t *testing.T) {
expErr error expErr error
}{ }{
{ {
"standard to auxiliary", "standard to gas",
MakeCoinForStandardDenom(99), MakeCoinForStandardDenom(99),
AuxiliaryDenom, GasDenom,
MakeCoinForAuxiliaryDenom(99 * (BaseDenomConversionMultiplier / AuxiliaryDenomConversionMultiplier)), MakeCoinForGasDenom(99 * (EvmDenomConversionMultiplier / GasDenomConversionMultiplier)),
nil, nil,
}, },
{ {
"auxiliary to standard", "gas to standard",
MakeCoinForAuxiliaryDenom(5e7), MakeCoinForGasDenom(5e7),
StandardDenom, StandardDenom,
MakeCoinForStandardDenom(50), MakeCoinForStandardDenom(50),
nil, nil,
@ -33,29 +33,29 @@ func TestRegisterDenoms(t *testing.T) {
{ {
"standard to base", "standard to base",
MakeCoinForStandardDenom(22), MakeCoinForStandardDenom(22),
BaseDenom, EvmDenom,
MakeCoinForBaseDenom(22 * BaseDenomConversionMultiplier), MakeCoinForEvmDenom(22 * EvmDenomConversionMultiplier),
nil, nil,
}, },
{ {
"base to standard", "base to standard",
MakeCoinForBaseDenom("97000000000000000000"), MakeCoinForEvmDenom("97000000000000000000"),
StandardDenom, StandardDenom,
MakeCoinForStandardDenom(97), MakeCoinForStandardDenom(97),
nil, nil,
}, },
{ {
"auxiliary to base", "gas to base",
MakeCoinForAuxiliaryDenom(33), MakeCoinForGasDenom(33),
BaseDenom, EvmDenom,
MakeCoinForBaseDenom(33 * AuxiliaryDenomConversionMultiplier), MakeCoinForEvmDenom(33 * GasDenomConversionMultiplier),
nil, nil,
}, },
{ {
"base to auxiliary", "base to gas",
MakeCoinForBaseDenom("770000000000000"), MakeCoinForEvmDenom("770000000000000"),
AuxiliaryDenom, GasDenom,
MakeCoinForAuxiliaryDenom(770000000000000 / AuxiliaryDenomConversionMultiplier), MakeCoinForGasDenom(770000000000000 / GasDenomConversionMultiplier),
nil, nil,
}, },
} }

View File

@ -3580,7 +3580,7 @@ paths:
base: base:
type: string type: string
description: >- description: >-
base represents the base denom (should be the DenomUnit base represents the evm denom (should be the DenomUnit
with exponent = 0). with exponent = 0).
display: display:
type: string type: string
@ -3787,7 +3787,7 @@ paths:
base: base:
type: string type: string
description: >- description: >-
base represents the base denom (should be the DenomUnit base represents the evm denom (should be the DenomUnit
with exponent = 0). with exponent = 0).
display: display:
type: string type: string
@ -38218,7 +38218,7 @@ definitions:
base: base:
type: string type: string
description: >- description: >-
base represents the base denom (should be the DenomUnit with exponent base represents the evm denom (should be the DenomUnit with exponent
= 0). = 0).
display: display:
type: string type: string
@ -38397,7 +38397,7 @@ definitions:
base: base:
type: string type: string
description: >- description: >-
base represents the base denom (should be the DenomUnit with base represents the evm denom (should be the DenomUnit with
exponent = 0). exponent = 0).
display: display:
type: string type: string
@ -38553,7 +38553,7 @@ definitions:
base: base:
type: string type: string
description: >- description: >-
base represents the base denom (should be the DenomUnit with base represents the evm denom (should be the DenomUnit with
exponent = 0). exponent = 0).
display: display:
type: string type: string

View File

@ -129,9 +129,9 @@ paths:
source of the fungible token. source of the fungible token.
base_denom: base_denom:
type: string type: string
description: base denomination of the relayed fungible token. description: evm denomination of the relayed fungible token.
description: >- description: >-
DenomTrace contains the base denomination for ICS20 fungible DenomTrace contains the evm denomination for ICS20 fungible
tokens and the tokens and the
source tracing information path. source tracing information path.
@ -263,9 +263,9 @@ paths:
source of the fungible token. source of the fungible token.
base_denom: base_denom:
type: string type: string
description: base denomination of the relayed fungible token. description: evm denomination of the relayed fungible token.
description: >- description: >-
DenomTrace contains the base denomination for ICS20 fungible DenomTrace contains the evm denomination for ICS20 fungible
tokens and the tokens and the
source tracing information path. source tracing information path.
@ -13640,9 +13640,9 @@ definitions:
source of the fungible token. source of the fungible token.
base_denom: base_denom:
type: string type: string
description: base denomination of the relayed fungible token. description: evm denomination of the relayed fungible token.
description: >- description: >-
DenomTrace contains the base denomination for ICS20 fungible tokens and DenomTrace contains the evm denomination for ICS20 fungible tokens and
the the
source tracing information path. source tracing information path.
@ -13696,9 +13696,9 @@ definitions:
source of the fungible token. source of the fungible token.
base_denom: base_denom:
type: string type: string
description: base denomination of the relayed fungible token. description: evm denomination of the relayed fungible token.
description: >- description: >-
DenomTrace contains the base denomination for ICS20 fungible tokens DenomTrace contains the evm denomination for ICS20 fungible tokens
and the and the
source tracing information path. source tracing information path.
@ -13722,9 +13722,9 @@ definitions:
source of the fungible token. source of the fungible token.
base_denom: base_denom:
type: string type: string
description: base denomination of the relayed fungible token. description: evm denomination of the relayed fungible token.
description: >- description: >-
DenomTrace contains the base denomination for ICS20 fungible tokens DenomTrace contains the evm denomination for ICS20 fungible tokens
and the and the
source tracing information path. source tracing information path.

View File

@ -16793,7 +16793,7 @@ paths:
base: base:
type: string type: string
description: >- description: >-
base represents the base denom (should be the DenomUnit base represents the evm denom (should be the DenomUnit
with exponent = 0). with exponent = 0).
display: display:
type: string type: string
@ -17000,7 +17000,7 @@ paths:
base: base:
type: string type: string
description: >- description: >-
base represents the base denom (should be the DenomUnit base represents the evm denom (should be the DenomUnit
with exponent = 0). with exponent = 0).
display: display:
type: string type: string
@ -41400,9 +41400,9 @@ paths:
source of the fungible token. source of the fungible token.
base_denom: base_denom:
type: string type: string
description: base denomination of the relayed fungible token. description: evm denomination of the relayed fungible token.
description: >- description: >-
DenomTrace contains the base denomination for ICS20 fungible DenomTrace contains the evm denomination for ICS20 fungible
tokens and the tokens and the
source tracing information path. source tracing information path.
@ -41534,9 +41534,9 @@ paths:
source of the fungible token. source of the fungible token.
base_denom: base_denom:
type: string type: string
description: base denomination of the relayed fungible token. description: evm denomination of the relayed fungible token.
description: >- description: >-
DenomTrace contains the base denomination for ICS20 fungible DenomTrace contains the evm denomination for ICS20 fungible
tokens and the tokens and the
source tracing information path. source tracing information path.
@ -60533,7 +60533,7 @@ definitions:
base: base:
type: string type: string
description: >- description: >-
base represents the base denom (should be the DenomUnit with exponent base represents the evm denom (should be the DenomUnit with exponent
= 0). = 0).
display: display:
type: string type: string
@ -60712,7 +60712,7 @@ definitions:
base: base:
type: string type: string
description: >- description: >-
base represents the base denom (should be the DenomUnit with base represents the evm denom (should be the DenomUnit with
exponent = 0). exponent = 0).
display: display:
type: string type: string
@ -60868,7 +60868,7 @@ definitions:
base: base:
type: string type: string
description: >- description: >-
base represents the base denom (should be the DenomUnit with base represents the evm denom (should be the DenomUnit with
exponent = 0). exponent = 0).
display: display:
type: string type: string
@ -84451,9 +84451,9 @@ definitions:
source of the fungible token. source of the fungible token.
base_denom: base_denom:
type: string type: string
description: base denomination of the relayed fungible token. description: evm denomination of the relayed fungible token.
description: >- description: >-
DenomTrace contains the base denomination for ICS20 fungible tokens and DenomTrace contains the evm denomination for ICS20 fungible tokens and
the the
source tracing information path. source tracing information path.
@ -84507,9 +84507,9 @@ definitions:
source of the fungible token. source of the fungible token.
base_denom: base_denom:
type: string type: string
description: base denomination of the relayed fungible token. description: evm denomination of the relayed fungible token.
description: >- description: >-
DenomTrace contains the base denomination for ICS20 fungible tokens DenomTrace contains the evm denomination for ICS20 fungible tokens
and the and the
source tracing information path. source tracing information path.
@ -84533,9 +84533,9 @@ definitions:
source of the fungible token. source of the fungible token.
base_denom: base_denom:
type: string type: string
description: base denomination of the relayed fungible token. description: evm denomination of the relayed fungible token.
description: >- description: >-
DenomTrace contains the base denomination for ICS20 fungible tokens DenomTrace contains the evm denomination for ICS20 fungible tokens
and the and the
source tracing information path. source tracing information path.

View File

@ -81,7 +81,7 @@ func NewRootCmd() *cobra.Command {
return err return err
} }
customAppTemplate, customAppConfig := servercfg.AppConfig(chaincfg.AuxiliaryDenom) customAppTemplate, customAppConfig := servercfg.AppConfig(chaincfg.GasDenom)
return server.InterceptConfigsPreRunHandler( return server.InterceptConfigsPreRunHandler(
cmd, cmd,
@ -137,7 +137,7 @@ func addSubCmds(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, de
ac.addStartCmdFlags, ac.addStartCmdFlags,
) )
// add keybase, auxiliary RPC, query, and tx child commands // add keybase, gas RPC, query, and tx child commands
rootCmd.AddCommand( rootCmd.AddCommand(
newQueryCmd(), newQueryCmd(),
newTxCmd(), newTxCmd(),

View File

@ -24,7 +24,7 @@ DATA=~/.0gchain
# remove any old state and config # remove any old state and config
rm -rf $DATA rm -rf $DATA
BINARY=0gchaind BINARY=./.build/0gchaind
# Create new data directory, overwriting any that alread existed # Create new data directory, overwriting any that alread existed
chainID="zgchain_8888-1" chainID="zgchain_8888-1"

View File

@ -42,7 +42,7 @@ func TestResetPeriodVestingAccount_NoVestingPeriods(t *testing.T) {
} }
func TestResetPeriodVestingAccount_SingleVestingPeriod_Vested(t *testing.T) { func TestResetPeriodVestingAccount_SingleVestingPeriod_Vested(t *testing.T) {
balance := sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(1e6))) balance := sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(1e6)))
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
periods := vestingtypes.Periods{ periods := vestingtypes.Periods{
@ -65,7 +65,7 @@ func TestResetPeriodVestingAccount_SingleVestingPeriod_Vested(t *testing.T) {
} }
func TestResetPeriodVestingAccount_SingleVestingPeriod_Vesting(t *testing.T) { func TestResetPeriodVestingAccount_SingleVestingPeriod_Vesting(t *testing.T) {
balance := sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(1e6))) balance := sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(1e6)))
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
periods := vestingtypes.Periods{ periods := vestingtypes.Periods{
@ -98,7 +98,7 @@ func TestResetPeriodVestingAccount_SingleVestingPeriod_Vesting(t *testing.T) {
} }
func TestResetPeriodVestingAccount_SingleVestingPeriod_ExactStartTime(t *testing.T) { func TestResetPeriodVestingAccount_SingleVestingPeriod_ExactStartTime(t *testing.T) {
balance := sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(1e6))) balance := sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(1e6)))
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
periods := vestingtypes.Periods{ periods := vestingtypes.Periods{
@ -126,25 +126,25 @@ func TestResetPeriodVestingAccount_SingleVestingPeriod_ExactStartTime(t *testing
} }
func TestResetPeriodVestingAccount_MultiplePeriods(t *testing.T) { func TestResetPeriodVestingAccount_MultiplePeriods(t *testing.T) {
balance := sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(4e6))) balance := sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(4e6)))
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
periods := vestingtypes.Periods{ periods := vestingtypes.Periods{
vestingtypes.Period{ vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // -15 days - vested Length: 15 * 24 * 60 * 60, // -15 days - vested
Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(1e6))), Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(1e6))),
}, },
vestingtypes.Period{ vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // 0 days - exact on the start time Length: 15 * 24 * 60 * 60, // 0 days - exact on the start time
Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(1e6))), Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(1e6))),
}, },
vestingtypes.Period{ vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // +15 days - vesting Length: 15 * 24 * 60 * 60, // +15 days - vesting
Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(1e6))), Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(1e6))),
}, },
vestingtypes.Period{ vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // +30 days - vesting Length: 15 * 24 * 60 * 60, // +30 days - vesting
Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(1e6))), Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(1e6))),
}, },
} }
@ -160,36 +160,36 @@ func TestResetPeriodVestingAccount_MultiplePeriods(t *testing.T) {
expectedPeriods := []vestingtypes.Period{ expectedPeriods := []vestingtypes.Period{
{ {
Length: 15 * 24 * 60 * 60, // 15 days Length: 15 * 24 * 60 * 60, // 15 days
Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(1e6))), Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(1e6))),
}, },
{ {
Length: 15 * 24 * 60 * 60, // 15 days Length: 15 * 24 * 60 * 60, // 15 days
Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(1e6))), Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(1e6))),
}, },
} }
assert.Equal(t, sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(2e6))), vacc.OriginalVesting, "expected original vesting to be updated") assert.Equal(t, sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(2e6))), vacc.OriginalVesting, "expected original vesting to be updated")
assert.Equal(t, newVestingStartTime.Unix(), vacc.StartTime, "expected vesting start time to be updated") assert.Equal(t, newVestingStartTime.Unix(), vacc.StartTime, "expected vesting start time to be updated")
assert.Equal(t, expectedEndtime, vacc.EndTime, "expected vesting end time end at last period") assert.Equal(t, expectedEndtime, vacc.EndTime, "expected vesting end time end at last period")
assert.Equal(t, expectedPeriods, vacc.VestingPeriods, "expected vesting periods to be updated") assert.Equal(t, expectedPeriods, vacc.VestingPeriods, "expected vesting periods to be updated")
} }
func TestResetPeriodVestingAccount_DelegatedVesting_GreaterThanVesting(t *testing.T) { func TestResetPeriodVestingAccount_DelegatedVesting_GreaterThanVesting(t *testing.T) {
balance := sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(3e6))) balance := sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(3e6)))
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
periods := vestingtypes.Periods{ periods := vestingtypes.Periods{
vestingtypes.Period{ vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // -15 days - vested Length: 15 * 24 * 60 * 60, // -15 days - vested
Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(1e6))), Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(1e6))),
}, },
vestingtypes.Period{ vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // 0 days - exact on the start time Length: 15 * 24 * 60 * 60, // 0 days - exact on the start time
Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(1e6))), Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(1e6))),
}, },
vestingtypes.Period{ vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // +15 days - vesting Length: 15 * 24 * 60 * 60, // +15 days - vesting
Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(1e6))), Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(1e6))),
}, },
} }
@ -199,35 +199,35 @@ func TestResetPeriodVestingAccount_DelegatedVesting_GreaterThanVesting(t *testin
newVestingStartTime := vestingStartTime.Add(30 * 24 * time.Hour) newVestingStartTime := vestingStartTime.Add(30 * 24 * time.Hour)
ResetPeriodicVestingAccount(vacc, newVestingStartTime) ResetPeriodicVestingAccount(vacc, newVestingStartTime)
assert.Equal(t, sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(2e6))), vacc.DelegatedFree, "expected delegated free to be updated") assert.Equal(t, sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(2e6))), vacc.DelegatedFree, "expected delegated free to be updated")
assert.Equal(t, sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(1e6))), vacc.DelegatedVesting, "expected delegated vesting to be updated") assert.Equal(t, sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(1e6))), vacc.DelegatedVesting, "expected delegated vesting to be updated")
} }
func TestResetPeriodVestingAccount_DelegatedVesting_LessThanVested(t *testing.T) { func TestResetPeriodVestingAccount_DelegatedVesting_LessThanVested(t *testing.T) {
balance := sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(3e6))) balance := sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(3e6)))
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
periods := vestingtypes.Periods{ periods := vestingtypes.Periods{
vestingtypes.Period{ vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // -15 days - vested Length: 15 * 24 * 60 * 60, // -15 days - vested
Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(1e6))), Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(1e6))),
}, },
vestingtypes.Period{ vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // 0 days - exact on the start time Length: 15 * 24 * 60 * 60, // 0 days - exact on the start time
Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(1e6))), Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(1e6))),
}, },
vestingtypes.Period{ vestingtypes.Period{
Length: 15 * 24 * 60 * 60, // +15 days - vesting Length: 15 * 24 * 60 * 60, // +15 days - vesting
Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(1e6))), Amount: sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(1e6))),
}, },
} }
vacc := createVestingAccount(balance, vestingStartTime, periods) vacc := createVestingAccount(balance, vestingStartTime, periods)
vacc.TrackDelegation(vestingStartTime, balance, sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(1e6)))) vacc.TrackDelegation(vestingStartTime, balance, sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(1e6))))
newVestingStartTime := vestingStartTime.Add(30 * 24 * time.Hour) newVestingStartTime := vestingStartTime.Add(30 * 24 * time.Hour)
ResetPeriodicVestingAccount(vacc, newVestingStartTime) ResetPeriodicVestingAccount(vacc, newVestingStartTime)
assert.Equal(t, sdk.Coins(nil), vacc.DelegatedFree, "expected delegrated free to be unmodified") assert.Equal(t, sdk.Coins(nil), vacc.DelegatedFree, "expected delegrated free to be unmodified")
assert.Equal(t, sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(1e6))), vacc.DelegatedVesting, "expected delegated vesting to be unmodified") assert.Equal(t, sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(1e6))), vacc.DelegatedVesting, "expected delegated vesting to be unmodified")
} }

View File

@ -64,7 +64,7 @@ func (suite *IntegrationTestSuite) setupAccountWithCosmosCoinERC20Balance(
tx := util.ZgChainMsgRequest{ tx := util.ZgChainMsgRequest{
Msgs: []sdk.Msg{&msg}, Msgs: []sdk.Msg{&msg},
GasLimit: 4e5, GasLimit: 4e5,
FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(400)), FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(400)),
Data: "converting sdk coin to erc20", Data: "converting sdk coin to erc20",
} }
res := user.SignAndBroadcastZgChainTx(tx) res := user.SignAndBroadcastZgChainTx(tx)
@ -103,7 +103,7 @@ func (suite *IntegrationTestSuite) TestConvertCosmosCoinsToFromERC20() {
tx := util.ZgChainMsgRequest{ tx := util.ZgChainMsgRequest{
Msgs: []sdk.Msg{&convertToErc20Msg}, Msgs: []sdk.Msg{&convertToErc20Msg},
GasLimit: 2e6, GasLimit: 2e6,
FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(2000)), FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(2000)),
Data: "converting sdk coin to erc20", Data: "converting sdk coin to erc20",
} }
res := user.SignAndBroadcastZgChainTx(tx) res := user.SignAndBroadcastZgChainTx(tx)
@ -145,7 +145,7 @@ func (suite *IntegrationTestSuite) TestConvertCosmosCoinsToFromERC20() {
tx = util.ZgChainMsgRequest{ tx = util.ZgChainMsgRequest{
Msgs: []sdk.Msg{&convertFromErc20Msg}, Msgs: []sdk.Msg{&convertFromErc20Msg},
GasLimit: 2e5, GasLimit: 2e5,
FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(200)), FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(200)),
Data: "converting erc20 to cosmos coin", Data: "converting erc20 to cosmos coin",
} }
res = user.SignAndBroadcastZgChainTx(tx) res = user.SignAndBroadcastZgChainTx(tx)
@ -184,7 +184,7 @@ func (suite *IntegrationTestSuite) TestEIP712ConvertCosmosCoinsToFromERC20() {
user, user,
suite.ZgChain, suite.ZgChain,
2e6, 2e6,
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(1e4)), sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e4)),
[]sdk.Msg{&convertToErc20Msg}, []sdk.Msg{&convertToErc20Msg},
"this is a memo", "this is a memo",
).GetTx() ).GetTx()
@ -238,7 +238,7 @@ func (suite *IntegrationTestSuite) TestEIP712ConvertCosmosCoinsToFromERC20() {
user, user,
suite.ZgChain, suite.ZgChain,
2e5, 2e5,
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(200)), sdk.NewCoins(chaincfg.MakeCoinForGasDenom(200)),
[]sdk.Msg{&convertFromErc20Msg}, []sdk.Msg{&convertFromErc20Msg},
"", "",
).GetTx() ).GetTx()
@ -332,7 +332,7 @@ func (suite *IntegrationTestSuite) TestConvertCosmosCoins_ERC20Magic() {
"cosmo-coin-converter-complex-alice", initialAliceAmount, "cosmo-coin-converter-complex-alice", initialAliceAmount,
) )
gasMoney := sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(1e5)) gasMoney := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e5))
bob := suite.ZgChain.NewFundedAccount("cosmo-coin-converter-complex-bob", gasMoney) bob := suite.ZgChain.NewFundedAccount("cosmo-coin-converter-complex-bob", gasMoney)
amount := big.NewInt(1e3) // test assumes this is half of alice's balance. amount := big.NewInt(1e3) // test assumes this is half of alice's balance.
@ -413,7 +413,7 @@ func (suite *IntegrationTestSuite) TestConvertCosmosCoins_ERC20Magic() {
convertTx := util.ZgChainMsgRequest{ convertTx := util.ZgChainMsgRequest{
Msgs: []sdk.Msg{&convertMsg}, Msgs: []sdk.Msg{&convertMsg},
GasLimit: 2e5, GasLimit: 2e5,
FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(200)), FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(200)),
Data: "bob converts his new erc20 to an sdk.Coin", Data: "bob converts his new erc20 to an sdk.Coin",
} }
convertRes := bob.SignAndBroadcastZgChainTx(convertTx) convertRes := bob.SignAndBroadcastZgChainTx(convertTx)

View File

@ -20,7 +20,7 @@ func (suite *IntegrationTestSuite) TestEthCallToGreeterContract() {
// this test manipulates state of the Greeter contract which means other tests shouldn't use it. // this test manipulates state of the Greeter contract which means other tests shouldn't use it.
// setup funded account to interact with contract // setup funded account to interact with contract
user := suite.ZgChain.NewFundedAccount("greeter-contract-user", sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(1e6))) user := suite.ZgChain.NewFundedAccount("greeter-contract-user", sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e6)))
greeterAddr := suite.ZgChain.ContractAddrs["greeter"] greeterAddr := suite.ZgChain.ContractAddrs["greeter"]
contract, err := greeter.NewGreeter(greeterAddr, suite.ZgChain.EvmClient) contract, err := greeter.NewGreeter(greeterAddr, suite.ZgChain.EvmClient)
@ -63,12 +63,12 @@ func (suite *IntegrationTestSuite) TestEthCallToErc20() {
func (suite *IntegrationTestSuite) TestEip712BasicMessageAuthorization() { func (suite *IntegrationTestSuite) TestEip712BasicMessageAuthorization() {
// create new funded account // create new funded account
sender := suite.ZgChain.NewFundedAccount("eip712-msgSend", sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(2e4))) sender := suite.ZgChain.NewFundedAccount("eip712-msgSend", sdk.NewCoins(chaincfg.MakeCoinForGasDenom(2e4)))
receiver := app.RandomAddress() receiver := app.RandomAddress()
// setup message for sending some auxiliary denom to random receiver // setup message for sending some gas denom to random receiver
msgs := []sdk.Msg{ msgs := []sdk.Msg{
banktypes.NewMsgSend(sender.SdkAddress, receiver, sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(1e3))), banktypes.NewMsgSend(sender.SdkAddress, receiver, sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e3))),
} }
// create tx // create tx
@ -76,7 +76,7 @@ func (suite *IntegrationTestSuite) TestEip712BasicMessageAuthorization() {
sender, sender,
suite.ZgChain, suite.ZgChain,
1e6, 1e6,
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(1e4)), sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e4)),
msgs, msgs,
"this is a memo", "this is a memo",
).GetTx() ).GetTx()
@ -95,10 +95,10 @@ func (suite *IntegrationTestSuite) TestEip712BasicMessageAuthorization() {
_, err = util.WaitForSdkTxCommit(suite.ZgChain.Tx, res.TxResponse.TxHash, 6*time.Second) _, err = util.WaitForSdkTxCommit(suite.ZgChain.Tx, res.TxResponse.TxHash, 6*time.Second)
suite.NoError(err) suite.NoError(err)
// check that the message was processed & the auxiliary denom is transferred. // check that the message was processed & the gas denom is transferred.
balRes, err := suite.ZgChain.Bank.Balance(context.Background(), &banktypes.QueryBalanceRequest{ balRes, err := suite.ZgChain.Bank.Balance(context.Background(), &banktypes.QueryBalanceRequest{
Address: receiver.String(), Address: receiver.String(),
Denom: chaincfg.AuxiliaryDenom, Denom: chaincfg.GasDenom,
}) })
suite.NoError(err) suite.NoError(err)
suite.Equal(sdk.NewInt(1e3), balRes.Balance.Amount) suite.Equal(sdk.NewInt(1e3), balRes.Balance.Amount)
@ -113,7 +113,7 @@ func (suite *IntegrationTestSuite) TestEip712BasicMessageAuthorization() {
// sdkDenom := suite.DeployedErc20.CosmosDenom // sdkDenom := suite.DeployedErc20.CosmosDenom
// // create new funded account // // create new funded account
// depositor := suite.ZgChain.NewFundedAccount("eip712-lend-depositor", sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(1e5))) // depositor := suite.ZgChain.NewFundedAccount("eip712-lend-depositor", sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e5)))
// // give them erc20 balance to deposit // // give them erc20 balance to deposit
// fundRes := suite.FundZgChainErc20Balance(depositor.EvmAddress, amount.BigInt()) // fundRes := suite.FundZgChainErc20Balance(depositor.EvmAddress, amount.BigInt())
// suite.NoError(fundRes.Err) // suite.NoError(fundRes.Err)
@ -143,7 +143,7 @@ func (suite *IntegrationTestSuite) TestEip712BasicMessageAuthorization() {
// depositor, // depositor,
// suite.ZgChain, // suite.ZgChain,
// 1e6, // 1e6,
// sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(1e4)), // sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e4)),
// msgs, // msgs,
// "doing the USDT Earn workflow! erc20 -> sdk.Coin -> USDX hard deposit", // "doing the USDT Earn workflow! erc20 -> sdk.Coin -> USDX hard deposit",
// ).GetTx() // ).GetTx()
@ -189,7 +189,7 @@ func (suite *IntegrationTestSuite) TestEip712BasicMessageAuthorization() {
// withdrawAndConvertBack := util.ZgChainMsgRequest{ // withdrawAndConvertBack := util.ZgChainMsgRequest{
// Msgs: []sdk.Msg{&withdraw, &convertBack}, // Msgs: []sdk.Msg{&withdraw, &convertBack},
// GasLimit: 1e6, // GasLimit: 1e6,
// FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(1000)), // FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1000)),
// Data: "withdrawing from mint & converting back to erc20", // Data: "withdrawing from mint & converting back to erc20",
// } // }
// lastRes := depositor.SignAndBroadcastZgChainTx(withdrawAndConvertBack) // lastRes := depositor.SignAndBroadcastZgChainTx(withdrawAndConvertBack)

View File

@ -24,10 +24,10 @@ func (suite *IntegrationTestSuite) TestEthGasPriceReturnsMinFee() {
minGasPrices, err := getMinFeeFromAppToml(util.ZgChainHomePath()) minGasPrices, err := getMinFeeFromAppToml(util.ZgChainHomePath())
suite.NoError(err) suite.NoError(err)
// evm uses base denom, get base denom min fee // evm uses evm denom, get evm denom min fee
evmMinGas := minGasPrices.AmountOf(chaincfg.BaseDenom).TruncateInt().BigInt() evmMinGas := minGasPrices.AmountOf(chaincfg.EvmDenom).TruncateInt().BigInt()
// returns eth_gasPrice, units in auxiliary denom // returns eth_gasPrice, units in gas denom
gasPrice, err := suite.ZgChain.EvmClient.SuggestGasPrice(context.Background()) gasPrice, err := suite.ZgChain.EvmClient.SuggestGasPrice(context.Background())
suite.NoError(err) suite.NoError(err)
@ -38,13 +38,13 @@ func (suite *IntegrationTestSuite) TestEvmRespectsMinFee() {
suite.SkipIfKvtoolDisabled() suite.SkipIfKvtoolDisabled()
// setup sender & receiver // setup sender & receiver
sender := suite.ZgChain.NewFundedAccount("evm-min-fee-test-sender", sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(1e3))) sender := suite.ZgChain.NewFundedAccount("evm-min-fee-test-sender", sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e3)))
randoReceiver := util.SdkToEvmAddress(app.RandomAddress()) randoReceiver := util.SdkToEvmAddress(app.RandomAddress())
// get min gas price for evm (from app.toml) // get min gas price for evm (from app.toml)
minFees, err := getMinFeeFromAppToml(util.ZgChainHomePath()) minFees, err := getMinFeeFromAppToml(util.ZgChainHomePath())
suite.NoError(err) suite.NoError(err)
minGasPrice := minFees.AmountOf(chaincfg.BaseDenom).TruncateInt() minGasPrice := minFees.AmountOf(chaincfg.EvmDenom).TruncateInt()
// attempt tx with less than min gas price (min fee - 1) // attempt tx with less than min gas price (min fee - 1)
tooLowGasPrice := minGasPrice.Sub(sdk.OneInt()).BigInt() tooLowGasPrice := minGasPrice.Sub(sdk.OneInt()).BigInt()

View File

@ -25,7 +25,7 @@ import (
) )
var ( var (
minEvmGasPrice = big.NewInt(1e10) // base denom minEvmGasPrice = big.NewInt(1e10) // evm denom
) )
type IntegrationTestSuite struct { type IntegrationTestSuite struct {
@ -54,7 +54,7 @@ func (suite *IntegrationTestSuite) TestChainID() {
// example test that funds a new account & queries its balance // example test that funds a new account & queries its balance
func (suite *IntegrationTestSuite) TestFundedAccount() { func (suite *IntegrationTestSuite) TestFundedAccount() {
funds := chaincfg.MakeCoinForAuxiliaryDenom(1e3) funds := chaincfg.MakeCoinForGasDenom(1e3)
acc := suite.ZgChain.NewFundedAccount("example-acc", sdk.NewCoins(funds)) acc := suite.ZgChain.NewFundedAccount("example-acc", sdk.NewCoins(funds))
// check that the sdk & evm signers are for the same account // check that the sdk & evm signers are for the same account
@ -63,21 +63,21 @@ func (suite *IntegrationTestSuite) TestFundedAccount() {
// check balance via SDK query // check balance via SDK query
res, err := suite.ZgChain.Bank.Balance(context.Background(), banktypes.NewQueryBalanceRequest( res, err := suite.ZgChain.Bank.Balance(context.Background(), banktypes.NewQueryBalanceRequest(
acc.SdkAddress, chaincfg.AuxiliaryDenom, acc.SdkAddress, chaincfg.GasDenom,
)) ))
suite.NoError(err) suite.NoError(err)
suite.Equal(funds, *res.Balance) suite.Equal(funds, *res.Balance)
// check balance via EVM query // check balance via EVM query
baseDenomBal, err := suite.ZgChain.EvmClient.BalanceAt(context.Background(), acc.EvmAddress, nil) evmDenomBal, err := suite.ZgChain.EvmClient.BalanceAt(context.Background(), acc.EvmAddress, nil)
suite.NoError(err) suite.NoError(err)
suite.Equal(funds.Amount.MulRaw(1e12).BigInt(), baseDenomBal) suite.Equal(funds.Amount.MulRaw(1e12).BigInt(), evmDenomBal)
} }
// example test that signs & broadcasts an EVM tx // example test that signs & broadcasts an EVM tx
func (suite *IntegrationTestSuite) TestTransferOverEVM() { func (suite *IntegrationTestSuite) TestTransferOverEVM() {
// fund an account that can perform the transfer // fund an account that can perform the transfer
initialFunds := chaincfg.MakeCoinForAuxiliaryDenom(1e6) // 1 (auxiliary denom) initialFunds := chaincfg.MakeCoinForGasDenom(1e6) // 1 (gas denom)
acc := suite.ZgChain.NewFundedAccount("evm-test-transfer", sdk.NewCoins(initialFunds)) acc := suite.ZgChain.NewFundedAccount("evm-test-transfer", sdk.NewCoins(initialFunds))
// get a rando account to send 0gchain to // get a rando account to send 0gchain to
@ -89,10 +89,10 @@ func (suite *IntegrationTestSuite) TestTransferOverEVM() {
suite.NoError(err) suite.NoError(err)
suite.Equal(uint64(0), nonce) // sanity check. the account should have no prior txs suite.Equal(uint64(0), nonce) // sanity check. the account should have no prior txs
// transfer auxiliary denom over EVM // transfer gas denom over EVM
AuxiliaryDenomToTransfer := big.NewInt(1e17) // .1 (auxiliary denom); base denom has 18 decimals. GasDenomToTransfer := big.NewInt(1e17) // .1 (gas denom); evm denom has 18 decimals.
req := util.EvmTxRequest{ req := util.EvmTxRequest{
Tx: ethtypes.NewTransaction(nonce, to, AuxiliaryDenomToTransfer, 1e5, minEvmGasPrice, nil), Tx: ethtypes.NewTransaction(nonce, to, GasDenomToTransfer, 1e5, minEvmGasPrice, nil),
Data: "any ol' data to track this through the system", Data: "any ol' data to track this through the system",
} }
res := acc.SignAndBroadcastEvmTx(req) res := acc.SignAndBroadcastEvmTx(req)
@ -100,31 +100,31 @@ func (suite *IntegrationTestSuite) TestTransferOverEVM() {
suite.Equal(ethtypes.ReceiptStatusSuccessful, res.Receipt.Status) suite.Equal(ethtypes.ReceiptStatusSuccessful, res.Receipt.Status)
// evm txs refund unused gas. so to know the expected balance we need to know how much gas was used. // evm txs refund unused gas. so to know the expected balance we need to know how much gas was used.
AuxiliaryDenomUsedForGas := sdkmath.NewIntFromBigInt(minEvmGasPrice). GasDenomUsedForGas := sdkmath.NewIntFromBigInt(minEvmGasPrice).
Mul(sdkmath.NewIntFromUint64(res.Receipt.GasUsed)). Mul(sdkmath.NewIntFromUint64(res.Receipt.GasUsed)).
QuoRaw(1e12) // convert base denom to auxiliary denom QuoRaw(1e12) // convert evm denom to gas denom
// expect (9 - gas used) (auxiliary denom) remaining in account. // expect (9 - gas used) (gas denom) remaining in account.
balance := suite.ZgChain.QuerySdkForBalances(acc.SdkAddress) balance := suite.ZgChain.QuerySdkForBalances(acc.SdkAddress)
suite.Equal(sdkmath.NewInt(9e5).Sub(AuxiliaryDenomUsedForGas), balance.AmountOf(chaincfg.AuxiliaryDenom)) suite.Equal(sdkmath.NewInt(9e5).Sub(GasDenomUsedForGas), balance.AmountOf(chaincfg.GasDenom))
} }
// TestIbcTransfer transfers (auxiliary denom) from the primary 0g-chain (suite.ZgChain) to the ibc chain (suite.Ibc). // TestIbcTransfer transfers (gas denom) from the primary 0g-chain (suite.ZgChain) to the ibc chain (suite.Ibc).
// Note that because the IBC chain also runs 0g-chain's binary, this tests both the sending & receiving. // Note that because the IBC chain also runs 0g-chain's binary, this tests both the sending & receiving.
func (suite *IntegrationTestSuite) TestIbcTransfer() { func (suite *IntegrationTestSuite) TestIbcTransfer() {
suite.SkipIfIbcDisabled() suite.SkipIfIbcDisabled()
// ARRANGE // ARRANGE
// setup 0g-chain account // setup 0g-chain account
funds := chaincfg.MakeCoinForAuxiliaryDenom(1e5) // .1 (auxiliary denom) funds := chaincfg.MakeCoinForGasDenom(1e5) // .1 (gas denom)
zgChainAcc := suite.ZgChain.NewFundedAccount("ibc-transfer-0g-side", sdk.NewCoins(funds)) zgChainAcc := suite.ZgChain.NewFundedAccount("ibc-transfer-0g-side", sdk.NewCoins(funds))
// setup ibc account // setup ibc account
ibcAcc := suite.Ibc.NewFundedAccount("ibc-transfer-ibc-side", sdk.NewCoins()) ibcAcc := suite.Ibc.NewFundedAccount("ibc-transfer-ibc-side", sdk.NewCoins())
gasLimit := int64(2e5) gasLimit := int64(2e5)
fee := chaincfg.MakeCoinForAuxiliaryDenom(200) fee := chaincfg.MakeCoinForGasDenom(200)
fundsToSend := chaincfg.MakeCoinForAuxiliaryDenom(5e4) // .005 (auxiliary denom) fundsToSend := chaincfg.MakeCoinForGasDenom(5e4) // .005 (gas denom)
transferMsg := ibctypes.NewMsgTransfer( transferMsg := ibctypes.NewMsgTransfer(
testutil.IbcPort, testutil.IbcPort,
testutil.IbcChannel, testutil.IbcChannel,
@ -154,7 +154,7 @@ func (suite *IntegrationTestSuite) TestIbcTransfer() {
// the balance should be deducted from 0g-chain account // the balance should be deducted from 0g-chain account
suite.Eventually(func() bool { suite.Eventually(func() bool {
balance := suite.ZgChain.QuerySdkForBalances(zgChainAcc.SdkAddress) balance := suite.ZgChain.QuerySdkForBalances(zgChainAcc.SdkAddress)
return balance.AmountOf(chaincfg.AuxiliaryDenom).Equal(expectedSrcBalance.Amount) return balance.AmountOf(chaincfg.GasDenom).Equal(expectedSrcBalance.Amount)
}, 10*time.Second, 1*time.Second) }, 10*time.Second, 1*time.Second)
// expect the balance to be transferred to the ibc chain! // expect the balance to be transferred to the ibc chain!

View File

@ -74,7 +74,7 @@ var (
EvmRpcUrl: "http://localhost:8545", EvmRpcUrl: "http://localhost:8545",
ChainId: "0gchainlocalnet_8888-1", ChainId: "0gchainlocalnet_8888-1",
StakingDenom: chaincfg.AuxiliaryDenom, StakingDenom: chaincfg.GasDenom,
} }
kvtoolIbcChain = ChainDetails{ kvtoolIbcChain = ChainDetails{
RpcUrl: "http://localhost:26658", RpcUrl: "http://localhost:26658",

View File

@ -262,7 +262,7 @@ func (a *SigningAccount) BankSend(to sdk.AccAddress, amount sdk.Coins) util.ZgCh
util.ZgChainMsgRequest{ util.ZgChainMsgRequest{
Msgs: []sdk.Msg{banktypes.NewMsgSend(a.SdkAddress, to, amount)}, Msgs: []sdk.Msg{banktypes.NewMsgSend(a.SdkAddress, to, amount)},
GasLimit: 2e5, // 200,000 gas GasLimit: 2e5, // 200,000 gas
FeeAmount: sdk.NewCoins(sdk.NewCoin(a.gasDenom, sdkmath.NewInt(200))), // assume min gas price of .001 auxiliary denom FeeAmount: sdk.NewCoins(sdk.NewCoin(a.gasDenom, sdkmath.NewInt(200))), // assume min gas price of .001 gas denom
Data: fmt.Sprintf("sending %s to %s", amount, to), Data: fmt.Sprintf("sending %s to %s", amount, to),
}, },
) )

View File

@ -98,7 +98,7 @@ message Metadata {
string description = 1; string description = 1;
// denom_units represents the list of DenomUnit's for a given coin // denom_units represents the list of DenomUnit's for a given coin
repeated DenomUnit denom_units = 2; repeated DenomUnit denom_units = 2;
// base represents the base denom (should be the DenomUnit with exponent = 0). // base represents the evm denom (should be the DenomUnit with exponent = 0).
string base = 3; string base = 3;
// display indicates the suggested denom that should be // display indicates the suggested denom that should be
// displayed in clients. // displayed in clients.

View File

@ -234,18 +234,18 @@ message Tip {
string tipper = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; string tipper = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
} }
// AuxSignerData is the intermediary format that an auxiliary signer (e.g. a // AuxSignerData is the intermediary format that an gas signer (e.g. a
// tipper) builds and sends to the fee payer (who will build and broadcast the // tipper) builds and sends to the fee payer (who will build and broadcast the
// actual tx). AuxSignerData is not a valid tx in itself, and will be rejected // actual tx). AuxSignerData is not a valid tx in itself, and will be rejected
// by the node if sent directly as-is. // by the node if sent directly as-is.
// //
// Since: cosmos-sdk 0.46 // Since: cosmos-sdk 0.46
message AuxSignerData { message AuxSignerData {
// address is the bech32-encoded address of the auxiliary signer. If using // address is the bech32-encoded address of the gas signer. If using
// AuxSignerData across different chains, the bech32 prefix of the target // AuxSignerData across different chains, the bech32 prefix of the target
// chain (where the final transaction is broadcasted) should be used. // chain (where the final transaction is broadcasted) should be used.
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// sign_doc is the SIGN_MODE_DIRECT_AUX sign doc that the auxiliary signer // sign_doc is the SIGN_MODE_DIRECT_AUX sign doc that the gas signer
// signs. Note: we use the same sign doc even if we're signing with // signs. Note: we use the same sign doc even if we're signing with
// LEGACY_AMINO_JSON. // LEGACY_AMINO_JSON.
SignDocDirectAux sign_doc = 2; SignDocDirectAux sign_doc = 2;

View File

@ -6,13 +6,13 @@ option go_package = "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types";
import "gogoproto/gogo.proto"; import "gogoproto/gogo.proto";
// DenomTrace contains the base denomination for ICS20 fungible tokens and the // DenomTrace contains the evm denomination for ICS20 fungible tokens and the
// source tracing information path. // source tracing information path.
message DenomTrace { message DenomTrace {
// path defines the chain of port/channel identifiers used for tracing the // path defines the chain of port/channel identifiers used for tracing the
// source of the fungible token. // source of the fungible token.
string path = 1; string path = 1;
// base denomination of the relayed fungible token. // evm denomination of the relayed fungible token.
string base_denom = 2; string base_denom = 2;
} }

View File

@ -36,7 +36,7 @@ func (suite *MsgServerTestSuite) SetupTest() {
// Set up genesis state and initialize // Set up genesis state and initialize
_, addrs := app.GeneratePrivKeyAddressPairs(3) _, addrs := app.GeneratePrivKeyAddressPairs(3)
coins := sdk.NewCoins(c("bnb", 10000000000), c(chaincfg.AuxiliaryDenom, 10000)) coins := sdk.NewCoins(c("bnb", 10000000000), c(chaincfg.GasDenom, 10000))
authGS := app.NewFundedGenStateWithSameCoins(tApp.AppCodec(), coins, addrs) authGS := app.NewFundedGenStateWithSameCoins(tApp.AppCodec(), coins, addrs)
tApp.InitializeFromGenesisStates(authGS, NewBep3GenStateMulti(cdc, addrs[0])) tApp.InitializeFromGenesisStates(authGS, NewBep3GenStateMulti(cdc, addrs[0]))

View File

@ -20,7 +20,7 @@ type GenesisTestSuite struct {
} }
func (suite *GenesisTestSuite) SetupTest() { func (suite *GenesisTestSuite) SetupTest() {
coin := chaincfg.MakeCoinForAuxiliaryDenom(1) coin := chaincfg.MakeCoinForGasDenom(1)
suite.swaps = atomicSwaps(10) suite.swaps = atomicSwaps(10)
supply := types.NewAssetSupply(coin, coin, coin, coin, time.Duration(0)) supply := types.NewAssetSupply(coin, coin, coin, coin, time.Duration(0))

View File

@ -11,7 +11,7 @@ import (
) )
func TestAssetSupplyValidate(t *testing.T) { func TestAssetSupplyValidate(t *testing.T) {
coin := chaincfg.MakeCoinForAuxiliaryDenom(1) coin := chaincfg.MakeCoinForGasDenom(1)
invalidCoin := sdk.Coin{Denom: "Invalid Denom", Amount: sdkmath.NewInt(-1)} invalidCoin := sdk.Coin{Denom: "Invalid Denom", Amount: sdkmath.NewInt(-1)}
testCases := []struct { testCases := []struct {
msg string msg string

View File

@ -61,7 +61,7 @@ func (suite *MsgServerTestSuite) SetupTest() {
[]types.Proposal{}, []types.Proposal{},
[]types.Vote{}, []types.Vote{},
) )
suite.communityPoolAmt = sdk.NewCoins(chaincfg.MakeCoinForBaseDenom(1000000000000000)) suite.communityPoolAmt = sdk.NewCoins(chaincfg.MakeCoinForEvmDenom(1000000000000000))
suite.app.InitializeFromGenesisStates( suite.app.InitializeFromGenesisStates(
app.GenesisState{types.ModuleName: cdc.MustMarshalJSON(testGenesis)}, app.GenesisState{types.ModuleName: cdc.MustMarshalJSON(testGenesis)},
// TODO: not used? // TODO: not used?

View File

@ -171,7 +171,7 @@ func NewVoteCmd() *cobra.Command {
tokens = val.GetTokens() tokens = val.GetTokens()
} }
} }
// the denom of token is base denom, need to convert to A0GI // the denom of token is evm denom, need to convert to A0GI
a0giTokenCnt := tokens.Quo(sdk.NewInt(1_000_000_000_000_000_000)) a0giTokenCnt := tokens.Quo(sdk.NewInt(1_000_000_000_000_000_000))
// 1_000 0AGI token / vote // 1_000 0AGI token / vote
numBallots := a0giTokenCnt.Quo(sdk.NewInt(1_000)).Uint64() numBallots := a0giTokenCnt.Quo(sdk.NewInt(1_000)).Uint64()

View File

@ -13,53 +13,53 @@ import (
"github.com/0glabs/0g-chain/x/evmutil/types" "github.com/0glabs/0g-chain/x/evmutil/types"
) )
// ConversionMultiplier is the conversion multiplier between base denom and auxiliary denom // ConversionMultiplier is the conversion multiplier between evm denom and gas denom
var ConversionMultiplier = sdkmath.NewInt(chaincfg.AuxiliaryDenomConversionMultiplier) var ConversionMultiplier = sdkmath.NewInt(chaincfg.GasDenomConversionMultiplier)
var _ evmtypes.BankKeeper = EvmBankKeeper{} var _ evmtypes.BankKeeper = EvmBankKeeper{}
// EvmBankKeeper is a BankKeeper wrapper for the x/evm module to allow the use // EvmBankKeeper is a BankKeeper wrapper for the x/evm module to allow the use
// of the 18 decimal base denom coin on the evm. // of the 18 decimal evm denom coin on the evm.
// x/evm consumes gas and send coins by minting and burning base denom coins in its module // x/evm consumes gas and send coins by minting and burning evm denom coins in its module
// account and then sending the funds to the target account. // account and then sending the funds to the target account.
// This keeper uses both the auxiliary denom coin and a separate base denom balance to manage the // This keeper uses both the gas denom coin and a separate evm denom balance to manage the
// extra percision needed by the evm. // extra percision needed by the evm.
type EvmBankKeeper struct { type EvmBankKeeper struct {
baseDenomKeeper Keeper evmDenomKeeper Keeper
bk types.BankKeeper bk types.BankKeeper
ak types.AccountKeeper ak types.AccountKeeper
} }
func NewEvmBankKeeper(baseKeeper Keeper, bk types.BankKeeper, ak types.AccountKeeper) EvmBankKeeper { func NewEvmBankKeeper(baseKeeper Keeper, bk types.BankKeeper, ak types.AccountKeeper) EvmBankKeeper {
return EvmBankKeeper{ return EvmBankKeeper{
baseDenomKeeper: baseKeeper, evmDenomKeeper: baseKeeper,
bk: bk, bk: bk,
ak: ak, ak: ak,
} }
} }
// GetBalance returns the total **spendable** balance of base denom for a given account by address. // GetBalance returns the total **spendable** balance of evm denom for a given account by address.
func (k EvmBankKeeper) GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin { func (k EvmBankKeeper) GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin {
if denom != chaincfg.BaseDenom { if denom != chaincfg.EvmDenom {
panic(fmt.Errorf("only evm denom %s is supported by EvmBankKeeper", chaincfg.BaseDenom)) panic(fmt.Errorf("only evm denom %s is supported by EvmBankKeeper", chaincfg.EvmDenom))
} }
spendableCoins := k.bk.SpendableCoins(ctx, addr) spendableCoins := k.bk.SpendableCoins(ctx, addr)
auxiliaryDenomFromBank := spendableCoins.AmountOf(chaincfg.AuxiliaryDenom) gasDenomFromBank := spendableCoins.AmountOf(chaincfg.GasDenom)
baseDenomFromBank := spendableCoins.AmountOf(chaincfg.BaseDenom) evmDenomFromBank := spendableCoins.AmountOf(chaincfg.EvmDenom)
baseDenomFromEvmBank := k.baseDenomKeeper.GetBalance(ctx, addr) evmDenomFromEvmBank := k.evmDenomKeeper.GetBalance(ctx, addr)
var total sdkmath.Int var total sdkmath.Int
if auxiliaryDenomFromBank.IsPositive() { if gasDenomFromBank.IsPositive() {
total = auxiliaryDenomFromBank.Mul(ConversionMultiplier).Add(baseDenomFromBank).Add(baseDenomFromEvmBank) total = gasDenomFromBank.Mul(ConversionMultiplier).Add(evmDenomFromBank).Add(evmDenomFromEvmBank)
} else { } else {
total = baseDenomFromBank.Add(baseDenomFromEvmBank) total = evmDenomFromBank.Add(evmDenomFromEvmBank)
} }
return sdk.NewCoin(chaincfg.BaseDenom, total) return sdk.NewCoin(chaincfg.EvmDenom, total)
} }
// SendCoins transfers base denom coins from a AccAddress to an AccAddress. // SendCoins transfers evm denom coins from a AccAddress to an AccAddress.
func (k EvmBankKeeper) SendCoins(ctx sdk.Context, senderAddr sdk.AccAddress, recipientAddr sdk.AccAddress, amt sdk.Coins) error { func (k EvmBankKeeper) SendCoins(ctx sdk.Context, senderAddr sdk.AccAddress, recipientAddr sdk.AccAddress, amt sdk.Coins) error {
// SendCoins method is not used by the evm module, but is required by the // SendCoins method is not used by the evm module, but is required by the
// evmtypes.BankKeeper interface. This must be updated if the evm module // evmtypes.BankKeeper interface. This must be updated if the evm module
@ -67,148 +67,148 @@ func (k EvmBankKeeper) SendCoins(ctx sdk.Context, senderAddr sdk.AccAddress, rec
panic("not implemented") panic("not implemented")
} }
// SendCoinsFromModuleToAccount transfers base denom coins from a ModuleAccount to an AccAddress. // SendCoinsFromModuleToAccount transfers evm denom coins from a ModuleAccount to an AccAddress.
// It will panic if the module account does not exist. An error is returned if the recipient // It will panic if the module account does not exist. An error is returned if the recipient
// address is black-listed or if sending the tokens fails. // address is black-listed or if sending the tokens fails.
func (k EvmBankKeeper) SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error { func (k EvmBankKeeper) SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error {
auxiliaryDenomCoin, baseDemonCnt, err := SplitBaseDenomCoins(amt) gasDenomCoin, baseDemonCnt, err := SplitEvmDenomCoins(amt)
if err != nil { if err != nil {
return err return err
} }
if auxiliaryDenomCoin.Amount.IsPositive() { if gasDenomCoin.Amount.IsPositive() {
if err := k.bk.SendCoinsFromModuleToAccount(ctx, senderModule, recipientAddr, sdk.NewCoins(auxiliaryDenomCoin)); err != nil { if err := k.bk.SendCoinsFromModuleToAccount(ctx, senderModule, recipientAddr, sdk.NewCoins(gasDenomCoin)); err != nil {
return err return err
} }
} }
senderAddr := k.GetModuleAddress(senderModule) senderAddr := k.GetModuleAddress(senderModule)
if err := k.ConvertOneAuxiliaryDenomToBaseDenomIfNeeded(ctx, senderAddr, baseDemonCnt); err != nil { if err := k.ConvertOneGasDenomToEvmDenomIfNeeded(ctx, senderAddr, baseDemonCnt); err != nil {
return err return err
} }
if err := k.baseDenomKeeper.SendBalance(ctx, senderAddr, recipientAddr, baseDemonCnt); err != nil { if err := k.evmDenomKeeper.SendBalance(ctx, senderAddr, recipientAddr, baseDemonCnt); err != nil {
return err return err
} }
return k.ConvertBaseDenomToAuxiliaryDenom(ctx, recipientAddr) return k.ConvertEvmDenomToGasDenom(ctx, recipientAddr)
} }
// SendCoinsFromAccountToModule transfers base denom coins from an AccAddress to a ModuleAccount. // SendCoinsFromAccountToModule transfers evm denom coins from an AccAddress to a ModuleAccount.
// It will panic if the module account does not exist. // It will panic if the module account does not exist.
func (k EvmBankKeeper) SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error { func (k EvmBankKeeper) SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error {
auxiliaryDenomCoin, baseDenomCnt, err := SplitBaseDenomCoins(amt) gasDenomCoin, evmDenomCnt, err := SplitEvmDenomCoins(amt)
if err != nil { if err != nil {
return err return err
} }
if auxiliaryDenomCoin.IsPositive() { if gasDenomCoin.IsPositive() {
if err := k.bk.SendCoinsFromAccountToModule(ctx, senderAddr, recipientModule, sdk.NewCoins(auxiliaryDenomCoin)); err != nil { if err := k.bk.SendCoinsFromAccountToModule(ctx, senderAddr, recipientModule, sdk.NewCoins(gasDenomCoin)); err != nil {
return err return err
} }
} }
if err := k.ConvertOneAuxiliaryDenomToBaseDenomIfNeeded(ctx, senderAddr, baseDenomCnt); err != nil { if err := k.ConvertOneGasDenomToEvmDenomIfNeeded(ctx, senderAddr, evmDenomCnt); err != nil {
return err return err
} }
recipientAddr := k.GetModuleAddress(recipientModule) recipientAddr := k.GetModuleAddress(recipientModule)
if err := k.baseDenomKeeper.SendBalance(ctx, senderAddr, recipientAddr, baseDenomCnt); err != nil { if err := k.evmDenomKeeper.SendBalance(ctx, senderAddr, recipientAddr, evmDenomCnt); err != nil {
return err return err
} }
return k.ConvertBaseDenomToAuxiliaryDenom(ctx, recipientAddr) return k.ConvertEvmDenomToGasDenom(ctx, recipientAddr)
} }
// MintCoins mints base denom coins by minting the equivalent auxiliary denom coins and any remaining base denom coins. // MintCoins mints evm denom coins by minting the equivalent gas denom coins and any remaining evm denom coins.
// It will panic if the module account does not exist or is unauthorized. // It will panic if the module account does not exist or is unauthorized.
func (k EvmBankKeeper) MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error { func (k EvmBankKeeper) MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error {
auxiliaryDenomCoin, baseDemonCnt, err := SplitBaseDenomCoins(amt) gasDenomCoin, baseDemonCnt, err := SplitEvmDenomCoins(amt)
if err != nil { if err != nil {
return err return err
} }
if auxiliaryDenomCoin.IsPositive() { if gasDenomCoin.IsPositive() {
if err := k.bk.MintCoins(ctx, moduleName, sdk.NewCoins(auxiliaryDenomCoin)); err != nil { if err := k.bk.MintCoins(ctx, moduleName, sdk.NewCoins(gasDenomCoin)); err != nil {
return err return err
} }
} }
recipientAddr := k.GetModuleAddress(moduleName) recipientAddr := k.GetModuleAddress(moduleName)
if err := k.baseDenomKeeper.AddBalance(ctx, recipientAddr, baseDemonCnt); err != nil { if err := k.evmDenomKeeper.AddBalance(ctx, recipientAddr, baseDemonCnt); err != nil {
return err return err
} }
return k.ConvertBaseDenomToAuxiliaryDenom(ctx, recipientAddr) return k.ConvertEvmDenomToGasDenom(ctx, recipientAddr)
} }
// BurnCoins burns base denom coins by burning the equivalent auxiliary denom coins and any remaining base denom coins. // BurnCoins burns evm denom coins by burning the equivalent gas denom coins and any remaining evm denom coins.
// It will panic if the module account does not exist or is unauthorized. // It will panic if the module account does not exist or is unauthorized.
func (k EvmBankKeeper) BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error { func (k EvmBankKeeper) BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error {
auxiliaryDenomCoin, baseDemonCnt, err := SplitBaseDenomCoins(amt) gasDenomCoin, baseDemonCnt, err := SplitEvmDenomCoins(amt)
if err != nil { if err != nil {
return err return err
} }
if auxiliaryDenomCoin.IsPositive() { if gasDenomCoin.IsPositive() {
if err := k.bk.BurnCoins(ctx, moduleName, sdk.NewCoins(auxiliaryDenomCoin)); err != nil { if err := k.bk.BurnCoins(ctx, moduleName, sdk.NewCoins(gasDenomCoin)); err != nil {
return err return err
} }
} }
moduleAddr := k.GetModuleAddress(moduleName) moduleAddr := k.GetModuleAddress(moduleName)
if err := k.ConvertOneAuxiliaryDenomToBaseDenomIfNeeded(ctx, moduleAddr, baseDemonCnt); err != nil { if err := k.ConvertOneGasDenomToEvmDenomIfNeeded(ctx, moduleAddr, baseDemonCnt); err != nil {
return err return err
} }
return k.baseDenomKeeper.RemoveBalance(ctx, moduleAddr, baseDemonCnt) return k.evmDenomKeeper.RemoveBalance(ctx, moduleAddr, baseDemonCnt)
} }
// ConvertOneauxiliaryDenomToBaseDenomIfNeeded converts 1 auxiliary denom to base denom for an address if // ConvertOnegasDenomToEvmDenomIfNeeded converts 1 gas denom to evm denom for an address if
// its base denom balance is smaller than the baseDenomCnt amount. // its evm denom balance is smaller than the evmDenomCnt amount.
func (k EvmBankKeeper) ConvertOneAuxiliaryDenomToBaseDenomIfNeeded(ctx sdk.Context, addr sdk.AccAddress, baseDenomCnt sdkmath.Int) error { func (k EvmBankKeeper) ConvertOneGasDenomToEvmDenomIfNeeded(ctx sdk.Context, addr sdk.AccAddress, evmDenomCnt sdkmath.Int) error {
baseDenomBal := k.baseDenomKeeper.GetBalance(ctx, addr) evmDenomBal := k.evmDenomKeeper.GetBalance(ctx, addr)
if baseDenomBal.GTE(baseDenomCnt) { if evmDenomBal.GTE(evmDenomCnt) {
return nil return nil
} }
auxiliaryDenomToStore := sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdk.OneInt())) gasDenomToStore := sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdk.OneInt()))
if err := k.bk.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, auxiliaryDenomToStore); err != nil { if err := k.bk.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, gasDenomToStore); err != nil {
return err return err
} }
// add 1 auxiliary denom equivalent of base denom to addr // add 1 gas denom equivalent of evm denom to addr
baseDenomToReceive := ConversionMultiplier evmDenomToReceive := ConversionMultiplier
if err := k.baseDenomKeeper.AddBalance(ctx, addr, baseDenomToReceive); err != nil { if err := k.evmDenomKeeper.AddBalance(ctx, addr, evmDenomToReceive); err != nil {
return err return err
} }
return nil return nil
} }
// ConvertBaseDenomToauxiliaryDenom converts all available base denom to auxiliary denom for a given AccAddress. // ConvertEvmDenomTogasDenom converts all available evm denom to gas denom for a given AccAddress.
func (k EvmBankKeeper) ConvertBaseDenomToAuxiliaryDenom(ctx sdk.Context, addr sdk.AccAddress) error { func (k EvmBankKeeper) ConvertEvmDenomToGasDenom(ctx sdk.Context, addr sdk.AccAddress) error {
totalBaseDenom := k.baseDenomKeeper.GetBalance(ctx, addr) totalEvmDenom := k.evmDenomKeeper.GetBalance(ctx, addr)
auxiliaryDenomCoin, _, err := SplitBaseDenomCoins(sdk.NewCoins(sdk.NewCoin(chaincfg.BaseDenom, totalBaseDenom))) gasDenomCoin, _, err := SplitEvmDenomCoins(sdk.NewCoins(sdk.NewCoin(chaincfg.EvmDenom, totalEvmDenom)))
if err != nil { if err != nil {
return err return err
} }
// do nothing if account does not have enough base denom for a single auxiliary denom // do nothing if account does not have enough evm denom for a single gas denom
auxiliaryDenomToReceive := auxiliaryDenomCoin.Amount gasDenomToReceive := gasDenomCoin.Amount
if !auxiliaryDenomToReceive.IsPositive() { if !gasDenomToReceive.IsPositive() {
return nil return nil
} }
// remove base denom used for converting to auxiliary denom // remove evm denom used for converting to gas denom
baseDenomToBurn := auxiliaryDenomToReceive.Mul(ConversionMultiplier) evmDenomToBurn := gasDenomToReceive.Mul(ConversionMultiplier)
finalBal := totalBaseDenom.Sub(baseDenomToBurn) finalBal := totalEvmDenom.Sub(evmDenomToBurn)
if err := k.baseDenomKeeper.SetBalance(ctx, addr, finalBal); err != nil { if err := k.evmDenomKeeper.SetBalance(ctx, addr, finalBal); err != nil {
return err return err
} }
fromAddr := k.GetModuleAddress(types.ModuleName) fromAddr := k.GetModuleAddress(types.ModuleName)
if err := k.bk.SendCoins(ctx, fromAddr, addr, sdk.NewCoins(auxiliaryDenomCoin)); err != nil { if err := k.bk.SendCoins(ctx, fromAddr, addr, sdk.NewCoins(gasDenomCoin)); err != nil {
return err return err
} }
@ -223,18 +223,18 @@ func (k EvmBankKeeper) GetModuleAddress(moduleName string) sdk.AccAddress {
return addr return addr
} }
// SplitBaseDenomCoins splits base denom coins to the equivalent auxiliary denom coins and any remaining base denom balance. // SplitEvmDenomCoins splits evm denom coins to the equivalent gas denom coins and any remaining evm denom balance.
// An error will be returned if the coins are not valid or if the coins are not the base denom. // An error will be returned if the coins are not valid or if the coins are not the evm denom.
func SplitBaseDenomCoins(coins sdk.Coins) (sdk.Coin, sdkmath.Int, error) { func SplitEvmDenomCoins(coins sdk.Coins) (sdk.Coin, sdkmath.Int, error) {
baseDemonCnt := sdk.ZeroInt() baseDemonCnt := sdk.ZeroInt()
auxiliaryDenomAmt := sdk.NewCoin(chaincfg.AuxiliaryDenom, sdk.ZeroInt()) gasDenomAmt := sdk.NewCoin(chaincfg.GasDenom, sdk.ZeroInt())
if len(coins) == 0 { if len(coins) == 0 {
return auxiliaryDenomAmt, baseDemonCnt, nil return gasDenomAmt, baseDemonCnt, nil
} }
if err := ValidateEvmCoins(coins); err != nil { if err := ValidateEvmCoins(coins); err != nil {
return auxiliaryDenomAmt, baseDemonCnt, err return gasDenomAmt, baseDemonCnt, err
} }
// note: we should always have len(coins) == 1 here since coins cannot have dup denoms after we validate. // note: we should always have len(coins) == 1 here since coins cannot have dup denoms after we validate.
@ -243,15 +243,15 @@ func SplitBaseDenomCoins(coins sdk.Coins) (sdk.Coin, sdkmath.Int, error) {
if remainingBalance.IsPositive() { if remainingBalance.IsPositive() {
baseDemonCnt = remainingBalance baseDemonCnt = remainingBalance
} }
auxiliaryDenomAmount := coin.Amount.Quo(ConversionMultiplier) gasDenomAmount := coin.Amount.Quo(ConversionMultiplier)
if auxiliaryDenomAmount.IsPositive() { if gasDenomAmount.IsPositive() {
auxiliaryDenomAmt = sdk.NewCoin(chaincfg.AuxiliaryDenom, auxiliaryDenomAmount) gasDenomAmt = sdk.NewCoin(chaincfg.GasDenom, gasDenomAmount)
} }
return auxiliaryDenomAmt, baseDemonCnt, nil return gasDenomAmt, baseDemonCnt, nil
} }
// ValidateEvmCoins validates the coins from evm is valid and is the base denom. // ValidateEvmCoins validates the coins from evm is valid and is the evm denom.
func ValidateEvmCoins(coins sdk.Coins) error { func ValidateEvmCoins(coins sdk.Coins) error {
if len(coins) == 0 { if len(coins) == 0 {
return nil return nil
@ -262,9 +262,9 @@ func ValidateEvmCoins(coins sdk.Coins) error {
return errorsmod.Wrap(sdkerrors.ErrInvalidCoins, coins.String()) return errorsmod.Wrap(sdkerrors.ErrInvalidCoins, coins.String())
} }
// validate that coin denom is base denom // validate that coin denom is evm denom
if len(coins) != 1 || coins[0].Denom != chaincfg.BaseDenom { if len(coins) != 1 || coins[0].Denom != chaincfg.EvmDenom {
errMsg := fmt.Sprintf("invalid evm coin denom, only %s is supported", chaincfg.BaseDenom) errMsg := fmt.Sprintf("invalid evm coin denom, only %s is supported", chaincfg.EvmDenom)
return errorsmod.Wrap(sdkerrors.ErrInvalidCoins, errMsg) return errorsmod.Wrap(sdkerrors.ErrInvalidCoins, errMsg)
} }

View File

@ -35,8 +35,8 @@ func (suite *evmBankKeeperTestSuite) SetupTest() {
} }
func (suite *evmBankKeeperTestSuite) TestGetBalance_ReturnsSpendable() { func (suite *evmBankKeeperTestSuite) TestGetBalance_ReturnsSpendable() {
startingCoins := sdk.NewCoins(sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 10)) startingCoins := sdk.NewCoins(sdk.NewInt64Coin(chaincfg.GasDenom, 10))
startingBaseDenom := sdkmath.NewInt(100) startingEvmDenom := sdkmath.NewInt(100)
now := tmtime.Now() now := tmtime.Now()
endTime := now.Add(24 * time.Hour) endTime := now.Add(24 * time.Hour)
@ -46,20 +46,20 @@ func (suite *evmBankKeeperTestSuite) TestGetBalance_ReturnsSpendable() {
err := suite.App.FundAccount(suite.Ctx, suite.Addrs[0], startingCoins) err := suite.App.FundAccount(suite.Ctx, suite.Addrs[0], startingCoins)
suite.Require().NoError(err) suite.Require().NoError(err)
err = suite.Keeper.SetBalance(suite.Ctx, suite.Addrs[0], startingBaseDenom) err = suite.Keeper.SetBalance(suite.Ctx, suite.Addrs[0], startingEvmDenom)
suite.Require().NoError(err) suite.Require().NoError(err)
coin := suite.EvmBankKeeper.GetBalance(suite.Ctx, suite.Addrs[0], chaincfg.BaseDenom) coin := suite.EvmBankKeeper.GetBalance(suite.Ctx, suite.Addrs[0], chaincfg.EvmDenom)
suite.Require().Equal(startingBaseDenom, coin.Amount) suite.Require().Equal(startingEvmDenom, coin.Amount)
ctx := suite.Ctx.WithBlockTime(now.Add(12 * time.Hour)) ctx := suite.Ctx.WithBlockTime(now.Add(12 * time.Hour))
coin = suite.EvmBankKeeper.GetBalance(ctx, suite.Addrs[0], chaincfg.BaseDenom) coin = suite.EvmBankKeeper.GetBalance(ctx, suite.Addrs[0], chaincfg.EvmDenom)
suite.Require().Equal(sdkmath.NewIntFromUint64(5_000_000_000_100), coin.Amount) suite.Require().Equal(sdkmath.NewIntFromUint64(5_000_000_000_100), coin.Amount)
} }
func (suite *evmBankKeeperTestSuite) TestGetBalance_NotEvmDenom() { func (suite *evmBankKeeperTestSuite) TestGetBalance_NotEvmDenom() {
suite.Require().Panics(func() { suite.Require().Panics(func() {
suite.EvmBankKeeper.GetBalance(suite.Ctx, suite.Addrs[0], chaincfg.AuxiliaryDenom) suite.EvmBankKeeper.GetBalance(suite.Ctx, suite.Addrs[0], chaincfg.GasDenom)
}) })
suite.Require().Panics(func() { suite.Require().Panics(func() {
suite.EvmBankKeeper.GetBalance(suite.Ctx, suite.Addrs[0], "busd") suite.EvmBankKeeper.GetBalance(suite.Ctx, suite.Addrs[0], "busd")
@ -73,39 +73,39 @@ func (suite *evmBankKeeperTestSuite) TestGetBalance() {
expAmount sdkmath.Int expAmount sdkmath.Int
}{ }{
{ {
"auxiliary denom with base denom", "gas denom with evm denom",
sdk.NewCoins( sdk.NewCoins(
sdk.NewInt64Coin(chaincfg.BaseDenom, 100), sdk.NewInt64Coin(chaincfg.EvmDenom, 100),
sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 10), sdk.NewInt64Coin(chaincfg.GasDenom, 10),
), ),
sdkmath.NewInt(10_000_000_000_100), sdkmath.NewInt(10_000_000_000_100),
}, },
{ {
"just base denom", "just evm denom",
sdk.NewCoins( sdk.NewCoins(
sdk.NewInt64Coin(chaincfg.BaseDenom, 100), sdk.NewInt64Coin(chaincfg.EvmDenom, 100),
sdk.NewInt64Coin("busd", 100), sdk.NewInt64Coin("busd", 100),
), ),
sdkmath.NewInt(100), sdkmath.NewInt(100),
}, },
{ {
"just auxiliary denom", "just gas denom",
sdk.NewCoins( sdk.NewCoins(
sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 10), sdk.NewInt64Coin(chaincfg.GasDenom, 10),
sdk.NewInt64Coin("busd", 100), sdk.NewInt64Coin("busd", 100),
), ),
sdkmath.NewInt(10_000_000_000_000), sdkmath.NewInt(10_000_000_000_000),
}, },
{ {
"no auxiliary denom or base denom", "no gas denom or evm denom",
sdk.NewCoins(), sdk.NewCoins(),
sdk.ZeroInt(), sdk.ZeroInt(),
}, },
{ {
"with avaka that is more than 1 auxiliary denom", "with avaka that is more than 1 gas denom",
sdk.NewCoins( sdk.NewCoins(
sdk.NewInt64Coin(chaincfg.BaseDenom, 20_000_000_000_220), sdk.NewInt64Coin(chaincfg.EvmDenom, 20_000_000_000_220),
sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 11), sdk.NewInt64Coin(chaincfg.GasDenom, 11),
), ),
sdkmath.NewInt(31_000_000_000_220), sdkmath.NewInt(31_000_000_000_220),
}, },
@ -116,7 +116,7 @@ func (suite *evmBankKeeperTestSuite) TestGetBalance() {
suite.SetupTest() suite.SetupTest()
suite.FundAccountWithZgChain(suite.Addrs[0], tt.startingAmount) suite.FundAccountWithZgChain(suite.Addrs[0], tt.startingAmount)
coin := suite.EvmBankKeeper.GetBalance(suite.Ctx, suite.Addrs[0], chaincfg.BaseDenom) coin := suite.EvmBankKeeper.GetBalance(suite.Ctx, suite.Addrs[0], chaincfg.EvmDenom)
suite.Require().Equal(tt.expAmount, coin.Amount) suite.Require().Equal(tt.expAmount, coin.Amount)
}) })
} }
@ -124,8 +124,8 @@ func (suite *evmBankKeeperTestSuite) TestGetBalance() {
func (suite *evmBankKeeperTestSuite) TestSendCoinsFromModuleToAccount() { func (suite *evmBankKeeperTestSuite) TestSendCoinsFromModuleToAccount() {
startingModuleCoins := sdk.NewCoins( startingModuleCoins := sdk.NewCoins(
sdk.NewInt64Coin(chaincfg.BaseDenom, 200), sdk.NewInt64Coin(chaincfg.EvmDenom, 200),
sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 100), sdk.NewInt64Coin(chaincfg.GasDenom, 100),
) )
tests := []struct { tests := []struct {
name string name string
@ -135,102 +135,102 @@ func (suite *evmBankKeeperTestSuite) TestSendCoinsFromModuleToAccount() {
hasErr bool hasErr bool
}{ }{
{ {
"send more than 1 auxiliary denom", "send more than 1 gas denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 12_000_000_000_010)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 12_000_000_000_010)),
sdk.Coins{}, sdk.Coins{},
sdk.NewCoins( sdk.NewCoins(
sdk.NewInt64Coin(chaincfg.BaseDenom, 10), sdk.NewInt64Coin(chaincfg.EvmDenom, 10),
sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 12), sdk.NewInt64Coin(chaincfg.GasDenom, 12),
), ),
false, false,
}, },
{ {
"send less than 1 auxiliary denom", "send less than 1 gas denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 122)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 122)),
sdk.Coins{}, sdk.Coins{},
sdk.NewCoins( sdk.NewCoins(
sdk.NewInt64Coin(chaincfg.BaseDenom, 122), sdk.NewInt64Coin(chaincfg.EvmDenom, 122),
sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 0), sdk.NewInt64Coin(chaincfg.GasDenom, 0),
), ),
false, false,
}, },
{ {
"send an exact amount of auxiliary denom", "send an exact amount of gas denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 98_000_000_000_000)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 98_000_000_000_000)),
sdk.Coins{}, sdk.Coins{},
sdk.NewCoins( sdk.NewCoins(
sdk.NewInt64Coin(chaincfg.BaseDenom, 0o0), sdk.NewInt64Coin(chaincfg.EvmDenom, 0o0),
sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 98), sdk.NewInt64Coin(chaincfg.GasDenom, 98),
), ),
false, false,
}, },
{ {
"send no base denom", "send no evm denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 0)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 0)),
sdk.Coins{}, sdk.Coins{},
sdk.NewCoins( sdk.NewCoins(
sdk.NewInt64Coin(chaincfg.BaseDenom, 0), sdk.NewInt64Coin(chaincfg.EvmDenom, 0),
sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 0), sdk.NewInt64Coin(chaincfg.GasDenom, 0),
), ),
false, false,
}, },
{ {
"errors if sending other coins", "errors if sending other coins",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 500), sdk.NewInt64Coin("busd", 1000)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 500), sdk.NewInt64Coin("busd", 1000)),
sdk.Coins{}, sdk.Coins{},
sdk.Coins{}, sdk.Coins{},
true, true,
}, },
{ {
"errors if not enough total base denom to cover", "errors if not enough total evm denom to cover",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 100_000_000_001_000)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 100_000_000_001_000)),
sdk.Coins{}, sdk.Coins{},
sdk.Coins{}, sdk.Coins{},
true, true,
}, },
{ {
"errors if not enough auxiliary denom to cover", "errors if not enough gas denom to cover",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 200_000_000_000_000)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 200_000_000_000_000)),
sdk.Coins{}, sdk.Coins{},
sdk.Coins{}, sdk.Coins{},
true, true,
}, },
{ {
"converts receiver's base denom to auxiliary denom if there's enough base denom after the transfer", "converts receiver's evm denom to gas denom if there's enough evm denom after the transfer",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 99_000_000_000_200)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 99_000_000_000_200)),
sdk.NewCoins( sdk.NewCoins(
sdk.NewInt64Coin(chaincfg.BaseDenom, 999_999_999_900), sdk.NewInt64Coin(chaincfg.EvmDenom, 999_999_999_900),
sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 1), sdk.NewInt64Coin(chaincfg.GasDenom, 1),
), ),
sdk.NewCoins( sdk.NewCoins(
sdk.NewInt64Coin(chaincfg.BaseDenom, 100), sdk.NewInt64Coin(chaincfg.EvmDenom, 100),
sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 101), sdk.NewInt64Coin(chaincfg.GasDenom, 101),
), ),
false, false,
}, },
{ {
"converts all of receiver's base denom to auxiliary denom even if somehow receiver has more than 1 auxiliary denom of base denom", "converts all of receiver's evm denom to gas denom even if somehow receiver has more than 1 gas denom of evm denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 12_000_000_000_100)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 12_000_000_000_100)),
sdk.NewCoins( sdk.NewCoins(
sdk.NewInt64Coin(chaincfg.BaseDenom, 5_999_999_999_990), sdk.NewInt64Coin(chaincfg.EvmDenom, 5_999_999_999_990),
sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 1), sdk.NewInt64Coin(chaincfg.GasDenom, 1),
), ),
sdk.NewCoins( sdk.NewCoins(
sdk.NewInt64Coin(chaincfg.BaseDenom, 90), sdk.NewInt64Coin(chaincfg.EvmDenom, 90),
sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 19), sdk.NewInt64Coin(chaincfg.GasDenom, 19),
), ),
false, false,
}, },
{ {
"swap 1 auxiliary denom for base denom if module account doesn't have enough base denom", "swap 1 gas denom for evm denom if module account doesn't have enough evm denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 99_000_000_001_000)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 99_000_000_001_000)),
sdk.NewCoins( sdk.NewCoins(
sdk.NewInt64Coin(chaincfg.BaseDenom, 200), sdk.NewInt64Coin(chaincfg.EvmDenom, 200),
sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 1), sdk.NewInt64Coin(chaincfg.GasDenom, 1),
), ),
sdk.NewCoins( sdk.NewCoins(
sdk.NewInt64Coin(chaincfg.BaseDenom, 1200), sdk.NewInt64Coin(chaincfg.EvmDenom, 1200),
sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 100), sdk.NewInt64Coin(chaincfg.GasDenom, 100),
), ),
false, false,
}, },
@ -243,8 +243,8 @@ func (suite *evmBankKeeperTestSuite) TestSendCoinsFromModuleToAccount() {
suite.FundAccountWithZgChain(suite.Addrs[0], tt.startingAccBal) suite.FundAccountWithZgChain(suite.Addrs[0], tt.startingAccBal)
suite.FundModuleAccountWithZgChain(evmtypes.ModuleName, startingModuleCoins) suite.FundModuleAccountWithZgChain(evmtypes.ModuleName, startingModuleCoins)
// fund our module with some auxiliary denom to account for converting extra base denom back to auxiliary denom // fund our module with some gas denom to account for converting extra evm denom back to gas denom
suite.FundModuleAccountWithZgChain(types.ModuleName, sdk.NewCoins(sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 10))) suite.FundModuleAccountWithZgChain(types.ModuleName, sdk.NewCoins(sdk.NewInt64Coin(chaincfg.GasDenom, 10)))
err := suite.EvmBankKeeper.SendCoinsFromModuleToAccount(suite.Ctx, evmtypes.ModuleName, suite.Addrs[0], tt.sendCoins) err := suite.EvmBankKeeper.SendCoinsFromModuleToAccount(suite.Ctx, evmtypes.ModuleName, suite.Addrs[0], tt.sendCoins)
if tt.hasErr { if tt.hasErr {
@ -254,24 +254,24 @@ func (suite *evmBankKeeperTestSuite) TestSendCoinsFromModuleToAccount() {
suite.Require().NoError(err) suite.Require().NoError(err)
} }
// check auxiliary denom // check gas denom
AuxiliaryDenomSender := suite.BankKeeper.GetBalance(suite.Ctx, suite.Addrs[0], chaincfg.AuxiliaryDenom) GasDenomSender := suite.BankKeeper.GetBalance(suite.Ctx, suite.Addrs[0], chaincfg.GasDenom)
suite.Require().Equal(tt.expAccBal.AmountOf(chaincfg.AuxiliaryDenom).Int64(), AuxiliaryDenomSender.Amount.Int64()) suite.Require().Equal(tt.expAccBal.AmountOf(chaincfg.GasDenom).Int64(), GasDenomSender.Amount.Int64())
// check base denom // check evm denom
actualBaseDenom := suite.Keeper.GetBalance(suite.Ctx, suite.Addrs[0]) actualEvmDenom := suite.Keeper.GetBalance(suite.Ctx, suite.Addrs[0])
suite.Require().Equal(tt.expAccBal.AmountOf(chaincfg.BaseDenom).Int64(), actualBaseDenom.Int64()) suite.Require().Equal(tt.expAccBal.AmountOf(chaincfg.EvmDenom).Int64(), actualEvmDenom.Int64())
}) })
} }
} }
func (suite *evmBankKeeperTestSuite) TestSendCoinsFromAccountToModule() { func (suite *evmBankKeeperTestSuite) TestSendCoinsFromAccountToModule() {
startingAccCoins := sdk.NewCoins( startingAccCoins := sdk.NewCoins(
sdk.NewInt64Coin(chaincfg.BaseDenom, 200), sdk.NewInt64Coin(chaincfg.EvmDenom, 200),
sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 100), sdk.NewInt64Coin(chaincfg.GasDenom, 100),
) )
startingModuleCoins := sdk.NewCoins( startingModuleCoins := sdk.NewCoins(
sdk.NewInt64Coin(chaincfg.BaseDenom, 100_000_000_000), sdk.NewInt64Coin(chaincfg.EvmDenom, 100_000_000_000),
) )
tests := []struct { tests := []struct {
name string name string
@ -281,36 +281,36 @@ func (suite *evmBankKeeperTestSuite) TestSendCoinsFromAccountToModule() {
hasErr bool hasErr bool
}{ }{
{ {
"send more than 1 auxiliary denom", "send more than 1 gas denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 12_000_000_000_010)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 12_000_000_000_010)),
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 190), sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 88)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 190), sdk.NewInt64Coin(chaincfg.GasDenom, 88)),
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 100_000_000_010), sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 12)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 100_000_000_010), sdk.NewInt64Coin(chaincfg.GasDenom, 12)),
false, false,
}, },
{ {
"send less than 1 auxiliary denom", "send less than 1 gas denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 122)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 122)),
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 78), sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 100)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 78), sdk.NewInt64Coin(chaincfg.GasDenom, 100)),
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 100_000_000_122), sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 0)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 100_000_000_122), sdk.NewInt64Coin(chaincfg.GasDenom, 0)),
false, false,
}, },
{ {
"send an exact amount of auxiliary denom", "send an exact amount of gas denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 98_000_000_000_000)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 98_000_000_000_000)),
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 200), sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 2)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 200), sdk.NewInt64Coin(chaincfg.GasDenom, 2)),
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 100_000_000_000), sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 98)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 100_000_000_000), sdk.NewInt64Coin(chaincfg.GasDenom, 98)),
false, false,
}, },
{ {
"send no base denom", "send no evm denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 0)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 0)),
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 200), sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 100)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 200), sdk.NewInt64Coin(chaincfg.GasDenom, 100)),
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 100_000_000_000), sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 0)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 100_000_000_000), sdk.NewInt64Coin(chaincfg.GasDenom, 0)),
false, false,
}, },
{ {
"errors if sending other coins", "errors if sending other coins",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 500), sdk.NewInt64Coin("busd", 1000)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 500), sdk.NewInt64Coin("busd", 1000)),
sdk.Coins{}, sdk.Coins{},
sdk.Coins{}, sdk.Coins{},
true, true,
@ -318,39 +318,39 @@ func (suite *evmBankKeeperTestSuite) TestSendCoinsFromAccountToModule() {
{ {
"errors if have dup coins", "errors if have dup coins",
sdk.Coins{ sdk.Coins{
sdk.NewInt64Coin(chaincfg.BaseDenom, 12_000_000_000_000), sdk.NewInt64Coin(chaincfg.EvmDenom, 12_000_000_000_000),
sdk.NewInt64Coin(chaincfg.BaseDenom, 2_000_000_000_000), sdk.NewInt64Coin(chaincfg.EvmDenom, 2_000_000_000_000),
}, },
sdk.Coins{}, sdk.Coins{},
sdk.Coins{}, sdk.Coins{},
true, true,
}, },
{ {
"errors if not enough total base denom to cover", "errors if not enough total evm denom to cover",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 100_000_000_001_000)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 100_000_000_001_000)),
sdk.Coins{}, sdk.Coins{},
sdk.Coins{}, sdk.Coins{},
true, true,
}, },
{ {
"errors if not enough auxiliary denom to cover", "errors if not enough gas denom to cover",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 200_000_000_000_000)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 200_000_000_000_000)),
sdk.Coins{}, sdk.Coins{},
sdk.Coins{}, sdk.Coins{},
true, true,
}, },
{ {
"converts 1 auxiliary denom to base denom if not enough base denom to cover", "converts 1 gas denom to evm denom if not enough evm denom to cover",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 99_001_000_000_000)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 99_001_000_000_000)),
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 999_000_000_200), sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 0)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 999_000_000_200), sdk.NewInt64Coin(chaincfg.GasDenom, 0)),
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 101_000_000_000), sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 99)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 101_000_000_000), sdk.NewInt64Coin(chaincfg.GasDenom, 99)),
false, false,
}, },
{ {
"converts receiver's base denom to auxiliary denom if there's enough base denom after the transfer", "converts receiver's evm denom to gas denom if there's enough evm denom after the transfer",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 5_900_000_000_200)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 5_900_000_000_200)),
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 100_000_000_000), sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 94)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 100_000_000_000), sdk.NewInt64Coin(chaincfg.GasDenom, 94)),
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 200), sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 6)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 200), sdk.NewInt64Coin(chaincfg.GasDenom, 6)),
false, false,
}, },
} }
@ -370,67 +370,67 @@ func (suite *evmBankKeeperTestSuite) TestSendCoinsFromAccountToModule() {
} }
// check sender balance // check sender balance
AuxiliaryDenomSender := suite.BankKeeper.GetBalance(suite.Ctx, suite.Addrs[0], chaincfg.AuxiliaryDenom) GasDenomSender := suite.BankKeeper.GetBalance(suite.Ctx, suite.Addrs[0], chaincfg.GasDenom)
suite.Require().Equal(tt.expSenderCoins.AmountOf(chaincfg.AuxiliaryDenom).Int64(), AuxiliaryDenomSender.Amount.Int64()) suite.Require().Equal(tt.expSenderCoins.AmountOf(chaincfg.GasDenom).Int64(), GasDenomSender.Amount.Int64())
actualBaseDenom := suite.Keeper.GetBalance(suite.Ctx, suite.Addrs[0]) actualEvmDenom := suite.Keeper.GetBalance(suite.Ctx, suite.Addrs[0])
suite.Require().Equal(tt.expSenderCoins.AmountOf(chaincfg.BaseDenom).Int64(), actualBaseDenom.Int64()) suite.Require().Equal(tt.expSenderCoins.AmountOf(chaincfg.EvmDenom).Int64(), actualEvmDenom.Int64())
// check module balance // check module balance
moduleAddr := suite.AccountKeeper.GetModuleAddress(evmtypes.ModuleName) moduleAddr := suite.AccountKeeper.GetModuleAddress(evmtypes.ModuleName)
AuxiliaryDenomSender = suite.BankKeeper.GetBalance(suite.Ctx, moduleAddr, chaincfg.AuxiliaryDenom) GasDenomSender = suite.BankKeeper.GetBalance(suite.Ctx, moduleAddr, chaincfg.GasDenom)
suite.Require().Equal(tt.expModuleCoins.AmountOf(chaincfg.AuxiliaryDenom).Int64(), AuxiliaryDenomSender.Amount.Int64()) suite.Require().Equal(tt.expModuleCoins.AmountOf(chaincfg.GasDenom).Int64(), GasDenomSender.Amount.Int64())
actualBaseDenom = suite.Keeper.GetBalance(suite.Ctx, moduleAddr) actualEvmDenom = suite.Keeper.GetBalance(suite.Ctx, moduleAddr)
suite.Require().Equal(tt.expModuleCoins.AmountOf(chaincfg.BaseDenom).Int64(), actualBaseDenom.Int64()) suite.Require().Equal(tt.expModuleCoins.AmountOf(chaincfg.EvmDenom).Int64(), actualEvmDenom.Int64())
}) })
} }
} }
func (suite *evmBankKeeperTestSuite) TestBurnCoins() { func (suite *evmBankKeeperTestSuite) TestBurnCoins() {
startingAuxiliaryDenom := sdkmath.NewInt(100) startingGasDenom := sdkmath.NewInt(100)
tests := []struct { tests := []struct {
name string name string
burnCoins sdk.Coins burnCoins sdk.Coins
expAuxiliaryDenom sdkmath.Int expGasDenom sdkmath.Int
expBaseDenom sdkmath.Int expEvmDenom sdkmath.Int
hasErr bool hasErr bool
baseDenomStart sdkmath.Int evmDenomStart sdkmath.Int
}{ }{
{ {
"burn more than 1 auxiliary denom", "burn more than 1 gas denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 12_021_000_000_002)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 12_021_000_000_002)),
sdkmath.NewInt(88), sdkmath.NewInt(88),
sdkmath.NewInt(100_000_000_000), sdkmath.NewInt(100_000_000_000),
false, false,
sdkmath.NewInt(121_000_000_002), sdkmath.NewInt(121_000_000_002),
}, },
{ {
"burn less than 1 auxiliary denom", "burn less than 1 gas denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 122)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 122)),
sdkmath.NewInt(100), sdkmath.NewInt(100),
sdkmath.NewInt(878), sdkmath.NewInt(878),
false, false,
sdkmath.NewInt(1000), sdkmath.NewInt(1000),
}, },
{ {
"burn an exact amount of auxiliary denom", "burn an exact amount of gas denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 98_000_000_000_000)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 98_000_000_000_000)),
sdkmath.NewInt(2), sdkmath.NewInt(2),
sdkmath.NewInt(10), sdkmath.NewInt(10),
false, false,
sdkmath.NewInt(10), sdkmath.NewInt(10),
}, },
{ {
"burn no base denom", "burn no evm denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 0)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 0)),
startingAuxiliaryDenom, startingGasDenom,
sdk.ZeroInt(), sdk.ZeroInt(),
false, false,
sdk.ZeroInt(), sdk.ZeroInt(),
}, },
{ {
"errors if burning other coins", "errors if burning other coins",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 500), sdk.NewInt64Coin("busd", 1000)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 500), sdk.NewInt64Coin("busd", 1000)),
startingAuxiliaryDenom, startingGasDenom,
sdkmath.NewInt(100), sdkmath.NewInt(100),
true, true,
sdkmath.NewInt(100), sdkmath.NewInt(100),
@ -438,41 +438,41 @@ func (suite *evmBankKeeperTestSuite) TestBurnCoins() {
{ {
"errors if have dup coins", "errors if have dup coins",
sdk.Coins{ sdk.Coins{
sdk.NewInt64Coin(chaincfg.BaseDenom, 12_000_000_000_000), sdk.NewInt64Coin(chaincfg.EvmDenom, 12_000_000_000_000),
sdk.NewInt64Coin(chaincfg.BaseDenom, 2_000_000_000_000), sdk.NewInt64Coin(chaincfg.EvmDenom, 2_000_000_000_000),
}, },
startingAuxiliaryDenom, startingGasDenom,
sdk.ZeroInt(), sdk.ZeroInt(),
true, true,
sdk.ZeroInt(), sdk.ZeroInt(),
}, },
{ {
"errors if burn amount is negative", "errors if burn amount is negative",
sdk.Coins{sdk.Coin{Denom: chaincfg.BaseDenom, Amount: sdkmath.NewInt(-100)}}, sdk.Coins{sdk.Coin{Denom: chaincfg.EvmDenom, Amount: sdkmath.NewInt(-100)}},
startingAuxiliaryDenom, startingGasDenom,
sdkmath.NewInt(50), sdkmath.NewInt(50),
true, true,
sdkmath.NewInt(50), sdkmath.NewInt(50),
}, },
{ {
"errors if not enough base denom to cover burn", "errors if not enough evm denom to cover burn",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 100_999_000_000_000)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 100_999_000_000_000)),
sdkmath.NewInt(0), sdkmath.NewInt(0),
sdkmath.NewInt(99_000_000_000), sdkmath.NewInt(99_000_000_000),
true, true,
sdkmath.NewInt(99_000_000_000), sdkmath.NewInt(99_000_000_000),
}, },
{ {
"errors if not enough auxiliary denom to cover burn", "errors if not enough gas denom to cover burn",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 200_000_000_000_000)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 200_000_000_000_000)),
sdkmath.NewInt(100), sdkmath.NewInt(100),
sdk.ZeroInt(), sdk.ZeroInt(),
true, true,
sdk.ZeroInt(), sdk.ZeroInt(),
}, },
{ {
"converts 1 auxiliary denom to base denom if not enough base denom to cover", "converts 1 gas denom to evm denom if not enough evm denom to cover",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 12_021_000_000_002)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 12_021_000_000_002)),
sdkmath.NewInt(87), sdkmath.NewInt(87),
sdkmath.NewInt(980_000_000_000), sdkmath.NewInt(980_000_000_000),
false, false,
@ -484,8 +484,8 @@ func (suite *evmBankKeeperTestSuite) TestBurnCoins() {
suite.Run(tt.name, func() { suite.Run(tt.name, func() {
suite.SetupTest() suite.SetupTest()
startingCoins := sdk.NewCoins( startingCoins := sdk.NewCoins(
sdk.NewCoin(chaincfg.AuxiliaryDenom, startingAuxiliaryDenom), sdk.NewCoin(chaincfg.GasDenom, startingGasDenom),
sdk.NewCoin(chaincfg.BaseDenom, tt.baseDenomStart), sdk.NewCoin(chaincfg.EvmDenom, tt.evmDenomStart),
) )
suite.FundModuleAccountWithZgChain(evmtypes.ModuleName, startingCoins) suite.FundModuleAccountWithZgChain(evmtypes.ModuleName, startingCoins)
@ -497,53 +497,53 @@ func (suite *evmBankKeeperTestSuite) TestBurnCoins() {
suite.Require().NoError(err) suite.Require().NoError(err)
} }
// check auxiliary denom // check gas denom
AuxiliaryDenomActual := suite.BankKeeper.GetBalance(suite.Ctx, suite.EvmModuleAddr, chaincfg.AuxiliaryDenom) GasDenomActual := suite.BankKeeper.GetBalance(suite.Ctx, suite.EvmModuleAddr, chaincfg.GasDenom)
suite.Require().Equal(tt.expAuxiliaryDenom, AuxiliaryDenomActual.Amount) suite.Require().Equal(tt.expGasDenom, GasDenomActual.Amount)
// check base denom // check evm denom
baseDenomActual := suite.Keeper.GetBalance(suite.Ctx, suite.EvmModuleAddr) evmDenomActual := suite.Keeper.GetBalance(suite.Ctx, suite.EvmModuleAddr)
suite.Require().Equal(tt.expBaseDenom, baseDenomActual) suite.Require().Equal(tt.expEvmDenom, evmDenomActual)
}) })
} }
} }
func (suite *evmBankKeeperTestSuite) TestMintCoins() { func (suite *evmBankKeeperTestSuite) TestMintCoins() {
tests := []struct { tests := []struct {
name string name string
mintCoins sdk.Coins mintCoins sdk.Coins
AuxiliaryDenomCnt sdkmath.Int GasDenomCnt sdkmath.Int
baseDenomCnt sdkmath.Int evmDenomCnt sdkmath.Int
hasErr bool hasErr bool
baseDenomStart sdkmath.Int evmDenomStart sdkmath.Int
}{ }{
{ {
"mint more than 1 auxiliary denom", "mint more than 1 gas denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 12_021_000_000_002)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 12_021_000_000_002)),
sdkmath.NewInt(12), sdkmath.NewInt(12),
sdkmath.NewInt(21_000_000_002), sdkmath.NewInt(21_000_000_002),
false, false,
sdk.ZeroInt(), sdk.ZeroInt(),
}, },
{ {
"mint less than 1 auxiliary denom", "mint less than 1 gas denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 901_000_000_001)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 901_000_000_001)),
sdk.ZeroInt(), sdk.ZeroInt(),
sdkmath.NewInt(901_000_000_001), sdkmath.NewInt(901_000_000_001),
false, false,
sdk.ZeroInt(), sdk.ZeroInt(),
}, },
{ {
"mint an exact amount of auxiliary denom", "mint an exact amount of gas denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 123_000_000_000_000_000)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 123_000_000_000_000_000)),
sdkmath.NewInt(123_000), sdkmath.NewInt(123_000),
sdk.ZeroInt(), sdk.ZeroInt(),
false, false,
sdk.ZeroInt(), sdk.ZeroInt(),
}, },
{ {
"mint no base denom", "mint no evm denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 0)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 0)),
sdk.ZeroInt(), sdk.ZeroInt(),
sdk.ZeroInt(), sdk.ZeroInt(),
false, false,
@ -551,7 +551,7 @@ func (suite *evmBankKeeperTestSuite) TestMintCoins() {
}, },
{ {
"errors if minting other coins", "errors if minting other coins",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 500), sdk.NewInt64Coin("busd", 1000)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 500), sdk.NewInt64Coin("busd", 1000)),
sdk.ZeroInt(), sdk.ZeroInt(),
sdkmath.NewInt(100), sdkmath.NewInt(100),
true, true,
@ -560,8 +560,8 @@ func (suite *evmBankKeeperTestSuite) TestMintCoins() {
{ {
"errors if have dup coins", "errors if have dup coins",
sdk.Coins{ sdk.Coins{
sdk.NewInt64Coin(chaincfg.BaseDenom, 12_000_000_000_000), sdk.NewInt64Coin(chaincfg.EvmDenom, 12_000_000_000_000),
sdk.NewInt64Coin(chaincfg.BaseDenom, 2_000_000_000_000), sdk.NewInt64Coin(chaincfg.EvmDenom, 2_000_000_000_000),
}, },
sdk.ZeroInt(), sdk.ZeroInt(),
sdk.ZeroInt(), sdk.ZeroInt(),
@ -570,23 +570,23 @@ func (suite *evmBankKeeperTestSuite) TestMintCoins() {
}, },
{ {
"errors if mint amount is negative", "errors if mint amount is negative",
sdk.Coins{sdk.Coin{Denom: chaincfg.BaseDenom, Amount: sdkmath.NewInt(-100)}}, sdk.Coins{sdk.Coin{Denom: chaincfg.EvmDenom, Amount: sdkmath.NewInt(-100)}},
sdk.ZeroInt(), sdk.ZeroInt(),
sdkmath.NewInt(50), sdkmath.NewInt(50),
true, true,
sdkmath.NewInt(50), sdkmath.NewInt(50),
}, },
{ {
"adds to existing base denom balance", "adds to existing evm denom balance",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 12_021_000_000_002)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 12_021_000_000_002)),
sdkmath.NewInt(12), sdkmath.NewInt(12),
sdkmath.NewInt(21_000_000_102), sdkmath.NewInt(21_000_000_102),
false, false,
sdkmath.NewInt(100), sdkmath.NewInt(100),
}, },
{ {
"convert base denom balance to auxiliary denom if it exceeds 1 auxiliary denom", "convert evm denom balance to gas denom if it exceeds 1 gas denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 10_999_000_000_000)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 10_999_000_000_000)),
sdkmath.NewInt(12), sdkmath.NewInt(12),
sdkmath.NewInt(1_200_000_001), sdkmath.NewInt(1_200_000_001),
false, false,
@ -597,8 +597,8 @@ func (suite *evmBankKeeperTestSuite) TestMintCoins() {
for _, tt := range tests { for _, tt := range tests {
suite.Run(tt.name, func() { suite.Run(tt.name, func() {
suite.SetupTest() suite.SetupTest()
suite.FundModuleAccountWithZgChain(types.ModuleName, sdk.NewCoins(sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 10))) suite.FundModuleAccountWithZgChain(types.ModuleName, sdk.NewCoins(sdk.NewInt64Coin(chaincfg.GasDenom, 10)))
suite.FundModuleAccountWithZgChain(evmtypes.ModuleName, sdk.NewCoins(sdk.NewCoin(chaincfg.BaseDenom, tt.baseDenomStart))) suite.FundModuleAccountWithZgChain(evmtypes.ModuleName, sdk.NewCoins(sdk.NewCoin(chaincfg.EvmDenom, tt.evmDenomStart)))
err := suite.EvmBankKeeper.MintCoins(suite.Ctx, evmtypes.ModuleName, tt.mintCoins) err := suite.EvmBankKeeper.MintCoins(suite.Ctx, evmtypes.ModuleName, tt.mintCoins)
if tt.hasErr { if tt.hasErr {
@ -608,13 +608,13 @@ func (suite *evmBankKeeperTestSuite) TestMintCoins() {
suite.Require().NoError(err) suite.Require().NoError(err)
} }
// check auxiliary denom // check gas denom
AuxiliaryDenomActual := suite.BankKeeper.GetBalance(suite.Ctx, suite.EvmModuleAddr, chaincfg.AuxiliaryDenom) GasDenomActual := suite.BankKeeper.GetBalance(suite.Ctx, suite.EvmModuleAddr, chaincfg.GasDenom)
suite.Require().Equal(tt.AuxiliaryDenomCnt, AuxiliaryDenomActual.Amount) suite.Require().Equal(tt.GasDenomCnt, GasDenomActual.Amount)
// check base denom // check evm denom
baseDenomActual := suite.Keeper.GetBalance(suite.Ctx, suite.EvmModuleAddr) evmDenomActual := suite.Keeper.GetBalance(suite.Ctx, suite.EvmModuleAddr)
suite.Require().Equal(tt.baseDenomCnt, baseDenomActual) suite.Require().Equal(tt.evmDenomCnt, evmDenomActual)
}) })
} }
} }
@ -627,22 +627,22 @@ func (suite *evmBankKeeperTestSuite) TestValidateEvmCoins() {
}{ }{
{ {
"valid coins", "valid coins",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 500)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 500)),
false, false,
}, },
{ {
"dup coins", "dup coins",
sdk.Coins{sdk.NewInt64Coin(chaincfg.BaseDenom, 500), sdk.NewInt64Coin(chaincfg.BaseDenom, 500)}, sdk.Coins{sdk.NewInt64Coin(chaincfg.EvmDenom, 500), sdk.NewInt64Coin(chaincfg.EvmDenom, 500)},
true, true,
}, },
{ {
"not evm coins", "not evm coins",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 500)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.GasDenom, 500)),
true, true,
}, },
{ {
"negative coins", "negative coins",
sdk.Coins{sdk.Coin{Denom: chaincfg.BaseDenom, Amount: sdkmath.NewInt(-500)}}, sdk.Coins{sdk.Coin{Denom: chaincfg.EvmDenom, Amount: sdkmath.NewInt(-500)}},
true, true,
}, },
} }
@ -658,8 +658,8 @@ func (suite *evmBankKeeperTestSuite) TestValidateEvmCoins() {
} }
} }
func (suite *evmBankKeeperTestSuite) TestConvertOneAuxiliaryDenomToBaseDenomIfNeeded() { func (suite *evmBankKeeperTestSuite) TestConvertOneGasDenomToEvmDenomIfNeeded() {
baseDenomNeeded := sdkmath.NewInt(200) evmDenomNeeded := sdkmath.NewInt(200)
tests := []struct { tests := []struct {
name string name string
startingCoins sdk.Coins startingCoins sdk.Coins
@ -667,21 +667,21 @@ func (suite *evmBankKeeperTestSuite) TestConvertOneAuxiliaryDenomToBaseDenomIfNe
success bool success bool
}{ }{
{ {
"not enough auxiliary denom for conversion", "not enough gas denom for conversion",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 100)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 100)),
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 100)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 100)),
false, false,
}, },
{ {
"converts 1 auxiliary denom to base denom", "converts 1 gas denom to evm denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 10), sdk.NewInt64Coin(chaincfg.BaseDenom, 100)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.GasDenom, 10), sdk.NewInt64Coin(chaincfg.EvmDenom, 100)),
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 9), sdk.NewInt64Coin(chaincfg.BaseDenom, 1_000_000_000_100)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.GasDenom, 9), sdk.NewInt64Coin(chaincfg.EvmDenom, 1_000_000_000_100)),
true, true,
}, },
{ {
"conversion not needed", "conversion not needed",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 10), sdk.NewInt64Coin(chaincfg.BaseDenom, 200)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.GasDenom, 10), sdk.NewInt64Coin(chaincfg.EvmDenom, 200)),
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 10), sdk.NewInt64Coin(chaincfg.BaseDenom, 200)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.GasDenom, 10), sdk.NewInt64Coin(chaincfg.EvmDenom, 200)),
true, true,
}, },
} }
@ -690,11 +690,11 @@ func (suite *evmBankKeeperTestSuite) TestConvertOneAuxiliaryDenomToBaseDenomIfNe
suite.SetupTest() suite.SetupTest()
suite.FundAccountWithZgChain(suite.Addrs[0], tt.startingCoins) suite.FundAccountWithZgChain(suite.Addrs[0], tt.startingCoins)
err := suite.EvmBankKeeper.ConvertOneAuxiliaryDenomToBaseDenomIfNeeded(suite.Ctx, suite.Addrs[0], baseDenomNeeded) err := suite.EvmBankKeeper.ConvertOneGasDenomToEvmDenomIfNeeded(suite.Ctx, suite.Addrs[0], evmDenomNeeded)
moduleZgChain := suite.BankKeeper.GetBalance(suite.Ctx, suite.AccountKeeper.GetModuleAddress(types.ModuleName), chaincfg.AuxiliaryDenom) moduleZgChain := suite.BankKeeper.GetBalance(suite.Ctx, suite.AccountKeeper.GetModuleAddress(types.ModuleName), chaincfg.GasDenom)
if tt.success { if tt.success {
suite.Require().NoError(err) suite.Require().NoError(err)
if tt.startingCoins.AmountOf(chaincfg.BaseDenom).LT(baseDenomNeeded) { if tt.startingCoins.AmountOf(chaincfg.EvmDenom).LT(evmDenomNeeded) {
suite.Require().Equal(sdk.OneInt(), moduleZgChain.Amount) suite.Require().Equal(sdk.OneInt(), moduleZgChain.Amount)
} }
} else { } else {
@ -702,54 +702,54 @@ func (suite *evmBankKeeperTestSuite) TestConvertOneAuxiliaryDenomToBaseDenomIfNe
suite.Require().Equal(sdk.ZeroInt(), moduleZgChain.Amount) suite.Require().Equal(sdk.ZeroInt(), moduleZgChain.Amount)
} }
baseDenomCnt := suite.Keeper.GetBalance(suite.Ctx, suite.Addrs[0]) evmDenomCnt := suite.Keeper.GetBalance(suite.Ctx, suite.Addrs[0])
suite.Require().Equal(tt.expectedCoins.AmountOf(chaincfg.BaseDenom), baseDenomCnt) suite.Require().Equal(tt.expectedCoins.AmountOf(chaincfg.EvmDenom), evmDenomCnt)
AuxiliaryDenomCoin := suite.BankKeeper.GetBalance(suite.Ctx, suite.Addrs[0], chaincfg.AuxiliaryDenom) GasDenomCoin := suite.BankKeeper.GetBalance(suite.Ctx, suite.Addrs[0], chaincfg.GasDenom)
suite.Require().Equal(tt.expectedCoins.AmountOf(chaincfg.AuxiliaryDenom), AuxiliaryDenomCoin.Amount) suite.Require().Equal(tt.expectedCoins.AmountOf(chaincfg.GasDenom), GasDenomCoin.Amount)
}) })
} }
} }
func (suite *evmBankKeeperTestSuite) TestConvertBaseDenomToAuxiliaryDenom() { func (suite *evmBankKeeperTestSuite) TestConvertEvmDenomToGasDenom() {
tests := []struct { tests := []struct {
name string name string
startingCoins sdk.Coins startingCoins sdk.Coins
expectedCoins sdk.Coins expectedCoins sdk.Coins
}{ }{
{ {
"not enough auxiliary denom", "not enough gas denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 100)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 100)),
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 100), sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 0)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 100), sdk.NewInt64Coin(chaincfg.GasDenom, 0)),
}, },
{ {
"converts base denom for 1 auxiliary denom", "converts evm denom for 1 gas denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 10), sdk.NewInt64Coin(chaincfg.BaseDenom, 1_000_000_000_003)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.GasDenom, 10), sdk.NewInt64Coin(chaincfg.EvmDenom, 1_000_000_000_003)),
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 11), sdk.NewInt64Coin(chaincfg.BaseDenom, 3)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.GasDenom, 11), sdk.NewInt64Coin(chaincfg.EvmDenom, 3)),
}, },
{ {
"converts more than 1 auxiliary denom of base denom", "converts more than 1 gas denom of evm denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 10), sdk.NewInt64Coin(chaincfg.BaseDenom, 8_000_000_000_123)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.GasDenom, 10), sdk.NewInt64Coin(chaincfg.EvmDenom, 8_000_000_000_123)),
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 18), sdk.NewInt64Coin(chaincfg.BaseDenom, 123)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.GasDenom, 18), sdk.NewInt64Coin(chaincfg.EvmDenom, 123)),
}, },
} }
for _, tt := range tests { for _, tt := range tests {
suite.Run(tt.name, func() { suite.Run(tt.name, func() {
suite.SetupTest() suite.SetupTest()
err := suite.App.FundModuleAccount(suite.Ctx, types.ModuleName, sdk.NewCoins(sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 10))) err := suite.App.FundModuleAccount(suite.Ctx, types.ModuleName, sdk.NewCoins(sdk.NewInt64Coin(chaincfg.GasDenom, 10)))
suite.Require().NoError(err) suite.Require().NoError(err)
suite.FundAccountWithZgChain(suite.Addrs[0], tt.startingCoins) suite.FundAccountWithZgChain(suite.Addrs[0], tt.startingCoins)
err = suite.EvmBankKeeper.ConvertBaseDenomToAuxiliaryDenom(suite.Ctx, suite.Addrs[0]) err = suite.EvmBankKeeper.ConvertEvmDenomToGasDenom(suite.Ctx, suite.Addrs[0])
suite.Require().NoError(err) suite.Require().NoError(err)
baseDenomCnt := suite.Keeper.GetBalance(suite.Ctx, suite.Addrs[0]) evmDenomCnt := suite.Keeper.GetBalance(suite.Ctx, suite.Addrs[0])
suite.Require().Equal(tt.expectedCoins.AmountOf(chaincfg.BaseDenom), baseDenomCnt) suite.Require().Equal(tt.expectedCoins.AmountOf(chaincfg.EvmDenom), evmDenomCnt)
AuxiliaryDenomCoin := suite.BankKeeper.GetBalance(suite.Ctx, suite.Addrs[0], chaincfg.AuxiliaryDenom) GasDenomCoin := suite.BankKeeper.GetBalance(suite.Ctx, suite.Addrs[0], chaincfg.GasDenom)
suite.Require().Equal(tt.expectedCoins.AmountOf(chaincfg.AuxiliaryDenom), AuxiliaryDenomCoin.Amount) suite.Require().Equal(tt.expectedCoins.AmountOf(chaincfg.GasDenom), GasDenomCoin.Amount)
}) })
} }
} }
func (suite *evmBankKeeperTestSuite) TestSplitBaseDenomCoins() { func (suite *evmBankKeeperTestSuite) TestSplitEvmDenomCoins() {
tests := []struct { tests := []struct {
name string name string
coins sdk.Coins coins sdk.Coins
@ -758,7 +758,7 @@ func (suite *evmBankKeeperTestSuite) TestSplitBaseDenomCoins() {
}{ }{
{ {
"invalid coins", "invalid coins",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 500)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.GasDenom, 500)),
nil, nil,
true, true,
}, },
@ -769,33 +769,33 @@ func (suite *evmBankKeeperTestSuite) TestSplitBaseDenomCoins() {
false, false,
}, },
{ {
"auxiliary denom & base denom coins", "gas denom & evm denom coins",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 8_000_000_000_123)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 8_000_000_000_123)),
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 8), sdk.NewInt64Coin(chaincfg.BaseDenom, 123)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.GasDenom, 8), sdk.NewInt64Coin(chaincfg.EvmDenom, 123)),
false, false,
}, },
{ {
"only base denom", "only evm denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 10_123)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 10_123)),
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 10_123)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 10_123)),
false, false,
}, },
{ {
"only auxiliary denom", "only gas denom",
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.BaseDenom, 5_000_000_000_000)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.EvmDenom, 5_000_000_000_000)),
sdk.NewCoins(sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 5)), sdk.NewCoins(sdk.NewInt64Coin(chaincfg.GasDenom, 5)),
false, false,
}, },
} }
for _, tt := range tests { for _, tt := range tests {
suite.Run(tt.name, func() { suite.Run(tt.name, func() {
AuxiliaryDenomCoin, baseDenomCnt, err := keeper.SplitBaseDenomCoins(tt.coins) GasDenomCoin, evmDenomCnt, err := keeper.SplitEvmDenomCoins(tt.coins)
if tt.shouldErr { if tt.shouldErr {
suite.Require().Error(err) suite.Require().Error(err)
} else { } else {
suite.Require().NoError(err) suite.Require().NoError(err)
suite.Require().Equal(tt.expectedCoins.AmountOf(chaincfg.AuxiliaryDenom), AuxiliaryDenomCoin.Amount) suite.Require().Equal(tt.expectedCoins.AmountOf(chaincfg.GasDenom), GasDenomCoin.Amount)
suite.Require().Equal(tt.expectedCoins.AmountOf(chaincfg.BaseDenom), baseDenomCnt) suite.Require().Equal(tt.expectedCoins.AmountOf(chaincfg.EvmDenom), evmDenomCnt)
} }
}) })
} }

View File

@ -51,7 +51,7 @@ func FullyBackedInvariant(bankK types.BankKeeper, k Keeper) sdk.Invariant {
}) })
bankAddr := authtypes.NewModuleAddress(types.ModuleName) bankAddr := authtypes.NewModuleAddress(types.ModuleName)
bankBalance := bankK.GetBalance(ctx, bankAddr, chaincfg.AuxiliaryDenom).Amount.Mul(ConversionMultiplier) bankBalance := bankK.GetBalance(ctx, bankAddr, chaincfg.GasDenom).Amount.Mul(ConversionMultiplier)
broken = totalMinorBalances.GT(bankBalance) broken = totalMinorBalances.GT(bankBalance)

View File

@ -50,7 +50,7 @@ func (suite *invariantTestSuite) SetupValidState() {
suite.FundModuleAccountWithZgChain( suite.FundModuleAccountWithZgChain(
types.ModuleName, types.ModuleName,
sdk.NewCoins( sdk.NewCoins(
sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(2)), // ( sum of all minor balances ) / conversion multiplier sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(2)), // ( sum of all minor balances ) / conversion multiplier
), ),
) )
@ -160,8 +160,8 @@ func (suite *invariantTestSuite) TestSmallBalances() {
// increase minor balance at least above conversion multiplier // increase minor balance at least above conversion multiplier
suite.Keeper.AddBalance(suite.Ctx, suite.Addrs[0], keeper.ConversionMultiplier) suite.Keeper.AddBalance(suite.Ctx, suite.Addrs[0], keeper.ConversionMultiplier)
// add same number of auxiliary denom to avoid breaking other invariants // add same number of gas denom to avoid breaking other invariants
amt := sdk.NewCoins(sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 1)) amt := sdk.NewCoins(sdk.NewInt64Coin(chaincfg.GasDenom, 1))
suite.Require().NoError( suite.Require().NoError(
suite.App.FundModuleAccount(suite.Ctx, types.ModuleName, amt), suite.App.FundModuleAccount(suite.Ctx, types.ModuleName, amt),
) )

View File

@ -115,7 +115,7 @@ func (k Keeper) SetAccount(ctx sdk.Context, account types.Account) error {
return nil return nil
} }
// GetBalance returns the total balance of base denom for a given account by address. // GetBalance returns the total balance of evm denom for a given account by address.
func (k Keeper) GetBalance(ctx sdk.Context, addr sdk.AccAddress) sdkmath.Int { func (k Keeper) GetBalance(ctx sdk.Context, addr sdk.AccAddress) sdkmath.Int {
account := k.GetAccount(ctx, addr) account := k.GetAccount(ctx, addr)
if account == nil { if account == nil {
@ -124,7 +124,7 @@ func (k Keeper) GetBalance(ctx sdk.Context, addr sdk.AccAddress) sdkmath.Int {
return account.Balance return account.Balance
} }
// SetBalance sets the total balance of base denom for a given account by address. // SetBalance sets the total balance of evm denom for a given account by address.
func (k Keeper) SetBalance(ctx sdk.Context, addr sdk.AccAddress, bal sdkmath.Int) error { func (k Keeper) SetBalance(ctx sdk.Context, addr sdk.AccAddress, bal sdkmath.Int) error {
account := k.GetAccount(ctx, addr) account := k.GetAccount(ctx, addr)
if account == nil { if account == nil {
@ -140,10 +140,10 @@ func (k Keeper) SetBalance(ctx sdk.Context, addr sdk.AccAddress, bal sdkmath.Int
return k.SetAccount(ctx, *account) return k.SetAccount(ctx, *account)
} }
// SendBalance transfers the base denom balance from sender addr to recipient addr. // SendBalance transfers the evm denom balance from sender addr to recipient addr.
func (k Keeper) SendBalance(ctx sdk.Context, senderAddr sdk.AccAddress, recipientAddr sdk.AccAddress, amt sdkmath.Int) error { func (k Keeper) SendBalance(ctx sdk.Context, senderAddr sdk.AccAddress, recipientAddr sdk.AccAddress, amt sdkmath.Int) error {
if amt.IsNegative() { if amt.IsNegative() {
return fmt.Errorf("cannot send a negative amount of base denom: %d", amt) return fmt.Errorf("cannot send a negative amount of evm denom: %d", amt)
} }
if amt.IsZero() { if amt.IsZero() {
@ -162,13 +162,13 @@ func (k Keeper) SendBalance(ctx sdk.Context, senderAddr sdk.AccAddress, recipien
return k.SetBalance(ctx, recipientAddr, receiverBal) return k.SetBalance(ctx, recipientAddr, receiverBal)
} }
// AddBalance increments the base denom balance of an address. // AddBalance increments the evm denom balance of an address.
func (k Keeper) AddBalance(ctx sdk.Context, addr sdk.AccAddress, amt sdkmath.Int) error { func (k Keeper) AddBalance(ctx sdk.Context, addr sdk.AccAddress, amt sdkmath.Int) error {
bal := k.GetBalance(ctx, addr) bal := k.GetBalance(ctx, addr)
return k.SetBalance(ctx, addr, amt.Add(bal)) return k.SetBalance(ctx, addr, amt.Add(bal))
} }
// RemoveBalance decrements the base denom balance of an address. // RemoveBalance decrements the evm denom balance of an address.
func (k Keeper) RemoveBalance(ctx sdk.Context, addr sdk.AccAddress, amt sdkmath.Int) error { func (k Keeper) RemoveBalance(ctx sdk.Context, addr sdk.AccAddress, amt sdkmath.Int) error {
if amt.IsNegative() { if amt.IsNegative() {
return fmt.Errorf("cannot remove a negative amount from balance: %d", amt) return fmt.Errorf("cannot remove a negative amount from balance: %d", amt)

View File

@ -82,14 +82,14 @@ func (suite *Suite) SetupTest() {
suite.Addrs = addrs suite.Addrs = addrs
evmGenesis := evmtypes.DefaultGenesisState() evmGenesis := evmtypes.DefaultGenesisState()
evmGenesis.Params.EvmDenom = chaincfg.BaseDenom evmGenesis.Params.EvmDenom = chaincfg.EvmDenom
feemarketGenesis := feemarkettypes.DefaultGenesisState() feemarketGenesis := feemarkettypes.DefaultGenesisState()
feemarketGenesis.Params.EnableHeight = 1 feemarketGenesis.Params.EnableHeight = 1
feemarketGenesis.Params.NoBaseFee = false feemarketGenesis.Params.NoBaseFee = false
cdc := suite.App.AppCodec() cdc := suite.App.AppCodec()
coins := sdk.NewCoins(sdk.NewInt64Coin(chaincfg.AuxiliaryDenom, 1000_000_000_000_000_000)) coins := sdk.NewCoins(sdk.NewInt64Coin(chaincfg.GasDenom, 1000_000_000_000_000_000))
authGS := app.NewFundedGenStateWithSameCoins(cdc, coins, []sdk.AccAddress{ authGS := app.NewFundedGenStateWithSameCoins(cdc, coins, []sdk.AccAddress{
sdk.AccAddress(suite.Key1.PubKey().Address()), sdk.AccAddress(suite.Key1.PubKey().Address()),
sdk.AccAddress(suite.Key2.PubKey().Address()), sdk.AccAddress(suite.Key2.PubKey().Address()),
@ -186,28 +186,28 @@ func (suite *Suite) ModuleBalance(denom string) sdk.Int {
} }
func (suite *Suite) FundAccountWithZgChain(addr sdk.AccAddress, coins sdk.Coins) { func (suite *Suite) FundAccountWithZgChain(addr sdk.AccAddress, coins sdk.Coins) {
AuxiliaryDenomAmt := coins.AmountOf(chaincfg.AuxiliaryDenom) GasDenomAmt := coins.AmountOf(chaincfg.GasDenom)
if AuxiliaryDenomAmt.IsPositive() { if GasDenomAmt.IsPositive() {
err := suite.App.FundAccount(suite.Ctx, addr, sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, AuxiliaryDenomAmt))) err := suite.App.FundAccount(suite.Ctx, addr, sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, GasDenomAmt)))
suite.Require().NoError(err) suite.Require().NoError(err)
} }
baseDenomAmt := coins.AmountOf(chaincfg.BaseDenom) evmDenomAmt := coins.AmountOf(chaincfg.EvmDenom)
if baseDenomAmt.IsPositive() { if evmDenomAmt.IsPositive() {
err := suite.Keeper.SetBalance(suite.Ctx, addr, baseDenomAmt) err := suite.Keeper.SetBalance(suite.Ctx, addr, evmDenomAmt)
suite.Require().NoError(err) suite.Require().NoError(err)
} }
} }
func (suite *Suite) FundModuleAccountWithZgChain(moduleName string, coins sdk.Coins) { func (suite *Suite) FundModuleAccountWithZgChain(moduleName string, coins sdk.Coins) {
AuxiliaryDenomAmt := coins.AmountOf(chaincfg.AuxiliaryDenom) GasDenomAmt := coins.AmountOf(chaincfg.GasDenom)
if AuxiliaryDenomAmt.IsPositive() { if GasDenomAmt.IsPositive() {
err := suite.App.FundModuleAccount(suite.Ctx, moduleName, sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, AuxiliaryDenomAmt))) err := suite.App.FundModuleAccount(suite.Ctx, moduleName, sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, GasDenomAmt)))
suite.Require().NoError(err) suite.Require().NoError(err)
} }
baseDenomAmt := coins.AmountOf(chaincfg.BaseDenom) evmDenomAmt := coins.AmountOf(chaincfg.EvmDenom)
if baseDenomAmt.IsPositive() { if evmDenomAmt.IsPositive() {
addr := suite.AccountKeeper.GetModuleAddress(moduleName) addr := suite.AccountKeeper.GetModuleAddress(moduleName)
err := suite.Keeper.SetBalance(suite.Ctx, addr, baseDenomAmt) err := suite.Keeper.SetBalance(suite.Ctx, addr, evmDenomAmt)
suite.Require().NoError(err) suite.Require().NoError(err)
} }
} }
@ -218,7 +218,7 @@ func (suite *Suite) DeployERC20() types.InternalEVMAddress {
suite.App.FundModuleAccount( suite.App.FundModuleAccount(
suite.Ctx, suite.Ctx,
types.ModuleName, types.ModuleName,
sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, sdkmath.NewInt(0))), sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, sdkmath.NewInt(0))),
) )
contractAddr, err := suite.Keeper.DeployTestMintableERC20Contract(suite.Ctx, "USDC", "USDC", uint8(18)) contractAddr, err := suite.Keeper.DeployTestMintableERC20Contract(suite.Ctx, "USDC", "USDC", uint8(18))
@ -319,7 +319,7 @@ func (suite *Suite) SendTx(
// Mint the max gas to the FeeCollector to ensure balance in case of refund // Mint the max gas to the FeeCollector to ensure balance in case of refund
suite.MintFeeCollector(sdk.NewCoins( suite.MintFeeCollector(sdk.NewCoins(
sdk.NewCoin( sdk.NewCoin(
chaincfg.AuxiliaryDenom, chaincfg.GasDenom,
sdkmath.NewInt(baseFee.Int64()*int64(gasRes.Gas*2)), sdkmath.NewInt(baseFee.Int64()*int64(gasRes.Gas*2)),
))) )))

View File

@ -143,7 +143,7 @@ func TestConversionPairs_Validate(t *testing.T) {
), ),
types.NewConversionPair( types.NewConversionPair(
testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000A"), testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000A"),
chaincfg.AuxiliaryDenom, chaincfg.GasDenom,
), ),
types.NewConversionPair( types.NewConversionPair(
testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000B"), testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000B"),
@ -163,7 +163,7 @@ func TestConversionPairs_Validate(t *testing.T) {
), ),
types.NewConversionPair( types.NewConversionPair(
testutil.MustNewInternalEVMAddressFromString("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"), testutil.MustNewInternalEVMAddressFromString("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),
chaincfg.AuxiliaryDenom, chaincfg.GasDenom,
), ),
types.NewConversionPair( types.NewConversionPair(
testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000B"), testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000B"),
@ -184,16 +184,16 @@ func TestConversionPairs_Validate(t *testing.T) {
), ),
types.NewConversionPair( types.NewConversionPair(
testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000A"), testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000A"),
chaincfg.AuxiliaryDenom, chaincfg.GasDenom,
), ),
types.NewConversionPair( types.NewConversionPair(
testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000B"), testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000B"),
chaincfg.AuxiliaryDenom, chaincfg.GasDenom,
), ),
), ),
errArgs{ errArgs{
expectPass: false, expectPass: false,
contains: "found duplicate enabled conversion pair denom " + chaincfg.AuxiliaryDenom, contains: "found duplicate enabled conversion pair denom " + chaincfg.GasDenom,
}, },
}, },
{ {
@ -209,7 +209,7 @@ func TestConversionPairs_Validate(t *testing.T) {
), ),
types.NewConversionPair( types.NewConversionPair(
testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000B"), testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000B"),
chaincfg.AuxiliaryDenom, chaincfg.GasDenom,
), ),
), ),
errArgs{ errArgs{

View File

@ -107,11 +107,11 @@ func (suite *ParamsTestSuite) TestParams_Validate() {
invalidConversionPairs := types.NewConversionPairs( invalidConversionPairs := types.NewConversionPairs(
types.NewConversionPair( types.NewConversionPair(
testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000A"), testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000A"),
chaincfg.AuxiliaryDenom, chaincfg.GasDenom,
), ),
types.NewConversionPair( types.NewConversionPair(
testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000B"), testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000B"),
chaincfg.AuxiliaryDenom, // duplicate denom! chaincfg.GasDenom, // duplicate denom!
), ),
) )
validAllowedCosmosDenoms := types.NewAllowedCosmosCoinERC20Tokens( validAllowedCosmosDenoms := types.NewAllowedCosmosCoinERC20Tokens(

View File

@ -10,7 +10,7 @@ import (
func TestRawPriceKey_Iteration(t *testing.T) { func TestRawPriceKey_Iteration(t *testing.T) {
// An iterator key should only match price keys with the same market // An iterator key should only match price keys with the same market
iteratorKey := RawPriceIteratorKey(chaincfg.AuxiliaryDenom + ":usd") iteratorKey := RawPriceIteratorKey(chaincfg.GasDenom + ":usd")
addr := sdk.AccAddress("test addr") addr := sdk.AccAddress("test addr")
@ -21,12 +21,12 @@ func TestRawPriceKey_Iteration(t *testing.T) {
}{ }{
{ {
name: "equal marketID is included in iteration", name: "equal marketID is included in iteration",
priceKey: RawPriceKey(chaincfg.AuxiliaryDenom+":usd", addr), priceKey: RawPriceKey(chaincfg.GasDenom+":usd", addr),
expectErr: false, expectErr: false,
}, },
{ {
name: "prefix overlapping marketID excluded from iteration", name: "prefix overlapping marketID excluded from iteration",
priceKey: RawPriceKey(chaincfg.AuxiliaryDenom+":usd:30", addr), priceKey: RawPriceKey(chaincfg.GasDenom+":usd:30", addr),
expectErr: true, expectErr: true,
}, },
} }