mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-24 15:25:18 +00:00
rename denoms
This commit is contained in:
parent
85059d734e
commit
56d337df16
2
Makefile
2
Makefile
@ -78,7 +78,7 @@ print-machine-info:
|
||||
BUILD_DIR := build# build files
|
||||
BIN_DIR := $(BUILD_DIR)/bin# for binary dev dependencies
|
||||
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
|
||||
export PATH := $(ROOT_DIR)/$(BIN_DIR):$(PATH)# add local bin first in path
|
||||
|
@ -62,11 +62,11 @@ func (suite *SimulateRequestTestSuite) TestSimulateRequest() {
|
||||
bank.MsgSend{
|
||||
FromAddress: fromAddr,
|
||||
ToAddress: toAddr,
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(1e6)),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e6)),
|
||||
},
|
||||
},
|
||||
Fee: auth.StdFee{
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(5e4)),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(5e4)),
|
||||
Gas: 1e6,
|
||||
},
|
||||
Memo: "test memo",
|
||||
|
@ -68,7 +68,7 @@ func TestAppAnteHandler_AuthorizedMempool(t *testing.T) {
|
||||
chainID,
|
||||
app.NewFundedGenStateWithSameCoins(
|
||||
tApp.AppCodec(),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(1e9)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e9)),
|
||||
testAddresses,
|
||||
),
|
||||
newBep3GenStateMulti(tApp.AppCodec(), deputy),
|
||||
@ -116,7 +116,7 @@ func TestAppAnteHandler_AuthorizedMempool(t *testing.T) {
|
||||
banktypes.NewMsgSend(
|
||||
tc.address,
|
||||
testAddresses[0],
|
||||
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(1_000_000)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1_000_000)),
|
||||
),
|
||||
},
|
||||
sdk.NewCoins(), // no fee
|
||||
|
@ -46,7 +46,7 @@ func TestAuthenticatedMempoolDecorator_AnteHandle_NotCheckTx(t *testing.T) {
|
||||
banktypes.NewMsgSend(
|
||||
testAddresses[0],
|
||||
testAddresses[1],
|
||||
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(100_000_000)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100_000_000)),
|
||||
),
|
||||
},
|
||||
sdk.NewCoins(), // no fee
|
||||
@ -81,12 +81,12 @@ func TestAuthenticatedMempoolDecorator_AnteHandle_Pass(t *testing.T) {
|
||||
banktypes.NewMsgSend(
|
||||
testAddresses[0],
|
||||
testAddresses[1],
|
||||
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(100)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
|
||||
),
|
||||
banktypes.NewMsgSend(
|
||||
testAddresses[2],
|
||||
testAddresses[1],
|
||||
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(100)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
|
||||
),
|
||||
},
|
||||
sdk.NewCoins(), // no fee
|
||||
@ -122,7 +122,7 @@ func TestAuthenticatedMempoolDecorator_AnteHandle_Reject(t *testing.T) {
|
||||
banktypes.NewMsgSend(
|
||||
testAddresses[0],
|
||||
testAddresses[1],
|
||||
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(100)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
|
||||
),
|
||||
},
|
||||
sdk.NewCoins(), // no fee
|
||||
|
@ -59,7 +59,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
|
||||
banktypes.NewMsgSend(
|
||||
testAddresses[0],
|
||||
testAddresses[1],
|
||||
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(100e6)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100e6)),
|
||||
),
|
||||
},
|
||||
checkTx: false,
|
||||
@ -129,7 +129,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
|
||||
[]sdk.Msg{banktypes.NewMsgSend(
|
||||
testAddresses[0],
|
||||
testAddresses[3],
|
||||
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(100e6)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100e6)),
|
||||
)}),
|
||||
},
|
||||
checkTx: false,
|
||||
@ -162,7 +162,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
|
||||
banktypes.NewMsgSend(
|
||||
testAddresses[0],
|
||||
testAddresses[3],
|
||||
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(100e6)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100e6)),
|
||||
),
|
||||
&evmtypes.MsgEthereumTx{},
|
||||
},
|
||||
|
@ -157,7 +157,7 @@ func (suite *EIP712TestSuite) SetupTest() {
|
||||
// Genesis states
|
||||
evmGs := evmtypes.NewGenesisState(
|
||||
evmtypes.NewParams(
|
||||
chaincfg.BaseDenom, // evmDenom
|
||||
chaincfg.EvmDenom, // evmDenom
|
||||
false, // allowedUnprotectedTxs
|
||||
true, // enableCreate
|
||||
true, // enableCall
|
||||
@ -224,10 +224,10 @@ func (suite *EIP712TestSuite) SetupTest() {
|
||||
pricefeedtypes.ModuleName: cdc.MustMarshalJSON(&pricefeedGenState),
|
||||
}
|
||||
|
||||
// funds our test accounts with some auxiliary denom
|
||||
// funds our test accounts with some gas denom
|
||||
coinsGenState := app.NewFundedGenStateWithSameCoins(
|
||||
tApp.AppCodec(),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(1e9)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e9)),
|
||||
[]sdk.AccAddress{suite.testAddr, suite.testAddr2},
|
||||
)
|
||||
|
||||
@ -377,7 +377,7 @@ func (suite *EIP712TestSuite) deployUSDCERC20(app app.TestApp, ctx sdk.Context)
|
||||
suite.tApp.FundModuleAccount(
|
||||
suite.ctx,
|
||||
evmutiltypes.ModuleName,
|
||||
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(0)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(0)),
|
||||
)
|
||||
|
||||
contractAddr, err := suite.evmutilKeeper.DeployTestMintableERC20Contract(suite.ctx, "USDC", "USDC", uint8(18))
|
||||
@ -477,7 +477,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
|
||||
errMsg: "insufficient funds",
|
||||
updateTx: func(txBuilder client.TxBuilder, msgs []sdk.Msg) client.TxBuilder {
|
||||
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))
|
||||
return txBuilder
|
||||
},
|
||||
@ -489,7 +489,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
|
||||
failCheckTx: true,
|
||||
errMsg: "invalid chain-id",
|
||||
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(
|
||||
suite.testAddr, suite.testPrivKey, "kavatest_12-1", uint64(sims.DefaultGenTxGas*10), gasAmt, msgs,
|
||||
)
|
||||
@ -502,7 +502,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
|
||||
failCheckTx: true,
|
||||
errMsg: "invalid pubkey",
|
||||
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(
|
||||
suite.testAddr2, suite.testPrivKey2, ChainID, uint64(sims.DefaultGenTxGas*10), gasAmt, msgs,
|
||||
)
|
||||
@ -530,7 +530,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
|
||||
msgs = tc.updateMsgs(msgs)
|
||||
}
|
||||
|
||||
gasAmt := sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(20))
|
||||
gasAmt := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(20))
|
||||
txBuilder := suite.createTestEIP712CosmosTxBuilder(
|
||||
suite.testAddr, suite.testPrivKey, ChainID, uint64(sims.DefaultGenTxGas*10), gasAmt, msgs,
|
||||
)
|
||||
@ -604,7 +604,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx_DepositAndWithdraw() {
|
||||
}
|
||||
|
||||
// deliver deposit msg
|
||||
gasAmt := sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(20))
|
||||
gasAmt := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(20))
|
||||
txBuilder := suite.createTestEIP712CosmosTxBuilder(
|
||||
suite.testAddr, suite.testPrivKey, ChainID, uint64(sims.DefaultGenTxGas*10), gasAmt, depositMsgs,
|
||||
)
|
||||
|
@ -31,7 +31,7 @@ func TestEvmMinGasFilter(t *testing.T) {
|
||||
|
||||
ctx := tApp.NewContext(true, tmproto.Header{Height: 1, Time: tmtime.Now()})
|
||||
tApp.GetEvmKeeper().SetParams(ctx, evmtypes.Params{
|
||||
EvmDenom: chaincfg.BaseDenom,
|
||||
EvmDenom: chaincfg.EvmDenom,
|
||||
})
|
||||
|
||||
testCases := []struct {
|
||||
|
@ -34,7 +34,7 @@ func TestVestingMempoolDecorator_MsgCreateVestingAccount_Unauthorized(t *testing
|
||||
"MsgCreateVestingAccount",
|
||||
vesting.NewMsgCreateVestingAccount(
|
||||
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(),
|
||||
false,
|
||||
),
|
||||
@ -45,7 +45,7 @@ func TestVestingMempoolDecorator_MsgCreateVestingAccount_Unauthorized(t *testing
|
||||
"MsgCreateVestingAccount",
|
||||
vesting.NewMsgCreatePermanentLockedAccount(
|
||||
testAddresses[0], testAddresses[1],
|
||||
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(100)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
|
||||
),
|
||||
true,
|
||||
"MsgTypeURL /cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccount not supported",
|
||||
@ -64,7 +64,7 @@ func TestVestingMempoolDecorator_MsgCreateVestingAccount_Unauthorized(t *testing
|
||||
"other messages not affected",
|
||||
banktypes.NewMsgSend(
|
||||
testAddresses[0], testAddresses[1],
|
||||
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(100)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
|
||||
),
|
||||
false,
|
||||
"",
|
||||
|
@ -159,7 +159,7 @@ func GenesisStateWithSingleValidator(
|
||||
balances := []banktypes.Balance{
|
||||
{
|
||||
Address: acc.GetAddress().String(),
|
||||
Coins: sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(100000000000000)),
|
||||
Coins: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100000000000000)),
|
||||
},
|
||||
}
|
||||
|
||||
@ -222,7 +222,7 @@ func genesisStateWithValSet(
|
||||
}
|
||||
// set validators and delegations
|
||||
currentStakingGenesis := stakingtypes.GetGenesisStateFromAppState(app.appCodec, genesisState)
|
||||
currentStakingGenesis.Params.BondDenom = chaincfg.AuxiliaryDenom // TODO:
|
||||
currentStakingGenesis.Params.BondDenom = chaincfg.GasDenom // TODO:
|
||||
|
||||
stakingGenesis := stakingtypes.NewGenesisState(
|
||||
currentStakingGenesis.Params,
|
||||
@ -242,13 +242,13 @@ func genesisStateWithValSet(
|
||||
|
||||
for range delegations {
|
||||
// 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
|
||||
balances = append(balances, banktypes.Balance{
|
||||
Address: authtypes.NewModuleAddress(stakingtypes.BondedPoolName).String(),
|
||||
Coins: sdk.Coins{chaincfg.MakeCoinForAuxiliaryDenom(bondAmt)},
|
||||
Coins: sdk.Coins{chaincfg.MakeCoinForGasDenom(bondAmt)},
|
||||
})
|
||||
|
||||
bankGenesis := banktypes.NewGenesisState(
|
||||
|
@ -44,12 +44,12 @@ func MakeCoinForStandardDenom(amount any) sdk.Coin {
|
||||
return makeCoin(StandardDenom, toBigInt(amount))
|
||||
}
|
||||
|
||||
func MakeCoinForAuxiliaryDenom(amount any) sdk.Coin {
|
||||
return makeCoin(AuxiliaryDenom, toBigInt(amount))
|
||||
func MakeCoinForGasDenom(amount any) sdk.Coin {
|
||||
return makeCoin(GasDenom, toBigInt(amount))
|
||||
}
|
||||
|
||||
func MakeCoinForBaseDenom(amount any) sdk.Coin {
|
||||
return makeCoin(BaseDenom, toBigInt(amount))
|
||||
func MakeCoinForEvmDenom(amount any) sdk.Coin {
|
||||
return makeCoin(EvmDenom, toBigInt(amount))
|
||||
}
|
||||
|
||||
func makeCoin(denom string, amount *big.Int) sdk.Coin {
|
||||
|
@ -7,31 +7,31 @@ import (
|
||||
const (
|
||||
StandardDenom = "a0gi"
|
||||
|
||||
AuxiliaryDenom = "ua0gi"
|
||||
GasDenom = "ua0gi"
|
||||
|
||||
BaseDenom = "neuron"
|
||||
EvmDenom = "neuron"
|
||||
|
||||
BondDenom = BaseDenom
|
||||
BondDenom = EvmDenom
|
||||
|
||||
AuxiliaryDenomUnit = 6
|
||||
GasDenomUnit = 6
|
||||
|
||||
BaseDenomUnit = 18
|
||||
EvmDenomUnit = 18
|
||||
|
||||
AuxiliaryDenomConversionMultiplier = 1e12
|
||||
BaseDenomConversionMultiplier = 1e18
|
||||
GasDenomConversionMultiplier = 1e12
|
||||
EvmDenomConversionMultiplier = 1e18
|
||||
)
|
||||
|
||||
// RegisterDenoms registers the base and auxiliary denominations to the SDK.
|
||||
// RegisterDenoms registers the base and gas denominations to the SDK.
|
||||
func RegisterDenoms() {
|
||||
if err := sdk.RegisterDenom(StandardDenom, sdk.OneDec()); err != nil {
|
||||
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)
|
||||
}
|
||||
|
||||
if err := sdk.RegisterDenom(BaseDenom, sdk.NewDecWithPrec(1, BaseDenomUnit)); err != nil {
|
||||
if err := sdk.RegisterDenom(EvmDenom, sdk.NewDecWithPrec(1, EvmDenomUnit)); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
@ -17,15 +17,15 @@ func TestRegisterDenoms(t *testing.T) {
|
||||
expErr error
|
||||
}{
|
||||
{
|
||||
"standard to auxiliary",
|
||||
"standard to gas",
|
||||
MakeCoinForStandardDenom(99),
|
||||
AuxiliaryDenom,
|
||||
MakeCoinForAuxiliaryDenom(99 * (BaseDenomConversionMultiplier / AuxiliaryDenomConversionMultiplier)),
|
||||
GasDenom,
|
||||
MakeCoinForGasDenom(99 * (EvmDenomConversionMultiplier / GasDenomConversionMultiplier)),
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"auxiliary to standard",
|
||||
MakeCoinForAuxiliaryDenom(5e7),
|
||||
"gas to standard",
|
||||
MakeCoinForGasDenom(5e7),
|
||||
StandardDenom,
|
||||
MakeCoinForStandardDenom(50),
|
||||
nil,
|
||||
@ -33,29 +33,29 @@ func TestRegisterDenoms(t *testing.T) {
|
||||
{
|
||||
"standard to base",
|
||||
MakeCoinForStandardDenom(22),
|
||||
BaseDenom,
|
||||
MakeCoinForBaseDenom(22 * BaseDenomConversionMultiplier),
|
||||
EvmDenom,
|
||||
MakeCoinForEvmDenom(22 * EvmDenomConversionMultiplier),
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"base to standard",
|
||||
MakeCoinForBaseDenom("97000000000000000000"),
|
||||
MakeCoinForEvmDenom("97000000000000000000"),
|
||||
StandardDenom,
|
||||
MakeCoinForStandardDenom(97),
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"auxiliary to base",
|
||||
MakeCoinForAuxiliaryDenom(33),
|
||||
BaseDenom,
|
||||
MakeCoinForBaseDenom(33 * AuxiliaryDenomConversionMultiplier),
|
||||
"gas to base",
|
||||
MakeCoinForGasDenom(33),
|
||||
EvmDenom,
|
||||
MakeCoinForEvmDenom(33 * GasDenomConversionMultiplier),
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"base to auxiliary",
|
||||
MakeCoinForBaseDenom("770000000000000"),
|
||||
AuxiliaryDenom,
|
||||
MakeCoinForAuxiliaryDenom(770000000000000 / AuxiliaryDenomConversionMultiplier),
|
||||
"base to gas",
|
||||
MakeCoinForEvmDenom("770000000000000"),
|
||||
GasDenom,
|
||||
MakeCoinForGasDenom(770000000000000 / GasDenomConversionMultiplier),
|
||||
nil,
|
||||
},
|
||||
}
|
||||
|
@ -3580,7 +3580,7 @@ paths:
|
||||
base:
|
||||
type: string
|
||||
description: >-
|
||||
base represents the base denom (should be the DenomUnit
|
||||
base represents the evm denom (should be the DenomUnit
|
||||
with exponent = 0).
|
||||
display:
|
||||
type: string
|
||||
@ -3787,7 +3787,7 @@ paths:
|
||||
base:
|
||||
type: string
|
||||
description: >-
|
||||
base represents the base denom (should be the DenomUnit
|
||||
base represents the evm denom (should be the DenomUnit
|
||||
with exponent = 0).
|
||||
display:
|
||||
type: string
|
||||
@ -38218,7 +38218,7 @@ definitions:
|
||||
base:
|
||||
type: string
|
||||
description: >-
|
||||
base represents the base denom (should be the DenomUnit with exponent
|
||||
base represents the evm denom (should be the DenomUnit with exponent
|
||||
= 0).
|
||||
display:
|
||||
type: string
|
||||
@ -38397,7 +38397,7 @@ definitions:
|
||||
base:
|
||||
type: string
|
||||
description: >-
|
||||
base represents the base denom (should be the DenomUnit with
|
||||
base represents the evm denom (should be the DenomUnit with
|
||||
exponent = 0).
|
||||
display:
|
||||
type: string
|
||||
@ -38553,7 +38553,7 @@ definitions:
|
||||
base:
|
||||
type: string
|
||||
description: >-
|
||||
base represents the base denom (should be the DenomUnit with
|
||||
base represents the evm denom (should be the DenomUnit with
|
||||
exponent = 0).
|
||||
display:
|
||||
type: string
|
||||
|
@ -129,9 +129,9 @@ paths:
|
||||
source of the fungible token.
|
||||
base_denom:
|
||||
type: string
|
||||
description: base denomination of the relayed fungible token.
|
||||
description: evm denomination of the relayed fungible token.
|
||||
description: >-
|
||||
DenomTrace contains the base denomination for ICS20 fungible
|
||||
DenomTrace contains the evm denomination for ICS20 fungible
|
||||
tokens and the
|
||||
|
||||
source tracing information path.
|
||||
@ -263,9 +263,9 @@ paths:
|
||||
source of the fungible token.
|
||||
base_denom:
|
||||
type: string
|
||||
description: base denomination of the relayed fungible token.
|
||||
description: evm denomination of the relayed fungible token.
|
||||
description: >-
|
||||
DenomTrace contains the base denomination for ICS20 fungible
|
||||
DenomTrace contains the evm denomination for ICS20 fungible
|
||||
tokens and the
|
||||
|
||||
source tracing information path.
|
||||
@ -13640,9 +13640,9 @@ definitions:
|
||||
source of the fungible token.
|
||||
base_denom:
|
||||
type: string
|
||||
description: base denomination of the relayed fungible token.
|
||||
description: evm denomination of the relayed fungible token.
|
||||
description: >-
|
||||
DenomTrace contains the base denomination for ICS20 fungible tokens and
|
||||
DenomTrace contains the evm denomination for ICS20 fungible tokens and
|
||||
the
|
||||
|
||||
source tracing information path.
|
||||
@ -13696,9 +13696,9 @@ definitions:
|
||||
source of the fungible token.
|
||||
base_denom:
|
||||
type: string
|
||||
description: base denomination of the relayed fungible token.
|
||||
description: evm denomination of the relayed fungible token.
|
||||
description: >-
|
||||
DenomTrace contains the base denomination for ICS20 fungible tokens
|
||||
DenomTrace contains the evm denomination for ICS20 fungible tokens
|
||||
and the
|
||||
|
||||
source tracing information path.
|
||||
@ -13722,9 +13722,9 @@ definitions:
|
||||
source of the fungible token.
|
||||
base_denom:
|
||||
type: string
|
||||
description: base denomination of the relayed fungible token.
|
||||
description: evm denomination of the relayed fungible token.
|
||||
description: >-
|
||||
DenomTrace contains the base denomination for ICS20 fungible tokens
|
||||
DenomTrace contains the evm denomination for ICS20 fungible tokens
|
||||
and the
|
||||
|
||||
source tracing information path.
|
||||
|
@ -16950,7 +16950,7 @@ paths:
|
||||
base:
|
||||
type: string
|
||||
description: >-
|
||||
base represents the base denom (should be the DenomUnit
|
||||
base represents the evm denom (should be the DenomUnit
|
||||
with exponent = 0).
|
||||
display:
|
||||
type: string
|
||||
@ -17157,7 +17157,7 @@ paths:
|
||||
base:
|
||||
type: string
|
||||
description: >-
|
||||
base represents the base denom (should be the DenomUnit
|
||||
base represents the evm denom (should be the DenomUnit
|
||||
with exponent = 0).
|
||||
display:
|
||||
type: string
|
||||
@ -41557,9 +41557,9 @@ paths:
|
||||
source of the fungible token.
|
||||
base_denom:
|
||||
type: string
|
||||
description: base denomination of the relayed fungible token.
|
||||
description: evm denomination of the relayed fungible token.
|
||||
description: >-
|
||||
DenomTrace contains the base denomination for ICS20 fungible
|
||||
DenomTrace contains the evm denomination for ICS20 fungible
|
||||
tokens and the
|
||||
|
||||
source tracing information path.
|
||||
@ -41691,9 +41691,9 @@ paths:
|
||||
source of the fungible token.
|
||||
base_denom:
|
||||
type: string
|
||||
description: base denomination of the relayed fungible token.
|
||||
description: evm denomination of the relayed fungible token.
|
||||
description: >-
|
||||
DenomTrace contains the base denomination for ICS20 fungible
|
||||
DenomTrace contains the evm denomination for ICS20 fungible
|
||||
tokens and the
|
||||
|
||||
source tracing information path.
|
||||
@ -64035,7 +64035,7 @@ definitions:
|
||||
base:
|
||||
type: string
|
||||
description: >-
|
||||
base represents the base denom (should be the DenomUnit with exponent
|
||||
base represents the evm denom (should be the DenomUnit with exponent
|
||||
= 0).
|
||||
display:
|
||||
type: string
|
||||
@ -64214,7 +64214,7 @@ definitions:
|
||||
base:
|
||||
type: string
|
||||
description: >-
|
||||
base represents the base denom (should be the DenomUnit with
|
||||
base represents the evm denom (should be the DenomUnit with
|
||||
exponent = 0).
|
||||
display:
|
||||
type: string
|
||||
@ -64370,7 +64370,7 @@ definitions:
|
||||
base:
|
||||
type: string
|
||||
description: >-
|
||||
base represents the base denom (should be the DenomUnit with
|
||||
base represents the evm denom (should be the DenomUnit with
|
||||
exponent = 0).
|
||||
display:
|
||||
type: string
|
||||
@ -87953,9 +87953,9 @@ definitions:
|
||||
source of the fungible token.
|
||||
base_denom:
|
||||
type: string
|
||||
description: base denomination of the relayed fungible token.
|
||||
description: evm denomination of the relayed fungible token.
|
||||
description: >-
|
||||
DenomTrace contains the base denomination for ICS20 fungible tokens and
|
||||
DenomTrace contains the evm denomination for ICS20 fungible tokens and
|
||||
the
|
||||
|
||||
source tracing information path.
|
||||
@ -88009,9 +88009,9 @@ definitions:
|
||||
source of the fungible token.
|
||||
base_denom:
|
||||
type: string
|
||||
description: base denomination of the relayed fungible token.
|
||||
description: evm denomination of the relayed fungible token.
|
||||
description: >-
|
||||
DenomTrace contains the base denomination for ICS20 fungible tokens
|
||||
DenomTrace contains the evm denomination for ICS20 fungible tokens
|
||||
and the
|
||||
|
||||
source tracing information path.
|
||||
@ -88035,9 +88035,9 @@ definitions:
|
||||
source of the fungible token.
|
||||
base_denom:
|
||||
type: string
|
||||
description: base denomination of the relayed fungible token.
|
||||
description: evm denomination of the relayed fungible token.
|
||||
description: >-
|
||||
DenomTrace contains the base denomination for ICS20 fungible tokens
|
||||
DenomTrace contains the evm denomination for ICS20 fungible tokens
|
||||
and the
|
||||
|
||||
source tracing information path.
|
||||
|
@ -76,7 +76,7 @@ func NewRootCmd() *cobra.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
customAppTemplate, customAppConfig := servercfg.AppConfig(chaincfg.AuxiliaryDenom)
|
||||
customAppTemplate, customAppConfig := servercfg.AppConfig(chaincfg.GasDenom)
|
||||
|
||||
return server.InterceptConfigsPreRunHandler(
|
||||
cmd,
|
||||
@ -139,7 +139,7 @@ func addSubCmds(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, de
|
||||
ac.addStartCmdFlags,
|
||||
)
|
||||
|
||||
// add keybase, auxiliary RPC, query, and tx child commands
|
||||
// add keybase, gas RPC, query, and tx child commands
|
||||
rootCmd.AddCommand(
|
||||
newQueryCmd(),
|
||||
newTxCmd(),
|
||||
|
@ -24,7 +24,7 @@ DATA=~/.0gchain
|
||||
# remove any old state and config
|
||||
rm -rf $DATA
|
||||
|
||||
BINARY=0gchaind
|
||||
BINARY=./.build/0gchaind
|
||||
|
||||
# Create new data directory, overwriting any that alread existed
|
||||
chainID="zgchain_8888-1"
|
||||
|
@ -42,7 +42,7 @@ func TestResetPeriodVestingAccount_NoVestingPeriods(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
|
||||
|
||||
periods := vestingtypes.Periods{
|
||||
@ -65,7 +65,7 @@ func TestResetPeriodVestingAccount_SingleVestingPeriod_Vested(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
|
||||
|
||||
periods := vestingtypes.Periods{
|
||||
@ -98,7 +98,7 @@ func TestResetPeriodVestingAccount_SingleVestingPeriod_Vesting(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
|
||||
|
||||
periods := vestingtypes.Periods{
|
||||
@ -126,25 +126,25 @@ func TestResetPeriodVestingAccount_SingleVestingPeriod_ExactStartTime(t *testing
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
periods := vestingtypes.Periods{
|
||||
vestingtypes.Period{
|
||||
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{
|
||||
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{
|
||||
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{
|
||||
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{
|
||||
{
|
||||
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
|
||||
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, expectedEndtime, vacc.EndTime, "expected vesting end time end at last period")
|
||||
assert.Equal(t, expectedPeriods, vacc.VestingPeriods, "expected vesting periods to be updated")
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
periods := vestingtypes.Periods{
|
||||
vestingtypes.Period{
|
||||
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{
|
||||
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{
|
||||
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)
|
||||
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.AuxiliaryDenom, sdkmath.NewInt(1e6))), vacc.DelegatedVesting, "expected delegated vesting 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.GasDenom, sdkmath.NewInt(1e6))), vacc.DelegatedVesting, "expected delegated vesting to be updated")
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
periods := vestingtypes.Periods{
|
||||
vestingtypes.Period{
|
||||
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{
|
||||
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{
|
||||
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.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)
|
||||
ResetPeriodicVestingAccount(vacc, newVestingStartTime)
|
||||
|
||||
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")
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ func (suite *IntegrationTestSuite) setupAccountWithCosmosCoinERC20Balance(
|
||||
tx := util.ZgChainMsgRequest{
|
||||
Msgs: []sdk.Msg{&msg},
|
||||
GasLimit: 4e5,
|
||||
FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(400)),
|
||||
FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(400)),
|
||||
Data: "converting sdk coin to erc20",
|
||||
}
|
||||
res := user.SignAndBroadcastZgChainTx(tx)
|
||||
@ -103,7 +103,7 @@ func (suite *IntegrationTestSuite) TestConvertCosmosCoinsToFromERC20() {
|
||||
tx := util.ZgChainMsgRequest{
|
||||
Msgs: []sdk.Msg{&convertToErc20Msg},
|
||||
GasLimit: 2e6,
|
||||
FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(2000)),
|
||||
FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(2000)),
|
||||
Data: "converting sdk coin to erc20",
|
||||
}
|
||||
res := user.SignAndBroadcastZgChainTx(tx)
|
||||
@ -145,7 +145,7 @@ func (suite *IntegrationTestSuite) TestConvertCosmosCoinsToFromERC20() {
|
||||
tx = util.ZgChainMsgRequest{
|
||||
Msgs: []sdk.Msg{&convertFromErc20Msg},
|
||||
GasLimit: 2e5,
|
||||
FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(200)),
|
||||
FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(200)),
|
||||
Data: "converting erc20 to cosmos coin",
|
||||
}
|
||||
res = user.SignAndBroadcastZgChainTx(tx)
|
||||
@ -184,7 +184,7 @@ func (suite *IntegrationTestSuite) TestEIP712ConvertCosmosCoinsToFromERC20() {
|
||||
user,
|
||||
suite.ZgChain,
|
||||
2e6,
|
||||
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(1e4)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e4)),
|
||||
[]sdk.Msg{&convertToErc20Msg},
|
||||
"this is a memo",
|
||||
).GetTx()
|
||||
@ -238,7 +238,7 @@ func (suite *IntegrationTestSuite) TestEIP712ConvertCosmosCoinsToFromERC20() {
|
||||
user,
|
||||
suite.ZgChain,
|
||||
2e5,
|
||||
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(200)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(200)),
|
||||
[]sdk.Msg{&convertFromErc20Msg},
|
||||
"",
|
||||
).GetTx()
|
||||
@ -332,7 +332,7 @@ func (suite *IntegrationTestSuite) TestConvertCosmosCoins_ERC20Magic() {
|
||||
"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)
|
||||
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{
|
||||
Msgs: []sdk.Msg{&convertMsg},
|
||||
GasLimit: 2e5,
|
||||
FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(200)),
|
||||
FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(200)),
|
||||
Data: "bob converts his new erc20 to an sdk.Coin",
|
||||
}
|
||||
convertRes := bob.SignAndBroadcastZgChainTx(convertTx)
|
||||
|
@ -20,7 +20,7 @@ func (suite *IntegrationTestSuite) TestEthCallToGreeterContract() {
|
||||
// this test manipulates state of the Greeter contract which means other tests shouldn't use it.
|
||||
|
||||
// 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"]
|
||||
contract, err := greeter.NewGreeter(greeterAddr, suite.ZgChain.EvmClient)
|
||||
@ -63,12 +63,12 @@ func (suite *IntegrationTestSuite) TestEthCallToErc20() {
|
||||
|
||||
func (suite *IntegrationTestSuite) TestEip712BasicMessageAuthorization() {
|
||||
// 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()
|
||||
|
||||
// setup message for sending some auxiliary denom to random receiver
|
||||
// setup message for sending some gas denom to random receiver
|
||||
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
|
||||
@ -76,7 +76,7 @@ func (suite *IntegrationTestSuite) TestEip712BasicMessageAuthorization() {
|
||||
sender,
|
||||
suite.ZgChain,
|
||||
1e6,
|
||||
sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(1e4)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e4)),
|
||||
msgs,
|
||||
"this is a memo",
|
||||
).GetTx()
|
||||
@ -95,10 +95,10 @@ func (suite *IntegrationTestSuite) TestEip712BasicMessageAuthorization() {
|
||||
_, err = util.WaitForSdkTxCommit(suite.ZgChain.Tx, res.TxResponse.TxHash, 6*time.Second)
|
||||
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{
|
||||
Address: receiver.String(),
|
||||
Denom: chaincfg.AuxiliaryDenom,
|
||||
Denom: chaincfg.GasDenom,
|
||||
})
|
||||
suite.NoError(err)
|
||||
suite.Equal(sdk.NewInt(1e3), balRes.Balance.Amount)
|
||||
@ -113,7 +113,7 @@ func (suite *IntegrationTestSuite) TestEip712BasicMessageAuthorization() {
|
||||
// sdkDenom := suite.DeployedErc20.CosmosDenom
|
||||
|
||||
// // 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
|
||||
// fundRes := suite.FundZgChainErc20Balance(depositor.EvmAddress, amount.BigInt())
|
||||
// suite.NoError(fundRes.Err)
|
||||
@ -143,7 +143,7 @@ func (suite *IntegrationTestSuite) TestEip712BasicMessageAuthorization() {
|
||||
// depositor,
|
||||
// suite.ZgChain,
|
||||
// 1e6,
|
||||
// sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(1e4)),
|
||||
// sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e4)),
|
||||
// msgs,
|
||||
// "doing the USDT Earn workflow! erc20 -> sdk.Coin -> USDX hard deposit",
|
||||
// ).GetTx()
|
||||
@ -189,7 +189,7 @@ func (suite *IntegrationTestSuite) TestEip712BasicMessageAuthorization() {
|
||||
// withdrawAndConvertBack := util.ZgChainMsgRequest{
|
||||
// Msgs: []sdk.Msg{&withdraw, &convertBack},
|
||||
// GasLimit: 1e6,
|
||||
// FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForAuxiliaryDenom(1000)),
|
||||
// FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1000)),
|
||||
// Data: "withdrawing from mint & converting back to erc20",
|
||||
// }
|
||||
// lastRes := depositor.SignAndBroadcastZgChainTx(withdrawAndConvertBack)
|
||||
|
@ -24,10 +24,10 @@ func (suite *IntegrationTestSuite) TestEthGasPriceReturnsMinFee() {
|
||||
minGasPrices, err := getMinFeeFromAppToml(util.ZgChainHomePath())
|
||||
suite.NoError(err)
|
||||
|
||||
// evm uses base denom, get base denom min fee
|
||||
evmMinGas := minGasPrices.AmountOf(chaincfg.BaseDenom).TruncateInt().BigInt()
|
||||
// evm uses evm denom, get evm denom min fee
|
||||
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())
|
||||
suite.NoError(err)
|
||||
|
||||
@ -38,13 +38,13 @@ func (suite *IntegrationTestSuite) TestEvmRespectsMinFee() {
|
||||
suite.SkipIfKvtoolDisabled()
|
||||
|
||||
// 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())
|
||||
|
||||
// get min gas price for evm (from app.toml)
|
||||
minFees, err := getMinFeeFromAppToml(util.ZgChainHomePath())
|
||||
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)
|
||||
tooLowGasPrice := minGasPrice.Sub(sdk.OneInt()).BigInt()
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
minEvmGasPrice = big.NewInt(1e10) // base denom
|
||||
minEvmGasPrice = big.NewInt(1e10) // evm denom
|
||||
)
|
||||
|
||||
type IntegrationTestSuite struct {
|
||||
@ -54,7 +54,7 @@ func (suite *IntegrationTestSuite) TestChainID() {
|
||||
|
||||
// example test that funds a new account & queries its balance
|
||||
func (suite *IntegrationTestSuite) TestFundedAccount() {
|
||||
funds := chaincfg.MakeCoinForAuxiliaryDenom(1e3)
|
||||
funds := chaincfg.MakeCoinForGasDenom(1e3)
|
||||
acc := suite.ZgChain.NewFundedAccount("example-acc", sdk.NewCoins(funds))
|
||||
|
||||
// check that the sdk & evm signers are for the same account
|
||||
@ -63,21 +63,21 @@ func (suite *IntegrationTestSuite) TestFundedAccount() {
|
||||
|
||||
// check balance via SDK query
|
||||
res, err := suite.ZgChain.Bank.Balance(context.Background(), banktypes.NewQueryBalanceRequest(
|
||||
acc.SdkAddress, chaincfg.AuxiliaryDenom,
|
||||
acc.SdkAddress, chaincfg.GasDenom,
|
||||
))
|
||||
suite.NoError(err)
|
||||
suite.Equal(funds, *res.Balance)
|
||||
|
||||
// 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.Equal(funds.Amount.MulRaw(1e12).BigInt(), baseDenomBal)
|
||||
suite.Equal(funds.Amount.MulRaw(1e12).BigInt(), evmDenomBal)
|
||||
}
|
||||
|
||||
// example test that signs & broadcasts an EVM tx
|
||||
func (suite *IntegrationTestSuite) TestTransferOverEVM() {
|
||||
// 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))
|
||||
|
||||
// get a rando account to send 0gchain to
|
||||
@ -89,10 +89,10 @@ func (suite *IntegrationTestSuite) TestTransferOverEVM() {
|
||||
suite.NoError(err)
|
||||
suite.Equal(uint64(0), nonce) // sanity check. the account should have no prior txs
|
||||
|
||||
// transfer auxiliary denom over EVM
|
||||
AuxiliaryDenomToTransfer := big.NewInt(1e17) // .1 (auxiliary denom); base denom has 18 decimals.
|
||||
// transfer gas denom over EVM
|
||||
GasDenomToTransfer := big.NewInt(1e17) // .1 (gas denom); evm denom has 18 decimals.
|
||||
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",
|
||||
}
|
||||
res := acc.SignAndBroadcastEvmTx(req)
|
||||
@ -100,31 +100,31 @@ func (suite *IntegrationTestSuite) TestTransferOverEVM() {
|
||||
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.
|
||||
AuxiliaryDenomUsedForGas := sdkmath.NewIntFromBigInt(minEvmGasPrice).
|
||||
GasDenomUsedForGas := sdkmath.NewIntFromBigInt(minEvmGasPrice).
|
||||
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)
|
||||
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.
|
||||
func (suite *IntegrationTestSuite) TestIbcTransfer() {
|
||||
suite.SkipIfIbcDisabled()
|
||||
|
||||
// ARRANGE
|
||||
// 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))
|
||||
// setup ibc account
|
||||
ibcAcc := suite.Ibc.NewFundedAccount("ibc-transfer-ibc-side", sdk.NewCoins())
|
||||
|
||||
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(
|
||||
testutil.IbcPort,
|
||||
testutil.IbcChannel,
|
||||
@ -154,7 +154,7 @@ func (suite *IntegrationTestSuite) TestIbcTransfer() {
|
||||
// the balance should be deducted from 0g-chain account
|
||||
suite.Eventually(func() bool {
|
||||
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)
|
||||
|
||||
// expect the balance to be transferred to the ibc chain!
|
||||
|
@ -74,7 +74,7 @@ var (
|
||||
EvmRpcUrl: "http://localhost:8545",
|
||||
|
||||
ChainId: "0gchainlocalnet_8888-1",
|
||||
StakingDenom: chaincfg.AuxiliaryDenom,
|
||||
StakingDenom: chaincfg.GasDenom,
|
||||
}
|
||||
kvtoolIbcChain = ChainDetails{
|
||||
RpcUrl: "http://localhost:26658",
|
||||
|
@ -258,7 +258,7 @@ func (a *SigningAccount) BankSend(to sdk.AccAddress, amount sdk.Coins) util.ZgCh
|
||||
util.ZgChainMsgRequest{
|
||||
Msgs: []sdk.Msg{banktypes.NewMsgSend(a.SdkAddress, to, amount)},
|
||||
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),
|
||||
},
|
||||
)
|
||||
|
@ -98,7 +98,7 @@ message Metadata {
|
||||
string description = 1;
|
||||
// denom_units represents the list of DenomUnit's for a given coin
|
||||
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;
|
||||
// display indicates the suggested denom that should be
|
||||
// displayed in clients.
|
||||
|
6
third_party/proto/cosmos/tx/v1beta1/tx.proto
vendored
6
third_party/proto/cosmos/tx/v1beta1/tx.proto
vendored
@ -234,18 +234,18 @@ message Tip {
|
||||
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
|
||||
// actual tx). AuxSignerData is not a valid tx in itself, and will be rejected
|
||||
// by the node if sent directly as-is.
|
||||
//
|
||||
// Since: cosmos-sdk 0.46
|
||||
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
|
||||
// chain (where the final transaction is broadcasted) should be used.
|
||||
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
|
||||
// LEGACY_AMINO_JSON.
|
||||
SignDocDirectAux sign_doc = 2;
|
||||
|
@ -6,13 +6,13 @@ option go_package = "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types";
|
||||
|
||||
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.
|
||||
message DenomTrace {
|
||||
// path defines the chain of port/channel identifiers used for tracing the
|
||||
// source of the fungible token.
|
||||
string path = 1;
|
||||
// base denomination of the relayed fungible token.
|
||||
// evm denomination of the relayed fungible token.
|
||||
string base_denom = 2;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ func (suite *MsgServerTestSuite) SetupTest() {
|
||||
|
||||
// Set up genesis state and initialize
|
||||
_, 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)
|
||||
tApp.InitializeFromGenesisStates(authGS, NewBep3GenStateMulti(cdc, addrs[0]))
|
||||
|
||||
|
@ -20,7 +20,7 @@ type GenesisTestSuite struct {
|
||||
}
|
||||
|
||||
func (suite *GenesisTestSuite) SetupTest() {
|
||||
coin := chaincfg.MakeCoinForAuxiliaryDenom(1)
|
||||
coin := chaincfg.MakeCoinForGasDenom(1)
|
||||
suite.swaps = atomicSwaps(10)
|
||||
|
||||
supply := types.NewAssetSupply(coin, coin, coin, coin, time.Duration(0))
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func TestAssetSupplyValidate(t *testing.T) {
|
||||
coin := chaincfg.MakeCoinForAuxiliaryDenom(1)
|
||||
coin := chaincfg.MakeCoinForGasDenom(1)
|
||||
invalidCoin := sdk.Coin{Denom: "Invalid Denom", Amount: sdkmath.NewInt(-1)}
|
||||
testCases := []struct {
|
||||
msg string
|
||||
|
@ -61,7 +61,7 @@ func (suite *MsgServerTestSuite) SetupTest() {
|
||||
[]types.Proposal{},
|
||||
[]types.Vote{},
|
||||
)
|
||||
suite.communityPoolAmt = sdk.NewCoins(chaincfg.MakeCoinForBaseDenom(1000000000000000))
|
||||
suite.communityPoolAmt = sdk.NewCoins(chaincfg.MakeCoinForEvmDenom(1000000000000000))
|
||||
suite.app.InitializeFromGenesisStates(
|
||||
app.GenesisState{types.ModuleName: cdc.MustMarshalJSON(testGenesis)},
|
||||
// TODO: not used?
|
||||
|
@ -171,7 +171,7 @@ func NewVoteCmd() *cobra.Command {
|
||||
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))
|
||||
// 1_000 0AGI token / vote
|
||||
numBallots := a0giTokenCnt.Quo(sdk.NewInt(1_000)).Uint64()
|
||||
|
@ -50,7 +50,7 @@ func (suite *invariantTestSuite) SetupValidState() {
|
||||
suite.FundModuleAccountWithZgChain(
|
||||
types.ModuleName,
|
||||
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
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -115,7 +115,7 @@ func (k Keeper) SetAccount(ctx sdk.Context, account types.Account) error {
|
||||
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 {
|
||||
account := k.GetAccount(ctx, addr)
|
||||
if account == nil {
|
||||
@ -124,7 +124,7 @@ func (k Keeper) GetBalance(ctx sdk.Context, addr sdk.AccAddress) sdkmath.Int {
|
||||
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 {
|
||||
account := k.GetAccount(ctx, addr)
|
||||
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)
|
||||
}
|
||||
|
||||
// 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 {
|
||||
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() {
|
||||
@ -162,13 +162,13 @@ func (k Keeper) SendBalance(ctx sdk.Context, senderAddr sdk.AccAddress, recipien
|
||||
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 {
|
||||
bal := k.GetBalance(ctx, addr)
|
||||
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 {
|
||||
if amt.IsNegative() {
|
||||
return fmt.Errorf("cannot remove a negative amount from balance: %d", amt)
|
||||
|
@ -80,14 +80,14 @@ func (suite *Suite) SetupTest() {
|
||||
suite.Addrs = addrs
|
||||
|
||||
evmGenesis := evmtypes.DefaultGenesisState()
|
||||
evmGenesis.Params.EvmDenom = chaincfg.BaseDenom
|
||||
evmGenesis.Params.EvmDenom = chaincfg.EvmDenom
|
||||
|
||||
feemarketGenesis := feemarkettypes.DefaultGenesisState()
|
||||
feemarketGenesis.Params.EnableHeight = 1
|
||||
feemarketGenesis.Params.NoBaseFee = false
|
||||
|
||||
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{
|
||||
sdk.AccAddress(suite.Key1.PubKey().Address()),
|
||||
sdk.AccAddress(suite.Key2.PubKey().Address()),
|
||||
@ -184,28 +184,28 @@ func (suite *Suite) ModuleBalance(denom string) sdk.Int {
|
||||
}
|
||||
|
||||
func (suite *Suite) FundAccountWithZgChain(addr sdk.AccAddress, coins sdk.Coins) {
|
||||
AuxiliaryDenomAmt := coins.AmountOf(chaincfg.AuxiliaryDenom)
|
||||
if AuxiliaryDenomAmt.IsPositive() {
|
||||
err := suite.App.FundAccount(suite.Ctx, addr, sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, AuxiliaryDenomAmt)))
|
||||
GasDenomAmt := coins.AmountOf(chaincfg.GasDenom)
|
||||
if GasDenomAmt.IsPositive() {
|
||||
err := suite.App.FundAccount(suite.Ctx, addr, sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, GasDenomAmt)))
|
||||
suite.Require().NoError(err)
|
||||
}
|
||||
baseDenomAmt := coins.AmountOf(chaincfg.BaseDenom)
|
||||
if baseDenomAmt.IsPositive() {
|
||||
err := suite.Keeper.SetBalance(suite.Ctx, addr, baseDenomAmt)
|
||||
evmDenomAmt := coins.AmountOf(chaincfg.EvmDenom)
|
||||
if evmDenomAmt.IsPositive() {
|
||||
err := suite.Keeper.SetBalance(suite.Ctx, addr, evmDenomAmt)
|
||||
suite.Require().NoError(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *Suite) FundModuleAccountWithZgChain(moduleName string, coins sdk.Coins) {
|
||||
AuxiliaryDenomAmt := coins.AmountOf(chaincfg.AuxiliaryDenom)
|
||||
if AuxiliaryDenomAmt.IsPositive() {
|
||||
err := suite.App.FundModuleAccount(suite.Ctx, moduleName, sdk.NewCoins(sdk.NewCoin(chaincfg.AuxiliaryDenom, AuxiliaryDenomAmt)))
|
||||
GasDenomAmt := coins.AmountOf(chaincfg.GasDenom)
|
||||
if GasDenomAmt.IsPositive() {
|
||||
err := suite.App.FundModuleAccount(suite.Ctx, moduleName, sdk.NewCoins(sdk.NewCoin(chaincfg.GasDenom, GasDenomAmt)))
|
||||
suite.Require().NoError(err)
|
||||
}
|
||||
baseDenomAmt := coins.AmountOf(chaincfg.BaseDenom)
|
||||
if baseDenomAmt.IsPositive() {
|
||||
evmDenomAmt := coins.AmountOf(chaincfg.EvmDenom)
|
||||
if evmDenomAmt.IsPositive() {
|
||||
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)
|
||||
}
|
||||
}
|
||||
@ -216,7 +216,7 @@ func (suite *Suite) DeployERC20() types.InternalEVMAddress {
|
||||
suite.App.FundModuleAccount(
|
||||
suite.Ctx,
|
||||
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))
|
||||
@ -317,7 +317,7 @@ func (suite *Suite) SendTx(
|
||||
// Mint the max gas to the FeeCollector to ensure balance in case of refund
|
||||
suite.MintFeeCollector(sdk.NewCoins(
|
||||
sdk.NewCoin(
|
||||
chaincfg.AuxiliaryDenom,
|
||||
chaincfg.GasDenom,
|
||||
sdkmath.NewInt(baseFee.Int64()*int64(gasRes.Gas*2)),
|
||||
)))
|
||||
|
||||
|
@ -143,7 +143,7 @@ func TestConversionPairs_Validate(t *testing.T) {
|
||||
),
|
||||
types.NewConversionPair(
|
||||
testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000A"),
|
||||
chaincfg.AuxiliaryDenom,
|
||||
chaincfg.GasDenom,
|
||||
),
|
||||
types.NewConversionPair(
|
||||
testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000B"),
|
||||
@ -163,7 +163,7 @@ func TestConversionPairs_Validate(t *testing.T) {
|
||||
),
|
||||
types.NewConversionPair(
|
||||
testutil.MustNewInternalEVMAddressFromString("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),
|
||||
chaincfg.AuxiliaryDenom,
|
||||
chaincfg.GasDenom,
|
||||
),
|
||||
types.NewConversionPair(
|
||||
testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000B"),
|
||||
@ -184,16 +184,16 @@ func TestConversionPairs_Validate(t *testing.T) {
|
||||
),
|
||||
types.NewConversionPair(
|
||||
testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000A"),
|
||||
chaincfg.AuxiliaryDenom,
|
||||
chaincfg.GasDenom,
|
||||
),
|
||||
types.NewConversionPair(
|
||||
testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000B"),
|
||||
chaincfg.AuxiliaryDenom,
|
||||
chaincfg.GasDenom,
|
||||
),
|
||||
),
|
||||
errArgs{
|
||||
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(
|
||||
testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000B"),
|
||||
chaincfg.AuxiliaryDenom,
|
||||
chaincfg.GasDenom,
|
||||
),
|
||||
),
|
||||
errArgs{
|
||||
|
@ -107,11 +107,11 @@ func (suite *ParamsTestSuite) TestParams_Validate() {
|
||||
invalidConversionPairs := types.NewConversionPairs(
|
||||
types.NewConversionPair(
|
||||
testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000A"),
|
||||
chaincfg.AuxiliaryDenom,
|
||||
chaincfg.GasDenom,
|
||||
),
|
||||
types.NewConversionPair(
|
||||
testutil.MustNewInternalEVMAddressFromString("0x000000000000000000000000000000000000000B"),
|
||||
chaincfg.AuxiliaryDenom, // duplicate denom!
|
||||
chaincfg.GasDenom, // duplicate denom!
|
||||
),
|
||||
)
|
||||
validAllowedCosmosDenoms := types.NewAllowedCosmosCoinERC20Tokens(
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
|
||||
func TestRawPriceKey_Iteration(t *testing.T) {
|
||||
// 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")
|
||||
|
||||
@ -21,12 +21,12 @@ func TestRawPriceKey_Iteration(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "equal marketID is included in iteration",
|
||||
priceKey: RawPriceKey(chaincfg.AuxiliaryDenom+":usd", addr),
|
||||
priceKey: RawPriceKey(chaincfg.GasDenom+":usd", addr),
|
||||
expectErr: false,
|
||||
},
|
||||
{
|
||||
name: "prefix overlapping marketID excluded from iteration",
|
||||
priceKey: RawPriceKey(chaincfg.AuxiliaryDenom+":usd:30", addr),
|
||||
priceKey: RawPriceKey(chaincfg.GasDenom+":usd:30", addr),
|
||||
expectErr: true,
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user