@imtbl/sdk 0.4.0-alpha → 0.4.0-alpha.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/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var axios$2 = require('axios');
3
+ var globalAxios$1 = require('axios');
4
4
  var coreSdk = require('@imtbl/core-sdk');
5
5
  var oidcClientTs = require('oidc-client-ts');
6
6
  var jwt_decode = require('jwt-decode');
@@ -9,11 +9,8 @@ var oidc = require('@magic-ext/oidc');
9
9
  var BN$2 = require('bn.js');
10
10
  var encUtils = require('enc-utils');
11
11
  var providers = require('@ethersproject/providers');
12
- var events = require('events');
13
- var ethers = require('ethers');
14
- var abi = require('@0xsequence/abi');
15
- var config = require('@0xsequence/config');
16
12
  var FormData$2 = require('form-data');
13
+ var ethers = require('ethers');
17
14
  var seaportJs = require('@opensea/seaport-js');
18
15
  var units = require('@ethersproject/units');
19
16
  var bignumber = require('@ethersproject/bignumber');
@@ -38,3323 +35,27 @@ function _interopNamespaceDefault(e) {
38
35
  get: function () { return e[k]; }
39
36
  });
40
37
  }
41
- });
42
- }
43
- n.default = e;
44
- return Object.freeze(n);
45
- }
46
-
47
- var encUtils__namespace = /*#__PURE__*/_interopNamespaceDefault(encUtils);
48
-
49
- exports.Environment = void 0;
50
- (function (Environment) {
51
- Environment["PRODUCTION"] = "production";
52
- Environment["SANDBOX"] = "sandbox";
53
- })(exports.Environment || (exports.Environment = {}));
54
- class ImmutableConfiguration {
55
- environment;
56
- apiKey;
57
- constructor(options) {
58
- this.environment = options.environment;
59
- this.apiKey = options.apiKey;
60
- }
61
- }
62
-
63
- function bind$1(fn, thisArg) {
64
- return function wrap() {
65
- return fn.apply(thisArg, arguments);
66
- };
67
- }
68
-
69
- // utils is a library of generic helper functions non-specific to axios
70
-
71
- const {toString: toString$1} = Object.prototype;
72
- const {getPrototypeOf: getPrototypeOf$1} = Object;
73
-
74
- const kindOf$1 = (cache => thing => {
75
- const str = toString$1.call(thing);
76
- return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
77
- })(Object.create(null));
78
-
79
- const kindOfTest$1 = (type) => {
80
- type = type.toLowerCase();
81
- return (thing) => kindOf$1(thing) === type
82
- };
83
-
84
- const typeOfTest$1 = type => thing => typeof thing === type;
85
-
86
- /**
87
- * Determine if a value is an Array
88
- *
89
- * @param {Object} val The value to test
90
- *
91
- * @returns {boolean} True if value is an Array, otherwise false
92
- */
93
- const {isArray: isArray$1} = Array;
94
-
95
- /**
96
- * Determine if a value is undefined
97
- *
98
- * @param {*} val The value to test
99
- *
100
- * @returns {boolean} True if the value is undefined, otherwise false
101
- */
102
- const isUndefined$1 = typeOfTest$1('undefined');
103
-
104
- /**
105
- * Determine if a value is a Buffer
106
- *
107
- * @param {*} val The value to test
108
- *
109
- * @returns {boolean} True if value is a Buffer, otherwise false
110
- */
111
- function isBuffer$1(val) {
112
- return val !== null && !isUndefined$1(val) && val.constructor !== null && !isUndefined$1(val.constructor)
113
- && isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
114
- }
115
-
116
- /**
117
- * Determine if a value is an ArrayBuffer
118
- *
119
- * @param {*} val The value to test
120
- *
121
- * @returns {boolean} True if value is an ArrayBuffer, otherwise false
122
- */
123
- const isArrayBuffer$1 = kindOfTest$1('ArrayBuffer');
124
-
125
-
126
- /**
127
- * Determine if a value is a view on an ArrayBuffer
128
- *
129
- * @param {*} val The value to test
130
- *
131
- * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
132
- */
133
- function isArrayBufferView$1(val) {
134
- let result;
135
- if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
136
- result = ArrayBuffer.isView(val);
137
- } else {
138
- result = (val) && (val.buffer) && (isArrayBuffer$1(val.buffer));
139
- }
140
- return result;
141
- }
142
-
143
- /**
144
- * Determine if a value is a String
145
- *
146
- * @param {*} val The value to test
147
- *
148
- * @returns {boolean} True if value is a String, otherwise false
149
- */
150
- const isString$2 = typeOfTest$1('string');
151
-
152
- /**
153
- * Determine if a value is a Function
154
- *
155
- * @param {*} val The value to test
156
- * @returns {boolean} True if value is a Function, otherwise false
157
- */
158
- const isFunction$1 = typeOfTest$1('function');
159
-
160
- /**
161
- * Determine if a value is a Number
162
- *
163
- * @param {*} val The value to test
164
- *
165
- * @returns {boolean} True if value is a Number, otherwise false
166
- */
167
- const isNumber$1 = typeOfTest$1('number');
168
-
169
- /**
170
- * Determine if a value is an Object
171
- *
172
- * @param {*} thing The value to test
173
- *
174
- * @returns {boolean} True if value is an Object, otherwise false
175
- */
176
- const isObject$1 = (thing) => thing !== null && typeof thing === 'object';
177
-
178
- /**
179
- * Determine if a value is a Boolean
180
- *
181
- * @param {*} thing The value to test
182
- * @returns {boolean} True if value is a Boolean, otherwise false
183
- */
184
- const isBoolean$1 = thing => thing === true || thing === false;
185
-
186
- /**
187
- * Determine if a value is a plain Object
188
- *
189
- * @param {*} val The value to test
190
- *
191
- * @returns {boolean} True if value is a plain Object, otherwise false
192
- */
193
- const isPlainObject$1 = (val) => {
194
- if (kindOf$1(val) !== 'object') {
195
- return false;
196
- }
197
-
198
- const prototype = getPrototypeOf$1(val);
199
- return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
200
- };
201
-
202
- /**
203
- * Determine if a value is a Date
204
- *
205
- * @param {*} val The value to test
206
- *
207
- * @returns {boolean} True if value is a Date, otherwise false
208
- */
209
- const isDate$1 = kindOfTest$1('Date');
210
-
211
- /**
212
- * Determine if a value is a File
213
- *
214
- * @param {*} val The value to test
215
- *
216
- * @returns {boolean} True if value is a File, otherwise false
217
- */
218
- const isFile$1 = kindOfTest$1('File');
219
-
220
- /**
221
- * Determine if a value is a Blob
222
- *
223
- * @param {*} val The value to test
224
- *
225
- * @returns {boolean} True if value is a Blob, otherwise false
226
- */
227
- const isBlob$2 = kindOfTest$1('Blob');
228
-
229
- /**
230
- * Determine if a value is a FileList
231
- *
232
- * @param {*} val The value to test
233
- *
234
- * @returns {boolean} True if value is a File, otherwise false
235
- */
236
- const isFileList$1 = kindOfTest$1('FileList');
237
-
238
- /**
239
- * Determine if a value is a Stream
240
- *
241
- * @param {*} val The value to test
242
- *
243
- * @returns {boolean} True if value is a Stream, otherwise false
244
- */
245
- const isStream$1 = (val) => isObject$1(val) && isFunction$1(val.pipe);
246
-
247
- /**
248
- * Determine if a value is a FormData
249
- *
250
- * @param {*} thing The value to test
251
- *
252
- * @returns {boolean} True if value is an FormData, otherwise false
253
- */
254
- const isFormData$2 = (thing) => {
255
- let kind;
256
- return thing && (
257
- (typeof FormData === 'function' && thing instanceof FormData) || (
258
- isFunction$1(thing.append) && (
259
- (kind = kindOf$1(thing)) === 'formdata' ||
260
- // detect form-data instance
261
- (kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
262
- )
263
- )
264
- )
265
- };
266
-
267
- /**
268
- * Determine if a value is a URLSearchParams object
269
- *
270
- * @param {*} val The value to test
271
- *
272
- * @returns {boolean} True if value is a URLSearchParams object, otherwise false
273
- */
274
- const isURLSearchParams$1 = kindOfTest$1('URLSearchParams');
275
-
276
- /**
277
- * Trim excess whitespace off the beginning and end of a string
278
- *
279
- * @param {String} str The String to trim
280
- *
281
- * @returns {String} The String freed of excess whitespace
282
- */
283
- const trim$1 = (str) => str.trim ?
284
- str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
285
-
286
- /**
287
- * Iterate over an Array or an Object invoking a function for each item.
288
- *
289
- * If `obj` is an Array callback will be called passing
290
- * the value, index, and complete array for each item.
291
- *
292
- * If 'obj' is an Object callback will be called passing
293
- * the value, key, and complete object for each property.
294
- *
295
- * @param {Object|Array} obj The object to iterate
296
- * @param {Function} fn The callback to invoke for each item
297
- *
298
- * @param {Boolean} [allOwnKeys = false]
299
- * @returns {any}
300
- */
301
- function forEach$1(obj, fn, {allOwnKeys = false} = {}) {
302
- // Don't bother if no value provided
303
- if (obj === null || typeof obj === 'undefined') {
304
- return;
305
- }
306
-
307
- let i;
308
- let l;
309
-
310
- // Force an array if not already something iterable
311
- if (typeof obj !== 'object') {
312
- /*eslint no-param-reassign:0*/
313
- obj = [obj];
314
- }
315
-
316
- if (isArray$1(obj)) {
317
- // Iterate over array values
318
- for (i = 0, l = obj.length; i < l; i++) {
319
- fn.call(null, obj[i], i, obj);
320
- }
321
- } else {
322
- // Iterate over object keys
323
- const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
324
- const len = keys.length;
325
- let key;
326
-
327
- for (i = 0; i < len; i++) {
328
- key = keys[i];
329
- fn.call(null, obj[key], key, obj);
330
- }
331
- }
332
- }
333
-
334
- function findKey$1(obj, key) {
335
- key = key.toLowerCase();
336
- const keys = Object.keys(obj);
337
- let i = keys.length;
338
- let _key;
339
- while (i-- > 0) {
340
- _key = keys[i];
341
- if (key === _key.toLowerCase()) {
342
- return _key;
343
- }
344
- }
345
- return null;
346
- }
347
-
348
- const _global$1 = (() => {
349
- /*eslint no-undef:0*/
350
- if (typeof globalThis !== "undefined") return globalThis;
351
- return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
352
- })();
353
-
354
- const isContextDefined$1 = (context) => !isUndefined$1(context) && context !== _global$1;
355
-
356
- /**
357
- * Accepts varargs expecting each argument to be an object, then
358
- * immutably merges the properties of each object and returns result.
359
- *
360
- * When multiple objects contain the same key the later object in
361
- * the arguments list will take precedence.
362
- *
363
- * Example:
364
- *
365
- * ```js
366
- * var result = merge({foo: 123}, {foo: 456});
367
- * console.log(result.foo); // outputs 456
368
- * ```
369
- *
370
- * @param {Object} obj1 Object to merge
371
- *
372
- * @returns {Object} Result of all merge properties
373
- */
374
- function merge$1(/* obj1, obj2, obj3, ... */) {
375
- const {caseless} = isContextDefined$1(this) && this || {};
376
- const result = {};
377
- const assignValue = (val, key) => {
378
- const targetKey = caseless && findKey$1(result, key) || key;
379
- if (isPlainObject$1(result[targetKey]) && isPlainObject$1(val)) {
380
- result[targetKey] = merge$1(result[targetKey], val);
381
- } else if (isPlainObject$1(val)) {
382
- result[targetKey] = merge$1({}, val);
383
- } else if (isArray$1(val)) {
384
- result[targetKey] = val.slice();
385
- } else {
386
- result[targetKey] = val;
387
- }
388
- };
389
-
390
- for (let i = 0, l = arguments.length; i < l; i++) {
391
- arguments[i] && forEach$1(arguments[i], assignValue);
392
- }
393
- return result;
394
- }
395
-
396
- /**
397
- * Extends object a by mutably adding to it the properties of object b.
398
- *
399
- * @param {Object} a The object to be extended
400
- * @param {Object} b The object to copy properties from
401
- * @param {Object} thisArg The object to bind function to
402
- *
403
- * @param {Boolean} [allOwnKeys]
404
- * @returns {Object} The resulting value of object a
405
- */
406
- const extend$1 = (a, b, thisArg, {allOwnKeys}= {}) => {
407
- forEach$1(b, (val, key) => {
408
- if (thisArg && isFunction$1(val)) {
409
- a[key] = bind$1(val, thisArg);
410
- } else {
411
- a[key] = val;
412
- }
413
- }, {allOwnKeys});
414
- return a;
415
- };
416
-
417
- /**
418
- * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
419
- *
420
- * @param {string} content with BOM
421
- *
422
- * @returns {string} content value without BOM
423
- */
424
- const stripBOM$1 = (content) => {
425
- if (content.charCodeAt(0) === 0xFEFF) {
426
- content = content.slice(1);
427
- }
428
- return content;
429
- };
430
-
431
- /**
432
- * Inherit the prototype methods from one constructor into another
433
- * @param {function} constructor
434
- * @param {function} superConstructor
435
- * @param {object} [props]
436
- * @param {object} [descriptors]
437
- *
438
- * @returns {void}
439
- */
440
- const inherits$1 = (constructor, superConstructor, props, descriptors) => {
441
- constructor.prototype = Object.create(superConstructor.prototype, descriptors);
442
- constructor.prototype.constructor = constructor;
443
- Object.defineProperty(constructor, 'super', {
444
- value: superConstructor.prototype
445
- });
446
- props && Object.assign(constructor.prototype, props);
447
- };
448
-
449
- /**
450
- * Resolve object with deep prototype chain to a flat object
451
- * @param {Object} sourceObj source object
452
- * @param {Object} [destObj]
453
- * @param {Function|Boolean} [filter]
454
- * @param {Function} [propFilter]
455
- *
456
- * @returns {Object}
457
- */
458
- const toFlatObject$1 = (sourceObj, destObj, filter, propFilter) => {
459
- let props;
460
- let i;
461
- let prop;
462
- const merged = {};
463
-
464
- destObj = destObj || {};
465
- // eslint-disable-next-line no-eq-null,eqeqeq
466
- if (sourceObj == null) return destObj;
467
-
468
- do {
469
- props = Object.getOwnPropertyNames(sourceObj);
470
- i = props.length;
471
- while (i-- > 0) {
472
- prop = props[i];
473
- if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
474
- destObj[prop] = sourceObj[prop];
475
- merged[prop] = true;
476
- }
477
- }
478
- sourceObj = filter !== false && getPrototypeOf$1(sourceObj);
479
- } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
480
-
481
- return destObj;
482
- };
483
-
484
- /**
485
- * Determines whether a string ends with the characters of a specified string
486
- *
487
- * @param {String} str
488
- * @param {String} searchString
489
- * @param {Number} [position= 0]
490
- *
491
- * @returns {boolean}
492
- */
493
- const endsWith$1 = (str, searchString, position) => {
494
- str = String(str);
495
- if (position === undefined || position > str.length) {
496
- position = str.length;
497
- }
498
- position -= searchString.length;
499
- const lastIndex = str.indexOf(searchString, position);
500
- return lastIndex !== -1 && lastIndex === position;
501
- };
502
-
503
-
504
- /**
505
- * Returns new array from array like object or null if failed
506
- *
507
- * @param {*} [thing]
508
- *
509
- * @returns {?Array}
510
- */
511
- const toArray$1 = (thing) => {
512
- if (!thing) return null;
513
- if (isArray$1(thing)) return thing;
514
- let i = thing.length;
515
- if (!isNumber$1(i)) return null;
516
- const arr = new Array(i);
517
- while (i-- > 0) {
518
- arr[i] = thing[i];
519
- }
520
- return arr;
521
- };
522
-
523
- /**
524
- * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
525
- * thing passed in is an instance of Uint8Array
526
- *
527
- * @param {TypedArray}
528
- *
529
- * @returns {Array}
530
- */
531
- // eslint-disable-next-line func-names
532
- const isTypedArray$1 = (TypedArray => {
533
- // eslint-disable-next-line func-names
534
- return thing => {
535
- return TypedArray && thing instanceof TypedArray;
536
- };
537
- })(typeof Uint8Array !== 'undefined' && getPrototypeOf$1(Uint8Array));
538
-
539
- /**
540
- * For each entry in the object, call the function with the key and value.
541
- *
542
- * @param {Object<any, any>} obj - The object to iterate over.
543
- * @param {Function} fn - The function to call for each entry.
544
- *
545
- * @returns {void}
546
- */
547
- const forEachEntry$1 = (obj, fn) => {
548
- const generator = obj && obj[Symbol.iterator];
549
-
550
- const iterator = generator.call(obj);
551
-
552
- let result;
553
-
554
- while ((result = iterator.next()) && !result.done) {
555
- const pair = result.value;
556
- fn.call(obj, pair[0], pair[1]);
557
- }
558
- };
559
-
560
- /**
561
- * It takes a regular expression and a string, and returns an array of all the matches
562
- *
563
- * @param {string} regExp - The regular expression to match against.
564
- * @param {string} str - The string to search.
565
- *
566
- * @returns {Array<boolean>}
567
- */
568
- const matchAll$1 = (regExp, str) => {
569
- let matches;
570
- const arr = [];
571
-
572
- while ((matches = regExp.exec(str)) !== null) {
573
- arr.push(matches);
574
- }
575
-
576
- return arr;
577
- };
578
-
579
- /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
580
- const isHTMLForm$1 = kindOfTest$1('HTMLFormElement');
581
-
582
- const toCamelCase$1 = str => {
583
- return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
584
- function replacer(m, p1, p2) {
585
- return p1.toUpperCase() + p2;
586
- }
587
- );
588
- };
589
-
590
- /* Creating a function that will check if an object has a property. */
591
- const hasOwnProperty$1 = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
592
-
593
- /**
594
- * Determine if a value is a RegExp object
595
- *
596
- * @param {*} val The value to test
597
- *
598
- * @returns {boolean} True if value is a RegExp object, otherwise false
599
- */
600
- const isRegExp$1 = kindOfTest$1('RegExp');
601
-
602
- const reduceDescriptors$1 = (obj, reducer) => {
603
- const descriptors = Object.getOwnPropertyDescriptors(obj);
604
- const reducedDescriptors = {};
605
-
606
- forEach$1(descriptors, (descriptor, name) => {
607
- if (reducer(descriptor, name, obj) !== false) {
608
- reducedDescriptors[name] = descriptor;
609
- }
610
- });
611
-
612
- Object.defineProperties(obj, reducedDescriptors);
613
- };
614
-
615
- /**
616
- * Makes all methods read-only
617
- * @param {Object} obj
618
- */
619
-
620
- const freezeMethods$1 = (obj) => {
621
- reduceDescriptors$1(obj, (descriptor, name) => {
622
- // skip restricted props in strict mode
623
- if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
624
- return false;
625
- }
626
-
627
- const value = obj[name];
628
-
629
- if (!isFunction$1(value)) return;
630
-
631
- descriptor.enumerable = false;
632
-
633
- if ('writable' in descriptor) {
634
- descriptor.writable = false;
635
- return;
636
- }
637
-
638
- if (!descriptor.set) {
639
- descriptor.set = () => {
640
- throw Error('Can not rewrite read-only method \'' + name + '\'');
641
- };
642
- }
643
- });
644
- };
645
-
646
- const toObjectSet$1 = (arrayOrString, delimiter) => {
647
- const obj = {};
648
-
649
- const define = (arr) => {
650
- arr.forEach(value => {
651
- obj[value] = true;
652
- });
653
- };
654
-
655
- isArray$1(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
656
-
657
- return obj;
658
- };
659
-
660
- const noop$1 = () => {};
661
-
662
- const toFiniteNumber$1 = (value, defaultValue) => {
663
- value = +value;
664
- return Number.isFinite(value) ? value : defaultValue;
665
- };
666
-
667
- const ALPHA$1 = 'abcdefghijklmnopqrstuvwxyz';
668
-
669
- const DIGIT$1 = '0123456789';
670
-
671
- const ALPHABET$1 = {
672
- DIGIT: DIGIT$1,
673
- ALPHA: ALPHA$1,
674
- ALPHA_DIGIT: ALPHA$1 + ALPHA$1.toUpperCase() + DIGIT$1
675
- };
676
-
677
- const generateString$1 = (size = 16, alphabet = ALPHABET$1.ALPHA_DIGIT) => {
678
- let str = '';
679
- const {length} = alphabet;
680
- while (size--) {
681
- str += alphabet[Math.random() * length|0];
682
- }
683
-
684
- return str;
685
- };
686
-
687
- /**
688
- * If the thing is a FormData object, return true, otherwise return false.
689
- *
690
- * @param {unknown} thing - The thing to check.
691
- *
692
- * @returns {boolean}
693
- */
694
- function isSpecCompliantForm$1(thing) {
695
- return !!(thing && isFunction$1(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
696
- }
697
-
698
- const toJSONObject$1 = (obj) => {
699
- const stack = new Array(10);
700
-
701
- const visit = (source, i) => {
702
-
703
- if (isObject$1(source)) {
704
- if (stack.indexOf(source) >= 0) {
705
- return;
706
- }
707
-
708
- if(!('toJSON' in source)) {
709
- stack[i] = source;
710
- const target = isArray$1(source) ? [] : {};
711
-
712
- forEach$1(source, (value, key) => {
713
- const reducedValue = visit(value, i + 1);
714
- !isUndefined$1(reducedValue) && (target[key] = reducedValue);
715
- });
716
-
717
- stack[i] = undefined;
718
-
719
- return target;
720
- }
721
- }
722
-
723
- return source;
724
- };
725
-
726
- return visit(obj, 0);
727
- };
728
-
729
- const isAsyncFn$1 = kindOfTest$1('AsyncFunction');
730
-
731
- const isThenable$1 = (thing) =>
732
- thing && (isObject$1(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
733
-
734
- var utils$1 = {
735
- isArray: isArray$1,
736
- isArrayBuffer: isArrayBuffer$1,
737
- isBuffer: isBuffer$1,
738
- isFormData: isFormData$2,
739
- isArrayBufferView: isArrayBufferView$1,
740
- isString: isString$2,
741
- isNumber: isNumber$1,
742
- isBoolean: isBoolean$1,
743
- isObject: isObject$1,
744
- isPlainObject: isPlainObject$1,
745
- isUndefined: isUndefined$1,
746
- isDate: isDate$1,
747
- isFile: isFile$1,
748
- isBlob: isBlob$2,
749
- isRegExp: isRegExp$1,
750
- isFunction: isFunction$1,
751
- isStream: isStream$1,
752
- isURLSearchParams: isURLSearchParams$1,
753
- isTypedArray: isTypedArray$1,
754
- isFileList: isFileList$1,
755
- forEach: forEach$1,
756
- merge: merge$1,
757
- extend: extend$1,
758
- trim: trim$1,
759
- stripBOM: stripBOM$1,
760
- inherits: inherits$1,
761
- toFlatObject: toFlatObject$1,
762
- kindOf: kindOf$1,
763
- kindOfTest: kindOfTest$1,
764
- endsWith: endsWith$1,
765
- toArray: toArray$1,
766
- forEachEntry: forEachEntry$1,
767
- matchAll: matchAll$1,
768
- isHTMLForm: isHTMLForm$1,
769
- hasOwnProperty: hasOwnProperty$1,
770
- hasOwnProp: hasOwnProperty$1, // an alias to avoid ESLint no-prototype-builtins detection
771
- reduceDescriptors: reduceDescriptors$1,
772
- freezeMethods: freezeMethods$1,
773
- toObjectSet: toObjectSet$1,
774
- toCamelCase: toCamelCase$1,
775
- noop: noop$1,
776
- toFiniteNumber: toFiniteNumber$1,
777
- findKey: findKey$1,
778
- global: _global$1,
779
- isContextDefined: isContextDefined$1,
780
- ALPHABET: ALPHABET$1,
781
- generateString: generateString$1,
782
- isSpecCompliantForm: isSpecCompliantForm$1,
783
- toJSONObject: toJSONObject$1,
784
- isAsyncFn: isAsyncFn$1,
785
- isThenable: isThenable$1
786
- };
787
-
788
- /**
789
- * Create an Error with the specified message, config, error code, request and response.
790
- *
791
- * @param {string} message The error message.
792
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
793
- * @param {Object} [config] The config.
794
- * @param {Object} [request] The request.
795
- * @param {Object} [response] The response.
796
- *
797
- * @returns {Error} The created error.
798
- */
799
- function AxiosError$1(message, code, config, request, response) {
800
- Error.call(this);
801
-
802
- if (Error.captureStackTrace) {
803
- Error.captureStackTrace(this, this.constructor);
804
- } else {
805
- this.stack = (new Error()).stack;
806
- }
807
-
808
- this.message = message;
809
- this.name = 'AxiosError';
810
- code && (this.code = code);
811
- config && (this.config = config);
812
- request && (this.request = request);
813
- response && (this.response = response);
814
- }
815
-
816
- utils$1.inherits(AxiosError$1, Error, {
817
- toJSON: function toJSON() {
818
- return {
819
- // Standard
820
- message: this.message,
821
- name: this.name,
822
- // Microsoft
823
- description: this.description,
824
- number: this.number,
825
- // Mozilla
826
- fileName: this.fileName,
827
- lineNumber: this.lineNumber,
828
- columnNumber: this.columnNumber,
829
- stack: this.stack,
830
- // Axios
831
- config: utils$1.toJSONObject(this.config),
832
- code: this.code,
833
- status: this.response && this.response.status ? this.response.status : null
834
- };
835
- }
836
- });
837
-
838
- const prototype$1$1 = AxiosError$1.prototype;
839
- const descriptors$1 = {};
840
-
841
- [
842
- 'ERR_BAD_OPTION_VALUE',
843
- 'ERR_BAD_OPTION',
844
- 'ECONNABORTED',
845
- 'ETIMEDOUT',
846
- 'ERR_NETWORK',
847
- 'ERR_FR_TOO_MANY_REDIRECTS',
848
- 'ERR_DEPRECATED',
849
- 'ERR_BAD_RESPONSE',
850
- 'ERR_BAD_REQUEST',
851
- 'ERR_CANCELED',
852
- 'ERR_NOT_SUPPORT',
853
- 'ERR_INVALID_URL'
854
- // eslint-disable-next-line func-names
855
- ].forEach(code => {
856
- descriptors$1[code] = {value: code};
857
- });
858
-
859
- Object.defineProperties(AxiosError$1, descriptors$1);
860
- Object.defineProperty(prototype$1$1, 'isAxiosError', {value: true});
861
-
862
- // eslint-disable-next-line func-names
863
- AxiosError$1.from = (error, code, config, request, response, customProps) => {
864
- const axiosError = Object.create(prototype$1$1);
865
-
866
- utils$1.toFlatObject(error, axiosError, function filter(obj) {
867
- return obj !== Error.prototype;
868
- }, prop => {
869
- return prop !== 'isAxiosError';
870
- });
871
-
872
- AxiosError$1.call(axiosError, error.message, code, config, request, response);
873
-
874
- axiosError.cause = error;
875
-
876
- axiosError.name = error.name;
877
-
878
- customProps && Object.assign(axiosError, customProps);
879
-
880
- return axiosError;
881
- };
882
-
883
- // eslint-disable-next-line strict
884
- var httpAdapter$1 = null;
885
-
886
- /**
887
- * Determines if the given thing is a array or js object.
888
- *
889
- * @param {string} thing - The object or array to be visited.
890
- *
891
- * @returns {boolean}
892
- */
893
- function isVisitable$1(thing) {
894
- return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
895
- }
896
-
897
- /**
898
- * It removes the brackets from the end of a string
899
- *
900
- * @param {string} key - The key of the parameter.
901
- *
902
- * @returns {string} the key without the brackets.
903
- */
904
- function removeBrackets$1(key) {
905
- return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
906
- }
907
-
908
- /**
909
- * It takes a path, a key, and a boolean, and returns a string
910
- *
911
- * @param {string} path - The path to the current key.
912
- * @param {string} key - The key of the current object being iterated over.
913
- * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
914
- *
915
- * @returns {string} The path to the current key.
916
- */
917
- function renderKey$1(path, key, dots) {
918
- if (!path) return key;
919
- return path.concat(key).map(function each(token, i) {
920
- // eslint-disable-next-line no-param-reassign
921
- token = removeBrackets$1(token);
922
- return !dots && i ? '[' + token + ']' : token;
923
- }).join(dots ? '.' : '');
924
- }
925
-
926
- /**
927
- * If the array is an array and none of its elements are visitable, then it's a flat array.
928
- *
929
- * @param {Array<any>} arr - The array to check
930
- *
931
- * @returns {boolean}
932
- */
933
- function isFlatArray$1(arr) {
934
- return utils$1.isArray(arr) && !arr.some(isVisitable$1);
935
- }
936
-
937
- const predicates$1 = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
938
- return /^is[A-Z]/.test(prop);
939
- });
940
-
941
- /**
942
- * Convert a data object to FormData
943
- *
944
- * @param {Object} obj
945
- * @param {?Object} [formData]
946
- * @param {?Object} [options]
947
- * @param {Function} [options.visitor]
948
- * @param {Boolean} [options.metaTokens = true]
949
- * @param {Boolean} [options.dots = false]
950
- * @param {?Boolean} [options.indexes = false]
951
- *
952
- * @returns {Object}
953
- **/
954
-
955
- /**
956
- * It converts an object into a FormData object
957
- *
958
- * @param {Object<any, any>} obj - The object to convert to form data.
959
- * @param {string} formData - The FormData object to append to.
960
- * @param {Object<string, any>} options
961
- *
962
- * @returns
963
- */
964
- function toFormData$1(obj, formData, options) {
965
- if (!utils$1.isObject(obj)) {
966
- throw new TypeError('target must be an object');
967
- }
968
-
969
- // eslint-disable-next-line no-param-reassign
970
- formData = formData || new (FormData)();
971
-
972
- // eslint-disable-next-line no-param-reassign
973
- options = utils$1.toFlatObject(options, {
974
- metaTokens: true,
975
- dots: false,
976
- indexes: false
977
- }, false, function defined(option, source) {
978
- // eslint-disable-next-line no-eq-null,eqeqeq
979
- return !utils$1.isUndefined(source[option]);
980
- });
981
-
982
- const metaTokens = options.metaTokens;
983
- // eslint-disable-next-line no-use-before-define
984
- const visitor = options.visitor || defaultVisitor;
985
- const dots = options.dots;
986
- const indexes = options.indexes;
987
- const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
988
- const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
989
-
990
- if (!utils$1.isFunction(visitor)) {
991
- throw new TypeError('visitor must be a function');
992
- }
993
-
994
- function convertValue(value) {
995
- if (value === null) return '';
996
-
997
- if (utils$1.isDate(value)) {
998
- return value.toISOString();
999
- }
1000
-
1001
- if (!useBlob && utils$1.isBlob(value)) {
1002
- throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
1003
- }
1004
-
1005
- if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
1006
- return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
1007
- }
1008
-
1009
- return value;
1010
- }
1011
-
1012
- /**
1013
- * Default visitor.
1014
- *
1015
- * @param {*} value
1016
- * @param {String|Number} key
1017
- * @param {Array<String|Number>} path
1018
- * @this {FormData}
1019
- *
1020
- * @returns {boolean} return true to visit the each prop of the value recursively
1021
- */
1022
- function defaultVisitor(value, key, path) {
1023
- let arr = value;
1024
-
1025
- if (value && !path && typeof value === 'object') {
1026
- if (utils$1.endsWith(key, '{}')) {
1027
- // eslint-disable-next-line no-param-reassign
1028
- key = metaTokens ? key : key.slice(0, -2);
1029
- // eslint-disable-next-line no-param-reassign
1030
- value = JSON.stringify(value);
1031
- } else if (
1032
- (utils$1.isArray(value) && isFlatArray$1(value)) ||
1033
- ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
1034
- )) {
1035
- // eslint-disable-next-line no-param-reassign
1036
- key = removeBrackets$1(key);
1037
-
1038
- arr.forEach(function each(el, index) {
1039
- !(utils$1.isUndefined(el) || el === null) && formData.append(
1040
- // eslint-disable-next-line no-nested-ternary
1041
- indexes === true ? renderKey$1([key], index, dots) : (indexes === null ? key : key + '[]'),
1042
- convertValue(el)
1043
- );
1044
- });
1045
- return false;
1046
- }
1047
- }
1048
-
1049
- if (isVisitable$1(value)) {
1050
- return true;
1051
- }
1052
-
1053
- formData.append(renderKey$1(path, key, dots), convertValue(value));
1054
-
1055
- return false;
1056
- }
1057
-
1058
- const stack = [];
1059
-
1060
- const exposedHelpers = Object.assign(predicates$1, {
1061
- defaultVisitor,
1062
- convertValue,
1063
- isVisitable: isVisitable$1
1064
- });
1065
-
1066
- function build(value, path) {
1067
- if (utils$1.isUndefined(value)) return;
1068
-
1069
- if (stack.indexOf(value) !== -1) {
1070
- throw Error('Circular reference detected in ' + path.join('.'));
1071
- }
1072
-
1073
- stack.push(value);
1074
-
1075
- utils$1.forEach(value, function each(el, key) {
1076
- const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
1077
- formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
1078
- );
1079
-
1080
- if (result === true) {
1081
- build(el, path ? path.concat(key) : [key]);
1082
- }
1083
- });
1084
-
1085
- stack.pop();
1086
- }
1087
-
1088
- if (!utils$1.isObject(obj)) {
1089
- throw new TypeError('data must be an object');
1090
- }
1091
-
1092
- build(obj);
1093
-
1094
- return formData;
1095
- }
1096
-
1097
- /**
1098
- * It encodes a string by replacing all characters that are not in the unreserved set with
1099
- * their percent-encoded equivalents
1100
- *
1101
- * @param {string} str - The string to encode.
1102
- *
1103
- * @returns {string} The encoded string.
1104
- */
1105
- function encode$1$1(str) {
1106
- const charMap = {
1107
- '!': '%21',
1108
- "'": '%27',
1109
- '(': '%28',
1110
- ')': '%29',
1111
- '~': '%7E',
1112
- '%20': '+',
1113
- '%00': '\x00'
1114
- };
1115
- return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
1116
- return charMap[match];
1117
- });
1118
- }
1119
-
1120
- /**
1121
- * It takes a params object and converts it to a FormData object
1122
- *
1123
- * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
1124
- * @param {Object<string, any>} options - The options object passed to the Axios constructor.
1125
- *
1126
- * @returns {void}
1127
- */
1128
- function AxiosURLSearchParams$1(params, options) {
1129
- this._pairs = [];
1130
-
1131
- params && toFormData$1(params, this, options);
1132
- }
1133
-
1134
- const prototype$2 = AxiosURLSearchParams$1.prototype;
1135
-
1136
- prototype$2.append = function append(name, value) {
1137
- this._pairs.push([name, value]);
1138
- };
1139
-
1140
- prototype$2.toString = function toString(encoder) {
1141
- const _encode = encoder ? function(value) {
1142
- return encoder.call(this, value, encode$1$1);
1143
- } : encode$1$1;
1144
-
1145
- return this._pairs.map(function each(pair) {
1146
- return _encode(pair[0]) + '=' + _encode(pair[1]);
1147
- }, '').join('&');
1148
- };
1149
-
1150
- /**
1151
- * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
1152
- * URI encoded counterparts
1153
- *
1154
- * @param {string} val The value to be encoded.
1155
- *
1156
- * @returns {string} The encoded value.
1157
- */
1158
- function encode$3(val) {
1159
- return encodeURIComponent(val).
1160
- replace(/%3A/gi, ':').
1161
- replace(/%24/g, '$').
1162
- replace(/%2C/gi, ',').
1163
- replace(/%20/g, '+').
1164
- replace(/%5B/gi, '[').
1165
- replace(/%5D/gi, ']');
1166
- }
1167
-
1168
- /**
1169
- * Build a URL by appending params to the end
1170
- *
1171
- * @param {string} url The base of the url (e.g., http://www.google.com)
1172
- * @param {object} [params] The params to be appended
1173
- * @param {?object} options
1174
- *
1175
- * @returns {string} The formatted url
1176
- */
1177
- function buildURL$1(url, params, options) {
1178
- /*eslint no-param-reassign:0*/
1179
- if (!params) {
1180
- return url;
1181
- }
1182
-
1183
- const _encode = options && options.encode || encode$3;
1184
-
1185
- const serializeFn = options && options.serialize;
1186
-
1187
- let serializedParams;
1188
-
1189
- if (serializeFn) {
1190
- serializedParams = serializeFn(params, options);
1191
- } else {
1192
- serializedParams = utils$1.isURLSearchParams(params) ?
1193
- params.toString() :
1194
- new AxiosURLSearchParams$1(params, options).toString(_encode);
1195
- }
1196
-
1197
- if (serializedParams) {
1198
- const hashmarkIndex = url.indexOf("#");
1199
-
1200
- if (hashmarkIndex !== -1) {
1201
- url = url.slice(0, hashmarkIndex);
1202
- }
1203
- url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
1204
- }
1205
-
1206
- return url;
1207
- }
1208
-
1209
- let InterceptorManager$2 = class InterceptorManager {
1210
- constructor() {
1211
- this.handlers = [];
1212
- }
1213
-
1214
- /**
1215
- * Add a new interceptor to the stack
1216
- *
1217
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
1218
- * @param {Function} rejected The function to handle `reject` for a `Promise`
1219
- *
1220
- * @return {Number} An ID used to remove interceptor later
1221
- */
1222
- use(fulfilled, rejected, options) {
1223
- this.handlers.push({
1224
- fulfilled,
1225
- rejected,
1226
- synchronous: options ? options.synchronous : false,
1227
- runWhen: options ? options.runWhen : null
1228
- });
1229
- return this.handlers.length - 1;
1230
- }
1231
-
1232
- /**
1233
- * Remove an interceptor from the stack
1234
- *
1235
- * @param {Number} id The ID that was returned by `use`
1236
- *
1237
- * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
1238
- */
1239
- eject(id) {
1240
- if (this.handlers[id]) {
1241
- this.handlers[id] = null;
1242
- }
1243
- }
1244
-
1245
- /**
1246
- * Clear all interceptors from the stack
1247
- *
1248
- * @returns {void}
1249
- */
1250
- clear() {
1251
- if (this.handlers) {
1252
- this.handlers = [];
1253
- }
1254
- }
1255
-
1256
- /**
1257
- * Iterate over all the registered interceptors
1258
- *
1259
- * This method is particularly useful for skipping over any
1260
- * interceptors that may have become `null` calling `eject`.
1261
- *
1262
- * @param {Function} fn The function to call for each interceptor
1263
- *
1264
- * @returns {void}
1265
- */
1266
- forEach(fn) {
1267
- utils$1.forEach(this.handlers, function forEachHandler(h) {
1268
- if (h !== null) {
1269
- fn(h);
1270
- }
1271
- });
1272
- }
1273
- };
1274
-
1275
- var InterceptorManager$1$1 = InterceptorManager$2;
1276
-
1277
- var transitionalDefaults$1 = {
1278
- silentJSONParsing: true,
1279
- forcedJSONParsing: true,
1280
- clarifyTimeoutError: false
1281
- };
1282
-
1283
- var URLSearchParams$1$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams$1;
1284
-
1285
- var FormData$1$1 = typeof FormData !== 'undefined' ? FormData : null;
1286
-
1287
- var Blob$1$1 = typeof Blob !== 'undefined' ? Blob : null;
1288
-
1289
- /**
1290
- * Determine if we're running in a standard browser environment
1291
- *
1292
- * This allows axios to run in a web worker, and react-native.
1293
- * Both environments support XMLHttpRequest, but not fully standard globals.
1294
- *
1295
- * web workers:
1296
- * typeof window -> undefined
1297
- * typeof document -> undefined
1298
- *
1299
- * react-native:
1300
- * navigator.product -> 'ReactNative'
1301
- * nativescript
1302
- * navigator.product -> 'NativeScript' or 'NS'
1303
- *
1304
- * @returns {boolean}
1305
- */
1306
- const isStandardBrowserEnv$1 = (() => {
1307
- let product;
1308
- if (typeof navigator !== 'undefined' && (
1309
- (product = navigator.product) === 'ReactNative' ||
1310
- product === 'NativeScript' ||
1311
- product === 'NS')
1312
- ) {
1313
- return false;
1314
- }
1315
-
1316
- return typeof window !== 'undefined' && typeof document !== 'undefined';
1317
- })();
1318
-
1319
- /**
1320
- * Determine if we're running in a standard browser webWorker environment
1321
- *
1322
- * Although the `isStandardBrowserEnv` method indicates that
1323
- * `allows axios to run in a web worker`, the WebWorker will still be
1324
- * filtered out due to its judgment standard
1325
- * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
1326
- * This leads to a problem when axios post `FormData` in webWorker
1327
- */
1328
- const isStandardBrowserWebWorkerEnv$1 = (() => {
1329
- return (
1330
- typeof WorkerGlobalScope !== 'undefined' &&
1331
- // eslint-disable-next-line no-undef
1332
- self instanceof WorkerGlobalScope &&
1333
- typeof self.importScripts === 'function'
1334
- );
1335
- })();
1336
-
1337
-
1338
- var platform$1 = {
1339
- isBrowser: true,
1340
- classes: {
1341
- URLSearchParams: URLSearchParams$1$1,
1342
- FormData: FormData$1$1,
1343
- Blob: Blob$1$1
1344
- },
1345
- isStandardBrowserEnv: isStandardBrowserEnv$1,
1346
- isStandardBrowserWebWorkerEnv: isStandardBrowserWebWorkerEnv$1,
1347
- protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
1348
- };
1349
-
1350
- function toURLEncodedForm$1(data, options) {
1351
- return toFormData$1(data, new platform$1.classes.URLSearchParams(), Object.assign({
1352
- visitor: function(value, key, path, helpers) {
1353
- if (platform$1.isNode && utils$1.isBuffer(value)) {
1354
- this.append(key, value.toString('base64'));
1355
- return false;
1356
- }
1357
-
1358
- return helpers.defaultVisitor.apply(this, arguments);
1359
- }
1360
- }, options));
1361
- }
1362
-
1363
- /**
1364
- * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
1365
- *
1366
- * @param {string} name - The name of the property to get.
1367
- *
1368
- * @returns An array of strings.
1369
- */
1370
- function parsePropPath$1(name) {
1371
- // foo[x][y][z]
1372
- // foo.x.y.z
1373
- // foo-x-y-z
1374
- // foo x y z
1375
- return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
1376
- return match[0] === '[]' ? '' : match[1] || match[0];
1377
- });
1378
- }
1379
-
1380
- /**
1381
- * Convert an array to an object.
1382
- *
1383
- * @param {Array<any>} arr - The array to convert to an object.
1384
- *
1385
- * @returns An object with the same keys and values as the array.
1386
- */
1387
- function arrayToObject$1(arr) {
1388
- const obj = {};
1389
- const keys = Object.keys(arr);
1390
- let i;
1391
- const len = keys.length;
1392
- let key;
1393
- for (i = 0; i < len; i++) {
1394
- key = keys[i];
1395
- obj[key] = arr[key];
1396
- }
1397
- return obj;
1398
- }
1399
-
1400
- /**
1401
- * It takes a FormData object and returns a JavaScript object
1402
- *
1403
- * @param {string} formData The FormData object to convert to JSON.
1404
- *
1405
- * @returns {Object<string, any> | null} The converted object.
1406
- */
1407
- function formDataToJSON$1(formData) {
1408
- function buildPath(path, value, target, index) {
1409
- let name = path[index++];
1410
- const isNumericKey = Number.isFinite(+name);
1411
- const isLast = index >= path.length;
1412
- name = !name && utils$1.isArray(target) ? target.length : name;
1413
-
1414
- if (isLast) {
1415
- if (utils$1.hasOwnProp(target, name)) {
1416
- target[name] = [target[name], value];
1417
- } else {
1418
- target[name] = value;
1419
- }
1420
-
1421
- return !isNumericKey;
1422
- }
1423
-
1424
- if (!target[name] || !utils$1.isObject(target[name])) {
1425
- target[name] = [];
1426
- }
1427
-
1428
- const result = buildPath(path, value, target[name], index);
1429
-
1430
- if (result && utils$1.isArray(target[name])) {
1431
- target[name] = arrayToObject$1(target[name]);
1432
- }
1433
-
1434
- return !isNumericKey;
1435
- }
1436
-
1437
- if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
1438
- const obj = {};
1439
-
1440
- utils$1.forEachEntry(formData, (name, value) => {
1441
- buildPath(parsePropPath$1(name), value, obj, 0);
1442
- });
1443
-
1444
- return obj;
1445
- }
1446
-
1447
- return null;
1448
- }
1449
-
1450
- const DEFAULT_CONTENT_TYPE$1 = {
1451
- 'Content-Type': undefined
1452
- };
1453
-
1454
- /**
1455
- * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1456
- * of the input
1457
- *
1458
- * @param {any} rawValue - The value to be stringified.
1459
- * @param {Function} parser - A function that parses a string into a JavaScript object.
1460
- * @param {Function} encoder - A function that takes a value and returns a string.
1461
- *
1462
- * @returns {string} A stringified version of the rawValue.
1463
- */
1464
- function stringifySafely$1(rawValue, parser, encoder) {
1465
- if (utils$1.isString(rawValue)) {
1466
- try {
1467
- (parser || JSON.parse)(rawValue);
1468
- return utils$1.trim(rawValue);
1469
- } catch (e) {
1470
- if (e.name !== 'SyntaxError') {
1471
- throw e;
1472
- }
1473
- }
1474
- }
1475
-
1476
- return (encoder || JSON.stringify)(rawValue);
1477
- }
1478
-
1479
- const defaults$2 = {
1480
-
1481
- transitional: transitionalDefaults$1,
1482
-
1483
- adapter: ['xhr', 'http'],
1484
-
1485
- transformRequest: [function transformRequest(data, headers) {
1486
- const contentType = headers.getContentType() || '';
1487
- const hasJSONContentType = contentType.indexOf('application/json') > -1;
1488
- const isObjectPayload = utils$1.isObject(data);
1489
-
1490
- if (isObjectPayload && utils$1.isHTMLForm(data)) {
1491
- data = new FormData(data);
1492
- }
1493
-
1494
- const isFormData = utils$1.isFormData(data);
1495
-
1496
- if (isFormData) {
1497
- if (!hasJSONContentType) {
1498
- return data;
1499
- }
1500
- return hasJSONContentType ? JSON.stringify(formDataToJSON$1(data)) : data;
1501
- }
1502
-
1503
- if (utils$1.isArrayBuffer(data) ||
1504
- utils$1.isBuffer(data) ||
1505
- utils$1.isStream(data) ||
1506
- utils$1.isFile(data) ||
1507
- utils$1.isBlob(data)
1508
- ) {
1509
- return data;
1510
- }
1511
- if (utils$1.isArrayBufferView(data)) {
1512
- return data.buffer;
1513
- }
1514
- if (utils$1.isURLSearchParams(data)) {
1515
- headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
1516
- return data.toString();
1517
- }
1518
-
1519
- let isFileList;
1520
-
1521
- if (isObjectPayload) {
1522
- if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
1523
- return toURLEncodedForm$1(data, this.formSerializer).toString();
1524
- }
1525
-
1526
- if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
1527
- const _FormData = this.env && this.env.FormData;
1528
-
1529
- return toFormData$1(
1530
- isFileList ? {'files[]': data} : data,
1531
- _FormData && new _FormData(),
1532
- this.formSerializer
1533
- );
1534
- }
1535
- }
1536
-
1537
- if (isObjectPayload || hasJSONContentType ) {
1538
- headers.setContentType('application/json', false);
1539
- return stringifySafely$1(data);
1540
- }
1541
-
1542
- return data;
1543
- }],
1544
-
1545
- transformResponse: [function transformResponse(data) {
1546
- const transitional = this.transitional || defaults$2.transitional;
1547
- const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1548
- const JSONRequested = this.responseType === 'json';
1549
-
1550
- if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
1551
- const silentJSONParsing = transitional && transitional.silentJSONParsing;
1552
- const strictJSONParsing = !silentJSONParsing && JSONRequested;
1553
-
1554
- try {
1555
- return JSON.parse(data);
1556
- } catch (e) {
1557
- if (strictJSONParsing) {
1558
- if (e.name === 'SyntaxError') {
1559
- throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
1560
- }
1561
- throw e;
1562
- }
1563
- }
1564
- }
1565
-
1566
- return data;
1567
- }],
1568
-
1569
- /**
1570
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
1571
- * timeout is not created.
1572
- */
1573
- timeout: 0,
1574
-
1575
- xsrfCookieName: 'XSRF-TOKEN',
1576
- xsrfHeaderName: 'X-XSRF-TOKEN',
1577
-
1578
- maxContentLength: -1,
1579
- maxBodyLength: -1,
1580
-
1581
- env: {
1582
- FormData: platform$1.classes.FormData,
1583
- Blob: platform$1.classes.Blob
1584
- },
1585
-
1586
- validateStatus: function validateStatus(status) {
1587
- return status >= 200 && status < 300;
1588
- },
1589
-
1590
- headers: {
1591
- common: {
1592
- 'Accept': 'application/json, text/plain, */*'
1593
- }
1594
- }
1595
- };
1596
-
1597
- utils$1.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
1598
- defaults$2.headers[method] = {};
1599
- });
1600
-
1601
- utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1602
- defaults$2.headers[method] = utils$1.merge(DEFAULT_CONTENT_TYPE$1);
1603
- });
1604
-
1605
- var defaults$1$1 = defaults$2;
1606
-
1607
- // RawAxiosHeaders whose duplicates are ignored by node
1608
- // c.f. https://nodejs.org/api/http.html#http_message_headers
1609
- const ignoreDuplicateOf$1 = utils$1.toObjectSet([
1610
- 'age', 'authorization', 'content-length', 'content-type', 'etag',
1611
- 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
1612
- 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
1613
- 'referer', 'retry-after', 'user-agent'
1614
- ]);
1615
-
1616
- /**
1617
- * Parse headers into an object
1618
- *
1619
- * ```
1620
- * Date: Wed, 27 Aug 2014 08:58:49 GMT
1621
- * Content-Type: application/json
1622
- * Connection: keep-alive
1623
- * Transfer-Encoding: chunked
1624
- * ```
1625
- *
1626
- * @param {String} rawHeaders Headers needing to be parsed
1627
- *
1628
- * @returns {Object} Headers parsed into an object
1629
- */
1630
- var parseHeaders$1 = rawHeaders => {
1631
- const parsed = {};
1632
- let key;
1633
- let val;
1634
- let i;
1635
-
1636
- rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
1637
- i = line.indexOf(':');
1638
- key = line.substring(0, i).trim().toLowerCase();
1639
- val = line.substring(i + 1).trim();
1640
-
1641
- if (!key || (parsed[key] && ignoreDuplicateOf$1[key])) {
1642
- return;
1643
- }
1644
-
1645
- if (key === 'set-cookie') {
1646
- if (parsed[key]) {
1647
- parsed[key].push(val);
1648
- } else {
1649
- parsed[key] = [val];
1650
- }
1651
- } else {
1652
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1653
- }
1654
- });
1655
-
1656
- return parsed;
1657
- };
1658
-
1659
- const $internals$1 = Symbol('internals');
1660
-
1661
- function normalizeHeader$1(header) {
1662
- return header && String(header).trim().toLowerCase();
1663
- }
1664
-
1665
- function normalizeValue$1(value) {
1666
- if (value === false || value == null) {
1667
- return value;
1668
- }
1669
-
1670
- return utils$1.isArray(value) ? value.map(normalizeValue$1) : String(value);
1671
- }
1672
-
1673
- function parseTokens$1(str) {
1674
- const tokens = Object.create(null);
1675
- const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1676
- let match;
1677
-
1678
- while ((match = tokensRE.exec(str))) {
1679
- tokens[match[1]] = match[2];
1680
- }
1681
-
1682
- return tokens;
1683
- }
1684
-
1685
- const isValidHeaderName$1 = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1686
-
1687
- function matchHeaderValue$1(context, value, header, filter, isHeaderNameFilter) {
1688
- if (utils$1.isFunction(filter)) {
1689
- return filter.call(this, value, header);
1690
- }
1691
-
1692
- if (isHeaderNameFilter) {
1693
- value = header;
1694
- }
1695
-
1696
- if (!utils$1.isString(value)) return;
1697
-
1698
- if (utils$1.isString(filter)) {
1699
- return value.indexOf(filter) !== -1;
1700
- }
1701
-
1702
- if (utils$1.isRegExp(filter)) {
1703
- return filter.test(value);
1704
- }
1705
- }
1706
-
1707
- function formatHeader$1(header) {
1708
- return header.trim()
1709
- .toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
1710
- return char.toUpperCase() + str;
1711
- });
1712
- }
1713
-
1714
- function buildAccessors$1(obj, header) {
1715
- const accessorName = utils$1.toCamelCase(' ' + header);
1716
-
1717
- ['get', 'set', 'has'].forEach(methodName => {
1718
- Object.defineProperty(obj, methodName + accessorName, {
1719
- value: function(arg1, arg2, arg3) {
1720
- return this[methodName].call(this, header, arg1, arg2, arg3);
1721
- },
1722
- configurable: true
1723
- });
1724
- });
1725
- }
1726
-
1727
- let AxiosHeaders$2 = class AxiosHeaders {
1728
- constructor(headers) {
1729
- headers && this.set(headers);
1730
- }
1731
-
1732
- set(header, valueOrRewrite, rewrite) {
1733
- const self = this;
1734
-
1735
- function setHeader(_value, _header, _rewrite) {
1736
- const lHeader = normalizeHeader$1(_header);
1737
-
1738
- if (!lHeader) {
1739
- throw new Error('header name must be a non-empty string');
1740
- }
1741
-
1742
- const key = utils$1.findKey(self, lHeader);
1743
-
1744
- if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
1745
- self[key || _header] = normalizeValue$1(_value);
1746
- }
1747
- }
1748
-
1749
- const setHeaders = (headers, _rewrite) =>
1750
- utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
1751
-
1752
- if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
1753
- setHeaders(header, valueOrRewrite);
1754
- } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName$1(header)) {
1755
- setHeaders(parseHeaders$1(header), valueOrRewrite);
1756
- } else {
1757
- header != null && setHeader(valueOrRewrite, header, rewrite);
1758
- }
1759
-
1760
- return this;
1761
- }
1762
-
1763
- get(header, parser) {
1764
- header = normalizeHeader$1(header);
1765
-
1766
- if (header) {
1767
- const key = utils$1.findKey(this, header);
1768
-
1769
- if (key) {
1770
- const value = this[key];
1771
-
1772
- if (!parser) {
1773
- return value;
1774
- }
1775
-
1776
- if (parser === true) {
1777
- return parseTokens$1(value);
1778
- }
1779
-
1780
- if (utils$1.isFunction(parser)) {
1781
- return parser.call(this, value, key);
1782
- }
1783
-
1784
- if (utils$1.isRegExp(parser)) {
1785
- return parser.exec(value);
1786
- }
1787
-
1788
- throw new TypeError('parser must be boolean|regexp|function');
1789
- }
1790
- }
1791
- }
1792
-
1793
- has(header, matcher) {
1794
- header = normalizeHeader$1(header);
1795
-
1796
- if (header) {
1797
- const key = utils$1.findKey(this, header);
1798
-
1799
- return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue$1(this, this[key], key, matcher)));
1800
- }
1801
-
1802
- return false;
1803
- }
1804
-
1805
- delete(header, matcher) {
1806
- const self = this;
1807
- let deleted = false;
1808
-
1809
- function deleteHeader(_header) {
1810
- _header = normalizeHeader$1(_header);
1811
-
1812
- if (_header) {
1813
- const key = utils$1.findKey(self, _header);
1814
-
1815
- if (key && (!matcher || matchHeaderValue$1(self, self[key], key, matcher))) {
1816
- delete self[key];
1817
-
1818
- deleted = true;
1819
- }
1820
- }
1821
- }
1822
-
1823
- if (utils$1.isArray(header)) {
1824
- header.forEach(deleteHeader);
1825
- } else {
1826
- deleteHeader(header);
1827
- }
1828
-
1829
- return deleted;
1830
- }
1831
-
1832
- clear(matcher) {
1833
- const keys = Object.keys(this);
1834
- let i = keys.length;
1835
- let deleted = false;
1836
-
1837
- while (i--) {
1838
- const key = keys[i];
1839
- if(!matcher || matchHeaderValue$1(this, this[key], key, matcher, true)) {
1840
- delete this[key];
1841
- deleted = true;
1842
- }
1843
- }
1844
-
1845
- return deleted;
1846
- }
1847
-
1848
- normalize(format) {
1849
- const self = this;
1850
- const headers = {};
1851
-
1852
- utils$1.forEach(this, (value, header) => {
1853
- const key = utils$1.findKey(headers, header);
1854
-
1855
- if (key) {
1856
- self[key] = normalizeValue$1(value);
1857
- delete self[header];
1858
- return;
1859
- }
1860
-
1861
- const normalized = format ? formatHeader$1(header) : String(header).trim();
1862
-
1863
- if (normalized !== header) {
1864
- delete self[header];
1865
- }
1866
-
1867
- self[normalized] = normalizeValue$1(value);
1868
-
1869
- headers[normalized] = true;
1870
- });
1871
-
1872
- return this;
1873
- }
1874
-
1875
- concat(...targets) {
1876
- return this.constructor.concat(this, ...targets);
1877
- }
1878
-
1879
- toJSON(asStrings) {
1880
- const obj = Object.create(null);
1881
-
1882
- utils$1.forEach(this, (value, header) => {
1883
- value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
1884
- });
1885
-
1886
- return obj;
1887
- }
1888
-
1889
- [Symbol.iterator]() {
1890
- return Object.entries(this.toJSON())[Symbol.iterator]();
1891
- }
1892
-
1893
- toString() {
1894
- return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
1895
- }
1896
-
1897
- get [Symbol.toStringTag]() {
1898
- return 'AxiosHeaders';
1899
- }
1900
-
1901
- static from(thing) {
1902
- return thing instanceof this ? thing : new this(thing);
1903
- }
1904
-
1905
- static concat(first, ...targets) {
1906
- const computed = new this(first);
1907
-
1908
- targets.forEach((target) => computed.set(target));
1909
-
1910
- return computed;
1911
- }
1912
-
1913
- static accessor(header) {
1914
- const internals = this[$internals$1] = (this[$internals$1] = {
1915
- accessors: {}
1916
- });
1917
-
1918
- const accessors = internals.accessors;
1919
- const prototype = this.prototype;
1920
-
1921
- function defineAccessor(_header) {
1922
- const lHeader = normalizeHeader$1(_header);
1923
-
1924
- if (!accessors[lHeader]) {
1925
- buildAccessors$1(prototype, _header);
1926
- accessors[lHeader] = true;
1927
- }
1928
- }
1929
-
1930
- utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1931
-
1932
- return this;
1933
- }
1934
- };
1935
-
1936
- AxiosHeaders$2.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
1937
-
1938
- utils$1.freezeMethods(AxiosHeaders$2.prototype);
1939
- utils$1.freezeMethods(AxiosHeaders$2);
1940
-
1941
- var AxiosHeaders$1$1 = AxiosHeaders$2;
1942
-
1943
- /**
1944
- * Transform the data for a request or a response
1945
- *
1946
- * @param {Array|Function} fns A single function or Array of functions
1947
- * @param {?Object} response The response object
1948
- *
1949
- * @returns {*} The resulting transformed data
1950
- */
1951
- function transformData$1(fns, response) {
1952
- const config = this || defaults$1$1;
1953
- const context = response || config;
1954
- const headers = AxiosHeaders$1$1.from(context.headers);
1955
- let data = context.data;
1956
-
1957
- utils$1.forEach(fns, function transform(fn) {
1958
- data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
1959
- });
1960
-
1961
- headers.normalize();
1962
-
1963
- return data;
1964
- }
1965
-
1966
- function isCancel$1(value) {
1967
- return !!(value && value.__CANCEL__);
1968
- }
1969
-
1970
- /**
1971
- * A `CanceledError` is an object that is thrown when an operation is canceled.
1972
- *
1973
- * @param {string=} message The message.
1974
- * @param {Object=} config The config.
1975
- * @param {Object=} request The request.
1976
- *
1977
- * @returns {CanceledError} The created error.
1978
- */
1979
- function CanceledError$1(message, config, request) {
1980
- // eslint-disable-next-line no-eq-null,eqeqeq
1981
- AxiosError$1.call(this, message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
1982
- this.name = 'CanceledError';
1983
- }
1984
-
1985
- utils$1.inherits(CanceledError$1, AxiosError$1, {
1986
- __CANCEL__: true
1987
- });
1988
-
1989
- /**
1990
- * Resolve or reject a Promise based on response status.
1991
- *
1992
- * @param {Function} resolve A function that resolves the promise.
1993
- * @param {Function} reject A function that rejects the promise.
1994
- * @param {object} response The response.
1995
- *
1996
- * @returns {object} The response.
1997
- */
1998
- function settle$1(resolve, reject, response) {
1999
- const validateStatus = response.config.validateStatus;
2000
- if (!response.status || !validateStatus || validateStatus(response.status)) {
2001
- resolve(response);
2002
- } else {
2003
- reject(new AxiosError$1(
2004
- 'Request failed with status code ' + response.status,
2005
- [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
2006
- response.config,
2007
- response.request,
2008
- response
2009
- ));
2010
- }
2011
- }
2012
-
2013
- var cookies$1 = platform$1.isStandardBrowserEnv ?
2014
-
2015
- // Standard browser envs support document.cookie
2016
- (function standardBrowserEnv() {
2017
- return {
2018
- write: function write(name, value, expires, path, domain, secure) {
2019
- const cookie = [];
2020
- cookie.push(name + '=' + encodeURIComponent(value));
2021
-
2022
- if (utils$1.isNumber(expires)) {
2023
- cookie.push('expires=' + new Date(expires).toGMTString());
2024
- }
2025
-
2026
- if (utils$1.isString(path)) {
2027
- cookie.push('path=' + path);
2028
- }
2029
-
2030
- if (utils$1.isString(domain)) {
2031
- cookie.push('domain=' + domain);
2032
- }
2033
-
2034
- if (secure === true) {
2035
- cookie.push('secure');
2036
- }
2037
-
2038
- document.cookie = cookie.join('; ');
2039
- },
2040
-
2041
- read: function read(name) {
2042
- const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
2043
- return (match ? decodeURIComponent(match[3]) : null);
2044
- },
2045
-
2046
- remove: function remove(name) {
2047
- this.write(name, '', Date.now() - 86400000);
2048
- }
2049
- };
2050
- })() :
2051
-
2052
- // Non standard browser env (web workers, react-native) lack needed support.
2053
- (function nonStandardBrowserEnv() {
2054
- return {
2055
- write: function write() {},
2056
- read: function read() { return null; },
2057
- remove: function remove() {}
2058
- };
2059
- })();
2060
-
2061
- /**
2062
- * Determines whether the specified URL is absolute
2063
- *
2064
- * @param {string} url The URL to test
2065
- *
2066
- * @returns {boolean} True if the specified URL is absolute, otherwise false
2067
- */
2068
- function isAbsoluteURL$1(url) {
2069
- // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
2070
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
2071
- // by any combination of letters, digits, plus, period, or hyphen.
2072
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
2073
- }
2074
-
2075
- /**
2076
- * Creates a new URL by combining the specified URLs
2077
- *
2078
- * @param {string} baseURL The base URL
2079
- * @param {string} relativeURL The relative URL
2080
- *
2081
- * @returns {string} The combined URL
2082
- */
2083
- function combineURLs$1(baseURL, relativeURL) {
2084
- return relativeURL
2085
- ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
2086
- : baseURL;
2087
- }
2088
-
2089
- /**
2090
- * Creates a new URL by combining the baseURL with the requestedURL,
2091
- * only when the requestedURL is not already an absolute URL.
2092
- * If the requestURL is absolute, this function returns the requestedURL untouched.
2093
- *
2094
- * @param {string} baseURL The base URL
2095
- * @param {string} requestedURL Absolute or relative URL to combine
2096
- *
2097
- * @returns {string} The combined full path
2098
- */
2099
- function buildFullPath$1(baseURL, requestedURL) {
2100
- if (baseURL && !isAbsoluteURL$1(requestedURL)) {
2101
- return combineURLs$1(baseURL, requestedURL);
2102
- }
2103
- return requestedURL;
2104
- }
2105
-
2106
- var isURLSameOrigin$1 = platform$1.isStandardBrowserEnv ?
2107
-
2108
- // Standard browser envs have full support of the APIs needed to test
2109
- // whether the request URL is of the same origin as current location.
2110
- (function standardBrowserEnv() {
2111
- const msie = /(msie|trident)/i.test(navigator.userAgent);
2112
- const urlParsingNode = document.createElement('a');
2113
- let originURL;
2114
-
2115
- /**
2116
- * Parse a URL to discover it's components
2117
- *
2118
- * @param {String} url The URL to be parsed
2119
- * @returns {Object}
2120
- */
2121
- function resolveURL(url) {
2122
- let href = url;
2123
-
2124
- if (msie) {
2125
- // IE needs attribute set twice to normalize properties
2126
- urlParsingNode.setAttribute('href', href);
2127
- href = urlParsingNode.href;
2128
- }
2129
-
2130
- urlParsingNode.setAttribute('href', href);
2131
-
2132
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
2133
- return {
2134
- href: urlParsingNode.href,
2135
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
2136
- host: urlParsingNode.host,
2137
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
2138
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
2139
- hostname: urlParsingNode.hostname,
2140
- port: urlParsingNode.port,
2141
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
2142
- urlParsingNode.pathname :
2143
- '/' + urlParsingNode.pathname
2144
- };
2145
- }
2146
-
2147
- originURL = resolveURL(window.location.href);
2148
-
2149
- /**
2150
- * Determine if a URL shares the same origin as the current location
2151
- *
2152
- * @param {String} requestURL The URL to test
2153
- * @returns {boolean} True if URL shares the same origin, otherwise false
2154
- */
2155
- return function isURLSameOrigin(requestURL) {
2156
- const parsed = (utils$1.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
2157
- return (parsed.protocol === originURL.protocol &&
2158
- parsed.host === originURL.host);
2159
- };
2160
- })() :
2161
-
2162
- // Non standard browser envs (web workers, react-native) lack needed support.
2163
- (function nonStandardBrowserEnv() {
2164
- return function isURLSameOrigin() {
2165
- return true;
2166
- };
2167
- })();
2168
-
2169
- function parseProtocol$1(url) {
2170
- const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
2171
- return match && match[1] || '';
2172
- }
2173
-
2174
- /**
2175
- * Calculate data maxRate
2176
- * @param {Number} [samplesCount= 10]
2177
- * @param {Number} [min= 1000]
2178
- * @returns {Function}
2179
- */
2180
- function speedometer$1(samplesCount, min) {
2181
- samplesCount = samplesCount || 10;
2182
- const bytes = new Array(samplesCount);
2183
- const timestamps = new Array(samplesCount);
2184
- let head = 0;
2185
- let tail = 0;
2186
- let firstSampleTS;
2187
-
2188
- min = min !== undefined ? min : 1000;
2189
-
2190
- return function push(chunkLength) {
2191
- const now = Date.now();
2192
-
2193
- const startedAt = timestamps[tail];
2194
-
2195
- if (!firstSampleTS) {
2196
- firstSampleTS = now;
2197
- }
2198
-
2199
- bytes[head] = chunkLength;
2200
- timestamps[head] = now;
2201
-
2202
- let i = tail;
2203
- let bytesCount = 0;
2204
-
2205
- while (i !== head) {
2206
- bytesCount += bytes[i++];
2207
- i = i % samplesCount;
2208
- }
2209
-
2210
- head = (head + 1) % samplesCount;
2211
-
2212
- if (head === tail) {
2213
- tail = (tail + 1) % samplesCount;
2214
- }
2215
-
2216
- if (now - firstSampleTS < min) {
2217
- return;
2218
- }
2219
-
2220
- const passed = startedAt && now - startedAt;
2221
-
2222
- return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2223
- };
2224
- }
2225
-
2226
- function progressEventReducer$1(listener, isDownloadStream) {
2227
- let bytesNotified = 0;
2228
- const _speedometer = speedometer$1(50, 250);
2229
-
2230
- return e => {
2231
- const loaded = e.loaded;
2232
- const total = e.lengthComputable ? e.total : undefined;
2233
- const progressBytes = loaded - bytesNotified;
2234
- const rate = _speedometer(progressBytes);
2235
- const inRange = loaded <= total;
2236
-
2237
- bytesNotified = loaded;
2238
-
2239
- const data = {
2240
- loaded,
2241
- total,
2242
- progress: total ? (loaded / total) : undefined,
2243
- bytes: progressBytes,
2244
- rate: rate ? rate : undefined,
2245
- estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
2246
- event: e
2247
- };
2248
-
2249
- data[isDownloadStream ? 'download' : 'upload'] = true;
2250
-
2251
- listener(data);
2252
- };
2253
- }
2254
-
2255
- const isXHRAdapterSupported$1 = typeof XMLHttpRequest !== 'undefined';
2256
-
2257
- var xhrAdapter$1 = isXHRAdapterSupported$1 && function (config) {
2258
- return new Promise(function dispatchXhrRequest(resolve, reject) {
2259
- let requestData = config.data;
2260
- const requestHeaders = AxiosHeaders$1$1.from(config.headers).normalize();
2261
- const responseType = config.responseType;
2262
- let onCanceled;
2263
- function done() {
2264
- if (config.cancelToken) {
2265
- config.cancelToken.unsubscribe(onCanceled);
2266
- }
2267
-
2268
- if (config.signal) {
2269
- config.signal.removeEventListener('abort', onCanceled);
2270
- }
2271
- }
2272
-
2273
- if (utils$1.isFormData(requestData)) {
2274
- if (platform$1.isStandardBrowserEnv || platform$1.isStandardBrowserWebWorkerEnv) {
2275
- requestHeaders.setContentType(false); // Let the browser set it
2276
- } else {
2277
- requestHeaders.setContentType('multipart/form-data;', false); // mobile/desktop app frameworks
2278
- }
2279
- }
2280
-
2281
- let request = new XMLHttpRequest();
2282
-
2283
- // HTTP basic authentication
2284
- if (config.auth) {
2285
- const username = config.auth.username || '';
2286
- const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
2287
- requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
2288
- }
2289
-
2290
- const fullPath = buildFullPath$1(config.baseURL, config.url);
2291
-
2292
- request.open(config.method.toUpperCase(), buildURL$1(fullPath, config.params, config.paramsSerializer), true);
2293
-
2294
- // Set the request timeout in MS
2295
- request.timeout = config.timeout;
2296
-
2297
- function onloadend() {
2298
- if (!request) {
2299
- return;
2300
- }
2301
- // Prepare the response
2302
- const responseHeaders = AxiosHeaders$1$1.from(
2303
- 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
2304
- );
2305
- const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
2306
- request.responseText : request.response;
2307
- const response = {
2308
- data: responseData,
2309
- status: request.status,
2310
- statusText: request.statusText,
2311
- headers: responseHeaders,
2312
- config,
2313
- request
2314
- };
2315
-
2316
- settle$1(function _resolve(value) {
2317
- resolve(value);
2318
- done();
2319
- }, function _reject(err) {
2320
- reject(err);
2321
- done();
2322
- }, response);
2323
-
2324
- // Clean up request
2325
- request = null;
2326
- }
2327
-
2328
- if ('onloadend' in request) {
2329
- // Use onloadend if available
2330
- request.onloadend = onloadend;
2331
- } else {
2332
- // Listen for ready state to emulate onloadend
2333
- request.onreadystatechange = function handleLoad() {
2334
- if (!request || request.readyState !== 4) {
2335
- return;
2336
- }
2337
-
2338
- // The request errored out and we didn't get a response, this will be
2339
- // handled by onerror instead
2340
- // With one exception: request that using file: protocol, most browsers
2341
- // will return status as 0 even though it's a successful request
2342
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
2343
- return;
2344
- }
2345
- // readystate handler is calling before onerror or ontimeout handlers,
2346
- // so we should call onloadend on the next 'tick'
2347
- setTimeout(onloadend);
2348
- };
2349
- }
2350
-
2351
- // Handle browser request cancellation (as opposed to a manual cancellation)
2352
- request.onabort = function handleAbort() {
2353
- if (!request) {
2354
- return;
2355
- }
2356
-
2357
- reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
2358
-
2359
- // Clean up request
2360
- request = null;
2361
- };
2362
-
2363
- // Handle low level network errors
2364
- request.onerror = function handleError() {
2365
- // Real errors are hidden from us by the browser
2366
- // onerror should only fire if it's a network error
2367
- reject(new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request));
2368
-
2369
- // Clean up request
2370
- request = null;
2371
- };
2372
-
2373
- // Handle timeout
2374
- request.ontimeout = function handleTimeout() {
2375
- let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
2376
- const transitional = config.transitional || transitionalDefaults$1;
2377
- if (config.timeoutErrorMessage) {
2378
- timeoutErrorMessage = config.timeoutErrorMessage;
2379
- }
2380
- reject(new AxiosError$1(
2381
- timeoutErrorMessage,
2382
- transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
2383
- config,
2384
- request));
2385
-
2386
- // Clean up request
2387
- request = null;
2388
- };
2389
-
2390
- // Add xsrf header
2391
- // This is only done if running in a standard browser environment.
2392
- // Specifically not if we're in a web worker, or react-native.
2393
- if (platform$1.isStandardBrowserEnv) {
2394
- // Add xsrf header
2395
- const xsrfValue = (config.withCredentials || isURLSameOrigin$1(fullPath))
2396
- && config.xsrfCookieName && cookies$1.read(config.xsrfCookieName);
2397
-
2398
- if (xsrfValue) {
2399
- requestHeaders.set(config.xsrfHeaderName, xsrfValue);
2400
- }
2401
- }
2402
-
2403
- // Remove Content-Type if data is undefined
2404
- requestData === undefined && requestHeaders.setContentType(null);
2405
-
2406
- // Add headers to the request
2407
- if ('setRequestHeader' in request) {
2408
- utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
2409
- request.setRequestHeader(key, val);
2410
- });
2411
- }
2412
-
2413
- // Add withCredentials to request if needed
2414
- if (!utils$1.isUndefined(config.withCredentials)) {
2415
- request.withCredentials = !!config.withCredentials;
2416
- }
2417
-
2418
- // Add responseType to request if needed
2419
- if (responseType && responseType !== 'json') {
2420
- request.responseType = config.responseType;
2421
- }
2422
-
2423
- // Handle progress if needed
2424
- if (typeof config.onDownloadProgress === 'function') {
2425
- request.addEventListener('progress', progressEventReducer$1(config.onDownloadProgress, true));
2426
- }
2427
-
2428
- // Not all browsers support upload events
2429
- if (typeof config.onUploadProgress === 'function' && request.upload) {
2430
- request.upload.addEventListener('progress', progressEventReducer$1(config.onUploadProgress));
2431
- }
2432
-
2433
- if (config.cancelToken || config.signal) {
2434
- // Handle cancellation
2435
- // eslint-disable-next-line func-names
2436
- onCanceled = cancel => {
2437
- if (!request) {
2438
- return;
2439
- }
2440
- reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
2441
- request.abort();
2442
- request = null;
2443
- };
2444
-
2445
- config.cancelToken && config.cancelToken.subscribe(onCanceled);
2446
- if (config.signal) {
2447
- config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
2448
- }
2449
- }
2450
-
2451
- const protocol = parseProtocol$1(fullPath);
2452
-
2453
- if (protocol && platform$1.protocols.indexOf(protocol) === -1) {
2454
- reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
2455
- return;
2456
- }
2457
-
2458
-
2459
- // Send the request
2460
- request.send(requestData || null);
2461
- });
2462
- };
2463
-
2464
- const knownAdapters$1 = {
2465
- http: httpAdapter$1,
2466
- xhr: xhrAdapter$1
2467
- };
2468
-
2469
- utils$1.forEach(knownAdapters$1, (fn, value) => {
2470
- if(fn) {
2471
- try {
2472
- Object.defineProperty(fn, 'name', {value});
2473
- } catch (e) {
2474
- // eslint-disable-next-line no-empty
2475
- }
2476
- Object.defineProperty(fn, 'adapterName', {value});
2477
- }
2478
- });
2479
-
2480
- var adapters$1 = {
2481
- getAdapter: (adapters) => {
2482
- adapters = utils$1.isArray(adapters) ? adapters : [adapters];
2483
-
2484
- const {length} = adapters;
2485
- let nameOrAdapter;
2486
- let adapter;
2487
-
2488
- for (let i = 0; i < length; i++) {
2489
- nameOrAdapter = adapters[i];
2490
- if((adapter = utils$1.isString(nameOrAdapter) ? knownAdapters$1[nameOrAdapter.toLowerCase()] : nameOrAdapter)) {
2491
- break;
2492
- }
2493
- }
2494
-
2495
- if (!adapter) {
2496
- if (adapter === false) {
2497
- throw new AxiosError$1(
2498
- `Adapter ${nameOrAdapter} is not supported by the environment`,
2499
- 'ERR_NOT_SUPPORT'
2500
- );
2501
- }
2502
-
2503
- throw new Error(
2504
- utils$1.hasOwnProp(knownAdapters$1, nameOrAdapter) ?
2505
- `Adapter '${nameOrAdapter}' is not available in the build` :
2506
- `Unknown adapter '${nameOrAdapter}'`
2507
- );
2508
- }
2509
-
2510
- if (!utils$1.isFunction(adapter)) {
2511
- throw new TypeError('adapter is not a function');
2512
- }
2513
-
2514
- return adapter;
2515
- },
2516
- adapters: knownAdapters$1
2517
- };
2518
-
2519
- /**
2520
- * Throws a `CanceledError` if cancellation has been requested.
2521
- *
2522
- * @param {Object} config The config that is to be used for the request
2523
- *
2524
- * @returns {void}
2525
- */
2526
- function throwIfCancellationRequested$1(config) {
2527
- if (config.cancelToken) {
2528
- config.cancelToken.throwIfRequested();
2529
- }
2530
-
2531
- if (config.signal && config.signal.aborted) {
2532
- throw new CanceledError$1(null, config);
2533
- }
2534
- }
2535
-
2536
- /**
2537
- * Dispatch a request to the server using the configured adapter.
2538
- *
2539
- * @param {object} config The config that is to be used for the request
2540
- *
2541
- * @returns {Promise} The Promise to be fulfilled
2542
- */
2543
- function dispatchRequest$1(config) {
2544
- throwIfCancellationRequested$1(config);
2545
-
2546
- config.headers = AxiosHeaders$1$1.from(config.headers);
2547
-
2548
- // Transform request data
2549
- config.data = transformData$1.call(
2550
- config,
2551
- config.transformRequest
2552
- );
2553
-
2554
- if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
2555
- config.headers.setContentType('application/x-www-form-urlencoded', false);
2556
- }
2557
-
2558
- const adapter = adapters$1.getAdapter(config.adapter || defaults$1$1.adapter);
2559
-
2560
- return adapter(config).then(function onAdapterResolution(response) {
2561
- throwIfCancellationRequested$1(config);
2562
-
2563
- // Transform response data
2564
- response.data = transformData$1.call(
2565
- config,
2566
- config.transformResponse,
2567
- response
2568
- );
2569
-
2570
- response.headers = AxiosHeaders$1$1.from(response.headers);
2571
-
2572
- return response;
2573
- }, function onAdapterRejection(reason) {
2574
- if (!isCancel$1(reason)) {
2575
- throwIfCancellationRequested$1(config);
2576
-
2577
- // Transform response data
2578
- if (reason && reason.response) {
2579
- reason.response.data = transformData$1.call(
2580
- config,
2581
- config.transformResponse,
2582
- reason.response
2583
- );
2584
- reason.response.headers = AxiosHeaders$1$1.from(reason.response.headers);
2585
- }
2586
- }
2587
-
2588
- return Promise.reject(reason);
2589
- });
2590
- }
2591
-
2592
- const headersToObject$1 = (thing) => thing instanceof AxiosHeaders$1$1 ? thing.toJSON() : thing;
2593
-
2594
- /**
2595
- * Config-specific merge-function which creates a new config-object
2596
- * by merging two configuration objects together.
2597
- *
2598
- * @param {Object} config1
2599
- * @param {Object} config2
2600
- *
2601
- * @returns {Object} New object resulting from merging config2 to config1
2602
- */
2603
- function mergeConfig$1(config1, config2) {
2604
- // eslint-disable-next-line no-param-reassign
2605
- config2 = config2 || {};
2606
- const config = {};
2607
-
2608
- function getMergedValue(target, source, caseless) {
2609
- if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
2610
- return utils$1.merge.call({caseless}, target, source);
2611
- } else if (utils$1.isPlainObject(source)) {
2612
- return utils$1.merge({}, source);
2613
- } else if (utils$1.isArray(source)) {
2614
- return source.slice();
2615
- }
2616
- return source;
2617
- }
2618
-
2619
- // eslint-disable-next-line consistent-return
2620
- function mergeDeepProperties(a, b, caseless) {
2621
- if (!utils$1.isUndefined(b)) {
2622
- return getMergedValue(a, b, caseless);
2623
- } else if (!utils$1.isUndefined(a)) {
2624
- return getMergedValue(undefined, a, caseless);
2625
- }
2626
- }
2627
-
2628
- // eslint-disable-next-line consistent-return
2629
- function valueFromConfig2(a, b) {
2630
- if (!utils$1.isUndefined(b)) {
2631
- return getMergedValue(undefined, b);
2632
- }
2633
- }
2634
-
2635
- // eslint-disable-next-line consistent-return
2636
- function defaultToConfig2(a, b) {
2637
- if (!utils$1.isUndefined(b)) {
2638
- return getMergedValue(undefined, b);
2639
- } else if (!utils$1.isUndefined(a)) {
2640
- return getMergedValue(undefined, a);
2641
- }
2642
- }
2643
-
2644
- // eslint-disable-next-line consistent-return
2645
- function mergeDirectKeys(a, b, prop) {
2646
- if (prop in config2) {
2647
- return getMergedValue(a, b);
2648
- } else if (prop in config1) {
2649
- return getMergedValue(undefined, a);
2650
- }
2651
- }
2652
-
2653
- const mergeMap = {
2654
- url: valueFromConfig2,
2655
- method: valueFromConfig2,
2656
- data: valueFromConfig2,
2657
- baseURL: defaultToConfig2,
2658
- transformRequest: defaultToConfig2,
2659
- transformResponse: defaultToConfig2,
2660
- paramsSerializer: defaultToConfig2,
2661
- timeout: defaultToConfig2,
2662
- timeoutMessage: defaultToConfig2,
2663
- withCredentials: defaultToConfig2,
2664
- adapter: defaultToConfig2,
2665
- responseType: defaultToConfig2,
2666
- xsrfCookieName: defaultToConfig2,
2667
- xsrfHeaderName: defaultToConfig2,
2668
- onUploadProgress: defaultToConfig2,
2669
- onDownloadProgress: defaultToConfig2,
2670
- decompress: defaultToConfig2,
2671
- maxContentLength: defaultToConfig2,
2672
- maxBodyLength: defaultToConfig2,
2673
- beforeRedirect: defaultToConfig2,
2674
- transport: defaultToConfig2,
2675
- httpAgent: defaultToConfig2,
2676
- httpsAgent: defaultToConfig2,
2677
- cancelToken: defaultToConfig2,
2678
- socketPath: defaultToConfig2,
2679
- responseEncoding: defaultToConfig2,
2680
- validateStatus: mergeDirectKeys,
2681
- headers: (a, b) => mergeDeepProperties(headersToObject$1(a), headersToObject$1(b), true)
2682
- };
2683
-
2684
- utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
2685
- const merge = mergeMap[prop] || mergeDeepProperties;
2686
- const configValue = merge(config1[prop], config2[prop], prop);
2687
- (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2688
- });
2689
-
2690
- return config;
2691
- }
2692
-
2693
- const VERSION$1 = "1.4.0";
2694
-
2695
- const validators$1$1 = {};
2696
-
2697
- // eslint-disable-next-line func-names
2698
- ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {
2699
- validators$1$1[type] = function validator(thing) {
2700
- return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
2701
- };
2702
- });
2703
-
2704
- const deprecatedWarnings$1 = {};
2705
-
2706
- /**
2707
- * Transitional option validator
2708
- *
2709
- * @param {function|boolean?} validator - set to false if the transitional option has been removed
2710
- * @param {string?} version - deprecated version / removed since version
2711
- * @param {string?} message - some message with additional info
2712
- *
2713
- * @returns {function}
2714
- */
2715
- validators$1$1.transitional = function transitional(validator, version, message) {
2716
- function formatMessage(opt, desc) {
2717
- return '[Axios v' + VERSION$1 + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
2718
- }
2719
-
2720
- // eslint-disable-next-line func-names
2721
- return (value, opt, opts) => {
2722
- if (validator === false) {
2723
- throw new AxiosError$1(
2724
- formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
2725
- AxiosError$1.ERR_DEPRECATED
2726
- );
2727
- }
2728
-
2729
- if (version && !deprecatedWarnings$1[opt]) {
2730
- deprecatedWarnings$1[opt] = true;
2731
- // eslint-disable-next-line no-console
2732
- console.warn(
2733
- formatMessage(
2734
- opt,
2735
- ' has been deprecated since v' + version + ' and will be removed in the near future'
2736
- )
2737
- );
2738
- }
2739
-
2740
- return validator ? validator(value, opt, opts) : true;
2741
- };
2742
- };
2743
-
2744
- /**
2745
- * Assert object's properties type
2746
- *
2747
- * @param {object} options
2748
- * @param {object} schema
2749
- * @param {boolean?} allowUnknown
2750
- *
2751
- * @returns {object}
2752
- */
2753
-
2754
- function assertOptions$1(options, schema, allowUnknown) {
2755
- if (typeof options !== 'object') {
2756
- throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
2757
- }
2758
- const keys = Object.keys(options);
2759
- let i = keys.length;
2760
- while (i-- > 0) {
2761
- const opt = keys[i];
2762
- const validator = schema[opt];
2763
- if (validator) {
2764
- const value = options[opt];
2765
- const result = value === undefined || validator(value, opt, options);
2766
- if (result !== true) {
2767
- throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
2768
- }
2769
- continue;
2770
- }
2771
- if (allowUnknown !== true) {
2772
- throw new AxiosError$1('Unknown option ' + opt, AxiosError$1.ERR_BAD_OPTION);
2773
- }
2774
- }
2775
- }
2776
-
2777
- var validator$1 = {
2778
- assertOptions: assertOptions$1,
2779
- validators: validators$1$1
2780
- };
2781
-
2782
- const validators$2 = validator$1.validators;
2783
-
2784
- /**
2785
- * Create a new instance of Axios
2786
- *
2787
- * @param {Object} instanceConfig The default config for the instance
2788
- *
2789
- * @return {Axios} A new instance of Axios
2790
- */
2791
- let Axios$2 = class Axios {
2792
- constructor(instanceConfig) {
2793
- this.defaults = instanceConfig;
2794
- this.interceptors = {
2795
- request: new InterceptorManager$1$1(),
2796
- response: new InterceptorManager$1$1()
2797
- };
2798
- }
2799
-
2800
- /**
2801
- * Dispatch a request
2802
- *
2803
- * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
2804
- * @param {?Object} config
2805
- *
2806
- * @returns {Promise} The Promise to be fulfilled
2807
- */
2808
- request(configOrUrl, config) {
2809
- /*eslint no-param-reassign:0*/
2810
- // Allow for axios('example/url'[, config]) a la fetch API
2811
- if (typeof configOrUrl === 'string') {
2812
- config = config || {};
2813
- config.url = configOrUrl;
2814
- } else {
2815
- config = configOrUrl || {};
2816
- }
2817
-
2818
- config = mergeConfig$1(this.defaults, config);
2819
-
2820
- const {transitional, paramsSerializer, headers} = config;
2821
-
2822
- if (transitional !== undefined) {
2823
- validator$1.assertOptions(transitional, {
2824
- silentJSONParsing: validators$2.transitional(validators$2.boolean),
2825
- forcedJSONParsing: validators$2.transitional(validators$2.boolean),
2826
- clarifyTimeoutError: validators$2.transitional(validators$2.boolean)
2827
- }, false);
2828
- }
2829
-
2830
- if (paramsSerializer != null) {
2831
- if (utils$1.isFunction(paramsSerializer)) {
2832
- config.paramsSerializer = {
2833
- serialize: paramsSerializer
2834
- };
2835
- } else {
2836
- validator$1.assertOptions(paramsSerializer, {
2837
- encode: validators$2.function,
2838
- serialize: validators$2.function
2839
- }, true);
2840
- }
2841
- }
2842
-
2843
- // Set config.method
2844
- config.method = (config.method || this.defaults.method || 'get').toLowerCase();
2845
-
2846
- let contextHeaders;
2847
-
2848
- // Flatten headers
2849
- contextHeaders = headers && utils$1.merge(
2850
- headers.common,
2851
- headers[config.method]
2852
- );
2853
-
2854
- contextHeaders && utils$1.forEach(
2855
- ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
2856
- (method) => {
2857
- delete headers[method];
2858
- }
2859
- );
2860
-
2861
- config.headers = AxiosHeaders$1$1.concat(contextHeaders, headers);
2862
-
2863
- // filter out skipped interceptors
2864
- const requestInterceptorChain = [];
2865
- let synchronousRequestInterceptors = true;
2866
- this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
2867
- if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
2868
- return;
2869
- }
2870
-
2871
- synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
2872
-
2873
- requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
2874
- });
2875
-
2876
- const responseInterceptorChain = [];
2877
- this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
2878
- responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
2879
- });
2880
-
2881
- let promise;
2882
- let i = 0;
2883
- let len;
2884
-
2885
- if (!synchronousRequestInterceptors) {
2886
- const chain = [dispatchRequest$1.bind(this), undefined];
2887
- chain.unshift.apply(chain, requestInterceptorChain);
2888
- chain.push.apply(chain, responseInterceptorChain);
2889
- len = chain.length;
2890
-
2891
- promise = Promise.resolve(config);
2892
-
2893
- while (i < len) {
2894
- promise = promise.then(chain[i++], chain[i++]);
2895
- }
2896
-
2897
- return promise;
2898
- }
2899
-
2900
- len = requestInterceptorChain.length;
2901
-
2902
- let newConfig = config;
2903
-
2904
- i = 0;
2905
-
2906
- while (i < len) {
2907
- const onFulfilled = requestInterceptorChain[i++];
2908
- const onRejected = requestInterceptorChain[i++];
2909
- try {
2910
- newConfig = onFulfilled(newConfig);
2911
- } catch (error) {
2912
- onRejected.call(this, error);
2913
- break;
2914
- }
2915
- }
2916
-
2917
- try {
2918
- promise = dispatchRequest$1.call(this, newConfig);
2919
- } catch (error) {
2920
- return Promise.reject(error);
2921
- }
2922
-
2923
- i = 0;
2924
- len = responseInterceptorChain.length;
2925
-
2926
- while (i < len) {
2927
- promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
2928
- }
2929
-
2930
- return promise;
2931
- }
2932
-
2933
- getUri(config) {
2934
- config = mergeConfig$1(this.defaults, config);
2935
- const fullPath = buildFullPath$1(config.baseURL, config.url);
2936
- return buildURL$1(fullPath, config.params, config.paramsSerializer);
2937
- }
2938
- };
2939
-
2940
- // Provide aliases for supported request methods
2941
- utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
2942
- /*eslint func-names:0*/
2943
- Axios$2.prototype[method] = function(url, config) {
2944
- return this.request(mergeConfig$1(config || {}, {
2945
- method,
2946
- url,
2947
- data: (config || {}).data
2948
- }));
2949
- };
2950
- });
2951
-
2952
- utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
2953
- /*eslint func-names:0*/
2954
-
2955
- function generateHTTPMethod(isForm) {
2956
- return function httpMethod(url, data, config) {
2957
- return this.request(mergeConfig$1(config || {}, {
2958
- method,
2959
- headers: isForm ? {
2960
- 'Content-Type': 'multipart/form-data'
2961
- } : {},
2962
- url,
2963
- data
2964
- }));
2965
- };
2966
- }
2967
-
2968
- Axios$2.prototype[method] = generateHTTPMethod();
2969
-
2970
- Axios$2.prototype[method + 'Form'] = generateHTTPMethod(true);
2971
- });
2972
-
2973
- var Axios$1$1 = Axios$2;
2974
-
2975
- /**
2976
- * A `CancelToken` is an object that can be used to request cancellation of an operation.
2977
- *
2978
- * @param {Function} executor The executor function.
2979
- *
2980
- * @returns {CancelToken}
2981
- */
2982
- let CancelToken$2 = class CancelToken {
2983
- constructor(executor) {
2984
- if (typeof executor !== 'function') {
2985
- throw new TypeError('executor must be a function.');
2986
- }
2987
-
2988
- let resolvePromise;
2989
-
2990
- this.promise = new Promise(function promiseExecutor(resolve) {
2991
- resolvePromise = resolve;
2992
- });
2993
-
2994
- const token = this;
2995
-
2996
- // eslint-disable-next-line func-names
2997
- this.promise.then(cancel => {
2998
- if (!token._listeners) return;
2999
-
3000
- let i = token._listeners.length;
3001
-
3002
- while (i-- > 0) {
3003
- token._listeners[i](cancel);
3004
- }
3005
- token._listeners = null;
3006
- });
3007
-
3008
- // eslint-disable-next-line func-names
3009
- this.promise.then = onfulfilled => {
3010
- let _resolve;
3011
- // eslint-disable-next-line func-names
3012
- const promise = new Promise(resolve => {
3013
- token.subscribe(resolve);
3014
- _resolve = resolve;
3015
- }).then(onfulfilled);
3016
-
3017
- promise.cancel = function reject() {
3018
- token.unsubscribe(_resolve);
3019
- };
3020
-
3021
- return promise;
3022
- };
3023
-
3024
- executor(function cancel(message, config, request) {
3025
- if (token.reason) {
3026
- // Cancellation has already been requested
3027
- return;
3028
- }
3029
-
3030
- token.reason = new CanceledError$1(message, config, request);
3031
- resolvePromise(token.reason);
3032
- });
3033
- }
3034
-
3035
- /**
3036
- * Throws a `CanceledError` if cancellation has been requested.
3037
- */
3038
- throwIfRequested() {
3039
- if (this.reason) {
3040
- throw this.reason;
3041
- }
3042
- }
3043
-
3044
- /**
3045
- * Subscribe to the cancel signal
3046
- */
3047
-
3048
- subscribe(listener) {
3049
- if (this.reason) {
3050
- listener(this.reason);
3051
- return;
3052
- }
3053
-
3054
- if (this._listeners) {
3055
- this._listeners.push(listener);
3056
- } else {
3057
- this._listeners = [listener];
3058
- }
3059
- }
3060
-
3061
- /**
3062
- * Unsubscribe from the cancel signal
3063
- */
3064
-
3065
- unsubscribe(listener) {
3066
- if (!this._listeners) {
3067
- return;
3068
- }
3069
- const index = this._listeners.indexOf(listener);
3070
- if (index !== -1) {
3071
- this._listeners.splice(index, 1);
3072
- }
3073
- }
3074
-
3075
- /**
3076
- * Returns an object that contains a new `CancelToken` and a function that, when called,
3077
- * cancels the `CancelToken`.
3078
- */
3079
- static source() {
3080
- let cancel;
3081
- const token = new CancelToken(function executor(c) {
3082
- cancel = c;
3083
- });
3084
- return {
3085
- token,
3086
- cancel
3087
- };
3088
- }
3089
- };
3090
-
3091
- var CancelToken$1$1 = CancelToken$2;
3092
-
3093
- /**
3094
- * Syntactic sugar for invoking a function and expanding an array for arguments.
3095
- *
3096
- * Common use case would be to use `Function.prototype.apply`.
3097
- *
3098
- * ```js
3099
- * function f(x, y, z) {}
3100
- * var args = [1, 2, 3];
3101
- * f.apply(null, args);
3102
- * ```
3103
- *
3104
- * With `spread` this example can be re-written.
3105
- *
3106
- * ```js
3107
- * spread(function(x, y, z) {})([1, 2, 3]);
3108
- * ```
3109
- *
3110
- * @param {Function} callback
3111
- *
3112
- * @returns {Function}
3113
- */
3114
- function spread$1(callback) {
3115
- return function wrap(arr) {
3116
- return callback.apply(null, arr);
3117
- };
3118
- }
3119
-
3120
- /**
3121
- * Determines whether the payload is an error thrown by Axios
3122
- *
3123
- * @param {*} payload The value to test
3124
- *
3125
- * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
3126
- */
3127
- function isAxiosError$1(payload) {
3128
- return utils$1.isObject(payload) && (payload.isAxiosError === true);
3129
- }
3130
-
3131
- const HttpStatusCode$2 = {
3132
- Continue: 100,
3133
- SwitchingProtocols: 101,
3134
- Processing: 102,
3135
- EarlyHints: 103,
3136
- Ok: 200,
3137
- Created: 201,
3138
- Accepted: 202,
3139
- NonAuthoritativeInformation: 203,
3140
- NoContent: 204,
3141
- ResetContent: 205,
3142
- PartialContent: 206,
3143
- MultiStatus: 207,
3144
- AlreadyReported: 208,
3145
- ImUsed: 226,
3146
- MultipleChoices: 300,
3147
- MovedPermanently: 301,
3148
- Found: 302,
3149
- SeeOther: 303,
3150
- NotModified: 304,
3151
- UseProxy: 305,
3152
- Unused: 306,
3153
- TemporaryRedirect: 307,
3154
- PermanentRedirect: 308,
3155
- BadRequest: 400,
3156
- Unauthorized: 401,
3157
- PaymentRequired: 402,
3158
- Forbidden: 403,
3159
- NotFound: 404,
3160
- MethodNotAllowed: 405,
3161
- NotAcceptable: 406,
3162
- ProxyAuthenticationRequired: 407,
3163
- RequestTimeout: 408,
3164
- Conflict: 409,
3165
- Gone: 410,
3166
- LengthRequired: 411,
3167
- PreconditionFailed: 412,
3168
- PayloadTooLarge: 413,
3169
- UriTooLong: 414,
3170
- UnsupportedMediaType: 415,
3171
- RangeNotSatisfiable: 416,
3172
- ExpectationFailed: 417,
3173
- ImATeapot: 418,
3174
- MisdirectedRequest: 421,
3175
- UnprocessableEntity: 422,
3176
- Locked: 423,
3177
- FailedDependency: 424,
3178
- TooEarly: 425,
3179
- UpgradeRequired: 426,
3180
- PreconditionRequired: 428,
3181
- TooManyRequests: 429,
3182
- RequestHeaderFieldsTooLarge: 431,
3183
- UnavailableForLegalReasons: 451,
3184
- InternalServerError: 500,
3185
- NotImplemented: 501,
3186
- BadGateway: 502,
3187
- ServiceUnavailable: 503,
3188
- GatewayTimeout: 504,
3189
- HttpVersionNotSupported: 505,
3190
- VariantAlsoNegotiates: 506,
3191
- InsufficientStorage: 507,
3192
- LoopDetected: 508,
3193
- NotExtended: 510,
3194
- NetworkAuthenticationRequired: 511,
3195
- };
3196
-
3197
- Object.entries(HttpStatusCode$2).forEach(([key, value]) => {
3198
- HttpStatusCode$2[value] = key;
3199
- });
3200
-
3201
- var HttpStatusCode$1$1 = HttpStatusCode$2;
3202
-
3203
- /**
3204
- * Create an instance of Axios
3205
- *
3206
- * @param {Object} defaultConfig The default config for the instance
3207
- *
3208
- * @returns {Axios} A new instance of Axios
3209
- */
3210
- function createInstance$1(defaultConfig) {
3211
- const context = new Axios$1$1(defaultConfig);
3212
- const instance = bind$1(Axios$1$1.prototype.request, context);
3213
-
3214
- // Copy axios.prototype to instance
3215
- utils$1.extend(instance, Axios$1$1.prototype, context, {allOwnKeys: true});
3216
-
3217
- // Copy context to instance
3218
- utils$1.extend(instance, context, null, {allOwnKeys: true});
3219
-
3220
- // Factory for creating new instances
3221
- instance.create = function create(instanceConfig) {
3222
- return createInstance$1(mergeConfig$1(defaultConfig, instanceConfig));
3223
- };
3224
-
3225
- return instance;
3226
- }
3227
-
3228
- // Create the default instance to be exported
3229
- const axios$1 = createInstance$1(defaults$1$1);
3230
-
3231
- // Expose Axios class to allow class inheritance
3232
- axios$1.Axios = Axios$1$1;
3233
-
3234
- // Expose Cancel & CancelToken
3235
- axios$1.CanceledError = CanceledError$1;
3236
- axios$1.CancelToken = CancelToken$1$1;
3237
- axios$1.isCancel = isCancel$1;
3238
- axios$1.VERSION = VERSION$1;
3239
- axios$1.toFormData = toFormData$1;
3240
-
3241
- // Expose AxiosError class
3242
- axios$1.AxiosError = AxiosError$1;
3243
-
3244
- // alias for CanceledError for backward compatibility
3245
- axios$1.Cancel = axios$1.CanceledError;
3246
-
3247
- // Expose all/spread
3248
- axios$1.all = function all(promises) {
3249
- return Promise.all(promises);
3250
- };
3251
-
3252
- axios$1.spread = spread$1;
3253
-
3254
- // Expose isAxiosError
3255
- axios$1.isAxiosError = isAxiosError$1;
3256
-
3257
- // Expose mergeConfig
3258
- axios$1.mergeConfig = mergeConfig$1;
3259
-
3260
- axios$1.AxiosHeaders = AxiosHeaders$1$1;
3261
-
3262
- axios$1.formToJSON = thing => formDataToJSON$1(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
3263
-
3264
- axios$1.HttpStatusCode = HttpStatusCode$1$1;
3265
-
3266
- axios$1.default = axios$1;
3267
-
3268
- // this module should only have a default export
3269
- var globalAxios$1 = axios$1;
3270
-
3271
- /* tslint:disable */
3272
- /* eslint-disable */
3273
- /**
3274
- * Immutable X API
3275
- * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3276
- *
3277
- * The version of the OpenAPI document: 3.0
3278
- * Contact: support@immutable.com
3279
- *
3280
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
3281
- * https://openapi-generator.tech
3282
- * Do not edit the class manually.
3283
- */
3284
- let Configuration$1 = class Configuration {
3285
- /**
3286
- * parameter for apiKey security
3287
- * @param name security name
3288
- * @memberof Configuration
3289
- */
3290
- apiKey;
3291
- /**
3292
- * parameter for basic security
3293
- *
3294
- * @type {string}
3295
- * @memberof Configuration
3296
- */
3297
- username;
3298
- /**
3299
- * parameter for basic security
3300
- *
3301
- * @type {string}
3302
- * @memberof Configuration
3303
- */
3304
- password;
3305
- /**
3306
- * parameter for oauth2 security
3307
- * @param name security name
3308
- * @param scopes oauth2 scope
3309
- * @memberof Configuration
3310
- */
3311
- accessToken;
3312
- /**
3313
- * override base path
3314
- *
3315
- * @type {string}
3316
- * @memberof Configuration
3317
- */
3318
- basePath;
3319
- /**
3320
- * base options for axios calls
3321
- *
3322
- * @type {any}
3323
- * @memberof Configuration
3324
- */
3325
- baseOptions;
3326
- /**
3327
- * The FormData constructor that will be used to create multipart form data
3328
- * requests. You can inject this here so that execution environments that
3329
- * do not support the FormData class can still run the generated client.
3330
- *
3331
- * @type {new () => FormData}
3332
- */
3333
- formDataCtor;
3334
- constructor(param = {}) {
3335
- this.apiKey = param.apiKey;
3336
- this.username = param.username;
3337
- this.password = param.password;
3338
- this.accessToken = param.accessToken;
3339
- this.basePath = param.basePath;
3340
- this.baseOptions = param.baseOptions;
3341
- this.formDataCtor = param.formDataCtor;
3342
- }
3343
- /**
3344
- * Check if the given MIME is a JSON MIME.
3345
- * JSON MIME examples:
3346
- * application/json
3347
- * application/json; charset=UTF8
3348
- * APPLICATION/JSON
3349
- * application/vnd.company+json
3350
- * @param mime - MIME (Multipurpose Internet Mail Extensions)
3351
- * @return True if the given MIME is JSON, false otherwise.
3352
- */
3353
- isJsonMime(mime) {
3354
- const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
3355
- return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
38
+ });
3356
39
  }
