@kimafinance/kima-transaction-widget 1.2.71-beta.1 → 1.2.73-beta.1

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.js CHANGED
@@ -920,8 +920,8 @@ var getNetworkOption = function getNetworkOption(id) {
920
920
  if (index < 0) return;
921
921
  return networkOptions[index];
922
922
  };
923
- var CLUSTER = 'devnet';
924
- var SOLANA_HOST = web3_js.clusterApiUrl(CLUSTER);
923
+ var SOLANA_HOST_DEVNET = web3_js.clusterApiUrl('devnet');
924
+ var SOLANA_HOST_MAINNET = web3_js.clusterApiUrl('mainnet-beta');
925
925
  var isEVMChain = function isEVMChain(chainId) {
926
926
  return chainId === exports.SupportNetworks.ETHEREUM || chainId === exports.SupportNetworks.POLYGON || chainId === exports.SupportNetworks.AVALANCHE || chainId === exports.SupportNetworks.BSC || chainId === exports.SupportNetworks.OPTIMISM || chainId === exports.SupportNetworks.ARBITRUM || chainId === exports.SupportNetworks.POLYGON_ZKEVM;
927
927
  };
@@ -7480,8 +7480,17 @@ function useAllowance(_ref) {
7480
7480
  if (tronAddress && tokenAddress) {
7481
7481
  return Promise.resolve(tronWeb.contract(ERC20ABI.abi, tokenAddress)).then(function (trc20Contract) {
7482
7482
  return Promise.resolve(trc20Contract.decimals().call()).then(function (decimals) {
7483
+ var parsedDecimals;
7484
+ if (typeof decimals === 'bigint') {
7485
+ parsedDecimals = Number(decimals);
7486
+ } else if (typeof decimals === 'string') {
7487
+ parsedDecimals = parseFloat(decimals);
7488
+ } else {
7489
+ parsedDecimals = decimals;
7490
+ }
7483
7491
  return Promise.resolve(trc20Contract.allowance(tronAddress, targetAddress).call()).then(function (userAllowance) {
7484
- setDecimals(+decimals);
7492
+ console.log(parsedDecimals, typeof parsedDecimals);
7493
+ setDecimals(parsedDecimals);
7485
7494
  setAllowance(+units.formatUnits(userAllowance, decimals));
7486
7495
  });
7487
7496
  });
@@ -7955,7 +7964,7 @@ function output(out, instance) {
7955
7964
  exports.output = output;
7956
7965
  const assert = { number, bool, bytes, hash, exists, output };
7957
7966
  exports.default = assert;
7958
- //# sourceMappingURL=_assert.js.map
7967
+
7959
7968
  });
7960
7969
 
7961
7970
  unwrapExports(_assert);
@@ -7964,7 +7973,7 @@ var crypto = createCommonjsModule(function (module, exports) {
7964
7973
  Object.defineProperty(exports, "__esModule", { value: true });
7965
7974
  exports.crypto = void 0;
7966
7975
  exports.crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
7967
- //# sourceMappingURL=crypto.js.map
7976
+
7968
7977
  });
7969
7978
 
7970
7979
  unwrapExports(crypto);
@@ -8166,7 +8175,7 @@ function randomBytes(bytesLength = 32) {
8166
8175
  throw new Error('crypto.getRandomValues must be defined');
8167
8176
  }
8168
8177
  exports.randomBytes = randomBytes;
8169
- //# sourceMappingURL=utils.js.map
8178
+
8170
8179
  });
8171
8180
 
8172
8181
  unwrapExports(utils);
@@ -8288,7 +8297,7 @@ class SHA2 extends utils.Hash {
8288
8297
  }
8289
8298
  }
8290
8299
  exports.SHA2 = SHA2;
8291
- //# sourceMappingURL=_sha2.js.map
8300
+
8292
8301
  });
8293
8302
 
8294
8303
  unwrapExports(_sha2);
@@ -8421,7 +8430,7 @@ class SHA224 extends SHA256 {
8421
8430
  */
8422
8431
  exports.sha256 = (0, utils.wrapConstructor)(() => new SHA256());
8423
8432
  exports.sha224 = (0, utils.wrapConstructor)(() => new SHA224());
8424
- //# sourceMappingURL=sha256.js.map
8433
+
8425
8434
  });
8426
8435
 
8427
8436
  unwrapExports(sha256);
@@ -8804,6 +8813,8 @@ const isFormData = (thing) => {
8804
8813
  */
8805
8814
  const isURLSearchParams = kindOfTest('URLSearchParams');
8806
8815
 
8816
+ const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest);
8817
+
8807
8818
  /**
8808
8819
  * Trim excess whitespace off the beginning and end of a string
8809
8820
  *
@@ -9192,8 +9203,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
9192
9203
  const noop = () => {};
9193
9204
 
9194
9205
  const toFiniteNumber = (value, defaultValue) => {
9195
- value = +value;
9196
- return Number.isFinite(value) ? value : defaultValue;
9206
+ return value != null && Number.isFinite(value = +value) ? value : defaultValue;
9197
9207
  };
9198
9208
 
9199
9209
  const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
@@ -9263,6 +9273,36 @@ const isAsyncFn = kindOfTest('AsyncFunction');
9263
9273
  const isThenable = (thing) =>
9264
9274
  thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
9265
9275
 
9276
+ // original code
9277
+ // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
9278
+
9279
+ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
9280
+ if (setImmediateSupported) {
9281
+ return setImmediate;
9282
+ }
9283
+
9284
+ return postMessageSupported ? ((token, callbacks) => {
9285
+ _global.addEventListener("message", ({source, data}) => {
9286
+ if (source === _global && data === token) {
9287
+ callbacks.length && callbacks.shift()();
9288
+ }
9289
+ }, false);
9290
+
9291
+ return (cb) => {
9292
+ callbacks.push(cb);
9293
+ _global.postMessage(token, "*");
9294
+ }
9295
+ })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
9296
+ })(
9297
+ typeof setImmediate === 'function',
9298
+ isFunction(_global.postMessage)
9299
+ );
9300
+
9301
+ const asap = typeof queueMicrotask !== 'undefined' ?
9302
+ queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
9303
+
9304
+ // *********************
9305
+
9266
9306
  var utils$1 = {
9267
9307
  isArray,
9268
9308
  isArrayBuffer,
@@ -9274,6 +9314,10 @@ var utils$1 = {
9274
9314
  isBoolean,
9275
9315
  isObject,
9276
9316
  isPlainObject,
9317
+ isReadableStream,
9318
+ isRequest,
9319
+ isResponse,
9320
+ isHeaders,
9277
9321
  isUndefined,
9278
9322
  isDate,
9279
9323
  isFile,
@@ -9314,7 +9358,9 @@ var utils$1 = {
9314
9358
  isSpecCompliantForm,
9315
9359
  toJSONObject,
9316
9360
  isAsyncFn,
9317
- isThenable
9361
+ isThenable,
9362
+ setImmediate: _setImmediate,
9363
+ asap
9318
9364
  };
9319
9365
 
9320
9366
  /**
@@ -9342,7 +9388,10 @@ function AxiosError(message, code, config, request, response) {
9342
9388
  code && (this.code = code);
9343
9389
  config && (this.config = config);
9344
9390
  request && (this.request = request);
9345
- response && (this.response = response);
9391
+ if (response) {
9392
+ this.response = response;
9393
+ this.status = response.status ? response.status : null;
9394
+ }
9346
9395
  }
9347
9396
 
9348
9397
  utils$1.inherits(AxiosError, Error, {
@@ -9362,7 +9411,7 @@ utils$1.inherits(AxiosError, Error, {
9362
9411
  // Axios
9363
9412
  config: utils$1.toJSONObject(this.config),
9364
9413
  code: this.code,
9365
- status: this.response && this.response.status ? this.response.status : null
9414
+ status: this.status
9366
9415
  };
9367
9416
  }
9368
9417
  });
@@ -9828,6 +9877,8 @@ var platform = {
9828
9877
 
9829
9878
  const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
9830
9879
 
9880
+ const _navigator = typeof navigator === 'object' && navigator || undefined;
9881
+
9831
9882
  /**
9832
9883
  * Determine if we're running in a standard browser environment
9833
9884
  *
@@ -9845,10 +9896,8 @@ const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'unde
9845
9896
  *
9846
9897
  * @returns {boolean}
9847
9898
  */
