Skip to content

Commit

Permalink
chore(token-registry): xNIBI and early wrapped ERC20s (#2208)
Browse files Browse the repository at this point in the history
* chore(token-registry): changes for cosmos/chain-registry#5784

* ci: improve changelog-check.yml workflow to better handle a monorepo

* ci(changelog-check): improve filter

* add erc20s_official.json and document it

* impl official_erc20s.json and official_bank_coins.json

* docs: update README
  • Loading branch information
Unique-Divine authored Feb 26, 2025
1 parent 8cae09b commit eb64da0
Show file tree
Hide file tree
Showing 27 changed files with 532 additions and 64 deletions.
35 changes: 34 additions & 1 deletion .github/workflows/changelog-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,42 @@ on:
types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled]

jobs:
# This implementation handles CHANGELOG.md checks for a monorepo, ensuring
# that changelogs throughout the repo are edited. The advantage of this
# implemenation is that packages or projecs with independent changelogs will
# can still have automation without requiring edits to the root changelog.
#
# IF a Go-related file (filter "nibiru-go") is changed, the
# "dangoslen/changelog-enforcer" action runs, enforcing changes to the
# CHANGELOG.md file at the root of the repo.
#
# ELSE IF no changelog was modified anywhere else, then
# "dangoslen/changelog-enforcer" runs.
#
# ELSE, some changelog file must have been modified that was not the root
# one, so the workflow can skip "dangoslen/changelog-enforcer".
changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Check for changelog and Go edits"
id: check_changelog
uses: dorny/paths-filter@v3
with:
filters: |
changelog:
- "**/CHANGELOG.md"
nibiru-go:
- "app/**.go"
- "cmd/**.go"
- "eth/**.go"
- "gosdk/**.go"
- "x/**.go"
- "**.proto"
- "go.mod"
- "go.sum"
- "contrib/docker/*"
- uses: dangoslen/changelog-enforcer@v3
if: steps.check_changelog.outputs.nibiru-go == 'true' || steps.check_changelog.outputs.changelog == 'false'
with:
skipLabels: "skip-changelog"
skipLabels: "skip-changelog"
10 changes: 5 additions & 5 deletions evm-core-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@nibiruchain/evm-core",
"description": "Lightweight Nibiru EVM TypeScript library for type-safe interactions with precompiled contracts, essential constants, and other core utilites.",
"version": "0.0.2",
"version": "0.0.3",
"private": false,
"include": ["src"],
"scripts": {
Expand All @@ -24,12 +24,12 @@
},
"exports": {
"./ethers": {
"import": "./dist/src/ethers/index.js",
"types": "./dist/src/ethers/index.d.ts"
"import": "./dist/ethers/index.js",
"types": "./dist/ethers/index.d.ts"
},
".": {
"import": "./dist/src/src.js",
"types": "./dist/src/src.d.ts"
"import": "./dist/src.js",
"types": "./dist/src.d.ts"
}
}
}
3 changes: 3 additions & 0 deletions token-registry/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# CHANGELOG - Nibiru/token-registry

