@exodus/models
Advanced tools
Comparing version 8.2.5 to 8.3.0
@@ -166,16 +166,23 @@ "use strict"; | ||
this._mutations = Array.from(this).map(tx => { | ||
if (balance === undefined) balance = tx.coinAmount.unitType.ZERO; | ||
try { | ||
if (balance === undefined) balance = tx.coinAmount.unitType.ZERO; | ||
if (!(tx.dropped || tx.data.replacedBy)) { | ||
if (!tx.error) balance = balance.add(tx.coinAmount); | ||
if (!(tx.dropped || tx.data.replacedBy)) { | ||
if (!tx.error) { | ||
balance = balance.add(tx.coinAmount); | ||
} | ||
if (tx.sent && tx.feeAmount && tx.feeAmount.unitType === tx.coinAmount.unitType) { | ||
balance = balance.sub(tx.feeAmount); | ||
if (tx.sent && tx.feeAmount && tx.feeAmount.unitType === tx.coinAmount.unitType) { | ||
balance = balance.sub(tx.feeAmount); | ||
} | ||
} | ||
return { | ||
tx, | ||
balance | ||
}; | ||
} catch (e) { | ||
console.warn('failed to calculate mutation for tx', tx.toJSON()); | ||
throw e; | ||
} | ||
return { | ||
tx, | ||
balance | ||
}; | ||
}); | ||
@@ -182,0 +189,0 @@ return this._mutations; |
@@ -23,2 +23,4 @@ "use strict"; | ||
const isColor = str => typeof str === 'string' && /^#[0-9a-fA-F]{3,6}/.test(str); | ||
class WalletAccount { | ||
@@ -32,3 +34,5 @@ constructor({ | ||
lastConnected, | ||
is2FA | ||
is2FA, | ||
color, | ||
icon | ||
}) { | ||
@@ -49,2 +53,6 @@ _defineProperty(this, "source", void 0); | ||
_defineProperty(this, "color", void 0); | ||
_defineProperty(this, "icon", void 0); | ||
if (!source) { | ||
@@ -68,2 +76,10 @@ throw new Error('expected "source" for a wallet account'); | ||
if (color && !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'); | ||
} | ||
this.source = source; | ||
@@ -76,2 +92,4 @@ this.index = index; | ||
this.is2FA = is2FA; | ||
this.color = color; | ||
this.icon = icon; | ||
return (0, _proxyFreeze.default)(this); | ||
@@ -91,3 +109,5 @@ } | ||
lastConnected: this.lastConnected, | ||
is2FA: this.is2FA | ||
is2FA: this.is2FA, | ||
color: this.color, | ||
icon: this.icon | ||
}; | ||
@@ -94,0 +114,0 @@ if (this.id != null) json.id = this.id; |
{ | ||
"name": "@exodus/models", | ||
"version": "8.2.5", | ||
"version": "8.3.0", | ||
"description": "Exodus models", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
48050
1164