diff --git a/packages/client/README.md b/packages/client/README.md index d2621d24..edc828a9 100644 --- a/packages/client/README.md +++ b/packages/client/README.md @@ -87,13 +87,13 @@ or get the `ChainInfo` object: const chainInfo: ChainInfo = registry.getChainInfo('osmosis'); // AssetList[] of the generated assets -const assetes: AssetList[] = chainInfo.assetLists; +const assets: AssetList[] = chainInfo.assetLists; // Chain const chain: Chain = chainInfo.chain; -// AssetList[] of the native assets -const assetes: AssetList[] = chainInfo.nativeAssetLists; +// Native asset list +const nativeAssetList: AssetList = chainInfo.nativeAssetList; ``` ## Related diff --git a/packages/client/__tests__/client-mock.test.ts b/packages/client/__tests__/client-mock.test.ts index 7e6ceef8..3d8615d5 100644 --- a/packages/client/__tests__/client-mock.test.ts +++ b/packages/client/__tests__/client-mock.test.ts @@ -75,6 +75,6 @@ describe('Test client', () => { it('Test mock fetching asset list', () => { const chainInfo = client.getChainInfo('osmosis'); - expect(chainInfo.nativeAssetLists.assets.length).toEqual(1); + expect(chainInfo.nativeAssetList.assets.length).toEqual(1); }); }); diff --git a/packages/client/__tests__/fetcher.test.ts b/packages/client/__tests__/fetcher.test.ts index cab9f5f2..fef49193 100644 --- a/packages/client/__tests__/fetcher.test.ts +++ b/packages/client/__tests__/fetcher.test.ts @@ -44,7 +44,7 @@ describe('Test fetcher', () => { expect(chainInfo.chain).toEqual(osmosis); const osmosisAssets = fetcher.getChainAssetList('osmosis'); - expect(chainInfo.nativeAssetLists).toEqual(osmosisAssets); + expect(chainInfo.nativeAssetList).toEqual(osmosisAssets); const num = osmosisAssets.assets.length; const numGenerated = generated[0].assets.length; diff --git a/packages/client/src/chain-info.ts b/packages/client/src/chain-info.ts index c61b8841..64460473 100644 --- a/packages/client/src/chain-info.ts +++ b/packages/client/src/chain-info.ts @@ -43,7 +43,7 @@ export class ChainInfo { get chain() { return this._chain; } - get nativeAssetLists() { + get nativeAssetList() { return this._assetList; } get assetLists() { diff --git a/packages/client/src/chain-util.ts b/packages/client/src/chain-util.ts index 04274737..c07c7c39 100644 --- a/packages/client/src/chain-util.ts +++ b/packages/client/src/chain-util.ts @@ -29,15 +29,16 @@ export interface ChainRegistryChainUtilOptions { export class ChainRegistryChainUtil { chainName: string; chainInfo: ChainInfo; - allAsset: AssetList[]; + + private _assets: AssetList[] = []; constructor(options: ChainRegistryChainUtilOptions) { this.chainName = options.chainName; this.chainInfo = options.chainInfo; - this.allAsset = [ + this._assets = [ { assets: [ - ...this.chainInfo.nativeAssetLists.assets, + ...this.chainInfo.nativeAssetList.assets, ...this.chainInfo.assetLists.flatMap(({ assets }) => assets) ], chain_name: this.chainName @@ -46,35 +47,35 @@ export class ChainRegistryChainUtil { } getAssetByDenom(denom: CoinDenom): Asset { - return getAssetByDenom(this.allAsset, denom, this.chainName); + return getAssetByDenom(this._assets, denom, this.chainName); } getDenomByCoinGeckoId(coinGeckoId: string): CoinDenom { - return getDenomByCoinGeckoId(this.allAsset, coinGeckoId, this.chainName); + return getDenomByCoinGeckoId(this._assets, coinGeckoId, this.chainName); } getCoinGeckoIdByDenom(coinGeckoId: string): CoinDenom { - return getCoinGeckoIdByDenom(this.allAsset, coinGeckoId, { + return getCoinGeckoIdByDenom(this._assets, coinGeckoId, { chainName: this.chainName }); } getSymbolByChainDenom(denom: CoinDenom): string { - return getSymbolByChainDenom(this.allAsset, denom, this.chainName); + return getSymbolByChainDenom(this._assets, denom, this.chainName); } getChainDenomBySymbol(token: string): CoinDenom { - return getChainDenomBySymbol(this.allAsset, token, this.chainName); + return getChainDenomBySymbol(this._assets, token, this.chainName); } getExponentByDenom(denom: CoinDenom): Exponent { - return getExponentByDenom(this.allAsset, denom, this.chainName); + return getExponentByDenom(this._assets, denom, this.chainName); } convertCoinGeckoPricesToDenomPriceMap( prices: Record ): PriceHash { - return convertCoinGeckoPricesToDenomPriceMap(this.allAsset, prices); + return convertCoinGeckoPricesToDenomPriceMap(this._assets, prices); } noDecimals(num: number | string): string { @@ -87,7 +88,7 @@ export class ChainRegistryChainUtil { amount: string | number ): string { return convertBaseUnitsToDollarValue( - this.allAsset, + this._assets, prices, symbol, amount, @@ -101,7 +102,7 @@ export class ChainRegistryChainUtil { value: string | number ): string { return convertDollarValueToDenomUnits( - this.allAsset, + this._assets, prices, symbol, value, @@ -114,7 +115,7 @@ export class ChainRegistryChainUtil { amount: string | number ): string { return convertBaseUnitsToDisplayUnits( - this.allAsset, + this._assets, symbol, amount, this.chainName