@exodus/models
Advanced tools
Comparing version 11.8.0 to 11.9.0
@@ -70,2 +70,3 @@ "use strict"; | ||
compatibilityMode, | ||
seedId, | ||
enabled = true | ||
@@ -83,21 +84,15 @@ }) { | ||
_defineProperty(this, "enabled", void 0); | ||
_defineProperty(this, "seedId", void 0); | ||
_defineProperty(this, "compatibilityMode", void 0); | ||
const isCustodial = CUSTODIAL_SOURCES.includes(source); | ||
if (!source) { | ||
throw new Error('expected "source" for a wallet account'); | ||
} else if (index == null && !isCustodial) { | ||
throw new Error('expected "index" for a wallet account'); | ||
} else if (source === EXODUS_SRC && id) { | ||
throw new Error('unexpected option "id" for an exodus wallet account'); | ||
} else if (!id && source !== EXODUS_SRC) { | ||
throw new Error('expected option "id" for a non-exodus wallet account'); | ||
} else if (source === EXODUS_SRC && lastConnected) { | ||
throw new Error('unexpected option "lastConnected" for a software wallet account'); | ||
} else if (source === EXODUS_SRC && model) { | ||
throw new Error('unexpected option "model" for a software wallet account'); | ||
} | ||
(0, _minimalisticAssert.default)(!compatibilityMode || SOFTWARE_SEED_SOURCES.includes(source), 'compatibilityMode can only be provided for software wallet accounts'); | ||
if (source !== EXODUS_SRC && is2FA) { | ||
throw new Error('is2FA: true is only valid for an exodus walletAccount'); | ||
} | ||
const isSoftware = SOFTWARE_SEED_SOURCES.includes(source); | ||
(0, _minimalisticAssert.default)(source, 'expected "source" for a wallet account'); | ||
(0, _minimalisticAssert.default)(!(index == null && !isCustodial), 'expected "index" for a wallet account'); | ||
(0, _minimalisticAssert.default)(id || isSoftware, 'expected option "id" for a non-software wallet account'); | ||
(0, _minimalisticAssert.default)(!isSoftware || !id, 'unexpected option "id" for a software wallet account'); | ||
(0, _minimalisticAssert.default)(!(isSoftware && lastConnected), 'unexpected option "lastConnected" for a software wallet account'); | ||
(0, _minimalisticAssert.default)(!compatibilityMode || isSoftware, 'compatibilityMode can only be provided for software wallet accounts'); | ||
(0, _minimalisticAssert.default)(!isSoftware || !model, 'unexpected option "model" for a software wallet account'); | ||
(0, _minimalisticAssert.default)(source === EXODUS_SRC || !is2FA, 'is2FA: true is only valid for an exodus walletAccount'); | ||
(0, _minimalisticAssert.default)(source !== SEED_SRC || seedId, 'expected option "seedId" for seed wallet account'); | ||
color = color || DEFAULT_COLORS[source]; | ||
@@ -121,2 +116,3 @@ icon = icon || DEFAULT_ICONS[source]; | ||
this.id = id; | ||
this.seedId = seedId; | ||
this.label = label || ''; | ||
@@ -133,3 +129,3 @@ this.model = model; | ||
toString() { | ||
return [this.source, this.index, this.id, this.source === SEED_SRC && this.compatibilityMode].filter(v => v != null && v !== false).join('_'); | ||
return [this.source, this.index, ...(this.source === SEED_SRC ? [this.seedId, this.compatibilityMode] : [this.id])].filter(v => v != null).join('_'); | ||
} | ||
@@ -147,3 +143,4 @@ toJSON() { | ||
enabled: this.enabled, | ||
compatibilityMode: this.compatibilityMode | ||
compatibilityMode: this.compatibilityMode, | ||
seedId: this.seedId | ||
}; | ||
@@ -150,0 +147,0 @@ if (this.id != null) json.id = this.id; |
{ | ||
"name": "@exodus/models", | ||
"version": "11.8.0", | ||
"version": "11.9.0", | ||
"description": "Exodus models", | ||
@@ -41,3 +41,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "5bd84273e226fdbbcf34260e2c87eeb41bfccaad" | ||
"gitHead": "5e5621479d4b3a463f52ecc50e172f0c8d48f139" | ||
} |
103035
2579