@xchainjs/xchain-dash 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.esm.js +284 -277
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +290 -289
- package/lib/index.js.map +1 -1
- package/package.json +7 -7
package/lib/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var xchainClient = require('@xchainjs/xchain-client');
|
|
6
4
|
var xchainUtil = require('@xchainjs/xchain-util');
|
|
7
5
|
var xchainUtxoProviders = require('@xchainjs/xchain-utxo-providers');
|
|
@@ -12,10 +10,7 @@ var coininfo = require('coininfo');
|
|
|
12
10
|
var xchainCrypto = require('@xchainjs/xchain-crypto');
|
|
13
11
|
var AppBtc = require('@ledgerhq/hw-app-btc');
|
|
14
12
|
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
function _interopNamespace(e) {
|
|
18
|
-
if (e && e.__esModule) return e;
|
|
13
|
+
function _interopNamespaceDefault(e) {
|
|
19
14
|
var n = Object.create(null);
|
|
20
15
|
if (e) {
|
|
21
16
|
Object.keys(e).forEach(function (k) {
|
|
@@ -28,14 +23,13 @@ function _interopNamespace(e) {
|
|
|
28
23
|
}
|
|
29
24
|
});
|
|
30
25
|
}
|
|
31
|
-
n
|
|
26
|
+
n.default = e;
|
|
32
27
|
return Object.freeze(n);
|
|
33
28
|
}
|
|
34
29
|
|
|
35
|
-
var dashcore__namespace = /*#__PURE__*/
|
|
36
|
-
var Dash__namespace = /*#__PURE__*/
|
|
37
|
-
var coininfo__namespace = /*#__PURE__*/
|
|
38
|
-
var AppBtc__default = /*#__PURE__*/_interopDefaultLegacy(AppBtc);
|
|
30
|
+
var dashcore__namespace = /*#__PURE__*/_interopNamespaceDefault(dashcore);
|
|
31
|
+
var Dash__namespace = /*#__PURE__*/_interopNamespaceDefault(Dash);
|
|
32
|
+
var coininfo__namespace = /*#__PURE__*/_interopNamespaceDefault(coininfo);
|
|
39
33
|
|
|
40
34
|
/**
|
|
41
35
|
* Minimum transaction fee in duff/kB.
|
|
@@ -130,6 +124,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
130
124
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
131
125
|
PERFORMANCE OF THIS SOFTWARE.
|
|
132
126
|
***************************************************************************** */
|
|
127
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
128
|
+
|
|
133
129
|
|
|
134
130
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
135
131
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -139,7 +135,12 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
139
135
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
140
136
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
141
137
|
});
|
|
142
|
-
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
141
|
+
var e = new Error(message);
|
|
142
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
143
|
+
};
|
|
143
144
|
|
|
144
145
|
function bind(fn, thisArg) {
|
|
145
146
|
return function wrap() {
|
|
@@ -844,7 +845,7 @@ const asap = typeof queueMicrotask !== 'undefined' ?
|
|
|
844
845
|
|
|
845
846
|
// *********************
|
|
846
847
|
|
|
847
|
-
var utils$
|
|
848
|
+
var utils$2 = {
|
|
848
849
|
isArray,
|
|
849
850
|
isArrayBuffer,
|
|
850
851
|
isBuffer,
|
|
@@ -932,7 +933,7 @@ function AxiosError(message, code, config, request, response) {
|
|
|
932
933
|
response && (this.response = response);
|
|
933
934
|
}
|
|
934
935
|
|
|
935
|
-
utils$
|
|
936
|
+
utils$2.inherits(AxiosError, Error, {
|
|
936
937
|
toJSON: function toJSON() {
|
|
937
938
|
return {
|
|
938
939
|
// Standard
|
|
@@ -947,7 +948,7 @@ utils$3.inherits(AxiosError, Error, {
|
|
|
947
948
|
columnNumber: this.columnNumber,
|
|
948
949
|
stack: this.stack,
|
|
949
950
|
// Axios
|
|
950
|
-
config: utils$
|
|
951
|
+
config: utils$2.toJSONObject(this.config),
|
|
951
952
|
code: this.code,
|
|
952
953
|
status: this.response && this.response.status ? this.response.status : null
|
|
953
954
|
};
|
|
@@ -982,7 +983,7 @@ Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
|
|
|
982
983
|
AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
983
984
|
const axiosError = Object.create(prototype$1);
|
|
984
985
|
|
|
985
|
-
utils$
|
|
986
|
+
utils$2.toFlatObject(error, axiosError, function filter(obj) {
|
|
986
987
|
return obj !== Error.prototype;
|
|
987
988
|
}, prop => {
|
|
988
989
|
return prop !== 'isAxiosError';
|
|
@@ -1010,7 +1011,7 @@ var httpAdapter = null;
|
|
|
1010
1011
|
* @returns {boolean}
|
|
1011
1012
|
*/
|
|
1012
1013
|
function isVisitable(thing) {
|
|
1013
|
-
return utils$
|
|
1014
|
+
return utils$2.isPlainObject(thing) || utils$2.isArray(thing);
|
|
1014
1015
|
}
|
|
1015
1016
|
|
|
1016
1017
|
/**
|
|
@@ -1021,7 +1022,7 @@ function isVisitable(thing) {
|
|
|
1021
1022
|
* @returns {string} the key without the brackets.
|
|
1022
1023
|
*/
|
|
1023
1024
|
function removeBrackets(key) {
|
|
1024
|
-
return utils$
|
|
1025
|
+
return utils$2.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
1025
1026
|
}
|
|
1026
1027
|
|
|
1027
1028
|
/**
|
|
@@ -1050,10 +1051,10 @@ function renderKey(path, key, dots) {
|
|
|
1050
1051
|
* @returns {boolean}
|
|
1051
1052
|
*/
|
|
1052
1053
|
function isFlatArray(arr) {
|
|
1053
|
-
return utils$
|
|
1054
|
+
return utils$2.isArray(arr) && !arr.some(isVisitable);
|
|
1054
1055
|
}
|
|
1055
1056
|
|
|
1056
|
-
const predicates = utils$
|
|
1057
|
+
const predicates = utils$2.toFlatObject(utils$2, {}, null, function filter(prop) {
|
|
1057
1058
|
return /^is[A-Z]/.test(prop);
|
|
1058
1059
|
});
|
|
1059
1060
|
|
|
@@ -1081,7 +1082,7 @@ const predicates = utils$3.toFlatObject(utils$3, {}, null, function filter(prop)
|
|
|
1081
1082
|
* @returns
|
|
1082
1083
|
*/
|
|
1083
1084
|
function toFormData(obj, formData, options) {
|
|
1084
|
-
if (!utils$
|
|
1085
|
+
if (!utils$2.isObject(obj)) {
|
|
1085
1086
|
throw new TypeError('target must be an object');
|
|
1086
1087
|
}
|
|
1087
1088
|
|
|
@@ -1089,13 +1090,13 @@ function toFormData(obj, formData, options) {
|
|
|
1089
1090
|
formData = formData || new (FormData)();
|
|
1090
1091
|
|
|
1091
1092
|
// eslint-disable-next-line no-param-reassign
|
|
1092
|
-
options = utils$
|
|
1093
|
+
options = utils$2.toFlatObject(options, {
|
|
1093
1094
|
metaTokens: true,
|
|
1094
1095
|
dots: false,
|
|
1095
1096
|
indexes: false
|
|
1096
1097
|
}, false, function defined(option, source) {
|
|
1097
1098
|
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
1098
|
-
return !utils$
|
|
1099
|
+
return !utils$2.isUndefined(source[option]);
|
|
1099
1100
|
});
|
|
1100
1101
|
|
|
1101
1102
|
const metaTokens = options.metaTokens;
|
|
@@ -1104,24 +1105,24 @@ function toFormData(obj, formData, options) {
|
|
|
1104
1105
|
const dots = options.dots;
|
|
1105
1106
|
const indexes = options.indexes;
|
|
1106
1107
|
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
|
1107
|
-
const useBlob = _Blob && utils$
|
|
1108
|
+
const useBlob = _Blob && utils$2.isSpecCompliantForm(formData);
|
|
1108
1109
|
|
|
1109
|
-
if (!utils$
|
|
1110
|
+
if (!utils$2.isFunction(visitor)) {
|
|
1110
1111
|
throw new TypeError('visitor must be a function');
|
|
1111
1112
|
}
|
|
1112
1113
|
|
|
1113
1114
|
function convertValue(value) {
|
|
1114
1115
|
if (value === null) return '';
|
|
1115
1116
|
|
|
1116
|
-
if (utils$
|
|
1117
|
+
if (utils$2.isDate(value)) {
|
|
1117
1118
|
return value.toISOString();
|
|
1118
1119
|
}
|
|
1119
1120
|
|
|
1120
|
-
if (!useBlob && utils$
|
|
1121
|
+
if (!useBlob && utils$2.isBlob(value)) {
|
|
1121
1122
|
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
|
1122
1123
|
}
|
|
1123
1124
|
|
|
1124
|
-
if (utils$
|
|
1125
|
+
if (utils$2.isArrayBuffer(value) || utils$2.isTypedArray(value)) {
|
|
1125
1126
|
return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
|
1126
1127
|
}
|
|
1127
1128
|
|
|
@@ -1142,20 +1143,20 @@ function toFormData(obj, formData, options) {
|
|
|
1142
1143
|
let arr = value;
|
|
1143
1144
|
|
|
1144
1145
|
if (value && !path && typeof value === 'object') {
|
|
1145
|
-
if (utils$
|
|
1146
|
+
if (utils$2.endsWith(key, '{}')) {
|
|
1146
1147
|
// eslint-disable-next-line no-param-reassign
|
|
1147
1148
|
key = metaTokens ? key : key.slice(0, -2);
|
|
1148
1149
|
// eslint-disable-next-line no-param-reassign
|
|
1149
1150
|
value = JSON.stringify(value);
|
|
1150
1151
|
} else if (
|
|
1151
|
-
(utils$
|
|
1152
|
-
((utils$
|
|
1152
|
+
(utils$2.isArray(value) && isFlatArray(value)) ||
|
|
1153
|
+
((utils$2.isFileList(value) || utils$2.endsWith(key, '[]')) && (arr = utils$2.toArray(value))
|
|
1153
1154
|
)) {
|
|
1154
1155
|
// eslint-disable-next-line no-param-reassign
|
|
1155
1156
|
key = removeBrackets(key);
|
|
1156
1157
|
|
|
1157
1158
|
arr.forEach(function each(el, index) {
|
|
1158
|
-
!(utils$
|
|
1159
|
+
!(utils$2.isUndefined(el) || el === null) && formData.append(
|
|
1159
1160
|
// eslint-disable-next-line no-nested-ternary
|
|
1160
1161
|
indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
|
|
1161
1162
|
convertValue(el)
|
|
@@ -1183,7 +1184,7 @@ function toFormData(obj, formData, options) {
|
|
|
1183
1184
|
});
|
|
1184
1185
|
|
|
1185
1186
|
function build(value, path) {
|
|
1186
|
-
if (utils$
|
|
1187
|
+
if (utils$2.isUndefined(value)) return;
|
|
1187
1188
|
|
|
1188
1189
|
if (stack.indexOf(value) !== -1) {
|
|
1189
1190
|
throw Error('Circular reference detected in ' + path.join('.'));
|
|
@@ -1191,9 +1192,9 @@ function toFormData(obj, formData, options) {
|
|
|
1191
1192
|
|
|
1192
1193
|
stack.push(value);
|
|
1193
1194
|
|
|
1194
|
-
utils$
|
|
1195
|
-
const result = !(utils$
|
|
1196
|
-
formData, el, utils$
|
|
1195
|
+
utils$2.forEach(value, function each(el, key) {
|
|
1196
|
+
const result = !(utils$2.isUndefined(el) || el === null) && visitor.call(
|
|
1197
|
+
formData, el, utils$2.isString(key) ? key.trim() : key, path, exposedHelpers
|
|
1197
1198
|
);
|
|
1198
1199
|
|
|
1199
1200
|
if (result === true) {
|
|
@@ -1204,7 +1205,7 @@ function toFormData(obj, formData, options) {
|
|
|
1204
1205
|
stack.pop();
|
|
1205
1206
|
}
|
|
1206
1207
|
|
|
1207
|
-
if (!utils$
|
|
1208
|
+
if (!utils$2.isObject(obj)) {
|
|
1208
1209
|
throw new TypeError('data must be an object');
|
|
1209
1210
|
}
|
|
1210
1211
|
|
|
@@ -1308,7 +1309,7 @@ function buildURL(url, params, options) {
|
|
|
1308
1309
|
if (serializeFn) {
|
|
1309
1310
|
serializedParams = serializeFn(params, options);
|
|
1310
1311
|
} else {
|
|
1311
|
-
serializedParams = utils$
|
|
1312
|
+
serializedParams = utils$2.isURLSearchParams(params) ?
|
|
1312
1313
|
params.toString() :
|
|
1313
1314
|
new AxiosURLSearchParams(params, options).toString(_encode);
|
|
1314
1315
|
}
|
|
@@ -1383,7 +1384,7 @@ class InterceptorManager {
|
|
|
1383
1384
|
* @returns {void}
|
|
1384
1385
|
*/
|
|
1385
1386
|
forEach(fn) {
|
|
1386
|
-
utils$
|
|
1387
|
+
utils$2.forEach(this.handlers, function forEachHandler(h) {
|
|
1387
1388
|
if (h !== null) {
|
|
1388
1389
|
fn(h);
|
|
1389
1390
|
}
|
|
@@ -1391,8 +1392,6 @@ class InterceptorManager {
|
|
|
1391
1392
|
}
|
|
1392
1393
|
}
|
|
1393
1394
|
|
|
1394
|
-
var InterceptorManager$1 = InterceptorManager;
|
|
1395
|
-
|
|
1396
1395
|
var transitionalDefaults = {
|
|
1397
1396
|
silentJSONParsing: true,
|
|
1398
1397
|
forcedJSONParsing: true,
|
|
@@ -1459,23 +1458,23 @@ const hasStandardBrowserWebWorkerEnv = (() => {
|
|
|
1459
1458
|
|
|
1460
1459
|
const origin = hasBrowserEnv && window.location.href || 'http://localhost';
|
|
1461
1460
|
|
|
1462
|
-
var utils$
|
|
1461
|
+
var utils$1 = /*#__PURE__*/Object.freeze({
|
|
1463
1462
|
__proto__: null,
|
|
1464
1463
|
hasBrowserEnv: hasBrowserEnv,
|
|
1465
|
-
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
|
1466
1464
|
hasStandardBrowserEnv: hasStandardBrowserEnv,
|
|
1465
|
+
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
|
1467
1466
|
origin: origin
|
|
1468
1467
|
});
|
|
1469
1468
|
|
|
1470
1469
|
var platform = {
|
|
1471
|
-
...utils$
|
|
1470
|
+
...utils$1,
|
|
1472
1471
|
...platform$1
|
|
1473
1472
|
};
|
|
1474
1473
|
|
|
1475
1474
|
function toURLEncodedForm(data, options) {
|
|
1476
1475
|
return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
|
|
1477
1476
|
visitor: function(value, key, path, helpers) {
|
|
1478
|
-
if (platform.isNode && utils$
|
|
1477
|
+
if (platform.isNode && utils$2.isBuffer(value)) {
|
|
1479
1478
|
this.append(key, value.toString('base64'));
|
|
1480
1479
|
return false;
|
|
1481
1480
|
}
|
|
@@ -1497,7 +1496,7 @@ function parsePropPath(name) {
|
|
|
1497
1496
|
// foo.x.y.z
|
|
1498
1497
|
// foo-x-y-z
|
|
1499
1498
|
// foo x y z
|
|
1500
|
-
return utils$
|
|
1499
|
+
return utils$2.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
|
1501
1500
|
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
1502
1501
|
});
|
|
1503
1502
|
}
|
|
@@ -1537,10 +1536,10 @@ function formDataToJSON(formData) {
|
|
|
1537
1536
|
|
|
1538
1537
|
const isNumericKey = Number.isFinite(+name);
|
|
1539
1538
|
const isLast = index >= path.length;
|
|
1540
|
-
name = !name && utils$
|
|
1539
|
+
name = !name && utils$2.isArray(target) ? target.length : name;
|
|
1541
1540
|
|
|
1542
1541
|
if (isLast) {
|
|
1543
|
-
if (utils$
|
|
1542
|
+
if (utils$2.hasOwnProp(target, name)) {
|
|
1544
1543
|
target[name] = [target[name], value];
|
|
1545
1544
|
} else {
|
|
1546
1545
|
target[name] = value;
|
|
@@ -1549,23 +1548,23 @@ function formDataToJSON(formData) {
|
|
|
1549
1548
|
return !isNumericKey;
|
|
1550
1549
|
}
|
|
1551
1550
|
|
|
1552
|
-
if (!target[name] || !utils$
|
|
1551
|
+
if (!target[name] || !utils$2.isObject(target[name])) {
|
|
1553
1552
|
target[name] = [];
|
|
1554
1553
|
}
|
|
1555
1554
|
|
|
1556
1555
|
const result = buildPath(path, value, target[name], index);
|
|
1557
1556
|
|
|
1558
|
-
if (result && utils$
|
|
1557
|
+
if (result && utils$2.isArray(target[name])) {
|
|
1559
1558
|
target[name] = arrayToObject(target[name]);
|
|
1560
1559
|
}
|
|
1561
1560
|
|
|
1562
1561
|
return !isNumericKey;
|
|
1563
1562
|
}
|
|
1564
1563
|
|
|
1565
|
-
if (utils$
|
|
1564
|
+
if (utils$2.isFormData(formData) && utils$2.isFunction(formData.entries)) {
|
|
1566
1565
|
const obj = {};
|
|
1567
1566
|
|
|
1568
|
-
utils$
|
|
1567
|
+
utils$2.forEachEntry(formData, (name, value) => {
|
|
1569
1568
|
buildPath(parsePropPath(name), value, obj, 0);
|
|
1570
1569
|
});
|
|
1571
1570
|
|
|
@@ -1586,10 +1585,10 @@ function formDataToJSON(formData) {
|
|
|
1586
1585
|
* @returns {string} A stringified version of the rawValue.
|
|
1587
1586
|
*/
|
|
1588
1587
|
function stringifySafely(rawValue, parser, encoder) {
|
|
1589
|
-
if (utils$
|
|
1588
|
+
if (utils$2.isString(rawValue)) {
|
|
1590
1589
|
try {
|
|
1591
1590
|
(parser || JSON.parse)(rawValue);
|
|
1592
|
-
return utils$
|
|
1591
|
+
return utils$2.trim(rawValue);
|
|
1593
1592
|
} catch (e) {
|
|
1594
1593
|
if (e.name !== 'SyntaxError') {
|
|
1595
1594
|
throw e;
|
|
@@ -1597,7 +1596,7 @@ function stringifySafely(rawValue, parser, encoder) {
|
|
|
1597
1596
|
}
|
|
1598
1597
|
}
|
|
1599
1598
|
|
|
1600
|
-
return (
|
|
1599
|
+
return (0, JSON.stringify)(rawValue);
|
|
1601
1600
|
}
|
|
1602
1601
|
|
|
1603
1602
|
const defaults = {
|
|
@@ -1609,31 +1608,31 @@ const defaults = {
|
|
|
1609
1608
|
transformRequest: [function transformRequest(data, headers) {
|
|
1610
1609
|
const contentType = headers.getContentType() || '';
|
|
1611
1610
|
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
1612
|
-
const isObjectPayload = utils$
|
|
1611
|
+
const isObjectPayload = utils$2.isObject(data);
|
|
1613
1612
|
|
|
1614
|
-
if (isObjectPayload && utils$
|
|
1613
|
+
if (isObjectPayload && utils$2.isHTMLForm(data)) {
|
|
1615
1614
|
data = new FormData(data);
|
|
1616
1615
|
}
|
|
1617
1616
|
|
|
1618
|
-
const isFormData = utils$
|
|
1617
|
+
const isFormData = utils$2.isFormData(data);
|
|
1619
1618
|
|
|
1620
1619
|
if (isFormData) {
|
|
1621
1620
|
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
1622
1621
|
}
|
|
1623
1622
|
|
|
1624
|
-
if (utils$
|
|
1625
|
-
utils$
|
|
1626
|
-
utils$
|
|
1627
|
-
utils$
|
|
1628
|
-
utils$
|
|
1629
|
-
utils$
|
|
1623
|
+
if (utils$2.isArrayBuffer(data) ||
|
|
1624
|
+
utils$2.isBuffer(data) ||
|
|
1625
|
+
utils$2.isStream(data) ||
|
|
1626
|
+
utils$2.isFile(data) ||
|
|
1627
|
+
utils$2.isBlob(data) ||
|
|
1628
|
+
utils$2.isReadableStream(data)
|
|
1630
1629
|
) {
|
|
1631
1630
|
return data;
|
|
1632
1631
|
}
|
|
1633
|
-
if (utils$
|
|
1632
|
+
if (utils$2.isArrayBufferView(data)) {
|
|
1634
1633
|
return data.buffer;
|
|
1635
1634
|
}
|
|
1636
|
-
if (utils$
|
|
1635
|
+
if (utils$2.isURLSearchParams(data)) {
|
|
1637
1636
|
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
1638
1637
|
return data.toString();
|
|
1639
1638
|
}
|
|
@@ -1645,7 +1644,7 @@ const defaults = {
|
|
|
1645
1644
|
return toURLEncodedForm(data, this.formSerializer).toString();
|
|
1646
1645
|
}
|
|
1647
1646
|
|
|
1648
|
-
if ((isFileList = utils$
|
|
1647
|
+
if ((isFileList = utils$2.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
|
1649
1648
|
const _FormData = this.env && this.env.FormData;
|
|
1650
1649
|
|
|
1651
1650
|
return toFormData(
|
|
@@ -1669,11 +1668,11 @@ const defaults = {
|
|
|
1669
1668
|
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
1670
1669
|
const JSONRequested = this.responseType === 'json';
|
|
1671
1670
|
|
|
1672
|
-
if (utils$
|
|
1671
|
+
if (utils$2.isResponse(data) || utils$2.isReadableStream(data)) {
|
|
1673
1672
|
return data;
|
|
1674
1673
|
}
|
|
1675
1674
|
|
|
1676
|
-
if (data && utils$
|
|
1675
|
+
if (data && utils$2.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
|
1677
1676
|
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
1678
1677
|
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
1679
1678
|
|
|
@@ -1721,15 +1720,13 @@ const defaults = {
|
|
|
1721
1720
|
}
|
|
1722
1721
|
};
|
|
1723
1722
|
|
|
1724
|
-
utils$
|
|
1723
|
+
utils$2.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
|
1725
1724
|
defaults.headers[method] = {};
|
|
1726
1725
|
});
|
|
1727
1726
|
|
|
1728
|
-
var defaults$1 = defaults;
|
|
1729
|
-
|
|
1730
1727
|
// RawAxiosHeaders whose duplicates are ignored by node
|
|
1731
1728
|
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
1732
|
-
const ignoreDuplicateOf = utils$
|
|
1729
|
+
const ignoreDuplicateOf = utils$2.toObjectSet([
|
|
1733
1730
|
'age', 'authorization', 'content-length', 'content-type', 'etag',
|
|
1734
1731
|
'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
|
|
1735
1732
|
'last-modified', 'location', 'max-forwards', 'proxy-authorization',
|
|
@@ -1790,7 +1787,7 @@ function normalizeValue(value) {
|
|
|
1790
1787
|
return value;
|
|
1791
1788
|
}
|
|
1792
1789
|
|
|
1793
|
-
return utils$
|
|
1790
|
+
return utils$2.isArray(value) ? value.map(normalizeValue) : String(value);
|
|
1794
1791
|
}
|
|
1795
1792
|
|
|
1796
1793
|
function parseTokens(str) {
|
|
@@ -1808,7 +1805,7 @@ function parseTokens(str) {
|
|
|
1808
1805
|
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
1809
1806
|
|
|
1810
1807
|
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
1811
|
-
if (utils$
|
|
1808
|
+
if (utils$2.isFunction(filter)) {
|
|
1812
1809
|
return filter.call(this, value, header);
|
|
1813
1810
|
}
|
|
1814
1811
|
|
|
@@ -1816,13 +1813,13 @@ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
|
1816
1813
|
value = header;
|
|
1817
1814
|
}
|
|
1818
1815
|
|
|
1819
|
-
if (!utils$
|
|
1816
|
+
if (!utils$2.isString(value)) return;
|
|
1820
1817
|
|
|
1821
|
-
if (utils$
|
|
1818
|
+
if (utils$2.isString(filter)) {
|
|
1822
1819
|
return value.indexOf(filter) !== -1;
|
|
1823
1820
|
}
|
|
1824
1821
|
|
|
1825
|
-
if (utils$
|
|
1822
|
+
if (utils$2.isRegExp(filter)) {
|
|
1826
1823
|
return filter.test(value);
|
|
1827
1824
|
}
|
|
1828
1825
|
}
|
|
@@ -1835,7 +1832,7 @@ function formatHeader(header) {
|
|
|
1835
1832
|
}
|
|
1836
1833
|
|
|
1837
1834
|
function buildAccessors(obj, header) {
|
|
1838
|
-
const accessorName = utils$
|
|
1835
|
+
const accessorName = utils$2.toCamelCase(' ' + header);
|
|
1839
1836
|
|
|
1840
1837
|
['get', 'set', 'has'].forEach(methodName => {
|
|
1841
1838
|
Object.defineProperty(obj, methodName + accessorName, {
|
|
@@ -1862,7 +1859,7 @@ class AxiosHeaders {
|
|
|
1862
1859
|
throw new Error('header name must be a non-empty string');
|
|
1863
1860
|
}
|
|
1864
1861
|
|
|
1865
|
-
const key = utils$
|
|
1862
|
+
const key = utils$2.findKey(self, lHeader);
|
|
1866
1863
|
|
|
1867
1864
|
if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
|
|
1868
1865
|
self[key || _header] = normalizeValue(_value);
|
|
@@ -1870,13 +1867,13 @@ class AxiosHeaders {
|
|
|
1870
1867
|
}
|
|
1871
1868
|
|
|
1872
1869
|
const setHeaders = (headers, _rewrite) =>
|
|
1873
|
-
utils$
|
|
1870
|
+
utils$2.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
1874
1871
|
|
|
1875
|
-
if (utils$
|
|
1872
|
+
if (utils$2.isPlainObject(header) || header instanceof this.constructor) {
|
|
1876
1873
|
setHeaders(header, valueOrRewrite);
|
|
1877
|
-
} else if(utils$
|
|
1874
|
+
} else if(utils$2.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
1878
1875
|
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
1879
|
-
} else if (utils$
|
|
1876
|
+
} else if (utils$2.isHeaders(header)) {
|
|
1880
1877
|
for (const [key, value] of header.entries()) {
|
|
1881
1878
|
setHeader(value, key, rewrite);
|
|
1882
1879
|
}
|
|
@@ -1891,7 +1888,7 @@ class AxiosHeaders {
|
|
|
1891
1888
|
header = normalizeHeader(header);
|
|
1892
1889
|
|
|
1893
1890
|
if (header) {
|
|
1894
|
-
const key = utils$
|
|
1891
|
+
const key = utils$2.findKey(this, header);
|
|
1895
1892
|
|
|
1896
1893
|
if (key) {
|
|
1897
1894
|
const value = this[key];
|
|
@@ -1904,11 +1901,11 @@ class AxiosHeaders {
|
|
|
1904
1901
|
return parseTokens(value);
|
|
1905
1902
|
}
|
|
1906
1903
|
|
|
1907
|
-
if (utils$
|
|
1904
|
+
if (utils$2.isFunction(parser)) {
|
|
1908
1905
|
return parser.call(this, value, key);
|
|
1909
1906
|
}
|
|
1910
1907
|
|
|
1911
|
-
if (utils$
|
|
1908
|
+
if (utils$2.isRegExp(parser)) {
|
|
1912
1909
|
return parser.exec(value);
|
|
1913
1910
|
}
|
|
1914
1911
|
|
|
@@ -1921,7 +1918,7 @@ class AxiosHeaders {
|
|
|
1921
1918
|
header = normalizeHeader(header);
|
|
1922
1919
|
|
|
1923
1920
|
if (header) {
|
|
1924
|
-
const key = utils$
|
|
1921
|
+
const key = utils$2.findKey(this, header);
|
|
1925
1922
|
|
|
1926
1923
|
return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
|
1927
1924
|
}
|
|
@@ -1937,7 +1934,7 @@ class AxiosHeaders {
|
|
|
1937
1934
|
_header = normalizeHeader(_header);
|
|
1938
1935
|
|
|
1939
1936
|
if (_header) {
|
|
1940
|
-
const key = utils$
|
|
1937
|
+
const key = utils$2.findKey(self, _header);
|
|
1941
1938
|
|
|
1942
1939
|
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
|
1943
1940
|
delete self[key];
|
|
@@ -1947,7 +1944,7 @@ class AxiosHeaders {
|
|
|
1947
1944
|
}
|
|
1948
1945
|
}
|
|
1949
1946
|
|
|
1950
|
-
if (utils$
|
|
1947
|
+
if (utils$2.isArray(header)) {
|
|
1951
1948
|
header.forEach(deleteHeader);
|
|
1952
1949
|
} else {
|
|
1953
1950
|
deleteHeader(header);
|
|
@@ -1976,8 +1973,8 @@ class AxiosHeaders {
|
|
|
1976
1973
|
const self = this;
|
|
1977
1974
|
const headers = {};
|
|
1978
1975
|
|
|
1979
|
-
utils$
|
|
1980
|
-
const key = utils$
|
|
1976
|
+
utils$2.forEach(this, (value, header) => {
|
|
1977
|
+
const key = utils$2.findKey(headers, header);
|
|
1981
1978
|
|
|
1982
1979
|
if (key) {
|
|
1983
1980
|
self[key] = normalizeValue(value);
|
|
@@ -2006,8 +2003,8 @@ class AxiosHeaders {
|
|
|
2006
2003
|
toJSON(asStrings) {
|
|
2007
2004
|
const obj = Object.create(null);
|
|
2008
2005
|
|
|
2009
|
-
utils$
|
|
2010
|
-
value != null && value !== false && (obj[header] = asStrings && utils$
|
|
2006
|
+
utils$2.forEach(this, (value, header) => {
|
|
2007
|
+
value != null && value !== false && (obj[header] = asStrings && utils$2.isArray(value) ? value.join(', ') : value);
|
|
2011
2008
|
});
|
|
2012
2009
|
|
|
2013
2010
|
return obj;
|
|
@@ -2054,7 +2051,7 @@ class AxiosHeaders {
|
|
|
2054
2051
|
}
|
|
2055
2052
|
}
|
|
2056
2053
|
|
|
2057
|
-
utils$
|
|
2054
|
+
utils$2.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
|
2058
2055
|
|
|
2059
2056
|
return this;
|
|
2060
2057
|
}
|
|
@@ -2063,7 +2060,7 @@ class AxiosHeaders {
|
|
|
2063
2060
|
AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
|
|
2064
2061
|
|
|
2065
2062
|
// reserved names hotfix
|
|
2066
|
-
utils$
|
|
2063
|
+
utils$2.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
|
|
2067
2064
|
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|
2068
2065
|
return {
|
|
2069
2066
|
get: () => value,
|
|
@@ -2073,9 +2070,7 @@ utils$3.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
|
|
|
2073
2070
|
}
|
|
2074
2071
|
});
|
|
2075
2072
|
|
|
2076
|
-
utils$
|
|
2077
|
-
|
|
2078
|
-
var AxiosHeaders$1 = AxiosHeaders;
|
|
2073
|
+
utils$2.freezeMethods(AxiosHeaders);
|
|
2079
2074
|
|
|
2080
2075
|
/**
|
|
2081
2076
|
* Transform the data for a request or a response
|
|
@@ -2086,12 +2081,12 @@ var AxiosHeaders$1 = AxiosHeaders;
|
|
|
2086
2081
|
* @returns {*} The resulting transformed data
|
|
2087
2082
|
*/
|
|
2088
2083
|
function transformData(fns, response) {
|
|
2089
|
-
const config = this || defaults
|
|
2084
|
+
const config = this || defaults;
|
|
2090
2085
|
const context = response || config;
|
|
2091
|
-
const headers = AxiosHeaders
|
|
2086
|
+
const headers = AxiosHeaders.from(context.headers);
|
|
2092
2087
|
let data = context.data;
|
|
2093
2088
|
|
|
2094
|
-
utils$
|
|
2089
|
+
utils$2.forEach(fns, function transform(fn) {
|
|
2095
2090
|
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
|
2096
2091
|
});
|
|
2097
2092
|
|
|
@@ -2119,7 +2114,7 @@ function CanceledError(message, config, request) {
|
|
|
2119
2114
|
this.name = 'CanceledError';
|
|
2120
2115
|
}
|
|
2121
2116
|
|
|
2122
|
-
utils$
|
|
2117
|
+
utils$2.inherits(CanceledError, AxiosError, {
|
|
2123
2118
|
__CANCEL__: true
|
|
2124
2119
|
});
|
|
2125
2120
|
|
|
@@ -2286,7 +2281,7 @@ const progressEventDecorator = (total, throttled) => {
|
|
|
2286
2281
|
}), throttled[1]];
|
|
2287
2282
|
};
|
|
2288
2283
|
|
|
2289
|
-
const asyncDecorator = (fn) => (...args) => utils$
|
|
2284
|
+
const asyncDecorator = (fn) => (...args) => utils$2.asap(() => fn(...args));
|
|
2290
2285
|
|
|
2291
2286
|
var isURLSameOrigin = platform.hasStandardBrowserEnv ?
|
|
2292
2287
|
|
|
@@ -2338,7 +2333,7 @@ var isURLSameOrigin = platform.hasStandardBrowserEnv ?
|
|
|
2338
2333
|
* @returns {boolean} True if URL shares the same origin, otherwise false
|
|
2339
2334
|
*/
|
|
2340
2335
|
return function isURLSameOrigin(requestURL) {
|
|
2341
|
-
const parsed = (utils$
|
|
2336
|
+
const parsed = (utils$2.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
|
2342
2337
|
return (parsed.protocol === originURL.protocol &&
|
|
2343
2338
|
parsed.host === originURL.host);
|
|
2344
2339
|
};
|
|
@@ -2358,11 +2353,11 @@ var cookies = platform.hasStandardBrowserEnv ?
|
|
|
2358
2353
|
write(name, value, expires, path, domain, secure) {
|
|
2359
2354
|
const cookie = [name + '=' + encodeURIComponent(value)];
|
|
2360
2355
|
|
|
2361
|
-
utils$
|
|
2356
|
+
utils$2.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
|
|
2362
2357
|
|
|
2363
|
-
utils$
|
|
2358
|
+
utils$2.isString(path) && cookie.push('path=' + path);
|
|
2364
2359
|
|
|
2365
|
-
utils$
|
|
2360
|
+
utils$2.isString(domain) && cookie.push('domain=' + domain);
|
|
2366
2361
|
|
|
2367
2362
|
secure === true && cookie.push('secure');
|
|
2368
2363
|
|
|
@@ -2435,7 +2430,7 @@ function buildFullPath(baseURL, requestedURL) {
|
|
|
2435
2430
|
return requestedURL;
|
|
2436
2431
|
}
|
|
2437
2432
|
|
|
2438
|
-
const headersToObject = (thing) => thing instanceof AxiosHeaders
|
|
2433
|
+
const headersToObject = (thing) => thing instanceof AxiosHeaders ? { ...thing } : thing;
|
|
2439
2434
|
|
|
2440
2435
|
/**
|
|
2441
2436
|
* Config-specific merge-function which creates a new config-object
|
|
@@ -2452,11 +2447,11 @@ function mergeConfig(config1, config2) {
|
|
|
2452
2447
|
const config = {};
|
|
2453
2448
|
|
|
2454
2449
|
function getMergedValue(target, source, caseless) {
|
|
2455
|
-
if (utils$
|
|
2456
|
-
return utils$
|
|
2457
|
-
} else if (utils$
|
|
2458
|
-
return utils$
|
|
2459
|
-
} else if (utils$
|
|
2450
|
+
if (utils$2.isPlainObject(target) && utils$2.isPlainObject(source)) {
|
|
2451
|
+
return utils$2.merge.call({caseless}, target, source);
|
|
2452
|
+
} else if (utils$2.isPlainObject(source)) {
|
|
2453
|
+
return utils$2.merge({}, source);
|
|
2454
|
+
} else if (utils$2.isArray(source)) {
|
|
2460
2455
|
return source.slice();
|
|
2461
2456
|
}
|
|
2462
2457
|
return source;
|
|
@@ -2464,25 +2459,25 @@ function mergeConfig(config1, config2) {
|
|
|
2464
2459
|
|
|
2465
2460
|
// eslint-disable-next-line consistent-return
|
|
2466
2461
|
function mergeDeepProperties(a, b, caseless) {
|
|
2467
|
-
if (!utils$
|
|
2462
|
+
if (!utils$2.isUndefined(b)) {
|
|
2468
2463
|
return getMergedValue(a, b, caseless);
|
|
2469
|
-
} else if (!utils$
|
|
2464
|
+
} else if (!utils$2.isUndefined(a)) {
|
|
2470
2465
|
return getMergedValue(undefined, a, caseless);
|
|
2471
2466
|
}
|
|
2472
2467
|
}
|
|
2473
2468
|
|
|
2474
2469
|
// eslint-disable-next-line consistent-return
|
|
2475
2470
|
function valueFromConfig2(a, b) {
|
|
2476
|
-
if (!utils$
|
|
2471
|
+
if (!utils$2.isUndefined(b)) {
|
|
2477
2472
|
return getMergedValue(undefined, b);
|
|
2478
2473
|
}
|
|
2479
2474
|
}
|
|
2480
2475
|
|
|
2481
2476
|
// eslint-disable-next-line consistent-return
|
|
2482
2477
|
function defaultToConfig2(a, b) {
|
|
2483
|
-
if (!utils$
|
|
2478
|
+
if (!utils$2.isUndefined(b)) {
|
|
2484
2479
|
return getMergedValue(undefined, b);
|
|
2485
|
-
} else if (!utils$
|
|
2480
|
+
} else if (!utils$2.isUndefined(a)) {
|
|
2486
2481
|
return getMergedValue(undefined, a);
|
|
2487
2482
|
}
|
|
2488
2483
|
}
|
|
@@ -2528,10 +2523,10 @@ function mergeConfig(config1, config2) {
|
|
|
2528
2523
|
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
|
2529
2524
|
};
|
|
2530
2525
|
|
|
2531
|
-
utils$
|
|
2526
|
+
utils$2.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
|
2532
2527
|
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
2533
2528
|
const configValue = merge(config1[prop], config2[prop], prop);
|
|
2534
|
-
(utils$
|
|
2529
|
+
(utils$2.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
2535
2530
|
});
|
|
2536
2531
|
|
|
2537
2532
|
return config;
|
|
@@ -2542,7 +2537,7 @@ var resolveConfig = (config) => {
|
|
|
2542
2537
|
|
|
2543
2538
|
let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
|
|
2544
2539
|
|
|
2545
|
-
newConfig.headers = headers = AxiosHeaders
|
|
2540
|
+
newConfig.headers = headers = AxiosHeaders.from(headers);
|
|
2546
2541
|
|
|
2547
2542
|
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
|
|
2548
2543
|
|
|
@@ -2555,7 +2550,7 @@ var resolveConfig = (config) => {
|
|
|
2555
2550
|
|
|
2556
2551
|
let contentType;
|
|
2557
2552
|
|
|
2558
|
-
if (utils$
|
|
2553
|
+
if (utils$2.isFormData(data)) {
|
|
2559
2554
|
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|
2560
2555
|
headers.setContentType(undefined); // Let the browser set it
|
|
2561
2556
|
} else if ((contentType = headers.getContentType()) !== false) {
|
|
@@ -2570,7 +2565,7 @@ var resolveConfig = (config) => {
|
|
|
2570
2565
|
// Specifically not if we're in a web worker, or react-native.
|
|
2571
2566
|
|
|
2572
2567
|
if (platform.hasStandardBrowserEnv) {
|
|
2573
|
-
withXSRFToken && utils$
|
|
2568
|
+
withXSRFToken && utils$2.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
|
|
2574
2569
|
|
|
2575
2570
|
if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
|
|
2576
2571
|
// Add xsrf header
|
|
@@ -2591,7 +2586,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
2591
2586
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
2592
2587
|
const _config = resolveConfig(config);
|
|
2593
2588
|
let requestData = _config.data;
|
|
2594
|
-
const requestHeaders = AxiosHeaders
|
|
2589
|
+
const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
|
|
2595
2590
|
let {responseType, onUploadProgress, onDownloadProgress} = _config;
|
|
2596
2591
|
let onCanceled;
|
|
2597
2592
|
let uploadThrottled, downloadThrottled;
|
|
@@ -2618,7 +2613,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
2618
2613
|
return;
|
|
2619
2614
|
}
|
|
2620
2615
|
// Prepare the response
|
|
2621
|
-
const responseHeaders = AxiosHeaders
|
|
2616
|
+
const responseHeaders = AxiosHeaders.from(
|
|
2622
2617
|
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
|
2623
2618
|
);
|
|
2624
2619
|
const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
|
@@ -2711,13 +2706,13 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
2711
2706
|
|
|
2712
2707
|
// Add headers to the request
|
|
2713
2708
|
if ('setRequestHeader' in request) {
|
|
2714
|
-
utils$
|
|
2709
|
+
utils$2.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
|
2715
2710
|
request.setRequestHeader(key, val);
|
|
2716
2711
|
});
|
|
2717
2712
|
}
|
|
2718
2713
|
|
|
2719
2714
|
// Add withCredentials to request if needed
|
|
2720
|
-
if (!utils$
|
|
2715
|
+
if (!utils$2.isUndefined(_config.withCredentials)) {
|
|
2721
2716
|
request.withCredentials = !!_config.withCredentials;
|
|
2722
2717
|
}
|
|
2723
2718
|
|
|
@@ -2814,12 +2809,10 @@ const composeSignals = (signals, timeout) => {
|
|
|
2814
2809
|
}];
|
|
2815
2810
|
};
|
|
2816
2811
|
|
|
2817
|
-
var composeSignals$1 = composeSignals;
|
|
2818
|
-
|
|
2819
2812
|
const streamChunk = function* (chunk, chunkSize) {
|
|
2820
2813
|
let len = chunk.byteLength;
|
|
2821
2814
|
|
|
2822
|
-
if (
|
|
2815
|
+
if (len < chunkSize) {
|
|
2823
2816
|
yield chunk;
|
|
2824
2817
|
return;
|
|
2825
2818
|
}
|
|
@@ -2918,7 +2911,7 @@ const supportsRequestStream = isReadableStreamSupported && test(() => {
|
|
|
2918
2911
|
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
2919
2912
|
|
|
2920
2913
|
const supportsResponseStream = isReadableStreamSupported &&
|
|
2921
|
-
test(() => utils$
|
|
2914
|
+
test(() => utils$2.isReadableStream(new Response('').body));
|
|
2922
2915
|
|
|
2923
2916
|
|
|
2924
2917
|
const resolvers = {
|
|
@@ -2927,7 +2920,7 @@ const resolvers = {
|
|
|
2927
2920
|
|
|
2928
2921
|
isFetchSupported && (((res) => {
|
|
2929
2922
|
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
|
2930
|
-
!resolvers[type] && (resolvers[type] = utils$
|
|
2923
|
+
!resolvers[type] && (resolvers[type] = utils$2.isFunction(res[type]) ? (res) => res[type]() :
|
|
2931
2924
|
(_, config) => {
|
|
2932
2925
|
throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
|
|
2933
2926
|
});
|
|
@@ -2939,29 +2932,29 @@ const getBodyLength = async (body) => {
|
|
|
2939
2932
|
return 0;
|
|
2940
2933
|
}
|
|
2941
2934
|
|
|
2942
|
-
if(utils$
|
|
2935
|
+
if(utils$2.isBlob(body)) {
|
|
2943
2936
|
return body.size;
|
|
2944
2937
|
}
|
|
2945
2938
|
|
|
2946
|
-
if(utils$
|
|
2939
|
+
if(utils$2.isSpecCompliantForm(body)) {
|
|
2947
2940
|
return (await new Request(body).arrayBuffer()).byteLength;
|
|
2948
2941
|
}
|
|
2949
2942
|
|
|
2950
|
-
if(utils$
|
|
2943
|
+
if(utils$2.isArrayBufferView(body) || utils$2.isArrayBuffer(body)) {
|
|
2951
2944
|
return body.byteLength;
|
|
2952
2945
|
}
|
|
2953
2946
|
|
|
2954
|
-
if(utils$
|
|
2947
|
+
if(utils$2.isURLSearchParams(body)) {
|
|
2955
2948
|
body = body + '';
|
|
2956
2949
|
}
|
|
2957
2950
|
|
|
2958
|
-
if(utils$
|
|
2951
|
+
if(utils$2.isString(body)) {
|
|
2959
2952
|
return (await encodeText(body)).byteLength;
|
|
2960
2953
|
}
|
|
2961
2954
|
};
|
|
2962
2955
|
|
|
2963
2956
|
const resolveBodyLength = async (headers, body) => {
|
|
2964
|
-
const length = utils$
|
|
2957
|
+
const length = utils$2.toFiniteNumber(headers.getContentLength());
|
|
2965
2958
|
|
|
2966
2959
|
return length == null ? getBodyLength(body) : length;
|
|
2967
2960
|
};
|
|
@@ -2985,7 +2978,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
2985
2978
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
2986
2979
|
|
|
2987
2980
|
let [composedSignal, stopTimeout] = (signal || cancelToken || timeout) ?
|
|
2988
|
-
composeSignals
|
|
2981
|
+
composeSignals([signal, cancelToken], timeout) : [];
|
|
2989
2982
|
|
|
2990
2983
|
let finished, request;
|
|
2991
2984
|
|
|
@@ -3012,7 +3005,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
3012
3005
|
|
|
3013
3006
|
let contentTypeHeader;
|
|
3014
3007
|
|
|
3015
|
-
if (utils$
|
|
3008
|
+
if (utils$2.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
|
|
3016
3009
|
headers.setContentType(contentTypeHeader);
|
|
3017
3010
|
}
|
|
3018
3011
|
|
|
@@ -3026,7 +3019,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
3026
3019
|
}
|
|
3027
3020
|
}
|
|
3028
3021
|
|
|
3029
|
-
if (!utils$
|
|
3022
|
+
if (!utils$2.isString(withCredentials)) {
|
|
3030
3023
|
withCredentials = withCredentials ? 'include' : 'omit';
|
|
3031
3024
|
}
|
|
3032
3025
|
|
|
@@ -3051,7 +3044,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
3051
3044
|
options[prop] = response[prop];
|
|
3052
3045
|
});
|
|
3053
3046
|
|
|
3054
|
-
const responseContentLength = utils$
|
|
3047
|
+
const responseContentLength = utils$2.toFiniteNumber(response.headers.get('content-length'));
|
|
3055
3048
|
|
|
3056
3049
|
const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
|
|
3057
3050
|
responseContentLength,
|
|
@@ -3069,7 +3062,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
3069
3062
|
|
|
3070
3063
|
responseType = responseType || 'text';
|
|
3071
3064
|
|
|
3072
|
-
let responseData = await resolvers[utils$
|
|
3065
|
+
let responseData = await resolvers[utils$2.findKey(resolvers, responseType) || 'text'](response, config);
|
|
3073
3066
|
|
|
3074
3067
|
!isStreamResponse && onFinish();
|
|
3075
3068
|
|
|
@@ -3078,7 +3071,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
3078
3071
|
return await new Promise((resolve, reject) => {
|
|
3079
3072
|
settle(resolve, reject, {
|
|
3080
3073
|
data: responseData,
|
|
3081
|
-
headers: AxiosHeaders
|
|
3074
|
+
headers: AxiosHeaders.from(response.headers),
|
|
3082
3075
|
status: response.status,
|
|
3083
3076
|
statusText: response.statusText,
|
|
3084
3077
|
config,
|
|
@@ -3107,7 +3100,7 @@ const knownAdapters = {
|
|
|
3107
3100
|
fetch: fetchAdapter
|
|
3108
3101
|
};
|
|
3109
3102
|
|
|
3110
|
-
utils$
|
|
3103
|
+
utils$2.forEach(knownAdapters, (fn, value) => {
|
|
3111
3104
|
if (fn) {
|
|
3112
3105
|
try {
|
|
3113
3106
|
Object.defineProperty(fn, 'name', {value});
|
|
@@ -3120,11 +3113,11 @@ utils$3.forEach(knownAdapters, (fn, value) => {
|
|
|
3120
3113
|
|
|
3121
3114
|
const renderReason = (reason) => `- ${reason}`;
|
|
3122
3115
|
|
|
3123
|
-
const isResolvedHandle = (adapter) => utils$
|
|
3116
|
+
const isResolvedHandle = (adapter) => utils$2.isFunction(adapter) || adapter === null || adapter === false;
|
|
3124
3117
|
|
|
3125
3118
|
var adapters = {
|
|
3126
3119
|
getAdapter: (adapters) => {
|
|
3127
|
-
adapters = utils$
|
|
3120
|
+
adapters = utils$2.isArray(adapters) ? adapters : [adapters];
|
|
3128
3121
|
|
|
3129
3122
|
const {length} = adapters;
|
|
3130
3123
|
let nameOrAdapter;
|
|
@@ -3202,7 +3195,7 @@ function throwIfCancellationRequested(config) {
|
|
|
3202
3195
|
function dispatchRequest(config) {
|
|
3203
3196
|
throwIfCancellationRequested(config);
|
|
3204
3197
|
|
|
3205
|
-
config.headers = AxiosHeaders
|
|
3198
|
+
config.headers = AxiosHeaders.from(config.headers);
|
|
3206
3199
|
|
|
3207
3200
|
// Transform request data
|
|
3208
3201
|
config.data = transformData.call(
|
|
@@ -3214,7 +3207,7 @@ function dispatchRequest(config) {
|
|
|
3214
3207
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
|
3215
3208
|
}
|
|
3216
3209
|
|
|
3217
|
-
const adapter = adapters.getAdapter(config.adapter || defaults
|
|
3210
|
+
const adapter = adapters.getAdapter(config.adapter || defaults.adapter);
|
|
3218
3211
|
|
|
3219
3212
|
return adapter(config).then(function onAdapterResolution(response) {
|
|
3220
3213
|
throwIfCancellationRequested(config);
|
|
@@ -3226,7 +3219,7 @@ function dispatchRequest(config) {
|
|
|
3226
3219
|
response
|
|
3227
3220
|
);
|
|
3228
3221
|
|
|
3229
|
-
response.headers = AxiosHeaders
|
|
3222
|
+
response.headers = AxiosHeaders.from(response.headers);
|
|
3230
3223
|
|
|
3231
3224
|
return response;
|
|
3232
3225
|
}, function onAdapterRejection(reason) {
|
|
@@ -3240,7 +3233,7 @@ function dispatchRequest(config) {
|
|
|
3240
3233
|
config.transformResponse,
|
|
3241
3234
|
reason.response
|
|
3242
3235
|
);
|
|
3243
|
-
reason.response.headers = AxiosHeaders
|
|
3236
|
+
reason.response.headers = AxiosHeaders.from(reason.response.headers);
|
|
3244
3237
|
}
|
|
3245
3238
|
}
|
|
3246
3239
|
|
|
@@ -3350,8 +3343,8 @@ class Axios {
|
|
|
3350
3343
|
constructor(instanceConfig) {
|
|
3351
3344
|
this.defaults = instanceConfig;
|
|
3352
3345
|
this.interceptors = {
|
|
3353
|
-
request: new InterceptorManager
|
|
3354
|
-
response: new InterceptorManager
|
|
3346
|
+
request: new InterceptorManager(),
|
|
3347
|
+
response: new InterceptorManager()
|
|
3355
3348
|
};
|
|
3356
3349
|
}
|
|
3357
3350
|
|
|
@@ -3413,7 +3406,7 @@ class Axios {
|
|
|
3413
3406
|
}
|
|
3414
3407
|
|
|
3415
3408
|
if (paramsSerializer != null) {
|
|
3416
|
-
if (utils$
|
|
3409
|
+
if (utils$2.isFunction(paramsSerializer)) {
|
|
3417
3410
|
config.paramsSerializer = {
|
|
3418
3411
|
serialize: paramsSerializer
|
|
3419
3412
|
};
|
|
@@ -3429,19 +3422,19 @@ class Axios {
|
|
|
3429
3422
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
|
3430
3423
|
|
|
3431
3424
|
// Flatten headers
|
|
3432
|
-
let contextHeaders = headers && utils$
|
|
3425
|
+
let contextHeaders = headers && utils$2.merge(
|
|
3433
3426
|
headers.common,
|
|
3434
3427
|
headers[config.method]
|
|
3435
3428
|
);
|
|
3436
3429
|
|
|
3437
|
-
headers && utils$
|
|
3430
|
+
headers && utils$2.forEach(
|
|
3438
3431
|
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
|
3439
3432
|
(method) => {
|
|
3440
3433
|
delete headers[method];
|
|
3441
3434
|
}
|
|
3442
3435
|
);
|
|
3443
3436
|
|
|
3444
|
-
config.headers = AxiosHeaders
|
|
3437
|
+
config.headers = AxiosHeaders.concat(contextHeaders, headers);
|
|
3445
3438
|
|
|
3446
3439
|
// filter out skipped interceptors
|
|
3447
3440
|
const requestInterceptorChain = [];
|
|
@@ -3521,7 +3514,7 @@ class Axios {
|
|
|
3521
3514
|
}
|
|
3522
3515
|
|
|
3523
3516
|
// Provide aliases for supported request methods
|
|
3524
|
-
utils$
|
|
3517
|
+
utils$2.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
|
3525
3518
|
/*eslint func-names:0*/
|
|
3526
3519
|
Axios.prototype[method] = function(url, config) {
|
|
3527
3520
|
return this.request(mergeConfig(config || {}, {
|
|
@@ -3532,7 +3525,7 @@ utils$3.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoDa
|
|
|
3532
3525
|
};
|
|
3533
3526
|
});
|
|
3534
3527
|
|
|
3535
|
-
utils$
|
|
3528
|
+
utils$2.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
3536
3529
|
/*eslint func-names:0*/
|
|
3537
3530
|
|
|
3538
3531
|
function generateHTTPMethod(isForm) {
|
|
@@ -3553,8 +3546,6 @@ utils$3.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method)
|
|
|
3553
3546
|
Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
|
|
3554
3547
|
});
|
|
3555
3548
|
|
|
3556
|
-
var Axios$1 = Axios;
|
|
3557
|
-
|
|
3558
3549
|
/**
|
|
3559
3550
|
* A `CancelToken` is an object that can be used to request cancellation of an operation.
|
|
3560
3551
|
*
|
|
@@ -3671,8 +3662,6 @@ class CancelToken {
|
|
|
3671
3662
|
}
|
|
3672
3663
|
}
|
|
3673
3664
|
|
|
3674
|
-
var CancelToken$1 = CancelToken;
|
|
3675
|
-
|
|
3676
3665
|
/**
|
|
3677
3666
|
* Syntactic sugar for invoking a function and expanding an array for arguments.
|
|
3678
3667
|
*
|
|
@@ -3708,7 +3697,7 @@ function spread(callback) {
|
|
|
3708
3697
|
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
|
3709
3698
|
*/
|
|
3710
3699
|
function isAxiosError(payload) {
|
|
3711
|
-
return utils$
|
|
3700
|
+
return utils$2.isObject(payload) && (payload.isAxiosError === true);
|
|
3712
3701
|
}
|
|
3713
3702
|
|
|
3714
3703
|
const HttpStatusCode = {
|
|
@@ -3781,8 +3770,6 @@ Object.entries(HttpStatusCode).forEach(([key, value]) => {
|
|
|
3781
3770
|
HttpStatusCode[value] = key;
|
|
3782
3771
|
});
|
|
3783
3772
|
|
|
3784
|
-
var HttpStatusCode$1 = HttpStatusCode;
|
|
3785
|
-
|
|
3786
3773
|
/**
|
|
3787
3774
|
* Create an instance of Axios
|
|
3788
3775
|
*
|
|
@@ -3791,14 +3778,14 @@ var HttpStatusCode$1 = HttpStatusCode;
|
|
|
3791
3778
|
* @returns {Axios} A new instance of Axios
|
|
3792
3779
|
*/
|
|
3793
3780
|
function createInstance(defaultConfig) {
|
|
3794
|
-
const context = new Axios
|
|
3795
|
-
const instance = bind(Axios
|
|
3781
|
+
const context = new Axios(defaultConfig);
|
|
3782
|
+
const instance = bind(Axios.prototype.request, context);
|
|
3796
3783
|
|
|
3797
3784
|
// Copy axios.prototype to instance
|
|
3798
|
-
utils$
|
|
3785
|
+
utils$2.extend(instance, Axios.prototype, context, {allOwnKeys: true});
|
|
3799
3786
|
|
|
3800
3787
|
// Copy context to instance
|
|
3801
|
-
utils$
|
|
3788
|
+
utils$2.extend(instance, context, null, {allOwnKeys: true});
|
|
3802
3789
|
|
|
3803
3790
|
// Factory for creating new instances
|
|
3804
3791
|
instance.create = function create(instanceConfig) {
|
|
@@ -3809,14 +3796,14 @@ function createInstance(defaultConfig) {
|
|
|
3809
3796
|
}
|
|
3810
3797
|
|
|
3811
3798
|
// Create the default instance to be exported
|
|
3812
|
-
const axios = createInstance(defaults
|
|
3799
|
+
const axios = createInstance(defaults);
|
|
3813
3800
|
|
|
3814
3801
|
// Expose Axios class to allow class inheritance
|
|
3815
|
-
axios.Axios = Axios
|
|
3802
|
+
axios.Axios = Axios;
|
|
3816
3803
|
|
|
3817
3804
|
// Expose Cancel & CancelToken
|
|
3818
3805
|
axios.CanceledError = CanceledError;
|
|
3819
|
-
axios.CancelToken = CancelToken
|
|
3806
|
+
axios.CancelToken = CancelToken;
|
|
3820
3807
|
axios.isCancel = isCancel;
|
|
3821
3808
|
axios.VERSION = VERSION;
|
|
3822
3809
|
axios.toFormData = toFormData;
|
|
@@ -3840,19 +3827,16 @@ axios.isAxiosError = isAxiosError;
|
|
|
3840
3827
|
// Expose mergeConfig
|
|
3841
3828
|
axios.mergeConfig = mergeConfig;
|
|
3842
3829
|
|
|
3843
|
-
axios.AxiosHeaders = AxiosHeaders
|
|
3830
|
+
axios.AxiosHeaders = AxiosHeaders;
|
|
3844
3831
|
|
|
3845
|
-
axios.formToJSON = thing => formDataToJSON(utils$
|
|
3832
|
+
axios.formToJSON = thing => formDataToJSON(utils$2.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
3846
3833
|
|
|
3847
3834
|
axios.getAdapter = adapters.getAdapter;
|
|
3848
3835
|
|
|
3849
|
-
axios.HttpStatusCode = HttpStatusCode
|
|
3836
|
+
axios.HttpStatusCode = HttpStatusCode;
|
|
3850
3837
|
|
|
3851
3838
|
axios.default = axios;
|
|
3852
3839
|
|
|
3853
|
-
// this module should only have a default export
|
|
3854
|
-
var axios$1 = axios;
|
|
3855
|
-
|
|
3856
3840
|
/**
|
|
3857
3841
|
* Function to generate the URL for the given network.
|
|
3858
3842
|
*
|
|
@@ -3875,7 +3859,7 @@ const urlForNetwork = (network) => {
|
|
|
3875
3859
|
* @returns {Promise<InsightAddressResponse>} Address details fetched from the Insight API.
|
|
3876
3860
|
*/
|
|
3877
3861
|
const getAddress = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
3878
|
-
const data = (yield axios
|
|
3862
|
+
const data = (yield axios.get(`${urlForNetwork(p.network)}/addr/${p.address}`)).data;
|
|
3879
3863
|
return data;
|
|
3880
3864
|
});
|
|
3881
3865
|
/**
|
|
@@ -3886,7 +3870,7 @@ const getAddress = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
3886
3870
|
*/
|
|
3887
3871
|
const getAddressTxs = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
3888
3872
|
const pageNum = (p === null || p === void 0 ? void 0 : p.pageNum) || 0;
|
|
3889
|
-
return (yield axios
|
|
3873
|
+
return (yield axios.get(`${urlForNetwork(p.network)}/txs?address=${p.address}&pageNum=${pageNum}`)).data;
|
|
3890
3874
|
});
|
|
3891
3875
|
/**
|
|
3892
3876
|
* Fetch UTXOs associated with an address from the Insight API.
|
|
@@ -3895,7 +3879,7 @@ const getAddressTxs = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
3895
3879
|
* @returns {Promise<InsightUtxoResponse[]>} UTXOs associated with the address.
|
|
3896
3880
|
*/
|
|
3897
3881
|
const getAddressUtxos = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
3898
|
-
return (yield axios
|
|
3882
|
+
return (yield axios.get(`${urlForNetwork(p.network)}/addr/${p.address}/utxo`)).data;
|
|
3899
3883
|
});
|
|
3900
3884
|
/**
|
|
3901
3885
|
* Fetch transaction details from the Insight API.
|
|
@@ -3904,7 +3888,7 @@ const getAddressUtxos = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
3904
3888
|
* @returns {Promise<InsightTxResponse>} Transaction details fetched from the Insight API.
|
|
3905
3889
|
*/
|
|
3906
3890
|
const getTx = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
3907
|
-
return (yield axios
|
|
3891
|
+
return (yield axios.get(`${urlForNetwork(p.network)}/tx/${p.txid}`)).data;
|
|
3908
3892
|
});
|
|
3909
3893
|
/**
|
|
3910
3894
|
* Fetch raw transaction data from the Insight API.
|
|
@@ -3913,128 +3897,145 @@ const getTx = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
3913
3897
|
* @returns {Promise<InsightRawTx>} Raw transaction data fetched from the Insight API.
|
|
3914
3898
|
*/
|
|
3915
3899
|
const getRawTx = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
3916
|
-
return (yield axios
|
|
3900
|
+
return (yield axios.get(`${urlForNetwork(p.network)}/rawtx/${p.txid}`)).data.rawtx;
|
|
3917
3901
|
});
|
|
3918
3902
|
|
|
3919
3903
|
function getDefaultExportFromCjs (x) {
|
|
3920
3904
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
3921
3905
|
}
|
|
3922
3906
|
|
|
3923
|
-
|
|
3924
|
-
var
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3907
|
+
var utils;
|
|
3908
|
+
var hasRequiredUtils;
|
|
3909
|
+
|
|
3910
|
+
function requireUtils () {
|
|
3911
|
+
if (hasRequiredUtils) return utils;
|
|
3912
|
+
hasRequiredUtils = 1;
|
|
3913
|
+
// baseline estimates, used to improve performance
|
|
3914
|
+
var TX_EMPTY_SIZE = 4 + 1 + 1 + 4;
|
|
3915
|
+
var TX_INPUT_BASE = 32 + 4 + 1 + 4;
|
|
3916
|
+
var TX_INPUT_PUBKEYHASH = 107;
|
|
3917
|
+
var TX_OUTPUT_BASE = 8 + 1;
|
|
3918
|
+
var TX_OUTPUT_PUBKEYHASH = 25;
|
|
3919
|
+
|
|
3920
|
+
function inputBytes (input) {
|
|
3921
|
+
return TX_INPUT_BASE + (input.script ? input.script.length : TX_INPUT_PUBKEYHASH)
|
|
3922
|
+
}
|
|
3923
|
+
|
|
3924
|
+
function outputBytes (output) {
|
|
3925
|
+
return TX_OUTPUT_BASE + (output.script ? output.script.length : TX_OUTPUT_PUBKEYHASH)
|
|
3926
|
+
}
|
|
3927
|
+
|
|
3928
|
+
function dustThreshold (output, feeRate) {
|
|
3929
|
+
/* ... classify the output for input estimate */
|
|
3930
|
+
return inputBytes({}) * feeRate
|
|
3931
|
+
}
|
|
3932
|
+
|
|
3933
|
+
function transactionBytes (inputs, outputs) {
|
|
3934
|
+
return TX_EMPTY_SIZE +
|
|
3935
|
+
inputs.reduce(function (a, x) { return a + inputBytes(x) }, 0) +
|
|
3936
|
+
outputs.reduce(function (a, x) { return a + outputBytes(x) }, 0)
|
|
3937
|
+
}
|
|
3938
|
+
|
|
3939
|
+
function uintOrNaN (v) {
|
|
3940
|
+
if (typeof v !== 'number') return NaN
|
|
3941
|
+
if (!isFinite(v)) return NaN
|
|
3942
|
+
if (Math.floor(v) !== v) return NaN
|
|
3943
|
+
if (v < 0) return NaN
|
|
3944
|
+
return v
|
|
3945
|
+
}
|
|
3946
|
+
|
|
3947
|
+
function sumForgiving (range) {
|
|
3948
|
+
return range.reduce(function (a, x) { return a + (isFinite(x.value) ? x.value : 0) }, 0)
|
|
3949
|
+
}
|
|
3950
|
+
|
|
3951
|
+
function sumOrNaN (range) {
|
|
3952
|
+
return range.reduce(function (a, x) { return a + uintOrNaN(x.value) }, 0)
|
|
3953
|
+
}
|
|
3954
|
+
|
|
3955
|
+
var BLANK_OUTPUT = outputBytes({});
|
|
3956
|
+
|
|
3957
|
+
function finalize (inputs, outputs, feeRate) {
|
|
3958
|
+
var bytesAccum = transactionBytes(inputs, outputs);
|
|
3959
|
+
var feeAfterExtraOutput = feeRate * (bytesAccum + BLANK_OUTPUT);
|
|
3960
|
+
var remainderAfterExtraOutput = sumOrNaN(inputs) - (sumOrNaN(outputs) + feeAfterExtraOutput);
|
|
3961
|
+
|
|
3962
|
+
// is it worth a change output?
|
|
3963
|
+
if (remainderAfterExtraOutput > dustThreshold({}, feeRate)) {
|
|
3964
|
+
outputs = outputs.concat({ value: remainderAfterExtraOutput });
|
|
3965
|
+
}
|
|
3966
|
+
|
|
3967
|
+
var fee = sumOrNaN(inputs) - sumOrNaN(outputs);
|
|
3968
|
+
if (!isFinite(fee)) return { fee: feeRate * bytesAccum }
|
|
3969
|
+
|
|
3970
|
+
return {
|
|
3971
|
+
inputs: inputs,
|
|
3972
|
+
outputs: outputs,
|
|
3973
|
+
fee: fee
|
|
3974
|
+
}
|
|
3975
|
+
}
|
|
3976
|
+
|
|
3977
|
+
utils = {
|
|
3978
|
+
dustThreshold: dustThreshold,
|
|
3979
|
+
finalize: finalize,
|
|
3980
|
+
inputBytes: inputBytes,
|
|
3981
|
+
outputBytes: outputBytes,
|
|
3982
|
+
sumOrNaN: sumOrNaN,
|
|
3983
|
+
sumForgiving: sumForgiving,
|
|
3984
|
+
transactionBytes: transactionBytes,
|
|
3985
|
+
uintOrNaN: uintOrNaN
|
|
3986
|
+
};
|
|
3987
|
+
return utils;
|
|
3932
3988
|
}
|
|
3933
3989
|
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
}
|
|
3990
|
+
var accumulative$1;
|
|
3991
|
+
var hasRequiredAccumulative;
|
|
3937
3992
|
|
|
3938
|
-
function
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3993
|
+
function requireAccumulative () {
|
|
3994
|
+
if (hasRequiredAccumulative) return accumulative$1;
|
|
3995
|
+
hasRequiredAccumulative = 1;
|
|
3996
|
+
var utils = requireUtils();
|
|
3942
3997
|
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3998
|
+
// add inputs until we reach or surpass the target value (or deplete)
|
|
3999
|
+
// worst-case: O(n)
|
|
4000
|
+
accumulative$1 = function accumulative (utxos, outputs, feeRate) {
|
|
4001
|
+
if (!isFinite(utils.uintOrNaN(feeRate))) return {}
|
|
4002
|
+
var bytesAccum = utils.transactionBytes([], outputs);
|
|
3948
4003
|
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
if (Math.floor(v) !== v) return NaN
|
|
3953
|
-
if (v < 0) return NaN
|
|
3954
|
-
return v
|
|
3955
|
-
}
|
|
4004
|
+
var inAccum = 0;
|
|
4005
|
+
var inputs = [];
|
|
4006
|
+
var outAccum = utils.sumOrNaN(outputs);
|
|
3956
4007
|
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
4008
|
+
for (var i = 0; i < utxos.length; ++i) {
|
|
4009
|
+
var utxo = utxos[i];
|
|
4010
|
+
var utxoBytes = utils.inputBytes(utxo);
|
|
4011
|
+
var utxoFee = feeRate * utxoBytes;
|
|
4012
|
+
var utxoValue = utils.uintOrNaN(utxo.value);
|
|
3960
4013
|
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
}
|
|
4014
|
+
// skip detrimental input
|
|
4015
|
+
if (utxoFee > utxo.value) {
|
|
4016
|
+
if (i === utxos.length - 1) return { fee: feeRate * (bytesAccum + utxoBytes) }
|
|
4017
|
+
continue
|
|
4018
|
+
}
|
|
3964
4019
|
|
|
3965
|
-
|
|
4020
|
+
bytesAccum += utxoBytes;
|
|
4021
|
+
inAccum += utxoValue;
|
|
4022
|
+
inputs.push(utxo);
|
|
3966
4023
|
|
|
3967
|
-
|
|
3968
|
-
var bytesAccum = transactionBytes(inputs, outputs);
|
|
3969
|
-
var feeAfterExtraOutput = feeRate * (bytesAccum + BLANK_OUTPUT);
|
|
3970
|
-
var remainderAfterExtraOutput = sumOrNaN(inputs) - (sumOrNaN(outputs) + feeAfterExtraOutput);
|
|
4024
|
+
var fee = feeRate * bytesAccum;
|
|
3971
4025
|
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
outputs = outputs.concat({ value: remainderAfterExtraOutput });
|
|
3975
|
-
}
|
|
4026
|
+
// go again?
|
|
4027
|
+
if (inAccum < outAccum + fee) continue
|
|
3976
4028
|
|
|
3977
|
-
|
|
3978
|
-
|
|
4029
|
+
return utils.finalize(inputs, outputs, feeRate)
|
|
4030
|
+
}
|
|
3979
4031
|
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
fee: fee
|
|
3984
|
-
}
|
|
4032
|
+
return { fee: feeRate * bytesAccum }
|
|
4033
|
+
};
|
|
4034
|
+
return accumulative$1;
|
|
3985
4035
|
}
|
|
3986
4036
|
|
|
3987
|
-
var
|
|
3988
|
-
|
|
3989
|
-
finalize: finalize,
|
|
3990
|
-
inputBytes: inputBytes,
|
|
3991
|
-
outputBytes: outputBytes,
|
|
3992
|
-
sumOrNaN: sumOrNaN,
|
|
3993
|
-
sumForgiving: sumForgiving,
|
|
3994
|
-
transactionBytes: transactionBytes,
|
|
3995
|
-
uintOrNaN: uintOrNaN
|
|
3996
|
-
};
|
|
3997
|
-
|
|
3998
|
-
var utils = utils$1;
|
|
3999
|
-
|
|
4000
|
-
// add inputs until we reach or surpass the target value (or deplete)
|
|
4001
|
-
// worst-case: O(n)
|
|
4002
|
-
var accumulative = function accumulative (utxos, outputs, feeRate) {
|
|
4003
|
-
if (!isFinite(utils.uintOrNaN(feeRate))) return {}
|
|
4004
|
-
var bytesAccum = utils.transactionBytes([], outputs);
|
|
4005
|
-
|
|
4006
|
-
var inAccum = 0;
|
|
4007
|
-
var inputs = [];
|
|
4008
|
-
var outAccum = utils.sumOrNaN(outputs);
|
|
4009
|
-
|
|
4010
|
-
for (var i = 0; i < utxos.length; ++i) {
|
|
4011
|
-
var utxo = utxos[i];
|
|
4012
|
-
var utxoBytes = utils.inputBytes(utxo);
|
|
4013
|
-
var utxoFee = feeRate * utxoBytes;
|
|
4014
|
-
var utxoValue = utils.uintOrNaN(utxo.value);
|
|
4015
|
-
|
|
4016
|
-
// skip detrimental input
|
|
4017
|
-
if (utxoFee > utxo.value) {
|
|
4018
|
-
if (i === utxos.length - 1) return { fee: feeRate * (bytesAccum + utxoBytes) }
|
|
4019
|
-
continue
|
|
4020
|
-
}
|
|
4021
|
-
|
|
4022
|
-
bytesAccum += utxoBytes;
|
|
4023
|
-
inAccum += utxoValue;
|
|
4024
|
-
inputs.push(utxo);
|
|
4025
|
-
|
|
4026
|
-
var fee = feeRate * bytesAccum;
|
|
4027
|
-
|
|
4028
|
-
// go again?
|
|
4029
|
-
if (inAccum < outAccum + fee) continue
|
|
4030
|
-
|
|
4031
|
-
return utils.finalize(inputs, outputs, feeRate)
|
|
4032
|
-
}
|
|
4033
|
-
|
|
4034
|
-
return { fee: feeRate * bytesAccum }
|
|
4035
|
-
};
|
|
4036
|
-
|
|
4037
|
-
var accumulative$1 = /*@__PURE__*/getDefaultExportFromCjs(accumulative);
|
|
4037
|
+
var accumulativeExports = requireAccumulative();
|
|
4038
|
+
var accumulative = /*@__PURE__*/getDefaultExportFromCjs(accumulativeExports);
|
|
4038
4039
|
|
|
4039
4040
|
/**
|
|
4040
4041
|
* Object containing the sizes (in bytes) of various components in a Dash transaction.
|
|
@@ -4122,7 +4123,7 @@ const buildTx = ({ amount, recipient, memo, feeRate, sender, network, }) => __aw
|
|
|
4122
4123
|
},
|
|
4123
4124
|
];
|
|
4124
4125
|
// Calculate inputs and outputs for the transaction
|
|
4125
|
-
const { inputs, outputs } = accumulative
|
|
4126
|
+
const { inputs, outputs } = accumulative(utxos, targetOutputs, feeRateWhole);
|
|
4126
4127
|
if (!inputs || !outputs)
|
|
4127
4128
|
throw new Error('Insufficient balance for transaction');
|
|
4128
4129
|
// Initialize new Dash transaction
|
|
@@ -4418,7 +4419,7 @@ class Client extends xchainUtxo.Client {
|
|
|
4418
4419
|
const broadcastTx = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4419
4420
|
const uniqueId = new Date().getTime().toString(); // Generate a unique identifier for the transaction request.
|
|
4420
4421
|
try {
|
|
4421
|
-
const response = (yield axios
|
|
4422
|
+
const response = (yield axios.post(`${params.nodeUrl}/tx/send`, // URL endpoint for broadcasting the transaction.
|
|
4422
4423
|
{
|
|
4423
4424
|
jsonrpc: '2.0',
|
|
4424
4425
|
rawtx: [params.txHex],
|
|
@@ -4555,7 +4556,7 @@ class ClientLedger extends Client {
|
|
|
4555
4556
|
if (this.app) {
|
|
4556
4557
|
return this.app;
|
|
4557
4558
|
}
|
|
4558
|
-
this.app = new
|
|
4559
|
+
this.app = new AppBtc({ transport: this.transport, currency: 'dash' });
|
|
4559
4560
|
return this.app;
|
|
4560
4561
|
});
|
|
4561
4562
|
}
|