@xchainjs/xchain-dash 1.0.5 → 1.0.7
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 +288 -283
- package/lib/index.js.map +1 -1
- package/package.json +7 -7
package/lib/index.esm.js
CHANGED
|
@@ -101,6 +101,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
101
101
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
102
102
|
PERFORMANCE OF THIS SOFTWARE.
|
|
103
103
|
***************************************************************************** */
|
|
104
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
105
|
+
|
|
104
106
|
|
|
105
107
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
106
108
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -110,7 +112,12 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
110
112
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
111
113
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
112
114
|
});
|
|
113
|
-
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
118
|
+
var e = new Error(message);
|
|
119
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
120
|
+
};
|
|
114
121
|
|
|
115
122
|
function bind(fn, thisArg) {
|
|
116
123
|
return function wrap() {
|
|
@@ -815,7 +822,7 @@ const asap = typeof queueMicrotask !== 'undefined' ?
|
|
|
815
822
|
|
|
816
823
|
// *********************
|
|
817
824
|
|
|
818
|
-
var utils$
|
|
825
|
+
var utils$2 = {
|
|
819
826
|
isArray,
|
|
820
827
|
isArrayBuffer,
|
|
821
828
|
isBuffer,
|
|
@@ -903,7 +910,7 @@ function AxiosError(message, code, config, request, response) {
|
|
|
903
910
|
response && (this.response = response);
|
|
904
911
|
}
|
|
905
912
|
|
|
906
|
-
utils$
|
|
913
|
+
utils$2.inherits(AxiosError, Error, {
|
|
907
914
|
toJSON: function toJSON() {
|
|
908
915
|
return {
|
|
909
916
|
// Standard
|
|
@@ -918,7 +925,7 @@ utils$3.inherits(AxiosError, Error, {
|
|
|
918
925
|
columnNumber: this.columnNumber,
|
|
919
926
|
stack: this.stack,
|
|
920
927
|
// Axios
|
|
921
|
-
config: utils$
|
|
928
|
+
config: utils$2.toJSONObject(this.config),
|
|
922
929
|
code: this.code,
|
|
923
930
|
status: this.response && this.response.status ? this.response.status : null
|
|
924
931
|
};
|
|
@@ -953,7 +960,7 @@ Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
|
|
|
953
960
|
AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
954
961
|
const axiosError = Object.create(prototype$1);
|
|
955
962
|
|
|
956
|
-
utils$
|
|
963
|
+
utils$2.toFlatObject(error, axiosError, function filter(obj) {
|
|
957
964
|
return obj !== Error.prototype;
|
|
958
965
|
}, prop => {
|
|
959
966
|
return prop !== 'isAxiosError';
|
|
@@ -981,7 +988,7 @@ var httpAdapter = null;
|
|
|
981
988
|
* @returns {boolean}
|
|
982
989
|
*/
|
|
983
990
|
function isVisitable(thing) {
|
|
984
|
-
return utils$
|
|
991
|
+
return utils$2.isPlainObject(thing) || utils$2.isArray(thing);
|
|
985
992
|
}
|
|
986
993
|
|
|
987
994
|
/**
|
|
@@ -992,7 +999,7 @@ function isVisitable(thing) {
|
|
|
992
999
|
* @returns {string} the key without the brackets.
|
|
993
1000
|
*/
|
|
994
1001
|
function removeBrackets(key) {
|
|
995
|
-
return utils$
|
|
1002
|
+
return utils$2.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
996
1003
|
}
|
|
997
1004
|
|
|
998
1005
|
/**
|
|
@@ -1021,10 +1028,10 @@ function renderKey(path, key, dots) {
|
|
|
1021
1028
|
* @returns {boolean}
|
|
1022
1029
|
*/
|
|
1023
1030
|
function isFlatArray(arr) {
|
|
1024
|
-
return utils$
|
|
1031
|
+
return utils$2.isArray(arr) && !arr.some(isVisitable);
|
|
1025
1032
|
}
|
|
1026
1033
|
|
|
1027
|
-
const predicates = utils$
|
|
1034
|
+
const predicates = utils$2.toFlatObject(utils$2, {}, null, function filter(prop) {
|
|
1028
1035
|
return /^is[A-Z]/.test(prop);
|
|
1029
1036
|
});
|
|
1030
1037
|
|
|
@@ -1052,7 +1059,7 @@ const predicates = utils$3.toFlatObject(utils$3, {}, null, function filter(prop)
|
|
|
1052
1059
|
* @returns
|
|
1053
1060
|
*/
|
|
1054
1061
|
function toFormData(obj, formData, options) {
|
|
1055
|
-
if (!utils$
|
|
1062
|
+
if (!utils$2.isObject(obj)) {
|
|
1056
1063
|
throw new TypeError('target must be an object');
|
|
1057
1064
|
}
|
|
1058
1065
|
|
|
@@ -1060,13 +1067,13 @@ function toFormData(obj, formData, options) {
|
|
|
1060
1067
|
formData = formData || new (FormData)();
|
|
1061
1068
|
|
|
1062
1069
|
// eslint-disable-next-line no-param-reassign
|
|
1063
|
-
options = utils$
|
|
1070
|
+
options = utils$2.toFlatObject(options, {
|
|
1064
1071
|
metaTokens: true,
|
|
1065
1072
|
dots: false,
|
|
1066
1073
|
indexes: false
|
|
1067
1074
|
}, false, function defined(option, source) {
|
|
1068
1075
|
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
1069
|
-
return !utils$
|
|
1076
|
+
return !utils$2.isUndefined(source[option]);
|
|
1070
1077
|
});
|
|
1071
1078
|
|
|
1072
1079
|
const metaTokens = options.metaTokens;
|
|
@@ -1075,24 +1082,24 @@ function toFormData(obj, formData, options) {
|
|
|
1075
1082
|
const dots = options.dots;
|
|
1076
1083
|
const indexes = options.indexes;
|
|
1077
1084
|
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
|
1078
|
-
const useBlob = _Blob && utils$
|
|
1085
|
+
const useBlob = _Blob && utils$2.isSpecCompliantForm(formData);
|
|
1079
1086
|
|
|
1080
|
-
if (!utils$
|
|
1087
|
+
if (!utils$2.isFunction(visitor)) {
|
|
1081
1088
|
throw new TypeError('visitor must be a function');
|
|
1082
1089
|
}
|
|
1083
1090
|
|
|
1084
1091
|
function convertValue(value) {
|
|
1085
1092
|
if (value === null) return '';
|
|
1086
1093
|
|
|
1087
|
-
if (utils$
|
|
1094
|
+
if (utils$2.isDate(value)) {
|
|
1088
1095
|
return value.toISOString();
|
|
1089
1096
|
}
|
|
1090
1097
|
|
|
1091
|
-
if (!useBlob && utils$
|
|
1098
|
+
if (!useBlob && utils$2.isBlob(value)) {
|
|
1092
1099
|
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
|
1093
1100
|
}
|
|
1094
1101
|
|
|
1095
|
-
if (utils$
|
|
1102
|
+
if (utils$2.isArrayBuffer(value) || utils$2.isTypedArray(value)) {
|
|
1096
1103
|
return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
|
1097
1104
|
}
|
|
1098
1105
|
|
|
@@ -1113,20 +1120,20 @@ function toFormData(obj, formData, options) {
|
|
|
1113
1120
|
let arr = value;
|
|
1114
1121
|
|
|
1115
1122
|
if (value && !path && typeof value === 'object') {
|
|
1116
|
-
if (utils$
|
|
1123
|
+
if (utils$2.endsWith(key, '{}')) {
|
|
1117
1124
|
// eslint-disable-next-line no-param-reassign
|
|
1118
1125
|
key = metaTokens ? key : key.slice(0, -2);
|
|
1119
1126
|
// eslint-disable-next-line no-param-reassign
|
|
1120
1127
|
value = JSON.stringify(value);
|
|
1121
1128
|
} else if (
|
|
1122
|
-
(utils$
|
|
1123
|
-
((utils$
|
|
1129
|
+
(utils$2.isArray(value) && isFlatArray(value)) ||
|
|
1130
|
+
((utils$2.isFileList(value) || utils$2.endsWith(key, '[]')) && (arr = utils$2.toArray(value))
|
|
1124
1131
|
)) {
|
|
1125
1132
|
// eslint-disable-next-line no-param-reassign
|
|
1126
1133
|
key = removeBrackets(key);
|
|
1127
1134
|
|
|
1128
1135
|
arr.forEach(function each(el, index) {
|
|
1129
|
-
!(utils$
|
|
1136
|
+
!(utils$2.isUndefined(el) || el === null) && formData.append(
|
|
1130
1137
|
// eslint-disable-next-line no-nested-ternary
|
|
1131
1138
|
indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
|
|
1132
1139
|
convertValue(el)
|
|
@@ -1154,7 +1161,7 @@ function toFormData(obj, formData, options) {
|
|
|
1154
1161
|
});
|
|
1155
1162
|
|
|
1156
1163
|
function build(value, path) {
|
|
1157
|
-
if (utils$
|
|
1164
|
+
if (utils$2.isUndefined(value)) return;
|
|
1158
1165
|
|
|
1159
1166
|
if (stack.indexOf(value) !== -1) {
|
|
1160
1167
|
throw Error('Circular reference detected in ' + path.join('.'));
|
|
@@ -1162,9 +1169,9 @@ function toFormData(obj, formData, options) {
|
|
|
1162
1169
|
|
|
1163
1170
|
stack.push(value);
|
|
1164
1171
|
|
|
1165
|
-
utils$
|
|
1166
|
-
const result = !(utils$
|
|
1167
|
-
formData, el, utils$
|
|
1172
|
+
utils$2.forEach(value, function each(el, key) {
|
|
1173
|
+
const result = !(utils$2.isUndefined(el) || el === null) && visitor.call(
|
|
1174
|
+
formData, el, utils$2.isString(key) ? key.trim() : key, path, exposedHelpers
|
|
1168
1175
|
);
|
|
1169
1176
|
|
|
1170
1177
|
if (result === true) {
|
|
@@ -1175,7 +1182,7 @@ function toFormData(obj, formData, options) {
|
|
|
1175
1182
|
stack.pop();
|
|
1176
1183
|
}
|
|
1177
1184
|
|
|
1178
|
-
if (!utils$
|
|
1185
|
+
if (!utils$2.isObject(obj)) {
|
|
1179
1186
|
throw new TypeError('data must be an object');
|
|
1180
1187
|
}
|
|
1181
1188
|
|
|
@@ -1279,7 +1286,7 @@ function buildURL(url, params, options) {
|
|
|
1279
1286
|
if (serializeFn) {
|
|
1280
1287
|
serializedParams = serializeFn(params, options);
|
|
1281
1288
|
} else {
|
|
1282
|
-
serializedParams = utils$
|
|
1289
|
+
serializedParams = utils$2.isURLSearchParams(params) ?
|
|
1283
1290
|
params.toString() :
|
|
1284
1291
|
new AxiosURLSearchParams(params, options).toString(_encode);
|
|
1285
1292
|
}
|
|
@@ -1354,7 +1361,7 @@ class InterceptorManager {
|
|
|
1354
1361
|
* @returns {void}
|
|
1355
1362
|
*/
|
|
1356
1363
|
forEach(fn) {
|
|
1357
|
-
utils$
|
|
1364
|
+
utils$2.forEach(this.handlers, function forEachHandler(h) {
|
|
1358
1365
|
if (h !== null) {
|
|
1359
1366
|
fn(h);
|
|
1360
1367
|
}
|
|
@@ -1362,8 +1369,6 @@ class InterceptorManager {
|
|
|
1362
1369
|
}
|
|
1363
1370
|
}
|
|
1364
1371
|
|
|
1365
|
-
var InterceptorManager$1 = InterceptorManager;
|
|
1366
|
-
|
|
1367
1372
|
var transitionalDefaults = {
|
|
1368
1373
|
silentJSONParsing: true,
|
|
1369
1374
|
forcedJSONParsing: true,
|
|
@@ -1430,23 +1435,23 @@ const hasStandardBrowserWebWorkerEnv = (() => {
|
|
|
1430
1435
|
|
|
1431
1436
|
const origin = hasBrowserEnv && window.location.href || 'http://localhost';
|
|
1432
1437
|
|
|
1433
|
-
var utils$
|
|
1438
|
+
var utils$1 = /*#__PURE__*/Object.freeze({
|
|
1434
1439
|
__proto__: null,
|
|
1435
1440
|
hasBrowserEnv: hasBrowserEnv,
|
|
1436
|
-
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
|
1437
1441
|
hasStandardBrowserEnv: hasStandardBrowserEnv,
|
|
1442
|
+
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
|
1438
1443
|
origin: origin
|
|
1439
1444
|
});
|
|
1440
1445
|
|
|
1441
1446
|
var platform = {
|
|
1442
|
-
...utils$
|
|
1447
|
+
...utils$1,
|
|
1443
1448
|
...platform$1
|
|
1444
1449
|
};
|
|
1445
1450
|
|
|
1446
1451
|
function toURLEncodedForm(data, options) {
|
|
1447
1452
|
return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
|
|
1448
1453
|
visitor: function(value, key, path, helpers) {
|
|
1449
|
-
if (platform.isNode && utils$
|
|
1454
|
+
if (platform.isNode && utils$2.isBuffer(value)) {
|
|
1450
1455
|
this.append(key, value.toString('base64'));
|
|
1451
1456
|
return false;
|
|
1452
1457
|
}
|
|
@@ -1468,7 +1473,7 @@ function parsePropPath(name) {
|
|
|
1468
1473
|
// foo.x.y.z
|
|
1469
1474
|
// foo-x-y-z
|
|
1470
1475
|
// foo x y z
|
|
1471
|
-
return utils$
|
|
1476
|
+
return utils$2.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
|
1472
1477
|
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
1473
1478
|
});
|
|
1474
1479
|
}
|
|
@@ -1508,10 +1513,10 @@ function formDataToJSON(formData) {
|
|
|
1508
1513
|
|
|
1509
1514
|
const isNumericKey = Number.isFinite(+name);
|
|
1510
1515
|
const isLast = index >= path.length;
|
|
1511
|
-
name = !name && utils$
|
|
1516
|
+
name = !name && utils$2.isArray(target) ? target.length : name;
|
|
1512
1517
|
|
|
1513
1518
|
if (isLast) {
|
|
1514
|
-
if (utils$
|
|
1519
|
+
if (utils$2.hasOwnProp(target, name)) {
|
|
1515
1520
|
target[name] = [target[name], value];
|
|
1516
1521
|
} else {
|
|
1517
1522
|
target[name] = value;
|
|
@@ -1520,23 +1525,23 @@ function formDataToJSON(formData) {
|
|
|
1520
1525
|
return !isNumericKey;
|
|
1521
1526
|
}
|
|
1522
1527
|
|
|
1523
|
-
if (!target[name] || !utils$
|
|
1528
|
+
if (!target[name] || !utils$2.isObject(target[name])) {
|
|
1524
1529
|
target[name] = [];
|
|
1525
1530
|
}
|
|
1526
1531
|
|
|
1527
1532
|
const result = buildPath(path, value, target[name], index);
|
|
1528
1533
|
|
|
1529
|
-
if (result && utils$
|
|
1534
|
+
if (result && utils$2.isArray(target[name])) {
|
|
1530
1535
|
target[name] = arrayToObject(target[name]);
|
|
1531
1536
|
}
|
|
1532
1537
|
|
|
1533
1538
|
return !isNumericKey;
|
|
1534
1539
|
}
|
|
1535
1540
|
|
|
1536
|
-
if (utils$
|
|
1541
|
+
if (utils$2.isFormData(formData) && utils$2.isFunction(formData.entries)) {
|
|
1537
1542
|
const obj = {};
|
|
1538
1543
|
|
|
1539
|
-
utils$
|
|
1544
|
+
utils$2.forEachEntry(formData, (name, value) => {
|
|
1540
1545
|
buildPath(parsePropPath(name), value, obj, 0);
|
|
1541
1546
|
});
|
|
1542
1547
|
|
|
@@ -1557,10 +1562,10 @@ function formDataToJSON(formData) {
|
|
|
1557
1562
|
* @returns {string} A stringified version of the rawValue.
|
|
1558
1563
|
*/
|
|
1559
1564
|
function stringifySafely(rawValue, parser, encoder) {
|
|
1560
|
-
if (utils$
|
|
1565
|
+
if (utils$2.isString(rawValue)) {
|
|
1561
1566
|
try {
|
|
1562
1567
|
(parser || JSON.parse)(rawValue);
|
|
1563
|
-
return utils$
|
|
1568
|
+
return utils$2.trim(rawValue);
|
|
1564
1569
|
} catch (e) {
|
|
1565
1570
|
if (e.name !== 'SyntaxError') {
|
|
1566
1571
|
throw e;
|
|
@@ -1568,7 +1573,7 @@ function stringifySafely(rawValue, parser, encoder) {
|
|
|
1568
1573
|
}
|
|
1569
1574
|
}
|
|
1570
1575
|
|
|
1571
|
-
return (
|
|
1576
|
+
return (0, JSON.stringify)(rawValue);
|
|
1572
1577
|
}
|
|
1573
1578
|
|
|
1574
1579
|
const defaults = {
|
|
@@ -1580,31 +1585,31 @@ const defaults = {
|
|
|
1580
1585
|
transformRequest: [function transformRequest(data, headers) {
|
|
1581
1586
|
const contentType = headers.getContentType() || '';
|
|
1582
1587
|
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
1583
|
-
const isObjectPayload = utils$
|
|
1588
|
+
const isObjectPayload = utils$2.isObject(data);
|
|
1584
1589
|
|
|
1585
|
-
if (isObjectPayload && utils$
|
|
1590
|
+
if (isObjectPayload && utils$2.isHTMLForm(data)) {
|
|
1586
1591
|
data = new FormData(data);
|
|
1587
1592
|
}
|
|
1588
1593
|
|
|
1589
|
-
const isFormData = utils$
|
|
1594
|
+
const isFormData = utils$2.isFormData(data);
|
|
1590
1595
|
|
|
1591
1596
|
if (isFormData) {
|
|
1592
1597
|
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
1593
1598
|
}
|
|
1594
1599
|
|
|
1595
|
-
if (utils$
|
|
1596
|
-
utils$
|
|
1597
|
-
utils$
|
|
1598
|
-
utils$
|
|
1599
|
-
utils$
|
|
1600
|
-
utils$
|
|
1600
|
+
if (utils$2.isArrayBuffer(data) ||
|
|
1601
|
+
utils$2.isBuffer(data) ||
|
|
1602
|
+
utils$2.isStream(data) ||
|
|
1603
|
+
utils$2.isFile(data) ||
|
|
1604
|
+
utils$2.isBlob(data) ||
|
|
1605
|
+
utils$2.isReadableStream(data)
|
|
1601
1606
|
) {
|
|
1602
1607
|
return data;
|
|
1603
1608
|
}
|
|
1604
|
-
if (utils$
|
|
1609
|
+
if (utils$2.isArrayBufferView(data)) {
|
|
1605
1610
|
return data.buffer;
|
|
1606
1611
|
}
|
|
1607
|
-
if (utils$
|
|
1612
|
+
if (utils$2.isURLSearchParams(data)) {
|
|
1608
1613
|
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
1609
1614
|
return data.toString();
|
|
1610
1615
|
}
|
|
@@ -1616,7 +1621,7 @@ const defaults = {
|
|
|
1616
1621
|
return toURLEncodedForm(data, this.formSerializer).toString();
|
|
1617
1622
|
}
|
|
1618
1623
|
|
|
1619
|
-
if ((isFileList = utils$
|
|
1624
|
+
if ((isFileList = utils$2.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
|
1620
1625
|
const _FormData = this.env && this.env.FormData;
|
|
1621
1626
|
|
|
1622
1627
|
return toFormData(
|
|
@@ -1640,11 +1645,11 @@ const defaults = {
|
|
|
1640
1645
|
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
1641
1646
|
const JSONRequested = this.responseType === 'json';
|
|
1642
1647
|
|
|
1643
|
-
if (utils$
|
|
1648
|
+
if (utils$2.isResponse(data) || utils$2.isReadableStream(data)) {
|
|
1644
1649
|
return data;
|
|
1645
1650
|
}
|
|
1646
1651
|
|
|
1647
|
-
if (data && utils$
|
|
1652
|
+
if (data && utils$2.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
|
1648
1653
|
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
1649
1654
|
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
1650
1655
|
|
|
@@ -1692,15 +1697,13 @@ const defaults = {
|
|
|
1692
1697
|
}
|
|
1693
1698
|
};
|
|
1694
1699
|
|
|
1695
|
-
utils$
|
|
1700
|
+
utils$2.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
|
1696
1701
|
defaults.headers[method] = {};
|
|
1697
1702
|
});
|
|
1698
1703
|
|
|
1699
|
-
var defaults$1 = defaults;
|
|
1700
|
-
|
|
1701
1704
|
// RawAxiosHeaders whose duplicates are ignored by node
|
|
1702
1705
|
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
1703
|
-
const ignoreDuplicateOf = utils$
|
|
1706
|
+
const ignoreDuplicateOf = utils$2.toObjectSet([
|
|
1704
1707
|
'age', 'authorization', 'content-length', 'content-type', 'etag',
|
|
1705
1708
|
'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
|
|
1706
1709
|
'last-modified', 'location', 'max-forwards', 'proxy-authorization',
|
|
@@ -1761,7 +1764,7 @@ function normalizeValue(value) {
|
|
|
1761
1764
|
return value;
|
|
1762
1765
|
}
|
|
1763
1766
|
|
|
1764
|
-
return utils$
|
|
1767
|
+
return utils$2.isArray(value) ? value.map(normalizeValue) : String(value);
|
|
1765
1768
|
}
|
|
1766
1769
|
|
|
1767
1770
|
function parseTokens(str) {
|
|
@@ -1779,7 +1782,7 @@ function parseTokens(str) {
|
|
|
1779
1782
|
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
1780
1783
|
|
|
1781
1784
|
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
1782
|
-
if (utils$
|
|
1785
|
+
if (utils$2.isFunction(filter)) {
|
|
1783
1786
|
return filter.call(this, value, header);
|
|
1784
1787
|
}
|
|
1785
1788
|
|
|
@@ -1787,13 +1790,13 @@ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
|
1787
1790
|
value = header;
|
|
1788
1791
|
}
|
|
1789
1792
|
|
|
1790
|
-
if (!utils$
|
|
1793
|
+
if (!utils$2.isString(value)) return;
|
|
1791
1794
|
|
|
1792
|
-
if (utils$
|
|
1795
|
+
if (utils$2.isString(filter)) {
|
|
1793
1796
|
return value.indexOf(filter) !== -1;
|
|
1794
1797
|
}
|
|
1795
1798
|
|
|
1796
|
-
if (utils$
|
|
1799
|
+
if (utils$2.isRegExp(filter)) {
|
|
1797
1800
|
return filter.test(value);
|
|
1798
1801
|
}
|
|
1799
1802
|
}
|
|
@@ -1806,7 +1809,7 @@ function formatHeader(header) {
|
|
|
1806
1809
|
}
|
|
1807
1810
|
|
|
1808
1811
|
function buildAccessors(obj, header) {
|
|
1809
|
-
const accessorName = utils$
|
|
1812
|
+
const accessorName = utils$2.toCamelCase(' ' + header);
|
|
1810
1813
|
|
|
1811
1814
|
['get', 'set', 'has'].forEach(methodName => {
|
|
1812
1815
|
Object.defineProperty(obj, methodName + accessorName, {
|
|
@@ -1833,7 +1836,7 @@ class AxiosHeaders {
|
|
|
1833
1836
|
throw new Error('header name must be a non-empty string');
|
|
1834
1837
|
}
|
|
1835
1838
|
|
|
1836
|
-
const key = utils$
|
|
1839
|
+
const key = utils$2.findKey(self, lHeader);
|
|
1837
1840
|
|
|
1838
1841
|
if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
|
|
1839
1842
|
self[key || _header] = normalizeValue(_value);
|
|
@@ -1841,13 +1844,13 @@ class AxiosHeaders {
|
|
|
1841
1844
|
}
|
|
1842
1845
|
|
|
1843
1846
|
const setHeaders = (headers, _rewrite) =>
|
|
1844
|
-
utils$
|
|
1847
|
+
utils$2.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
1845
1848
|
|
|
1846
|
-
if (utils$
|
|
1849
|
+
if (utils$2.isPlainObject(header) || header instanceof this.constructor) {
|
|
1847
1850
|
setHeaders(header, valueOrRewrite);
|
|
1848
|
-
} else if(utils$
|
|
1851
|
+
} else if(utils$2.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
1849
1852
|
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
1850
|
-
} else if (utils$
|
|
1853
|
+
} else if (utils$2.isHeaders(header)) {
|
|
1851
1854
|
for (const [key, value] of header.entries()) {
|
|
1852
1855
|
setHeader(value, key, rewrite);
|
|
1853
1856
|
}
|
|
@@ -1862,7 +1865,7 @@ class AxiosHeaders {
|
|
|
1862
1865
|
header = normalizeHeader(header);
|
|
1863
1866
|
|
|
1864
1867
|
if (header) {
|
|
1865
|
-
const key = utils$
|
|
1868
|
+
const key = utils$2.findKey(this, header);
|
|
1866
1869
|
|
|
1867
1870
|
if (key) {
|
|
1868
1871
|
const value = this[key];
|
|
@@ -1875,11 +1878,11 @@ class AxiosHeaders {
|
|
|
1875
1878
|
return parseTokens(value);
|
|
1876
1879
|
}
|
|
1877
1880
|
|
|
1878
|
-
if (utils$
|
|
1881
|
+
if (utils$2.isFunction(parser)) {
|
|
1879
1882
|
return parser.call(this, value, key);
|
|
1880
1883
|
}
|
|
1881
1884
|
|
|
1882
|
-
if (utils$
|
|
1885
|
+
if (utils$2.isRegExp(parser)) {
|
|
1883
1886
|
return parser.exec(value);
|
|
1884
1887
|
}
|
|
1885
1888
|
|
|
@@ -1892,7 +1895,7 @@ class AxiosHeaders {
|
|
|
1892
1895
|
header = normalizeHeader(header);
|
|
1893
1896
|
|
|
1894
1897
|
if (header) {
|
|
1895
|
-
const key = utils$
|
|
1898
|
+
const key = utils$2.findKey(this, header);
|
|
1896
1899
|
|
|
1897
1900
|
return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
|
1898
1901
|
}
|
|
@@ -1908,7 +1911,7 @@ class AxiosHeaders {
|
|
|
1908
1911
|
_header = normalizeHeader(_header);
|
|
1909
1912
|
|
|
1910
1913
|
if (_header) {
|
|
1911
|
-
const key = utils$
|
|
1914
|
+
const key = utils$2.findKey(self, _header);
|
|
1912
1915
|
|
|
1913
1916
|
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
|
1914
1917
|
delete self[key];
|
|
@@ -1918,7 +1921,7 @@ class AxiosHeaders {
|
|
|
1918
1921
|
}
|
|
1919
1922
|
}
|
|
1920
1923
|
|
|
1921
|
-
if (utils$
|
|
1924
|
+
if (utils$2.isArray(header)) {
|
|
1922
1925
|
header.forEach(deleteHeader);
|
|
1923
1926
|
} else {
|
|
1924
1927
|
deleteHeader(header);
|
|
@@ -1947,8 +1950,8 @@ class AxiosHeaders {
|
|
|
1947
1950
|
const self = this;
|
|
1948
1951
|
const headers = {};
|
|
1949
1952
|
|
|
1950
|
-
utils$
|
|
1951
|
-
const key = utils$
|
|
1953
|
+
utils$2.forEach(this, (value, header) => {
|
|
1954
|
+
const key = utils$2.findKey(headers, header);
|
|
1952
1955
|
|
|
1953
1956
|
if (key) {
|
|
1954
1957
|
self[key] = normalizeValue(value);
|
|
@@ -1977,8 +1980,8 @@ class AxiosHeaders {
|
|
|
1977
1980
|
toJSON(asStrings) {
|
|
1978
1981
|
const obj = Object.create(null);
|
|
1979
1982
|
|
|
1980
|
-
utils$
|
|
1981
|
-
value != null && value !== false && (obj[header] = asStrings && utils$
|
|
1983
|
+
utils$2.forEach(this, (value, header) => {
|
|
1984
|
+
value != null && value !== false && (obj[header] = asStrings && utils$2.isArray(value) ? value.join(', ') : value);
|
|
1982
1985
|
});
|
|
1983
1986
|
|
|
1984
1987
|
return obj;
|
|
@@ -2025,7 +2028,7 @@ class AxiosHeaders {
|
|
|
2025
2028
|
}
|
|
2026
2029
|
}
|
|
2027
2030
|
|
|
2028
|
-
utils$
|
|
2031
|
+
utils$2.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
|
2029
2032
|
|
|
2030
2033
|
return this;
|
|
2031
2034
|
}
|
|
@@ -2034,7 +2037,7 @@ class AxiosHeaders {
|
|
|
2034
2037
|
AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
|
|
2035
2038
|
|
|
2036
2039
|
// reserved names hotfix
|
|
2037
|
-
utils$
|
|
2040
|
+
utils$2.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
|
|
2038
2041
|
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|
2039
2042
|
return {
|
|
2040
2043
|
get: () => value,
|
|
@@ -2044,9 +2047,7 @@ utils$3.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
|
|
|
2044
2047
|
}
|
|
2045
2048
|
});
|
|
2046
2049
|
|
|
2047
|
-
utils$
|
|
2048
|
-
|
|
2049
|
-
var AxiosHeaders$1 = AxiosHeaders;
|
|
2050
|
+
utils$2.freezeMethods(AxiosHeaders);
|
|
2050
2051
|
|
|
2051
2052
|
/**
|
|
2052
2053
|
* Transform the data for a request or a response
|
|
@@ -2057,12 +2058,12 @@ var AxiosHeaders$1 = AxiosHeaders;
|
|
|
2057
2058
|
* @returns {*} The resulting transformed data
|
|
2058
2059
|
*/
|
|
2059
2060
|
function transformData(fns, response) {
|
|
2060
|
-
const config = this || defaults
|
|
2061
|
+
const config = this || defaults;
|
|
2061
2062
|
const context = response || config;
|
|
2062
|
-
const headers = AxiosHeaders
|
|
2063
|
+
const headers = AxiosHeaders.from(context.headers);
|
|
2063
2064
|
let data = context.data;
|
|
2064
2065
|
|
|
2065
|
-
utils$
|
|
2066
|
+
utils$2.forEach(fns, function transform(fn) {
|
|
2066
2067
|
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
|
2067
2068
|
});
|
|
2068
2069
|
|
|
@@ -2090,7 +2091,7 @@ function CanceledError(message, config, request) {
|
|
|
2090
2091
|
this.name = 'CanceledError';
|
|
2091
2092
|
}
|
|
2092
2093
|
|
|
2093
|
-
utils$
|
|
2094
|
+
utils$2.inherits(CanceledError, AxiosError, {
|
|
2094
2095
|
__CANCEL__: true
|
|
2095
2096
|
});
|
|
2096
2097
|
|
|
@@ -2257,7 +2258,7 @@ const progressEventDecorator = (total, throttled) => {
|
|
|
2257
2258
|
}), throttled[1]];
|
|
2258
2259
|
};
|
|
2259
2260
|
|
|
2260
|
-
const asyncDecorator = (fn) => (...args) => utils$
|
|
2261
|
+
const asyncDecorator = (fn) => (...args) => utils$2.asap(() => fn(...args));
|
|
2261
2262
|
|
|
2262
2263
|
var isURLSameOrigin = platform.hasStandardBrowserEnv ?
|
|
2263
2264
|
|
|
@@ -2309,7 +2310,7 @@ var isURLSameOrigin = platform.hasStandardBrowserEnv ?
|
|
|
2309
2310
|
* @returns {boolean} True if URL shares the same origin, otherwise false
|
|
2310
2311
|
*/
|
|
2311
2312
|
return function isURLSameOrigin(requestURL) {
|
|
2312
|
-
const parsed = (utils$
|
|
2313
|
+
const parsed = (utils$2.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
|
2313
2314
|
return (parsed.protocol === originURL.protocol &&
|
|
2314
2315
|
parsed.host === originURL.host);
|
|
2315
2316
|
};
|
|
@@ -2329,11 +2330,11 @@ var cookies = platform.hasStandardBrowserEnv ?
|
|
|
2329
2330
|
write(name, value, expires, path, domain, secure) {
|
|
2330
2331
|
const cookie = [name + '=' + encodeURIComponent(value)];
|
|
2331
2332
|
|
|
2332
|
-
utils$
|
|
2333
|
+
utils$2.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
|
|
2333
2334
|
|
|
2334
|
-
utils$
|
|
2335
|
+
utils$2.isString(path) && cookie.push('path=' + path);
|
|
2335
2336
|
|
|
2336
|
-
utils$
|
|
2337
|
+
utils$2.isString(domain) && cookie.push('domain=' + domain);
|
|
2337
2338
|
|
|
2338
2339
|
secure === true && cookie.push('secure');
|
|
2339
2340
|
|
|
@@ -2406,7 +2407,7 @@ function buildFullPath(baseURL, requestedURL) {
|
|
|
2406
2407
|
return requestedURL;
|
|
2407
2408
|
}
|
|
2408
2409
|
|
|
2409
|
-
const headersToObject = (thing) => thing instanceof AxiosHeaders
|
|
2410
|
+
const headersToObject = (thing) => thing instanceof AxiosHeaders ? { ...thing } : thing;
|
|
2410
2411
|
|
|
2411
2412
|
/**
|
|
2412
2413
|
* Config-specific merge-function which creates a new config-object
|
|
@@ -2423,11 +2424,11 @@ function mergeConfig(config1, config2) {
|
|
|
2423
2424
|
const config = {};
|
|
2424
2425
|
|
|
2425
2426
|
function getMergedValue(target, source, caseless) {
|
|
2426
|
-
if (utils$
|
|
2427
|
-
return utils$
|
|
2428
|
-
} else if (utils$
|
|
2429
|
-
return utils$
|
|
2430
|
-
} else if (utils$
|
|
2427
|
+
if (utils$2.isPlainObject(target) && utils$2.isPlainObject(source)) {
|
|
2428
|
+
return utils$2.merge.call({caseless}, target, source);
|
|
2429
|
+
} else if (utils$2.isPlainObject(source)) {
|
|
2430
|
+
return utils$2.merge({}, source);
|
|
2431
|
+
} else if (utils$2.isArray(source)) {
|
|
2431
2432
|
return source.slice();
|
|
2432
2433
|
}
|
|
2433
2434
|
return source;
|
|
@@ -2435,25 +2436,25 @@ function mergeConfig(config1, config2) {
|
|
|
2435
2436
|
|
|
2436
2437
|
// eslint-disable-next-line consistent-return
|
|
2437
2438
|
function mergeDeepProperties(a, b, caseless) {
|
|
2438
|
-
if (!utils$
|
|
2439
|
+
if (!utils$2.isUndefined(b)) {
|
|
2439
2440
|
return getMergedValue(a, b, caseless);
|
|
2440
|
-
} else if (!utils$
|
|
2441
|
+
} else if (!utils$2.isUndefined(a)) {
|
|
2441
2442
|
return getMergedValue(undefined, a, caseless);
|
|
2442
2443
|
}
|
|
2443
2444
|
}
|
|
2444
2445
|
|
|
2445
2446
|
// eslint-disable-next-line consistent-return
|
|
2446
2447
|
function valueFromConfig2(a, b) {
|
|
2447
|
-
if (!utils$
|
|
2448
|
+
if (!utils$2.isUndefined(b)) {
|
|
2448
2449
|
return getMergedValue(undefined, b);
|
|
2449
2450
|
}
|
|
2450
2451
|
}
|
|
2451
2452
|
|
|
2452
2453
|
// eslint-disable-next-line consistent-return
|
|
2453
2454
|
function defaultToConfig2(a, b) {
|
|
2454
|
-
if (!utils$
|
|
2455
|
+
if (!utils$2.isUndefined(b)) {
|
|
2455
2456
|
return getMergedValue(undefined, b);
|
|
2456
|
-
} else if (!utils$
|
|
2457
|
+
} else if (!utils$2.isUndefined(a)) {
|
|
2457
2458
|
return getMergedValue(undefined, a);
|
|
2458
2459
|
}
|
|
2459
2460
|
}
|
|
@@ -2499,10 +2500,10 @@ function mergeConfig(config1, config2) {
|
|
|
2499
2500
|
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
|
2500
2501
|
};
|
|
2501
2502
|
|
|
2502
|
-
utils$
|
|
2503
|
+
utils$2.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
|
2503
2504
|
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
2504
2505
|
const configValue = merge(config1[prop], config2[prop], prop);
|
|
2505
|
-
(utils$
|
|
2506
|
+
(utils$2.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
2506
2507
|
});
|
|
2507
2508
|
|
|
2508
2509
|
return config;
|
|
@@ -2513,7 +2514,7 @@ var resolveConfig = (config) => {
|
|
|
2513
2514
|
|
|
2514
2515
|
let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
|
|
2515
2516
|
|
|
2516
|
-
newConfig.headers = headers = AxiosHeaders
|
|
2517
|
+
newConfig.headers = headers = AxiosHeaders.from(headers);
|
|
2517
2518
|
|
|
2518
2519
|
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
|
|
2519
2520
|
|
|
@@ -2526,7 +2527,7 @@ var resolveConfig = (config) => {
|
|
|
2526
2527
|
|
|
2527
2528
|
let contentType;
|
|
2528
2529
|
|
|
2529
|
-
if (utils$
|
|
2530
|
+
if (utils$2.isFormData(data)) {
|
|
2530
2531
|
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|
2531
2532
|
headers.setContentType(undefined); // Let the browser set it
|
|
2532
2533
|
} else if ((contentType = headers.getContentType()) !== false) {
|
|
@@ -2541,7 +2542,7 @@ var resolveConfig = (config) => {
|
|
|
2541
2542
|
// Specifically not if we're in a web worker, or react-native.
|
|
2542
2543
|
|
|
2543
2544
|
if (platform.hasStandardBrowserEnv) {
|
|
2544
|
-
withXSRFToken && utils$
|
|
2545
|
+
withXSRFToken && utils$2.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
|
|
2545
2546
|
|
|
2546
2547
|
if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
|
|
2547
2548
|
// Add xsrf header
|
|
@@ -2562,7 +2563,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
2562
2563
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
2563
2564
|
const _config = resolveConfig(config);
|
|
2564
2565
|
let requestData = _config.data;
|
|
2565
|
-
const requestHeaders = AxiosHeaders
|
|
2566
|
+
const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
|
|
2566
2567
|
let {responseType, onUploadProgress, onDownloadProgress} = _config;
|
|
2567
2568
|
let onCanceled;
|
|
2568
2569
|
let uploadThrottled, downloadThrottled;
|
|
@@ -2589,7 +2590,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
2589
2590
|
return;
|
|
2590
2591
|
}
|
|
2591
2592
|
// Prepare the response
|
|
2592
|
-
const responseHeaders = AxiosHeaders
|
|
2593
|
+
const responseHeaders = AxiosHeaders.from(
|
|
2593
2594
|
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
|
2594
2595
|
);
|
|
2595
2596
|
const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
|
@@ -2682,13 +2683,13 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
2682
2683
|
|
|
2683
2684
|
// Add headers to the request
|
|
2684
2685
|
if ('setRequestHeader' in request) {
|
|
2685
|
-
utils$
|
|
2686
|
+
utils$2.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
|
2686
2687
|
request.setRequestHeader(key, val);
|
|
2687
2688
|
});
|
|
2688
2689
|
}
|
|
2689
2690
|
|
|
2690
2691
|
// Add withCredentials to request if needed
|
|
2691
|
-
if (!utils$
|
|
2692
|
+
if (!utils$2.isUndefined(_config.withCredentials)) {
|
|
2692
2693
|
request.withCredentials = !!_config.withCredentials;
|
|
2693
2694
|
}
|
|
2694
2695
|
|
|
@@ -2785,12 +2786,10 @@ const composeSignals = (signals, timeout) => {
|
|
|
2785
2786
|
}];
|
|
2786
2787
|
};
|
|
2787
2788
|
|
|
2788
|
-
var composeSignals$1 = composeSignals;
|
|
2789
|
-
|
|
2790
2789
|
const streamChunk = function* (chunk, chunkSize) {
|
|
2791
2790
|
let len = chunk.byteLength;
|
|
2792
2791
|
|
|
2793
|
-
if (
|
|
2792
|
+
if (len < chunkSize) {
|
|
2794
2793
|
yield chunk;
|
|
2795
2794
|
return;
|
|
2796
2795
|
}
|
|
@@ -2889,7 +2888,7 @@ const supportsRequestStream = isReadableStreamSupported && test(() => {
|
|
|
2889
2888
|
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
2890
2889
|
|
|
2891
2890
|
const supportsResponseStream = isReadableStreamSupported &&
|
|
2892
|
-
test(() => utils$
|
|
2891
|
+
test(() => utils$2.isReadableStream(new Response('').body));
|
|
2893
2892
|
|
|
2894
2893
|
|
|
2895
2894
|
const resolvers = {
|
|
@@ -2898,7 +2897,7 @@ const resolvers = {
|
|
|
2898
2897
|
|
|
2899
2898
|
isFetchSupported && (((res) => {
|
|
2900
2899
|
['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
|
|
2901
|
-
!resolvers[type] && (resolvers[type] = utils$
|
|
2900
|
+
!resolvers[type] && (resolvers[type] = utils$2.isFunction(res[type]) ? (res) => res[type]() :
|
|
2902
2901
|
(_, config) => {
|
|
2903
2902
|
throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
|
|
2904
2903
|
});
|
|
@@ -2910,29 +2909,29 @@ const getBodyLength = async (body) => {
|
|
|
2910
2909
|
return 0;
|
|
2911
2910
|
}
|
|
2912
2911
|
|
|
2913
|
-
if(utils$
|
|
2912
|
+
if(utils$2.isBlob(body)) {
|
|
2914
2913
|
return body.size;
|
|
2915
2914
|
}
|
|
2916
2915
|
|
|
2917
|
-
if(utils$
|
|
2916
|
+
if(utils$2.isSpecCompliantForm(body)) {
|
|
2918
2917
|
return (await new Request(body).arrayBuffer()).byteLength;
|
|
2919
2918
|
}
|
|
2920
2919
|
|
|
2921
|
-
if(utils$
|
|
2920
|
+
if(utils$2.isArrayBufferView(body) || utils$2.isArrayBuffer(body)) {
|
|
2922
2921
|
return body.byteLength;
|
|
2923
2922
|
}
|
|
2924
2923
|
|
|
2925
|
-
if(utils$
|
|
2924
|
+
if(utils$2.isURLSearchParams(body)) {
|
|
2926
2925
|
body = body + '';
|
|
2927
2926
|
}
|
|
2928
2927
|
|
|
2929
|
-
if(utils$
|
|
2928
|
+
if(utils$2.isString(body)) {
|
|
2930
2929
|
return (await encodeText(body)).byteLength;
|
|
2931
2930
|
}
|
|
2932
2931
|
};
|
|
2933
2932
|
|
|
2934
2933
|
const resolveBodyLength = async (headers, body) => {
|
|
2935
|
-
const length = utils$
|
|
2934
|
+
const length = utils$2.toFiniteNumber(headers.getContentLength());
|
|
2936
2935
|
|
|
2937
2936
|
return length == null ? getBodyLength(body) : length;
|
|
2938
2937
|
};
|
|
@@ -2956,7 +2955,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
2956
2955
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
|
2957
2956
|
|
|
2958
2957
|
let [composedSignal, stopTimeout] = (signal || cancelToken || timeout) ?
|
|
2959
|
-
composeSignals
|
|
2958
|
+
composeSignals([signal, cancelToken], timeout) : [];
|
|
2960
2959
|
|
|
2961
2960
|
let finished, request;
|
|
2962
2961
|
|
|
@@ -2983,7 +2982,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
2983
2982
|
|
|
2984
2983
|
let contentTypeHeader;
|
|
2985
2984
|
|
|
2986
|
-
if (utils$
|
|
2985
|
+
if (utils$2.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
|
|
2987
2986
|
headers.setContentType(contentTypeHeader);
|
|
2988
2987
|
}
|
|
2989
2988
|
|
|
@@ -2997,7 +2996,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
2997
2996
|
}
|
|
2998
2997
|
}
|
|
2999
2998
|
|
|
3000
|
-
if (!utils$
|
|
2999
|
+
if (!utils$2.isString(withCredentials)) {
|
|
3001
3000
|
withCredentials = withCredentials ? 'include' : 'omit';
|
|
3002
3001
|
}
|
|
3003
3002
|
|
|
@@ -3022,7 +3021,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
3022
3021
|
options[prop] = response[prop];
|
|
3023
3022
|
});
|
|
3024
3023
|
|
|
3025
|
-
const responseContentLength = utils$
|
|
3024
|
+
const responseContentLength = utils$2.toFiniteNumber(response.headers.get('content-length'));
|
|
3026
3025
|
|
|
3027
3026
|
const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
|
|
3028
3027
|
responseContentLength,
|
|
@@ -3040,7 +3039,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
3040
3039
|
|
|
3041
3040
|
responseType = responseType || 'text';
|
|
3042
3041
|
|
|
3043
|
-
let responseData = await resolvers[utils$
|
|
3042
|
+
let responseData = await resolvers[utils$2.findKey(resolvers, responseType) || 'text'](response, config);
|
|
3044
3043
|
|
|
3045
3044
|
!isStreamResponse && onFinish();
|
|
3046
3045
|
|
|
@@ -3049,7 +3048,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
|
|
|
3049
3048
|
return await new Promise((resolve, reject) => {
|
|
3050
3049
|
settle(resolve, reject, {
|
|
3051
3050
|
data: responseData,
|
|
3052
|
-
headers: AxiosHeaders
|
|
3051
|
+
headers: AxiosHeaders.from(response.headers),
|
|
3053
3052
|
status: response.status,
|
|
3054
3053
|
statusText: response.statusText,
|
|
3055
3054
|
config,
|
|
@@ -3078,7 +3077,7 @@ const knownAdapters = {
|
|
|
3078
3077
|
fetch: fetchAdapter
|
|
3079
3078
|
};
|
|
3080
3079
|
|
|
3081
|
-
utils$
|
|
3080
|
+
utils$2.forEach(knownAdapters, (fn, value) => {
|
|
3082
3081
|
if (fn) {
|
|
3083
3082
|
try {
|
|
3084
3083
|
Object.defineProperty(fn, 'name', {value});
|
|
@@ -3091,11 +3090,11 @@ utils$3.forEach(knownAdapters, (fn, value) => {
|
|
|
3091
3090
|
|
|
3092
3091
|
const renderReason = (reason) => `- ${reason}`;
|
|
3093
3092
|
|
|
3094
|
-
const isResolvedHandle = (adapter) => utils$
|
|
3093
|
+
const isResolvedHandle = (adapter) => utils$2.isFunction(adapter) || adapter === null || adapter === false;
|
|
3095
3094
|
|
|
3096
3095
|
var adapters = {
|
|
3097
3096
|
getAdapter: (adapters) => {
|
|
3098
|
-
adapters = utils$
|
|
3097
|
+
adapters = utils$2.isArray(adapters) ? adapters : [adapters];
|
|
3099
3098
|
|
|
3100
3099
|
const {length} = adapters;
|
|
3101
3100
|
let nameOrAdapter;
|
|
@@ -3173,7 +3172,7 @@ function throwIfCancellationRequested(config) {
|
|
|
3173
3172
|
function dispatchRequest(config) {
|
|
3174
3173
|
throwIfCancellationRequested(config);
|
|
3175
3174
|
|
|
3176
|
-
config.headers = AxiosHeaders
|
|
3175
|
+
config.headers = AxiosHeaders.from(config.headers);
|
|
3177
3176
|
|
|
3178
3177
|
// Transform request data
|
|
3179
3178
|
config.data = transformData.call(
|
|
@@ -3185,7 +3184,7 @@ function dispatchRequest(config) {
|
|
|
3185
3184
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
|
3186
3185
|
}
|
|
3187
3186
|
|
|
3188
|
-
const adapter = adapters.getAdapter(config.adapter || defaults
|
|
3187
|
+
const adapter = adapters.getAdapter(config.adapter || defaults.adapter);
|
|
3189
3188
|
|
|
3190
3189
|
return adapter(config).then(function onAdapterResolution(response) {
|
|
3191
3190
|
throwIfCancellationRequested(config);
|
|
@@ -3197,7 +3196,7 @@ function dispatchRequest(config) {
|
|
|
3197
3196
|
response
|
|
3198
3197
|
);
|
|
3199
3198
|
|
|
3200
|
-
response.headers = AxiosHeaders
|
|
3199
|
+
response.headers = AxiosHeaders.from(response.headers);
|
|
3201
3200
|
|
|
3202
3201
|
return response;
|
|
3203
3202
|
}, function onAdapterRejection(reason) {
|
|
@@ -3211,7 +3210,7 @@ function dispatchRequest(config) {
|
|
|
3211
3210
|
config.transformResponse,
|
|
3212
3211
|
reason.response
|
|
3213
3212
|
);
|
|
3214
|
-
reason.response.headers = AxiosHeaders
|
|
3213
|
+
reason.response.headers = AxiosHeaders.from(reason.response.headers);
|
|
3215
3214
|
}
|
|
3216
3215
|
}
|
|
3217
3216
|
|
|
@@ -3321,8 +3320,8 @@ class Axios {
|
|
|
3321
3320
|
constructor(instanceConfig) {
|
|
3322
3321
|
this.defaults = instanceConfig;
|
|
3323
3322
|
this.interceptors = {
|
|
3324
|
-
request: new InterceptorManager
|
|
3325
|
-
response: new InterceptorManager
|
|
3323
|
+
request: new InterceptorManager(),
|
|
3324
|
+
response: new InterceptorManager()
|
|
3326
3325
|
};
|
|
3327
3326
|
}
|
|
3328
3327
|
|
|
@@ -3384,7 +3383,7 @@ class Axios {
|
|
|
3384
3383
|
}
|
|
3385
3384
|
|
|
3386
3385
|
if (paramsSerializer != null) {
|
|
3387
|
-
if (utils$
|
|
3386
|
+
if (utils$2.isFunction(paramsSerializer)) {
|
|
3388
3387
|
config.paramsSerializer = {
|
|
3389
3388
|
serialize: paramsSerializer
|
|
3390
3389
|
};
|
|
@@ -3400,19 +3399,19 @@ class Axios {
|
|
|
3400
3399
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
|
3401
3400
|
|
|
3402
3401
|
// Flatten headers
|
|
3403
|
-
let contextHeaders = headers && utils$
|
|
3402
|
+
let contextHeaders = headers && utils$2.merge(
|
|
3404
3403
|
headers.common,
|
|
3405
3404
|
headers[config.method]
|
|
3406
3405
|
);
|
|
3407
3406
|
|
|
3408
|
-
headers && utils$
|
|
3407
|
+
headers && utils$2.forEach(
|
|
3409
3408
|
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
|
3410
3409
|
(method) => {
|
|
3411
3410
|
delete headers[method];
|
|
3412
3411
|
}
|
|
3413
3412
|
);
|
|
3414
3413
|
|
|
3415
|
-
config.headers = AxiosHeaders
|
|
3414
|
+
config.headers = AxiosHeaders.concat(contextHeaders, headers);
|
|
3416
3415
|
|
|
3417
3416
|
// filter out skipped interceptors
|
|
3418
3417
|
const requestInterceptorChain = [];
|
|
@@ -3492,7 +3491,7 @@ class Axios {
|
|
|
3492
3491
|
}
|
|
3493
3492
|
|
|
3494
3493
|
// Provide aliases for supported request methods
|
|
3495
|
-
utils$
|
|
3494
|
+
utils$2.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
|
3496
3495
|
/*eslint func-names:0*/
|
|
3497
3496
|
Axios.prototype[method] = function(url, config) {
|
|
3498
3497
|
return this.request(mergeConfig(config || {}, {
|
|
@@ -3503,7 +3502,7 @@ utils$3.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoDa
|
|
|
3503
3502
|
};
|
|
3504
3503
|
});
|
|
3505
3504
|
|
|
3506
|
-
utils$
|
|
3505
|
+
utils$2.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
3507
3506
|
/*eslint func-names:0*/
|
|
3508
3507
|
|
|
3509
3508
|
function generateHTTPMethod(isForm) {
|
|
@@ -3524,8 +3523,6 @@ utils$3.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method)
|
|
|
3524
3523
|
Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
|
|
3525
3524
|
});
|
|
3526
3525
|
|
|
3527
|
-
var Axios$1 = Axios;
|
|
3528
|
-
|
|
3529
3526
|
/**
|
|
3530
3527
|
* A `CancelToken` is an object that can be used to request cancellation of an operation.
|
|
3531
3528
|
*
|
|
@@ -3642,8 +3639,6 @@ class CancelToken {
|
|
|
3642
3639
|
}
|
|
3643
3640
|
}
|
|
3644
3641
|
|
|
3645
|
-
var CancelToken$1 = CancelToken;
|
|
3646
|
-
|
|
3647
3642
|
/**
|
|
3648
3643
|
* Syntactic sugar for invoking a function and expanding an array for arguments.
|
|
3649
3644
|
*
|
|
@@ -3679,7 +3674,7 @@ function spread(callback) {
|
|
|
3679
3674
|
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
|
3680
3675
|
*/
|
|
3681
3676
|
function isAxiosError(payload) {
|
|
3682
|
-
return utils$
|
|
3677
|
+
return utils$2.isObject(payload) && (payload.isAxiosError === true);
|
|
3683
3678
|
}
|
|
3684
3679
|
|
|
3685
3680
|
const HttpStatusCode = {
|
|
@@ -3752,8 +3747,6 @@ Object.entries(HttpStatusCode).forEach(([key, value]) => {
|
|
|
3752
3747
|
HttpStatusCode[value] = key;
|
|
3753
3748
|
});
|
|
3754
3749
|
|
|
3755
|
-
var HttpStatusCode$1 = HttpStatusCode;
|
|
3756
|
-
|
|
3757
3750
|
/**
|
|
3758
3751
|
* Create an instance of Axios
|
|
3759
3752
|
*
|
|
@@ -3762,14 +3755,14 @@ var HttpStatusCode$1 = HttpStatusCode;
|
|
|
3762
3755
|
* @returns {Axios} A new instance of Axios
|
|
3763
3756
|
*/
|
|
3764
3757
|
function createInstance(defaultConfig) {
|
|
3765
|
-
const context = new Axios
|
|
3766
|
-
const instance = bind(Axios
|
|
3758
|
+
const context = new Axios(defaultConfig);
|
|
3759
|
+
const instance = bind(Axios.prototype.request, context);
|
|
3767
3760
|
|
|
3768
3761
|
// Copy axios.prototype to instance
|
|
3769
|
-
utils$
|
|
3762
|
+
utils$2.extend(instance, Axios.prototype, context, {allOwnKeys: true});
|
|
3770
3763
|
|
|
3771
3764
|
// Copy context to instance
|
|
3772
|
-
utils$
|
|
3765
|
+
utils$2.extend(instance, context, null, {allOwnKeys: true});
|
|
3773
3766
|
|
|
3774
3767
|
// Factory for creating new instances
|
|
3775
3768
|
instance.create = function create(instanceConfig) {
|
|
@@ -3780,14 +3773,14 @@ function createInstance(defaultConfig) {
|
|
|
3780
3773
|
}
|
|
3781
3774
|
|
|
3782
3775
|
// Create the default instance to be exported
|
|
3783
|
-
const axios = createInstance(defaults
|
|
3776
|
+
const axios = createInstance(defaults);
|
|
3784
3777
|
|
|
3785
3778
|
// Expose Axios class to allow class inheritance
|
|
3786
|
-
axios.Axios = Axios
|
|
3779
|
+
axios.Axios = Axios;
|
|
3787
3780
|
|
|
3788
3781
|
// Expose Cancel & CancelToken
|
|
3789
3782
|
axios.CanceledError = CanceledError;
|
|
3790
|
-
axios.CancelToken = CancelToken
|
|
3783
|
+
axios.CancelToken = CancelToken;
|
|
3791
3784
|
axios.isCancel = isCancel;
|
|
3792
3785
|
axios.VERSION = VERSION;
|
|
3793
3786
|
axios.toFormData = toFormData;
|
|
@@ -3811,19 +3804,16 @@ axios.isAxiosError = isAxiosError;
|
|
|
3811
3804
|
// Expose mergeConfig
|
|
3812
3805
|
axios.mergeConfig = mergeConfig;
|
|
3813
3806
|
|
|
3814
|
-
axios.AxiosHeaders = AxiosHeaders
|
|
3807
|
+
axios.AxiosHeaders = AxiosHeaders;
|
|
3815
3808
|
|
|
3816
|
-
axios.formToJSON = thing => formDataToJSON(utils$
|
|
3809
|
+
axios.formToJSON = thing => formDataToJSON(utils$2.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
3817
3810
|
|
|
3818
3811
|
axios.getAdapter = adapters.getAdapter;
|
|
3819
3812
|
|
|
3820
|
-
axios.HttpStatusCode = HttpStatusCode
|
|
3813
|
+
axios.HttpStatusCode = HttpStatusCode;
|
|
3821
3814
|
|
|
3822
3815
|
axios.default = axios;
|
|
3823
3816
|
|
|
3824
|
-
// this module should only have a default export
|
|
3825
|
-
var axios$1 = axios;
|
|
3826
|
-
|
|
3827
3817
|
/**
|
|
3828
3818
|
* Function to generate the URL for the given network.
|
|
3829
3819
|
*
|
|
@@ -3846,7 +3836,7 @@ const urlForNetwork = (network) => {
|
|
|
3846
3836
|
* @returns {Promise<InsightAddressResponse>} Address details fetched from the Insight API.
|
|
3847
3837
|
*/
|
|
3848
3838
|
const getAddress = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
3849
|
-
const data = (yield axios
|
|
3839
|
+
const data = (yield axios.get(`${urlForNetwork(p.network)}/addr/${p.address}`)).data;
|
|
3850
3840
|
return data;
|
|
3851
3841
|
});
|
|
3852
3842
|
/**
|
|
@@ -3857,7 +3847,7 @@ const getAddress = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
3857
3847
|
*/
|
|
3858
3848
|
const getAddressTxs = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
3859
3849
|
const pageNum = (p === null || p === void 0 ? void 0 : p.pageNum) || 0;
|
|
3860
|
-
return (yield axios
|
|
3850
|
+
return (yield axios.get(`${urlForNetwork(p.network)}/txs?address=${p.address}&pageNum=${pageNum}`)).data;
|
|
3861
3851
|
});
|
|
3862
3852
|
/**
|
|
3863
3853
|
* Fetch UTXOs associated with an address from the Insight API.
|
|
@@ -3866,7 +3856,7 @@ const getAddressTxs = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
3866
3856
|
* @returns {Promise<InsightUtxoResponse[]>} UTXOs associated with the address.
|
|
3867
3857
|
*/
|
|
3868
3858
|
const getAddressUtxos = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
3869
|
-
return (yield axios
|
|
3859
|
+
return (yield axios.get(`${urlForNetwork(p.network)}/addr/${p.address}/utxo`)).data;
|
|
3870
3860
|
});
|
|
3871
3861
|
/**
|
|
3872
3862
|
* Fetch transaction details from the Insight API.
|
|
@@ -3875,7 +3865,7 @@ const getAddressUtxos = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
3875
3865
|
* @returns {Promise<InsightTxResponse>} Transaction details fetched from the Insight API.
|
|
3876
3866
|
*/
|
|
3877
3867
|
const getTx = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
3878
|
-
return (yield axios
|
|
3868
|
+
return (yield axios.get(`${urlForNetwork(p.network)}/tx/${p.txid}`)).data;
|
|
3879
3869
|
});
|
|
3880
3870
|
/**
|
|
3881
3871
|
* Fetch raw transaction data from the Insight API.
|
|
@@ -3884,128 +3874,145 @@ const getTx = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
3884
3874
|
* @returns {Promise<InsightRawTx>} Raw transaction data fetched from the Insight API.
|
|
3885
3875
|
*/
|
|
3886
3876
|
const getRawTx = (p) => __awaiter(void 0, void 0, void 0, function* () {
|
|
3887
|
-
return (yield axios
|
|
3877
|
+
return (yield axios.get(`${urlForNetwork(p.network)}/rawtx/${p.txid}`)).data.rawtx;
|
|
3888
3878
|
});
|
|
3889
3879
|
|
|
3890
3880
|
function getDefaultExportFromCjs (x) {
|
|
3891
3881
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
3892
3882
|
}
|
|
3893
3883
|
|
|
3894
|
-
|
|
3895
|
-
var
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3884
|
+
var utils;
|
|
3885
|
+
var hasRequiredUtils;
|
|
3886
|
+
|
|
3887
|
+
function requireUtils () {
|
|
3888
|
+
if (hasRequiredUtils) return utils;
|
|
3889
|
+
hasRequiredUtils = 1;
|
|
3890
|
+
// baseline estimates, used to improve performance
|
|
3891
|
+
var TX_EMPTY_SIZE = 4 + 1 + 1 + 4;
|
|
3892
|
+
var TX_INPUT_BASE = 32 + 4 + 1 + 4;
|
|
3893
|
+
var TX_INPUT_PUBKEYHASH = 107;
|
|
3894
|
+
var TX_OUTPUT_BASE = 8 + 1;
|
|
3895
|
+
var TX_OUTPUT_PUBKEYHASH = 25;
|
|
3896
|
+
|
|
3897
|
+
function inputBytes (input) {
|
|
3898
|
+
return TX_INPUT_BASE + (input.script ? input.script.length : TX_INPUT_PUBKEYHASH)
|
|
3899
|
+
}
|
|
3900
|
+
|
|
3901
|
+
function outputBytes (output) {
|
|
3902
|
+
return TX_OUTPUT_BASE + (output.script ? output.script.length : TX_OUTPUT_PUBKEYHASH)
|
|
3903
|
+
}
|
|
3904
|
+
|
|
3905
|
+
function dustThreshold (output, feeRate) {
|
|
3906
|
+
/* ... classify the output for input estimate */
|
|
3907
|
+
return inputBytes({}) * feeRate
|
|
3908
|
+
}
|
|
3909
|
+
|
|
3910
|
+
function transactionBytes (inputs, outputs) {
|
|
3911
|
+
return TX_EMPTY_SIZE +
|
|
3912
|
+
inputs.reduce(function (a, x) { return a + inputBytes(x) }, 0) +
|
|
3913
|
+
outputs.reduce(function (a, x) { return a + outputBytes(x) }, 0)
|
|
3914
|
+
}
|
|
3915
|
+
|
|
3916
|
+
function uintOrNaN (v) {
|
|
3917
|
+
if (typeof v !== 'number') return NaN
|
|
3918
|
+
if (!isFinite(v)) return NaN
|
|
3919
|
+
if (Math.floor(v) !== v) return NaN
|
|
3920
|
+
if (v < 0) return NaN
|
|
3921
|
+
return v
|
|
3922
|
+
}
|
|
3923
|
+
|
|
3924
|
+
function sumForgiving (range) {
|
|
3925
|
+
return range.reduce(function (a, x) { return a + (isFinite(x.value) ? x.value : 0) }, 0)
|
|
3926
|
+
}
|
|
3927
|
+
|
|
3928
|
+
function sumOrNaN (range) {
|
|
3929
|
+
return range.reduce(function (a, x) { return a + uintOrNaN(x.value) }, 0)
|
|
3930
|
+
}
|
|
3931
|
+
|
|
3932
|
+
var BLANK_OUTPUT = outputBytes({});
|
|
3933
|
+
|
|
3934
|
+
function finalize (inputs, outputs, feeRate) {
|
|
3935
|
+
var bytesAccum = transactionBytes(inputs, outputs);
|
|
3936
|
+
var feeAfterExtraOutput = feeRate * (bytesAccum + BLANK_OUTPUT);
|
|
3937
|
+
var remainderAfterExtraOutput = sumOrNaN(inputs) - (sumOrNaN(outputs) + feeAfterExtraOutput);
|
|
3938
|
+
|
|
3939
|
+
// is it worth a change output?
|
|
3940
|
+
if (remainderAfterExtraOutput > dustThreshold({}, feeRate)) {
|
|
3941
|
+
outputs = outputs.concat({ value: remainderAfterExtraOutput });
|
|
3942
|
+
}
|
|
3943
|
+
|
|
3944
|
+
var fee = sumOrNaN(inputs) - sumOrNaN(outputs);
|
|
3945
|
+
if (!isFinite(fee)) return { fee: feeRate * bytesAccum }
|
|
3946
|
+
|
|
3947
|
+
return {
|
|
3948
|
+
inputs: inputs,
|
|
3949
|
+
outputs: outputs,
|
|
3950
|
+
fee: fee
|
|
3951
|
+
}
|
|
3952
|
+
}
|
|
3953
|
+
|
|
3954
|
+
utils = {
|
|
3955
|
+
dustThreshold: dustThreshold,
|
|
3956
|
+
finalize: finalize,
|
|
3957
|
+
inputBytes: inputBytes,
|
|
3958
|
+
outputBytes: outputBytes,
|
|
3959
|
+
sumOrNaN: sumOrNaN,
|
|
3960
|
+
sumForgiving: sumForgiving,
|
|
3961
|
+
transactionBytes: transactionBytes,
|
|
3962
|
+
uintOrNaN: uintOrNaN
|
|
3963
|
+
};
|
|
3964
|
+
return utils;
|
|
3903
3965
|
}
|
|
3904
3966
|
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
}
|
|
3967
|
+
var accumulative$1;
|
|
3968
|
+
var hasRequiredAccumulative;
|
|
3908
3969
|
|
|
3909
|
-
function
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3970
|
+
function requireAccumulative () {
|
|
3971
|
+
if (hasRequiredAccumulative) return accumulative$1;
|
|
3972
|
+
hasRequiredAccumulative = 1;
|
|
3973
|
+
var utils = requireUtils();
|
|
3913
3974
|
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3975
|
+
// add inputs until we reach or surpass the target value (or deplete)
|
|
3976
|
+
// worst-case: O(n)
|
|
3977
|
+
accumulative$1 = function accumulative (utxos, outputs, feeRate) {
|
|
3978
|
+
if (!isFinite(utils.uintOrNaN(feeRate))) return {}
|
|
3979
|
+
var bytesAccum = utils.transactionBytes([], outputs);
|
|
3919
3980
|
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
if (Math.floor(v) !== v) return NaN
|
|
3924
|
-
if (v < 0) return NaN
|
|
3925
|
-
return v
|
|
3926
|
-
}
|
|
3981
|
+
var inAccum = 0;
|
|
3982
|
+
var inputs = [];
|
|
3983
|
+
var outAccum = utils.sumOrNaN(outputs);
|
|
3927
3984
|
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3985
|
+
for (var i = 0; i < utxos.length; ++i) {
|
|
3986
|
+
var utxo = utxos[i];
|
|
3987
|
+
var utxoBytes = utils.inputBytes(utxo);
|
|
3988
|
+
var utxoFee = feeRate * utxoBytes;
|
|
3989
|
+
var utxoValue = utils.uintOrNaN(utxo.value);
|
|
3931
3990
|
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
}
|
|
3991
|
+
// skip detrimental input
|
|
3992
|
+
if (utxoFee > utxo.value) {
|
|
3993
|
+
if (i === utxos.length - 1) return { fee: feeRate * (bytesAccum + utxoBytes) }
|
|
3994
|
+
continue
|
|
3995
|
+
}
|
|
3935
3996
|
|
|
3936
|
-
|
|
3997
|
+
bytesAccum += utxoBytes;
|
|
3998
|
+
inAccum += utxoValue;
|
|
3999
|
+
inputs.push(utxo);
|
|
3937
4000
|
|
|
3938
|
-
|
|
3939
|
-
var bytesAccum = transactionBytes(inputs, outputs);
|
|
3940
|
-
var feeAfterExtraOutput = feeRate * (bytesAccum + BLANK_OUTPUT);
|
|
3941
|
-
var remainderAfterExtraOutput = sumOrNaN(inputs) - (sumOrNaN(outputs) + feeAfterExtraOutput);
|
|
4001
|
+
var fee = feeRate * bytesAccum;
|
|
3942
4002
|
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
outputs = outputs.concat({ value: remainderAfterExtraOutput });
|
|
3946
|
-
}
|
|
4003
|
+
// go again?
|
|
4004
|
+
if (inAccum < outAccum + fee) continue
|
|
3947
4005
|
|
|
3948
|
-
|
|
3949
|
-
|
|
4006
|
+
return utils.finalize(inputs, outputs, feeRate)
|
|
4007
|
+
}
|
|
3950
4008
|
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
fee: fee
|
|
3955
|
-
}
|
|
4009
|
+
return { fee: feeRate * bytesAccum }
|
|
4010
|
+
};
|
|
4011
|
+
return accumulative$1;
|
|
3956
4012
|
}
|
|
3957
4013
|
|
|
3958
|
-
var
|
|
3959
|
-
|
|
3960
|
-
finalize: finalize,
|
|
3961
|
-
inputBytes: inputBytes,
|
|
3962
|
-
outputBytes: outputBytes,
|
|
3963
|
-
sumOrNaN: sumOrNaN,
|
|
3964
|
-
sumForgiving: sumForgiving,
|
|
3965
|
-
transactionBytes: transactionBytes,
|
|
3966
|
-
uintOrNaN: uintOrNaN
|
|
3967
|
-
};
|
|
3968
|
-
|
|
3969
|
-
var utils = utils$1;
|
|
3970
|
-
|
|
3971
|
-
// add inputs until we reach or surpass the target value (or deplete)
|
|
3972
|
-
// worst-case: O(n)
|
|
3973
|
-
var accumulative = function accumulative (utxos, outputs, feeRate) {
|
|
3974
|
-
if (!isFinite(utils.uintOrNaN(feeRate))) return {}
|
|
3975
|
-
var bytesAccum = utils.transactionBytes([], outputs);
|
|
3976
|
-
|
|
3977
|
-
var inAccum = 0;
|
|
3978
|
-
var inputs = [];
|
|
3979
|
-
var outAccum = utils.sumOrNaN(outputs);
|
|
3980
|
-
|
|
3981
|
-
for (var i = 0; i < utxos.length; ++i) {
|
|
3982
|
-
var utxo = utxos[i];
|
|
3983
|
-
var utxoBytes = utils.inputBytes(utxo);
|
|
3984
|
-
var utxoFee = feeRate * utxoBytes;
|
|
3985
|
-
var utxoValue = utils.uintOrNaN(utxo.value);
|
|
3986
|
-
|
|
3987
|
-
// skip detrimental input
|
|
3988
|
-
if (utxoFee > utxo.value) {
|
|
3989
|
-
if (i === utxos.length - 1) return { fee: feeRate * (bytesAccum + utxoBytes) }
|
|
3990
|
-
continue
|
|
3991
|
-
}
|
|
3992
|
-
|
|
3993
|
-
bytesAccum += utxoBytes;
|
|
3994
|
-
inAccum += utxoValue;
|
|
3995
|
-
inputs.push(utxo);
|
|
3996
|
-
|
|
3997
|
-
var fee = feeRate * bytesAccum;
|
|
3998
|
-
|
|
3999
|
-
// go again?
|
|
4000
|
-
if (inAccum < outAccum + fee) continue
|
|
4001
|
-
|
|
4002
|
-
return utils.finalize(inputs, outputs, feeRate)
|
|
4003
|
-
}
|
|
4004
|
-
|
|
4005
|
-
return { fee: feeRate * bytesAccum }
|
|
4006
|
-
};
|
|
4007
|
-
|
|
4008
|
-
var accumulative$1 = /*@__PURE__*/getDefaultExportFromCjs(accumulative);
|
|
4014
|
+
var accumulativeExports = requireAccumulative();
|
|
4015
|
+
var accumulative = /*@__PURE__*/getDefaultExportFromCjs(accumulativeExports);
|
|
4009
4016
|
|
|
4010
4017
|
/**
|
|
4011
4018
|
* Object containing the sizes (in bytes) of various components in a Dash transaction.
|
|
@@ -4093,7 +4100,7 @@ const buildTx = ({ amount, recipient, memo, feeRate, sender, network, }) => __aw
|
|
|
4093
4100
|
},
|
|
4094
4101
|
];
|
|
4095
4102
|
// Calculate inputs and outputs for the transaction
|
|
4096
|
-
const { inputs, outputs } = accumulative
|
|
4103
|
+
const { inputs, outputs } = accumulative(utxos, targetOutputs, feeRateWhole);
|
|
4097
4104
|
if (!inputs || !outputs)
|
|
4098
4105
|
throw new Error('Insufficient balance for transaction');
|
|
4099
4106
|
// Initialize new Dash transaction
|
|
@@ -4389,7 +4396,7 @@ class Client extends Client$1 {
|
|
|
4389
4396
|
const broadcastTx = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4390
4397
|
const uniqueId = new Date().getTime().toString(); // Generate a unique identifier for the transaction request.
|
|
4391
4398
|
try {
|
|
4392
|
-
const response = (yield axios
|
|
4399
|
+
const response = (yield axios.post(`${params.nodeUrl}/tx/send`, // URL endpoint for broadcasting the transaction.
|
|
4393
4400
|
{
|
|
4394
4401
|
jsonrpc: '2.0',
|
|
4395
4402
|
rawtx: [params.txHex],
|