Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@chain-registry/utils

Package Overview
Dependencies
Maintainers
3
Versions
265
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chain-registry/utils - npm Package Compare versions

Comparing version 1.19.0 to 1.19.2

CHANGELOG.md

47

main/assets.js

@@ -7,3 +7,3 @@ "use strict";

exports.getTokenNameByDenom = exports.getTokenLogoByDenom = exports.getSymbolByDenom = exports.getNativeTokenByChainName = exports.getExponentFromAsset = exports.getExponentBySymbol = exports.getExponentByDenom = exports.getDenomBySymbol = exports.getDenomByCoinGeckoId = exports.getCoinGeckoIdByDenom = exports.getChainNameByDenom = exports.getChainLogo = exports.getAssetBySymbol = exports.getAssetByDenom = exports.customFind = void 0;
var customFind = function customFind(array, filterFn) {
var customFind = exports.customFind = function customFind(array, filterFn) {
var filteredItems = array.filter(filterFn);

@@ -16,3 +16,2 @@ var filterCount = filteredItems.length;

};
exports.customFind = customFind;
var getAssetByKeyValue = function getAssetByKeyValue(assets, key, value, chainName) {

@@ -30,16 +29,13 @@ var filteredAssets = assets.filter(function (_ref) {

};
var getAssetByDenom = function getAssetByDenom(assets, denom, chainName) {
var getAssetByDenom = exports.getAssetByDenom = function getAssetByDenom(assets, denom, chainName) {
return getAssetByKeyValue(assets, 'base', denom, chainName);
};
exports.getAssetByDenom = getAssetByDenom;
var getAssetBySymbol = function getAssetBySymbol(assets, symbol, chainName) {
var getAssetBySymbol = exports.getAssetBySymbol = function getAssetBySymbol(assets, symbol, chainName) {
return getAssetByKeyValue(assets, 'symbol', symbol, chainName);
};
exports.getAssetBySymbol = getAssetBySymbol;
var getDenomByCoinGeckoId = function getDenomByCoinGeckoId(assets, coinGeckoId, chainName) {
var getDenomByCoinGeckoId = exports.getDenomByCoinGeckoId = function getDenomByCoinGeckoId(assets, coinGeckoId, chainName) {
var _getAssetByKeyValue;
return (_getAssetByKeyValue = getAssetByKeyValue(assets, 'coingecko_id', coinGeckoId, chainName)) === null || _getAssetByKeyValue === void 0 ? void 0 : _getAssetByKeyValue.base;
};
exports.getDenomByCoinGeckoId = getDenomByCoinGeckoId;
var getCoinGeckoIdByDenom = function getCoinGeckoIdByDenom(assets, denom) {
var getCoinGeckoIdByDenom = exports.getCoinGeckoIdByDenom = function getCoinGeckoIdByDenom(assets, denom) {
var _ref3 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},

@@ -72,14 +68,11 @@ chainName = _ref3.chainName,

};
exports.getCoinGeckoIdByDenom = getCoinGeckoIdByDenom;
var getSymbolByDenom = function getSymbolByDenom(assets, denom, chainName) {
var getSymbolByDenom = exports.getSymbolByDenom = function getSymbolByDenom(assets, denom, chainName) {
var _getAssetByDenom;
return (_getAssetByDenom = getAssetByDenom(assets, denom, chainName)) === null || _getAssetByDenom === void 0 ? void 0 : _getAssetByDenom.symbol;
};
exports.getSymbolByDenom = getSymbolByDenom;
var getDenomBySymbol = function getDenomBySymbol(assets, symbol, chainName) {
var getDenomBySymbol = exports.getDenomBySymbol = function getDenomBySymbol(assets, symbol, chainName) {
var _getAssetByKeyValue2;
return (_getAssetByKeyValue2 = getAssetByKeyValue(assets, 'symbol', symbol, chainName)) === null || _getAssetByKeyValue2 === void 0 ? void 0 : _getAssetByKeyValue2.base;
};
exports.getDenomBySymbol = getDenomBySymbol;
var getExponentFromAsset = function getExponentFromAsset(asset) {
var getExponentFromAsset = exports.getExponentFromAsset = function getExponentFromAsset(asset) {
var _asset$denom_units$fi;

@@ -91,14 +84,11 @@ return (_asset$denom_units$fi = asset.denom_units.find(function (_ref8) {

};
exports.getExponentFromAsset = getExponentFromAsset;
var getExponentByDenom = function getExponentByDenom(assets, denom, chainName) {
var getExponentByDenom = exports.getExponentByDenom = function getExponentByDenom(assets, denom, chainName) {
var asset = getAssetByDenom(assets, denom, chainName);
return asset ? getExponentFromAsset(asset) : undefined;
};
exports.getExponentByDenom = getExponentByDenom;
var getExponentBySymbol = function getExponentBySymbol(assets, symbol, chainName) {
var getExponentBySymbol = exports.getExponentBySymbol = function getExponentBySymbol(assets, symbol, chainName) {
var asset = getAssetBySymbol(assets, symbol, chainName);
return asset ? getExponentFromAsset(asset) : undefined;
};
exports.getExponentBySymbol = getExponentBySymbol;
var getNativeTokenByChainName = function getNativeTokenByChainName(assets, chainName) {
var getNativeTokenByChainName = exports.getNativeTokenByChainName = function getNativeTokenByChainName(assets, chainName) {
var assetList = customFind(assets, function (assetList) {

@@ -109,19 +99,15 @@ return assetList.chain_name === chainName && !assetList.assets[0].base.startsWith('ibc/');

};
exports.getNativeTokenByChainName = getNativeTokenByChainName;
var getTokenLogoByDenom = function getTokenLogoByDenom(assets, denom, chainName) {
var getTokenLogoByDenom = exports.getTokenLogoByDenom = function getTokenLogoByDenom(assets, denom, chainName) {
var asset = getAssetByDenom(assets, denom, chainName);
return Object.values((asset === null || asset === void 0 ? void 0 : asset.logo_URIs) || {})[0];
};
exports.getTokenLogoByDenom = getTokenLogoByDenom;
var getChainLogo = function getChainLogo(assets, chainName) {
var getChainLogo = exports.getChainLogo = function getChainLogo(assets, chainName) {
var nativeToken = getNativeTokenByChainName(assets, chainName);
return Object.values((nativeToken === null || nativeToken === void 0 ? void 0 : nativeToken.logo_URIs) || {})[0];
};
exports.getChainLogo = getChainLogo;
var getTokenNameByDenom = function getTokenNameByDenom(assets, denom, chainName) {
var getTokenNameByDenom = exports.getTokenNameByDenom = function getTokenNameByDenom(assets, denom, chainName) {
var asset = getAssetByDenom(assets, denom, chainName);
return asset === null || asset === void 0 ? void 0 : asset.name;
};
exports.getTokenNameByDenom = getTokenNameByDenom;
var getChainNameByDenom = function getChainNameByDenom(assets, denom) {
var getChainNameByDenom = exports.getChainNameByDenom = function getChainNameByDenom(assets, denom) {
var _customFind;

@@ -141,3 +127,2 @@ var isIbcDenom = denom.startsWith('ibc/');

})) === null || _customFind === void 0 ? void 0 : _customFind.chain_name;
};
exports.getChainNameByDenom = getChainNameByDenom;
};

@@ -10,3 +10,3 @@ "use strict";

var _assets = require("./assets");
var mapCoinGeckoPricesToDenoms = function mapCoinGeckoPricesToDenoms(assets, prices) {
var mapCoinGeckoPricesToDenoms = exports.mapCoinGeckoPricesToDenoms = function mapCoinGeckoPricesToDenoms(assets, prices) {
return Object.keys(prices).reduce(function (res, geckoId) {

@@ -21,7 +21,5 @@ var denom = (0, _assets.getDenomByCoinGeckoId)(assets, geckoId);

};
exports.mapCoinGeckoPricesToDenoms = mapCoinGeckoPricesToDenoms;
var roundDown = function roundDown(value) {
var roundDown = exports.roundDown = function roundDown(value) {
return new _bignumber["default"](value).decimalPlaces(0, _bignumber["default"].ROUND_DOWN).toString();
};
exports.roundDown = roundDown;
var getAssetInfo = function getAssetInfo(assets, symbol, chainName) {

@@ -43,3 +41,3 @@ var asset = (0, _assets.getAssetBySymbol)(assets, symbol, chainName);

};
var convertBaseUnitToDollarValue = function convertBaseUnitToDollarValue(assets, prices, symbol, amount, chainName) {
var convertBaseUnitToDollarValue = exports.convertBaseUnitToDollarValue = function convertBaseUnitToDollarValue(assets, prices, symbol, amount, chainName) {
var _getAssetInfo = getAssetInfo(assets, symbol, chainName),

@@ -51,4 +49,3 @@ denom = _getAssetInfo.denom,

};
exports.convertBaseUnitToDollarValue = convertBaseUnitToDollarValue;
var convertDollarValueToBaseUnit = function convertDollarValueToBaseUnit(assets, prices, symbol, value, chainName) {
var convertDollarValueToBaseUnit = exports.convertDollarValueToBaseUnit = function convertDollarValueToBaseUnit(assets, prices, symbol, value, chainName) {
var _getAssetInfo2 = getAssetInfo(assets, symbol, chainName),

@@ -60,4 +57,3 @@ denom = _getAssetInfo2.denom,

};
exports.convertDollarValueToBaseUnit = convertDollarValueToBaseUnit;
var convertBaseUnitToDisplayUnit = function convertBaseUnitToDisplayUnit(assets, symbol, amount, chainName) {
var convertBaseUnitToDisplayUnit = exports.convertBaseUnitToDisplayUnit = function convertBaseUnitToDisplayUnit(assets, symbol, amount, chainName) {
var _getAssetInfo3 = getAssetInfo(assets, symbol, chainName),

@@ -67,8 +63,6 @@ exponent = _getAssetInfo3.exponent;

};
exports.convertBaseUnitToDisplayUnit = convertBaseUnitToDisplayUnit;
var convertDisplayUnitToBaseUnit = function convertDisplayUnitToBaseUnit(assets, symbol, amount, chainName) {
var convertDisplayUnitToBaseUnit = exports.convertDisplayUnitToBaseUnit = function convertDisplayUnitToBaseUnit(assets, symbol, amount, chainName) {
var _getAssetInfo4 = getAssetInfo(assets, symbol, chainName),
exponent = _getAssetInfo4.exponent;
return roundDown(shiftDecimalPlaces(amount, exponent));
};
exports.convertDisplayUnitToBaseUnit = convertDisplayUnitToBaseUnit;
};

@@ -8,3 +8,3 @@ "use strict";

var _assets = require("./assets");
var getGasPriceRangesFromChain = function getGasPriceRangesFromChain(chain) {
var getGasPriceRangesFromChain = exports.getGasPriceRangesFromChain = function getGasPriceRangesFromChain(chain) {
var _chain$fees, _chain$fees$fee_token, _feeToken$low_gas_pri, _feeToken$average_gas, _feeToken$high_gas_pr;

@@ -18,4 +18,3 @@ var feeToken = (_chain$fees = chain.fees) === null || _chain$fees === void 0 ? void 0 : (_chain$fees$fee_token = _chain$fees.fee_tokens) === null || _chain$fees$fee_token === void 0 ? void 0 : _chain$fees$fee_token[0];

};
exports.getGasPriceRangesFromChain = getGasPriceRangesFromChain;
var getChainByChainName = function getChainByChainName(chains, chainName) {
var getChainByChainName = exports.getChainByChainName = function getChainByChainName(chains, chainName) {
return (0, _assets.customFind)(chains, function (chain) {

@@ -25,4 +24,3 @@ return chain.chain_name === chainName;

};
exports.getChainByChainName = getChainByChainName;
var getChainByChainId = function getChainByChainId(chains, chainId) {
var getChainByChainId = exports.getChainByChainId = function getChainByChainId(chains, chainId) {
return (0, _assets.customFind)(chains, function (chain) {

@@ -32,27 +30,21 @@ return chain.chain_id === chainId;

};
exports.getChainByChainId = getChainByChainId;
var getChainNameByChainId = function getChainNameByChainId(chains, chainId) {
var getChainNameByChainId = exports.getChainNameByChainId = function getChainNameByChainId(chains, chainId) {
var _getChainByChainId;
return (_getChainByChainId = getChainByChainId(chains, chainId)) === null || _getChainByChainId === void 0 ? void 0 : _getChainByChainId.chain_name;
};
exports.getChainNameByChainId = getChainNameByChainId;
var getChainIdByChainName = function getChainIdByChainName(chains, chainName) {
var getChainIdByChainName = exports.getChainIdByChainName = function getChainIdByChainName(chains, chainName) {
var _getChainByChainName;
return (_getChainByChainName = getChainByChainName(chains, chainName)) === null || _getChainByChainName === void 0 ? void 0 : _getChainByChainName.chain_id;
};
exports.getChainIdByChainName = getChainIdByChainName;
var getChainGasPriceRanges = function getChainGasPriceRanges(chains, chainName) {
var getChainGasPriceRanges = exports.getChainGasPriceRanges = function getChainGasPriceRanges(chains, chainName) {
var chain = getChainByChainName(chains, chainName);
return chain ? getGasPriceRangesFromChain(chain) : undefined;
};
exports.getChainGasPriceRanges = getChainGasPriceRanges;
var getChainPrettyName = function getChainPrettyName(chains, chainName) {
var getChainPrettyName = exports.getChainPrettyName = function getChainPrettyName(chains, chainName) {
var _getChainByChainName2;
return (_getChainByChainName2 = getChainByChainName(chains, chainName)) === null || _getChainByChainName2 === void 0 ? void 0 : _getChainByChainName2.pretty_name;
};
exports.getChainPrettyName = getChainPrettyName;
var getChainBech32Prefix = function getChainBech32Prefix(chains, chainName) {
var getChainBech32Prefix = exports.getChainBech32Prefix = function getChainBech32Prefix(chains, chainName) {
var _getChainByChainName3;
return (_getChainByChainName3 = getChainByChainName(chains, chainName)) === null || _getChainByChainName3 === void 0 ? void 0 : _getChainByChainName3.bech32_prefix;
};
exports.getChainBech32Prefix = getChainBech32Prefix;
};

@@ -12,8 +12,8 @@ "use strict";

var _sha = require("sha.js");
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
var ibcDenom = function ibcDenom(paths, coinMinimalDenom) {
var ibcDenom = exports.ibcDenom = function ibcDenom(paths, coinMinimalDenom) {
var prefixes = [];

@@ -36,3 +36,2 @@ var _iterator = _createForOfIteratorHelper(paths),

};
exports.ibcDenom = ibcDenom;
var findInfo = function findInfo(ibc, to, from) {

@@ -43,7 +42,6 @@ return ibc.find(function (i) {

};
var getIbcInfo = function getIbcInfo(ibc, chain, counterparty) {
var getIbcInfo = exports.getIbcInfo = function getIbcInfo(ibc, chain, counterparty) {
return findInfo(ibc, chain, counterparty) || findInfo(ibc, counterparty, chain);
};
exports.getIbcInfo = getIbcInfo;
var getTransferChannel = function getTransferChannel(info) {
var getTransferChannel = exports.getTransferChannel = function getTransferChannel(info) {
return info.channels.find(function (channel) {

@@ -53,4 +51,3 @@ return channel.chain_1.port_id === 'transfer' && channel.chain_2.port_id === 'transfer';

};
exports.getTransferChannel = getTransferChannel;
var getNonTransferChannel = function getNonTransferChannel(info) {
var getNonTransferChannel = exports.getNonTransferChannel = function getNonTransferChannel(info) {
return info.channels.find(function (channel) {

@@ -60,4 +57,3 @@ return channel.chain_1.port_id !== 'transfer' && channel.chain_2.port_id === 'transfer' || channel.chain_1.port_id === 'transfer' && channel.chain_2.port_id !== 'transfer';

};
exports.getNonTransferChannel = getNonTransferChannel;
var getWasmChannel = function getWasmChannel(info) {
var getWasmChannel = exports.getWasmChannel = function getWasmChannel(info) {
return info.channels.find(function (channel) {

@@ -67,4 +63,3 @@ return channel.chain_1.port_id.startsWith('wasm.') && channel.chain_2.port_id === 'transfer' || channel.chain_1.port_id === 'transfer' && channel.chain_2.port_id.startsWith('wasm');

};
exports.getWasmChannel = getWasmChannel;
var getIbcAssetPath = function getIbcAssetPath(ibc, chain, counterparty, assets, base) {
var getIbcAssetPath = exports.getIbcAssetPath = function getIbcAssetPath(ibc, chain, counterparty, assets, base) {
var _asset$traces$filter, _asset$traces, _asset$traces$filter2;

@@ -116,4 +111,3 @@ var ibcInfo = getIbcInfo(ibc, chain, counterparty);

};
exports.getIbcAssetPath = getIbcAssetPath;
var getIbcDenomByBase = function getIbcDenomByBase(ibc, chain, counterparty, assets, base) {
var getIbcDenomByBase = exports.getIbcDenomByBase = function getIbcDenomByBase(ibc, chain, counterparty, assets, base) {
var ibcInfo = getIbcInfo(ibc, chain, counterparty);

@@ -150,4 +144,3 @@ if (ibcInfo) {

};
exports.getIbcDenomByBase = getIbcDenomByBase;
var getIbcAssets = function getIbcAssets(chainName, ibc, assets) {
var getIbcAssets = exports.getIbcAssets = function getIbcAssets(chainName, ibc, assets) {
var chainIbcInfo = ibc.filter(function (i) {

@@ -227,3 +220,2 @@ return i.chain_1.chain_name === chainName || i.chain_2.chain_name === chainName;

},
chain: {

@@ -257,4 +249,3 @@ // dst_denom

};
exports.getIbcAssets = getIbcAssets;
var getCw20Assets = function getCw20Assets(chainName, ibc, assets) {
var getCw20Assets = exports.getCw20Assets = function getCw20Assets(chainName, ibc, assets) {
var chainIbcInfo = ibc.filter(function (i) {

@@ -356,4 +347,3 @@ return i.chain_1.chain_name === chainName || i.chain_2.chain_name === chainName;

};
exports.getCw20Assets = getCw20Assets;
var getAssetLists = function getAssetLists(chainName, ibc, assets) {
var getAssetLists = exports.getAssetLists = function getAssetLists(chainName, ibc, assets) {
var ibcAssetLists = getIbcAssets(chainName, ibc, assets);

@@ -375,3 +365,2 @@ var cw20Assets = getCw20Assets(chainName, ibc, assets);

}, []);
};
exports.getAssetLists = getAssetLists;
};
{
"name": "@chain-registry/utils",
"version": "1.19.0",
"version": "1.19.2",
"description": "Chain Registry Utils",

@@ -75,7 +75,7 @@ "author": "Dan Lynch <pyramation@gmail.com>",

"@babel/runtime": "^7.21.0",
"@chain-registry/types": "^0.18.1",
"@chain-registry/types": "^0.18.3",
"bignumber.js": "9.1.1",
"sha.js": "^2.4.11"
},
"gitHead": "e57916824aad1598342fe9175e9e87b1ba0babcb"
"gitHead": "3da58f4178fd61379a8358fca13f9d53f85d25cc"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc