diff --git a/.github/workflows/utility/chain_registry.mjs b/.github/workflows/utility/chain_registry.mjs index 1908b61..24df811 100644 --- a/.github/workflows/utility/chain_registry.mjs +++ b/.github/workflows/utility/chain_registry.mjs @@ -192,7 +192,6 @@ export function setFileProperty(chainName, file, property, value) { let json = readJsonFile(filePath); json[property] = value; writeJsonFile(filePath, json); - return; } } } @@ -218,13 +217,8 @@ export function getIBCFileProperty(chainName1, chainName2, property) { export function getAssetProperty(chainName, baseDenom, property) { const assets = getFileProperty(chainName, "assetlist", "assets"); if(assets) { - let selectedAsset; - assets.forEach((asset) => { - if(asset.base == baseDenom) { - selectedAsset = asset; - return; - } - }); + const selectedAsset = assets.find(asset => asset.base === baseDenom); + if(selectedAsset) { return selectedAsset[property]; } @@ -234,13 +228,11 @@ export function getAssetProperty(chainName, baseDenom, property) { export function setAssetProperty(chainName, baseDenom, property, value) { const assets = getFileProperty(chainName, "assetlist", "assets"); if(assets) { - assets.forEach((asset) => { - if(asset.base == baseDenom) { - asset[property] = value; - setFileProperty(chainName, "assetlist", "assets", assets); - return; - } - }); + const asset = assets.find(asset => asset.base === baseDenom); + if (asset) { + asset[property] = value; + setFileProperty(chainName, "assetlist", "assets", assets); + } } } diff --git a/.github/workflows/utility/sync_images.mjs b/.github/workflows/utility/sync_images.mjs index 2f001a0..211eee1 100644 --- a/.github/workflows/utility/sync_images.mjs +++ b/.github/workflows/utility/sync_images.mjs @@ -52,9 +52,6 @@ // // write changes to chain_reg - -import * as fs from 'fs'; -import * as path from 'path'; import * as chain_reg from './chain_registry.mjs'; function createImagesArray(){ @@ -63,7 +60,6 @@ function createImagesArray(){ // get list of assets, iterate each asset // record the logo_URIs and images properties - let chainFiles = []; let newImageContainingObject; let chains = chain_reg.getChains(); @@ -80,7 +76,7 @@ function createImagesArray(){ logo_URIs: logo_URIs, images: images, hasUpdated: false - } + }; //console.log(imageContainingObject); newImageContainingObject = compareImages(imageContainingObject); @@ -107,7 +103,7 @@ function createImagesArray(){ logo_URIs: logo_URIs, images: images, hasUpdated: false - } + }; //console.log(imageContainingObject); newImageContainingObject = compareImages(imageContainingObject); @@ -260,7 +256,7 @@ function overwriteLogoURIs(chain_name, base_denom){ let logo_URIs = { png: images?.[0]?.png, svg: images?.[0]?.svg - } + }; if(images) { if(images[0].png || images[0].svg) { chain_reg.setFileProperty(chainName, "chain", "logo_URIs", logo_URIs); @@ -274,7 +270,7 @@ function overwriteLogoURIs(chain_name, base_denom){ let logo_URIs = { png: images?.[0]?.png, svg: images?.[0]?.svg - } + }; if(images) { if(images[0].png || images[0].svg) { chain_reg.setAssetProperty(assetPointer.chain_name, assetPointer.base_denom, "logo_URIs", logo_URIs); @@ -290,4 +286,4 @@ function main(){ overwriteLogoURIs(); } -main() \ No newline at end of file +main(); \ No newline at end of file diff --git a/_packages/initia-registry/README.md b/_packages/initia-registry/README.md index 384d16b..89ab27b 100644 --- a/_packages/initia-registry/README.md +++ b/_packages/initia-registry/README.md @@ -11,7 +11,7 @@ npm install @initia/initia-registry Fetch data from initia-registry: ```typescript -import { assets, chains, ibc } from "@intiia/initia-registry"; +import { assets, chains, ibc } from "@initia/initia-registry"; import { Chain } from "@initia/initia-registry-types"; const assetList: Chain = assets.find( diff --git a/_packages/types/src/types/Chain.ts b/_packages/types/src/types/Chain.ts index f5fa61e..96bcb76 100644 --- a/_packages/types/src/types/Chain.ts +++ b/_packages/types/src/types/Chain.ts @@ -170,12 +170,9 @@ export interface Chain { }[]; }; images?: ( - | { + { [k: string]: unknown; - } - | { - [k: string]: unknown; - } + } )[]; logo_URIs?: { png?: string;