@exodus/models
Advanced tools
Comparing version 2.0.2 to 2.1.0
@@ -0,1 +1,13 @@ | ||
2.1.0 / 2019-07-24 | ||
------------------ | ||
- Add `tx.from` as an array of addresses | ||
- Remove `tx.outputs` | ||
- Remove `tx.paymentId` | ||
- Rename `tx.memo` to `tx.personalNote` | ||
- Correctly throw when parsing a tx if `tx.addresses` is not a valid type | ||
- Export `TxSet.utils` | ||
- Export `AddressSet.PATH_SORTER` | ||
- Export `Address.utils` and `Address.isAddress` | ||
2.0.2 / 2019-07-12 | ||
@@ -2,0 +14,0 @@ ------------------ |
@@ -6,10 +6,8 @@ "use strict"; | ||
}); | ||
exports.PATH_SORTER = exports.default = void 0; | ||
exports.default = void 0; | ||
var _assert = _interopRequireDefault(require("assert")); | ||
var _address = _interopRequireWildcard(require("../address")); | ||
var _address = _interopRequireDefault(require("../address")); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -45,3 +43,3 @@ | ||
add(address) { | ||
(0, _assert.default)((0, _address.isAddress)(address), 'Must be an instance of an Address.'); | ||
(0, _assert.default)(_address.default.isAddress(address), 'Must be an instance of an Address.'); | ||
let ac = new AddressSet(); | ||
@@ -117,3 +115,3 @@ ac._data = new Map(this._data); | ||
const PATH_SORTER = (a1, a2) => { | ||
_defineProperty(AddressSet, "PATH_SORTER", (a1, a2) => { | ||
const p1 = a1.pathArray; | ||
@@ -125,4 +123,2 @@ const p2 = a2.pathArray; | ||
} | ||
}; | ||
exports.PATH_SORTER = PATH_SORTER; | ||
}); |
@@ -6,3 +6,2 @@ "use strict"; | ||
}); | ||
exports.isAddress = isAddress; | ||
exports.default = void 0; | ||
@@ -12,2 +11,6 @@ | ||
var util = _interopRequireWildcard(require("./util")); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -57,2 +60,7 @@ | ||
static isAddress(address) { | ||
const val = typeof address === 'object' && (address instanceof Address || 'address' in address && 'meta' in address); | ||
return val; | ||
} | ||
} | ||
@@ -62,5 +70,2 @@ | ||
function isAddress(address) { | ||
const val = typeof address === 'object' && (address instanceof Address || 'address' in address && 'meta' in address); | ||
return val; | ||
} | ||
_defineProperty(Address, "util", util); |
@@ -14,4 +14,12 @@ "use strict"; | ||
var util = _interopRequireWildcard(require("./util")); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var _Symbol$iterator = Symbol.iterator; | ||
class TxSet { | ||
@@ -169,3 +177,3 @@ constructor() { | ||
[Symbol.iterator]() { | ||
[_Symbol$iterator]() { | ||
return this._txs.values(); | ||
@@ -181,2 +189,5 @@ } | ||
exports.default = TxSet; | ||
_defineProperty(TxSet, "util", util); | ||
TxSet.EMPTY = new TxSet(); | ||
@@ -183,0 +194,0 @@ |
@@ -20,4 +20,2 @@ "use strict"; | ||
var _utxoCollection = _interopRequireDefault(require("../utxo-collection")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -31,3 +29,4 @@ | ||
this.confirmations = -1; | ||
this.memo = ''; | ||
this.from = []; | ||
this.personalNote = ''; | ||
this.meta = {}; | ||
@@ -64,6 +63,11 @@ this.token = null; | ||
if (json.from) { | ||
(0, _assert.default)(Array.isArray(json.from), 'Tx.fromJSON(): from has to be an array.'); | ||
tx.from = json.from; | ||
} | ||
if (json.to) tx.to = json.to; | ||
if (json.spread) tx.spread = json.spread; | ||
if (json.duration) tx.duration = json.duration; | ||
if (json.memo) tx.memo = json.memo; | ||
if (json.personalNote) tx.personalNote = json.personalNote; | ||
if (json.token) tx.token = json.token; | ||
@@ -76,5 +80,9 @@ if (json.data) tx.data = json.data; | ||
if (json.addresses) { | ||
if (Array.isArray(json.addresses)) tx.addresses = _addressSet.default.fromArray(json.addresses); | ||
if (json.addresses instanceof _addressSet.default) tx.addresses = json.addresses; | ||
(0, _assert.default)('Tx.toJSON(): unknown addresses type.'); | ||
if (Array.isArray(json.addresses)) { | ||
tx.addresses = _addressSet.default.fromArray(json.addresses); | ||
} else if (json.addresses instanceof _addressSet.default) { | ||
tx.addresses = json.addresses; | ||
} else { | ||
_assert.default.fail('Tx.toJSON(): unknown addresses type.'); | ||
} | ||
} else { | ||
@@ -85,13 +93,2 @@ tx.addresses = _addressSet.default.EMPTY; | ||
if (json.height) tx.height = json.height; | ||
if (json.outputs) { | ||
if (json.outputs instanceof _utxoCollection.default) tx.outputs = json.outputs;else tx.outputs = _utxoCollection.default.fromJSON(json.outputs, { | ||
currency: _assets.default[tx.coinName].currency | ||
}); | ||
} | ||
if (json.paymentId) { | ||
tx.paymentId = json.paymentId; | ||
} | ||
return (0, _proxyFreeze.default)(tx); | ||
@@ -124,3 +121,2 @@ } | ||
obj.date = obj.date.toISOString(); | ||
if (this.exchange) delete obj.memo; | ||
@@ -132,5 +128,5 @@ if (this.addresses) { | ||
if (!obj.memo) delete obj.memo; | ||
if (obj.from.length === 0) delete obj.from; | ||
if (!obj.personalNote) delete obj.personalNote; | ||
if (Object.keys(obj.data).length === 0) delete obj.data; | ||
if (this.outputs) obj.outputs = this.outputs.toJSON(); | ||
return obj; | ||
@@ -137,0 +133,0 @@ } |
@@ -12,3 +12,3 @@ "use strict"; | ||
var _addressSet = _interopRequireWildcard(require("../address-set")); | ||
var _addressSet = _interopRequireDefault(require("../address-set")); | ||
@@ -302,3 +302,3 @@ var _currency = _interopRequireWildcard(require("@exodus/currency")); | ||
addrs.sort(_addressSet.PATH_SORTER); | ||
addrs.sort(_addressSet.default.PATH_SORTER); | ||
this._addresses = _addressSet.default.fromArray(addrs); | ||
@@ -305,0 +305,0 @@ return this._addresses; |
{ | ||
"name": "@exodus/models", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"description": "Exodus models", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
33388
810