fix: tx commands are no need to specify --chain-id (#12092)
## Description Closes: #12085 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
This commit is contained in:
parent
b0756f24bb
commit
cabd3a9b4f
@ -62,6 +62,10 @@ func ReadFromClientConfig(ctx client.Context) (client.Context, error) {
|
||||
return ctx, fmt.Errorf("couldn't make client config: %v", err)
|
||||
}
|
||||
|
||||
if ctx.ChainID != "" {
|
||||
conf.ChainID = ctx.ChainID // chain-id will be written to the client.toml while initiating the chain.
|
||||
}
|
||||
|
||||
if err := writeConfigToFile(configFilePath, conf); err != nil {
|
||||
return ctx, fmt.Errorf("could not write client config to the file: %v", err)
|
||||
}
|
||||
|
||||
@ -26,10 +26,12 @@ const (
|
||||
// initClientContext initiates client Context for tests
|
||||
func initClientContext(t *testing.T, envVar string) (client.Context, func()) {
|
||||
home := t.TempDir()
|
||||
chainId := "test-chain"
|
||||
clientCtx := client.Context{}.
|
||||
WithHomeDir(home).
|
||||
WithViper("").
|
||||
WithCodec(codec.NewProtoCodec(codectypes.NewInterfaceRegistry()))
|
||||
WithCodec(codec.NewProtoCodec(codectypes.NewInterfaceRegistry())).
|
||||
WithChainID(chainId)
|
||||
|
||||
require.NoError(t, clientCtx.Viper.BindEnv(nodeEnv))
|
||||
if envVar != "" {
|
||||
@ -38,6 +40,7 @@ func initClientContext(t *testing.T, envVar string) (client.Context, func()) {
|
||||
|
||||
clientCtx, err := config.ReadFromClientConfig(clientCtx)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, clientCtx.ChainID, chainId)
|
||||
|
||||
return clientCtx, func() { _ = os.RemoveAll(home) }
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user