-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #141 from oasisprotocol/kostko/feature/net-set-cha…
…in-ctx feat(cmd/network): Add network set-chain-context subcommand
- Loading branch information
Showing
6 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package network | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
cliConfig "github.com/oasisprotocol/cli/config" | ||
) | ||
|
||
var setChainContextCmd = &cobra.Command{ | ||
Use: "set-chain-context <name> <chain-context>", | ||
Short: "Sets the chain context of the given network", | ||
Args: cobra.ExactArgs(2), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
cfg := cliConfig.Global() | ||
name, chainContext := args[0], args[1] | ||
|
||
net := cfg.Networks.All[name] | ||
if net == nil { | ||
cobra.CheckErr(fmt.Errorf("network '%s' does not exist", name)) | ||
return // To make staticcheck happy as it doesn't know CheckErr exits. | ||
} | ||
|
||
net.ChainContext = chainContext | ||
|
||
err := cfg.Save() | ||
cobra.CheckErr(err) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
oasis network set-chain-context mainnet_local b11b369e0da5bb230b220127f5e7b242d385ef8c6f54906243f30af63c815535 |
Empty file.