From 5cae1e0f16cd16d92cc4917489c03c47b0485fa2 Mon Sep 17 00:00:00 2001 From: David Nix Date: Wed, 16 Aug 2023 11:37:36 -0600 Subject: [PATCH 1/7] Fix compiler error --- local-interchain/interchain/genesis.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/local-interchain/interchain/genesis.go b/local-interchain/interchain/genesis.go index 4daae2e28..59f70975e 100644 --- a/local-interchain/interchain/genesis.go +++ b/local-interchain/interchain/genesis.go @@ -5,10 +5,11 @@ import ( "log" "strings" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/strangelove-ventures/interchaintest/v7/chain/cosmos" "github.com/strangelove-ventures/interchaintest/v7/ibc" - types "github.com/strangelove-ventures/localinterchain/interchain/types" + "github.com/strangelove-ventures/localinterchain/interchain/types" ) func AddGenesisKeysToKeyring(ctx context.Context, config *types.Config, chains []ibc.Chain) { @@ -62,7 +63,7 @@ func SetupGenesisWallets(config *types.Config, chains []ibc.Chain) map[ibc.Chain for _, coin := range amount { additionalWallets[chainObj] = append(additionalWallets[chainObj], ibc.WalletAmount{ Address: acc.Address, - Amount: coin.Amount.Int64(), + Amount: math.NewInt(coin.Amount.Int64()), Denom: coin.Denom, }) } From bf00e3702a4534674f968c3d7f7ef489ba851edd Mon Sep 17 00:00:00 2001 From: David Nix Date: Wed, 16 Aug 2023 11:37:59 -0600 Subject: [PATCH 2/7] Use go run in Makefile Prevents needing to build the binary first. --- local-interchain/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/local-interchain/Makefile b/local-interchain/Makefile index 637308389..4df91e194 100644 --- a/local-interchain/Makefile +++ b/local-interchain/Makefile @@ -12,7 +12,7 @@ build: .PHONY: run run: - ../bin/local-ic $(filter-out $@,$(MAKECMDGOALS)) + go run ./cmd/local-ic $(filter-out $@,$(MAKECMDGOALS)) .PHONY: install install: From 1fd5ec2c82c5005d51840538bea4b41db3823df0 Mon Sep 17 00:00:00 2001 From: David Nix Date: Wed, 16 Aug 2023 11:38:58 -0600 Subject: [PATCH 3/7] Remove unecessary init functions --- local-interchain/cmd/local-ic/chains.go | 4 ---- local-interchain/cmd/local-ic/main.go | 4 ++++ local-interchain/cmd/local-ic/new_chain.go | 4 ---- local-interchain/cmd/local-ic/start_chain.go | 4 ---- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/local-interchain/cmd/local-ic/chains.go b/local-interchain/cmd/local-ic/chains.go index 004932086..6b52894b3 100644 --- a/local-interchain/cmd/local-ic/chains.go +++ b/local-interchain/cmd/local-ic/chains.go @@ -59,7 +59,3 @@ func GetFiles() []string { return fileNames } - -func init() { - rootCmd.AddCommand(chainsCmd) -} diff --git a/local-interchain/cmd/local-ic/main.go b/local-interchain/cmd/local-ic/main.go index bbcb4f8ef..a78af4c51 100644 --- a/local-interchain/cmd/local-ic/main.go +++ b/local-interchain/cmd/local-ic/main.go @@ -6,6 +6,10 @@ import ( ) func main() { + rootCmd.AddCommand(chainsCmd) + rootCmd.AddCommand(newChainCmd) + rootCmd.AddCommand(startCmd) + if err := rootCmd.Execute(); err != nil { fmt.Fprintf(os.Stderr, "error while executing your CLI. Err: %v\n", err) os.Exit(1) diff --git a/local-interchain/cmd/local-ic/new_chain.go b/local-interchain/cmd/local-ic/new_chain.go index 30715be23..d0ab64654 100644 --- a/local-interchain/cmd/local-ic/new_chain.go +++ b/local-interchain/cmd/local-ic/new_chain.go @@ -185,7 +185,3 @@ func getOrDefault[T any](output string, defaultVal T) T { return any(text).(T) } - -func init() { - rootCmd.AddCommand(newChainCmd) -} diff --git a/local-interchain/cmd/local-ic/start_chain.go b/local-interchain/cmd/local-ic/start_chain.go index b1f7bedba..8bcd95b22 100644 --- a/local-interchain/cmd/local-ic/start_chain.go +++ b/local-interchain/cmd/local-ic/start_chain.go @@ -30,7 +30,3 @@ var startCmd = &cobra.Command{ interchain.StartChain(parentDir, configPath) }, } - -func init() { - rootCmd.AddCommand(startCmd) -} From 20cf604118819402c06c21e089e57e43f8895bc3 Mon Sep 17 00:00:00 2001 From: David Nix Date: Wed, 16 Aug 2023 11:44:46 -0600 Subject: [PATCH 4/7] Remove unecessary global var --- local-interchain/cmd/local-ic/root.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/local-interchain/cmd/local-ic/root.go b/local-interchain/cmd/local-ic/root.go index fdfc2a908..32bc46008 100644 --- a/local-interchain/cmd/local-ic/root.go +++ b/local-interchain/cmd/local-ic/root.go @@ -9,10 +9,6 @@ import ( "github.com/spf13/cobra" ) -var ( - MakeFileInstallDirectory string -) - var rootCmd = &cobra.Command{ Use: "local-ic", Short: "Your local IBC interchain of nodes program", @@ -28,24 +24,25 @@ var rootCmd = &cobra.Command{ func GetDirectory() string { // Config variable override for the ICTEST_HOME + var makeInstalDir string if res := os.Getenv("ICTEST_HOME"); res != "" { - MakeFileInstallDirectory = res + makeInstalDir = res } - if MakeFileInstallDirectory == "" { + if makeInstalDir == "" { dirname, err := os.UserHomeDir() if err != nil { log.Fatal(err) } - MakeFileInstallDirectory = path.Join(dirname, "local-interchain") + makeInstalDir = path.Join(dirname, "local-interchain") } - if err := directoryRequirementChecks(MakeFileInstallDirectory, "configs", "chains"); err != nil { + if err := directoryRequirementChecks(makeInstalDir, "configs", "chains"); err != nil { log.Fatal(err) } - return MakeFileInstallDirectory + return makeInstalDir } func directoryRequirementChecks(parent string, subDirectories ...string) error { From 5966ffc194e315818929b4379c5136afb7d082ca Mon Sep 17 00:00:00 2001 From: David Nix Date: Wed, 16 Aug 2023 11:48:40 -0600 Subject: [PATCH 5/7] Fix misspelling in var name --- local-interchain/cmd/local-ic/root.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/local-interchain/cmd/local-ic/root.go b/local-interchain/cmd/local-ic/root.go index 32bc46008..e7cd77515 100644 --- a/local-interchain/cmd/local-ic/root.go +++ b/local-interchain/cmd/local-ic/root.go @@ -24,25 +24,25 @@ var rootCmd = &cobra.Command{ func GetDirectory() string { // Config variable override for the ICTEST_HOME - var makeInstalDir string + var makeFileInstallDir string if res := os.Getenv("ICTEST_HOME"); res != "" { - makeInstalDir = res + makeFileInstallDir = res } - if makeInstalDir == "" { + if makeFileInstallDir == "" { dirname, err := os.UserHomeDir() if err != nil { log.Fatal(err) } - makeInstalDir = path.Join(dirname, "local-interchain") + makeFileInstallDir = path.Join(dirname, "local-interchain") } - if err := directoryRequirementChecks(makeInstalDir, "configs", "chains"); err != nil { + if err := directoryRequirementChecks(makeFileInstallDir, "configs", "chains"); err != nil { log.Fatal(err) } - return makeInstalDir + return makeFileInstallDir } func directoryRequirementChecks(parent string, subDirectories ...string) error { From b87ff712f4c5523ef1078e18e73456e921493af8 Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Thu, 14 Sep 2023 14:28:28 -0500 Subject: [PATCH 6/7] Revert "Remove unecessary global var" This reverts commit 20cf604118819402c06c21e089e57e43f8895bc3. --- local-interchain/cmd/local-ic/root.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/local-interchain/cmd/local-ic/root.go b/local-interchain/cmd/local-ic/root.go index e7cd77515..fdfc2a908 100644 --- a/local-interchain/cmd/local-ic/root.go +++ b/local-interchain/cmd/local-ic/root.go @@ -9,6 +9,10 @@ import ( "github.com/spf13/cobra" ) +var ( + MakeFileInstallDirectory string +) + var rootCmd = &cobra.Command{ Use: "local-ic", Short: "Your local IBC interchain of nodes program", @@ -24,25 +28,24 @@ var rootCmd = &cobra.Command{ func GetDirectory() string { // Config variable override for the ICTEST_HOME - var makeFileInstallDir string if res := os.Getenv("ICTEST_HOME"); res != "" { - makeFileInstallDir = res + MakeFileInstallDirectory = res } - if makeFileInstallDir == "" { + if MakeFileInstallDirectory == "" { dirname, err := os.UserHomeDir() if err != nil { log.Fatal(err) } - makeFileInstallDir = path.Join(dirname, "local-interchain") + MakeFileInstallDirectory = path.Join(dirname, "local-interchain") } - if err := directoryRequirementChecks(makeFileInstallDir, "configs", "chains"); err != nil { + if err := directoryRequirementChecks(MakeFileInstallDirectory, "configs", "chains"); err != nil { log.Fatal(err) } - return makeFileInstallDir + return MakeFileInstallDirectory } func directoryRequirementChecks(parent string, subDirectories ...string) error { From a033db85a7c0543391cc1ff13594c00d03b5d78d Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Thu, 14 Sep 2023 14:29:42 -0500 Subject: [PATCH 7/7] Add comment for why InstallDir must be public --- local-interchain/cmd/local-ic/root.go | 1 + 1 file changed, 1 insertion(+) diff --git a/local-interchain/cmd/local-ic/root.go b/local-interchain/cmd/local-ic/root.go index fdfc2a908..45d3dfff8 100644 --- a/local-interchain/cmd/local-ic/root.go +++ b/local-interchain/cmd/local-ic/root.go @@ -10,6 +10,7 @@ import ( ) var ( + // This must be global for the Makefile to build properly (ldflags). MakeFileInstallDirectory string )