@exodus/models
Advanced tools
Comparing version 8.2.6 to 8.2.7
@@ -0,1 +1,12 @@ | ||
8.2.6 / 2020-10-09 | ||
------------------ | ||
- same as 8.3.0, to avoid re-publishing all asset libs that depends on ~8.2.x | ||
8.3.0 / 2020-10-09 | ||
------------------ | ||
- add WalletAccount .icon, .color | ||
8.2.4 / 2020-06-25 | ||
@@ -2,0 +13,0 @@ ------------------ |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = exports.LEDGER_SRC = exports.TREZOR_SRC = exports.EXODUS_SRC = void 0; | ||
exports.default = exports.getDefaultLabel = exports.DEFAULT_ICONS = exports.DEFAULT_COLORS = exports.LEDGER_SRC = exports.TREZOR_SRC = exports.EXODUS_SRC = void 0; | ||
@@ -23,3 +23,24 @@ var _proxyFreeze = _interopRequireDefault(require("proxy-freeze")); | ||
exports.LEDGER_SRC = LEDGER_SRC; | ||
const DEFAULT_COLORS = Object.freeze({ | ||
exodus: '#ff3974', | ||
trezor: '#7b39ff', | ||
ledger: '#f5e400' | ||
}); | ||
exports.DEFAULT_COLORS = DEFAULT_COLORS; | ||
const DEFAULT_ICONS = Object.freeze({ | ||
exodus: 'exodus', | ||
trezor: 'trezor', | ||
ledger: 'trezor' | ||
}); | ||
exports.DEFAULT_ICONS = DEFAULT_ICONS; | ||
const capFirst = str => str[0].toUpperCase() + str.slice(1); | ||
const getDefaultLabel = ({ | ||
source, | ||
index | ||
}) => index === 0 ? capFirst(source) : ''; | ||
exports.getDefaultLabel = getDefaultLabel; | ||
const isColor = str => typeof str === 'string' && /^#[0-9a-fA-F]{3,6}/.test(str); | ||
@@ -75,8 +96,15 @@ | ||
if (color && !isColor(color)) { | ||
color = color || DEFAULT_COLORS[source]; | ||
icon = icon || DEFAULT_ICONS[source]; | ||
label = label || getDefaultLabel({ | ||
source, | ||
index | ||
}); | ||
if (!isColor(color)) { | ||
throw new Error('expected "color" to be a hex string'); | ||
} | ||
if (icon && typeof icon !== 'string') { | ||
throw new Error('expected "icon" to be a string'); | ||
if (typeof icon !== 'string' || !icon.length) { | ||
throw new Error('expected "icon" to be a non-empty string'); | ||
} | ||
@@ -83,0 +111,0 @@ |
{ | ||
"name": "@exodus/models", | ||
"version": "8.2.6", | ||
"version": "8.2.7", | ||
"description": "Exodus models", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
48969
1188