diff --git a/app/e2e_include_upgrades.go b/app/e2e_include_upgrades.go index 9d6af8d51..4f913c1ae 100644 --- a/app/e2e_include_upgrades.go +++ b/app/e2e_include_upgrades.go @@ -2,8 +2,11 @@ package app -import "github.com/babylonlabs-io/babylon/app/upgrades/vanilla" +import ( + "github.com/babylonlabs-io/babylon/app/upgrades/launchsignet" + "github.com/babylonlabs-io/babylon/app/upgrades/vanilla" +) func init() { - Upgrades = append(Upgrades, vanilla.Upgrade) + Upgrades = append(Upgrades, vanilla.Upgrade, launchsignet.Upgrade) } diff --git a/app/upgrades/launchsignet/upgrades.go b/app/upgrades/launchsignet/upgrades.go index 7a841b2ab..9765acdc0 100644 --- a/app/upgrades/launchsignet/upgrades.go +++ b/app/upgrades/launchsignet/upgrades.go @@ -20,7 +20,6 @@ import ( "github.com/babylonlabs-io/babylon/app/keepers" appparams "github.com/babylonlabs-io/babylon/app/params" "github.com/babylonlabs-io/babylon/app/upgrades" - "github.com/babylonlabs-io/babylon/cmd/babylond/cmd/genhelpers" btclightkeeper "github.com/babylonlabs-io/babylon/x/btclightclient/keeper" btclighttypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" ) @@ -68,7 +67,7 @@ func LoadBTCHeadersFromData() ([]*btclighttypes.BTCHeaderInfo, error) { } btcHeadersFilePath := filepath.Join(pwd, "data/btc_headers.json") - gs, err := genhelpers.LoadBtcLightGenStateFromFile(appparams.DefaultEncodingConfig().Codec, btcHeadersFilePath) + gs, err := btclighttypes.LoadBtcLightGenStateFromFile(appparams.DefaultEncodingConfig().Codec, btcHeadersFilePath) if err != nil { return nil, err } diff --git a/cmd/babylond/cmd/genhelpers/set_btc_headers.go b/cmd/babylond/cmd/genhelpers/set_btc_headers.go index 5ddfa3b36..7df48e4fd 100644 --- a/cmd/babylond/cmd/genhelpers/set_btc_headers.go +++ b/cmd/babylond/cmd/genhelpers/set_btc_headers.go @@ -2,12 +2,8 @@ package genhelpers import ( "fmt" - "os" - "path/filepath" - cmtos "github.com/cometbft/cometbft/libs/os" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" @@ -51,7 +47,7 @@ Possible content of 'btc_headers.json' is config := server.GetServerContextFromCmd(cmd).Config config.SetRoot(clientCtx.HomeDir) - inputBtcHeaders, err := LoadBtcLightGenStateFromFile(clientCtx.Codec, args[0]) + inputBtcHeaders, err := btclighttypes.LoadBtcLightGenStateFromFile(clientCtx.Codec, args[0]) if err != nil { return err } @@ -102,23 +98,3 @@ Possible content of 'btc_headers.json' is return cmd } - -func LoadBtcLightGenStateFromFile(cdc codec.Codec, inputFilePath string) (*btclighttypes.GenesisState, error) { - filePath := filepath.Clean(inputFilePath) - if !cmtos.FileExists(filePath) { - return nil, fmt.Errorf("input file %s does not exists", filePath) - } - - bz, err := os.ReadFile(filePath) - if err != nil { - return nil, err - } - - var genState btclighttypes.GenesisState - err = cdc.UnmarshalJSON(bz, &genState) - if err != nil { - return nil, err - } - - return &genState, nil -} diff --git a/x/btclightclient/types/genesis.go b/x/btclightclient/types/genesis.go index 13835fa2b..f8555fdcf 100644 --- a/x/btclightclient/types/genesis.go +++ b/x/btclightclient/types/genesis.go @@ -4,6 +4,8 @@ import ( "encoding/json" "errors" "fmt" + "os" + "path/filepath" bbn "github.com/babylonlabs-io/babylon/types" "github.com/btcsuite/btcd/chaincfg" @@ -86,3 +88,19 @@ func GenesisStateFromAppState(cdc codec.Codec, appState map[string]json.RawMessa return genesisState } + +func LoadBtcLightGenStateFromFile(cdc codec.Codec, inputFilePath string) (*GenesisState, error) { + filePath := filepath.Clean(inputFilePath) + bz, err := os.ReadFile(filePath) + if err != nil { + return nil, err + } + + var genState GenesisState + err = cdc.UnmarshalJSON(bz, &genState) + if err != nil { + return nil, err + } + + return &genState, nil +}