Skip to content

Commit

Permalink
feat: chain-id replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathansumner committed Apr 16, 2024
1 parent 459bf08 commit 7f4f616
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions cmd/fetchd/cmd/genasiupgrade.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package cmd

import (
"fmt"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
"github.com/spf13/cobra"
"github.com/tendermint/tendermint/types"
)

const (
Expand Down Expand Up @@ -39,7 +45,23 @@ func ASIGenesisUpgradeCmd(defaultNodeHome string) *cobra.Command {

Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
return nil
clientCtx := client.GetClientContextFromCmd(cmd)

serverCtx := server.GetServerContextFromCmd(cmd)
config := serverCtx.Config

config.SetRoot(clientCtx.HomeDir)

genFile := config.GenesisFile()

_, genDoc, err := genutiltypes.GenesisStateFromGenFile(genFile)
if err != nil {
return fmt.Errorf("failed to unmarshal genesis state: %w", err)
}

// replace chain-id
ASIGenesisUpgradeReplaceChainID(genDoc)
return genutil.ExportGenesisFile(genDoc, genFile)
},
}

Expand All @@ -53,7 +75,9 @@ func ASIGenesisUpgradeCmd(defaultNodeHome string) *cobra.Command {

func ASIGenesisUpgradeReplaceDenomMetadata() {}

func ASIGenesisUpgradeReplaceChainID() {}
func ASIGenesisUpgradeReplaceChainID(genesisData *types.GenesisDoc) {
genesisData.ChainID = NewChainId
}

func ASIGenesisUpgradeReplaceDenom() {}

Expand Down

0 comments on commit 7f4f616

Please sign in to comment.