Skip to content

Commit

Permalink
use the name given by the user to generate the fetch URL (#1233)
Browse files Browse the repository at this point in the history
* use the name given by the user to generate the fetch URL

* add example

---------

Co-authored-by: Andrew Gouin <andrew@gouin.io>
Co-authored-by: Dan Kanefsky <56059752+boojamya@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 26, 2023
1 parent 3c78287 commit 993c21b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions cmd/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,10 @@ func chainsAddCmd(a *appState) *cobra.Command {
" the chain-registry or passing a file (-f) or url (-u)",
Args: withUsage(cobra.MinimumNArgs(0)),
Example: fmt.Sprintf(` $ %s chains add cosmoshub
$ %s chains add testnets/cosmoshubtestnet
$ %s chains add cosmoshub osmosis
$ %s chains add --file chains/ibc0.json ibc0
$ %s chains add --url https://relayer.com/ibc0.json ibc0`, appName, appName, appName, appName),
$ %s chains add --url https://relayer.com/ibc0.json ibc0`, appName, appName, appName, appName, appName),
RunE: func(cmd *cobra.Command, args []string) error {
file, url, err := getAddInputs(cmd)
if err != nil {
Expand Down Expand Up @@ -447,7 +448,7 @@ func addChainsFromRegistry(ctx context.Context, a *appState, chains []string) er
continue
}

chainConfig, err := chainInfo.GetChainConfig(ctx)
chainConfig, err := chainInfo.GetChainConfig(ctx, chain)
if err != nil {
a.log.Warn(
"Error generating chain config",
Expand Down
8 changes: 4 additions & 4 deletions cregistry/chain_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ func (c ChainInfo) GetRandomRPCEndpoint(ctx context.Context) (string, error) {
}

// GetAssetList returns the asset metadata from the cosmos chain registry for this particular chain.
func (c ChainInfo) GetAssetList(ctx context.Context) (AssetList, error) {
chainRegURL := fmt.Sprintf("https://raw.githubusercontent.com/cosmos/chain-registry/master/%s/assetlist.json", c.ChainName)
func (c ChainInfo) GetAssetList(ctx context.Context, name string) (AssetList, error) {
chainRegURL := fmt.Sprintf("https://raw.githubusercontent.com/cosmos/chain-registry/master/%s/assetlist.json", name)

res, err := http.Get(chainRegURL)
if err != nil {
Expand Down Expand Up @@ -236,11 +236,11 @@ func (c ChainInfo) GetAssetList(ctx context.Context) (AssetList, error) {

// GetChainConfig returns a CosmosProviderConfig composed from the details found in the cosmos chain registry for
// this particular chain.
func (c ChainInfo) GetChainConfig(ctx context.Context) (*cosmos.CosmosProviderConfig, error) {
func (c ChainInfo) GetChainConfig(ctx context.Context, name string) (*cosmos.CosmosProviderConfig, error) {
debug := viper.GetBool("debug")
home := viper.GetString("home")

assetList, err := c.GetAssetList(ctx)
assetList, err := c.GetAssetList(ctx, name)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 993c21b

Please sign in to comment.