-
Notifications
You must be signed in to change notification settings - Fork 552
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: scaffold chain-registry files (#4413)
* feat: scaffold chain-registry files * cl * cl * updates * updates * typo * renaming * finalize chain-registry * updates * lint * lint * typos (cherry picked from commit ed3d0b3)
- Loading branch information
1 parent
f110f48
commit 7c17f73
Showing
6 changed files
with
503 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
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,68 @@ | ||
package ignitecmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/ignite/cli/v29/ignite/pkg/cliui" | ||
"github.com/ignite/cli/v29/ignite/services/chain" | ||
"github.com/ignite/cli/v29/ignite/services/scaffolder" | ||
) | ||
|
||
// NewScaffoldChainRegistry returns the command to scaffold the chain registry chain.json and assets.json files. | ||
func NewScaffoldChainRegistry() *cobra.Command { | ||
c := &cobra.Command{ | ||
Use: "chain-registry", | ||
Short: "Configs for the chain registry", | ||
Long: `Scaffold the chain registry chain.json and assets.json files. | ||
The chain registry is a GitHub repo, hosted at https://github.com/cosmos/cosmos-registry, that | ||
contains the chain.json and assets.json files of most of chains in the Cosmos ecosystem. | ||
It is good practices, when creating a new chain, and about to launch a testnet or mainnet, to | ||
publish the chain's metadata in the chain registry. | ||
Read more about the chain.json at https://github.com/cosmos/chain-registry?tab=readme-ov-file#chainjson | ||
Read more about the assets.json at https://github.com/cosmos/chain-registry?tab=readme-ov-file#assetlists`, | ||
Args: cobra.NoArgs, | ||
PreRunE: migrationPreRunHandler, | ||
RunE: scaffoldChainRegistryFiles, | ||
} | ||
|
||
flagSetPath(c) | ||
flagSetClearCache(c) | ||
|
||
c.Flags().AddFlagSet(flagSetYes()) | ||
|
||
return c | ||
} | ||
|
||
func scaffoldChainRegistryFiles(cmd *cobra.Command, _ []string) error { | ||
session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) | ||
defer session.End() | ||
|
||
cfg, _, err := getChainConfig(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
c, err := chain.NewWithHomeFlags(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
appPath := flagGetPath(cmd) | ||
sc, err := scaffolder.New(cmd.Context(), appPath, cfg.Build.Proto.Path) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err = sc.AddChainRegistryFiles(c, cfg); err != nil { | ||
return err | ||
} | ||
|
||
// no need for post scaffolding, as we are just creating two files | ||
// that are not part of the build process | ||
|
||
session.Printf("🎉 chain-registry files successfully scaffolded\n") | ||
|
||
return nil | ||
} |
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
Oops, something went wrong.