From 52b7c6374120e73dd87b6445c0638926887d5966 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 16 Jan 2025 00:32:25 +0100 Subject: [PATCH] split --- ignite/pkg/chainregistry/asset.go | 52 +++++++++++++++++++ .../{chainregistry.go => chain.go} | 48 ----------------- ignite/pkg/chainregistry/doc.go | 3 ++ 3 files changed, 55 insertions(+), 48 deletions(-) create mode 100644 ignite/pkg/chainregistry/asset.go rename ignite/pkg/chainregistry/{chainregistry.go => chain.go} (69%) create mode 100644 ignite/pkg/chainregistry/doc.go diff --git a/ignite/pkg/chainregistry/asset.go b/ignite/pkg/chainregistry/asset.go new file mode 100644 index 0000000000..5ec491322d --- /dev/null +++ b/ignite/pkg/chainregistry/asset.go @@ -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) +} diff --git a/ignite/pkg/chainregistry/chainregistry.go b/ignite/pkg/chainregistry/chain.go similarity index 69% rename from ignite/pkg/chainregistry/chainregistry.go rename to ignite/pkg/chainregistry/chain.go index b0d41ae5ee..8e7db169e4 100644 --- a/ignite/pkg/chainregistry/chainregistry.go +++ b/ignite/pkg/chainregistry/chain.go @@ -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 ( @@ -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) -} diff --git a/ignite/pkg/chainregistry/doc.go b/ignite/pkg/chainregistry/doc.go new file mode 100644 index 0000000000..d6d2df8e44 --- /dev/null +++ b/ignite/pkg/chainregistry/doc.go @@ -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