-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Local-interchain cleanup #710
Changes from 4 commits
5cae1e0
bf00e37
1fd5ec2
20cf604
5966ffc
5733d50
b87ff71
a033db8
3eb7db7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,3 @@ func GetFiles() []string { | |
|
||
return fileNames | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(chainsCmd) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,6 @@ import ( | |
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
MakeFileInstallDirectory string | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid global vars. In this case, wasn't needed at all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is required for the ldflags in
There are 3 install cases:
This would remove the first which is the most common desire imo |
||
|
||
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 { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah nice. Yea this makes sense because this got merged first: Really surprised CI didn't catch this?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh one more note... around backporting. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh good catch. We should get that back ported. I can look at it. |
||
Denom: coin.Denom, | ||
}) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I avoid
init()
functions at all costs. Even though this is common in Viper and co-located with the subcommand file, I think it's an anti-pattern. It hides order of operations and hides functionality in themain()
function. IOW, I want to look atmain()
and know exactly what's happening.