@imtbl/sdk 0.39.1 → 0.39.2
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/dist/blockchain_data.js +1 -1
- package/dist/browser/checkout/sdk.js +6 -6
- package/dist/browser/checkout/widgets.js +60 -60
- package/dist/checkout.d.ts +30 -14
- package/dist/checkout.js +284 -257
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +12 -12
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +496 -442
- package/dist/index.d.ts +30 -14
- package/dist/index.js +524 -470
- package/dist/passport.js +235 -208
- package/package.json +2 -2
package/dist/checkout.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import globalAxios, { HttpStatusCode as HttpStatusCode$2 } from 'axios';
|
|
2
|
-
import { ethers, ContractFactory, utils as utils$
|
|
2
|
+
import { ethers, ContractFactory, utils as utils$2, Contract as Contract$1, BigNumber as BigNumber$1, providers, constants as constants$1 } from 'ethers';
|
|
3
3
|
import { Web3Provider, JsonRpcProvider } from '@ethersproject/providers';
|
|
4
4
|
import detectEthereumProvider from '@metamask/detect-provider';
|
|
5
5
|
import * as Uniswap from '@uniswap/sdk-core';
|
|
@@ -570,8 +570,9 @@ const reduceDescriptors = (obj, reducer) => {
|
|
|
570
570
|
const reducedDescriptors = {};
|
|
571
571
|
|
|
572
572
|
forEach(descriptors, (descriptor, name) => {
|
|
573
|
-
|
|
574
|
-
|
|
573
|
+
let ret;
|
|
574
|
+
if ((ret = reducer(descriptor, name, obj)) !== false) {
|
|
575
|
+
reducedDescriptors[name] = ret || descriptor;
|
|
575
576
|
}
|
|
576
577
|
});
|
|
577
578
|
|
|
@@ -697,7 +698,7 @@ const isAsyncFn = kindOfTest('AsyncFunction');
|
|
|
697
698
|
const isThenable = (thing) =>
|
|
698
699
|
thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
|
699
700
|
|
|
700
|
-
var utils = {
|
|
701
|
+
var utils$1 = {
|
|
701
702
|
isArray,
|
|
702
703
|
isArrayBuffer,
|
|
703
704
|
isBuffer,
|
|
@@ -779,7 +780,7 @@ function AxiosError(message, code, config, request, response) {
|
|
|
779
780
|
response && (this.response = response);
|
|
780
781
|
}
|
|
781
782
|
|
|
782
|
-
utils.inherits(AxiosError, Error, {
|
|
783
|
+
utils$1.inherits(AxiosError, Error, {
|
|
783
784
|
toJSON: function toJSON() {
|
|
784
785
|
return {
|
|
785
786
|
// Standard
|
|
@@ -794,7 +795,7 @@ utils.inherits(AxiosError, Error, {
|
|
|
794
795
|
columnNumber: this.columnNumber,
|
|
795
796
|
stack: this.stack,
|
|
796
797
|
// Axios
|
|
797
|
-
config: utils.toJSONObject(this.config),
|
|
798
|
+
config: utils$1.toJSONObject(this.config),
|
|
798
799
|
code: this.code,
|
|
799
800
|
status: this.response && this.response.status ? this.response.status : null
|
|
800
801
|
};
|
|
@@ -829,7 +830,7 @@ Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
|
|
|
829
830
|
AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
830
831
|
const axiosError = Object.create(prototype$1);
|
|
831
832
|
|
|
832
|
-
utils.toFlatObject(error, axiosError, function filter(obj) {
|
|
833
|
+
utils$1.toFlatObject(error, axiosError, function filter(obj) {
|
|
833
834
|
return obj !== Error.prototype;
|
|
834
835
|
}, prop => {
|
|
835
836
|
return prop !== 'isAxiosError';
|
|
@@ -857,7 +858,7 @@ var httpAdapter = null;
|
|
|
857
858
|
* @returns {boolean}
|
|
858
859
|
*/
|
|
859
860
|
function isVisitable(thing) {
|
|
860
|
-
return utils.isPlainObject(thing) || utils.isArray(thing);
|
|
861
|
+
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
|
861
862
|
}
|
|
862
863
|
|
|
863
864
|
/**
|
|
@@ -868,7 +869,7 @@ function isVisitable(thing) {
|
|
|
868
869
|
* @returns {string} the key without the brackets.
|
|
869
870
|
*/
|
|
870
871
|
function removeBrackets(key) {
|
|
871
|
-
return utils.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
872
|
+
return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
|
872
873
|
}
|
|
873
874
|
|
|
874
875
|
/**
|
|
@@ -897,10 +898,10 @@ function renderKey(path, key, dots) {
|
|
|
897
898
|
* @returns {boolean}
|
|
898
899
|
*/
|
|
899
900
|
function isFlatArray(arr) {
|
|
900
|
-
return utils.isArray(arr) && !arr.some(isVisitable);
|
|
901
|
+
return utils$1.isArray(arr) && !arr.some(isVisitable);
|
|
901
902
|
}
|
|
902
903
|
|
|
903
|
-
const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
|
|
904
|
+
const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
|
|
904
905
|
return /^is[A-Z]/.test(prop);
|
|
905
906
|
});
|
|
906
907
|
|
|
@@ -928,7 +929,7 @@ const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
|
|
|
928
929
|
* @returns
|
|
929
930
|
*/
|
|
930
931
|
function toFormData(obj, formData, options) {
|
|
931
|
-
if (!utils.isObject(obj)) {
|
|
932
|
+
if (!utils$1.isObject(obj)) {
|
|
932
933
|
throw new TypeError('target must be an object');
|
|
933
934
|
}
|
|
934
935
|
|
|
@@ -936,13 +937,13 @@ function toFormData(obj, formData, options) {
|
|
|
936
937
|
formData = formData || new (FormData)();
|
|
937
938
|
|
|
938
939
|
// eslint-disable-next-line no-param-reassign
|
|
939
|
-
options = utils.toFlatObject(options, {
|
|
940
|
+
options = utils$1.toFlatObject(options, {
|
|
940
941
|
metaTokens: true,
|
|
941
942
|
dots: false,
|
|
942
943
|
indexes: false
|
|
943
944
|
}, false, function defined(option, source) {
|
|
944
945
|
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
945
|
-
return !utils.isUndefined(source[option]);
|
|
946
|
+
return !utils$1.isUndefined(source[option]);
|
|
946
947
|
});
|
|
947
948
|
|
|
948
949
|
const metaTokens = options.metaTokens;
|
|
@@ -951,24 +952,24 @@ function toFormData(obj, formData, options) {
|
|
|
951
952
|
const dots = options.dots;
|
|
952
953
|
const indexes = options.indexes;
|
|
953
954
|
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
|
954
|
-
const useBlob = _Blob && utils.isSpecCompliantForm(formData);
|
|
955
|
+
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
955
956
|
|
|
956
|
-
if (!utils.isFunction(visitor)) {
|
|
957
|
+
if (!utils$1.isFunction(visitor)) {
|
|
957
958
|
throw new TypeError('visitor must be a function');
|
|
958
959
|
}
|
|
959
960
|
|
|
960
961
|
function convertValue(value) {
|
|
961
962
|
if (value === null) return '';
|
|
962
963
|
|
|
963
|
-
if (utils.isDate(value)) {
|
|
964
|
+
if (utils$1.isDate(value)) {
|
|
964
965
|
return value.toISOString();
|
|
965
966
|
}
|
|
966
967
|
|
|
967
|
-
if (!useBlob && utils.isBlob(value)) {
|
|
968
|
+
if (!useBlob && utils$1.isBlob(value)) {
|
|
968
969
|
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
|
969
970
|
}
|
|
970
971
|
|
|
971
|
-
if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
|
|
972
|
+
if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
|
972
973
|
return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
|
973
974
|
}
|
|
974
975
|
|
|
@@ -989,20 +990,20 @@ function toFormData(obj, formData, options) {
|
|
|
989
990
|
let arr = value;
|
|
990
991
|
|
|
991
992
|
if (value && !path && typeof value === 'object') {
|
|
992
|
-
if (utils.endsWith(key, '{}')) {
|
|
993
|
+
if (utils$1.endsWith(key, '{}')) {
|
|
993
994
|
// eslint-disable-next-line no-param-reassign
|
|
994
995
|
key = metaTokens ? key : key.slice(0, -2);
|
|
995
996
|
// eslint-disable-next-line no-param-reassign
|
|
996
997
|
value = JSON.stringify(value);
|
|
997
998
|
} else if (
|
|
998
|
-
(utils.isArray(value) && isFlatArray(value)) ||
|
|
999
|
-
((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value))
|
|
999
|
+
(utils$1.isArray(value) && isFlatArray(value)) ||
|
|
1000
|
+
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
|
|
1000
1001
|
)) {
|
|
1001
1002
|
// eslint-disable-next-line no-param-reassign
|
|
1002
1003
|
key = removeBrackets(key);
|
|
1003
1004
|
|
|
1004
1005
|
arr.forEach(function each(el, index) {
|
|
1005
|
-
!(utils.isUndefined(el) || el === null) && formData.append(
|
|
1006
|
+
!(utils$1.isUndefined(el) || el === null) && formData.append(
|
|
1006
1007
|
// eslint-disable-next-line no-nested-ternary
|
|
1007
1008
|
indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
|
|
1008
1009
|
convertValue(el)
|
|
@@ -1030,7 +1031,7 @@ function toFormData(obj, formData, options) {
|
|
|
1030
1031
|
});
|
|
1031
1032
|
|
|
1032
1033
|
function build(value, path) {
|
|
1033
|
-
if (utils.isUndefined(value)) return;
|
|
1034
|
+
if (utils$1.isUndefined(value)) return;
|
|
1034
1035
|
|
|
1035
1036
|
if (stack.indexOf(value) !== -1) {
|
|
1036
1037
|
throw Error('Circular reference detected in ' + path.join('.'));
|
|
@@ -1038,9 +1039,9 @@ function toFormData(obj, formData, options) {
|
|
|
1038
1039
|
|
|
1039
1040
|
stack.push(value);
|
|
1040
1041
|
|
|
1041
|
-
utils.forEach(value, function each(el, key) {
|
|
1042
|
-
const result = !(utils.isUndefined(el) || el === null) && visitor.call(
|
|
1043
|
-
formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers
|
|
1042
|
+
utils$1.forEach(value, function each(el, key) {
|
|
1043
|
+
const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
|
|
1044
|
+
formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
|
|
1044
1045
|
);
|
|
1045
1046
|
|
|
1046
1047
|
if (result === true) {
|
|
@@ -1051,7 +1052,7 @@ function toFormData(obj, formData, options) {
|
|
|
1051
1052
|
stack.pop();
|
|
1052
1053
|
}
|
|
1053
1054
|
|
|
1054
|
-
if (!utils.isObject(obj)) {
|
|
1055
|
+
if (!utils$1.isObject(obj)) {
|
|
1055
1056
|
throw new TypeError('data must be an object');
|
|
1056
1057
|
}
|
|
1057
1058
|
|
|
@@ -1155,7 +1156,7 @@ function buildURL(url, params, options) {
|
|
|
1155
1156
|
if (serializeFn) {
|
|
1156
1157
|
serializedParams = serializeFn(params, options);
|
|
1157
1158
|
} else {
|
|
1158
|
-
serializedParams = utils.isURLSearchParams(params) ?
|
|
1159
|
+
serializedParams = utils$1.isURLSearchParams(params) ?
|
|
1159
1160
|
params.toString() :
|
|
1160
1161
|
new AxiosURLSearchParams(params, options).toString(_encode);
|
|
1161
1162
|
}
|
|
@@ -1230,7 +1231,7 @@ class InterceptorManager {
|
|
|
1230
1231
|
* @returns {void}
|
|
1231
1232
|
*/
|
|
1232
1233
|
forEach(fn) {
|
|
1233
|
-
utils.forEach(this.handlers, function forEachHandler(h) {
|
|
1234
|
+
utils$1.forEach(this.handlers, function forEachHandler(h) {
|
|
1234
1235
|
if (h !== null) {
|
|
1235
1236
|
fn(h);
|
|
1236
1237
|
}
|
|
@@ -1252,6 +1253,18 @@ var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
|
|
|
1252
1253
|
|
|
1253
1254
|
var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
|
|
1254
1255
|
|
|
1256
|
+
var platform$1 = {
|
|
1257
|
+
isBrowser: true,
|
|
1258
|
+
classes: {
|
|
1259
|
+
URLSearchParams: URLSearchParams$1,
|
|
1260
|
+
FormData: FormData$1,
|
|
1261
|
+
Blob: Blob$1
|
|
1262
|
+
},
|
|
1263
|
+
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
|
1264
|
+
};
|
|
1265
|
+
|
|
1266
|
+
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
1267
|
+
|
|
1255
1268
|
/**
|
|
1256
1269
|
* Determine if we're running in a standard browser environment
|
|
1257
1270
|
*
|
|
@@ -1269,18 +1282,10 @@ var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
|
|
|
1269
1282
|
*
|
|
1270
1283
|
* @returns {boolean}
|
|
1271
1284
|
*/
|
|
1272
|
-
const
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
product === 'NativeScript' ||
|
|
1277
|
-
product === 'NS')
|
|
1278
|
-
) {
|
|
1279
|
-
return false;
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
1283
|
-
})();
|
|
1285
|
+
const hasStandardBrowserEnv = (
|
|
1286
|
+
(product) => {
|
|
1287
|
+
return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0
|
|
1288
|
+
})(typeof navigator !== 'undefined' && navigator.product);
|
|
1284
1289
|
|
|
1285
1290
|
/**
|
|
1286
1291
|
* Determine if we're running in a standard browser webWorker environment
|
|
@@ -1291,7 +1296,7 @@ const isStandardBrowserEnv = (() => {
|
|
|
1291
1296
|
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
|
1292
1297
|
* This leads to a problem when axios post `FormData` in webWorker
|
|
1293
1298
|
*/
|
|
1294
|
-
|
|
1299
|
+
const hasStandardBrowserWebWorkerEnv = (() => {
|
|
1295
1300
|
return (
|
|
1296
1301
|
typeof WorkerGlobalScope !== 'undefined' &&
|
|
1297
1302
|
// eslint-disable-next-line no-undef
|
|
@@ -1300,23 +1305,22 @@ const isStandardBrowserEnv = (() => {
|
|
|
1300
1305
|
);
|
|
1301
1306
|
})();
|
|
1302
1307
|
|
|
1308
|
+
var utils = /*#__PURE__*/Object.freeze({
|
|
1309
|
+
__proto__: null,
|
|
1310
|
+
hasBrowserEnv: hasBrowserEnv,
|
|
1311
|
+
hasStandardBrowserEnv: hasStandardBrowserEnv,
|
|
1312
|
+
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv
|
|
1313
|
+
});
|
|
1303
1314
|
|
|
1304
1315
|
var platform = {
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
URLSearchParams: URLSearchParams$1,
|
|
1308
|
-
FormData: FormData$1,
|
|
1309
|
-
Blob: Blob$1
|
|
1310
|
-
},
|
|
1311
|
-
isStandardBrowserEnv,
|
|
1312
|
-
isStandardBrowserWebWorkerEnv,
|
|
1313
|
-
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
|
1316
|
+
...utils,
|
|
1317
|
+
...platform$1
|
|
1314
1318
|
};
|
|
1315
1319
|
|
|
1316
1320
|
function toURLEncodedForm(data, options) {
|
|
1317
1321
|
return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
|
|
1318
1322
|
visitor: function(value, key, path, helpers) {
|
|
1319
|
-
if (platform.isNode && utils.isBuffer(value)) {
|
|
1323
|
+
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
1320
1324
|
this.append(key, value.toString('base64'));
|
|
1321
1325
|
return false;
|
|
1322
1326
|
}
|
|
@@ -1338,7 +1342,7 @@ function parsePropPath(name) {
|
|
|
1338
1342
|
// foo.x.y.z
|
|
1339
1343
|
// foo-x-y-z
|
|
1340
1344
|
// foo x y z
|
|
1341
|
-
return utils.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
|
1345
|
+
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
|
1342
1346
|
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
1343
1347
|
});
|
|
1344
1348
|
}
|
|
@@ -1373,12 +1377,15 @@ function arrayToObject(arr) {
|
|
|
1373
1377
|
function formDataToJSON(formData) {
|
|
1374
1378
|
function buildPath(path, value, target, index) {
|
|
1375
1379
|
let name = path[index++];
|
|
1380
|
+
|
|
1381
|
+
if (name === '__proto__') return true;
|
|
1382
|
+
|
|
1376
1383
|
const isNumericKey = Number.isFinite(+name);
|
|
1377
1384
|
const isLast = index >= path.length;
|
|
1378
|
-
name = !name && utils.isArray(target) ? target.length : name;
|
|
1385
|
+
name = !name && utils$1.isArray(target) ? target.length : name;
|
|
1379
1386
|
|
|
1380
1387
|
if (isLast) {
|
|
1381
|
-
if (utils.hasOwnProp(target, name)) {
|
|
1388
|
+
if (utils$1.hasOwnProp(target, name)) {
|
|
1382
1389
|
target[name] = [target[name], value];
|
|
1383
1390
|
} else {
|
|
1384
1391
|
target[name] = value;
|
|
@@ -1387,23 +1394,23 @@ function formDataToJSON(formData) {
|
|
|
1387
1394
|
return !isNumericKey;
|
|
1388
1395
|
}
|
|
1389
1396
|
|
|
1390
|
-
if (!target[name] || !utils.isObject(target[name])) {
|
|
1397
|
+
if (!target[name] || !utils$1.isObject(target[name])) {
|
|
1391
1398
|
target[name] = [];
|
|
1392
1399
|
}
|
|
1393
1400
|
|
|
1394
1401
|
const result = buildPath(path, value, target[name], index);
|
|
1395
1402
|
|
|
1396
|
-
if (result && utils.isArray(target[name])) {
|
|
1403
|
+
if (result && utils$1.isArray(target[name])) {
|
|
1397
1404
|
target[name] = arrayToObject(target[name]);
|
|
1398
1405
|
}
|
|
1399
1406
|
|
|
1400
1407
|
return !isNumericKey;
|
|
1401
1408
|
}
|
|
1402
1409
|
|
|
1403
|
-
if (utils.isFormData(formData) && utils.isFunction(formData.entries)) {
|
|
1410
|
+
if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
|
|
1404
1411
|
const obj = {};
|
|
1405
1412
|
|
|
1406
|
-
utils.forEachEntry(formData, (name, value) => {
|
|
1413
|
+
utils$1.forEachEntry(formData, (name, value) => {
|
|
1407
1414
|
buildPath(parsePropPath(name), value, obj, 0);
|
|
1408
1415
|
});
|
|
1409
1416
|
|
|
@@ -1413,10 +1420,6 @@ function formDataToJSON(formData) {
|
|
|
1413
1420
|
return null;
|
|
1414
1421
|
}
|
|
1415
1422
|
|
|
1416
|
-
const DEFAULT_CONTENT_TYPE = {
|
|
1417
|
-
'Content-Type': undefined
|
|
1418
|
-
};
|
|
1419
|
-
|
|
1420
1423
|
/**
|
|
1421
1424
|
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
|
1422
1425
|
* of the input
|
|
@@ -1428,10 +1431,10 @@ const DEFAULT_CONTENT_TYPE = {
|
|
|
1428
1431
|
* @returns {string} A stringified version of the rawValue.
|
|
1429
1432
|
*/
|
|
1430
1433
|
function stringifySafely(rawValue, parser, encoder) {
|
|
1431
|
-
if (utils.isString(rawValue)) {
|
|
1434
|
+
if (utils$1.isString(rawValue)) {
|
|
1432
1435
|
try {
|
|
1433
1436
|
(parser || JSON.parse)(rawValue);
|
|
1434
|
-
return utils.trim(rawValue);
|
|
1437
|
+
return utils$1.trim(rawValue);
|
|
1435
1438
|
} catch (e) {
|
|
1436
1439
|
if (e.name !== 'SyntaxError') {
|
|
1437
1440
|
throw e;
|
|
@@ -1451,13 +1454,13 @@ const defaults = {
|
|
|
1451
1454
|
transformRequest: [function transformRequest(data, headers) {
|
|
1452
1455
|
const contentType = headers.getContentType() || '';
|
|
1453
1456
|
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
1454
|
-
const isObjectPayload = utils.isObject(data);
|
|
1457
|
+
const isObjectPayload = utils$1.isObject(data);
|
|
1455
1458
|
|
|
1456
|
-
if (isObjectPayload && utils.isHTMLForm(data)) {
|
|
1459
|
+
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
1457
1460
|
data = new FormData(data);
|
|
1458
1461
|
}
|
|
1459
1462
|
|
|
1460
|
-
const isFormData = utils.isFormData(data);
|
|
1463
|
+
const isFormData = utils$1.isFormData(data);
|
|
1461
1464
|
|
|
1462
1465
|
if (isFormData) {
|
|
1463
1466
|
if (!hasJSONContentType) {
|
|
@@ -1466,18 +1469,18 @@ const defaults = {
|
|
|
1466
1469
|
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
1467
1470
|
}
|
|
1468
1471
|
|
|
1469
|
-
if (utils.isArrayBuffer(data) ||
|
|
1470
|
-
utils.isBuffer(data) ||
|
|
1471
|
-
utils.isStream(data) ||
|
|
1472
|
-
utils.isFile(data) ||
|
|
1473
|
-
utils.isBlob(data)
|
|
1472
|
+
if (utils$1.isArrayBuffer(data) ||
|
|
1473
|
+
utils$1.isBuffer(data) ||
|
|
1474
|
+
utils$1.isStream(data) ||
|
|
1475
|
+
utils$1.isFile(data) ||
|
|
1476
|
+
utils$1.isBlob(data)
|
|
1474
1477
|
) {
|
|
1475
1478
|
return data;
|
|
1476
1479
|
}
|
|
1477
|
-
if (utils.isArrayBufferView(data)) {
|
|
1480
|
+
if (utils$1.isArrayBufferView(data)) {
|
|
1478
1481
|
return data.buffer;
|
|
1479
1482
|
}
|
|
1480
|
-
if (utils.isURLSearchParams(data)) {
|
|
1483
|
+
if (utils$1.isURLSearchParams(data)) {
|
|
1481
1484
|
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
1482
1485
|
return data.toString();
|
|
1483
1486
|
}
|
|
@@ -1489,7 +1492,7 @@ const defaults = {
|
|
|
1489
1492
|
return toURLEncodedForm(data, this.formSerializer).toString();
|
|
1490
1493
|
}
|
|
1491
1494
|
|
|
1492
|
-
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
|
1495
|
+
if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
|
1493
1496
|
const _FormData = this.env && this.env.FormData;
|
|
1494
1497
|
|
|
1495
1498
|
return toFormData(
|
|
@@ -1513,7 +1516,7 @@ const defaults = {
|
|
|
1513
1516
|
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
1514
1517
|
const JSONRequested = this.responseType === 'json';
|
|
1515
1518
|
|
|
1516
|
-
if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
|
1519
|
+
if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
|
1517
1520
|
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
1518
1521
|
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
1519
1522
|
|
|
@@ -1555,24 +1558,21 @@ const defaults = {
|
|
|
1555
1558
|
|
|
1556
1559
|
headers: {
|
|
1557
1560
|
common: {
|
|
1558
|
-
'Accept': 'application/json, text/plain, */*'
|
|
1561
|
+
'Accept': 'application/json, text/plain, */*',
|
|
1562
|
+
'Content-Type': undefined
|
|
1559
1563
|
}
|
|
1560
1564
|
}
|
|
1561
1565
|
};
|
|
1562
1566
|
|
|
1563
|
-
utils.forEach(['delete', 'get', 'head'],
|
|
1567
|
+
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
|
1564
1568
|
defaults.headers[method] = {};
|
|
1565
1569
|
});
|
|
1566
1570
|
|
|
1567
|
-
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
1568
|
-
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
|
1569
|
-
});
|
|
1570
|
-
|
|
1571
1571
|
var defaults$1 = defaults;
|
|
1572
1572
|
|
|
1573
1573
|
// RawAxiosHeaders whose duplicates are ignored by node
|
|
1574
1574
|
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
1575
|
-
const ignoreDuplicateOf = utils.toObjectSet([
|
|
1575
|
+
const ignoreDuplicateOf = utils$1.toObjectSet([
|
|
1576
1576
|
'age', 'authorization', 'content-length', 'content-type', 'etag',
|
|
1577
1577
|
'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
|
|
1578
1578
|
'last-modified', 'location', 'max-forwards', 'proxy-authorization',
|
|
@@ -1633,7 +1633,7 @@ function normalizeValue(value) {
|
|
|
1633
1633
|
return value;
|
|
1634
1634
|
}
|
|
1635
1635
|
|
|
1636
|
-
return utils.isArray(value) ? value.map(normalizeValue) : String(value);
|
|
1636
|
+
return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
|
|
1637
1637
|
}
|
|
1638
1638
|
|
|
1639
1639
|
function parseTokens(str) {
|
|
@@ -1651,7 +1651,7 @@ function parseTokens(str) {
|
|
|
1651
1651
|
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
1652
1652
|
|
|
1653
1653
|
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
1654
|
-
if (utils.isFunction(filter)) {
|
|
1654
|
+
if (utils$1.isFunction(filter)) {
|
|
1655
1655
|
return filter.call(this, value, header);
|
|
1656
1656
|
}
|
|
1657
1657
|
|
|
@@ -1659,13 +1659,13 @@ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
|
1659
1659
|
value = header;
|
|
1660
1660
|
}
|
|
1661
1661
|
|
|
1662
|
-
if (!utils.isString(value)) return;
|
|
1662
|
+
if (!utils$1.isString(value)) return;
|
|
1663
1663
|
|
|
1664
|
-
if (utils.isString(filter)) {
|
|
1664
|
+
if (utils$1.isString(filter)) {
|
|
1665
1665
|
return value.indexOf(filter) !== -1;
|
|
1666
1666
|
}
|
|
1667
1667
|
|
|
1668
|
-
if (utils.isRegExp(filter)) {
|
|
1668
|
+
if (utils$1.isRegExp(filter)) {
|
|
1669
1669
|
return filter.test(value);
|
|
1670
1670
|
}
|
|
1671
1671
|
}
|
|
@@ -1678,7 +1678,7 @@ function formatHeader(header) {
|
|
|
1678
1678
|
}
|
|
1679
1679
|
|
|
1680
1680
|
function buildAccessors(obj, header) {
|
|
1681
|
-
const accessorName = utils.toCamelCase(' ' + header);
|
|
1681
|
+
const accessorName = utils$1.toCamelCase(' ' + header);
|
|
1682
1682
|
|
|
1683
1683
|
['get', 'set', 'has'].forEach(methodName => {
|
|
1684
1684
|
Object.defineProperty(obj, methodName + accessorName, {
|
|
@@ -1705,7 +1705,7 @@ class AxiosHeaders {
|
|
|
1705
1705
|
throw new Error('header name must be a non-empty string');
|
|
1706
1706
|
}
|
|
1707
1707
|
|
|
1708
|
-
const key = utils.findKey(self, lHeader);
|
|
1708
|
+
const key = utils$1.findKey(self, lHeader);
|
|
1709
1709
|
|
|
1710
1710
|
if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
|
|
1711
1711
|
self[key || _header] = normalizeValue(_value);
|
|
@@ -1713,11 +1713,11 @@ class AxiosHeaders {
|
|
|
1713
1713
|
}
|
|
1714
1714
|
|
|
1715
1715
|
const setHeaders = (headers, _rewrite) =>
|
|
1716
|
-
utils.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
1716
|
+
utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
1717
1717
|
|
|
1718
|
-
if (utils.isPlainObject(header) || header instanceof this.constructor) {
|
|
1718
|
+
if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
|
1719
1719
|
setHeaders(header, valueOrRewrite);
|
|
1720
|
-
} else if(utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
1720
|
+
} else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
1721
1721
|
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
1722
1722
|
} else {
|
|
1723
1723
|
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
@@ -1730,7 +1730,7 @@ class AxiosHeaders {
|
|
|
1730
1730
|
header = normalizeHeader(header);
|
|
1731
1731
|
|
|
1732
1732
|
if (header) {
|
|
1733
|
-
const key = utils.findKey(this, header);
|
|
1733
|
+
const key = utils$1.findKey(this, header);
|
|
1734
1734
|
|
|
1735
1735
|
if (key) {
|
|
1736
1736
|
const value = this[key];
|
|
@@ -1743,11 +1743,11 @@ class AxiosHeaders {
|
|
|
1743
1743
|
return parseTokens(value);
|
|
1744
1744
|
}
|
|
1745
1745
|
|
|
1746
|
-
if (utils.isFunction(parser)) {
|
|
1746
|
+
if (utils$1.isFunction(parser)) {
|
|
1747
1747
|
return parser.call(this, value, key);
|
|
1748
1748
|
}
|
|
1749
1749
|
|
|
1750
|
-
if (utils.isRegExp(parser)) {
|
|
1750
|
+
if (utils$1.isRegExp(parser)) {
|
|
1751
1751
|
return parser.exec(value);
|
|
1752
1752
|
}
|
|
1753
1753
|
|
|
@@ -1760,7 +1760,7 @@ class AxiosHeaders {
|
|
|
1760
1760
|
header = normalizeHeader(header);
|
|
1761
1761
|
|
|
1762
1762
|
if (header) {
|
|
1763
|
-
const key = utils.findKey(this, header);
|
|
1763
|
+
const key = utils$1.findKey(this, header);
|
|
1764
1764
|
|
|
1765
1765
|
return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
|
1766
1766
|
}
|
|
@@ -1776,7 +1776,7 @@ class AxiosHeaders {
|
|
|
1776
1776
|
_header = normalizeHeader(_header);
|
|
1777
1777
|
|
|
1778
1778
|
if (_header) {
|
|
1779
|
-
const key = utils.findKey(self, _header);
|
|
1779
|
+
const key = utils$1.findKey(self, _header);
|
|
1780
1780
|
|
|
1781
1781
|
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
|
1782
1782
|
delete self[key];
|
|
@@ -1786,7 +1786,7 @@ class AxiosHeaders {
|
|
|
1786
1786
|
}
|
|
1787
1787
|
}
|
|
1788
1788
|
|
|
1789
|
-
if (utils.isArray(header)) {
|
|
1789
|
+
if (utils$1.isArray(header)) {
|
|
1790
1790
|
header.forEach(deleteHeader);
|
|
1791
1791
|
} else {
|
|
1792
1792
|
deleteHeader(header);
|
|
@@ -1815,8 +1815,8 @@ class AxiosHeaders {
|
|
|
1815
1815
|
const self = this;
|
|
1816
1816
|
const headers = {};
|
|
1817
1817
|
|
|
1818
|
-
utils.forEach(this, (value, header) => {
|
|
1819
|
-
const key = utils.findKey(headers, header);
|
|
1818
|
+
utils$1.forEach(this, (value, header) => {
|
|
1819
|
+
const key = utils$1.findKey(headers, header);
|
|
1820
1820
|
|
|
1821
1821
|
if (key) {
|
|
1822
1822
|
self[key] = normalizeValue(value);
|
|
@@ -1845,8 +1845,8 @@ class AxiosHeaders {
|
|
|
1845
1845
|
toJSON(asStrings) {
|
|
1846
1846
|
const obj = Object.create(null);
|
|
1847
1847
|
|
|
1848
|
-
utils.forEach(this, (value, header) => {
|
|
1849
|
-
value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value);
|
|
1848
|
+
utils$1.forEach(this, (value, header) => {
|
|
1849
|
+
value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
|
1850
1850
|
});
|
|
1851
1851
|
|
|
1852
1852
|
return obj;
|
|
@@ -1893,7 +1893,7 @@ class AxiosHeaders {
|
|
|
1893
1893
|
}
|
|
1894
1894
|
}
|
|
1895
1895
|
|
|
1896
|
-
utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
|
1896
|
+
utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
|
1897
1897
|
|
|
1898
1898
|
return this;
|
|
1899
1899
|
}
|
|
@@ -1901,8 +1901,18 @@ class AxiosHeaders {
|
|
|
1901
1901
|
|
|
1902
1902
|
AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
|
|
1903
1903
|
|
|
1904
|
-
|
|
1905
|
-
utils.
|
|
1904
|
+
// reserved names hotfix
|
|
1905
|
+
utils$1.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
|
|
1906
|
+
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
|
1907
|
+
return {
|
|
1908
|
+
get: () => value,
|
|
1909
|
+
set(headerValue) {
|
|
1910
|
+
this[mapped] = headerValue;
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
});
|
|
1914
|
+
|
|
1915
|
+
utils$1.freezeMethods(AxiosHeaders);
|
|
1906
1916
|
|
|
1907
1917
|
var AxiosHeaders$1 = AxiosHeaders;
|
|
1908
1918
|
|
|
@@ -1920,7 +1930,7 @@ function transformData(fns, response) {
|
|
|
1920
1930
|
const headers = AxiosHeaders$1.from(context.headers);
|
|
1921
1931
|
let data = context.data;
|
|
1922
1932
|
|
|
1923
|
-
utils.forEach(fns, function transform(fn) {
|
|
1933
|
+
utils$1.forEach(fns, function transform(fn) {
|
|
1924
1934
|
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
|
1925
1935
|
});
|
|
1926
1936
|
|
|
@@ -1948,7 +1958,7 @@ function CanceledError(message, config, request) {
|
|
|
1948
1958
|
this.name = 'CanceledError';
|
|
1949
1959
|
}
|
|
1950
1960
|
|
|
1951
|
-
utils.inherits(CanceledError, AxiosError, {
|
|
1961
|
+
utils$1.inherits(CanceledError, AxiosError, {
|
|
1952
1962
|
__CANCEL__: true
|
|
1953
1963
|
});
|
|
1954
1964
|
|
|
@@ -1976,53 +1986,44 @@ function settle(resolve, reject, response) {
|
|
|
1976
1986
|
}
|
|
1977
1987
|
}
|
|
1978
1988
|
|
|
1979
|
-
var cookies = platform.
|
|
1989
|
+
var cookies = platform.hasStandardBrowserEnv ?
|
|
1980
1990
|
|
|
1981
|
-
// Standard browser envs support document.cookie
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
const cookie = [];
|
|
1986
|
-
cookie.push(name + '=' + encodeURIComponent(value));
|
|
1991
|
+
// Standard browser envs support document.cookie
|
|
1992
|
+
{
|
|
1993
|
+
write(name, value, expires, path, domain, secure) {
|
|
1994
|
+
const cookie = [name + '=' + encodeURIComponent(value)];
|
|
1987
1995
|
|
|
1988
|
-
|
|
1989
|
-
cookie.push('expires=' + new Date(expires).toGMTString());
|
|
1990
|
-
}
|
|
1996
|
+
utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
|
|
1991
1997
|
|
|
1992
|
-
|
|
1993
|
-
cookie.push('path=' + path);
|
|
1994
|
-
}
|
|
1998
|
+
utils$1.isString(path) && cookie.push('path=' + path);
|
|
1995
1999
|
|
|
1996
|
-
|
|
1997
|
-
cookie.push('domain=' + domain);
|
|
1998
|
-
}
|
|
2000
|
+
utils$1.isString(domain) && cookie.push('domain=' + domain);
|
|
1999
2001
|
|
|
2000
|
-
|
|
2001
|
-
cookie.push('secure');
|
|
2002
|
-
}
|
|
2002
|
+
secure === true && cookie.push('secure');
|
|
2003
2003
|
|
|
2004
|
-
|
|
2005
|
-
|
|
2004
|
+
document.cookie = cookie.join('; ');
|
|
2005
|
+
},
|
|
2006
2006
|
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2007
|
+
read(name) {
|
|
2008
|
+
const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
|
2009
|
+
return (match ? decodeURIComponent(match[3]) : null);
|
|
2010
|
+
},
|
|
2011
2011
|
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
})() :
|
|
2012
|
+
remove(name) {
|
|
2013
|
+
this.write(name, '', Date.now() - 86400000);
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2017
2016
|
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2017
|
+
:
|
|
2018
|
+
|
|
2019
|
+
// Non-standard browser env (web workers, react-native) lack needed support.
|
|
2020
|
+
{
|
|
2021
|
+
write() {},
|
|
2022
|
+
read() {
|
|
2023
|
+
return null;
|
|
2024
|
+
},
|
|
2025
|
+
remove() {}
|
|
2026
|
+
};
|
|
2026
2027
|
|
|
2027
2028
|
/**
|
|
2028
2029
|
* Determines whether the specified URL is absolute
|
|
@@ -2048,7 +2049,7 @@ function isAbsoluteURL(url) {
|
|
|
2048
2049
|
*/
|
|
2049
2050
|
function combineURLs(baseURL, relativeURL) {
|
|
2050
2051
|
return relativeURL
|
|
2051
|
-
? baseURL.replace(
|
|
2052
|
+
? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
|
2052
2053
|
: baseURL;
|
|
2053
2054
|
}
|
|
2054
2055
|
|
|
@@ -2069,7 +2070,7 @@ function buildFullPath(baseURL, requestedURL) {
|
|
|
2069
2070
|
return requestedURL;
|
|
2070
2071
|
}
|
|
2071
2072
|
|
|
2072
|
-
var isURLSameOrigin = platform.
|
|
2073
|
+
var isURLSameOrigin = platform.hasStandardBrowserEnv ?
|
|
2073
2074
|
|
|
2074
2075
|
// Standard browser envs have full support of the APIs needed to test
|
|
2075
2076
|
// whether the request URL is of the same origin as current location.
|
|
@@ -2079,7 +2080,7 @@ var isURLSameOrigin = platform.isStandardBrowserEnv ?
|
|
|
2079
2080
|
let originURL;
|
|
2080
2081
|
|
|
2081
2082
|
/**
|
|
2082
|
-
* Parse a URL to discover
|
|
2083
|
+
* Parse a URL to discover its components
|
|
2083
2084
|
*
|
|
2084
2085
|
* @param {String} url The URL to be parsed
|
|
2085
2086
|
* @returns {Object}
|
|
@@ -2119,7 +2120,7 @@ var isURLSameOrigin = platform.isStandardBrowserEnv ?
|
|
|
2119
2120
|
* @returns {boolean} True if URL shares the same origin, otherwise false
|
|
2120
2121
|
*/
|
|
2121
2122
|
return function isURLSameOrigin(requestURL) {
|
|
2122
|
-
const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
|
2123
|
+
const parsed = (utils$1.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
|
2123
2124
|
return (parsed.protocol === originURL.protocol &&
|
|
2124
2125
|
parsed.host === originURL.host);
|
|
2125
2126
|
};
|
|
@@ -2224,7 +2225,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
2224
2225
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
2225
2226
|
let requestData = config.data;
|
|
2226
2227
|
const requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
|
|
2227
|
-
|
|
2228
|
+
let {responseType, withXSRFToken} = config;
|
|
2228
2229
|
let onCanceled;
|
|
2229
2230
|
function done() {
|
|
2230
2231
|
if (config.cancelToken) {
|
|
@@ -2236,11 +2237,15 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
2236
2237
|
}
|
|
2237
2238
|
}
|
|
2238
2239
|
|
|
2239
|
-
|
|
2240
|
-
|
|
2240
|
+
let contentType;
|
|
2241
|
+
|
|
2242
|
+
if (utils$1.isFormData(requestData)) {
|
|
2243
|
+
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|
2241
2244
|
requestHeaders.setContentType(false); // Let the browser set it
|
|
2242
|
-
} else {
|
|
2243
|
-
|
|
2245
|
+
} else if ((contentType = requestHeaders.getContentType()) !== false) {
|
|
2246
|
+
// fix semicolon duplication issue for ReactNative FormData implementation
|
|
2247
|
+
const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
|
|
2248
|
+
requestHeaders.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
|
|
2244
2249
|
}
|
|
2245
2250
|
}
|
|
2246
2251
|
|
|
@@ -2356,13 +2361,16 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
2356
2361
|
// Add xsrf header
|
|
2357
2362
|
// This is only done if running in a standard browser environment.
|
|
2358
2363
|
// Specifically not if we're in a web worker, or react-native.
|
|
2359
|
-
if
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2364
|
+
if(platform.hasStandardBrowserEnv) {
|
|
2365
|
+
withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(config));
|
|
2366
|
+
|
|
2367
|
+
if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(fullPath))) {
|
|
2368
|
+
// Add xsrf header
|
|
2369
|
+
const xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
|
|
2363
2370
|
|
|
2364
|
-
|
|
2365
|
-
|
|
2371
|
+
if (xsrfValue) {
|
|
2372
|
+
requestHeaders.set(config.xsrfHeaderName, xsrfValue);
|
|
2373
|
+
}
|
|
2366
2374
|
}
|
|
2367
2375
|
}
|
|
2368
2376
|
|
|
@@ -2371,13 +2379,13 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
|
2371
2379
|
|
|
2372
2380
|
// Add headers to the request
|
|
2373
2381
|
if ('setRequestHeader' in request) {
|
|
2374
|
-
utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
|
2382
|
+
utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
|
2375
2383
|
request.setRequestHeader(key, val);
|
|
2376
2384
|
});
|
|
2377
2385
|
}
|
|
2378
2386
|
|
|
2379
2387
|
// Add withCredentials to request if needed
|
|
2380
|
-
if (!utils.isUndefined(config.withCredentials)) {
|
|
2388
|
+
if (!utils$1.isUndefined(config.withCredentials)) {
|
|
2381
2389
|
request.withCredentials = !!config.withCredentials;
|
|
2382
2390
|
}
|
|
2383
2391
|
|
|
@@ -2432,8 +2440,8 @@ const knownAdapters = {
|
|
|
2432
2440
|
xhr: xhrAdapter
|
|
2433
2441
|
};
|
|
2434
2442
|
|
|
2435
|
-
utils.forEach(knownAdapters, (fn, value) => {
|
|
2436
|
-
if(fn) {
|
|
2443
|
+
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
2444
|
+
if (fn) {
|
|
2437
2445
|
try {
|
|
2438
2446
|
Object.defineProperty(fn, 'name', {value});
|
|
2439
2447
|
} catch (e) {
|
|
@@ -2443,38 +2451,56 @@ utils.forEach(knownAdapters, (fn, value) => {
|
|
|
2443
2451
|
}
|
|
2444
2452
|
});
|
|
2445
2453
|
|
|
2454
|
+
const renderReason = (reason) => `- ${reason}`;
|
|
2455
|
+
|
|
2456
|
+
const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
2457
|
+
|
|
2446
2458
|
var adapters = {
|
|
2447
2459
|
getAdapter: (adapters) => {
|
|
2448
|
-
adapters = utils.isArray(adapters) ? adapters : [adapters];
|
|
2460
|
+
adapters = utils$1.isArray(adapters) ? adapters : [adapters];
|
|
2449
2461
|
|
|
2450
2462
|
const {length} = adapters;
|
|
2451
2463
|
let nameOrAdapter;
|
|
2452
2464
|
let adapter;
|
|
2453
2465
|
|
|
2466
|
+
const rejectedReasons = {};
|
|
2467
|
+
|
|
2454
2468
|
for (let i = 0; i < length; i++) {
|
|
2455
2469
|
nameOrAdapter = adapters[i];
|
|
2456
|
-
|
|
2470
|
+
let id;
|
|
2471
|
+
|
|
2472
|
+
adapter = nameOrAdapter;
|
|
2473
|
+
|
|
2474
|
+
if (!isResolvedHandle(nameOrAdapter)) {
|
|
2475
|
+
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|
2476
|
+
|
|
2477
|
+
if (adapter === undefined) {
|
|
2478
|
+
throw new AxiosError(`Unknown adapter '${id}'`);
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
|
|
2482
|
+
if (adapter) {
|
|
2457
2483
|
break;
|
|
2458
2484
|
}
|
|
2485
|
+
|
|
2486
|
+
rejectedReasons[id || '#' + i] = adapter;
|
|
2459
2487
|
}
|
|
2460
2488
|
|
|
2461
2489
|
if (!adapter) {
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
'
|
|
2490
|
+
|
|
2491
|
+
const reasons = Object.entries(rejectedReasons)
|
|
2492
|
+
.map(([id, state]) => `adapter ${id} ` +
|
|
2493
|
+
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
|
2466
2494
|
);
|
|
2467
|
-
}
|
|
2468
2495
|
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
`Unknown adapter '${nameOrAdapter}'`
|
|
2473
|
-
);
|
|
2474
|
-
}
|
|
2496
|
+
let s = length ?
|
|
2497
|
+
(reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
|
|
2498
|
+
'as no adapter specified';
|
|
2475
2499
|
|
|
2476
|
-
|
|
2477
|
-
|
|
2500
|
+
throw new AxiosError(
|
|
2501
|
+
`There is no suitable adapter to dispatch the request ` + s,
|
|
2502
|
+
'ERR_NOT_SUPPORT'
|
|
2503
|
+
);
|
|
2478
2504
|
}
|
|
2479
2505
|
|
|
2480
2506
|
return adapter;
|
|
@@ -2572,11 +2598,11 @@ function mergeConfig(config1, config2) {
|
|
|
2572
2598
|
const config = {};
|
|
2573
2599
|
|
|
2574
2600
|
function getMergedValue(target, source, caseless) {
|
|
2575
|
-
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
|
2576
|
-
return utils.merge.call({caseless}, target, source);
|
|
2577
|
-
} else if (utils.isPlainObject(source)) {
|
|
2578
|
-
return utils.merge({}, source);
|
|
2579
|
-
} else if (utils.isArray(source)) {
|
|
2601
|
+
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
2602
|
+
return utils$1.merge.call({caseless}, target, source);
|
|
2603
|
+
} else if (utils$1.isPlainObject(source)) {
|
|
2604
|
+
return utils$1.merge({}, source);
|
|
2605
|
+
} else if (utils$1.isArray(source)) {
|
|
2580
2606
|
return source.slice();
|
|
2581
2607
|
}
|
|
2582
2608
|
return source;
|
|
@@ -2584,25 +2610,25 @@ function mergeConfig(config1, config2) {
|
|
|
2584
2610
|
|
|
2585
2611
|
// eslint-disable-next-line consistent-return
|
|
2586
2612
|
function mergeDeepProperties(a, b, caseless) {
|
|
2587
|
-
if (!utils.isUndefined(b)) {
|
|
2613
|
+
if (!utils$1.isUndefined(b)) {
|
|
2588
2614
|
return getMergedValue(a, b, caseless);
|
|
2589
|
-
} else if (!utils.isUndefined(a)) {
|
|
2615
|
+
} else if (!utils$1.isUndefined(a)) {
|
|
2590
2616
|
return getMergedValue(undefined, a, caseless);
|
|
2591
2617
|
}
|
|
2592
2618
|
}
|
|
2593
2619
|
|
|
2594
2620
|
// eslint-disable-next-line consistent-return
|
|
2595
2621
|
function valueFromConfig2(a, b) {
|
|
2596
|
-
if (!utils.isUndefined(b)) {
|
|
2622
|
+
if (!utils$1.isUndefined(b)) {
|
|
2597
2623
|
return getMergedValue(undefined, b);
|
|
2598
2624
|
}
|
|
2599
2625
|
}
|
|
2600
2626
|
|
|
2601
2627
|
// eslint-disable-next-line consistent-return
|
|
2602
2628
|
function defaultToConfig2(a, b) {
|
|
2603
|
-
if (!utils.isUndefined(b)) {
|
|
2629
|
+
if (!utils$1.isUndefined(b)) {
|
|
2604
2630
|
return getMergedValue(undefined, b);
|
|
2605
|
-
} else if (!utils.isUndefined(a)) {
|
|
2631
|
+
} else if (!utils$1.isUndefined(a)) {
|
|
2606
2632
|
return getMergedValue(undefined, a);
|
|
2607
2633
|
}
|
|
2608
2634
|
}
|
|
@@ -2627,6 +2653,7 @@ function mergeConfig(config1, config2) {
|
|
|
2627
2653
|
timeout: defaultToConfig2,
|
|
2628
2654
|
timeoutMessage: defaultToConfig2,
|
|
2629
2655
|
withCredentials: defaultToConfig2,
|
|
2656
|
+
withXSRFToken: defaultToConfig2,
|
|
2630
2657
|
adapter: defaultToConfig2,
|
|
2631
2658
|
responseType: defaultToConfig2,
|
|
2632
2659
|
xsrfCookieName: defaultToConfig2,
|
|
@@ -2647,16 +2674,16 @@ function mergeConfig(config1, config2) {
|
|
|
2647
2674
|
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
|
2648
2675
|
};
|
|
2649
2676
|
|
|
2650
|
-
utils.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
|
2677
|
+
utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
|
2651
2678
|
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
2652
2679
|
const configValue = merge(config1[prop], config2[prop], prop);
|
|
2653
|
-
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
2680
|
+
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
2654
2681
|
});
|
|
2655
2682
|
|
|
2656
2683
|
return config;
|
|
2657
2684
|
}
|
|
2658
2685
|
|
|
2659
|
-
const VERSION = "1.
|
|
2686
|
+
const VERSION = "1.6.5";
|
|
2660
2687
|
|
|
2661
2688
|
const validators$1 = {};
|
|
2662
2689
|
|
|
@@ -2794,7 +2821,7 @@ class Axios {
|
|
|
2794
2821
|
}
|
|
2795
2822
|
|
|
2796
2823
|
if (paramsSerializer != null) {
|
|
2797
|
-
if (utils.isFunction(paramsSerializer)) {
|
|
2824
|
+
if (utils$1.isFunction(paramsSerializer)) {
|
|
2798
2825
|
config.paramsSerializer = {
|
|
2799
2826
|
serialize: paramsSerializer
|
|
2800
2827
|
};
|
|
@@ -2809,15 +2836,13 @@ class Axios {
|
|
|
2809
2836
|
// Set config.method
|
|
2810
2837
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
|
2811
2838
|
|
|
2812
|
-
let contextHeaders;
|
|
2813
|
-
|
|
2814
2839
|
// Flatten headers
|
|
2815
|
-
contextHeaders = headers && utils.merge(
|
|
2840
|
+
let contextHeaders = headers && utils$1.merge(
|
|
2816
2841
|
headers.common,
|
|
2817
2842
|
headers[config.method]
|
|
2818
2843
|
);
|
|
2819
2844
|
|
|
2820
|
-
|
|
2845
|
+
headers && utils$1.forEach(
|
|
2821
2846
|
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
|
2822
2847
|
(method) => {
|
|
2823
2848
|
delete headers[method];
|
|
@@ -2904,7 +2929,7 @@ class Axios {
|
|
|
2904
2929
|
}
|
|
2905
2930
|
|
|
2906
2931
|
// Provide aliases for supported request methods
|
|
2907
|
-
utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
|
2932
|
+
utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
|
2908
2933
|
/*eslint func-names:0*/
|
|
2909
2934
|
Axios.prototype[method] = function(url, config) {
|
|
2910
2935
|
return this.request(mergeConfig(config || {}, {
|
|
@@ -2915,7 +2940,7 @@ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData
|
|
|
2915
2940
|
};
|
|
2916
2941
|
});
|
|
2917
2942
|
|
|
2918
|
-
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
2943
|
+
utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
2919
2944
|
/*eslint func-names:0*/
|
|
2920
2945
|
|
|
2921
2946
|
function generateHTTPMethod(isForm) {
|
|
@@ -3091,7 +3116,7 @@ function spread(callback) {
|
|
|
3091
3116
|
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
|
3092
3117
|
*/
|
|
3093
3118
|
function isAxiosError(payload) {
|
|
3094
|
-
return utils.isObject(payload) && (payload.isAxiosError === true);
|
|
3119
|
+
return utils$1.isObject(payload) && (payload.isAxiosError === true);
|
|
3095
3120
|
}
|
|
3096
3121
|
|
|
3097
3122
|
const HttpStatusCode = {
|
|
@@ -3178,10 +3203,10 @@ function createInstance(defaultConfig) {
|
|
|
3178
3203
|
const instance = bind(Axios$1.prototype.request, context);
|
|
3179
3204
|
|
|
3180
3205
|
// Copy axios.prototype to instance
|
|
3181
|
-
utils.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
|
|
3206
|
+
utils$1.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
|
|
3182
3207
|
|
|
3183
3208
|
// Copy context to instance
|
|
3184
|
-
utils.extend(instance, context, null, {allOwnKeys: true});
|
|
3209
|
+
utils$1.extend(instance, context, null, {allOwnKeys: true});
|
|
3185
3210
|
|
|
3186
3211
|
// Factory for creating new instances
|
|
3187
3212
|
instance.create = function create(instanceConfig) {
|
|
@@ -3225,7 +3250,9 @@ axios.mergeConfig = mergeConfig;
|
|
|
3225
3250
|
|
|
3226
3251
|
axios.AxiosHeaders = AxiosHeaders$1;
|
|
3227
3252
|
|
|
3228
|
-
axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
3253
|
+
axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
3254
|
+
|
|
3255
|
+
axios.getAdapter = adapters.getAdapter;
|
|
3229
3256
|
|
|
3230
3257
|
axios.HttpStatusCode = HttpStatusCode$1;
|
|
3231
3258
|
|
|
@@ -17029,7 +17056,7 @@ const _abi$3 = [
|
|
|
17029
17056
|
class ERC20__factory {
|
|
17030
17057
|
static abi = _abi$3;
|
|
17031
17058
|
static createInterface() {
|
|
17032
|
-
return new utils$
|
|
17059
|
+
return new utils$2.Interface(_abi$3);
|
|
17033
17060
|
}
|
|
17034
17061
|
static connect(address, signerOrProvider) {
|
|
17035
17062
|
return new Contract$1(address, _abi$3, signerOrProvider);
|
|
@@ -17831,7 +17858,7 @@ class ImmutableSwapProxy__factory extends ContractFactory {
|
|
|
17831
17858
|
static bytecode = _bytecode$2;
|
|
17832
17859
|
static abi = _abi$2;
|
|
17833
17860
|
static createInterface() {
|
|
17834
|
-
return new utils$
|
|
17861
|
+
return new utils$2.Interface(_abi$2);
|
|
17835
17862
|
}
|
|
17836
17863
|
static connect(address, signerOrProvider) {
|
|
17837
17864
|
return new Contract$1(address, _abi$2, signerOrProvider);
|
|
@@ -17959,7 +17986,7 @@ class Multicall__factory extends ContractFactory {
|
|
|
17959
17986
|
static bytecode = _bytecode$1;
|
|
17960
17987
|
static abi = _abi$1;
|
|
17961
17988
|
static createInterface() {
|
|
17962
|
-
return new utils$
|
|
17989
|
+
return new utils$2.Interface(_abi$1);
|
|
17963
17990
|
}
|
|
17964
17991
|
static connect(address, signerOrProvider) {
|
|
17965
17992
|
return new Contract$1(address, _abi$1, signerOrProvider);
|
|
@@ -18983,7 +19010,7 @@ class UniswapV3Pool__factory extends ContractFactory {
|
|
|
18983
19010
|
static bytecode = _bytecode;
|
|
18984
19011
|
static abi = _abi;
|
|
18985
19012
|
static createInterface() {
|
|
18986
|
-
return new utils$
|
|
19013
|
+
return new utils$2.Interface(_abi);
|
|
18987
19014
|
}
|
|
18988
19015
|
static connect(address, signerOrProvider) {
|
|
18989
19016
|
return new Contract$1(address, _abi, signerOrProvider);
|
|
@@ -19190,7 +19217,7 @@ async function getQuotesForRoutes(provider, quoterContractAddress, routes, amoun
|
|
|
19190
19217
|
return quoteResults;
|
|
19191
19218
|
}
|
|
19192
19219
|
try {
|
|
19193
|
-
const decodedQuoteResult = utils$
|
|
19220
|
+
const decodedQuoteResult = utils$2.defaultAbiCoder.decode(returnTypes, promiseResult.value);
|
|
19194
19221
|
if (decodedQuoteResult) {
|
|
19195
19222
|
// The 0th element in each decoded data is going to be the amountOut or amountIn.
|
|
19196
19223
|
const quoteAmount = decodedQuoteResult[amountIndex];
|
|
@@ -20020,7 +20047,7 @@ const CONTRACTS_FOR_CHAIN_ID = {
|
|
|
20020
20047
|
coreFactory: '0xb18c44b211065E69844FbA9AE146DA362104AfBf',
|
|
20021
20048
|
quoterV2: '0x87854A7D4b9BaC3D37f4516A1Ac7F36fB5ad539f',
|
|
20022
20049
|
peripheryRouter: '0x786ec643F231960D4C1A4E336990F8E7bF8f1277',
|
|
20023
|
-
|
|
20050
|
+
immutableSwapProxy: '0xDdBDa144cEbe1cCd68E746CDff8a6e4Be51A9e98',
|
|
20024
20051
|
},
|
|
20025
20052
|
};
|
|
20026
20053
|
const SUPPORTED_SANDBOX_CHAINS = {
|
|
@@ -20129,7 +20156,7 @@ class Exchange {
|
|
|
20129
20156
|
this.nativeTokenService = new NativeTokenService(this.nativeToken, this.wrappedNativeToken);
|
|
20130
20157
|
this.secondaryFees = config.secondaryFees;
|
|
20131
20158
|
this.routerContractAddress = config.chain.contracts.peripheryRouter;
|
|
20132
|
-
this.swapProxyContractAddress = config.chain.contracts.
|
|
20159
|
+
this.swapProxyContractAddress = config.chain.contracts.immutableSwapProxy;
|
|
20133
20160
|
this.provider = new ethers.providers.StaticJsonRpcProvider({
|
|
20134
20161
|
url: config.chain.rpcUrl,
|
|
20135
20162
|
skipFetchSetup: true,
|
|
@@ -25774,7 +25801,7 @@ class APIError extends Error {
|
|
|
25774
25801
|
|
|
25775
25802
|
/* eslint-disable implicit-arrow-linebreak */
|
|
25776
25803
|
const defaultHeaders = {
|
|
25777
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.39.
|
|
25804
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.39.2',
|
|
25778
25805
|
};
|
|
25779
25806
|
/**
|
|
25780
25807
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -27123,7 +27150,7 @@ const GAS_OVERRIDES = {
|
|
|
27123
27150
|
maxPriorityFeePerGas: BigNumber$1.from(101e9),
|
|
27124
27151
|
};
|
|
27125
27152
|
|
|
27126
|
-
const SDK_VERSION_MARKER = '0.39.
|
|
27153
|
+
const SDK_VERSION_MARKER = '0.39.2';
|
|
27127
27154
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
27128
27155
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
27129
27156
|
|
|
@@ -27261,6 +27288,8 @@ class CheckoutConfiguration {
|
|
|
27261
27288
|
const getTokenAllowList = async (config, { type = TokenFilterTypes.ALL, chainId, exclude, }) => {
|
|
27262
27289
|
let tokens = [];
|
|
27263
27290
|
let onRampConfig;
|
|
27291
|
+
let onBridgeConfig;
|
|
27292
|
+
const targetChainId = chainId ?? getL1ChainId(config);
|
|
27264
27293
|
switch (type) {
|
|
27265
27294
|
case TokenFilterTypes.SWAP:
|
|
27266
27295
|
// Fetch tokens from dex-tokens config because
|
|
@@ -27271,16 +27300,19 @@ const getTokenAllowList = async (config, { type = TokenFilterTypes.ALL, chainId,
|
|
|
27271
27300
|
break;
|
|
27272
27301
|
case TokenFilterTypes.ONRAMP:
|
|
27273
27302
|
onRampConfig = (await config.remote.getConfig('onramp'));
|
|
27274
|
-
|
|
27275
|
-
if (!onRampConfig) {
|
|
27303
|
+
if (!onRampConfig)
|
|
27276
27304
|
tokens = [];
|
|
27277
|
-
}
|
|
27278
27305
|
tokens = onRampConfig[OnRampProvider.TRANSAK]?.tokens || [];
|
|
27279
27306
|
break;
|
|
27280
27307
|
case TokenFilterTypes.BRIDGE:
|
|
27308
|
+
onBridgeConfig = (await config.remote.getConfig('bridge'));
|
|
27309
|
+
if (!onBridgeConfig)
|
|
27310
|
+
tokens = [];
|
|
27311
|
+
tokens = onBridgeConfig[targetChainId]?.tokens || [];
|
|
27312
|
+
break;
|
|
27281
27313
|
case TokenFilterTypes.ALL:
|
|
27282
27314
|
default:
|
|
27283
|
-
tokens = (await config.remote.getTokensConfig(
|
|
27315
|
+
tokens = (await config.remote.getTokensConfig(targetChainId)).allowed;
|
|
27284
27316
|
}
|
|
27285
27317
|
if (!exclude || exclude?.length === 0)
|
|
27286
27318
|
return { tokens };
|
|
@@ -27467,7 +27499,7 @@ const getBalance = async (config, web3Provider, walletAddress) => await withChec
|
|
|
27467
27499
|
const balance = await web3Provider.getBalance(walletAddress);
|
|
27468
27500
|
return {
|
|
27469
27501
|
balance,
|
|
27470
|
-
formattedBalance: utils$
|
|
27502
|
+
formattedBalance: utils$2.formatUnits(balance, networkInfo.nativeCurrency.decimals),
|
|
27471
27503
|
token: networkInfo.nativeCurrency,
|
|
27472
27504
|
};
|
|
27473
27505
|
}, { type: CheckoutErrorType.GET_BALANCE_ERROR });
|
|
@@ -27479,7 +27511,7 @@ async function getERC20Balance(web3Provider, walletAddress, tokenAddress) {
|
|
|
27479
27511
|
contract.balanceOf(walletAddress),
|
|
27480
27512
|
])
|
|
27481
27513
|
.then(([tokenInfo, balance]) => {
|
|
27482
|
-
const formattedBalance = utils$
|
|
27514
|
+
const formattedBalance = utils$2.formatUnits(balance, tokenInfo.decimals);
|
|
27483
27515
|
return {
|
|
27484
27516
|
balance,
|
|
27485
27517
|
formattedBalance,
|
|
@@ -27578,7 +27610,7 @@ const getIndexerBalance = async (config, walletAddress, chainId, filterTokens) =
|
|
|
27578
27610
|
...tokenData,
|
|
27579
27611
|
decimals,
|
|
27580
27612
|
};
|
|
27581
|
-
const formattedBalance = utils$
|
|
27613
|
+
const formattedBalance = utils$2.formatUnits(item.value, token.decimals);
|
|
27582
27614
|
balances.push({ balance, formattedBalance, token });
|
|
27583
27615
|
});
|
|
27584
27616
|
return { balances };
|
|
@@ -27928,7 +27960,7 @@ async function swapGasEstimator(config) {
|
|
|
27928
27960
|
try {
|
|
27929
27961
|
const exchange = await createExchangeInstance(chainId, config);
|
|
27930
27962
|
// Create a fake transaction to get the gas from the quote
|
|
27931
|
-
const { swap } = await exchange.getUnsignedSwapTxFromAmountIn(DUMMY_WALLET_ADDRESS, inAddress, outAddress, BigNumber$1.from(utils$
|
|
27963
|
+
const { swap } = await exchange.getUnsignedSwapTxFromAmountIn(DUMMY_WALLET_ADDRESS, inAddress, outAddress, BigNumber$1.from(utils$2.parseUnits('1', DEFAULT_TOKEN_DECIMALS)));
|
|
27932
27964
|
if (!swap.gasFeeEstimate) {
|
|
27933
27965
|
return {
|
|
27934
27966
|
gasEstimateType: GasEstimateType.SWAP,
|
|
@@ -28447,7 +28479,7 @@ const getTokenBalanceRequirement = (itemRequirement, balances) => {
|
|
|
28447
28479
|
type: ItemType.NATIVE,
|
|
28448
28480
|
delta: {
|
|
28449
28481
|
balance: delta,
|
|
28450
|
-
formattedBalance: utils$
|
|
28482
|
+
formattedBalance: utils$2.formatUnits(delta, decimals),
|
|
28451
28483
|
},
|
|
28452
28484
|
current: {
|
|
28453
28485
|
...tokenBalanceResult,
|
|
@@ -28457,7 +28489,7 @@ const getTokenBalanceRequirement = (itemRequirement, balances) => {
|
|
|
28457
28489
|
...tokenBalanceResult,
|
|
28458
28490
|
type: ItemType.NATIVE,
|
|
28459
28491
|
balance: BigNumber$1.from(itemRequirement.amount),
|
|
28460
|
-
formattedBalance: utils$
|
|
28492
|
+
formattedBalance: utils$2.formatUnits(itemRequirement.amount, decimals),
|
|
28461
28493
|
},
|
|
28462
28494
|
};
|
|
28463
28495
|
}
|
|
@@ -28480,13 +28512,13 @@ const getTokenBalanceRequirement = (itemRequirement, balances) => {
|
|
|
28480
28512
|
type: ItemType.ERC20,
|
|
28481
28513
|
delta: {
|
|
28482
28514
|
balance: delta,
|
|
28483
|
-
formattedBalance: utils$
|
|
28515
|
+
formattedBalance: utils$2.formatUnits(delta, decimals),
|
|
28484
28516
|
},
|
|
28485
28517
|
current: tokenBalanceResult,
|
|
28486
28518
|
required: {
|
|
28487
28519
|
...tokenBalanceResult,
|
|
28488
28520
|
balance: BigNumber$1.from(itemRequirement.amount),
|
|
28489
|
-
formattedBalance: utils$
|
|
28521
|
+
formattedBalance: utils$2.formatUnits(itemRequirement.amount, decimals),
|
|
28490
28522
|
},
|
|
28491
28523
|
};
|
|
28492
28524
|
};
|
|
@@ -28858,7 +28890,7 @@ const constructFees$1 = (approvalGasFee, swapGasFee, swapFees) => {
|
|
|
28858
28890
|
let approvalToken;
|
|
28859
28891
|
if (approvalGasFee) {
|
|
28860
28892
|
approvalGasFeeAmount = approvalGasFee.value;
|
|
28861
|
-
approvalGasFeeFormatted = utils$
|
|
28893
|
+
approvalGasFeeFormatted = utils$2.formatUnits(approvalGasFee.value, approvalGasFee.token.decimals);
|
|
28862
28894
|
approvalToken = {
|
|
28863
28895
|
name: approvalGasFee.token.name ?? '',
|
|
28864
28896
|
symbol: approvalGasFee.token.symbol ?? '',
|
|
@@ -28871,7 +28903,7 @@ const constructFees$1 = (approvalGasFee, swapGasFee, swapFees) => {
|
|
|
28871
28903
|
let swapGasToken;
|
|
28872
28904
|
if (swapGasFee) {
|
|
28873
28905
|
swapGasFeeAmount = swapGasFee.value;
|
|
28874
|
-
swapGasFeeFormatted = utils$
|
|
28906
|
+
swapGasFeeFormatted = utils$2.formatUnits(swapGasFee.value, swapGasFee.token.decimals);
|
|
28875
28907
|
swapGasToken = {
|
|
28876
28908
|
name: swapGasFee.token.name ?? '',
|
|
28877
28909
|
symbol: swapGasFee.token.symbol ?? '',
|
|
@@ -28884,7 +28916,7 @@ const constructFees$1 = (approvalGasFee, swapGasFee, swapFees) => {
|
|
|
28884
28916
|
fees.push({
|
|
28885
28917
|
type: FeeType.SWAP_FEE,
|
|
28886
28918
|
amount: swapFee.amount.value,
|
|
28887
|
-
formattedAmount: utils$
|
|
28919
|
+
formattedAmount: utils$2.formatUnits(swapFee.amount.value, swapFee.amount.token.decimals),
|
|
28888
28920
|
token: {
|
|
28889
28921
|
name: swapFee.amount.token.name ?? '',
|
|
28890
28922
|
symbol: swapFee.amount.token.symbol ?? '',
|
|
@@ -28922,7 +28954,7 @@ const constructSwapRoute = (chainId, fundsRequired, userBalance, fees) => {
|
|
|
28922
28954
|
type,
|
|
28923
28955
|
fundsRequired: {
|
|
28924
28956
|
amount: fundsRequired,
|
|
28925
|
-
formattedAmount: utils$
|
|
28957
|
+
formattedAmount: utils$2.formatUnits(fundsRequired, userBalance.token.decimals),
|
|
28926
28958
|
},
|
|
28927
28959
|
userBalance: {
|
|
28928
28960
|
balance: userBalance.balance,
|
|
@@ -29138,28 +29170,23 @@ const filterTokens = (allowedTokens, balances) => {
|
|
|
29138
29170
|
};
|
|
29139
29171
|
const allowListCheckForOnRamp = async (config, availableRoutingOptions) => {
|
|
29140
29172
|
if (availableRoutingOptions.onRamp) {
|
|
29141
|
-
const onRampOptions = await config.
|
|
29142
|
-
|
|
29143
|
-
Object.entries(onRampOptions)
|
|
29144
|
-
.forEach(([onRampProvider, onRampProviderConfig]) => {
|
|
29145
|
-
// Allowed list per onRamp provider
|
|
29146
|
-
onRampAllowList[onRampProvider] = onRampProviderConfig.tokens ?? [];
|
|
29147
|
-
});
|
|
29148
|
-
return onRampAllowList;
|
|
29173
|
+
const onRampOptions = (await getTokenAllowList(config, { type: TokenFilterTypes.ONRAMP }));
|
|
29174
|
+
return onRampOptions.tokens;
|
|
29149
29175
|
}
|
|
29150
|
-
return
|
|
29176
|
+
return [];
|
|
29151
29177
|
};
|
|
29152
29178
|
const allowListCheckForBridge = async (config, tokenBalances, availableRoutingOptions) => {
|
|
29153
29179
|
if (availableRoutingOptions.bridge) {
|
|
29154
|
-
const
|
|
29155
|
-
const
|
|
29180
|
+
const chainId = getL1ChainId(config);
|
|
29181
|
+
const allowedTokens = (await getTokenAllowList(config, { type: TokenFilterTypes.BRIDGE, chainId })).tokens;
|
|
29182
|
+
const balances = tokenBalances.get(chainId);
|
|
29156
29183
|
return filterTokens(allowedTokens, balances);
|
|
29157
29184
|
}
|
|
29158
29185
|
return [];
|
|
29159
29186
|
};
|
|
29160
29187
|
const allowListCheckForSwap = async (config, tokenBalances, availableRoutingOptions) => {
|
|
29161
29188
|
if (availableRoutingOptions.swap) {
|
|
29162
|
-
const allowedTokens = (await config.
|
|
29189
|
+
const allowedTokens = (await getTokenAllowList(config, { type: TokenFilterTypes.SWAP })).tokens;
|
|
29163
29190
|
const balances = tokenBalances.get(getL2ChainId(config));
|
|
29164
29191
|
return filterTokens(allowedTokens, balances);
|
|
29165
29192
|
}
|
|
@@ -29261,7 +29288,7 @@ const constructFees = (bridgeGasFee, bridgeFee, imtblFee, approvalGasFee, token)
|
|
|
29261
29288
|
bridgeFees.push({
|
|
29262
29289
|
type: FeeType.BRIDGE_FEE,
|
|
29263
29290
|
amount: bridgeFee,
|
|
29264
|
-
formattedAmount: utils$
|
|
29291
|
+
formattedAmount: utils$2.formatUnits(bridgeFee, bridgeFeeDecimals),
|
|
29265
29292
|
token,
|
|
29266
29293
|
});
|
|
29267
29294
|
}
|
|
@@ -29269,7 +29296,7 @@ const constructFees = (bridgeGasFee, bridgeFee, imtblFee, approvalGasFee, token)
|
|
|
29269
29296
|
bridgeFees.push({
|
|
29270
29297
|
type: FeeType.IMMUTABLE_FEE,
|
|
29271
29298
|
amount: imtblFee,
|
|
29272
|
-
formattedAmount: utils$
|
|
29299
|
+
formattedAmount: utils$2.formatUnits(imtblFee, bridgeFeeDecimals),
|
|
29273
29300
|
token,
|
|
29274
29301
|
});
|
|
29275
29302
|
}
|
|
@@ -29277,13 +29304,13 @@ const constructFees = (bridgeGasFee, bridgeFee, imtblFee, approvalGasFee, token)
|
|
|
29277
29304
|
approvalGasFee: {
|
|
29278
29305
|
type: FeeType.GAS,
|
|
29279
29306
|
amount: approvalGasFee,
|
|
29280
|
-
formattedAmount: utils$
|
|
29307
|
+
formattedAmount: utils$2.formatUnits(approvalGasFee, DEFAULT_TOKEN_DECIMALS$1),
|
|
29281
29308
|
token,
|
|
29282
29309
|
},
|
|
29283
29310
|
bridgeGasFee: {
|
|
29284
29311
|
type: FeeType.GAS,
|
|
29285
29312
|
amount: bridgeGasFee,
|
|
29286
|
-
formattedAmount: utils$
|
|
29313
|
+
formattedAmount: utils$2.formatUnits(bridgeGasFee, DEFAULT_TOKEN_DECIMALS$1),
|
|
29287
29314
|
token,
|
|
29288
29315
|
},
|
|
29289
29316
|
bridgeFees,
|
|
@@ -29488,7 +29515,7 @@ const constructBridgeRequirements = (dexQuotes, l1balances, l2balances, l1tol2ad
|
|
|
29488
29515
|
}
|
|
29489
29516
|
bridgeRequirements.push({
|
|
29490
29517
|
amount: amountToBridge,
|
|
29491
|
-
formattedAmount: utils$
|
|
29518
|
+
formattedAmount: utils$2.formatUnits(amountToBridge, l1balance.token.decimals),
|
|
29492
29519
|
// L2 address is used for the bridge requirement as the bridge route uses the indexer to find L1 address
|
|
29493
29520
|
l2address,
|
|
29494
29521
|
});
|
|
@@ -29586,7 +29613,7 @@ const modifyTokenBalancesWithBridgedAmount = (config, tokenBalances, l2balances,
|
|
|
29586
29613
|
const tokenInfo = swappableTokens.find((token) => token.address === l2address);
|
|
29587
29614
|
balanceMap.set(l2address, {
|
|
29588
29615
|
balance: newBalance,
|
|
29589
|
-
formattedBalance: utils$
|
|
29616
|
+
formattedBalance: utils$2.formatUnits(newBalance, tokenInfo.decimals),
|
|
29590
29617
|
token: tokenInfo,
|
|
29591
29618
|
});
|
|
29592
29619
|
}
|
|
@@ -29717,10 +29744,10 @@ const onRampRoute = async (config, availableRoutingOptions, balanceRequirement)
|
|
|
29717
29744
|
return undefined;
|
|
29718
29745
|
const { required, current, delta } = balanceRequirement;
|
|
29719
29746
|
let hasAllowList = false;
|
|
29720
|
-
const
|
|
29721
|
-
|
|
29722
|
-
if (
|
|
29723
|
-
hasAllowList =
|
|
29747
|
+
const onRampAllowList = await allowListCheckForOnRamp(config, availableRoutingOptions);
|
|
29748
|
+
onRampAllowList.forEach((token) => {
|
|
29749
|
+
if (token.address === required.token?.address) {
|
|
29750
|
+
hasAllowList = true;
|
|
29724
29751
|
}
|
|
29725
29752
|
});
|
|
29726
29753
|
if (!hasAllowList)
|
|
@@ -30108,7 +30135,7 @@ const calculateFeesPercent = (orderFee, amountBn) => {
|
|
|
30108
30135
|
};
|
|
30109
30136
|
const calculateFeesToken = (orderFee, decimals) => {
|
|
30110
30137
|
const feeToken = orderFee.amount;
|
|
30111
|
-
const bnFeeAmount = utils$
|
|
30138
|
+
const bnFeeAmount = utils$2.parseUnits(feeToken.token, decimals);
|
|
30112
30139
|
return bnFeeAmount;
|
|
30113
30140
|
};
|
|
30114
30141
|
const calculateFees = (orderFees, weiAmount, decimals = 18) => {
|
|
@@ -30364,7 +30391,7 @@ const getERC721Requirement = (id, contractAddress, spenderAddress) => ({
|
|
|
30364
30391
|
spenderAddress,
|
|
30365
30392
|
});
|
|
30366
30393
|
const getBuyToken = (buyToken, decimals = 18) => {
|
|
30367
|
-
const bnAmount = utils$
|
|
30394
|
+
const bnAmount = utils$2.parseUnits(buyToken.amount, decimals);
|
|
30368
30395
|
if (buyToken.type === ItemType.NATIVE) {
|
|
30369
30396
|
return {
|
|
30370
30397
|
type: ItemType.NATIVE,
|
|
@@ -30550,13 +30577,13 @@ async function getItemRequirementsFromRequirements(provider, requirements) {
|
|
|
30550
30577
|
if (itemRequirementParam.type === ItemType.NATIVE) {
|
|
30551
30578
|
return {
|
|
30552
30579
|
...itemRequirementParam,
|
|
30553
|
-
amount: utils$
|
|
30580
|
+
amount: utils$2.parseUnits(itemRequirementParam.amount, 18),
|
|
30554
30581
|
};
|
|
30555
30582
|
}
|
|
30556
30583
|
if (itemRequirementParam.type === ItemType.ERC20) {
|
|
30557
30584
|
return {
|
|
30558
30585
|
...itemRequirementParam,
|
|
30559
|
-
amount: utils$
|
|
30586
|
+
amount: utils$2.parseUnits(itemRequirementParam.amount, decimals[index]),
|
|
30560
30587
|
};
|
|
30561
30588
|
}
|
|
30562
30589
|
return itemRequirementParam;
|