9848
- const hasStandardBrowserEnv = (
9849
- (product) => {
9850
- return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0
9851
- })(typeof navigator !== 'undefined' && navigator.product);
9899
+ const hasStandardBrowserEnv = hasBrowserEnv &&
9900
+ (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
9852
9901
 
9853
9902
  /**
9854
9903
  * Determine if we're running in a standard browser webWorker environment
@@ -9868,11 +9917,15 @@ const hasStandardBrowserWebWorkerEnv = (() => {
9868
9917
  );
9869
9918
  })();
9870
9919
 
9920
+ const origin = hasBrowserEnv && window.location.href || 'http://localhost';
9921
+
9871
9922
  var utils$2 = {
9872
9923
  __proto__: null,
9873
9924
  hasBrowserEnv: hasBrowserEnv,
9874
9925
  hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
9875
- hasStandardBrowserEnv: hasStandardBrowserEnv
9926
+ hasStandardBrowserEnv: hasStandardBrowserEnv,
9927
+ navigator: _navigator,
9928
+ origin: origin
9876
9929
  };
9877
9930
 
9878
9931
  var platform$1 = {
@@ -10012,7 +10065,7 @@ const defaults = {
10012
10065
 
10013
10066
  transitional: transitionalDefaults,
10014
10067
 
10015
- adapter: ['xhr', 'http'],
10068
+ adapter: ['xhr', 'http', 'fetch'],
10016
10069
 
10017
10070
  transformRequest: [function transformRequest(data, headers) {
10018
10071
  const contentType = headers.getContentType() || '';
@@ -10033,7 +10086,8 @@ const defaults = {
10033
10086
  utils$1.isBuffer(data) ||
10034
10087
  utils$1.isStream(data) ||
10035
10088
  utils$1.isFile(data) ||
10036
- utils$1.isBlob(data)
10089
+ utils$1.isBlob(data) ||
10090
+ utils$1.isReadableStream(data)
10037
10091
  ) {
10038
10092
  return data;
10039
10093
  }
@@ -10076,6 +10130,10 @@ const defaults = {
10076
10130
  const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
10077
10131
  const JSONRequested = this.responseType === 'json';
10078
10132
 
10133
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
10134
+ return data;
10135
+ }
10136
+
10079
10137
  if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
10080
10138
  const silentJSONParsing = transitional && transitional.silentJSONParsing;
10081
10139
  const strictJSONParsing = !silentJSONParsing && JSONRequested;
@@ -10277,6 +10335,10 @@ class AxiosHeaders {
10277
10335
  setHeaders(header, valueOrRewrite);
10278
10336
  } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
10279
10337
  setHeaders(parseHeaders(header), valueOrRewrite);
10338
+ } else if (utils$1.isHeaders(header)) {
10339
+ for (const [key, value] of header.entries()) {
10340
+ setHeader(value, key, rewrite);
10341
+ }
10280
10342
  } else {
10281
10343
  header != null && setHeader(valueOrRewrite, header, rewrite);
10282
10344
  }
@@ -10542,96 +10604,153 @@ function settle(resolve, reject, response) {
10542
10604
  }
10543
10605
  }
10544
10606
 
10545
- var cookies = platform$1.hasStandardBrowserEnv ?
10607
+ function parseProtocol(url) {
10608
+ const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
10609
+ return match && match[1] || '';
10610
+ }
10546
10611
 
10547
- // Standard browser envs support document.cookie
10548
- {
10549
- write(name, value, expires, path, domain, secure) {
10550
- const cookie = [name + '=' + encodeURIComponent(value)];
10612
+ /**
10613
+ * Calculate data maxRate
10614
+ * @param {Number} [samplesCount= 10]
10615
+ * @param {Number} [min= 1000]
10616
+ * @returns {Function}
10617
+ */
10618
+ function speedometer(samplesCount, min) {
10619
+ samplesCount = samplesCount || 10;
10620
+ const bytes = new Array(samplesCount);
10621
+ const timestamps = new Array(samplesCount);
10622
+ let head = 0;
10623
+ let tail = 0;
10624
+ let firstSampleTS;
10551
10625
 
10552
- utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
10626
+ min = min !== undefined ? min : 1000;
10553
10627
 
10554
- utils$1.isString(path) && cookie.push('path=' + path);
10628
+ return function push(chunkLength) {
10629
+ const now = Date.now();
10555
10630
 
10556
- utils$1.isString(domain) && cookie.push('domain=' + domain);
10631
+ const startedAt = timestamps[tail];
10557
10632
 
10558
- secure === true && cookie.push('secure');
10633
+ if (!firstSampleTS) {
10634
+ firstSampleTS = now;
10635
+ }
10559
10636
 
10560
- document.cookie = cookie.join('; ');
10561
- },
10637
+ bytes[head] = chunkLength;
10638
+ timestamps[head] = now;
10562
10639
 
10563
- read(name) {
10564
- const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
10565
- return (match ? decodeURIComponent(match[3]) : null);
10566
- },
10640
+ let i = tail;
10641
+ let bytesCount = 0;
10567
10642
 
10568
- remove(name) {
10569
- this.write(name, '', Date.now() - 86400000);
10643
+ while (i !== head) {
10644
+ bytesCount += bytes[i++];
10645
+ i = i % samplesCount;
10570
10646
  }
10571
- }
10572
10647
 
10573
- :
10648
+ head = (head + 1) % samplesCount;
10574
10649
 
10575
- // Non-standard browser env (web workers, react-native) lack needed support.
10576
- {
10577
- write() {},
10578
- read() {
10579
- return null;
10580
- },
10581
- remove() {}
10582
- };
10650
+ if (head === tail) {
10651
+ tail = (tail + 1) % samplesCount;
10652
+ }
10583
10653
 
10584
- /**
10585
- * Determines whether the specified URL is absolute
10586
- *
10587
- * @param {string} url The URL to test
10588
- *
10589
- * @returns {boolean} True if the specified URL is absolute, otherwise false
10590
- */
10591
- function isAbsoluteURL(url) {
10592
- // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
10593
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
10594
- // by any combination of letters, digits, plus, period, or hyphen.
10595
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
10596
- }
10654
+ if (now - firstSampleTS < min) {
10655
+ return;
10656
+ }
10597
10657
 
10598
- /**
10599
- * Creates a new URL by combining the specified URLs
10600
- *
10601
- * @param {string} baseURL The base URL
10602
- * @param {string} relativeURL The relative URL
10603
- *
10604
- * @returns {string} The combined URL
10605
- */
10606
- function combineURLs(baseURL, relativeURL) {
10607
- return relativeURL
10608
- ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
10609
- : baseURL;
10658
+ const passed = startedAt && now - startedAt;
10659
+
10660
+ return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
10661
+ };
10610
10662
  }
10611
10663
 
10612
10664
  /**
10613
- * Creates a new URL by combining the baseURL with the requestedURL,
10614
- * only when the requestedURL is not already an absolute URL.
10615
- * If the requestURL is absolute, this function returns the requestedURL untouched.
10616
- *
10617
- * @param {string} baseURL The base URL
10618
- * @param {string} requestedURL Absolute or relative URL to combine
10619
- *
10620
- * @returns {string} The combined full path
10665
+ * Throttle decorator
10666
+ * @param {Function} fn
10667
+ * @param {Number} freq
10668
+ * @return {Function}
10621
10669
  */
10622
- function buildFullPath(baseURL, requestedURL) {
10623
- if (baseURL && !isAbsoluteURL(requestedURL)) {
10624
- return combineURLs(baseURL, requestedURL);
10625
- }
10626
- return requestedURL;
10670
+ function throttle(fn, freq) {
10671
+ let timestamp = 0;
10672
+ let threshold = 1000 / freq;
10673
+ let lastArgs;
10674
+ let timer;
10675
+
10676
+ const invoke = (args, now = Date.now()) => {
10677
+ timestamp = now;
10678
+ lastArgs = null;
10679
+ if (timer) {
10680
+ clearTimeout(timer);
10681
+ timer = null;
10682
+ }
10683
+ fn.apply(null, args);
10684
+ };
10685
+
10686
+ const throttled = (...args) => {
10687
+ const now = Date.now();
10688
+ const passed = now - timestamp;
10689
+ if ( passed >= threshold) {
10690
+ invoke(args, now);
10691
+ } else {
10692
+ lastArgs = args;
10693
+ if (!timer) {
10694
+ timer = setTimeout(() => {
10695
+ timer = null;
10696
+ invoke(lastArgs);
10697
+ }, threshold - passed);
10698
+ }
10699
+ }
10700
+ };
10701
+
10702
+ const flush = () => lastArgs && invoke(lastArgs);
10703
+
10704
+ return [throttled, flush];
10627
10705
  }
10628
10706
 
10707
+ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
10708
+ let bytesNotified = 0;
10709
+ const _speedometer = speedometer(50, 250);
10710
+
10711
+ return throttle(e => {
10712
+ const loaded = e.loaded;
10713
+ const total = e.lengthComputable ? e.total : undefined;
10714
+ const progressBytes = loaded - bytesNotified;
10715
+ const rate = _speedometer(progressBytes);
10716
+ const inRange = loaded <= total;
10717
+
10718
+ bytesNotified = loaded;
10719
+
10720
+ const data = {
10721
+ loaded,
10722
+ total,
10723
+ progress: total ? (loaded / total) : undefined,
10724
+ bytes: progressBytes,
10725
+ rate: rate ? rate : undefined,
10726
+ estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
10727
+ event: e,
10728
+ lengthComputable: total != null,
10729
+ [isDownloadStream ? 'download' : 'upload']: true
10730
+ };
10731
+
10732
+ listener(data);
10733
+ }, freq);
10734
+ };
10735
+
10736
+ const progressEventDecorator = (total, throttled) => {
10737
+ const lengthComputable = total != null;
10738
+
10739
+ return [(loaded) => throttled[0]({
10740
+ lengthComputable,
10741
+ total,
10742
+ loaded
10743
+ }), throttled[1]];
10744
+ };
10745
+
10746
+ const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
10747
+
10629
10748
  var isURLSameOrigin = platform$1.hasStandardBrowserEnv ?
10630
10749
 
10631
10750
  // Standard browser envs have full support of the APIs needed to test
10632
10751
  // whether the request URL is of the same origin as current location.
10633
10752
  (function standardBrowserEnv() {
10634
- const msie = /(msie|trident)/i.test(navigator.userAgent);
10753
+ const msie = platform$1.navigator && /(msie|trident)/i.test(platform$1.navigator.userAgent);
10635
10754
  const urlParsingNode = document.createElement('a');
10636
10755
  let originURL;
10637
10756
 
@@ -10689,137 +10808,267 @@ var isURLSameOrigin = platform$1.hasStandardBrowserEnv ?
10689
10808
  };
10690
10809
  })();
