@xchainjs/xchain-dash 1.0.11 → 2.0.0
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 +128 -265
- package/lib/index.js +130 -266
- package/package.json +6 -6
- package/lib/index.esm.js.map +0 -1
- package/lib/index.js.map +0 -1
package/lib/index.js
CHANGED
|
@@ -7,6 +7,7 @@ var dashcore = require('@dashevo/dashcore-lib');
|
|
|
7
7
|
var xchainUtxo = require('@xchainjs/xchain-utxo');
|
|
8
8
|
var Dash = require('bitcoinjs-lib');
|
|
9
9
|
var coininfo = require('coininfo');
|
|
10
|
+
var accumulative = require('coinselect/accumulative');
|
|
10
11
|
var xchainCrypto = require('@xchainjs/xchain-crypto');
|
|
11
12
|
var AppBtc = require('@ledgerhq/hw-app-btc');
|
|
12
13
|
|
|
@@ -33,6 +34,7 @@ function _interopNamespace(e) {
|
|
|
33
34
|
var dashcore__namespace = /*#__PURE__*/_interopNamespace(dashcore);
|
|
34
35
|
var Dash__namespace = /*#__PURE__*/_interopNamespace(Dash);
|
|
35
36
|
var coininfo__namespace = /*#__PURE__*/_interopNamespace(coininfo);
|
|
37
|
+
var accumulative__default = /*#__PURE__*/_interopDefault(accumulative);
|
|
36
38
|
var AppBtc__default = /*#__PURE__*/_interopDefault(AppBtc);
|
|
37
39
|
|
|
38
40
|
/**
|
|
@@ -829,7 +831,7 @@ const asap = typeof queueMicrotask !== 'undefined' ?
|
|
|
829
831
|
|
|
830
832
|
// *********************
|
|
831
833
|
|
|
832
|
-
var utils$
|
|
834
|
+
var utils$1 = {
|
|
833
835
|
isArray,
|
|
834
836
|
isArrayBuffer,
|
|
835
837
|
isBuffer,
|
|
@@ -918,7 +920,7 @@ function AxiosError(message, code, config, request, response) {
|
|
|
918
920
|
}
|
|
919
921
|
}
|
|
920
922
|
|
|
921
|
-
utils$
|
|
923
|
+
utils$1.inherits(AxiosError, Error, {
|
|
922
924
|
toJSON: function toJSON() {
|
|
923
925
|
return {
|
|
924
926
|
// Standard
|
|
@@ -933,7 +935,7 @@ utils$2.inherits(AxiosError, Error, {
|
|
|
933
935
|
columnNumber: this.columnNumber,
|
|
934
936
|
stack: this.stack,
|
|
935
937
|
// Axios
|
|
936
|
-
config: utils$
|
|
938
|
+
config: utils$1.toJSONObject(this.config),
|
|
937
939
|
code: this.code,
|
|
938
940
|
status: this.status
|
|
939
941
|
};
|
|
@@ -968,7 +970,7 @@ Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
|
|
|
968
970
|
AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
969
971
|
const axiosError = Object.create(prototype$1);
|
|
970
972
|
|
|
971
|
-
utils$
|
|
973
|
+
utils$1.toFlatObject(error, axiosError, function filter(obj) {
|
|
972
974
|
return obj !== Error.prototype;
|
|
973
975
|
}, prop => {
|
|
974
976
|
return prop !== 'isAxiosError';
|
|
@@ -996,7 +998,7 @@ var httpAdapter = null;
|
|
|
996
998
|
* @returns {boolean}
|
|
997
999
|
*/
|
|
998
1000
|
function isVisitable(thing) {
|
|
999
|
-
return utils$
|
|
1001
|
+
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
|
1000
1002
|
}
|
|
1001
1003
|
|
|
1002
1004
|
/**
|
|
@@ -1007,7 +1009,7 @@ function isVisitable(thing) {
|
|
|
1007
1009
|
* @returns {string} the key without the brackets.
|
|
1008
1010
|
*/
|
|
1009
1011
|
function removeBrackets(key) {
|
|
1010
|
-
return utils$
|
|
1012
|
+
return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
1011
1013
|
}
|
|
1012
1014
|
|
|
1013
1015
|
/**
|
|
@@ -1036,10 +1038,10 @@ function renderKey(path, key, dots) {
|
|
|
1036
1038
|
* @returns {boolean}
|
|
1037
1039
|
*/
|
|
1038
1040
|
function isFlatArray(arr) {
|
|
1039
|
-
return utils$
|
|
1041
|
+
return utils$1.isArray(arr) && !arr.some(isVisitable);
|
|
1040
1042
|
}
|
|
1041
1043
|
|
|
1042
|
-
const predicates = utils$
|
|
1044
|
+
const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
|
|
1043
1045
|
return /^is[A-Z]/.test(prop);
|
|
1044
1046
|
});
|
|
1045
1047
|
|
|
@@ -1067,7 +1069,7 @@ const predicates = utils$2.toFlatObject(utils$2, {}, null, function filter(prop)
|
|
|
1067
1069
|
* @returns
|
|
1068
1070
|
*/
|
|
1069
1071
|
function toFormData(obj, formData, options) {
|
|
1070
|
-
if (!utils$
|
|
1072
|
+
if (!utils$1.isObject(obj)) {
|
|
1071
1073
|
throw new TypeError('target must be an object');
|
|
1072
1074
|
}
|
|
1073
1075
|
|
|
@@ -1075,13 +1077,13 @@ function toFormData(obj, formData, options) {
|
|
|
1075
1077
|
formData = formData || new (FormData)();
|
|
1076
1078
|
|
|
1077
1079
|
// eslint-disable-next-line no-param-reassign
|
|
1078
|
-
options = utils$
|
|
1080
|
+
options = utils$1.toFlatObject(options, {
|
|
1079
1081
|
metaTokens: true,
|
|
1080
1082
|
dots: false,
|
|
1081
1083
|
indexes: false
|
|
1082
1084
|
}, false, function defined(option, source) {
|
|
1083
1085
|
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
1084
|
-
return !utils$
|
|
1086
|
+
return !utils$1.isUndefined(source[option]);
|
|
1085
1087
|
});
|
|
1086
1088
|
|
|
1087
1089
|
const metaTokens = options.metaTokens;
|
|
@@ -1090,24 +1092,24 @@ function toFormData(obj, formData, options) {
|
|
|
1090
1092
|
const dots = options.dots;
|
|
1091
1093
|
const indexes = options.indexes;
|
|
1092
1094
|
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
|
1093
|
-
const useBlob = _Blob && utils$
|
|
1095
|
+
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
1094
1096
|
|
|
1095
|
-
if (!utils$
|
|
1097
|
+
if (!utils$1.isFunction(visitor)) {
|
|
1096
1098
|
throw new TypeError('visitor must be a function');
|
|
1097
1099
|
}
|
|
1098
1100
|
|
|
1099
1101
|
function convertValue(value) {
|
|
1100
1102
|
if (value === null) return '';
|
|
1101
1103
|
|
|
1102
|
-
if (utils$
|
|
1104
|
+
if (utils$1.isDate(value)) {
|
|
1103
1105
|
return value.toISOString();
|
|
1104
1106
|
}
|
|
1105
1107
|
|
|
1106
|
-
if (!useBlob && utils$
|
|
1108
|
+
if (!useBlob && utils$1.isBlob(value)) {
|
|
1107
1109
|
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
|
1108
1110
|
}
|
|
1109
1111
|
|
|
1110
|
-
if (utils$
|
|
1112
|
+
if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
|
1111
1113
|
return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
|
1112
1114
|
}
|
|
1113
1115
|
|
|
@@ -1128,20 +1130,20 @@ function toFormData(obj, formData, options) {
|
|
|
1128
1130
|
let arr = value;
|
|
1129
1131
|
|
|
1130
1132
|
if (value && !path && typeof value === 'object') {
|
|
1131
|
-
if (utils$
|
|
1133
|
+
if (utils$1.endsWith(key, '{}')) {
|
|
1132
1134
|
// eslint-disable-next-line no-param-reassign
|
|
1133
1135
|
key = metaTokens ? key : key.slice(0, -2);
|
|
1134
1136
|
// eslint-disable-next-line no-param-reassign
|
|
1135
1137
|
value = JSON.stringify(value);
|
|
1136
1138
|
} else if (
|
|
1137
|
-
(utils$
|
|
1138
|
-
((utils$
|
|
1139
|
+
(utils$1.isArray(value) && isFlatArray(value)) ||
|
|
1140
|
+
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
|
|
1139
1141
|
)) {
|
|
1140
1142
|
// eslint-disable-next-line no-param-reassign
|
|
1141
1143
|
key = removeBrackets(key);
|
|
1142
1144
|
|
|
1143
1145
|
arr.forEach(function each(el, index) {
|
|
1144
|
-
!(utils$
|
|
1146
|
+
!(utils$1.isUndefined(el) || el === null) && formData.append(
|
|
1145
1147
|
// eslint-disable-next-line no-nested-ternary
|
|
1146
1148
|
indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
|
|
1147
1149
|
convertValue(el)
|
|
@@ -1169,7 +1171,7 @@ function toFormData(obj, formData, options) {
|
|
|
1169
1171
|
});
|
|
1170
1172
|
|
|
1171
1173
|
function build(value, path) {
|
|
1172
|
-
if (utils$
|
|
1174
|
+
if (utils$1.isUndefined(value)) return;
|
|
1173
1175
|
|
|
1174
1176
|
if (stack.indexOf(value) !== -1) {
|
|
1175
1177
|
throw Error('Circular reference detected in ' + path.join('.'));
|
|
@@ -1177,9 +1179,9 @@ function toFormData(obj, formData, options) {
|
|
|
1177
1179
|
|
|
1178
1180
|
stack.push(value);
|
|
1179
1181
|
|
|
1180
|
-
utils$
|
|
1181
|
-
const result = !(utils$
|
|
1182
|
-
formData, el, utils$
|
|
1182
|
+
utils$1.forEach(value, function each(el, key) {
|
|
1183
|
+
const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
|
|
1184
|
+
formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
|
|
1183
1185
|
);
|
|
1184
1186
|
|
|
1185
1187
|
if (result === true) {
|
|
@@ -1190,7 +1192,7 @@ function toFormData(obj, formData, options) {
|
|
|
1190
1192
|
stack.pop();
|
|
1191
1193
|
}
|
|
1192
1194
|
|
|
1193
|
-
if (!utils$
|
|
1195
|
+
if (!utils$1.isObject(obj)) {
|
|
1194
1196
|
throw new TypeError('data must be an object');
|
|
1195
1197
|
}
|
|
1196
1198
|
|
|
@@ -1287,7 +1289,7 @@ function buildURL(url, params, options) {
|
|
|
1287
1289
|
|
|
1288
1290
|
const _encode = options && options.encode || encode;
|
|
1289
1291
|
|
|
1290
|
-
if (utils$
|
|
1292
|
+
if (utils$1.isFunction(options)) {
|
|
1291
1293
|
options = {
|
|
1292
1294
|
serialize: options
|
|
1293
1295
|
};
|
|
@@ -1300,7 +1302,7 @@ function buildURL(url, params, options) {
|
|
|
1300
1302
|
if (serializeFn) {
|
|
1301
1303
|
serializedParams = serializeFn(params, options);
|
|
1302
1304
|
} else {
|
|
1303
|
-
serializedParams = utils$
|
|
1305
|
+
serializedParams = utils$1.isURLSearchParams(params) ?
|
|
1304
1306
|
params.toString() :
|
|
1305
1307
|
new AxiosURLSearchParams(params, options).toString(_encode);
|
|
1306
1308
|
}
|
|
@@ -1375,7 +1377,7 @@ class InterceptorManager {
|
|
|
1375
1377
|
* @returns {void}
|
|
1376
1378
|
*/
|
|
1377
1379
|
forEach(fn) {
|
|
1378
|
-
utils$
|
|
1380
|
+
utils$1.forEach(this.handlers, function forEachHandler(h) {
|
|
1379
1381
|
if (h !== null) {
|
|
1380
1382
|
fn(h);
|
|
1381
1383
|
}
|
|
@@ -1449,7 +1451,7 @@ const hasStandardBrowserWebWorkerEnv = (() => {
|
|
|
1449
1451
|
|
|
1450
1452
|
const origin = hasBrowserEnv && window.location.href || 'http://localhost';
|
|
1451
1453
|
|
|
1452
|
-
var utils
|
|
1454
|
+
var utils = /*#__PURE__*/Object.freeze({
|
|
1453
1455
|
__proto__: null,
|
|
1454
1456
|
hasBrowserEnv: hasBrowserEnv,
|
|
1455
1457
|
hasStandardBrowserEnv: hasStandardBrowserEnv,
|
|
@@ -1459,14 +1461,14 @@ var utils$1 = /*#__PURE__*/Object.freeze({
|
|
|
1459
1461
|
});
|
|
1460
1462
|
|
|
1461
1463
|
var platform = {
|
|
1462
|
-
...utils
|
|
1464
|
+
...utils,
|
|
1463
1465
|
...platform$1
|
|
1464
1466
|
};
|
|
1465
1467
|
|
|
1466
1468
|
function toURLEncodedForm(data, options) {
|
|
1467
1469
|
return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
|
|
1468
1470
|
visitor: function(value, key, path, helpers) {
|
|
1469
|
-
if (platform.isNode && utils$
|
|
1471
|
+
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
1470
1472
|
this.append(key, value.toString('base64'));
|
|
1471
1473
|
return false;
|
|
1472
1474
|
}
|
|
@@ -1488,7 +1490,7 @@ function parsePropPath(name) {
|
|
|
1488
1490
|
// foo.x.y.z
|
|
1489
1491
|
// foo-x-y-z
|
|
1490
1492
|
// foo x y z
|
|
1491
|
-
return utils$
|
|
1493
|
+
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
|
1492
1494
|
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
1493
1495
|
});
|
|
1494
1496
|
}
|
|
@@ -1528,10 +1530,10 @@ function formDataToJSON(formData) {
|
|
|
1528
1530
|
|
|
1529
1531
|
const isNumericKey = Number.isFinite(+name);
|
|
1530
1532
|
const isLast = index >= path.length;
|
|
1531
|
-
name = !name && utils$
|
|
1533
|
+
name = !name && utils$1.isArray(target) ? target.length : name;
|
|
1532
1534
|
|
|
1533
1535
|
if (isLast) {
|
|
1534
|
-
if (utils$
|
|
1536
|
+
if (utils$1.hasOwnProp(target, name)) {
|
|
1535
1537
|
target[name] = [target[name], value];
|
|
1536
1538
|
} else {
|
|
1537
1539
|
target[name] = value;
|
|
@@ -1540,23 +1542,23 @@ function formDataToJSON(formData) {
|
|
|
1540
1542
|
return !isNumericKey;
|
|
1541
1543
|
}
|
|
1542
1544
|
|
|
1543
|
-
if (!target[name] || !utils$
|
|
1545
|
+
if (!target[name] || !utils$1.isObject(target[name])) {
|
|
1544
1546
|
target[name] = [];
|
|
1545
1547
|
}
|
|
1546
1548
|
|
|
1547
1549
|
const result = buildPath(path, value, target[name], index);
|
|
1548
1550
|
|
|
1549
|
-
if (result && utils$
|
|
1551
|
+
if (result && utils$1.isArray(target[name])) {
|
|
1550
1552
|
target[name] = arrayToObject(target[name]);
|
|
1551
1553
|
}
|
|
1552
1554
|
|
|
1553
1555
|
return !isNumericKey;
|
|
1554
1556
|
}
|
|
1555
1557
|
|
|
1556
|
-
if (utils$
|
|
1558
|
+
if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
|
|
1557
1559
|
const obj = {};
|
|
1558
1560
|
|
|
1559
|
-
utils$
|
|
1561
|
+
utils$1.forEachEntry(formData, (name, value) => {
|
|
1560
1562
|
buildPath(parsePropPath(name), value, obj, 0);
|
|
1561
1563
|
});
|
|
1562
1564
|
|
|
@@ -1577,10 +1579,10 @@ function formDataToJSON(formData) {
|
|
|
1577
1579
|
* @returns {string} A stringified version of the rawValue.
|
|
1578
1580
|
*/
|
|
1579
1581
|
function stringifySafely(rawValue, parser, encoder) {
|
|
1580
|
-
if (utils$
|
|
1582
|
+
if (utils$1.isString(rawValue)) {
|
|
1581
1583
|
try {
|
|
1582
1584
|
(parser || JSON.parse)(rawValue);
|
|
1583
|
-
return utils$
|
|
1585
|
+
return utils$1.trim(rawValue);
|
|
1584
1586
|
} catch (e) {
|
|
1585
1587
|
if (e.name !== 'SyntaxError') {
|
|
1586
1588
|
throw e;
|
|
@@ -1600,31 +1602,31 @@ const defaults = {
|
|
|
1600
1602
|
transformRequest: [function transformRequest(data, headers) {
|
|
1601
1603
|
const contentType = headers.getContentType() || '';
|
|
1602
1604
|
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
1603
|
-
const isObjectPayload = utils$
|
|
1605
|
+
const isObjectPayload = utils$1.isObject(data);
|
|
1604
1606
|
|
|
1605
|
-
if (isObjectPayload && utils$
|
|
1607
|
+
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
1606
1608
|
data = new FormData(data);
|
|
1607
1609
|
}
|
|
1608
1610
|
|
|
1609
|
-
const isFormData = utils$
|
|
1611
|
+
const isFormData = utils$1.isFormData(data);
|
|
1610
1612
|
|
|
1611
1613
|
if (isFormData) {
|
|
1612
1614
|
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
1613
1615
|
}
|
|
1614
1616
|
|
|
1615
|
-
if (utils$
|
|
1616
|
-
utils$
|
|
1617
|
-
utils$
|
|
1618
|
-
utils$
|
|
1619
|
-
utils$
|
|
1620
|
-
utils$
|
|
1617
|
+
if (utils$1.isArrayBuffer(data) ||
|
|
1618
|
+
utils$1.isBuffer(data) ||
|
|
1619
|
+
utils$1.isStream(data) ||
|
|
1620
|
+
utils$1.isFile(data) ||
|
|
1621
|
+
utils$1.isBlob(data) ||
|
|
1622
|
+
utils$1.isReadableStream(data)
|
|
1621
1623
|
) {
|
|
1622
1624
|
return data;
|
|
1623
1625
|
}
|
|
1624
|
-
if (utils$
|
|
1626
|
+
if (utils$1.isArrayBufferView(data)) {
|
|
1625
1627
|
return data.buffer;
|
|
1626
1628
|
}
|
|
1627
|
-
if (utils$
|
|
1629
|
+
if (utils$1.isURLSearchParams(data)) {
|
|
1628
1630
|
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
1629
1631
|
return data.toString();
|
|
1630
1632
|
}
|
|
@@ -1636,7 +1638,7 @@ const defaults = {
|
|
|
1636
1638
|
return toURLEncodedForm(data, this.formSerializer).toString();
|
|
1637
1639
|
}
|
|
1638
1640
|
|
|
1639
|
-
if ((isFileList = utils$
|
|
1641
|
+
if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
|
1640
1642
|
const _FormData = this.env && this.env.FormData;
|
|
1641
1643
|
|
|
1642
1644
|
return toFormData(
|
|
@@ -1660,11 +1662,11 @@ const defaults = {
|
|
|
1660
1662
|
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
1661
1663
|
const JSONRequested = this.responseType === 'json';
|
|
1662
1664
|
|
|
1663
|
-
if (utils$
|
|
1665
|
+
if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
|
|
1664
1666
|
return data;
|
|
1665
1667
|
}
|
|
1666
1668
|
|
|
1667
|
-
if (data && utils$
|
|
1669
|
+
if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
|
1668
1670
|
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
1669
1671
|
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
1670
1672
|
|
|
@@ -1712,13 +1714,13 @@ const defaults = {
|
|
|
1712
1714
|
}
|
|
1713
1715
|
};
|
|
1714
1716
|
|
|
1715
|
-
utils$
|
|
1717
|
+
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
|
1716
1718
|
defaults.headers[method] = {};
|
|
1717
1719
|
});
|
|
1718
1720
|
|
|
1719
1721
|
// RawAxiosHeaders whose duplicates are ignored by node
|
|
1720
1722
|
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
1721
|
-
const ignoreDuplicateOf = utils$
|
|
1723
|
+
const ignoreDuplicateOf = utils$1.toObjectSet([
|
|
1722
1724
|
'age', 'authorization', 'content-length', 'content-type', 'etag',
|
|
1723
1725
|
'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
|
|
1724
1726
|
'last-modified', 'location', 'max-forwards', 'proxy-authorization',
|
|
@@ -1779,7 +1781,7 @@ function normalizeValue(value) {
|
|
|
1779
1781
|
return value;
|
|
1780
1782
|
}
|
|
1781
1783
|
|
|
1782
|
-
return utils$
|
|
1784
|
+
return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
|
|
1783
1785
|
}
|
|
1784
1786
|
|
|
1785
1787
|
function parseTokens(str) {
|
|
@@ -1797,7 +1799,7 @@ function parseTokens(str) {
|
|
|
1797
1799
|
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
1798
1800
|
|
|
1799
1801
|
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
1800
|
-
if (utils$
|
|
1802
|
+
if (utils$1.isFunction(filter)) {
|
|
1801
1803
|
return filter.call(this, value, header);
|
|
1802
1804
|
}
|
|
1803
1805
|
|
|
@@ -1805,13 +1807,13 @@ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
|
1805
1807
|
value = header;
|
|
1806
1808
|
}
|
|
1807
1809
|
|
|
1808
|
-
if (!utils$
|
|
1810
|
+
if (!utils$1.isString(value)) return;
|
|
1809
1811
|
|
|
1810
|
-
if (utils$
|
|
1812
|
+
if (utils$1.isString(filter)) {
|
|
1811
1813
|
return value.indexOf(filter) !== -1;
|
|
1812
1814
|
}
|
|
1813
1815
|
|
|
1814
|
-
if (utils$
|
|
1816
|
+
if (utils$1.isRegExp(filter)) {
|
|
1815
1817
|
return filter.test(value);
|
|
1816
1818
|
}
|
|
1817
1819
|
}
|
|
@@ -1824,7 +1826,7 @@ function formatHeader(header) {
|
|
|
1824
1826
|
}
|
|
1825
1827
|
|
|
1826
1828
|
function buildAccessors(obj, header) {
|
|
1827
|
-
const accessorName = utils$
|
|
1829
|
+
const accessorName = utils$1.toCamelCase(' ' + header);
|
|
1828
1830
|
|
|
1829
1831
|
['get', 'set', 'has'].forEach(methodName => {
|
|
1830
1832
|
Object.defineProperty(obj, methodName + accessorName, {
|
|
@@ -1851,7 +1853,7 @@ class AxiosHeaders {
|
|
|
1851
1853
|
throw new Error('header name must be a non-empty string');
|
|
1852
1854
|
}
|
|
1853
1855
|
|
|
1854
|
-
const key = utils$
|
|
1856
|
+
const key = utils$1.findKey(self, lHeader);
|
|
1855
1857
|
|
|
1856
1858
|
if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
|
|
1857
1859
|
self[key || _header] = normalizeValue(_value);
|
|
@@ -1859,13 +1861,13 @@ class AxiosHeaders {
|
|
|
1859
1861
|
}
|
|
1860
1862
|
|
|
1861
1863
|
const setHeaders = (headers, _rewrite) =>
|
|
1862
|
-
utils$
|
|
1864
|
+
utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
1863
1865
|
|
|
1864
|
-
if (utils$
|
|
1866
|
+
if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
|
1865
1867
|
setHeaders(header, valueOrRewrite);
|
|
1866
|
-
} else if(utils$
|
|
1868
|
+
} else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
1867
1869
|
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
1868
|
-
} else if (utils$
|
|
1870
|
+
} else if (utils$1.isHeaders(header)) {
|
|
1869
1871
|
for (const [key, value] of header.entries()) {
|
|
1870
1872
|
setHeader(value, key, rewrite);
|
|
1871
1873
|
}
|
|
@@ -1880,7 +1882,7 @@ class AxiosHeaders {
|
|
|
1880
1882
|
header = normalizeHeader(header);
|
|
1881
1883
|
|
|
1882
1884
|
if (header) {
|
|
1883
|
-
const key = utils$
|
|
1885
|
+
const key = utils$1.findKey(this, header);
|
|
1884
1886
|
|
|
1885
1887
|
if (key) {
|
|
1886
1888
|
const value = this[key];
|
|
@@ -1893,11 +1895,11 @@ class AxiosHeaders {
|
|
|
1893
1895
|
return parseTokens(value);
|
|
1894
1896
|
}
|
|
1895
1897
|
|
|
1896
|
-
if (utils$
|
|
1898
|
+
if (utils$1.isFunction(parser)) {
|
|
1897
1899
|
return parser.call(this, value, key);
|
|
1898
1900
|
}
|
|
1899
1901
|
|
|
1900
|
-
if (utils$
|
|
1902
|
+
if (utils$1.isRegExp(parser)) {
|
|
1901
1903
|
return parser.exec(value);
|
|
1902
1904
|
}
|
|
1903
1905
|
|
|
@@ -1910,7 +1912,7 @@ class AxiosHeaders {
|
|
|
1910
1912
|
header = normalizeHeader(header);
|
|
1911
1913
|
|
|
1912
1914
|
if (header) {
|
|
1913
|
-
const key = utils$
|
|
1915
|
+
const key = utils$1.findKey(this, header);
|
|
1914
1916
|
|
|
1915
1917
|
return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
|
1916
1918
|
}
|
|
@@ -1926,7 +1928,7 @@ class AxiosHeaders {
|
|
|
1926
1928
|
_header = normalizeHeader(_header);
|
|
1927
1929
|
|
|
1928
1930
|
if (_header) {
|
|
1929
|
-
const key = utils$
|
|
1931
|
+
const key = utils$1.findKey(self, _header);
|
|
1930
1932
|
|
|
1931
1933
|
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
|
1932
1934
|
delete self[key];
|
|
@@ -1936,7 +1938,7 @@ class AxiosHeaders {
|
|
|
1936
1938
|
}
|
|
1937
1939
|
}
|
|
1938
1940
|
|
|
1939
|
-
if (utils$
|
|
1941
|
+
if (utils$1.isArray(header)) {
|
|
1940
1942
|
header.forEach(deleteHeader);
|
|
1941
1943
|
} else {
|
|
1942
1944
|
deleteHeader(header);
|
|
@@ -1965,8 +1967,8 @@ class AxiosHeaders {
|
|
|
1965
1967
|
const self = this;
|
|
1966
1968
|
const headers = {};
|
|
1967
1969
|
|
|
1968
|
-
utils$
|
|
1969
|
-
const key = utils$
|
|
1970
|
+
utils$1.forEach(this, (value, header) => {
|
|
1971
|
+
const key = utils$1.findKey(headers, header);
|
|
1970
1972
|
|
|
1971
1973
|
if (key) {
|
|
1972
1974
|
self[key] = normalizeValue(value);
|
|
@@ -1995,8 +1997,8 @@ class AxiosHeaders {
|
|
|
1995
1997
|
toJSON(asStrings) {
|
|
1996
1998
|
const obj = Object.create(null);
|
|
1997
1999
|
|
|
1998
|
-
utils$
|
|
1999
|
-
value != null && value !== false && (obj[header] = asStrings && utils$
|
|
2000
|
+
utils$1.forEach(this, (value, header) => {
|
|
2001
|
+
value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
|
2000
2002
|
});
|
|
2001
2003
|
|
|
2002
2004
|
return obj;
|
|
@@ -2043,7 +2045,7 @@ class AxiosHeaders {
|
|
|
2043
2045
|
}
|
|
2044
2046
|
}
|
|
2045
2047
|
|
|
2046
|
-
utils$
|
|
2048
|
+
utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
|
2047
2049
|
|
|
2048
2050
|
return this;
|
|
2049
2051
|
}
|
|
@@ -2052,7 +2054,7 @@ class AxiosHeaders {
|
|
|
2052
2054
|
AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
|
|
2053
2055
|
|
|
2054
2056
|
// reserved names hotfix
|
|
2055
|
-
utils$
|
|
2057
|
+
utils$1.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
|
|
2056
2058
|
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|
2057
2059
|
return {
|
|
2058
2060
|
get: () => value,
|
|
@@ -2062,7 +2064,7 @@ utils$2.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
|
|
|
2062
2064
|
}
|
|
2063
2065
|
});
|
|
2064
2066
|
|
|
2065
|
-
utils$
|
|
2067
|
+
utils$1.freezeMethods(AxiosHeaders);
|
|
2066
2068
|
|
|
2067
2069
|
/**
|
|
2068
2070
|
* Transform the data for a request or a response
|
|
@@ -2078,7 +2080,7 @@ function transformData(fns, response) {
|
|
|
2078
2080
|
const headers = AxiosHeaders.from(context.headers);
|
|
2079
2081
|
let data = context.data;
|
|
2080
2082
|
|
|
2081
|
-
utils$
|
|
2083
|
+
utils$1.forEach(fns, function transform(fn) {
|
|
2082
2084
|
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
|
2083
2085
|
});
|
|
2084
2086
|
|
|
@@ -2106,7 +2108,7 @@ function CanceledError(message, config, request) {
|
|
|
2106
2108
|
this.name = 'CanceledError';
|
|
2107
2109
|
}
|
|
2108
2110
|
|
|
2109
|
-
utils$
|
|
2111
|
+
utils$1.inherits(CanceledError, AxiosError, {
|
|
2110
2112
|
__CANCEL__: true
|
|
2111
2113
|
});
|
|
2112
2114
|
|
|
@@ -2273,7 +2275,7 @@ const progressEventDecorator = (total, throttled) => {
|
|
|
2273
2275
|
}), throttled[1]];
|
|
2274
2276
|
};
|
|
2275
2277
|
|
|
2276
|
-
const asyncDecorator = (fn) => (...args) => utils$
|
|
2278
|
+
const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
|
|
2277
2279
|
|
|
2278
2280
|
var isURLSameOrigin = platform.hasStandardBrowserEnv ? ((origin, isMSIE) => (url) => {
|
|
2279
2281
|
url = new URL(url, platform.origin);
|
|
@@ -2295,11 +2297,11 @@ var cookies = platform.hasStandardBrowserEnv ?
|
|
|
2295
2297
|
write(name, value, expires, path, domain, secure) {
|
|
2296
2298
|
const cookie = [name + '=' + encodeURIComponent(value)];
|
|
2297
2299
|
|
|
2298
|
-
utils$
|
|
2300
|
+
utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
|
|
2299
2301
|
|
|
2300
|
-
utils$
|
|
2302
|
+
utils$1.isString(path) && cookie.push('path=' + path);
|
|
2301
2303
|
|
|
2302
|
-
utils$
|
|
2304
|
+
utils$1.isString(domain) && cookie.push('domain=' + domain);
|
|
2303
2305
|
|
|
2304
2306
|
secure === true && cookie.push('secure');
|
|
2305
2307
|
|
|
@@ -2390,11 +2392,11 @@ function mergeConfig(config1, config2) {
|
|
|
2390
2392
|
const config = {};
|
|
2391
2393
|
|
|
2392
2394
|
function getMergedValue(target, source, prop, caseless) {
|
|
2393
|
-
if (utils$
|
|
2394
|
-
return utils$
|
|
2395
|
-
} else if (utils$
|
|
2396
|
-
return utils$
|
|
2397
|
-
} else if (utils$
|
|
2395
|
+
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
2396
|
+
return utils$1.merge.call({caseless}, target, source);
|
|
2397
|
+
} else if (utils$1.isPlainObject(source)) {
|
|
2398
|
+
return utils$1.merge({}, source);
|
|
2399
|
+
} else if (utils$1.isArray(source)) {
|
|
2398
2400
|
return source.slice();
|
|
2399
2401
|
}
|
|
2400
2402
|
return source;
|
|
@@ -2402,25 +2404,25 @@ function mergeConfig(config1, config2) {
|
|
|
2402
2404
|
|
|
2403
2405
|
// eslint-disable-next-line consistent-return
|
|
2404
2406
|
function mergeDeepProperties(a, b, prop , caseless) {
|
|
2405
|
-
if (!utils$
|
|
2407
|
+
if (!utils$1.isUndefined(b)) {
|
|
2406
2408
|
return getMergedValue(a, b, prop , caseless);
|
|
2407
|
-
} else if (!utils$
|
|
2409
|
+
} else if (!utils$1.isUndefined(a)) {
|
|
2408
2410
|
return getMergedValue(undefined, a, prop , caseless);
|
|
2409
2411
|
}
|
|
2410
2412
|
}
|
|
2411
2413
|
|
|
2412
2414
|
// eslint-disable-next-line consistent-return
|
|
2413
2415
|
function valueFromConfig2(a, b) {
|
|
2414
|
-
if (!utils$
|
|
2416
|
+
if (!utils$1.isUndefined(b)) {
|
|
2415
2417
|
return getMergedValue(undefined, b);
|
|
2416
2418
|
}
|
|
2417
2419
|
}
|
|
2418
2420
|
|
|
2419
2421
|
// eslint-disable-next-line consistent-return
|
|
2420
2422
|
function defaultToConfig2(a, b) {
|
|
2421
|
-
if (!utils$
|
|
2423
|
+
if (!utils$1.isUndefined(b)) {
|
|
2422
2424
|
return getMergedValue(undefined, b);
|
|
2423
|
-
} else if (!utils$
|
|
2425
|
+
} else if (!utils$1.isUndefined(a)) {
|
|
2424
2426
|
return getMergedValue(undefined, a);
|
|
2425
2427
|
}
|
|
2426
2428
|
}
|
|
@@ -2466,10 +2468,10 @@ function mergeConfig(config1, config2) {
|
|
|
2466
2468
|
headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
|
|
2467
2469
|
};
|
|
2468
2470
|
|
|
2469
|
-
utils$
|
|
2471
|
+
utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
|
2470
2472
|
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
2471
2473
|
const configValue = merge(config1[prop], config2[prop], prop);
|
|
2472
|
-
(utils$
|
|
2474
|
+
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
2473
2475
|
});
|
|
2474
2476
|
|
|
2475
2477
|
return config;
|
|
@@ -2493,7 +2495,7 @@ var resolveConfig = (config) => {
|
|
|
2493
2495
|
|
|
2494
2496
|
let contentType;
|
|
2495
2497
|
|
|
2496
|
-
if (utils$
|
|
2498
|
+
if (utils$1.isFormData(data)) {
|
|
2497
2499
|
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|
2498
2500
|
headers.setContentType(undefined); // Let the browser set it
|
|
2499
2501
|
} else if ((contentType = headers.getContentType()) !== false) {
|
|
@@ -2508,7 +2510,7 @@ var resolveConfig = (config) => {
|
|
|
2508
2510
|
// Specifically not if we're in a web worker, or react-native.
|
|
2509
2511
|
|
|
2510
2512
|
if (platform.hasStandardBrowserEnv) {
|
|
2511
|
-
withXSRFToken && utils$
|
|
2513
|
+
withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
|
|
2512
2514
|
|
|
2513
2515
|
if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
|
|
2514
2516
|
// Add xsrf header
|
|
@@ -2649,13 +2651,13 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
2649
2651
|
|
|
2650
2652
|
// Add headers to the request
|
|
2651
2653
|
if ('setRequestHeader' in request) {
|
|
2652
|
-
utils$
|
|
2654
|
+
utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
|
2653
2655
|
request.setRequestHeader(key, val);
|
|
2654
2656
|
});
|
|
2655
2657
|
}
|
|
2656
2658
|
|
|
2657
2659
|
// Add withCredentials to request if needed
|
|
2658
|
-
if (!utils$
|
|
2660
|
+
if (!utils$1.isUndefined(_config.withCredentials)) {
|
|
2659
2661
|
request.withCredentials = !!_config.withCredentials;
|
|
2660
2662
|
}
|
|
2661
2663
|
|
|
@@ -2747,7 +2749,7 @@ const composeSignals = (signals, timeout) => {
|
|
|
2747
2749
|
|
|
2748
2750
|
const {signal} = controller;
|
|
2749
2751
|
|
|
2750
|
-
signal.unsubscribe = () => utils$
|
|
2752
|
+
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
|
2751
2753
|
|
|
2752
2754
|
return signal;
|
|
2753
2755
|
}
|
|
@@ -2875,7 +2877,7 @@ const supportsRequestStream = isReadableStreamSupported && test(() => {
|
|
|
2875
2877
|
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
2876
2878
|
|
|
2877
2879
|
const supportsResponseStream = isReadableStreamSupported &&
|
|
2878
|
-
test(() => utils$
|
|
2880
|
+
test(() => utils$1.isReadableStream(new Response('').body));
|
|
2879
2881
|
|
|
2880
2882
|
|
|
2881
2883
|
const resolvers = {
|
|
@@ -2884,7 +2886,7 @@ const resolvers = {
|
|
|
2884
2886
|
|
|
2885
2887
|
isFetchSupported && (((res) => {
|
|
2886
2888
|
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
|
2887
|
-
!resolvers[type] && (resolvers[type] = utils$
|
|
2889
|
+
!resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
|
|
2888
2890
|
(_, config) => {
|
|
2889
2891
|
throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
|
|
2890
2892
|
});
|
|
@@ -2896,11 +2898,11 @@ const getBodyLength = async (body) => {
|
|
|
2896
2898
|
return 0;
|
|
2897
2899
|
}
|
|
2898
2900
|
|
|
2899
|
-
if(utils$
|
|
2901
|
+
if(utils$1.isBlob(body)) {
|
|
2900
2902
|
return body.size;
|
|
2901
2903
|
}
|
|
2902
2904
|
|
|
2903
|
-
if(utils$
|
|
2905
|
+
if(utils$1.isSpecCompliantForm(body)) {
|
|
2904
2906
|
const _request = new Request(platform.origin, {
|
|
2905
2907
|
method: 'POST',
|
|
2906
2908
|
body,
|
|
@@ -2908,21 +2910,21 @@ const getBodyLength = async (body) => {
|
|
|
2908
2910
|
return (await _request.arrayBuffer()).byteLength;
|
|
2909
2911
|
}
|
|
2910
2912
|
|
|
2911
|
-
if(utils$
|
|
2913
|
+
if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
|
2912
2914
|
return body.byteLength;
|
|
2913
2915
|
}
|
|
2914
2916
|
|
|
2915
|
-
if(utils$
|
|
2917
|
+
if(utils$1.isURLSearchParams(body)) {
|
|
2916
2918
|
body = body + '';
|
|
2917
2919
|
}
|
|
2918
2920
|
|
|
2919
|
-
if(utils$
|
|
2921
|
+
if(utils$1.isString(body)) {
|
|
2920
2922
|
return (await encodeText(body)).byteLength;
|
|
2921
2923
|
}
|
|
2922
2924
|
};
|
|
2923
2925
|
|
|
2924
2926
|
const resolveBodyLength = async (headers, body) => {
|
|
2925
|
-
const length = utils$
|
|
2927
|
+
const length = utils$1.toFiniteNumber(headers.getContentLength());
|
|
2926
2928
|
|
|
2927
2929
|
return length == null ? getBodyLength(body) : length;
|
|
2928
2930
|
};
|
|
@@ -2968,7 +2970,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
2968
2970
|
|
|
2969
2971
|
let contentTypeHeader;
|
|
2970
2972
|
|
|
2971
|
-
if (utils$
|
|
2973
|
+
if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
|
|
2972
2974
|
headers.setContentType(contentTypeHeader);
|
|
2973
2975
|
}
|
|
2974
2976
|
|
|
@@ -2982,7 +2984,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
2982
2984
|
}
|
|
2983
2985
|
}
|
|
2984
2986
|
|
|
2985
|
-
if (!utils$
|
|
2987
|
+
if (!utils$1.isString(withCredentials)) {
|
|
2986
2988
|
withCredentials = withCredentials ? 'include' : 'omit';
|
|
2987
2989
|
}
|
|
2988
2990
|
|
|
@@ -3010,7 +3012,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
3010
3012
|
options[prop] = response[prop];
|
|
3011
3013
|
});
|
|
3012
3014
|
|
|
3013
|
-
const responseContentLength = utils$
|
|
3015
|
+
const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
|
3014
3016
|
|
|
3015
3017
|
const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
|
|
3016
3018
|
responseContentLength,
|
|
@@ -3028,7 +3030,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
3028
3030
|
|
|
3029
3031
|
responseType = responseType || 'text';
|
|
3030
3032
|
|
|
3031
|
-
let responseData = await resolvers[utils$
|
|
3033
|
+
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
|
3032
3034
|
|
|
3033
3035
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
3034
3036
|
|
|
@@ -3064,7 +3066,7 @@ const knownAdapters = {
|
|
|
3064
3066
|
fetch: fetchAdapter
|
|
3065
3067
|
};
|
|
3066
3068
|
|
|
3067
|
-
utils$
|
|
3069
|
+
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
3068
3070
|
if (fn) {
|
|
3069
3071
|
try {
|
|
3070
3072
|
Object.defineProperty(fn, 'name', {value});
|
|
@@ -3077,11 +3079,11 @@ utils$2.forEach(knownAdapters, (fn, value) => {
|
|
|
3077
3079
|
|
|
3078
3080
|
const renderReason = (reason) => `- ${reason}`;
|
|
3079
3081
|
|
|
3080
|
-
const isResolvedHandle = (adapter) => utils$
|
|
3082
|
+
const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
3081
3083
|
|
|
3082
3084
|
var adapters = {
|
|
3083
3085
|
getAdapter: (adapters) => {
|
|
3084
|
-
adapters = utils$
|
|
3086
|
+
adapters = utils$1.isArray(adapters) ? adapters : [adapters];
|
|
3085
3087
|
|
|
3086
3088
|
const {length} = adapters;
|
|
3087
3089
|
let nameOrAdapter;
|
|
@@ -3378,7 +3380,7 @@ class Axios {
|
|
|
3378
3380
|
}
|
|
3379
3381
|
|
|
3380
3382
|
if (paramsSerializer != null) {
|
|
3381
|
-
if (utils$
|
|
3383
|
+
if (utils$1.isFunction(paramsSerializer)) {
|
|
3382
3384
|
config.paramsSerializer = {
|
|
3383
3385
|
serialize: paramsSerializer
|
|
3384
3386
|
};
|
|
@@ -3406,12 +3408,12 @@ class Axios {
|
|
|
3406
3408
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
|
3407
3409
|
|
|
3408
3410
|
// Flatten headers
|
|
3409
|
-
let contextHeaders = headers && utils$
|
|
3411
|
+
let contextHeaders = headers && utils$1.merge(
|
|
3410
3412
|
headers.common,
|
|
3411
3413
|
headers[config.method]
|
|
3412
3414
|
);
|
|
3413
3415
|
|
|
3414
|
-
headers && utils$
|
|
3416
|
+
headers && utils$1.forEach(
|
|
3415
3417
|
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
|
3416
3418
|
(method) => {
|
|
3417
3419
|
delete headers[method];
|
|
@@ -3498,7 +3500,7 @@ class Axios {
|
|
|
3498
3500
|
}
|
|
3499
3501
|
|
|
3500
3502
|
// Provide aliases for supported request methods
|
|
3501
|
-
utils$
|
|
3503
|
+
utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
|
3502
3504
|
/*eslint func-names:0*/
|
|
3503
3505
|
Axios.prototype[method] = function(url, config) {
|
|
3504
3506
|
return this.request(mergeConfig(config || {}, {
|
|
@@ -3509,7 +3511,7 @@ utils$2.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoDa
|
|
|
3509
3511
|
};
|
|
3510
3512
|
});
|
|
3511
3513
|
|
|
3512
|
-
utils$
|
|
3514
|
+
utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
3513
3515
|
/*eslint func-names:0*/
|
|
3514
3516
|
|
|
3515
3517
|
function generateHTTPMethod(isForm) {
|
|
@@ -3695,7 +3697,7 @@ function spread(callback) {
|
|
|
3695
3697
|
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
|
3696
3698
|
*/
|
|
3697
3699
|
function isAxiosError(payload) {
|
|
3698
|
-
return utils$
|
|
3700
|
+
return utils$1.isObject(payload) && (payload.isAxiosError === true);
|
|
3699
3701
|
}
|
|
3700
3702
|
|
|
3701
3703
|
const HttpStatusCode = {
|
|
@@ -3780,10 +3782,10 @@ function createInstance(defaultConfig) {
|
|
|
3780
3782
|
const instance = bind(Axios.prototype.request, context);
|
|
3781
3783
|
|
|
3782
3784
|
// Copy axios.prototype to instance
|
|
3783
|
-
utils$
|
|
3785
|
+
utils$1.extend(instance, Axios.prototype, context, {allOwnKeys: true});
|
|
3784
3786
|
|
|
3785
3787
|
// Copy context to instance
|
|
3786
|
-
utils$
|
|
3788
|
+
utils$1.extend(instance, context, null, {allOwnKeys: true});
|
|
3787
3789
|
|
|
3788
3790
|
// Factory for creating new instances
|
|
3789
3791
|
instance.create = function create(instanceConfig) {
|
|
@@ -3827,7 +3829,7 @@ axios.mergeConfig = mergeConfig;
|
|
|
3827
3829
|
|
|
3828
3830
|
axios.AxiosHeaders = AxiosHeaders;
|
|
3829
3831
|
|
|
3830
|
-
axios.formToJSON = thing => formDataToJSON(utils$
|
|
3832
|
+
axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
3831
3833
|
|
|
3832
3834
|
axios.getAdapter = adapters.getAdapter;
|
|
3833
3835
|
|
|
@@ -3898,143 +3900,6 @@ const getRawTx = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
3898
3900
|
return (yield axios.get(`${urlForNetwork(p.network)}/rawtx/${p.txid}`)).data.rawtx;
|
|
3899
3901
|
});
|
|
3900
3902
|
|
|
3901
|
-
function getDefaultExportFromCjs (x) {
|
|
3902
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
3903
|
-
}
|
|
3904
|
-
|
|
3905
|
-
var utils;
|
|
3906
|
-
var hasRequiredUtils;
|
|
3907
|
-
|
|
3908
|
-
function requireUtils () {
|
|
3909
|
-
if (hasRequiredUtils) return utils;
|
|
3910
|
-
hasRequiredUtils = 1;
|
|
3911
|
-
// baseline estimates, used to improve performance
|
|
3912
|
-
var TX_EMPTY_SIZE = 4 + 1 + 1 + 4;
|
|
3913
|
-
var TX_INPUT_BASE = 32 + 4 + 1 + 4;
|
|
3914
|
-
var TX_INPUT_PUBKEYHASH = 107;
|
|
3915
|
-
var TX_OUTPUT_BASE = 8 + 1;
|
|
3916
|
-
var TX_OUTPUT_PUBKEYHASH = 25;
|
|
3917
|
-
|
|
3918
|
-
function inputBytes (input) {
|
|
3919
|
-
return TX_INPUT_BASE + (input.script ? input.script.length : TX_INPUT_PUBKEYHASH)
|
|
3920
|
-
}
|
|
3921
|
-
|
|
3922
|
-
function outputBytes (output) {
|
|
3923
|
-
return TX_OUTPUT_BASE + (output.script ? output.script.length : TX_OUTPUT_PUBKEYHASH)
|
|
3924
|
-
}
|
|
3925
|
-
|
|
3926
|
-
function dustThreshold (output, feeRate) {
|
|
3927
|
-
/* ... classify the output for input estimate */
|
|
3928
|
-
return inputBytes({}) * feeRate
|
|
3929
|
-
}
|
|
3930
|
-
|
|
3931
|
-
function transactionBytes (inputs, outputs) {
|
|
3932
|
-
return TX_EMPTY_SIZE +
|
|
3933
|
-
inputs.reduce(function (a, x) { return a + inputBytes(x) }, 0) +
|
|
3934
|
-
outputs.reduce(function (a, x) { return a + outputBytes(x) }, 0)
|
|
3935
|
-
}
|
|
3936
|
-
|
|
3937
|
-
function uintOrNaN (v) {
|
|
3938
|
-
if (typeof v !== 'number') return NaN
|
|
3939
|
-
if (!isFinite(v)) return NaN
|
|
3940
|
-
if (Math.floor(v) !== v) return NaN
|
|
3941
|
-
if (v < 0) return NaN
|
|
3942
|
-
return v
|
|
3943
|
-
}
|
|
3944
|
-
|
|
3945
|
-
function sumForgiving (range) {
|
|
3946
|
-
return range.reduce(function (a, x) { return a + (isFinite(x.value) ? x.value : 0) }, 0)
|
|
3947
|
-
}
|
|
3948
|
-
|
|
3949
|
-
function sumOrNaN (range) {
|
|
3950
|
-
return range.reduce(function (a, x) { return a + uintOrNaN(x.value) }, 0)
|
|
3951
|
-
}
|
|
3952
|
-
|
|
3953
|
-
var BLANK_OUTPUT = outputBytes({});
|
|
3954
|
-
|
|
3955
|
-
function finalize (inputs, outputs, feeRate) {
|
|
3956
|
-
var bytesAccum = transactionBytes(inputs, outputs);
|
|
3957
|
-
var feeAfterExtraOutput = feeRate * (bytesAccum + BLANK_OUTPUT);
|
|
3958
|
-
var remainderAfterExtraOutput = sumOrNaN(inputs) - (sumOrNaN(outputs) + feeAfterExtraOutput);
|
|
3959
|
-
|
|
3960
|
-
// is it worth a change output?
|
|
3961
|
-
if (remainderAfterExtraOutput > dustThreshold({}, feeRate)) {
|
|
3962
|
-
outputs = outputs.concat({ value: remainderAfterExtraOutput });
|
|
3963
|
-
}
|
|
3964
|
-
|
|
3965
|
-
var fee = sumOrNaN(inputs) - sumOrNaN(outputs);
|
|
3966
|
-
if (!isFinite(fee)) return { fee: feeRate * bytesAccum }
|
|
3967
|
-
|
|
3968
|
-
return {
|
|
3969
|
-
inputs: inputs,
|
|
3970
|
-
outputs: outputs,
|
|
3971
|
-
fee: fee
|
|
3972
|
-
}
|
|
3973
|
-
}
|
|
3974
|
-
|
|
3975
|
-
utils = {
|
|
3976
|
-
dustThreshold: dustThreshold,
|
|
3977
|
-
finalize: finalize,
|
|
3978
|
-
inputBytes: inputBytes,
|
|
3979
|
-
outputBytes: outputBytes,
|
|
3980
|
-
sumOrNaN: sumOrNaN,
|
|
3981
|
-
sumForgiving: sumForgiving,
|
|
3982
|
-
transactionBytes: transactionBytes,
|
|
3983
|
-
uintOrNaN: uintOrNaN
|
|
3984
|
-
};
|
|
3985
|
-
return utils;
|
|
3986
|
-
}
|
|
3987
|
-
|
|
3988
|
-
var accumulative$1;
|
|
3989
|
-
var hasRequiredAccumulative;
|
|
3990
|
-
|
|
3991
|
-
function requireAccumulative () {
|
|
3992
|
-
if (hasRequiredAccumulative) return accumulative$1;
|
|
3993
|
-
hasRequiredAccumulative = 1;
|
|
3994
|
-
var utils = requireUtils();
|
|
3995
|
-
|
|
3996
|
-
// add inputs until we reach or surpass the target value (or deplete)
|
|
3997
|
-
// worst-case: O(n)
|
|
3998
|
-
accumulative$1 = function accumulative (utxos, outputs, feeRate) {
|
|
3999
|
-
if (!isFinite(utils.uintOrNaN(feeRate))) return {}
|
|
4000
|
-
var bytesAccum = utils.transactionBytes([], outputs);
|
|
4001
|
-
|
|
4002
|
-
var inAccum = 0;
|
|
4003
|
-
var inputs = [];
|
|
4004
|
-
var outAccum = utils.sumOrNaN(outputs);
|
|
4005
|
-
|
|
4006
|
-
for (var i = 0; i < utxos.length; ++i) {
|
|
4007
|
-
var utxo = utxos[i];
|
|
4008
|
-
var utxoBytes = utils.inputBytes(utxo);
|
|
4009
|
-
var utxoFee = feeRate * utxoBytes;
|
|
4010
|
-
var utxoValue = utils.uintOrNaN(utxo.value);
|
|
4011
|
-
|
|
4012
|
-
// skip detrimental input
|
|
4013
|
-
if (utxoFee > utxo.value) {
|
|
4014
|
-
if (i === utxos.length - 1) return { fee: feeRate * (bytesAccum + utxoBytes) }
|
|
4015
|
-
continue
|
|
4016
|
-
}
|
|
4017
|
-
|
|
4018
|
-
bytesAccum += utxoBytes;
|
|
4019
|
-
inAccum += utxoValue;
|
|
4020
|
-
inputs.push(utxo);
|
|
4021
|
-
|
|
4022
|
-
var fee = feeRate * bytesAccum;
|
|
4023
|
-
|
|
4024
|
-
// go again?
|
|
4025
|
-
if (inAccum < outAccum + fee) continue
|
|
4026
|
-
|
|
4027
|
-
return utils.finalize(inputs, outputs, feeRate)
|
|
4028
|
-
}
|
|
4029
|
-
|
|
4030
|
-
return { fee: feeRate * bytesAccum }
|
|
4031
|
-
};
|
|
4032
|
-
return accumulative$1;
|
|
4033
|
-
}
|
|
4034
|
-
|
|
4035
|
-
var accumulativeExports = requireAccumulative();
|
|
4036
|
-
var accumulative = /*@__PURE__*/getDefaultExportFromCjs(accumulativeExports);
|
|
4037
|
-
|
|
4038
3903
|
/**
|
|
4039
3904
|
* Object containing the sizes (in bytes) of various components in a Dash transaction.
|
|
4040
3905
|
*/
|
|
@@ -4121,7 +3986,7 @@ const buildTx = ({ amount, recipient, memo, feeRate, sender, network, }) => __aw
|
|
|
4121
3986
|
},
|
|
4122
3987
|
];
|
|
4123
3988
|
// Calculate inputs and outputs for the transaction
|
|
4124
|
-
const { inputs, outputs } =
|
|
3989
|
+
const { inputs, outputs } = accumulative__default.default(utxos, targetOutputs, feeRateWhole);
|
|
4125
3990
|
if (!inputs || !outputs)
|
|
4126
3991
|
throw new Error('Insufficient balance for transaction');
|
|
4127
3992
|
// Initialize new Dash transaction
|
|
@@ -4648,4 +4513,3 @@ exports.defaultDashParams = defaultDashParams;
|
|
|
4648
4513
|
exports.explorerProviders = explorerProviders;
|
|
4649
4514
|
exports.getPrefix = getPrefix;
|
|
4650
4515
|
exports.validateAddress = validateAddress;
|
|
4651
|
-
//# sourceMappingURL=index.js.map
|