Skip to content

Commit

Permalink
fix(token-registry): meet formatting requirements for cosmos/chain-re…
Browse files Browse the repository at this point in the history
…gistry.

1. Add missing "address" field for the xNIBI token with type_asset "cw20"
2. Generate raw.githubusercontent URIs pointing to cosmos/chain-registry
  • Loading branch information
Unique-Divine committed Jan 7, 2025
1 parent 8c6e021 commit 7aebf75
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
2 changes: 1 addition & 1 deletion eth/rpc/backend/backend_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func (s *BackendSuite) buildContractCreationTx(nonce uint64) gethcore.Transactio

// buildContractCallTx builds a contract call transaction
func (s *BackendSuite) buildContractCallTx(nonce uint64, contractAddr gethcommon.Address) gethcore.Transaction {
//recipient := crypto.CreateAddress(s.fundedAccEthAddr, 29381)
// recipient := crypto.CreateAddress(s.fundedAccEthAddr, 29381)
transferAmount := big.NewInt(100)

packedArgs, err := embeds.SmartContract_TestERC20.ABI.Pack(
Expand Down
9 changes: 9 additions & 0 deletions token-registry/assetlist.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package tokenregistry

import "bytes"

func NibiruAssetList() AssetList {
var tokens = TOKENS()
for idx, token := range tokens {
Expand All @@ -13,6 +15,12 @@ func NibiruAssetList() AssetList {
}
}

func PointImagesToCosmosChainRegistry(assetListJson []byte) (out []byte) {
oldImgPath := []byte("raw.githubusercontent.com/NibiruChain/nibiru/main/token-registry/img")
newImgPath := []byte("raw.githubusercontent.com/cosmos/chain-registry/master/nibiru/images")
return bytes.ReplaceAll(assetListJson, oldImgPath, newImgPath)
}

func TOKENS() []Token {
return []Token{
{
Expand Down Expand Up @@ -168,6 +176,7 @@ func TOKENS() []Token {
Name: "Astrovault Nibiru LST (xNIBI)",
Description: "Astrovault Nibiru LST (xNIBI)",
TypeAsset: TypeAsset_CW20,
Address: some("nibi1cehpv50vl90g9qkwwny8mw7txw79zs6f7wsfe8ey7dgp238gpy4qhdqjhm"),
ExtendedDescription: some("xNIBI is a liquid staking derivative for NIBI created by Astrovault."),
Socials: &SocialLinks{
Website: some("https://astrovault.io/"),
Expand Down
23 changes: 22 additions & 1 deletion token-registry/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func findRootPath() (string, error) {
}

const SAVE_PATH_ASSETLIST = "dist/assetlist.json"
const SAVE_PATH_COSMOS_ASSETLIST = "dist/cosmos-assetlist.json"

func main() {
assetList := tokenregistry.NibiruAssetList()
Expand Down Expand Up @@ -60,5 +61,25 @@ func main() {
return
}

fmt.Printf("✅ Generation complete! See %v\n", SAVE_PATH_ASSETLIST)
savePath = path.Join(rootPath, SAVE_PATH_COSMOS_ASSETLIST)
saveBz := tokenregistry.PointImagesToCosmosChainRegistry(prettyBz)
err = os.WriteFile(savePath, saveBz, perm)
if err != nil {
log.Error().Msg(err.Error())
return
}

fmt.Printf("✅ Generation complete!\n")
fmt.Printf(
"File \"%v\" contains the asset list using images only from the Nibiru repo\n",
SAVE_PATH_ASSETLIST,
)
fmt.Printf(
"File \"%v\" contains the asset list for the cosmos/chain-registry\n",
SAVE_PATH_COSMOS_ASSETLIST,
)
fmt.Println("You can submit a PR to cosmos/chain-registry using " +
SAVE_PATH_COSMOS_ASSETLIST +
" as the file chain-registry/nibiru/assetlist.json",
)
}
6 changes: 4 additions & 2 deletions token-registry/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ func some[T any](v T) *T {
}

type Token struct {
// The human-readable name of the asset
Name string `json:"name"`
// A short description of the asset
Description string `json:"description"`
// Contract address for the token. Required for [TypeAsset] "erc20" and "cw20".
Address *string `json:"address,omitempty"`
// An extended, detailed description of the asset (optional)
ExtendedDescription *string `json:"extended_description,omitempty"`
// Links to social platforms and official websites (optional)
Expand All @@ -20,8 +24,6 @@ type Token struct {
DenomUnits []DenomUnit `json:"denom_units"`
// The base denomination for the asset (canonical name)
Base string `json:"base"`
// The human-readable name of the asset
Name string `json:"name"`
// The display name or symbol used in UI for the asset
Display string `json:"display"`
// The ticker or symbol of the asset
Expand Down

0 comments on commit 7aebf75

Please sign in to comment.