Skip to content

Commit

Permalink
split
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Jan 15, 2025
1 parent a7150cc commit 52b7c63
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 48 deletions.
52 changes: 52 additions & 0 deletions ignite/pkg/chainregistry/asset.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package chainregistry

import (
"encoding/json"
"os"
)

// AssetList represents the assetlist.json file from the chain registry.
// https://raw.githubusercontent.com/cosmos/chain-registry/master/assetlist.schema.json
// https://github.com/cosmos/chain-registry?tab=readme-ov-file#assetlists
type AssetList struct {
ChainName string `json:"chain_name"`
Assets []Asset `json:"assets"`
}

type Asset struct {
Description string `json:"description"`
DenomUnits []DenomUnit `json:"denom_units"`
Base string `json:"base"`
Name string `json:"name"`
Display string `json:"display"`
Symbol string `json:"symbol"`
LogoURIs LogoURIs `json:"logo_URIs"`
CoingeckoID string `json:"coingecko_id,omitempty"`
Socials Socials `json:"socials,omitempty"`
TypeAsset string `json:"type_asset"`
}

type DenomUnit struct {
Denom string `json:"denom"`
Exponent int `json:"exponent"`
}

type LogoURIs struct {
Png string `json:"png"`
Svg string `json:"svg"`
}

type Socials struct {
Website string `json:"website"`
Twitter string `json:"twitter"`
}

// SaveJSON saves the assetlist.json to the given out directory.
func (c AssetList) SaveJSON(out string) error {
bz, err := json.MarshalIndent(c, "", " ")
if err != nil {
return err
}

return os.WriteFile(out, bz, 0o600)
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// package chainregistry is a package that contains the chain.json and assetlist.json structs from the chain registry.
// Useful when parsing or creating chain.json and assetlist.json files.
package chainregistry

import (
Expand Down Expand Up @@ -112,49 +110,3 @@ func (c Chain) SaveJSON(out string) error {

return os.WriteFile(out, bz, 0o600)
}

// AssetList represents the assetlist.json file from the chain registry.
// https://raw.githubusercontent.com/cosmos/chain-registry/master/assetlist.schema.json
// https://github.com/cosmos/chain-registry?tab=readme-ov-file#assetlists
type AssetList struct {
ChainName string `json:"chain_name"`
Assets []Asset `json:"assets"`
}

type Asset struct {
Description string `json:"description"`
DenomUnits []DenomUnit `json:"denom_units"`
Base string `json:"base"`
Name string `json:"name"`
Display string `json:"display"`
Symbol string `json:"symbol"`
LogoURIs LogoURIs `json:"logo_URIs"`
CoingeckoID string `json:"coingecko_id,omitempty"`
Socials Socials `json:"socials,omitempty"`
TypeAsset string `json:"type_asset"`
}

type DenomUnit struct {
Denom string `json:"denom"`
Exponent int `json:"exponent"`
}

type LogoURIs struct {
Png string `json:"png"`
Svg string `json:"svg"`
}

type Socials struct {
Website string `json:"website"`
Twitter string `json:"twitter"`
}

// SaveJSON saves the assetlist.json to the given out directory.
func (c AssetList) SaveJSON(out string) error {
bz, err := json.MarshalIndent(c, "", " ")
if err != nil {
return err
}

return os.WriteFile(out, bz, 0o600)
}
3 changes: 3 additions & 0 deletions ignite/pkg/chainregistry/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// package chainregistry is a package that contains the chain.json and assetlist.json structs from the chain registry.
// Useful when parsing or creating chain.json and assetlist.json files.
package chainregistry

0 comments on commit 52b7c63

Please sign in to comment.