@exodus/models
Advanced tools
Comparing version 9.0.0 to 9.1.0
@@ -28,3 +28,3 @@ "use strict"; | ||
const ac = new AddressSet(); | ||
for (let addr of vals) { | ||
for (const addr of vals) { | ||
ac._data.set(addr.address, addr); | ||
@@ -36,3 +36,3 @@ } | ||
(0, _minimalisticAssert.default)(_address.default.isAddress(address), 'Must be an instance of an Address.'); | ||
let ac = new AddressSet(); | ||
const ac = new AddressSet(); | ||
ac._data = new Map(this._data); | ||
@@ -52,5 +52,5 @@ ac._data.set(address.address, address); | ||
remove(address) { | ||
let addrObj = this.get(address); | ||
const addrObj = this.get(address); | ||
if (!addrObj) return this; | ||
let ac = new AddressSet(); | ||
const ac = new AddressSet(); | ||
ac._data = new Map(this._data); | ||
@@ -75,5 +75,5 @@ ac._data.delete(addrObj.address); | ||
union(otherSet) { | ||
let arr1 = [...this]; | ||
let arr2 = [...otherSet]; | ||
let both = [...arr1, ...arr2]; | ||
const arr1 = [...this]; | ||
const arr2 = [...otherSet]; | ||
const both = [...arr1, ...arr2]; | ||
return AddressSet.fromArray(both); | ||
@@ -80,0 +80,0 @@ } |
@@ -29,3 +29,3 @@ "use strict"; | ||
if (typeof json === 'string') json = JSON.parse(json); | ||
return Address.create(json.address, json.meta ? json.meta : json.path); | ||
return Address.create(json.address, json.meta || json.path); | ||
} | ||
@@ -32,0 +32,0 @@ get pathArray() { |
@@ -24,2 +24,32 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "FIAT_ORDER_COMPLETE_STATUS", { | ||
enumerable: true, | ||
get: function () { | ||
return _fiatOrder.COMPLETE_STATUS; | ||
} | ||
}); | ||
Object.defineProperty(exports, "FIAT_ORDER_STALE_STATUS", { | ||
enumerable: true, | ||
get: function () { | ||
return _fiatOrder.STALE_STATUS; | ||
} | ||
}); | ||
Object.defineProperty(exports, "FIAT_ORDER_STATUS_MAP", { | ||
enumerable: true, | ||
get: function () { | ||
return _fiatOrder.STATUS_MAP; | ||
} | ||
}); | ||
Object.defineProperty(exports, "FiatOrder", { | ||
enumerable: true, | ||
get: function () { | ||
return _fiatOrder.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "FiatOrderSet", { | ||
enumerable: true, | ||
get: function () { | ||
return _fiatOrderSet.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Order", { | ||
@@ -79,2 +109,8 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "fiatOrderAdapter", { | ||
enumerable: true, | ||
get: function () { | ||
return _fiatOrder.adapter; | ||
} | ||
}); | ||
Object.defineProperty(exports, "normalizeTxJSON", { | ||
@@ -126,7 +162,11 @@ enumerable: true, | ||
var _order = _interopRequireDefault(require("./order")); | ||
var _orderSet = _interopRequireDefault(require("./order-set")); | ||
var _fiatOrder = _interopRequireWildcard(require("./fiat-order")); | ||
var _fiatOrderSet = _interopRequireDefault(require("./fiat-order-set")); | ||
var _accountState = _interopRequireDefault(require("./account-state")); | ||
var _orderSet = _interopRequireDefault(require("./order-set")); | ||
var _utils = require("./tx/utils"); | ||
var _util = require("./order/util"); | ||
var _util2 = require("./order-set/util"); | ||
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 }; } |
@@ -53,3 +53,3 @@ "use strict"; | ||
if (!items) return this; | ||
for (let item of items) { | ||
for (const item of items) { | ||
if (this.get(item)) { | ||
@@ -79,3 +79,3 @@ console.log(`OrderSet#add() already has #{item.orderId}`); | ||
if (this._sortOrder.length !== otherSet._sortOrder.length) return false; | ||
let len = this._sortOrder.length; | ||
const len = this._sortOrder.length; | ||
for (let i = 0; i < len; ++i) { | ||
@@ -111,5 +111,5 @@ if (this._sortOrder[i] !== otherSet._sortOrder[i]) return false; | ||
union(otherSet) { | ||
let arr1 = [...this]; | ||
let arr2 = [...otherSet]; | ||
let both = [...arr1, ...arr2]; | ||
const arr1 = [...this]; | ||
const arr2 = [...otherSet]; | ||
const both = [...arr1, ...arr2]; | ||
return OrderSet.fromArray(both); | ||
@@ -116,0 +116,0 @@ } |
@@ -53,4 +53,4 @@ "use strict"; | ||
(0, _minimalisticAssert.default)(typeof this.orderId === 'string', `orderId must be a string, received: ${this.orderId}`); | ||
if (typeof props.fromAmount !== 'undefined' && !(0, _currency.isNumberUnit)(props.fromAmount)) throw new Error('fromAmount must be of type: NumberUnit'); | ||
if (typeof props.toAmount !== 'undefined' && !(0, _currency.isNumberUnit)(props.toAmount)) throw new Error('toAmount must be of type: NumberUnit'); | ||
if (props.fromAmount !== undefined && !(0, _currency.isNumberUnit)(props.fromAmount)) throw new Error('fromAmount must be of type: NumberUnit'); | ||
if (props.toAmount !== undefined && !(0, _currency.isNumberUnit)(props.toAmount)) throw new Error('toAmount must be of type: NumberUnit'); | ||
this.status = props.status || ''; | ||
@@ -94,3 +94,3 @@ if (props.errorDetails) this.errorDetails = props.errorDetails; | ||
toJSON() { | ||
let obj = { | ||
const obj = { | ||
...this, | ||
@@ -106,3 +106,3 @@ date: this.date.toISOString() | ||
console.log('Order: calling deprecated function order.toJSONLegacy(), use orderToJSONLegacy() instead'); | ||
let obj = { | ||
const obj = { | ||
...this, | ||
@@ -109,0 +109,0 @@ date: this.date.toISOString() |
@@ -40,3 +40,3 @@ "use strict"; | ||
(0, _minimalisticAssert.default)(order && order instanceof _.default, 'toJSONLegacy: requires an Order'); | ||
let obj = { | ||
const obj = { | ||
...order, | ||
@@ -43,0 +43,0 @@ date: order.date.toISOString() |
@@ -22,3 +22,3 @@ "use strict"; | ||
toJSON() { | ||
let obj = { | ||
const obj = { | ||
...this | ||
@@ -28,3 +28,3 @@ }; | ||
obj.sends = {}; | ||
for (let [key, value] of Object.entries(this.sends)) { | ||
for (const [key, value] of Object.entries(this.sends)) { | ||
obj.sends[key] = { | ||
@@ -31,0 +31,0 @@ ...value |
@@ -68,3 +68,3 @@ "use strict"; | ||
delete(tx) { | ||
let txObj = this.get(tx); | ||
const txObj = this.get(tx); | ||
if (!txObj) return this; | ||
@@ -71,0 +71,0 @@ const txs = new Map(this._txs); |
@@ -48,3 +48,3 @@ "use strict"; | ||
this.confirmations = typeof confirmations === 'number' ? confirmations : -1; | ||
if (typeof dropped !== 'undefined') this.dropped = !!dropped && this.confirmations <= 0; | ||
if (dropped !== undefined) this.dropped = !!dropped && this.confirmations <= 0; | ||
if (coinAmount) { | ||
@@ -51,0 +51,0 @@ this.coinAmount = coinAmount; |
@@ -25,4 +25,4 @@ "use strict"; | ||
_defineProperty(this, _Symbol$iterator, function* symbolIterator() { | ||
let arr = this.toArray(); | ||
for (let val of arr) yield val; | ||
const arr = this.toArray(); | ||
for (const val of arr) yield val; | ||
}); | ||
@@ -39,3 +39,3 @@ this.currency = currency; | ||
} = {}) { | ||
let currency = options.currency || pickCurrencyFromArray(utxoArray); | ||
const currency = options.currency || pickCurrencyFromArray(utxoArray); | ||
if (currency == null && utxoArray == null) console.warn('UtxoCollection.fromArray(): both currency and utxoArray are null.');else if (currency == null && utxoArray.length === 0) { | ||
@@ -45,3 +45,3 @@ console.warn('UtxoCollection.fromArray(): currency is null and utxoArray has zero items.'); | ||
utxoArray = (0, _lodash.uniqBy)(utxoArray, utxo => `${utxo.txId}:${utxo.vout}`); | ||
let utxos = utxoArray.map(utxo => { | ||
const utxos = utxoArray.map(utxo => { | ||
(0, _minimalisticAssert.default)(utxo.address, 'utxo.address must be provided'); | ||
@@ -65,8 +65,8 @@ (0, _minimalisticAssert.default)(utxo.address instanceof _address.default || addressMap, 'Must pass addressMap if utxo.address is not of type Address'); | ||
if (typeof json === 'string') json = JSON.parse(json); | ||
let utxoData = {}; | ||
const utxoData = {}; | ||
Object.keys(json).forEach(address => { | ||
let addr = new _address.default(json[address].address, { | ||
const addr = new _address.default(json[address].address, { | ||
path: json[address].path | ||
}); | ||
let sortedUtxos = (0, _lodash.sortBy)(json[address].utxos, utxo => currency.parse(utxo.value).toDefaultNumber()); | ||
const sortedUtxos = (0, _lodash.sortBy)(json[address].utxos, utxo => currency.parse(utxo.value).toDefaultNumber()); | ||
utxoData[address] = sortedUtxos.map(utxo => ({ | ||
@@ -78,3 +78,3 @@ ...utxo, | ||
}); | ||
let col = new UtxoCollection({ | ||
const col = new UtxoCollection({ | ||
currency | ||
@@ -95,5 +95,5 @@ }); | ||
const txMap = col => { | ||
let map = {}; | ||
const map = {}; | ||
col.toArray().forEach(utxo => { | ||
let key = `${utxo.txId}/${utxo.vout}`; | ||
const key = `${utxo.txId}/${utxo.vout}`; | ||
map[key] = utxo; | ||
@@ -103,5 +103,5 @@ }); | ||
}; | ||
let thisMap = txMap(this); | ||
let otherMap = txMap(utxoCol); | ||
let retUtxos = []; | ||
const thisMap = txMap(this); | ||
const otherMap = txMap(utxoCol); | ||
const retUtxos = []; | ||
Object.keys(thisMap).forEach(key => { | ||
@@ -127,4 +127,4 @@ if (!otherMap[key]) retUtxos.push(thisMap[key]); | ||
getAddressesForTxId(txId) { | ||
let arrUtxos = this.toArray().filter(utxo => utxo.txId === txId); | ||
let arrAddrs = arrUtxos.map(utxo => utxo.address); | ||
const arrUtxos = this.toArray().filter(utxo => utxo.txId === txId); | ||
const arrAddrs = arrUtxos.map(utxo => utxo.address); | ||
return _addressSet.default.fromArray(arrAddrs); | ||
@@ -150,3 +150,3 @@ } | ||
let currentUtxos = this; | ||
for (let address of utxoCol.addresses) { | ||
for (const address of utxoCol.addresses) { | ||
currentUtxos = currentUtxos.setAddressUtxos(address, utxoCol.getAddressUtxos(address)); | ||
@@ -157,7 +157,7 @@ } | ||
removeAddressUtxos(address) { | ||
let newData = { | ||
const newData = { | ||
...this._data | ||
}; | ||
delete newData[address.toString()]; | ||
let col = new UtxoCollection({ | ||
const col = new UtxoCollection({ | ||
...this | ||
@@ -177,7 +177,7 @@ }); | ||
if (utxos.size === 0) return [selected, remaining]; | ||
let arrUtxos = minimumAmount.defaultUnit.unitName === 'BTC' ? (0, _lodash.sortBy)(utxos.toArray(), utxo => !utxo.confirmations, utxo => utxo.value.toDefaultNumber()) : (0, _lodash.sortBy)(utxos.toArray(), utxo => utxo.value.toDefaultNumber()); | ||
let selectedUtxos = []; | ||
let currency = arrUtxos[0].value.unitType; | ||
const arrUtxos = minimumAmount.defaultUnit.unitName === 'BTC' ? (0, _lodash.sortBy)(utxos.toArray(), utxo => !utxo.confirmations, utxo => utxo.value.toDefaultNumber()) : (0, _lodash.sortBy)(utxos.toArray(), utxo => utxo.value.toDefaultNumber()); | ||
const selectedUtxos = []; | ||
const currency = arrUtxos[0].value.unitType; | ||
let sum = currency.ZERO; | ||
for (let utxo of arrUtxos) { | ||
for (const utxo of arrUtxos) { | ||
selectedUtxos.push(utxo); | ||
@@ -245,7 +245,7 @@ sum = sum.add(utxo.value); | ||
if (utxos.size === 0) return this.removeAddressUtxos(address); | ||
let newUtxos = { | ||
const newUtxos = { | ||
...this._data, | ||
[address.toString()]: utxos.toArray() | ||
}; | ||
let col = new UtxoCollection({ | ||
const col = new UtxoCollection({ | ||
...this | ||
@@ -263,3 +263,3 @@ }); | ||
toJSON() { | ||
let jsonMap = {}; | ||
const jsonMap = {}; | ||
[...this.addresses].forEach(addr => { | ||
@@ -284,4 +284,4 @@ const address = addr.toString(); | ||
union(utxos) { | ||
let arr1 = this.toArray(); | ||
let arr2 = utxos.toArray(); | ||
const arr1 = this.toArray(); | ||
const arr2 = utxos.toArray(); | ||
return UtxoCollection.fromArray([...arr1, ...arr2], { | ||
@@ -341,5 +341,5 @@ ...this | ||
if (!Array.isArray(utxos)) return; | ||
for (let utxo of utxos) { | ||
for (const utxo of utxos) { | ||
if (typeof utxo.value === 'object' && utxo.value.unitType) return utxo.value.unitType; | ||
} | ||
} |
{ | ||
"name": "@exodus/models", | ||
"version": "9.0.0", | ||
"version": "9.1.0", | ||
"description": "Exodus models", | ||
@@ -15,2 +15,3 @@ "main": "lib/index.js", | ||
"@exodus/currency": "^2.1.2", | ||
"@exodus/fiat-client": "^7.8.4", | ||
"@exodus/serialization": "^1.0.0", | ||
@@ -35,4 +36,3 @@ "bip32-path": "~0.4.2", | ||
"lint:fix": "yarn lint --fix" | ||
}, | ||
"gitHead": "fa4657928633ef68e7392f524e2a4144ab12ddcf" | ||
} | ||
} |
95593
23
2426
8
+ Added@exodus/fiat-client@^7.8.4