10691
10810
 
10692
- function parseProtocol(url) {
10693
- const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
10694
- return match && match[1] || '';
10695
- }
10696
-
10697
- /**
10698
- * Calculate data maxRate
10699
- * @param {Number} [samplesCount= 10]
10700
- * @param {Number} [min= 1000]
10701
- * @returns {Function}
10702
- */
10703
- function speedometer(samplesCount, min) {
10704
- samplesCount = samplesCount || 10;
10705
- const bytes = new Array(samplesCount);
10706
- const timestamps = new Array(samplesCount);
10707
- let head = 0;
10708
- let tail = 0;
10709
- let firstSampleTS;
10710
-
10711
- min = min !== undefined ? min : 1000;
10712
-
10713
- return function push(chunkLength) {
10714
- const now = Date.now();
10811
+ var cookies = platform$1.hasStandardBrowserEnv ?
10715
10812
 
10716
- const startedAt = timestamps[tail];
10813
+ // Standard browser envs support document.cookie
10814
+ {
10815
+ write(name, value, expires, path, domain, secure) {
10816
+ const cookie = [name + '=' + encodeURIComponent(value)];
10717
10817
 
10718
- if (!firstSampleTS) {
10719
- firstSampleTS = now;
10720
- }
10818
+ utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
10721
10819
 
10722
- bytes[head] = chunkLength;
10723
- timestamps[head] = now;
10820
+ utils$1.isString(path) && cookie.push('path=' + path);
10724
10821
 
10725
- let i = tail;
10726
- let bytesCount = 0;
10822
+ utils$1.isString(domain) && cookie.push('domain=' + domain);
10727
10823
 
10728
- while (i !== head) {
10729
- bytesCount += bytes[i++];
10730
- i = i % samplesCount;
10731
- }
10824
+ secure === true && cookie.push('secure');
10732
10825
 
10733
- head = (head + 1) % samplesCount;
10826
+ document.cookie = cookie.join('; ');
10827
+ },
10734
10828
 
10735
- if (head === tail) {
10736
- tail = (tail + 1) % samplesCount;
10737
- }
10829
+ read(name) {
10830
+ const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
10831
+ return (match ? decodeURIComponent(match[3]) : null);
10832
+ },
10738
10833
 
10739
- if (now - firstSampleTS < min) {
10740
- return;
10834
+ remove(name) {
10835
+ this.write(name, '', Date.now() - 86400000);
10741
10836
  }
10837
+ }
10742
10838
 
10743
- const passed = startedAt && now - startedAt;
10839
+ :
10744
10840
 
10745
- return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
10841
+ // Non-standard browser env (web workers, react-native) lack needed support.
10842
+ {
10843
+ write() {},
10844
+ read() {
10845
+ return null;
10846
+ },
10847
+ remove() {}
10746
10848
  };
10747
- }
10748
10849
 
10749
- function progressEventReducer(listener, isDownloadStream) {
10750
- let bytesNotified = 0;
10751
- const _speedometer = speedometer(50, 250);
10850
+ /**
10851
+ * Determines whether the specified URL is absolute
10852
+ *
10853
+ * @param {string} url The URL to test
10854
+ *
10855
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
10856
+ */
10857
+ function isAbsoluteURL(url) {
10858
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
10859
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
10860
+ // by any combination of letters, digits, plus, period, or hyphen.
10861
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
10862
+ }
10752
10863
 
10753
- return e => {
10754
- const loaded = e.loaded;
10755
- const total = e.lengthComputable ? e.total : undefined;
10756
- const progressBytes = loaded - bytesNotified;
10757
- const rate = _speedometer(progressBytes);
10758
- const inRange = loaded <= total;
10864
+ /**
10865
+ * Creates a new URL by combining the specified URLs
10866
+ *
10867
+ * @param {string} baseURL The base URL
10868
+ * @param {string} relativeURL The relative URL
10869
+ *
10870
+ * @returns {string} The combined URL
10871
+ */
10872
+ function combineURLs(baseURL, relativeURL) {
10873
+ return relativeURL
10874
+ ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
10875
+ : baseURL;
10876
+ }
10759
10877
 
10760
- bytesNotified = loaded;
10878
+ /**
10879
+ * Creates a new URL by combining the baseURL with the requestedURL,
10880
+ * only when the requestedURL is not already an absolute URL.
10881
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
10882
+ *
10883
+ * @param {string} baseURL The base URL
10884
+ * @param {string} requestedURL Absolute or relative URL to combine
10885
+ *
10886
+ * @returns {string} The combined full path
10887
+ */
10888
+ function buildFullPath(baseURL, requestedURL) {
10889
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
10890
+ return combineURLs(baseURL, requestedURL);
10891
+ }
10892
+ return requestedURL;
10893
+ }
10761
10894
 
10762
- const data = {
10763
- loaded,
10764
- total,
10765
- progress: total ? (loaded / total) : undefined,
10766
- bytes: progressBytes,
10767
- rate: rate ? rate : undefined,
10768
- estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
10769
- event: e
10770
- };
10895
+ const headersToObject = (thing) => thing instanceof AxiosHeaders ? { ...thing } : thing;
10771
10896
 
10772
- data[isDownloadStream ? 'download' : 'upload'] = true;
10897
+ /**
10898
+ * Config-specific merge-function which creates a new config-object
10899
+ * by merging two configuration objects together.
10900
+ *
10901
+ * @param {Object} config1
10902
+ * @param {Object} config2
10903
+ *
10904
+ * @returns {Object} New object resulting from merging config2 to config1
10905
+ */
10906
+ function mergeConfig(config1, config2) {
10907
+ // eslint-disable-next-line no-param-reassign
10908
+ config2 = config2 || {};
10909
+ const config = {};
10773
10910
 
10774
- listener(data);
10911
+ function getMergedValue(target, source, caseless) {
10912
+ if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
10913
+ return utils$1.merge.call({caseless}, target, source);
10914
+ } else if (utils$1.isPlainObject(source)) {
10915
+ return utils$1.merge({}, source);
10916
+ } else if (utils$1.isArray(source)) {
10917
+ return source.slice();
10918
+ }
10919
+ return source;
10920
+ }
10921
+
10922
+ // eslint-disable-next-line consistent-return
10923
+ function mergeDeepProperties(a, b, caseless) {
10924
+ if (!utils$1.isUndefined(b)) {
10925
+ return getMergedValue(a, b, caseless);
10926
+ } else if (!utils$1.isUndefined(a)) {
10927
+ return getMergedValue(undefined, a, caseless);
10928
+ }
10929
+ }
10930
+
10931
+ // eslint-disable-next-line consistent-return
10932
+ function valueFromConfig2(a, b) {
10933
+ if (!utils$1.isUndefined(b)) {
10934
+ return getMergedValue(undefined, b);
10935
+ }
10936
+ }
10937
+
10938
+ // eslint-disable-next-line consistent-return
10939
+ function defaultToConfig2(a, b) {
10940
+ if (!utils$1.isUndefined(b)) {
10941
+ return getMergedValue(undefined, b);
10942
+ } else if (!utils$1.isUndefined(a)) {
10943
+ return getMergedValue(undefined, a);
10944
+ }
10945
+ }
10946
+
10947
+ // eslint-disable-next-line consistent-return
10948
+ function mergeDirectKeys(a, b, prop) {
10949
+ if (prop in config2) {
10950
+ return getMergedValue(a, b);
10951
+ } else if (prop in config1) {
10952
+ return getMergedValue(undefined, a);
10953
+ }
10954
+ }
10955
+
10956
+ const mergeMap = {
10957
+ url: valueFromConfig2,
10958
+ method: valueFromConfig2,
10959
+ data: valueFromConfig2,
10960
+ baseURL: defaultToConfig2,
10961
+ transformRequest: defaultToConfig2,
10962
+ transformResponse: defaultToConfig2,
10963
+ paramsSerializer: defaultToConfig2,
10964
+ timeout: defaultToConfig2,
10965
+ timeoutMessage: defaultToConfig2,
10966
+ withCredentials: defaultToConfig2,
10967
+ withXSRFToken: defaultToConfig2,
10968
+ adapter: defaultToConfig2,
10969
+ responseType: defaultToConfig2,
10970
+ xsrfCookieName: defaultToConfig2,
10971
+ xsrfHeaderName: defaultToConfig2,
10972
+ onUploadProgress: defaultToConfig2,
10973
+ onDownloadProgress: defaultToConfig2,
10974
+ decompress: defaultToConfig2,
10975
+ maxContentLength: defaultToConfig2,
10976
+ maxBodyLength: defaultToConfig2,
10977
+ beforeRedirect: defaultToConfig2,
10978
+ transport: defaultToConfig2,
10979
+ httpAgent: defaultToConfig2,
10980
+ httpsAgent: defaultToConfig2,
10981
+ cancelToken: defaultToConfig2,
10982
+ socketPath: defaultToConfig2,
10983
+ responseEncoding: defaultToConfig2,
10984
+ validateStatus: mergeDirectKeys,
10985
+ headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
10775
10986
  };
10987
+
10988
+ utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
10989
+ const merge = mergeMap[prop] || mergeDeepProperties;
10990
+ const configValue = merge(config1[prop], config2[prop], prop);
10991
+ (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
10992
+ });
10993
+
10994
+ return config;
10776
10995
  }
10777
10996
 
10778
- const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
10997
+ var resolveConfig = (config) => {
10998
+ const newConfig = mergeConfig({}, config);
10779
10999
 
10780
- var xhrAdapter = isXHRAdapterSupported && function (config) {
10781
- return new Promise(function dispatchXhrRequest(resolve, reject) {
10782
- let requestData = config.data;
10783
- const requestHeaders = AxiosHeaders.from(config.headers).normalize();
10784
- let {responseType, withXSRFToken} = config;
10785
- let onCanceled;
10786
- function done() {
10787
- if (config.cancelToken) {
10788
- config.cancelToken.unsubscribe(onCanceled);
10789
- }
11000
+ let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
10790
11001
 
10791
- if (config.signal) {
10792
- config.signal.removeEventListener('abort', onCanceled);
10793
- }
11002
+ newConfig.headers = headers = AxiosHeaders.from(headers);
11003
+
11004
+ newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
11005
+
11006
+ // HTTP basic authentication
11007
+ if (auth) {
11008
+ headers.set('Authorization', 'Basic ' +
11009
+ btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
11010
+ );
11011
+ }
11012
+
11013
+ let contentType;
11014
+
11015
+ if (utils$1.isFormData(data)) {
11016
+ if (platform$1.hasStandardBrowserEnv || platform$1.hasStandardBrowserWebWorkerEnv) {
11017
+ headers.setContentType(undefined); // Let the browser set it
11018
+ } else if ((contentType = headers.getContentType()) !== false) {
11019
+ // fix semicolon duplication issue for ReactNative FormData implementation
11020
+ const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
11021
+ headers.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
10794
11022
  }
11023
+ }
11024
+
11025
+ // Add xsrf header
11026
+ // This is only done if running in a standard browser environment.
11027
+ // Specifically not if we're in a web worker, or react-native.
10795
11028
 
10796
- let contentType;
11029
+ if (platform$1.hasStandardBrowserEnv) {
11030
+ withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
10797
11031
 
10798
- if (utils$1.isFormData(requestData)) {
10799
- if (platform$1.hasStandardBrowserEnv || platform$1.hasStandardBrowserWebWorkerEnv) {
10800
- requestHeaders.setContentType(false); // Let the browser set it
10801
- } else if ((contentType = requestHeaders.getContentType()) !== false) {
10802
- // fix semicolon duplication issue for ReactNative FormData implementation
10803
- const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
10804
- requestHeaders.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
11032
+ if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
11033
+ // Add xsrf header
11034
+ const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
11035
+
11036
+ if (xsrfValue) {
11037
+ headers.set(xsrfHeaderName, xsrfValue);
10805
11038
  }
10806
11039
  }
11040
+ }
10807
11041
 
10808
- let request = new XMLHttpRequest();
11042
+ return newConfig;
11043
+ };
11044
+
11045
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
11046
+
11047
+ var xhrAdapter = isXHRAdapterSupported && function (config) {
11048
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
11049
+ const _config = resolveConfig(config);
11050
+ let requestData = _config.data;
11051
+ const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
11052
+ let {responseType, onUploadProgress, onDownloadProgress} = _config;
11053
+ let onCanceled;
11054
+ let uploadThrottled, downloadThrottled;
11055
+ let flushUpload, flushDownload;
11056
+
11057
+ function done() {
11058
+ flushUpload && flushUpload(); // flush events
11059
+ flushDownload && flushDownload(); // flush events
11060
+
11061
+ _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
10809
11062
 
10810
- // HTTP basic authentication
10811
- if (config.auth) {
10812
- const username = config.auth.username || '';
10813
- const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
10814
- requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
11063
+ _config.signal && _config.signal.removeEventListener('abort', onCanceled);
10815
11064
  }
10816
11065
 
10817
- const fullPath = buildFullPath(config.baseURL, config.url);
11066
+ let request = new XMLHttpRequest();
10818
11067
 
10819
- request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
11068
+ request.open(_config.method.toUpperCase(), _config.url, true);
10820
11069
 
10821
11070
  // Set the request timeout in MS
10822
- request.timeout = config.timeout;
11071
+ request.timeout = _config.timeout;
10823
11072
 
10824
11073
  function onloadend() {
10825
11074
  if (!request) {
@@ -10899,10 +11148,10 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
10899
11148
 
10900
11149
  // Handle timeout
10901
11150
  request.ontimeout = function handleTimeout() {
10902
- let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
10903
- const transitional = config.transitional || transitionalDefaults;
10904
- if (config.timeoutErrorMessage) {
10905
- timeoutErrorMessage = config.timeoutErrorMessage;
11151
+ let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
11152
+ const transitional = _config.transitional || transitionalDefaults;
11153
+ if (_config.timeoutErrorMessage) {
11154
+ timeoutErrorMessage = _config.timeoutErrorMessage;
10906
11155
  }
10907
11156
  reject(new AxiosError(
10908
11157
  timeoutErrorMessage,
@@ -10914,22 +11163,6 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
10914
11163
  request = null;
10915
11164
  };
10916
11165
 
10917
- // Add xsrf header
10918
- // This is only done if running in a standard browser environment.
10919
- // Specifically not if we're in a web worker, or react-native.
10920
- if(platform$1.hasStandardBrowserEnv) {
10921
- withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(config));
10922
-
10923
- if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(fullPath))) {
10924
- // Add xsrf header
10925
- const xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
10926
-
10927
- if (xsrfValue) {
10928
- requestHeaders.set(config.xsrfHeaderName, xsrfValue);
10929
- }
10930
- }
10931
- }
10932
-
10933
11166
  // Remove Content-Type if data is undefined
10934
11167
  requestData === undefined && requestHeaders.setContentType(null);
10935
11168
 
@@ -10941,26 +11174,31 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
10941
11174
  }
10942
11175
 
10943
11176
  // Add withCredentials to request if needed
10944
- if (!utils$1.isUndefined(config.withCredentials)) {
10945
- request.withCredentials = !!config.withCredentials;
11177
+ if (!utils$1.isUndefined(_config.withCredentials)) {
11178
+ request.withCredentials = !!_config.withCredentials;
10946
11179
  }
10947
11180
 
10948
11181
  // Add responseType to request if needed
10949
11182
  if (responseType && responseType !== 'json') {
10950
- request.responseType = config.responseType;
11183
+ request.responseType = _config.responseType;
10951
11184
  }
10952
11185
 
10953
11186
  // Handle progress if needed
10954
- if (typeof config.onDownloadProgress === 'function') {
10955
- request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true));
11187
+ if (onDownloadProgress) {
11188
+ ([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
11189
+ request.addEventListener('progress', downloadThrottled);
10956
11190
  }
10957
11191
 
10958
11192
  // Not all browsers support upload events
10959
- if (typeof config.onUploadProgress === 'function' && request.upload) {
10960
- request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress));
11193
+ if (onUploadProgress && request.upload) {
11194
+ ([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
11195
+
11196
+ request.upload.addEventListener('progress', uploadThrottled);
11197
+
11198
+ request.upload.addEventListener('loadend', flushUpload);
10961
11199
  }
10962
11200
 
10963
- if (config.cancelToken || config.signal) {
11201
+ if (_config.cancelToken || _config.signal) {
10964
11202
  // Handle cancellation
10965
11203
  // eslint-disable-next-line func-names
10966
11204
  onCanceled = cancel => {
@@ -10972,13 +11210,13 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
10972
11210
  request = null;
10973
11211
  };
10974
11212
 
10975
- config.cancelToken && config.cancelToken.subscribe(onCanceled);
10976
- if (config.signal) {
10977
- config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
11213
+ _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
11214
+ if (_config.signal) {
11215
+ _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
10978
11216
  }
10979
11217
  }
10980
11218
 
10981
- const protocol = parseProtocol(fullPath);
11219
+ const protocol = parseProtocol(_config.url);
10982
11220
 
10983
11221
  if (protocol && platform$1.protocols.indexOf(protocol) === -1) {
10984
11222
  reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
@@ -10991,9 +11229,358 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
10991
11229
  });
10992
11230
  };
10993
11231
 
11232
+ const composeSignals = (signals, timeout) => {
11233
+ const {length} = (signals = signals ? signals.filter(Boolean) : []);
11234
+
11235
+ if (timeout || length) {
11236
+ let controller = new AbortController();
11237
+
11238
+ let aborted;
11239
+
11240
+ const onabort = function (reason) {
11241
+ if (!aborted) {
11242
+ aborted = true;
11243
+ unsubscribe();
11244
+ const err = reason instanceof Error ? reason : this.reason;
11245
+ controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
11246
+ }
11247
+ };
11248
+
11249
+ let timer = timeout && setTimeout(() => {
11250
+ timer = null;
11251
+ onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
11252
+ }, timeout);
11253
+
11254
+ const unsubscribe = () => {
11255
+ if (signals) {
11256
+ timer && clearTimeout(timer);
11257
+ timer = null;
11258
+ signals.forEach(signal => {
11259
+ signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
11260
+ });
11261
+ signals = null;
11262
+ }
11263
+ };
11264
+
11265
+ signals.forEach((signal) => signal.addEventListener('abort', onabort));
11266
+
11267
+ const {signal} = controller;
11268
+
11269
+ signal.unsubscribe = () => utils$1.asap(unsubscribe);
11270
+
11271
+ return signal;
11272
+ }
11273
+ };
11274
+
11275
+ const streamChunk = function* (chunk, chunkSize) {
11276
+ let len = chunk.byteLength;
11277
+
11278
+ if (!chunkSize || len < chunkSize) {
11279
+ yield chunk;
11280
+ return;
11281
+ }
11282
+
11283
+ let pos = 0;
11284
+ let end;
11285
+
11286
+ while (pos < len) {
11287
+ end = pos + chunkSize;
11288
+ yield chunk.slice(pos, end);
11289
+ pos = end;
11290
+ }
11291
+ };
11292
+
11293
+ const readBytes = async function* (iterable, chunkSize) {
11294
+ for await (const chunk of readStream(iterable)) {
11295
+ yield* streamChunk(chunk, chunkSize);
11296
+ }
11297
+ };
11298
+
11299
+ const readStream = async function* (stream) {
11300
+ if (stream[Symbol.asyncIterator]) {
11301
+ yield* stream;
11302
+ return;
11303
+ }
11304
+
11305
+ const reader = stream.getReader();
11306
+ try {
11307
+ for (;;) {
11308
+ const {done, value} = await reader.read();
11309
+ if (done) {
11310
+ break;
11311
+ }
11312
+ yield value;
11313
+ }
11314
+ } finally {
11315
+ await reader.cancel();
11316
+ }
11317
+ };
11318
+
11319
+ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
11320
+ const iterator = readBytes(stream, chunkSize);
11321
+
11322
+ let bytes = 0;
11323
+ let done;
11324
+ let _onFinish = (e) => {
11325
+ if (!done) {
11326
+ done = true;
11327
+ onFinish && onFinish(e);
11328
+ }
11329
+ };
11330
+
11331
+ return new ReadableStream({
11332
+ async pull(controller) {
11333
+ try {
11334
+ const {done, value} = await iterator.next();
11335
+
11336
+ if (done) {
11337
+ _onFinish();
11338
+ controller.close();
11339
+ return;
11340
+ }
11341
+
11342
+ let len = value.byteLength;
11343
+ if (onProgress) {
11344
+ let loadedBytes = bytes += len;
11345
+ onProgress(loadedBytes);
11346
+ }
11347
+ controller.enqueue(new Uint8Array(value));
11348
+ } catch (err) {
11349
+ _onFinish(err);
11350
+ throw err;
11351
+ }
11352
+ },
11353
+ cancel(reason) {
11354
+ _onFinish(reason);
11355
+ return iterator.return();
11356
+ }
11357
+ }, {
11358
+ highWaterMark: 2
11359
+ })
11360
+ };
11361
+
11362
+ const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
11363
+ const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
11364
+
11365
+ // used only inside the fetch adapter
11366
+ const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
11367
+ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
11368
+ async (str) => new Uint8Array(await new Response(str).arrayBuffer())
11369
+ );
11370
+
11371
+ const test = (fn, ...args) => {
11372
+ try {
11373
+ return !!fn(...args);
11374
+ } catch (e) {
11375
+ return false
11376
+ }
11377
+ };
11378
+
11379
+ const supportsRequestStream = isReadableStreamSupported && test(() => {
11380
+ let duplexAccessed = false;
11381
+
11382
+ const hasContentType = new Request(platform$1.origin, {
11383
+ body: new ReadableStream(),
11384
+ method: 'POST',
11385
+ get duplex() {
11386
+ duplexAccessed = true;
11387
+ return 'half';
11388
+ },
11389
+ }).headers.has('Content-Type');
11390
+
11391
+ return duplexAccessed && !hasContentType;
11392
+ });
11393
+
11394
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
11395
+
11396
+ const supportsResponseStream = isReadableStreamSupported &&
11397
+ test(() => utils$1.isReadableStream(new Response('').body));
11398
+
11399
+
11400
+ const resolvers = {
11401
+ stream: supportsResponseStream && ((res) => res.body)
11402
+ };
11403
+
11404
+ isFetchSupported && (((res) => {
11405
+ ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
11406
+ !resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
11407
+ (_, config) => {
11408
+ throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
11409
+ });
11410
+ });
11411
+ })(new Response));
11412
+
11413
+ const getBodyLength = async (body) => {
11414
+ if (body == null) {
11415
+ return 0;
11416
+ }
11417
+
11418
+ if(utils$1.isBlob(body)) {
11419
+ return body.size;
11420
+ }
11421
+
11422
+ if(utils$1.isSpecCompliantForm(body)) {
11423
+ const _request = new Request(platform$1.origin, {
11424
+ method: 'POST',
11425
+ body,
11426
+ });
11427
+ return (await _request.arrayBuffer()).byteLength;
11428
+ }
11429
+
11430
+ if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
11431
+ return body.byteLength;
11432
+ }
11433
+
11434
+ if(utils$1.isURLSearchParams(body)) {
11435
+ body = body + '';
11436
+ }
11437
+
11438
+ if(utils$1.isString(body)) {
11439
+ return (await encodeText(body)).byteLength;
11440
+ }
11441
+ };
11442
+
11443
+ const resolveBodyLength = async (headers, body) => {
11444
+ const length = utils$1.toFiniteNumber(headers.getContentLength());
11445
+
11446
+ return length == null ? getBodyLength(body) : length;
11447
+ };
11448
+
11449
+ var fetchAdapter = isFetchSupported && (async (config) => {
11450
+ let {
11451
+ url,
11452
+ method,
11453
+ data,
11454
+ signal,
11455
+ cancelToken,
11456
+ timeout,
11457
+ onDownloadProgress,
11458
+ onUploadProgress,
11459
+ responseType,
11460
+ headers,
11461
+ withCredentials = 'same-origin',
11462
+ fetchOptions
11463
+ } = resolveConfig(config);
11464
+
11465
+ responseType = responseType ? (responseType + '').toLowerCase() : 'text';
11466
+
11467
+ let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
11468
+
11469
+ let request;
11470
+
11471
+ const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
11472
+ composedSignal.unsubscribe();
11473
+ });
11474
+
11475
+ let requestContentLength;
11476
+
11477
+ try {
11478
+ if (
11479
+ onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
11480
+ (requestContentLength = await resolveBodyLength(headers, data)) !== 0
11481
+ ) {
11482
+ let _request = new Request(url, {
11483
+ method: 'POST',
11484
+ body: data,
11485
+ duplex: "half"
11486
+ });
11487
+
11488
+ let contentTypeHeader;
11489
+
11490
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
11491
+ headers.setContentType(contentTypeHeader);
11492
+ }
11493
+
11494
+ if (_request.body) {
11495
+ const [onProgress, flush] = progressEventDecorator(
11496
+ requestContentLength,
11497
+ progressEventReducer(asyncDecorator(onUploadProgress))
11498
+ );
11499
+
11500
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
11501
+ }
11502
+ }
11503
+
11504
+ if (!utils$1.isString(withCredentials)) {
11505
+ withCredentials = withCredentials ? 'include' : 'omit';
11506
+ }
11507
+
11508
+ // Cloudflare Workers throws when credentials are defined
11509
+ // see https://github.com/cloudflare/workerd/issues/902
11510
+ const isCredentialsSupported = "credentials" in Request.prototype;
11511
+ request = new Request(url, {
11512
+ ...fetchOptions,
11513
+ signal: composedSignal,
11514
+ method: method.toUpperCase(),
11515
+ headers: headers.normalize().toJSON(),
11516
+ body: data,
11517
+ duplex: "half",
11518
+ credentials: isCredentialsSupported ? withCredentials : undefined
11519
+ });
11520
+
11521
+ let response = await fetch(request);
11522
+
11523
+ const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
11524
+
11525
+ if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
11526
+ const options = {};
11527
+
11528
+ ['status', 'statusText', 'headers'].forEach(prop => {
11529
+ options[prop] = response[prop];
11530
+ });
11531
+
11532
+ const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
11533
+
11534
+ const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
11535
+ responseContentLength,
11536
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
11537
+ ) || [];
11538
+
11539
+ response = new Response(
11540
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
11541
+ flush && flush();
11542
+ unsubscribe && unsubscribe();
11543
+ }),
11544
+ options
11545
+ );
11546
+ }
11547
+
11548
+ responseType = responseType || 'text';
11549
+
11550
+ let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
11551
+
11552
+ !isStreamResponse && unsubscribe && unsubscribe();
11553
+
11554
+ return await new Promise((resolve, reject) => {
11555
+ settle(resolve, reject, {
11556
+ data: responseData,
11557
+ headers: AxiosHeaders.from(response.headers),
11558
+ status: response.status,
11559
+ statusText: response.statusText,
11560
+ config,
11561
+ request
11562
+ });
11563
+ })
11564
+ } catch (err) {
11565
+ unsubscribe && unsubscribe();
11566
+
11567
+ if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
11568
+ throw Object.assign(
11569
+ new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
11570
+ {
11571
+ cause: err.cause || err
11572
+ }
11573
+ )
11574
+ }
11575
+
11576
+ throw AxiosError.from(err, err && err.code, config, request);
11577
+ }
11578
+ });
11579
+
10994
11580
  const knownAdapters = {
10995
11581
  http: httpAdapter,
10996
- xhr: xhrAdapter
11582
+ xhr: xhrAdapter,
11583
+ fetch: fetchAdapter
10997
11584
  };
10998
11585
 
10999
11586
  utils$1.forEach(knownAdapters, (fn, value) => {
@@ -11137,109 +11724,7 @@ function dispatchRequest(config) {
11137
11724
  });
11138
11725
  }
11139
11726
 
11140
- const headersToObject = (thing) => thing instanceof AxiosHeaders ? thing.toJSON() : thing;
11141
-
11142
- /**
11143
- * Config-specific merge-function which creates a new config-object
11144
- * by merging two configuration objects together.
11145
- *
11146
- * @param {Object} config1
11147
- * @param {Object} config2
11148
- *
11149
- * @returns {Object} New object resulting from merging config2 to config1
11150
- */
11151
- function mergeConfig(config1, config2) {
11152
- // eslint-disable-next-line no-param-reassign
11153
- config2 = config2 || {};
11154
- const config = {};
11155
-
11156
- function getMergedValue(target, source, caseless) {
11157
- if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
11158
- return utils$1.merge.call({caseless}, target, source);
11159
- } else if (utils$1.isPlainObject(source)) {
11160
- return utils$1.merge({}, source);
11161
- } else if (utils$1.isArray(source)) {
11162
- return source.slice();
11163
- }
11164
- return source;
11165
- }
11166
-
11167
- // eslint-disable-next-line consistent-return
11168
- function mergeDeepProperties(a, b, caseless) {
11169
- if (!utils$1.isUndefined(b)) {
11170
- return getMergedValue(a, b, caseless);
11171
- } else if (!utils$1.isUndefined(a)) {
11172
- return getMergedValue(undefined, a, caseless);
11173
- }
11174
- }
11175
-
11176
- // eslint-disable-next-line consistent-return
11177
- function valueFromConfig2(a, b) {
11178
- if (!utils$1.isUndefined(b)) {
11179
- return getMergedValue(undefined, b);
11180
- }
11181
- }
11182
-
11183
- // eslint-disable-next-line consistent-return
11184
- function defaultToConfig2(a, b) {
11185
- if (!utils$1.isUndefined(b)) {
11186
- return getMergedValue(undefined, b);
11187
- } else if (!utils$1.isUndefined(a)) {
11188
- return getMergedValue(undefined, a);
11189
- }
11190
- }
11191
-
11192
- // eslint-disable-next-line consistent-return
11193
- function mergeDirectKeys(a, b, prop) {
11194
- if (prop in config2) {
11195
- return getMergedValue(a, b);
11196
- } else if (prop in config1) {
11197
- return getMergedValue(undefined, a);
11198
- }
11199
- }
11200
-
11201
- const mergeMap = {
11202
- url: valueFromConfig2,
11203
- method: valueFromConfig2,
11204
- data: valueFromConfig2,
11205
- baseURL: defaultToConfig2,
11206
- transformRequest: defaultToConfig2,
11207
- transformResponse: defaultToConfig2,
11208
- paramsSerializer: defaultToConfig2,
11209
- timeout: defaultToConfig2,
11210
- timeoutMessage: defaultToConfig2,
11211
- withCredentials: defaultToConfig2,
11212
- withXSRFToken: defaultToConfig2,
11213
- adapter: defaultToConfig2,
11214
- responseType: defaultToConfig2,
11215
- xsrfCookieName: defaultToConfig2,
11216
- xsrfHeaderName: defaultToConfig2,
11217
- onUploadProgress: defaultToConfig2,
11218
- onDownloadProgress: defaultToConfig2,
11219
- decompress: defaultToConfig2,
11220
- maxContentLength: defaultToConfig2,
11221
- maxBodyLength: defaultToConfig2,
11222
- beforeRedirect: defaultToConfig2,
11223
- transport: defaultToConfig2,
11224
- httpAgent: defaultToConfig2,
11225
- httpsAgent: defaultToConfig2,
11226
- cancelToken: defaultToConfig2,
11227
- socketPath: defaultToConfig2,
11228
- responseEncoding: defaultToConfig2,
11229
- validateStatus: mergeDirectKeys,
11230
- headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
11231
- };
11232
-
11233
- utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
11234
- const merge = mergeMap[prop] || mergeDeepProperties;
11235
- const configValue = merge(config1[prop], config2[prop], prop);
11236
- (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
11237
- });
11238
-
11239
- return config;
11240
- }
11241
-
11242
- const VERSION = "1.6.7";
11727
+ const VERSION = "1.7.7";
11243
11728
 
11244
11729
  const validators = {};
11245
11730
 
@@ -11365,12 +11850,15 @@ class Axios {
11365
11850
 
11366
11851
  // slice off the Error: ... line
11367
11852
  const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
11368
-
11369
- if (!err.stack) {
11370
- err.stack = stack;
11371
- // match without the 2 top stack lines
11372
- } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
11373
- err.stack += '\n' + stack;
11853
+ try {
11854
+ if (!err.stack) {
11855
+ err.stack = stack;
11856
+ // match without the 2 top stack lines
11857
+ } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
11858
+ err.stack += '\n' + stack;
11859
+ }
11860
+ } catch (e) {
11861
+ // ignore the case where "stack" is an un-writable property
11374
11862
  }
11375
11863
  }
11376
11864
 
@@ -11641,6 +12129,20 @@ class CancelToken {
11641
12129
  }
11642
12130
  }
11643
12131
 
12132
+ toAbortSignal() {
12133
+ const controller = new AbortController();
12134
+
12135
+ const abort = (err) => {
12136
+ controller.abort(err);
12137
+ };
12138
+
12139
+ this.subscribe(abort);
12140
+
12141
+ controller.signal.unsubscribe = () => this.unsubscribe(abort);
12142
+
12143
+ return controller.signal;
12144
+ }
12145
+
11644
12146
  /**
11645
12147
  * Returns an object that contains a new `CancelToken` and a function that, when called,
11646
12148
  * cancels the `CancelToken`.
@@ -12875,7 +13377,7 @@ var KimaProvider = function KimaProvider(_ref) {
12875
13377
  return React__default.createElement(reactRedux.Provider, {
12876
13378
  store: store
12877
13379
  }, React__default.createElement(ConnectionProvider, {
12878
- endpoint: SOLANA_HOST
13380
+ endpoint: networkOption === exports.NetworkOptions.mainnet ? SOLANA_HOST_MAINNET : SOLANA_HOST_DEVNET
12879
13381
  }, React__default.createElement(SolanaWalletProvider, {
12880
13382
  wallets: wallets
12881
13383
  }, React__default.createElement(tronwalletAdapterReactHooks.WalletProvider, {