-
Notifications
You must be signed in to change notification settings - Fork 553
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a7150cc
commit 52b7c63
Showing
3 changed files
with
55 additions
and
48 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
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) | ||
} |
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,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 |