@chain-registry/utils 1.15.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/main/asset-list-util.js +33 -4
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.16.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.15.0...@chain-registry/utils@1.16.0) (2023-12-15)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* add getCoinGeckoIdByDenom method ([b05e67b](https://github.com/cosmology-tech/chain-registry/commit/b05e67b4b54258412d359745b1cd095987c67eb6))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [1.15.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@1.14.0...@chain-registry/utils@1.15.0) (2023-12-15)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @chain-registry/utils
|
package/main/asset-list-util.js
CHANGED
|
@@ -10,6 +10,7 @@ exports.convertCoinGeckoPricesToDenomPriceMap = convertCoinGeckoPricesToDenomPri
|
|
|
10
10
|
exports.convertDollarValueToDenomUnits = convertDollarValueToDenomUnits;
|
|
11
11
|
exports.getAssetByDenom = getAssetByDenom;
|
|
12
12
|
exports.getChainDenomBySymbol = getChainDenomBySymbol;
|
|
13
|
+
exports.getCoinGeckoIdByDenom = getCoinGeckoIdByDenom;
|
|
13
14
|
exports.getDenomByCoinGeckoId = getDenomByCoinGeckoId;
|
|
14
15
|
exports.getExponentByDenom = getExponentByDenom;
|
|
15
16
|
exports.getSymbolByChainDenom = getSymbolByChainDenom;
|
|
@@ -29,6 +30,34 @@ function getDenomByCoinGeckoId(assets, coinGeckoId) {
|
|
|
29
30
|
return asset.coingecko_id === coinGeckoId;
|
|
30
31
|
}).base;
|
|
31
32
|
}
|
|
33
|
+
function getCoinGeckoIdByDenom(assets, denom) {
|
|
34
|
+
var _asset$coingecko_id;
|
|
35
|
+
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
36
|
+
_ref$allowTestnet = _ref.allowTestnet,
|
|
37
|
+
allowTestnet = _ref$allowTestnet === void 0 ? false : _ref$allowTestnet,
|
|
38
|
+
_ref$customAssetFilte = _ref.customAssetFilter,
|
|
39
|
+
customAssetFilter = _ref$customAssetFilte === void 0 ? function () {
|
|
40
|
+
return true;
|
|
41
|
+
} : _ref$customAssetFilte,
|
|
42
|
+
_ref$excludedChainNam = _ref.excludedChainNames,
|
|
43
|
+
excludedChainNames = _ref$excludedChainNam === void 0 ? [] : _ref$excludedChainNam;
|
|
44
|
+
var filteredAssetLists = assets.filter(function (_ref2) {
|
|
45
|
+
var chain_name = _ref2.chain_name;
|
|
46
|
+
return (allowTestnet || !chain_name.includes('testnet')) && !excludedChainNames.includes(chain_name);
|
|
47
|
+
});
|
|
48
|
+
var filteredAssets = filteredAssetLists.flatMap(function (_ref3) {
|
|
49
|
+
var assets = _ref3.assets;
|
|
50
|
+
return assets;
|
|
51
|
+
}).filter(function (_ref4) {
|
|
52
|
+
var coingecko_id = _ref4.coingecko_id;
|
|
53
|
+
return coingecko_id;
|
|
54
|
+
}).filter(customAssetFilter);
|
|
55
|
+
var asset = filteredAssets.find(function (_ref5) {
|
|
56
|
+
var base = _ref5.base;
|
|
57
|
+
return base === denom;
|
|
58
|
+
});
|
|
59
|
+
return (_asset$coingecko_id = asset === null || asset === void 0 ? void 0 : asset.coingecko_id) !== null && _asset$coingecko_id !== void 0 ? _asset$coingecko_id : null;
|
|
60
|
+
}
|
|
32
61
|
function getSymbolByChainDenom(assets, denom) {
|
|
33
62
|
var asset = getAssetByDenom(assets, denom);
|
|
34
63
|
var symbol = asset.symbol;
|
|
@@ -38,8 +67,8 @@ function getSymbolByChainDenom(assets, denom) {
|
|
|
38
67
|
return symbol;
|
|
39
68
|
}
|
|
40
69
|
function getChainDenomBySymbol(assets, token) {
|
|
41
|
-
var asset = assets.find(function (
|
|
42
|
-
var symbol =
|
|
70
|
+
var asset = assets.find(function (_ref6) {
|
|
71
|
+
var symbol = _ref6.symbol;
|
|
43
72
|
return symbol === token;
|
|
44
73
|
});
|
|
45
74
|
var base = asset === null || asset === void 0 ? void 0 : asset.base;
|
|
@@ -51,8 +80,8 @@ function getChainDenomBySymbol(assets, token) {
|
|
|
51
80
|
}
|
|
52
81
|
function getExponentByDenom(assets, denom) {
|
|
53
82
|
var asset = getAssetByDenom(assets, denom);
|
|
54
|
-
var unit = asset.denom_units.find(function (
|
|
55
|
-
var denom =
|
|
83
|
+
var unit = asset.denom_units.find(function (_ref7) {
|
|
84
|
+
var denom = _ref7.denom;
|
|
56
85
|
return denom === asset.display;
|
|
57
86
|
});
|
|
58
87
|
return (unit === null || unit === void 0 ? void 0 : unit.exponent) || 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chain-registry/utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "Chain Registry Utils",
|
|
5
5
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/cosmology-tech/chain-registry",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"bignumber.js": "9.1.1",
|
|
78
78
|
"sha.js": "^2.4.11"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "1fe81f4f767d431be5b8f870d9bea98e9cef6bab"
|
|
81
81
|
}
|