3357
- };
40
+ n.default = e;
41
+ return Object.freeze(n);
42
+ }
43
+
44
+ var encUtils__namespace = /*#__PURE__*/_interopNamespaceDefault(encUtils);
45
+
46
+ exports.Environment = void 0;
47
+ (function (Environment) {
48
+ Environment["PRODUCTION"] = "production";
49
+ Environment["SANDBOX"] = "sandbox";
50
+ })(exports.Environment || (exports.Environment = {}));
51
+ class ImmutableConfiguration {
52
+ environment;
53
+ apiKey;
54
+ constructor(options) {
55
+ this.environment = options.environment;
56
+ this.apiKey = options.apiKey;
57
+ }
58
+ }
3358
59
 
3359
60
  /* tslint:disable */
3360
61
  /* eslint-disable */
@@ -5064,7 +1765,7 @@ class TokensApi extends BaseAPI$1 {
5064
1765
  * https://openapi-generator.tech
5065
1766
  * Do not edit the class manually.
5066
1767
  */
5067
- let Configuration$2 = class Configuration {
1768
+ let Configuration$1 = class Configuration {
5068
1769
  /**
5069
1770
  * parameter for apiKey security
5070
1771
  * @param name security name
@@ -5476,122 +2177,59 @@ const TokenContractType = {
5476
2177
  */
5477
2178
 
5478
2179
  var index = /*#__PURE__*/Object.freeze({
5479
- __proto__: null,
5480
- APIError400AllOfCodeEnum: APIError400AllOfCodeEnum,
5481
- APIError401AllOfCodeEnum: APIError401AllOfCodeEnum,
5482
- APIError403AllOfCodeEnum: APIError403AllOfCodeEnum,
5483
- APIError404AllOfCodeEnum: APIError404AllOfCodeEnum,
5484
- APIError429AllOfCodeEnum: APIError429AllOfCodeEnum,
5485
- APIError500AllOfCodeEnum: APIError500AllOfCodeEnum,
5486
- ActivitiesApi: ActivitiesApi,
5487
- ActivitiesApiAxiosParamCreator: ActivitiesApiAxiosParamCreator,
5488
- ActivitiesApiFactory: ActivitiesApiFactory,
5489
- ActivitiesApiFp: ActivitiesApiFp,
5490
- ActivityType: ActivityType,
5491
- ChainsApi: ChainsApi,
5492
- ChainsApiAxiosParamCreator: ChainsApiAxiosParamCreator,
5493
- ChainsApiFactory: ChainsApiFactory,
5494
- ChainsApiFp: ChainsApiFp,
5495
- CollectionContractType: CollectionContractType,
5496
- CollectionsApi: CollectionsApi,
5497
- CollectionsApiAxiosParamCreator: CollectionsApiAxiosParamCreator,
5498
- CollectionsApiFactory: CollectionsApiFactory,
5499
- CollectionsApiFp: CollectionsApiFp,
5500
- Configuration: Configuration$2,
5501
- CreateOrderProtocolDataOrderTypeEnum: CreateOrderProtocolDataOrderTypeEnum,
5502
- ERC20ItemItemTypeEnum: ERC20ItemItemTypeEnum,
5503
- ERC721ItemItemTypeEnum: ERC721ItemItemTypeEnum,
5504
- FeeFeeTypeEnum: FeeFeeTypeEnum,
5505
- NFTContractType: NFTContractType,
5506
- NativeItemItemTypeEnum: NativeItemItemTypeEnum,
5507
- NftOwnersApi: NftOwnersApi,
5508
- NftOwnersApiAxiosParamCreator: NftOwnersApiAxiosParamCreator,
5509
- NftOwnersApiFactory: NftOwnersApiFactory,
5510
- NftOwnersApiFp: NftOwnersApiFp,
5511
- NftsApi: NftsApi,
5512
- NftsApiAxiosParamCreator: NftsApiAxiosParamCreator,
5513
- NftsApiFactory: NftsApiFactory,
5514
- NftsApiFp: NftsApiFp,
5515
- OrderStatus: OrderStatus$1,
5516
- OrdersApi: OrdersApi,
5517
- OrdersApiAxiosParamCreator: OrdersApiAxiosParamCreator,
5518
- OrdersApiFactory: OrdersApiFactory,
5519
- OrdersApiFp: OrdersApiFp,
5520
- PassportApi: PassportApi,
5521
- PassportApiAxiosParamCreator: PassportApiAxiosParamCreator,
5522
- PassportApiFactory: PassportApiFactory,
5523
- PassportApiFp: PassportApiFp,
5524
- SaleFeeTypeEnum: SaleFeeTypeEnum,
5525
- TokenContractType: TokenContractType,
5526
- TokensApi: TokensApi,
5527
- TokensApiAxiosParamCreator: TokensApiAxiosParamCreator,
5528
- TokensApiFactory: TokensApiFactory,
5529
- TokensApiFp: TokensApiFp
2180
+ __proto__: null,
2181
+ APIError400AllOfCodeEnum: APIError400AllOfCodeEnum,
2182
+ APIError401AllOfCodeEnum: APIError401AllOfCodeEnum,
2183
+ APIError403AllOfCodeEnum: APIError403AllOfCodeEnum,
2184
+ APIError404AllOfCodeEnum: APIError404AllOfCodeEnum,
2185
+ APIError429AllOfCodeEnum: APIError429AllOfCodeEnum,
2186
+ APIError500AllOfCodeEnum: APIError500AllOfCodeEnum,
2187
+ ActivitiesApi: ActivitiesApi,
2188
+ ActivitiesApiAxiosParamCreator: ActivitiesApiAxiosParamCreator,
2189
+ ActivitiesApiFactory: ActivitiesApiFactory,
2190
+ ActivitiesApiFp: ActivitiesApiFp,
2191
+ ActivityType: ActivityType,
2192
+ ChainsApi: ChainsApi,
2193
+ ChainsApiAxiosParamCreator: ChainsApiAxiosParamCreator,
2194
+ ChainsApiFactory: ChainsApiFactory,
2195
+ ChainsApiFp: ChainsApiFp,
2196
+ CollectionContractType: CollectionContractType,
2197
+ CollectionsApi: CollectionsApi,
2198
+ CollectionsApiAxiosParamCreator: CollectionsApiAxiosParamCreator,
2199
+ CollectionsApiFactory: CollectionsApiFactory,
2200
+ CollectionsApiFp: CollectionsApiFp,
2201
+ Configuration: Configuration$1,
2202
+ CreateOrderProtocolDataOrderTypeEnum: CreateOrderProtocolDataOrderTypeEnum,
2203
+ ERC20ItemItemTypeEnum: ERC20ItemItemTypeEnum,
2204
+ ERC721ItemItemTypeEnum: ERC721ItemItemTypeEnum,
2205
+ FeeFeeTypeEnum: FeeFeeTypeEnum,
2206
+ NFTContractType: NFTContractType,
2207
+ NativeItemItemTypeEnum: NativeItemItemTypeEnum,
2208
+ NftOwnersApi: NftOwnersApi,
2209
+ NftOwnersApiAxiosParamCreator: NftOwnersApiAxiosParamCreator,
2210
+ NftOwnersApiFactory: NftOwnersApiFactory,
2211
+ NftOwnersApiFp: NftOwnersApiFp,
2212
+ NftsApi: NftsApi,
2213
+ NftsApiAxiosParamCreator: NftsApiAxiosParamCreator,
2214
+ NftsApiFactory: NftsApiFactory,
2215
+ NftsApiFp: NftsApiFp,
2216
+ OrderStatus: OrderStatus$1,
2217
+ OrdersApi: OrdersApi,
2218
+ OrdersApiAxiosParamCreator: OrdersApiAxiosParamCreator,
2219
+ OrdersApiFactory: OrdersApiFactory,
2220
+ OrdersApiFp: OrdersApiFp,
2221
+ PassportApi: PassportApi,
2222
+ PassportApiAxiosParamCreator: PassportApiAxiosParamCreator,
2223
+ PassportApiFactory: PassportApiFactory,
2224
+ PassportApiFp: PassportApiFp,
2225
+ SaleFeeTypeEnum: SaleFeeTypeEnum,
2226
+ TokenContractType: TokenContractType,
2227
+ TokensApi: TokensApi,
2228
+ TokensApiAxiosParamCreator: TokensApiAxiosParamCreator,
2229
+ TokensApiFactory: TokensApiFactory,
2230
+ TokensApiFp: TokensApiFp
5530
2231
  });
5531
2232
 
5532
- class MultiRollupApiClients {
5533
- config;
5534
- activitiesApi;
5535
- chainsApi;
5536
- collectionApi;
5537
- nftOwnersApi;
5538
- nftsApi;
5539
- ordersApi;
5540
- passportApi;
5541
- constructor(config) {
5542
- this.config = config;
5543
- this.activitiesApi = new ActivitiesApi(config.indexer);
5544
- this.chainsApi = new ChainsApi(config.indexer);
5545
- this.collectionApi = new CollectionsApi(config.indexer);
5546
- this.nftOwnersApi = new NftOwnersApi(config.indexer);
5547
- this.nftsApi = new NftsApi(config.indexer);
5548
- this.ordersApi = new OrdersApi(config.orderBook);
5549
- this.passportApi = new PassportApi(config.passport);
5550
- }
5551
- }
5552
-
5553
- // eslint-disable-next-line @typescript-eslint/naming-convention
5554
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.4.0-alpha' };
5555
- const createConfig = ({ basePath, headers, }) => {
5556
- if (!basePath.trim()) {
5557
- throw Error('basePath can not be empty');
5558
- }
5559
- const composedHeaders = { ...defaultHeaders$1, ...(headers || {}) };
5560
- const apiConfigOptions = {
5561
- basePath,
5562
- baseOptions: { headers: composedHeaders },
5563
- };
5564
- return new Configuration$1(apiConfigOptions);
5565
- };
5566
- /**
5567
- * Creates a Configuration for the specified environment
5568
- * @returns an MultiRollupAPIConfiguration
5569
- */
5570
- const multiRollupConfig = {
5571
- getProduction: () => ({
5572
- indexer: createConfig({
5573
- basePath: 'https://indexer-mr.imtbl.com',
5574
- }),
5575
- orderBook: createConfig({
5576
- basePath: 'https://order-book-mr.imtbl.com',
5577
- }),
5578
- passport: createConfig({
5579
- basePath: 'https://api.immutable.com',
5580
- }),
5581
- }),
5582
- getSandbox: () => ({
5583
- indexer: createConfig({
5584
- basePath: 'https://indexer-mr.sandbox.imtbl.com',
5585
- }),
5586
- orderBook: createConfig({
5587
- basePath: 'https://order-book-mr.sandbox.imtbl.com',
5588
- }),
5589
- passport: createConfig({
5590
- basePath: 'https://api.sandbox.immutable.com',
5591
- }),
5592
- }),
5593
- };
5594
-
5595
2233
  /**
5596
2234
  * Custom Error class that is returned from the API when a request fails
5597
2235
  */
@@ -5611,7 +2249,7 @@ class APIError extends Error {
5611
2249
 
5612
2250
  /* eslint-disable implicit-arrow-linebreak */
5613
2251
  const defaultHeaders = {
5614
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.4.0-alpha',
2252
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.4.0-alpha.2',
5615
2253
  };
5616
2254
  /**
5617
2255
  * createAPIConfiguration to create a custom Configuration
@@ -5667,7 +2305,7 @@ class BlockchainDataConfiguration {
5667
2305
  * @returns APIError
5668
2306
  */
5669
2307
  function formatError(error) {
5670
- if (axios$2.isAxiosError(error) && error.response) {
2308
+ if (globalAxios$1.isAxiosError(error) && error.response) {
5671
2309
  const apiError = error.response.data;
5672
2310
  if (apiError.code && apiError.message) {
5673
2311
  return new APIError({
@@ -5877,7 +2515,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
5877
2515
  chainID,
5878
2516
  coreContractAddress,
5879
2517
  registrationContractAddress,
5880
- sdkVersion: 'ts-immutable-sdk-0.4.0-alpha',
2518
+ sdkVersion: 'ts-immutable-sdk-0.4.0-alpha.2',
5881
2519
  });
5882
2520
  /**
5883
2521
  * Sets `sdkVersion` at the time of build
@@ -9601,8 +6239,6 @@ var globalAxios = axios;
9601
6239
  * https://openapi-generator.tech
9602
6240
  * Do not edit the class manually.
9603
6241
  */
9604
- // Some imports not used depending on template conditions
9605
- // @ts-ignore
9606
6242
  const BASE_PATH = "https://guardian.sandbox.imtbl.com".replace(/\/+$/, "");
9607
6243
  /**
9608
6244
  *
@@ -9630,10 +6266,10 @@ class BaseAPI {
9630
6266
  */
9631
6267
  class RequiredError extends Error {
9632
6268
  field;
9633
- name = "RequiredError";
9634
6269
  constructor(field, msg) {
9635
6270
  super(msg);
9636
6271
  this.field = field;
6272
+ this.name = "RequiredError";
9637
6273
  }
9638
6274
  }
9639
6275
 
@@ -9678,6 +6314,8 @@ const setBearerAuthToObject = async function (object, configuration) {
9678
6314
  }
9679
6315
  };
9680
6316
  function setFlattenedQueryParams(urlSearchParams, parameter, key = "") {
6317
+ if (parameter == null)
6318
+ return;
9681
6319
  if (typeof parameter === "object") {
9682
6320
  if (Array.isArray(parameter)) {
9683
6321
  parameter.forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
@@ -9833,7 +6471,7 @@ const TransactionsApiAxiosParamCreator = function (configuration) {
9833
6471
  * @summary Info for a specific transaction
9834
6472
  * @param {string} transactionID The id of the starkex transaction to retrieve
9835
6473
  * @param {'starkex' | 'evm'} chainType roll up type
9836
- * @param {string} [chainID] ID of evm chain
6474
+ * @param {number} [chainID] ID of evm chain
9837
6475
  * @param {*} [options] Override http request option.
9838
6476
  * @throws {RequiredError}
9839
6477
  */
@@ -9908,7 +6546,7 @@ const TransactionsApiFp = function (configuration) {
9908
6546
  * @summary Info for a specific transaction
9909
6547
  * @param {string} transactionID The id of the starkex transaction to retrieve
9910
6548
  * @param {'starkex' | 'evm'} chainType roll up type
9911
- * @param {string} [chainID] ID of evm chain
6549
+ * @param {number} [chainID] ID of evm chain
9912
6550
  * @param {*} [options] Override http request option.
9913
6551
  * @throws {RequiredError}
9914
6552
  */
@@ -10225,12 +6863,10 @@ class AuthManager {
10225
6863
  userManager;
10226
6864
  config;
10227
6865
  deviceCredentialsManager;
10228
- logoutMode;
10229
6866
  constructor(config) {
10230
6867
  this.config = config;
10231
6868
  this.userManager = new oidcClientTs.UserManager(getAuthConfiguration(config));
10232
6869
  this.deviceCredentialsManager = new DeviceCredentialsManager();
10233
- this.logoutMode = config.oidcConfiguration.logoutMode || 'redirect';
10234
6870
  }
10235
6871
  static mapOidcUserToDomainModel = (oidcUser) => {
10236
6872
  const passport = oidcUser.profile?.passport;
@@ -10295,7 +6931,7 @@ class AuthManager {
10295
6931
  }
10296
6932
  async loginWithDeviceFlow() {
10297
6933
  return withPassportError(async () => {
10298
- const response = await axios$2.post(`${this.config.authenticationDomain}/oauth/device/code`, {
6934
+ const response = await globalAxios$1.post(`${this.config.authenticationDomain}/oauth/device/code`, {
10299
6935
  client_id: this.config.oidcConfiguration.clientId,
10300
6936
  scope: this.config.oidcConfiguration.scope,
10301
6937
  audience: this.config.oidcConfiguration.audience,
@@ -10328,7 +6964,7 @@ class AuthManager {
10328
6964
  return user;
10329
6965
  }
10330
6966
  catch (error) {
10331
- if (axios$2.isAxiosError(error)) {
6967
+ if (globalAxios$1.isAxiosError(error)) {
10332
6968
  const responseError = error.response?.data;
10333
6969
  switch (responseError.error) {
10334
6970
  case 'authorization_pending':
@@ -10353,7 +6989,7 @@ class AuthManager {
10353
6989
  }
10354
6990
  /* eslint-enable no-await-in-loop */
10355
6991
  async getDeviceFlowToken(deviceCode) {
10356
- const response = await axios$2.post(`${this.config.authenticationDomain}/oauth/token`, {
6992
+ const response = await globalAxios$1.post(`${this.config.authenticationDomain}/oauth/token`, {
10357
6993
  client_id: this.config.oidcConfiguration.clientId,
10358
6994
  grant_type: 'urn:ietf:params:oauth:grant-type:device_code',
10359
6995
  device_code: deviceCode,
@@ -10376,7 +7012,7 @@ class AuthManager {
10376
7012
  }, PassportErrorType.AUTHENTICATION_ERROR);
10377
7013
  }
10378
7014
  async refreshToken(refreshToken) {
10379
- const response = await axios$2.post(`${this.config.authenticationDomain}/oauth/token`, {
7015
+ const response = await globalAxios$1.post(`${this.config.authenticationDomain}/oauth/token`, {
10380
7016
  client_id: this.config.oidcConfiguration.clientId,
10381
7017
  grant_type: 'refresh_token',
10382
7018
  refresh_token: refreshToken,
@@ -10384,15 +7020,7 @@ class AuthManager {
10384
7020
  return response.data;
10385
7021
  }
10386
7022
  async logout() {
10387
- return withPassportError(async () => {
10388
- if (this.logoutMode === 'silent') {
10389
- return this.userManager.signoutSilent();
10390
- }
10391
- return this.userManager.signoutRedirect();
10392
- }, PassportErrorType.LOGOUT_ERROR);
10393
- }
10394
- async logoutSilentCallback(url) {
10395
- return this.userManager.signoutSilentCallback(url);
7023
+ return withPassportError(async () => this.userManager.signoutRedirect(), PassportErrorType.LOGOUT_ERROR);
10396
7024
  }
10397
7025
  async logoutDeviceFlow() {
10398
7026
  return withPassportError(async () => {
@@ -10595,7 +7223,6 @@ async function createOrder$1({ starkSigner, user, request, ordersApi, guardianCl
10595
7223
  amount_sell: amountSell,
10596
7224
  token_sell: convertToSignableToken(request.sell),
10597
7225
  fees: request.fees,
10598
- split_fees: true,
10599
7226
  expiration_timestamp: request.expiration_timestamp,
10600
7227
  };
10601
7228
  const getSignableOrderResponse = await ordersApi.getSignableOrder({
@@ -11050,10 +7677,6 @@ class PassportConfiguration {
11050
7677
  magicProviderId;
11051
7678
  oidcConfiguration;
11052
7679
  baseConfig;
11053
- zkEvmChainId;
11054
- zkEvmRpcUrl;
11055
- relayerUrl;
11056
- multiRollupConfig;
11057
7680
  constructor({ baseConfig, overrides, ...oidcConfiguration }) {
11058
7681
  validateConfiguration(oidcConfiguration, [
11059
7682
  'clientId',
@@ -11066,16 +7689,10 @@ class PassportConfiguration {
11066
7689
  validateConfiguration(overrides, [
11067
7690
  'network',
11068
7691
  'authenticationDomain',
11069
- 'passportDomain',
11070
7692
  'magicPublishableApiKey',
11071
7693
  'magicProviderId',
11072
- 'zkEvmRpcUrl',
11073
- 'zkEvmChainId',
11074
- 'relayerUrl',
7694
+ 'passportDomain',
11075
7695
  'imxPublicApiDomain',
11076
- 'indexerMrBasePath',
11077
- 'orderBookMrBasePath',
11078
- 'passportMrBasePath',
11079
7696
  ], 'overrides');
11080
7697
  this.network = overrides.network;
11081
7698
  this.authenticationDomain = overrides.authenticationDomain;
@@ -11083,20 +7700,6 @@ class PassportConfiguration {
11083
7700
  this.imxPublicApiDomain = overrides.imxPublicApiDomain;
11084
7701
  this.magicPublishableApiKey = overrides.magicPublishableApiKey;
11085
7702
  this.magicProviderId = overrides.magicProviderId;
11086
- this.zkEvmRpcUrl = overrides.zkEvmRpcUrl;
11087
- this.zkEvmChainId = overrides.zkEvmChainId;
11088
- this.relayerUrl = overrides.relayerUrl;
11089
- this.multiRollupConfig = {
11090
- indexer: createConfig({
11091
- basePath: overrides.indexerMrBasePath,
11092
- }),
11093
- orderBook: createConfig({
11094
- basePath: overrides.orderBookMrBasePath,
11095
- }),
11096
- passport: createConfig({
11097
- basePath: overrides.passportMrBasePath,
11098
- }),
11099
- };
11100
7703
  }
11101
7704
  else {
11102
7705
  switch (baseConfig.environment) {
@@ -11107,10 +7710,6 @@ class PassportConfiguration {
11107
7710
  this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
11108
7711
  this.passportDomain = 'https://passport.immutable.com';
11109
7712
  this.imxPublicApiDomain = 'https://api.immutable.com';
11110
- this.zkEvmRpcUrl = ''; // TODO: ID-785 Update once mainnet has been deployed
11111
- this.zkEvmChainId = ''; // TODO: ID-785 Update once mainnet has been deployed
11112
- this.relayerUrl = 'https://api.immutable.com/relayer-mr';
11113
- this.multiRollupConfig = multiRollupConfig.getProduction();
11114
7713
  break;
11115
7714
  }
11116
7715
  case exports.Environment.SANDBOX:
@@ -11121,10 +7720,6 @@ class PassportConfiguration {
11121
7720
  this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
11122
7721
  this.passportDomain = 'https://passport.sandbox.immutable.com';
11123
7722
  this.imxPublicApiDomain = 'https://api.sandbox.immutable.com';
11124
- this.zkEvmRpcUrl = 'https://zkevm-rpc.sandbox.x.immutable.com';
11125
- this.zkEvmChainId = 'eip155:13392';
11126
- this.relayerUrl = 'https://api.sandbox.immutable.com/relayer-mr';
11127
- this.multiRollupConfig = multiRollupConfig.getSandbox();
11128
7723
  break;
11129
7724
  }
11130
7725
  }
@@ -11285,537 +7880,6 @@ class ConfirmationScreen {
11285
7880
  }
11286
7881
  }
11287
7882
 
11288
- var RelayerTransactionStatus;
11289
- (function (RelayerTransactionStatus) {
11290
- RelayerTransactionStatus["PENDING"] = "PENDING";
11291
- RelayerTransactionStatus["SUBMITTED"] = "SUBMITTED";
11292
- RelayerTransactionStatus["SUCCESSFUL"] = "SUCCESSFUL";
11293
- RelayerTransactionStatus["REVERTED"] = "REVERTED";
11294
- RelayerTransactionStatus["FAILED"] = "FAILED";
11295
- })(RelayerTransactionStatus || (RelayerTransactionStatus = {}));
11296
- exports.ProviderEvent = void 0;
11297
- (function (ProviderEvent) {
11298
- ProviderEvent["ACCOUNTS_CHANGED"] = "accountsChanged";
11299
- })(exports.ProviderEvent || (exports.ProviderEvent = {}));
11300
-
11301
- class TypedEventEmitter {
11302
- emitter = new events.EventEmitter();
11303
- emit(eventName, ...eventArg) {
11304
- this.emitter.emit(eventName, ...eventArg);
11305
- }
11306
- on(eventName, handler) {
11307
- this.emitter.on(eventName, handler);
11308
- }
11309
- removeListener(eventName, handler) {
11310
- this.emitter.removeListener(eventName, handler);
11311
- }
11312
- }
11313
-
11314
- class RelayerClient {
11315
- config;
11316
- constructor({ config }) {
11317
- this.config = config;
11318
- }
11319
- async postToRelayer(request) {
11320
- const body = {
11321
- id: 1,
11322
- jsonrpc: '2.0',
11323
- ...request,
11324
- };
11325
- const response = await fetch(`${this.config.relayerUrl}/v1/transactions`, {
11326
- method: 'POST',
11327
- headers: {
11328
- 'Content-Type': 'application/json',
11329
- },
11330
- body: JSON.stringify(body),
11331
- });
11332
- const jsonResponse = await response.json();
11333
- if (jsonResponse.error) {
11334
- throw jsonResponse.error;
11335
- }
11336
- return jsonResponse;
11337
- }
11338
- async ethSendTransaction(to, data) {
11339
- const payload = {
11340
- method: 'eth_sendTransaction',
11341
- params: [{
11342
- to,
11343
- data,
11344
- chainId: this.config.zkEvmChainId.toString(),
11345
- }],
11346
- };
11347
- const { result } = await this.postToRelayer(payload);
11348
- return result;
11349
- }
11350
- async imGetTransactionByHash(hash) {
11351
- const payload = {
11352
- method: 'im_getTransactionByHash',
11353
- params: [hash],
11354
- };
11355
- const { result } = await this.postToRelayer(payload);
11356
- return result;
11357
- }
11358
- async imGetFeeOptions(userAddress, data) {
11359
- const payload = {
11360
- method: 'im_getFeeOptions',
11361
- params: [{
11362
- userAddress,
11363
- data,
11364
- chainId: this.config.zkEvmChainId.toString(),
11365
- }],
11366
- };
11367
- const { result } = await this.postToRelayer(payload);
11368
- return result;
11369
- }
11370
- }
11371
-
11372
- /**
11373
- * ProviderErrors should take priority over RpcErrorCodes
11374
- */
11375
- exports.ProviderErrorCode = void 0;
11376
- (function (ProviderErrorCode) {
11377
- ProviderErrorCode[ProviderErrorCode["USER_REJECTED_REQUEST"] = 4001] = "USER_REJECTED_REQUEST";
11378
- ProviderErrorCode[ProviderErrorCode["UNAUTHORIZED"] = 4100] = "UNAUTHORIZED";
11379
- ProviderErrorCode[ProviderErrorCode["UNSUPPORTED_METHOD"] = 4200] = "UNSUPPORTED_METHOD";
11380
- ProviderErrorCode[ProviderErrorCode["DISCONNECTED"] = 4900] = "DISCONNECTED";
11381
- })(exports.ProviderErrorCode || (exports.ProviderErrorCode = {}));
11382
- exports.RpcErrorCode = void 0;
11383
- (function (RpcErrorCode) {
11384
- RpcErrorCode[RpcErrorCode["RPC_SERVER_ERROR"] = -32000] = "RPC_SERVER_ERROR";
11385
- RpcErrorCode[RpcErrorCode["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
11386
- RpcErrorCode[RpcErrorCode["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
11387
- RpcErrorCode[RpcErrorCode["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
11388
- RpcErrorCode[RpcErrorCode["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
11389
- RpcErrorCode[RpcErrorCode["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
11390
- })(exports.RpcErrorCode || (exports.RpcErrorCode = {}));
11391
- class JsonRpcError extends Error {
11392
- message;
11393
- code;
11394
- constructor(code, message) {
11395
- super(message);
11396
- this.message = message;
11397
- this.code = code;
11398
- }
11399
- }
11400
-
11401
- const MESSAGE_TO_SIGN = 'Only sign this message from Immutable Passport';
11402
- async function registerZkEvmUser({ authManager, magicProvider, multiRollupApiClients, accessToken, }) {
11403
- const web3Provider = new providers.Web3Provider(magicProvider);
11404
- const ethSigner = web3Provider.getSigner();
11405
- const ethereumAddress = await ethSigner.getAddress();
11406
- const ethereumSignature = await signRaw(MESSAGE_TO_SIGN, ethSigner);
11407
- const headers = { Authorization: `Bearer ${accessToken}` };
11408
- try {
11409
- await multiRollupApiClients.passportApi.createCounterfactualAddress({
11410
- createCounterfactualAddressRequest: {
11411
- ethereumAddress,
11412
- ethereumSignature,
11413
- },
11414
- }, { headers });
11415
- }
11416
- catch (error) {
11417
- throw new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, `Failed to create counterfactual address: ${error}`);
11418
- }
11419
- const user = await authManager.loginSilent();
11420
- if (!user?.zkEvm) {
11421
- throw new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, 'Failed to refresh user details');
11422
- }
11423
- return user;
11424
- }
11425
-
11426
- const loginZkEvmUser = async ({ authManager, config, magicAdapter, multiRollupApiClients, }) => {
11427
- const user = await authManager.getUser() || await authManager.login();
11428
- if (!user.idToken) {
11429
- throw new Error('User is missing idToken');
11430
- }
11431
- const magicProvider = await magicAdapter.login(user.idToken, config.network);
11432
- if (!user.zkEvm) {
11433
- // Generate counterfactual address and retrieve updated Auth0 user
11434
- const userZkevm = await registerZkEvmUser({
11435
- authManager,
11436
- magicProvider,
11437
- multiRollupApiClients,
11438
- accessToken: user.accessToken,
11439
- });
11440
- return {
11441
- user: userZkevm,
11442
- magicProvider,
11443
- };
11444
- }
11445
- return {
11446
- user: user,
11447
- magicProvider,
11448
- };
11449
- };
11450
-
11451
- // These are ignored by the Relayer but for consistency we set them to the
11452
- // appropriate values for a 1/1 wallet.
11453
- //
11454
- // Weight of a single signature in the multisig
11455
- const SIGNATURE_WEIGHT = 1;
11456
- // Total required weight in the multisig
11457
- const SIGNATURE_THRESHOLD = 1;
11458
- const ETH_SIGN_FLAG = '02';
11459
- const ETH_SIGN_PREFIX = '\x19\x01';
11460
- const META_TRANSACTIONS_TYPE = `tuple(
11461
- bool delegateCall,
11462
- bool revertOnError,
11463
- uint256 gasLimit,
11464
- address target,
11465
- uint256 value,
11466
- bytes data
11467
- )[]`;
11468
- function getNormalisedTransactions(txs) {
11469
- return txs.map((t) => ({
11470
- delegateCall: t.delegateCall === true,
11471
- revertOnError: t.revertOnError === true,
11472
- gasLimit: t.gasLimit ?? ethers.ethers.constants.Zero,
11473
- target: t.to ?? ethers.ethers.constants.AddressZero,
11474
- value: t.value ?? ethers.ethers.constants.Zero,
11475
- data: t.data ?? [],
11476
- }));
11477
- }
11478
- function digestOfTransactionsAndNonce(nonce, normalisedTransactions) {
11479
- const packMetaTransactionsNonceData = ethers.ethers.utils.defaultAbiCoder.encode(['uint256', META_TRANSACTIONS_TYPE], [nonce, normalisedTransactions]);
11480
- return ethers.ethers.utils.keccak256(packMetaTransactionsNonceData);
11481
- }
11482
- const getNonce = async (jsonRpcProvider, smartContractWalletAddress) => {
11483
- const code = await jsonRpcProvider.send('eth_getCode', [smartContractWalletAddress, 'latest']);
11484
- if (code && code !== '0x') {
11485
- const contract = new ethers.ethers.Contract(smartContractWalletAddress, abi.walletContracts.mainModule.abi, jsonRpcProvider);
11486
- return contract.nonce();
11487
- }
11488
- return 0;
11489
- };
11490
- const getSignedMetaTransactions = async (metaTransactions, nonce, chainId, walletAddress, signer) => {
11491
- const normalisedMetaTransactions = getNormalisedTransactions(metaTransactions);
11492
- // Get the hash
11493
- const digest = digestOfTransactionsAndNonce(nonce, normalisedMetaTransactions);
11494
- const completePayload = ethers.ethers.utils.solidityPack(['string', 'uint256', 'address', 'bytes32'], [ETH_SIGN_PREFIX, chainId, walletAddress, digest]);
11495
- const hash = ethers.ethers.utils.keccak256(completePayload);
11496
- // Sign the digest
11497
- const hashArray = ethers.ethers.utils.arrayify(hash);
11498
- const ethsigNoType = await signer.signMessage(hashArray);
11499
- const signedDigest = `${ethsigNoType}${ETH_SIGN_FLAG}`;
11500
- // Add metadata
11501
- const encodedSignature = config.encodeSignature({
11502
- threshold: SIGNATURE_THRESHOLD,
11503
- signers: [
11504
- {
11505
- weight: SIGNATURE_WEIGHT,
11506
- signature: signedDigest,
11507
- },
11508
- ],
11509
- });
11510
- // Encode the transaction;
11511
- const walletInterface = new ethers.ethers.utils.Interface(abi.walletContracts.mainModule.abi);
11512
- return walletInterface.encodeFunctionData(walletInterface.getFunction('execute'), [
11513
- normalisedMetaTransactions,
11514
- nonce,
11515
- encodedSignature,
11516
- ]);
11517
- };
11518
- const chainIdNumber = (chainId) => {
11519
- const caip2Components = chainId.split(':');
11520
- if (caip2Components.length !== 2) {
11521
- throw new Error('Invalid configuration, chain ID is not in CAIP-2 format');
11522
- }
11523
- return ethers.BigNumber.from(caip2Components[1]);
11524
- };
11525
-
11526
- const MAX_TRANSACTION_HASH_RETRIEVAL_RETRIES = 30;
11527
- const TRANSACTION_HASH_RETRIEVAL_WAIT = 1000;
11528
- const converBigNumberishToNumber = (value) => ethers.BigNumber.from(value).toNumber();
11529
- const transformGardianTransactions = (txs) => {
11530
- try {
11531
- return txs.map((t) => ({
11532
- delegateCall: t.delegateCall === true,
11533
- revertOnError: t.revertOnError === true,
11534
- gasLimit: t.gasLimit ? converBigNumberishToNumber(t.gasLimit).toString() : '0',
11535
- target: t.to ?? ethers.ethers.constants.AddressZero,
11536
- value: t.value ? converBigNumberishToNumber(t.value).toString() : '0',
11537
- data: t.data ? t.data.toString() : '0x00',
11538
- }));
11539
- }
11540
- catch (error) {
11541
- const errorMessage = (error instanceof Error) ? error.message : String(error);
11542
- throw new JsonRpcError(exports.RpcErrorCode.INVALID_PARAMS, `Transaction failed to parsing: ${errorMessage}`);
11543
- }
11544
- };
11545
- const guardianValidation = async ({ transactionAPI, chainId, nonce, user, metaTransactions, }) => {
11546
- const headers = { Authorization: `Bearer ${user.accessToken}` };
11547
- const guardianTransactions = transformGardianTransactions(metaTransactions);
11548
- try {
11549
- await transactionAPI.evaluateTransaction({
11550
- id: 'evm',
11551
- transactionEvaluationRequest: {
11552
- chainType: 'evm',
11553
- chainId,
11554
- transactionData: {
11555
- nonce,
11556
- userAddress: user.zkEvm.ethAddress,
11557
- metaTransactions: guardianTransactions,
11558
- },
11559
- },
11560
- }, { headers });
11561
- }
11562
- catch (error) {
11563
- const errorMessage = (error instanceof Error) ? error.message : String(error);
11564
- throw new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, `Transaction failed to validate with error: ${errorMessage}`);
11565
- }
11566
- };
11567
- const sendTransaction = async ({ params, magicProvider, jsonRpcProvider, relayerClient, transactionAPI, config, user, }) => {
11568
- const transactionRequest = params[0];
11569
- if (!transactionRequest.to) {
11570
- throw new JsonRpcError(exports.RpcErrorCode.INVALID_PARAMS, 'eth_sendTransaction requires a "to" field');
11571
- }
11572
- const chainId = chainIdNumber(config.zkEvmChainId);
11573
- const magicWeb3Provider = new providers.Web3Provider(magicProvider);
11574
- const signer = magicWeb3Provider.getSigner();
11575
- const nonce = await getNonce(jsonRpcProvider, user.zkEvm.ethAddress);
11576
- const metaTransaction = {
11577
- to: transactionRequest.to,
11578
- data: transactionRequest.data,
11579
- nonce,
11580
- value: transactionRequest.value,
11581
- revertOnError: true,
11582
- };
11583
- // NOTE: We sign the transaction before getting the fee options because
11584
- // accurate estimation of a transaction gas cost is only possible if the smart
11585
- // wallet contract can actually execute it (in a simulated environment) - and
11586
- // it can only execute signed transactions.
11587
- const signedTransaction = await getSignedMetaTransactions([metaTransaction], nonce, chainId, user.zkEvm.ethAddress, signer);
11588
- // TODO: ID-698 Add support for non-native gas payments (e.g ERC20, feeTransaction initialisation must change)
11589
- // NOTE: "Fee Options" represent the multiple ways we could pay for the gas
11590
- // used in this transaction. Each fee option has a "recipientAddress" we
11591
- // should transfer the payment to, an amount and a currency. We choose one
11592
- // option and build a transaction that sends the expected currency amount for
11593
- // that option to the specified address.
11594
- const feeOptions = await relayerClient.imGetFeeOptions(user.zkEvm.ethAddress, signedTransaction);
11595
- const imxFeeOption = feeOptions.find((feeOption) => feeOption.tokenSymbol === 'IMX');
11596
- if (!imxFeeOption) {
11597
- throw new Error('Failed to retrieve fees for IMX token');
11598
- }
11599
- const feeMetaTransaction = {
11600
- nonce,
11601
- to: imxFeeOption.recipientAddress,
11602
- value: imxFeeOption.tokenPrice,
11603
- revertOnError: true,
11604
- };
11605
- await guardianValidation({
11606
- transactionAPI,
11607
- chainId: config.zkEvmChainId,
11608
- nonce: converBigNumberishToNumber(nonce),
11609
- user,
11610
- metaTransactions: [metaTransaction, feeMetaTransaction],
11611
- });
11612
- // NOTE: We sign again because we now are adding the fee transaction, so the
11613
- // whole payload is different and needs a new signature.
11614
- const signedTransactions = await getSignedMetaTransactions([metaTransaction, feeMetaTransaction], nonce, chainId, user.zkEvm.ethAddress, signer);
11615
- // TODO: ID-697 Evaluate transactions through Guardian
11616
- const relayerId = await relayerClient.ethSendTransaction(user.zkEvm.ethAddress, signedTransactions);
11617
- const retrieveRelayerTransaction = async () => {
11618
- const tx = await relayerClient.imGetTransactionByHash(relayerId);
11619
- // NOTE: The transaction hash is only available from the Relayer once the
11620
- // transaction is actually submitted onchain. Hence we need to poll the
11621
- // Relayer get transaction endpoint until the status transitions to one that
11622
- // has the hash available.
11623
- if (tx.status === RelayerTransactionStatus.PENDING) {
11624
- throw new Error();
11625
- }
11626
- return tx;
11627
- };
11628
- const relayerTransaction = await retryWithDelay(retrieveRelayerTransaction, {
11629
- retries: MAX_TRANSACTION_HASH_RETRIEVAL_RETRIES,
11630
- interval: TRANSACTION_HASH_RETRIEVAL_WAIT,
11631
- finalErr: new JsonRpcError(exports.RpcErrorCode.RPC_SERVER_ERROR, 'transaction hash not generated in time'),
11632
- });
11633
- if (![RelayerTransactionStatus.SUBMITTED, RelayerTransactionStatus.SUCCESSFUL].includes(relayerTransaction.status)) {
11634
- throw new JsonRpcError(exports.RpcErrorCode.RPC_SERVER_ERROR, `Transaction failed to submit with status ${relayerTransaction.status}`);
11635
- }
11636
- return relayerTransaction.hash;
11637
- };
11638
-
11639
- class ZkEvmProvider {
11640
- authManager;
11641
- config;
11642
- confirmationScreen;
11643
- magicAdapter;
11644
- relayerClient;
11645
- transactionAPI;
11646
- multiRollupApiClients;
11647
- jsonRpcProvider; // Used for read
11648
- eventEmitter;
11649
- magicProvider; // Used for signing
11650
- user;
11651
- constructor({ authManager, magicAdapter, config, confirmationScreen, multiRollupApiClients, }) {
11652
- this.authManager = authManager;
11653
- this.magicAdapter = magicAdapter;
11654
- this.config = config;
11655
- this.confirmationScreen = confirmationScreen;
11656
- this.relayerClient = new RelayerClient({ config });
11657
- this.transactionAPI = new TransactionsApi(new Configuration({
11658
- basePath: this.config.imxPublicApiDomain,
11659
- }));
11660
- this.jsonRpcProvider = new providers.JsonRpcProvider(this.config.zkEvmRpcUrl);
11661
- this.multiRollupApiClients = multiRollupApiClients;
11662
- this.eventEmitter = new TypedEventEmitter();
11663
- }
11664
- isLoggedIn() {
11665
- return this.magicProvider !== undefined && this.user !== undefined;
11666
- }
11667
- async performRequest(request) {
11668
- switch (request.method) {
11669
- case 'eth_requestAccounts': {
11670
- if (this.isLoggedIn()) {
11671
- return [this.user.zkEvm.ethAddress];
11672
- }
11673
- const { magicProvider, user } = await loginZkEvmUser({
11674
- authManager: this.authManager,
11675
- config: this.config,
11676
- magicAdapter: this.magicAdapter,
11677
- multiRollupApiClients: this.multiRollupApiClients,
11678
- });
11679
- this.user = user;
11680
- this.magicProvider = magicProvider;
11681
- this.eventEmitter.emit(exports.ProviderEvent.ACCOUNTS_CHANGED, [this.user.zkEvm.ethAddress]);
11682
- return [this.user.zkEvm.ethAddress];
11683
- }
11684
- case 'eth_sendTransaction': {
11685
- if (!this.isLoggedIn()) {
11686
- throw new JsonRpcError(exports.ProviderErrorCode.UNAUTHORIZED, 'Unauthorised - call eth_requestAccounts first');
11687
- }
11688
- return sendTransaction({
11689
- params: request.params || [],
11690
- magicProvider: this.magicProvider,
11691
- transactionAPI: this.transactionAPI,
11692
- jsonRpcProvider: this.jsonRpcProvider,
11693
- config: this.config,
11694
- relayerClient: this.relayerClient,
11695
- user: this.user,
11696
- });
11697
- }
11698
- case 'eth_accounts': {
11699
- return this.isLoggedIn() ? [this.user.zkEvm.ethAddress] : [];
11700
- }
11701
- // Pass through methods
11702
- case 'eth_gasPrice':
11703
- case 'eth_getBalance':
11704
- case 'eth_getStorageAt':
11705
- case 'eth_estimateGas':
11706
- case 'eth_call':
11707
- case 'eth_blockNumber':
11708
- case 'eth_chainId':
11709
- case 'eth_getBlockByHash':
11710
- case 'eth_getBlockByNumber':
11711
- case 'eth_getTransactionByHash':
11712
- case 'eth_getTransactionReceipt':
11713
- case 'eth_getTransactionCount': {
11714
- return this.jsonRpcProvider.send(request.method, request.params || []);
11715
- }
11716
- default: {
11717
- throw new JsonRpcError(exports.ProviderErrorCode.UNSUPPORTED_METHOD, 'Method not supported');
11718
- }
11719
- }
11720
- }
11721
- async performJsonRpcRequest(request) {
11722
- const { id, jsonrpc } = request;
11723
- try {
11724
- const result = await this.performRequest(request);
11725
- return {
11726
- id,
11727
- jsonrpc,
11728
- result,
11729
- };
11730
- }
11731
- catch (error) {
11732
- let jsonRpcError;
11733
- if (error instanceof JsonRpcError) {
11734
- jsonRpcError = error;
11735
- }
11736
- else if (error instanceof Error) {
11737
- jsonRpcError = new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, error.message);
11738
- }
11739
- else {
11740
- jsonRpcError = new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, 'Internal error');
11741
- }
11742
- return {
11743
- id,
11744
- jsonrpc,
11745
- error: jsonRpcError,
11746
- };
11747
- }
11748
- }
11749
- async request(request) {
11750
- try {
11751
- return this.performRequest(request);
11752
- }
11753
- catch (error) {
11754
- if (error instanceof JsonRpcError) {
11755
- throw error;
11756
- }
11757
- if (error instanceof Error) {
11758
- throw new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, error.message);
11759
- }
11760
- throw new JsonRpcError(exports.RpcErrorCode.INTERNAL_ERROR, 'Internal error');
11761
- }
11762
- }
11763
- sendAsync(request, callback) {
11764
- if (!callback) {
11765
- throw new Error('No callback provided');
11766
- }
11767
- if (Array.isArray(request)) {
11768
- Promise.all(request.map(this.performJsonRpcRequest)).then((result) => {
11769
- callback(null, result);
11770
- }).catch((error) => {
11771
- callback(error, []);
11772
- });
11773
- }
11774
- else {
11775
- this.performJsonRpcRequest(request).then((result) => {
11776
- callback(null, result);
11777
- }).catch((error) => {
11778
- callback(error, null);
11779
- });
11780
- }
11781
- }
11782
- async send(request, callbackOrParams, callback) {
11783
- // Web3 >= 1.0.0-beta.38 calls `send` with method and parameters.
11784
- if (typeof request === 'string') {
11785
- if (typeof callbackOrParams === 'function') {
11786
- return this.sendAsync({
11787
- method: request,
11788
- params: [],
11789
- }, callbackOrParams);
11790
- }
11791
- if (callback) {
11792
- return this.sendAsync({
11793
- method: request,
11794
- params: Array.isArray(callbackOrParams) ? callbackOrParams : [],
11795
- }, callback);
11796
- }
11797
- return this.request({
11798
- method: request,
11799
- params: Array.isArray(callbackOrParams) ? callbackOrParams : [],
11800
- });
11801
- }
11802
- // Web3 <= 1.0.0-beta.37 uses `send` with a callback for async queries.
11803
- if (typeof callbackOrParams === 'function') {
11804
- return this.sendAsync(request, callbackOrParams);
11805
- }
11806
- if (!Array.isArray(request) && typeof request === 'object') {
11807
- return this.performJsonRpcRequest(request);
11808
- }
11809
- throw new JsonRpcError(exports.RpcErrorCode.INVALID_REQUEST, 'Invalid request');
11810
- }
11811
- on(event, listener) {
11812
- this.eventEmitter.on(event, listener);
11813
- }
11814
- removeListener(event, listener) {
11815
- this.eventEmitter.removeListener(event, listener);
11816
- }
11817
- }
11818
-
11819
7883
  class Passport {
11820
7884
  authManager;
11821
7885
  config;
@@ -11823,7 +7887,6 @@ class Passport {
11823
7887
  immutableXClient;
11824
7888
  magicAdapter;
11825
7889
  passportImxProviderFactory;
11826
- multiRollupApiClients;
11827
7890
  constructor(passportModuleConfiguration) {
11828
7891
  this.config = new PassportConfiguration(passportModuleConfiguration);
11829
7892
  this.authManager = new AuthManager(this.config);
@@ -11833,7 +7896,6 @@ class Passport {
11833
7896
  || new ImmutableXClient({
11834
7897
  baseConfig: passportModuleConfiguration.baseConfig,
11835
7898
  });
11836
- this.multiRollupApiClients = new MultiRollupApiClients(this.config.multiRollupConfig);
11837
7899
  this.passportImxProviderFactory = new PassportImxProviderFactory({
11838
7900
  authManager: this.authManager,
11839
7901
  config: this.config,
@@ -11863,29 +7925,12 @@ class Passport {
11863
7925
  async connectImxWithCredentials(tokenResponse) {
11864
7926
  return this.passportImxProviderFactory.getProviderWithCredentials(tokenResponse);
11865
7927
  }
11866
- // TODO ID-926 Make method public once development has been finalised
11867
- connectEvm() {
11868
- return new ZkEvmProvider({
11869
- authManager: this.authManager,
11870
- magicAdapter: this.magicAdapter,
11871
- config: this.config,
11872
- confirmationScreen: this.confirmationScreen,
11873
- multiRollupApiClients: this.multiRollupApiClients,
11874
- });
11875
- }
11876
7928
  async loginCallback() {
11877
7929
  return this.authManager.loginCallback();
11878
7930
  }
11879
7931
  async logout() {
11880
7932
  return this.authManager.logout();
11881
7933
  }
11882
- /**
11883
- * This method should only be called from the logout redirect uri
11884
- * when logout mode is 'silent'.
11885
- */
11886
- async logoutSilentCallback(url) {
11887
- return this.authManager.logoutSilentCallback(url);
11888
- }
11889
7934
  async logoutDeviceFlow() {
11890
7935
  return this.authManager.logoutDeviceFlow();
11891
7936
  }
@@ -12186,7 +8231,7 @@ const getRequestBody = (options) => {
12186
8231
  return undefined;
12187
8232
  };
12188
8233
  const sendRequest = async (config, options, url, body, formData, headers, onCancel) => {
12189
- const source = axios$2.CancelToken.source();
8234
+ const source = globalAxios$1.CancelToken.source();
12190
8235
  const requestConfig = {
12191
8236
  url,
12192
8237
  headers,
@@ -12197,7 +8242,7 @@ const sendRequest = async (config, options, url, body, formData, headers, onCanc
12197
8242
  };
12198
8243
  onCancel(() => source.cancel('The user aborted a request.'));
12199
8244
  try {
12200
- return await axios$2.request(requestConfig);
8245
+ return await globalAxios$1.request(requestConfig);
12201
8246
  }
12202
8247
  catch (error) {
12203
8248
  const axiosError = error;
@@ -12802,25 +8847,31 @@ class ImmutableApiClientFactory {
12802
8847
  }
12803
8848
  }
12804
8849
 
8850
+ const DEVNET_CHAIN_NAME = 'imtbl-zkevm-devnet';
12805
8851
  const TESTNET_CHAIN_NAME = 'imtbl-zkevm-testnet';
12806
8852
  const MAINNET_CHAIN_NAME = 'imtbl-zkevm-mainnet';
12807
- function getOrderbookConfig(environment) {
12808
- switch (environment) {
12809
- case exports.Environment.SANDBOX:
8853
+ function getOrderbookConfig(chainName) {
8854
+ switch (chainName) {
8855
+ case DEVNET_CHAIN_NAME:
8856
+ return {
8857
+ seaportContractAddress: '0x41388404Efb7a68Fd31d75CEf71dF91e2BDBa2fb',
8858
+ zoneContractAddress: '0xCb5063b0c1dcF4f7fed8E7eaa79faf9859792767',
8859
+ apiEndpoint: 'https://order-book-mr.dev.imtbl.com',
8860
+ provider: new ethers.providers.JsonRpcProvider('https://zkevm-rpc.dev.x.immutable.com'),
8861
+ };
8862
+ case TESTNET_CHAIN_NAME:
12810
8863
  return {
12811
8864
  seaportContractAddress: '0x45E23dA18804F99Cf67408AeBE85F67c958381Ff',
12812
8865
  zoneContractAddress: '0x25b00b7eb97eab6194798E9B8eF63Aa526D5bd7E',
12813
8866
  apiEndpoint: 'https://order-book-mr.sandbox.imtbl.com',
12814
- chainName: TESTNET_CHAIN_NAME,
12815
8867
  provider: new ethers.providers.JsonRpcProvider('https://zkevm-rpc.sandbox.x.immutable.com'),
12816
8868
  };
12817
- // not yet deployed
12818
- case exports.Environment.PRODUCTION:
8869
+ case MAINNET_CHAIN_NAME:
8870
+ // not yet deployed
12819
8871
  return {
12820
8872
  seaportContractAddress: '',
12821
8873
  zoneContractAddress: '',
12822
8874
  apiEndpoint: 'https://order-book-mr.imtbl.com',
12823
- chainName: MAINNET_CHAIN_NAME,
12824
8875
  provider: new ethers.providers.JsonRpcProvider('https://zkevm-rpc.x.immutable.com'),
12825
8876
  };
12826
8877
  default:
@@ -13779,19 +9830,21 @@ class Orderbook {
13779
9830
  apiClient;
13780
9831
  seaport;
13781
9832
  orderbookConfig;
13782
- constructor(config) {
13783
- const obConfig = getOrderbookConfig(config.baseConfig.environment);
13784
- const finalConfig = {
13785
- ...obConfig,
13786
- ...config.overrides,
13787
- };
13788
- if (!finalConfig) {
13789
- throw new Error('Orderbook configuration not passed, please specify the environment under config.baseConfig.environment');
13790
- }
13791
- this.orderbookConfig = finalConfig;
13792
- const { apiEndpoint, chainName } = this.orderbookConfig;
9833
+ constructor(config, localConfig) {
9834
+ // either use preconfigured config or local config passed in
9835
+ const maybeConfig = getOrderbookConfig(config.overrides?.chainName) || localConfig;
9836
+ if (!maybeConfig) {
9837
+ throw new Error('Orderbook configuration not passed, either select one of the preseet chainNames or pass in localConfig');
9838
+ }
9839
+ this.orderbookConfig = maybeConfig;
9840
+ const { apiEndpoint } = this.orderbookConfig;
13793
9841
  if (!apiEndpoint) {
13794
- throw new Error('API endpoint must be provided');
9842
+ throw new Error('API endpoint must be provided as an override');
9843
+ }
9844
+ // TODO: Move chainId lookup to a map based on env. Just using override to get dev started
9845
+ const chainName = config.overrides?.chainName;
9846
+ if (!chainName) {
9847
+ throw new Error('chainName must be provided as an override');
13795
9848
  }
13796
9849
  this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainName, this.orderbookConfig.seaportContractAddress).create();
13797
9850
  const seaportLibFactory = new SeaportLibFactory(this.orderbookConfig.seaportContractAddress, this.orderbookConfig.provider);
@@ -25126,7 +21179,7 @@ const ETH_MAINNET_CHAIN_ID = 'eip155:1';
25126
21179
  /**
25127
21180
  * @constant {string} ZKEVM_DEVNET_CHAIN_ID - The chain ID for the zkEVM devnet (EIP-155 compatible format).
25128
21181
  */
25129
- const ZKEVM_DEVNET_CHAIN_ID = 'eip155:13423';
21182
+ const ZKEVM_DEVNET_CHAIN_ID = 'eip155:13403';
25130
21183
  /**
25131
21184
  /**
25132
21185
  * @constant {string} ZKEVM_TESTNET_CHAIN_ID - The chain ID for the zkEVM testnet (EIP-155 compatible format).
@@ -25184,8 +21237,8 @@ const SUPPORTED_BRIDGES_FOR_ENVIRONMENT = {
25184
21237
  */
25185
21238
  const CONTRACTS_FOR_BRIDGE = new Map()
25186
21239
  .set(ETH_SEPOLIA_TO_ZKEVM_DEVNET, {
25187
- rootChainERC20Predicate: '0xf0b3435411A74F1aeCBD0fd6D53a90D5227fEeba',
25188
- rootChainStateSender: '0x868097dbAcfD431F441d09D0e4D3B5eD3182E597',
21240
+ rootChainERC20Predicate: '0x15Dd735de418B6d290727aed82cC25F8966dE4A5',
21241
+ rootChainStateSender: '0xb3Bac13799dAca9D9eC9307303a65fA1218b4724',
25189
21242
  childChainERC20Predicate: '0x0000000000000000000000000000000000001004',
25190
21243
  childChainStateReceiver: '0x0000000000000000000000000000000000001001',
25191
21244
  })
@@ -27422,28 +23475,16 @@ const SUPPORTED_CHAIN_IDS_FOR_ENVIRONMENT = {
27422
23475
  [exports.Environment.PRODUCTION]: SUPPORTED_PRODUCTION_CHAINS,
27423
23476
  };
27424
23477
  function validateOverrides(overrides) {
27425
- const keysToCheck = ['rpcURL', 'exchangeContracts', 'commonRoutingTokens', 'nativeToken'];
27426
- for (const key of keysToCheck) {
27427
- if (!overrides[key]) {
23478
+ Object.entries(overrides).forEach(([key, value]) => {
23479
+ if (!value) {
27428
23480
  throw new InvalidConfigurationError(`Missing override: ${key}`);
27429
23481
  }
27430
- }
23482
+ });
27431
23483
  Object.entries(overrides.exchangeContracts).forEach(([key, contract]) => {
27432
23484
  if (!isValidNonZeroAddress(contract)) {
27433
23485
  throw new InvalidConfigurationError(`Invalid exchange contract address for ${key}`);
27434
23486
  }
27435
23487
  });
27436
- if (!overrides.secondaryFees) {
27437
- return;
27438
- }
27439
- for (const secondaryFee of overrides.secondaryFees) {
27440
- if (!isValidNonZeroAddress(secondaryFee.feeRecipient)) {
27441
- throw new InvalidConfigurationError(`Invalid secondary fee recipient address: ${secondaryFee.feeRecipient}`);
27442
- }
27443
- if (secondaryFee.feeBasisPoints < 0 || secondaryFee.feeBasisPoints > 10000) {
27444
- throw new InvalidConfigurationError(`Invalid secondary fee percentage: ${secondaryFee.feeBasisPoints}`);
27445
- }
27446
- }
27447
23488
  }
27448
23489
  /**
27449
23490
  * {@link ExchangeConfiguration} is used to configure the {@link Exchange} class.
@@ -27453,7 +23494,6 @@ function validateOverrides(overrides) {
27453
23494
  class ExchangeConfiguration {
27454
23495
  baseConfig;
27455
23496
  chain;
27456
- secondaryFees;
27457
23497
  constructor({ chainId, baseConfig, overrides }) {
27458
23498
  this.baseConfig = baseConfig;
27459
23499
  if (overrides) {
@@ -27465,10 +23505,8 @@ class ExchangeConfiguration {
27465
23505
  commonRoutingTokens: overrides.commonRoutingTokens,
27466
23506
  nativeToken: overrides.nativeToken,
27467
23507
  };
27468
- this.secondaryFees = overrides.secondaryFees ? overrides.secondaryFees : [];
27469
23508
  return;
27470
23509
  }
27471
- this.secondaryFees = [];
27472
23510
  const chain = SUPPORTED_CHAIN_IDS_FOR_ENVIRONMENT[baseConfig.environment][chainId];
27473
23511
  if (!chain) {
27474
23512
  throw new ChainNotSupportedError(chainId, baseConfig.environment);
@@ -27482,13 +23520,11 @@ class Exchange {
27482
23520
  router;
27483
23521
  chainId;
27484
23522
  nativeToken;
27485
- secondaryFees;
27486
23523
  constructor(configuration) {
27487
23524
  const config = new ExchangeConfiguration(configuration);
27488
23525
  this.chainId = config.chain.chainId;
27489
23526
  this.nativeToken = config.chain.nativeToken;
27490
23527
  this.provider = new ethers.ethers.providers.JsonRpcProvider(config.chain.rpcUrl);
27491
- this.secondaryFees = config.secondaryFees;
27492
23528
  this.router = new Router(this.provider, config.chain.commonRoutingTokens, {
27493
23529
  multicallAddress: config.chain.contracts.multicall,
27494
23530
  factoryAddress: config.chain.contracts.coreFactory,
@@ -27571,9 +23607,6 @@ class Exchange {
27571
23607
  async getUnsignedSwapTxFromAmountOut(fromAddress, tokenInAddress, tokenOutAddress, amountOut, slippagePercent = DEFAULT_SLIPPAGE, maxHops = DEFAULT_MAX_HOPS, deadline = DEFAULT_DEADLINE) {
27572
23608
  return await this.getUnsignedSwapTx(fromAddress, tokenInAddress, tokenOutAddress, amountOut, slippagePercent, maxHops, deadline, sdkCore.TradeType.EXACT_OUTPUT);
27573
23609
  }
27574
- thereAreSecondaryFees() {
27575
- return this.secondaryFees.length > 0;
27576
- }
27577
23610
  }
27578
23611
 
27579
23612
  /* eslint-disable class-methods-use-this */
@@ -27650,8 +23683,8 @@ const $762782b6c862d954$export$db5daa1b5156ccfe = [
27650
23683
  */ exports.ChainId = void 0;
27651
23684
  (function(ChainId) {
27652
23685
  ChainId[ChainId["IMTBL_ZKEVM_MAINNET"] = 13371] = "IMTBL_ZKEVM_MAINNET";
27653
- ChainId[ChainId["IMTBL_ZKEVM_TESTNET"] = 13372] = "IMTBL_ZKEVM_TESTNET";
27654
- ChainId[ChainId["IMTBL_ZKEVM_DEVNET"] = 13423] = "IMTBL_ZKEVM_DEVNET";
23686
+ ChainId[ChainId["IMTBL_ZKEVM_TESTNET"] = 13392] = "IMTBL_ZKEVM_TESTNET";
23687
+ ChainId[ChainId["IMTBL_ZKEVM_DEVNET"] = 13403] = "IMTBL_ZKEVM_DEVNET";
27655
23688
  ChainId[ChainId["ETHEREUM"] = 1] = "ETHEREUM";
27656
23689
  ChainId[ChainId["SEPOLIA"] = 11155111] = "SEPOLIA";
27657
23690
  })(exports.ChainId || (exports.ChainId = {}));
@@ -27736,10 +23769,6 @@ const $d85ad1457a3f1a83$export$161d4a74df65fc08 = {
27736
23769
  [(exports.Environment).SANDBOX]: "https://checkout-api.sandbox.immutable.com",
27737
23770
  [(exports.Environment).PRODUCTION]: "https://checkout-api.immutable.com"
27738
23771
  };
27739
- const $d85ad1457a3f1a83$export$7b057be2a3f512cc = {
27740
- [(exports.Environment).SANDBOX]: "https://zkevm-rpc.sandbox.x.immutable.com",
27741
- [(exports.Environment).PRODUCTION]: "https://zkevm-rpc.x.immutable.com"
27742
- };
27743
23772
  const $d85ad1457a3f1a83$export$6f24f3cef7d501c4 = new Map([
27744
23773
  [
27745
23774
  (exports.ChainId).ETHEREUM,
@@ -27765,7 +23794,7 @@ const $d85ad1457a3f1a83$export$6f24f3cef7d501c4 = new Map([
27765
23794
  chainIdHex: `0x${(exports.ChainId).IMTBL_ZKEVM_MAINNET.toString(16)}`,
27766
23795
  chainName: (exports.ChainName).IMTBL_ZKEVM_MAINNET,
27767
23796
  rpcUrls: [
27768
- "https://rpc.immutable.com"
23797
+ "https://zkevm-rpc.x.immutable.com"
27769
23798
  ],
27770
23799
  nativeCurrency: {
27771
23800
  name: "IMX",
@@ -27800,7 +23829,7 @@ const $d85ad1457a3f1a83$export$3e81fc0987227f10 = new Map([
27800
23829
  chainIdHex: `0x${(exports.ChainId).IMTBL_ZKEVM_TESTNET.toString(16)}`,
27801
23830
  chainName: (exports.ChainName).IMTBL_ZKEVM_TESTNET,
27802
23831
  rpcUrls: [
27803
- "https://rpc.testnet.immutable.com"
23832
+ "https://zkevm-rpc.sandbox.x.immutable.com"
27804
23833
  ],
27805
23834
  nativeCurrency: {
27806
23835
  name: "IMX",
@@ -28176,19 +24205,16 @@ async function $5c763be0b0b81038$var$getMetaMaskProvider() {
28176
24205
  if (!provider || !provider.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No MetaMask provider installed.", (exports.CheckoutErrorType).METAMASK_PROVIDER_ERROR);
28177
24206
  return new (providers.Web3Provider)(provider);
28178
24207
  }
28179
- async function $5c763be0b0b81038$export$500fbc0cd14cdbaa(walletProviderName) {
28180
- let provider = null;
28181
- switch(walletProviderName){
24208
+ async function $5c763be0b0b81038$export$500fbc0cd14cdbaa(defaultProvider) {
24209
+ let web3Provider = null;
24210
+ switch(defaultProvider){
28182
24211
  case (exports.WalletProviderName).METAMASK:
28183
- provider = await $5c763be0b0b81038$var$getMetaMaskProvider();
24212
+ web3Provider = await $5c763be0b0b81038$var$getMetaMaskProvider();
28184
24213
  break;
28185
24214
  default:
28186
24215
  throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Provider not supported", (exports.CheckoutErrorType).DEFAULT_PROVIDER_ERROR);
28187
24216
  }
28188
- return {
28189
- provider: provider,
28190
- walletProviderName: walletProviderName
28191
- };
24217
+ return web3Provider;
28192
24218
  }
28193
24219
 
28194
24220
 
@@ -28197,8 +24223,9 @@ async function $5c763be0b0b81038$export$500fbc0cd14cdbaa(walletProviderName) {
28197
24223
 
28198
24224
 
28199
24225
 
24226
+
28200
24227
  function $bb88265fe45a0393$export$ebe4804963e71f98(web3Provider) {
28201
- if (web3Provider && web3Provider.provider?.request && typeof web3Provider.provider.request === "function") return true;
24228
+ if (web3Provider && web3Provider instanceof (providers.Web3Provider) && web3Provider.provider?.request) return true;
28202
24229
  return false;
28203
24230
  }
28204
24231
  async function $bb88265fe45a0393$export$9e1fd9cc88c637a0(config, web3Provider, validateProviderOptions) {
@@ -28363,7 +24390,7 @@ class $a492ee374ae7b613$export$d902b56530cd5f87 {
28363
24390
  static async makeHttpRequest(url) {
28364
24391
  let response;
28365
24392
  try {
28366
- response = await (0, axios$2).get(url);
24393
+ response = await (0, globalAxios$1).get(url);
28367
24394
  } catch (error) {
28368
24395
  throw new Error(`Error fetching from api: ${error.message}`);
28369
24396
  }
@@ -28408,23 +24435,10 @@ class $4013c5c91bb535f6$export$6ad73ea7e1b6f37f extends Error {
28408
24435
  this.message = message;
28409
24436
  }
28410
24437
  }
28411
- const $4013c5c91bb535f6$var$networkMap = (prod, dev, local)=>{
28412
- let networks;
28413
- if (dev) networks = ($d85ad1457a3f1a83$export$3a9ebede6a150274);
28414
- else if (prod) {
28415
- networks = ($d85ad1457a3f1a83$export$6f24f3cef7d501c4);
28416
- if (local) {
28417
- const rpcUrls = networks.get((exports.ChainId).IMTBL_ZKEVM_MAINNET)?.rpcUrls;
28418
- rpcUrls?.splice(0, 1, ($d85ad1457a3f1a83$export$7b057be2a3f512cc)[(exports.Environment).PRODUCTION]);
28419
- }
28420
- } else {
28421
- networks = ($d85ad1457a3f1a83$export$3e81fc0987227f10);
28422
- if (local) {
28423
- const rpcUrls = networks.get((exports.ChainId).IMTBL_ZKEVM_TESTNET)?.rpcUrls;
28424
- rpcUrls?.splice(0, 1, ($d85ad1457a3f1a83$export$7b057be2a3f512cc)[(exports.Environment).SANDBOX]);
28425
- }
28426
- }
28427
- return networks;
24438
+ const $4013c5c91bb535f6$var$networkMap = (prod, dev)=>{
24439
+ if (dev) return $d85ad1457a3f1a83$export$3a9ebede6a150274;
24440
+ if (prod) return $d85ad1457a3f1a83$export$6f24f3cef7d501c4;
24441
+ return $d85ad1457a3f1a83$export$3e81fc0987227f10;
28428
24442
  };
28429
24443
  const $4013c5c91bb535f6$export$9b794d067cdd1af6 = (config)=>{
28430
24444
  // DevMode and Sandbox will both use Sepolia.
@@ -28442,11 +24456,6 @@ class $4013c5c91bb535f6$export$4823433c4a67bbc6 {
28442
24456
  // This will be used to get around the lack of
28443
24457
  // Environment.DEVELOPMENT
28444
24458
  isDevelopment = false;
28445
- // This is a hidden feature that is only available
28446
- // when building the project from source code.
28447
- // This will be used to get around the lack of
28448
- // Environment.LOCAL_DEVELOPMENT
28449
- isLocal = false;
28450
24459
  isProduction;
28451
24460
  remote;
28452
24461
  environment;
@@ -28456,7 +24465,7 @@ class $4013c5c91bb535f6$export$4823433c4a67bbc6 {
28456
24465
  this.environment = config.baseConfig.environment;
28457
24466
  // Developer mode will super set any environment configuration
28458
24467
  this.isProduction = !this.isDevelopment && this.environment === (exports.Environment).PRODUCTION;
28459
- this.networkMap = $4013c5c91bb535f6$var$networkMap(this.isProduction, this.isDevelopment, this.isLocal);
24468
+ this.networkMap = $4013c5c91bb535f6$var$networkMap(this.isProduction, this.isDevelopment);
28460
24469
  this.remote = new ($a492ee374ae7b613$export$d902b56530cd5f87)({
28461
24470
  isDevelopment: this.isDevelopment,
28462
24471
  isProduction: this.isProduction
@@ -28602,7 +24611,10 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
28602
24611
  * @param {CreateProviderParams} params - The parameters for creating the provider.
28603
24612
  * @returns {Promise<CreateProviderResult>} A promise that resolves to the created provider.
28604
24613
  */ async createProvider(params) {
28605
- return await $5c763be0b0b81038$export$500fbc0cd14cdbaa(params.walletProvider);
24614
+ const web3Provider = await $5c763be0b0b81038$export$500fbc0cd14cdbaa(params.walletProvider);
24615
+ return {
24616
+ provider: web3Provider
24617
+ };
28606
24618
  }
28607
24619
  /**
28608
24620
  * Checks if a wallet is connected to the specified provider.
@@ -28719,7 +24731,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
28719
24731
  function $parcel$export(e, n, v, s) {
28720
24732
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
28721
24733
  }
28722
- const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.4.0-alpha";
24734
+ const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.4.0-alpha.2";
28723
24735
  const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
28724
24736
  const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
28725
24737
 
@@ -30538,7 +26550,6 @@ exports.ERC721PermissionedMintable = ERC721PermissionedMintable;
30538
26550
  exports.GenericIMXProvider = GenericIMXProvider;
30539
26551
  exports.ImmutableConfiguration = ImmutableConfiguration;
30540
26552
  exports.ImmutableXClient = ImmutableXClient;
30541
- exports.JsonRpcError = JsonRpcError;
30542
26553
  exports.MetaMaskIMXProvider = MetaMaskIMXProvider;
30543
26554
  exports.Orderbook = Orderbook;
30544
26555
  exports.Passport = Passport;