Skip to content

Commit

Permalink
refactor: remove init FX bridge token amount (PundiAI#916)
Browse files Browse the repository at this point in the history
  • Loading branch information
zakir-code authored Jan 16, 2025
1 parent c749ceb commit 2e86610
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 41 deletions.
16 changes: 0 additions & 16 deletions app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
Expand All @@ -26,11 +25,8 @@ import (
feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"

fxtypes "github.com/pundiai/fx-core/v8/types"
ethtypes "github.com/pundiai/fx-core/v8/x/eth/types"
)

const EthModuleInitAmount = "378600525462891000000000000"

// GenesisState The genesis state of the blockchain is represented here as a map of raw json
// messages key'd by a identifier string.
// The identifier is used to determine which module genesis information belongs
Expand All @@ -45,11 +41,6 @@ type GenesisState map[string]json.RawMessage
//nolint:gocyclo // a lot of modules need to be modified
func newDefAppGenesisByDenom(cdc codec.JSONCodec, moduleBasics module.BasicManager) GenesisState {
denom := fxtypes.DefaultDenom
ethInitAmount, ok := sdkmath.NewIntFromString(EthModuleInitAmount)
if !ok {
panic("invalid eth module init amount")
}

genesis := make(map[string]json.RawMessage)
for _, m := range moduleBasics {
switch m.Name() {
Expand Down Expand Up @@ -104,13 +95,6 @@ func newDefAppGenesisByDenom(cdc codec.JSONCodec, moduleBasics module.BasicManag
case banktypes.ModuleName:
state := banktypes.DefaultGenesisState()
state.DenomMetadata = []banktypes.Metadata{fxtypes.NewDefaultMetadata()}

ethModuleInitCoins := sdk.NewCoins(sdk.NewCoin(denom, ethInitAmount))
state.Balances = append(state.Balances, banktypes.Balance{
Address: authtypes.NewModuleAddress(ethtypes.ModuleName).String(),
Coins: ethModuleInitCoins,
})
state.Supply = ethModuleInitCoins
genesis[m.Name()] = cdc.MustMarshalJSON(state)
case paramstypes.ModuleName:
if mod, ok := m.(module.HasGenesisBasics); ok {
Expand Down
19 changes: 2 additions & 17 deletions app/genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,8 @@
"send_enabled": [],
"default_send_enabled": true
},
"balances": [
{
"address": "cosmos1c602zv38ht8xu8u2qcmymyl55mcyvvjrzq9ur3",
"coins": [
{
"denom": "apundiai",
"amount": "378600525462891000000000000"
}
]
}
],
"supply": [
{
"denom": "apundiai",
"amount": "378600525462891000000000000"
}
],
"balances": [],
"supply": [],
"denom_metadata": [
{
"description": "The native staking token of the Pundi AIFX",
Expand Down
14 changes: 6 additions & 8 deletions local-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
set -eo pipefail

export FX_HOME=${FX_HOME:-"/tmp/fxcore"}
export FX_CHAIN_ID=${FX_CHAIN_ID:-"fxcore"}
readonly default_denom=apundiai
readonly default_display_denom=pundiai

if [[ "$1" == "init" ]]; then
if [ -d "$FX_HOME" ]; then
Expand All @@ -14,7 +16,7 @@ if [[ "$1" == "init" ]]; then
fi

# Initialize private validator, p2p, genesis, and application configuration files
fxcored init local --chain-id fxcore --default-denom $default_denom
fxcored init local --chain-id "$FX_CHAIN_ID" --default-denom $default_denom

fxcored config config.toml rpc.cors_allowed_origins "*"
# open prometheus
Expand All @@ -33,18 +35,14 @@ if [[ "$1" == "init" ]]; then
fxcored config app.toml json-rpc.api "eth,txpool,personal,net,debug,web3"

# update fxcore client config
fxcored config set client chain-id "fxcore"
fxcored config set client chain-id "$FX_CHAIN_ID"
fxcored config set client keyring-backend "test"
fxcored config set client output "json"
fxcored config set client broadcast-mode "sync"

echo "test test test test test test test test test test test junk" | fxcored keys add fx1 --recover
if [ -n "${2:-""}" ]; then
fxcored genesis add-genesis-account fx1 10004000000000000000000000$default_denom
else
fxcored genesis add-genesis-account fx1 4000000000000000000000$default_denom
fi
fxcored genesis gentx fx1 100000000000000000000$default_denom --chain-id=fxcore \
fxcored genesis add-genesis-account fx1 10000$default_display_denom
fxcored genesis gentx fx1 100$default_display_denom --chain-id="$FX_CHAIN_ID" \
--gas="200000" \
--moniker="fx-validator" \
--commission-max-change-rate="0.01" \
Expand Down

0 comments on commit 2e86610

Please sign in to comment.