- [#2208](https://github.com/NibiruChain/nibiru/pull/2208) chore(token-registry): Add the xNIBI CW20 token and early wrapped ERC20 tokens for NIBI and AXV
49 changes: 49 additions & 0 deletions token-registry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,52 @@
This directory implements the Nibiru Token Registry by providing a means to
register offchain digital token metadata to onchain identifiers for use with
applications like wallets.

<img src="https://raw.githubusercontent.com/NibiruChain/nibiru/main/token-registry/nibiru-web-app.png">

## Generation Script

The command to generate files from the Nibiru Token Registry is
```bash
just gen-token-registry
```

If you don't have the `just` command, run this first.
```bash
cargo install just
```

This produces several files:
- `dist/cosmos-assetlist.json`: An external JSON file for use inside the
[cosmos/chain-registry GitHub repo](https://github.com/cosmos/chain-registry/tree/master/nibiru).
- `token-registry/official_erc20s.json`: Verified ERC20s for the Nibiru web app
- `token-registry/official_bank_coins.json`: Bank Coins in the Nibiru web app

## official_erc20s.json

This file maintains a registry of known ERC20 tokens. It's intended for use in the [Nibiru web
application](https://app.nibiru.fi) and the Nibiru Indexer that provides data on
tokens and token balances.

### Fields of the `official_erc20s.json` configuration file
- `contractAddr`: ERC20 smart contract address of the token
- `displayName`: Concise display name of the token. Example: "Wrapped Ether".
- `symbol`: Symbol, or ticker, of the digital asset.
Example: "ETH", "NIBI"
- `decimals`: The number of decimal places, or power of 10, that is used for the
display unit of the token. Said more concretely, the smallest unit of
the token, "base unit", is such that 1 TOKEN == 10^{decimals} base units.
- Example: NIBI has 6 decimals. This means the base unit seen onchain is 10^{-6} NIBI.
- Example: ETH has 18 decimals. This means the base unit of ETH is 10^{-18} ether.
- `logoSrc`: GitHub static asset link for the logo image that will often appear
inside a circular frame.
Example: "raw.githubusercontent.com/NibiruChain/nibiru/main/token-registry/img/0000_nibiru.png"
- `priceInfo`: (Optional)

Related Ticket: https://github.com/NibiruChain/go-heartmonitor/issues/378

## Exporting for the cosmos/chain-registry

1. Run the generation script (`just gen-token-registry`)
2. Copy or move the "dist/cosmos-assetlist.json" file to replace
"nibiru/assetlist.json" in the "cosmos/chain-registry" repo.
36 changes: 18 additions & 18 deletions token-registry/assetlist.go → token-registry/cosmos_assetlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ func TOKENS() []Token {
Display: "nibi",
Symbol: "NIBI",
LogoURIs: &LogoURIs{
Png: some("./img/0000_nibiru.png"),
Svg: some("./img/0000_nibiru.svg"),
Png: some("https://raw.githubusercontent.com/cosmos/chain-registry/master/nibiru/images/nibiru.png"),
Svg: some("https://raw.githubusercontent.com/cosmos/chain-registry/master/nibiru/images/nibiru.svg"),
},
CoingeckoID: some("nibiru"),
Images: []AssetImage{
{
Png: some("./img/0000_nibiru.png"),
Svg: some("./img/0000_nibiru.svg"),
Png: some("https://raw.githubusercontent.com/cosmos/chain-registry/master/nibiru/images/nibiru.png"),
Svg: some("https://raw.githubusercontent.com/cosmos/chain-registry/master/nibiru/images/nibiru.svg"),
Theme: &ImageTheme{
PrimaryColorHex: some("#14c0ce"),
},
Expand All @@ -71,13 +71,13 @@ func TOKENS() []Token {
Display: "stNIBI",
Symbol: "stNIBI",
LogoURIs: &LogoURIs{
Png: some("./img/0001_stnibi-500x500.png"),
Svg: some("./img/0001_stnibi-500x500.svg"),
Png: some("https://raw.githubusercontent.com/cosmos/chain-registry/master/nibiru/images/stnibi-logo-circle-500x500.png"),
Svg: some("https://raw.githubusercontent.com/cosmos/chain-registry/master/nibiru/images/stnibi-logo-circle-500x500.svg"),
},
Images: []AssetImage{
{
Png: some("./img/0001_stnibi-500x500.png"),
Svg: some("./img/0001_stnibi-500x500.svg"),
Png: some("https://raw.githubusercontent.com/cosmos/chain-registry/master/nibiru/images/stnibi-logo-circle-500x500.png"),
Svg: some("https://raw.githubusercontent.com/cosmos/chain-registry/master/nibiru/images/stnibi-logo-circle-500x500.svg"),
Theme: &ImageTheme{
PrimaryColorHex: some("#14c0ce"),
},
Expand Down Expand Up @@ -125,17 +125,17 @@ func TOKENS() []Token {
ChainName: "noble",
BaseDenom: "uusdc",
},
Png: some("./img/0002_usdc.png"),
Svg: some("./img/0002_usdc.svg"),
Png: some("https://raw.githubusercontent.com/cosmos/chain-registry/master/_non-cosmos/ethereum/images/usdc.png"),
Svg: some("https://raw.githubusercontent.com/cosmos/chain-registry/master/_non-cosmos/ethereum/images/usdc.svg"),
Theme: &ImageTheme{
Circle: some(true),
PrimaryColorHex: some("#2775CA"),
},
},
},
LogoURIs: &LogoURIs{
Png: some("./img/0002_usdc.png"),
Svg: some("./img/0002_usdc.svg"),
Png: some("https://raw.githubusercontent.com/cosmos/chain-registry/master/_non-cosmos/ethereum/images/usdc.png"),
Svg: some("https://raw.githubusercontent.com/cosmos/chain-registry/master/_non-cosmos/ethereum/images/usdc.svg"),
},
TypeAsset: TypeAsset_ICS20,
},
Expand All @@ -156,17 +156,17 @@ func TOKENS() []Token {
Display: "AXV",
Symbol: "AXV",
LogoURIs: &LogoURIs{
Png: some("./img/0003_astrovault-axv.png"),
Svg: some("./img/0003_astrovault-axv.svg"),
Png: some("https://raw.githubusercontent.com/cosmos/chain-registry/master/neutron/images/axv.png"),
Svg: some("https://raw.githubusercontent.com/cosmos/chain-registry/master/neutron/images/axv.svg"),
},
Images: []AssetImage{
{
ImageSync: &ImageSync{
ChainName: "neutron",
BaseDenom: "cw20:neutron10dxyft3nv4vpxh5vrpn0xw8geej8dw3g39g7nqp8mrm307ypssksau29af",
},
Png: some("./img/0003_astrovault-axv.png"),
Svg: some("./img/0003_astrovault-axv.svg"),
Png: some("https://raw.githubusercontent.com/cosmos/chain-registry/master/neutron/images/axv.png"),
Svg: some("https://raw.githubusercontent.com/cosmos/chain-registry/master/neutron/images/axv.svg"),
},
},
TypeAsset: TypeAsset_SDKCoin,
Expand All @@ -190,11 +190,11 @@ func TOKENS() []Token {
Display: "xNIBI",
Symbol: "xNIBI",
LogoURIs: &LogoURIs{
Svg: some("./img/0004_astrovault-xnibi.svg"),
Svg: some("./img/004_astrovault-xnibi.svg"),
},
Images: []AssetImage{
{
Svg: some("./img/0004_astrovault-xnibi.svg"),
Svg: some("./img/004_astrovault-xnibi.svg"),
},
},
},
Expand Down
File renamed without changes.
109 changes: 96 additions & 13 deletions token-registry/githubify.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package tokenregistry

import "strings"

// GitHubify replaces local image paths with GitHub raw URLs.
//
// Example: "./img/token.png" → "https://raw.githubusercontent.com/NibiruChain/nibiru/main/token-registry/img/token.png"
func (t Token) GitHubify() Token {
out := t

Expand All @@ -16,42 +19,49 @@ func (t Token) GitHubify() Token {
return out
}

// localImageToGitHub converts a path to a local image into a GitHub download
// LocalImageToGitHub converts a path to a local image into a GitHub download
// link in the NibiruChain/nibiru repository.
func localImageToGitHub(local string) string {
trimmed := strings.TrimPrefix(local, "./img/")
func LocalImageToGitHub(local string) string {
prefix := "./img/"
trimmed := strings.TrimPrefix(local, prefix)
return "https://raw.githubusercontent.com/NibiruChain/nibiru/main/token-registry/img/" + trimmed
}

// isLocalImage returns true if an image URI is meant for a local file in
// IsLocalImage returns true if an image URI is meant for a local file in
// the "token-registry/img" directory.
func isLocalImage(maybeLocal *string) bool {
func IsLocalImage(maybeLocal *string) bool {
if maybeLocal == nil {
return false
}
return strings.HasPrefix(*maybeLocal, "./img")
}

// GitHubify replaces local image paths with GitHub raw URLs.
//
// Example: "./img/token.png" → "https://raw.githubusercontent.com/NibiruChain/nibiru/main/token-registry/img/token.png"
func (logouris LogoURIs) GitHubify() *LogoURIs {
out := new(LogoURIs)
out.Png, out.Svg = logouris.Png, logouris.Svg
if logouris.Png != nil && isLocalImage(logouris.Png) {
out.Png = some(localImageToGitHub(*logouris.Png))
if logouris.Png != nil && IsLocalImage(logouris.Png) {
out.Png = some(LocalImageToGitHub(*logouris.Png))
}
if logouris.Svg != nil && isLocalImage(logouris.Svg) {
out.Svg = some(localImageToGitHub(*logouris.Svg))
if logouris.Svg != nil && IsLocalImage(logouris.Svg) {
out.Svg = some(LocalImageToGitHub(*logouris.Svg))
}
return out
}

// GitHubify replaces local image paths with GitHub raw URLs.
//
// Example: "./img/token.png" → "https://raw.githubusercontent.com/NibiruChain/nibiru/main/token-registry/img/token.png"
func (ai AssetImage) GitHubify() AssetImage {
out := AssetImage{}
out.Png, out.Svg = ai.Png, ai.Svg
if ai.Png != nil && isLocalImage(ai.Png) {
out.Png = some(localImageToGitHub(*ai.Png))
if ai.Png != nil && IsLocalImage(ai.Png) {
out.Png = some(LocalImageToGitHub(*ai.Png))
}
if ai.Svg != nil && isLocalImage(ai.Svg) {
out.Svg = some(localImageToGitHub(*ai.Svg))
if ai.Svg != nil && IsLocalImage(ai.Svg) {
out.Svg = some(LocalImageToGitHub(*ai.Svg))
}
if ai.Theme != nil {
out.Theme = ai.Theme
Expand All @@ -61,3 +71,76 @@ func (ai AssetImage) GitHubify() AssetImage {
}
return out
}

// GitHubImageToLocal converts a GitHub raw image URL into a local image path.
func GitHubImageToLocal(githubURL string) string {
prefix := "https://raw.githubusercontent.com/NibiruChain/nibiru/main/token-registry/img/"
trimmed := strings.TrimPrefix(githubURL, prefix)
return "./img/" + trimmed
}

// IsGitHubImage returns true if an image URI is a GitHub raw URL from the
// NibiruChain/nibiru repository.
func IsGitHubImage(maybeGitHub *string) bool {
if maybeGitHub == nil {
return false
}
prefix := "https://raw.githubusercontent.com/NibiruChain/nibiru/main/token-registry/img/"
return strings.HasPrefix(*maybeGitHub, prefix)
}

// GitHubifyReverse replaces GitHub raw URLs with local image paths.
//
// Example:
// "https://raw.githubusercontent.com/NibiruChain/nibiru/main/token-registry/img/token.png" → "./img/token.png"
func (logouris LogoURIs) GitHubifyReverse() *LogoURIs {
out := new(LogoURIs)
out.Png, out.Svg = logouris.Png, logouris.Svg
if logouris.Png != nil && IsGitHubImage(logouris.Png) {
out.Png = some(GitHubImageToLocal(*logouris.Png))
}
if logouris.Svg != nil && IsGitHubImage(logouris.Svg) {
out.Svg = some(GitHubImageToLocal(*logouris.Svg))
}
return out
}

// GitHubifyReverse replaces GitHub raw URLs with local image paths.
//
// Example:
// "https://raw.githubusercontent.com/NibiruChain/nibiru/main/token-registry/img/token.png" → "./img/token.png"
func (ai AssetImage) GitHubifyReverse() AssetImage {
out := AssetImage{}
out.Png, out.Svg = ai.Png, ai.Svg
if ai.Png != nil && IsGitHubImage(ai.Png) {
out.Png = some(GitHubImageToLocal(*ai.Png))
}
if ai.Svg != nil && IsGitHubImage(ai.Svg) {
out.Svg = some(GitHubImageToLocal(*ai.Svg))
}
if ai.Theme != nil {
out.Theme = ai.Theme
}
if ai.ImageSync != nil {
out.ImageSync = ai.ImageSync
}
return out
}

// GitHubifyReverse replaces GitHub raw URLs with local image paths.
//
// Example:
// "https://raw.githubusercontent.com/NibiruChain/nibiru/main/token-registry/img/token.png" → "./img/token.png"
func (t Token) GitHubifyReverse() Token {
out := t

if out.LogoURIs != nil {
out.LogoURIs = out.LogoURIs.GitHubifyReverse()
}

for imgIdx, img := range out.Images {
out.Images[imgIdx] = img.GitHubifyReverse()
}

return out
}
Binary file added token-registry/img/000_nibiru-evm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit eb64da0

Please sign in to comment.