@exodus/assets
Advanced tools
Comparing version 8.0.85 to 8.0.86
@@ -8,2 +8,3 @@ "use strict"; | ||
combinedAssets: true, | ||
coerceTokenProps: true, | ||
connectAssets: true, | ||
@@ -18,2 +19,3 @@ addToken: true, | ||
exports.addToken = addToken; | ||
exports.coerceTokenProps = coerceTokenProps; | ||
exports.combinedAssets = void 0; | ||
@@ -23,6 +25,6 @@ exports.connectAssets = connectAssets; | ||
exports.updateCombinedAsset = updateCombinedAsset; | ||
var _lodash = require("lodash"); | ||
var _basicUtils = require("@exodus/basic-utils"); | ||
var _assetsBase = _interopRequireDefault(require("@exodus/assets-base")); | ||
var _combinedAssetsMeta = _interopRequireWildcard(require("@exodus/combined-assets-meta")); | ||
var _currency = require("@exodus/currency"); | ||
var _combinedAssets2 = _interopRequireDefault(require("./combined-assets")); | ||
var _validateAsset = require("./validate-asset"); | ||
@@ -40,5 +42,8 @@ Object.keys(_validateAsset).forEach(function (key) { | ||
}); | ||
var _createCombined = require("./combined-assets/create-combined"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const combinedAssets = _combinedAssets2.default; | ||
const combinedAssets = (0, _basicUtils.keyBy)(_combinedAssetsMeta.default, ({ | ||
name | ||
}) => name); | ||
exports.combinedAssets = combinedAssets; | ||
@@ -48,3 +53,3 @@ const connectProp = (asset, prop, value) => { | ||
}; | ||
const defineAssetPropsPassOne = (assets, asset) => { | ||
const defineAssetProps = (assets, asset) => { | ||
Object.defineProperties(asset, { | ||
@@ -71,22 +76,41 @@ baseAsset: { | ||
} | ||
connectProp(asset, 'currency', _currency.UnitType.create(asset.units)); | ||
connectProp(asset, 'properTicker', asset.ticker); | ||
connectProp(asset, 'displayName', asset.properName); | ||
connectProp(asset, 'displayTicker', asset.properTicker); | ||
asset.isBuiltIn = !!(_assetsBase.default[asset.name] || combinedAssets[asset.name]); | ||
if (asset.baseAsset.name === asset.name) { | ||
connectProp(asset, 'displayNetworkName', asset.properName); | ||
connectProp(asset, 'displayNetworkTicker', asset.properTicker); | ||
if (!asset.isBuiltIn || ['bcashclaim', 'bgoldclaim', 'bitcoinsvclaim'].includes(asset.name)) { | ||
coerceTokenProps(asset, asset.baseAsset); | ||
} | ||
}; | ||
const defineAssetPropsPassTwo = asset => { | ||
connectProp(asset, 'displayNetworkName', asset.baseAsset.displayNetworkName); | ||
connectProp(asset, 'displayNetworkTicker', asset.baseAsset.displayNetworkTicker); | ||
}; | ||
function coerceTokenProps(asset, baseAsset) { | ||
const { | ||
units, | ||
properName, | ||
properTicker, | ||
displayName, | ||
displayTicker, | ||
ticker, | ||
color | ||
} = asset; | ||
connectProp(asset, 'currency', _currency.UnitType.create(units)); | ||
connectProp(asset, 'displayName', properName); | ||
connectProp(asset, 'displayTicker', properTicker); | ||
connectProp(asset, 'properName', displayName); | ||
connectProp(asset, 'properTicker', displayTicker || ticker); | ||
connectProp(asset, 'primaryColor', color || '#FFFFFF'); | ||
connectProp(asset, 'chainBadgeColors', baseAsset.chainBadgeColors); | ||
connectProp(asset, 'displayNetworkName', baseAsset.displayNetworkName || baseAsset.displayName); | ||
connectProp(asset, 'displayNetworkTicker', baseAsset.displayNetworkTicker || baseAsset.displayTicker); | ||
connectProp(asset, 'blockExplorer', baseAsset.blockExplorer); | ||
connectProp(asset, 'gradientCoords', { | ||
x1: '0%', | ||
y1: '0%', | ||
x2: '100%', | ||
y2: '100%' | ||
}); | ||
connectProp(asset, 'gradientColors', ['#EAEAEA', '#FFF']); | ||
return asset; | ||
} | ||
function connectAssets(assets) { | ||
const _assets = (0, _lodash.mapValues)(assets, v => ({ | ||
const _assets = (0, _basicUtils.mapValues)(assets, v => ({ | ||
...v | ||
})); | ||
Object.values(_assets).forEach(asset => defineAssetPropsPassOne(_assets, asset)); | ||
Object.values(_assets).forEach(defineAssetPropsPassTwo); | ||
Object.values(_assets).forEach(asset => defineAssetProps(_assets, asset)); | ||
return _assets; | ||
@@ -108,4 +132,3 @@ } | ||
(0, _validateAsset.validateTokenDef)(asset); | ||
defineAssetPropsPassOne(assets, asset); | ||
defineAssetPropsPassTwo(asset); | ||
defineAssetProps(assets, asset); | ||
assets[name] = asset; | ||
@@ -127,4 +150,3 @@ } | ||
assets[name] = asset; | ||
defineAssetPropsPassOne(assets, asset); | ||
defineAssetPropsPassTwo(asset); | ||
defineAssetProps(assets, asset); | ||
} catch (e) { | ||
@@ -141,7 +163,6 @@ delete assets[name]; | ||
(0, _validateAsset.assert)(!assets[name], `asset ${name} already exists`); | ||
const asset = (0, _createCombined.createCombined)(assetDef); | ||
const asset = (0, _combinedAssetsMeta.createCombined)(assetDef, assets); | ||
try { | ||
assets[name] = asset; | ||
defineAssetPropsPassOne(assets, asset); | ||
defineAssetPropsPassTwo(asset); | ||
defineAssetProps(assets, asset); | ||
} catch (e) { | ||
@@ -163,10 +184,9 @@ delete assets[name]; | ||
(0, _validateAsset.assert)(!newMemberAsset.isCombined, `asset ${newMemberAsset.name} must not be a combined asset`); | ||
const assetDef = (0, _lodash.omit)(combinedAsset, ['baseAsset', 'feeAsset', 'combinedAssets']); | ||
const assetDef = (0, _basicUtils.omit)(combinedAsset, ['baseAsset', 'feeAsset', 'combinedAssets']); | ||
assetDef.combinedAssetNames.push(newMemberAsset.name); | ||
const asset = (0, _createCombined.createCombined)(assetDef); | ||
const asset = (0, _combinedAssetsMeta.createCombined)(assetDef, assets); | ||
const orig = assets[name]; | ||
try { | ||
assets[name] = asset; | ||
defineAssetPropsPassOne(assets, asset); | ||
defineAssetPropsPassTwo(asset); | ||
defineAssetProps(assets, asset); | ||
} catch (e) { | ||
@@ -178,5 +198,5 @@ assets[name] = orig; | ||
var _default = connectAssets({ | ||
..._combinedAssets2.default, | ||
...combinedAssets, | ||
..._assetsBase.default | ||
}); | ||
exports.default = _default; |
{ | ||
"name": "@exodus/assets", | ||
"version": "8.0.85", | ||
"version": "8.0.86", | ||
"description": "Exodus assets", | ||
@@ -14,3 +14,5 @@ "main": "lib/index.js", | ||
"@exodus/assets-base": "^8.1.3", | ||
"@exodus/currency": "^2.1.2", | ||
"@exodus/basic-utils": "^1.4.0", | ||
"@exodus/combined-assets-meta": "^1.0.2", | ||
"@exodus/currency": "^2.2.0", | ||
"lodash": "^4.17.11" | ||
@@ -28,3 +30,3 @@ }, | ||
}, | ||
"gitHead": "6f7b3ded9636faecc225cbc49d4ad57b6c003f90" | ||
"gitHead": "e009757fff8c943dab5b1d3d713adab1a1a53d84" | ||
} |
@@ -14,6 +14,9 @@ # Exodus Assets | ||
```js | ||
import { keyBy } from '@exodus/basic-utils' | ||
import { connectAssets } from '@exodus/assets' | ||
import assetsBase from '@exodus/assets-base' | ||
import combinedAssetsList from '@exodus/combined-assets-meta' | ||
const assets = connectAssets(assetsBase) | ||
const combinedAssets = keyBy(combinedAssetsList, ({ name }) => name) | ||
const assets = connectAssets({ ...combinedAssets, ...assetsBase }) | ||
@@ -20,0 +23,0 @@ for (const [key, val] of Object.entries(assets)) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26
12358
5
4
266
1
+ Added@exodus/basic-utils@^1.4.0
+ Added@exodus/basic-utils@1.5.0(transitive)
Updated@exodus/currency@^2.2.0