Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: hyperweb-io/chain-registry
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: chain-registry@1.24.1
Choose a base ref
...
head repository: hyperweb-io/chain-registry
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: chain-registry@1.25.0
Choose a head ref
  • 8 commits
  • 25 files changed
  • 2 contributors

Commits on Dec 18, 2023

  1. Copy the full SHA
    d415f33 View commit details

Commits on Dec 19, 2023

  1. spacing

    pyramation committed Dec 19, 2023
    Copy the full SHA
    baa8d1c View commit details
  2. add client tests

    pyramation committed Dec 19, 2023
    Copy the full SHA
    693050e View commit details
  3. Copy the full SHA
    24aa0b8 View commit details

Commits on Dec 20, 2023

  1. clean up names

    marslavish committed Dec 20, 2023
    Copy the full SHA
    f3c8fe8 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    071e0cc View commit details
  3. Merge pull request #59 from cosmology-tech/fix/optional-param

    Add chainName as optional param to utils
    pyramation authored Dec 20, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6b8dec2 View commit details
  4. chore(release): publish

     - @chain-registry/assets@1.26.0
     - chain-registry@1.25.0
     - @chain-registry/client@1.18.0
     - @chain-registry/cosmostation@1.28.0
     - @chain-registry/juno@1.26.0
     - @chain-registry/keplr@1.30.0
     - @chain-registry/osmosis@1.26.0
     - @chain-registry/utils@1.17.0
    pyramation committed Dec 20, 2023
    Copy the full SHA
    c8644d2 View commit details
8 changes: 8 additions & 0 deletions packages/assets/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.26.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/assets@1.25.1...@chain-registry/assets@1.26.0) (2023-12-20)

**Note:** Version bump only for package @chain-registry/assets





## [1.25.1](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/assets@1.25.0...@chain-registry/assets@1.25.1) (2023-12-15)

**Note:** Version bump only for package @chain-registry/assets
6 changes: 3 additions & 3 deletions packages/assets/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@chain-registry/assets",
"version": "1.25.1",
"version": "1.26.0",
"description": "Chain Registry Asset Lists",
"author": "Dan Lynch <pyramation@gmail.com>",
"homepage": "https://github.com/cosmology-tech/chain-registry",
@@ -49,14 +49,14 @@
"@babel/plugin-transform-runtime": "7.21.4",
"@babel/preset-env": "7.21.4",
"@babel/preset-typescript": "^7.21.4",
"@chain-registry/utils": "^1.16.1",
"@chain-registry/utils": "^1.17.0",
"@types/jest": "^29.5.1",
"@typescript-eslint/eslint-plugin": "5.59.0",
"@typescript-eslint/parser": "5.59.0",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "29.5.0",
"babel-watch": "^7.7.2",
"chain-registry": "^1.24.1",
"chain-registry": "^1.25.0",
"cross-env": "^7.0.2",
"eslint": "8.38.0",
"eslint-config-prettier": "^8.8.0",
8 changes: 8 additions & 0 deletions packages/chain-registry/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.25.0](https://github.com/cosmology-tech/chain-registry/compare/chain-registry@1.24.1...chain-registry@1.25.0) (2023-12-20)

**Note:** Version bump only for package chain-registry





## [1.24.1](https://github.com/cosmology-tech/chain-registry/compare/chain-registry@1.24.0...chain-registry@1.24.1) (2023-12-15)

**Note:** Version bump only for package chain-registry
4 changes: 2 additions & 2 deletions packages/chain-registry/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chain-registry",
"version": "1.24.1",
"version": "1.25.0",
"description": "Cosmos chain registry ⚛️",
"author": "Dan Lynch <pyramation@gmail.com>",
"homepage": "https://github.com/cosmology-tech/chain-registry/tree/master/packages/chain-registry#readme",
@@ -48,7 +48,7 @@
"@babel/plugin-transform-runtime": "7.21.4",
"@babel/preset-env": "7.21.4",
"@babel/preset-typescript": "^7.21.4",
"@chain-registry/utils": "^1.16.1",
"@chain-registry/utils": "^1.17.0",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "10.1.0",
"cross-env": "^7.0.2",
8 changes: 8 additions & 0 deletions packages/client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.18.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/client@1.17.1...@chain-registry/client@1.18.0) (2023-12-20)

**Note:** Version bump only for package @chain-registry/client





## [1.17.1](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/client@1.17.0...@chain-registry/client@1.17.1) (2023-12-15)

**Note:** Version bump only for package @chain-registry/client
6 changes: 3 additions & 3 deletions packages/client/README.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion packages/client/__tests__/client-mock.test.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
86 changes: 86 additions & 0 deletions packages/client/__tests__/client.api.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { assets, chains } from 'chain-registry';

import {
ChainRegistryChainUtil,
ChainRegistryChainUtilOptions,
ChainRegistryClient,
ChainRegistryClientOptions
} from '../src';

describe('tests for asset-list-util', () => {
const assetLists = assets.filter(
({ chain_name }) => chain_name === 'osmosis'
);
const chainInfos = chains.filter(
({ chain_name }) => chain_name === 'osmosis'
);

const regOptions: ChainRegistryClientOptions = {
chainNames: ['osmosis'],
chains: chainInfos,
assetLists
};

const regClient = new ChainRegistryClient(regOptions);
const chainInfo = regClient.getChainInfo('osmosis');
const options: ChainRegistryChainUtilOptions = {
chainInfo,
chainName: 'osmosis'
};
const client = new ChainRegistryChainUtil(options);

it('getAssetByDenom', () => {
const asset = client.getAssetByDenom('uosmo');
expect(asset.base).toEqual('uosmo');
});

it('getDenomByCoinGeckoId', () => {
const denom1 = client.getDenomByCoinGeckoId('osmosis');
expect(denom1).toEqual('uosmo');
const denom2 = client.getDenomByCoinGeckoId('ion');
expect(denom2).toEqual('uion');
});

it('getSymbolByChainDenom', () => {
const denom1 = client.getSymbolByChainDenom('uosmo');
expect(denom1).toEqual('OSMO');
const denom2 = client.getSymbolByChainDenom('uion');
expect(denom2).toEqual('ION');
});

it('getChainDenomBySymbol', () => {
const denom1 = client.getChainDenomBySymbol('OSMO');
expect(denom1).toEqual('uosmo');
const denom2 = client.getChainDenomBySymbol('ION');
expect(denom2).toEqual('uion');
});

it('getExponentByDenom', () => {
const exponent = client.getExponentByDenom('uosmo');
expect(exponent).toEqual(6);
});

it('convertBaseUnitsToDollarValue', () => {
const value = client.convertBaseUnitsToDollarValue({ uosmo: 1 }, 'OSMO', 5);
expect(value).toEqual('0.000005');
});

it('convertDollarValueToDenomUnits', () => {
const value = client.convertDollarValueToDenomUnits(
{ uosmo: 1 },
'OSMO',
0.00001
);
expect(value).toEqual('10');
});

it('convertBaseUnitsToDisplayUnits', () => {
const value = client.convertBaseUnitsToDisplayUnits('OSMO', 99);
expect(value).toEqual('0.000099');
});

it('uosmo coingecko id', () => {
const id = client.getCoinGeckoIdByDenom('uosmo');
expect(id).toEqual('osmosis');
});
});
2 changes: 1 addition & 1 deletion packages/client/__tests__/fetcher.test.ts
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 2 additions & 2 deletions packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@chain-registry/client",
"version": "1.17.1",
"version": "1.18.0",
"description": "Chain Registry Client",
"author": "Dan Lynch <pyramation@gmail.com>",
"homepage": "https://github.com/cosmology-tech/chain-registry",
@@ -76,7 +76,7 @@
"dependencies": {
"@babel/runtime": "^7.21.0",
"@chain-registry/types": "^0.17.1",
"@chain-registry/utils": "^1.16.1",
"@chain-registry/utils": "^1.17.0",
"bfs-path": "^1.0.2",
"cross-fetch": "^3.1.5"
}
2 changes: 1 addition & 1 deletion packages/client/src/chain-info.ts
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ export class ChainInfo {
get chain() {
return this._chain;
}
get nativeAssetLists() {
get nativeAssetList() {
return this._assetList;
}
get assetLists() {
63 changes: 45 additions & 18 deletions packages/client/src/chain-util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Asset } from '@chain-registry/types';
import { Asset, AssetList } from '@chain-registry/types';
import type {
CoinDenom,
CoinGeckoUSD,
@@ -12,6 +12,7 @@ import {
convertDollarValueToDenomUnits,
getAssetByDenom,
getChainDenomBySymbol,
getCoinGeckoIdByDenom,
getDenomByCoinGeckoId,
getExponentByDenom,
getSymbolByChainDenom,
@@ -28,44 +29,53 @@ export interface ChainRegistryChainUtilOptions {
export class ChainRegistryChainUtil {
chainName: string;
chainInfo: ChainInfo;
allAsset: Asset[];

private _assets: AssetList[] = [];

constructor(options: ChainRegistryChainUtilOptions) {
this.chainName = options.chainName;
this.chainInfo = options.chainInfo;
this.allAsset = this.chainInfo.assetLists.reduce(
(m, it) => {
[].push.apply(m, it.assets);
return m;
},
[...this.chainInfo.nativeAssetLists.assets]
);
this._assets = [
{
assets: [
...this.chainInfo.nativeAssetList.assets,
...this.chainInfo.assetLists.flatMap(({ assets }) => assets)
],
chain_name: this.chainName
}
];
}

getAssetByDenom(denom: CoinDenom): Asset {
return getAssetByDenom(this.allAsset, denom);
return getAssetByDenom(this._assets, denom, this.chainName);
}

getDenomByCoinGeckoId(coinGeckoId: string): CoinDenom {
return getDenomByCoinGeckoId(this.allAsset, coinGeckoId);
return getDenomByCoinGeckoId(this._assets, coinGeckoId, this.chainName);
}

getCoinGeckoIdByDenom(coinGeckoId: string): CoinDenom {
return getCoinGeckoIdByDenom(this._assets, coinGeckoId, {
chainName: this.chainName
});
}

getSymbolByChainDenom(denom: CoinDenom): string {
return getSymbolByChainDenom(this.allAsset, denom);
return getSymbolByChainDenom(this._assets, denom, this.chainName);
}

getChainDenomBySymbol(token: string): CoinDenom {
return getChainDenomBySymbol(this.allAsset, token);
return getChainDenomBySymbol(this._assets, token, this.chainName);
}

getExponentByDenom(denom: CoinDenom): Exponent {
return getExponentByDenom(this.allAsset, denom);
return getExponentByDenom(this._assets, denom, this.chainName);
}

convertCoinGeckoPricesToDenomPriceMap(
prices: Record<string, CoinGeckoUSD>
): PriceHash {
return convertCoinGeckoPricesToDenomPriceMap(this.allAsset, prices);
return convertCoinGeckoPricesToDenomPriceMap(this._assets, prices);
}

noDecimals(num: number | string): string {
@@ -77,21 +87,38 @@ export class ChainRegistryChainUtil {
symbol: string,
amount: string | number
): string {
return convertBaseUnitsToDollarValue(this.allAsset, prices, symbol, amount);
return convertBaseUnitsToDollarValue(
this._assets,
prices,
symbol,
amount,
this.chainName
);
}

convertDollarValueToDenomUnits(
prices: PriceHash,
symbol: string,
value: string | number
): string {
return convertDollarValueToDenomUnits(this.allAsset, prices, symbol, value);
return convertDollarValueToDenomUnits(
this._assets,
prices,
symbol,
value,
this.chainName
);
}

convertBaseUnitsToDisplayUnits(
symbol: string,
amount: string | number
): string {
return convertBaseUnitsToDisplayUnits(this.allAsset, symbol, amount);
return convertBaseUnitsToDisplayUnits(
this._assets,
symbol,
amount,
this.chainName
);
}
}
8 changes: 8 additions & 0 deletions packages/cosmostation/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.28.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/cosmostation@1.27.1...@chain-registry/cosmostation@1.28.0) (2023-12-20)

**Note:** Version bump only for package @chain-registry/cosmostation





## [1.27.1](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/cosmostation@1.27.0...@chain-registry/cosmostation@1.27.1) (2023-12-15)

**Note:** Version bump only for package @chain-registry/cosmostation
6 changes: 3 additions & 3 deletions packages/cosmostation/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@chain-registry/cosmostation",
"version": "1.27.1",
"version": "1.28.0",
"description": "Chain Registry to Cosmostation",
"author": "Dan Lynch <pyramation@gmail.com>",
"homepage": "https://github.com/cosmology-tech/chain-registry",
@@ -57,7 +57,7 @@
"babel-core": "7.0.0-bridge.0",
"babel-jest": "29.5.0",
"babel-watch": "^7.7.2",
"chain-registry": "^1.24.1",
"chain-registry": "^1.25.0",
"cross-env": "^7.0.2",
"eslint": "8.38.0",
"eslint-config-prettier": "^8.8.0",
@@ -73,7 +73,7 @@
"dependencies": {
"@babel/runtime": "^7.21.0",
"@chain-registry/types": "^0.17.1",
"@chain-registry/utils": "^1.16.1",
"@chain-registry/utils": "^1.17.0",
"@cosmostation/extension-client": "0.1.15"
}
}
Loading