@depay/widgets 12.12.1 → 12.12.3

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.
@@ -28333,10 +28333,10 @@ const getConfiguration$1 = () =>{
28333
28333
  return getWindow$1()._Web3ClientConfiguration
28334
28334
  };
28335
28335
 
28336
- function _optionalChain$3$3(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
28336
+ function _optionalChain$5$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
28337
28337
  const BATCH_INTERVAL$1$1 = 10;
28338
28338
  const CHUNK_SIZE$1$1 = 99;
28339
- const MAX_RETRY$1$1 = 3;
28339
+ const MAX_RETRY$1$1 = 5;
28340
28340
 
28341
28341
  class StaticJsonRpcBatchProvider$1 extends ethers.providers.JsonRpcProvider {
28342
28342
 
@@ -28364,12 +28364,12 @@ class StaticJsonRpcBatchProvider$1 extends ethers.providers.JsonRpcProvider {
28364
28364
  // on whether it was a success or error
28365
28365
  chunk.forEach((inflightRequest, index) => {
28366
28366
  const payload = result[index];
28367
- if (_optionalChain$3$3([payload, 'optionalAccess', _ => _.error])) {
28367
+ if (_optionalChain$5$1([payload, 'optionalAccess', _ => _.error])) {
28368
28368
  const error = new Error(payload.error.message);
28369
28369
  error.code = payload.error.code;
28370
28370
  error.data = payload.error.data;
28371
28371
  inflightRequest.reject(error);
28372
- } else if(_optionalChain$3$3([payload, 'optionalAccess', _2 => _2.result])) {
28372
+ } else if(_optionalChain$5$1([payload, 'optionalAccess', _2 => _2.result])) {
28373
28373
  inflightRequest.resolve(payload.result);
28374
28374
  } else {
28375
28375
  inflightRequest.reject();
@@ -28444,6 +28444,7 @@ class StaticJsonRpcBatchProvider$1 extends ethers.providers.JsonRpcProvider {
28444
28444
 
28445
28445
  }
28446
28446
 
28447
+ function _optionalChain$4$2(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
28447
28448
  const getAllProviders$1 = ()=> {
28448
28449
  if(getWindow$1()._Web3ClientProviders == undefined) {
28449
28450
  getWindow$1()._Web3ClientProviders = {};
@@ -28489,17 +28490,20 @@ const setProviderEndpoints$2 = async (blockchain, endpoints, detectFastest = tru
28489
28490
  let timeout = 900;
28490
28491
  let before = new Date().getTime();
28491
28492
  setTimeout(()=>resolve(timeout), timeout);
28492
- const response = await fetch(endpoint, {
28493
- method: 'POST',
28494
- headers: {
28495
- 'Accept': 'application/json',
28496
- 'Content-Type': 'application/json'
28497
- },
28498
- referrer: "",
28499
- referrerPolicy: "no-referrer",
28500
- body: JSON.stringify({ method: 'net_version', id: 1, jsonrpc: '2.0' })
28501
- });
28502
- if(!response.ok) { return resolve(999) }
28493
+ let response;
28494
+ try {
28495
+ response = await fetch(endpoint, {
28496
+ method: 'POST',
28497
+ headers: {
28498
+ 'Accept': 'application/json',
28499
+ 'Content-Type': 'application/json'
28500
+ },
28501
+ referrer: "",
28502
+ referrerPolicy: "no-referrer",
28503
+ body: JSON.stringify({ method: 'net_version', id: 1, jsonrpc: '2.0' })
28504
+ });
28505
+ } catch (e) {}
28506
+ if(!_optionalChain$4$2([response, 'optionalAccess', _ => _.ok])) { return resolve(999) }
28503
28507
  let after = new Date().getTime();
28504
28508
  resolve(after-before);
28505
28509
  })
@@ -28554,10 +28558,10 @@ var EVM = {
28554
28558
  setProvider: setProvider$2,
28555
28559
  };
28556
28560
 
28557
- function _optionalChain$2$2(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
28561
+ function _optionalChain$3$3(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
28558
28562
  const BATCH_INTERVAL = 10;
28559
28563
  const CHUNK_SIZE = 99;
28560
- const MAX_RETRY = 3;
28564
+ const MAX_RETRY = 10;
28561
28565
 
28562
28566
  class StaticJsonRpcSequentialProvider extends Connection {
28563
28567
 
@@ -28573,9 +28577,7 @@ class StaticJsonRpcSequentialProvider extends Connection {
28573
28577
  }
28574
28578
 
28575
28579
  handleError(error, attempt, chunk) {
28576
- if(attempt < MAX_RETRY && error && [
28577
- 'Failed to fetch', 'limit reached', '504', '503', '502', '500', '429', '426', '422', '413', '409', '408', '406', '405', '404', '403', '402', '401', '400'
28578
- ].some((errorType)=>error.toString().match(errorType))) {
28580
+ if(attempt < MAX_RETRY) {
28579
28581
  const index = this._endpoints.indexOf(this._endpoint)+1;
28580
28582
  this._endpoint = index >= this._endpoints.length ? this._endpoints[0] : this._endpoints[index];
28581
28583
  this._provider = new Connection(this._endpoint);
@@ -28605,7 +28607,15 @@ class StaticJsonRpcSequentialProvider extends Connection {
28605
28607
  ).then((response)=>{
28606
28608
  if(response.ok) {
28607
28609
  response.json().then((parsedJson)=>{
28608
- resolve(parsedJson);
28610
+ if(parsedJson.find((entry)=>_optionalChain$3$3([entry, 'optionalAccess', _ => _.error]))) {
28611
+ if(attempt < MAX_RETRY) {
28612
+ reject('Error in batch found!');
28613
+ } else {
28614
+ resolve(parsedJson);
28615
+ }
28616
+ } else {
28617
+ resolve(parsedJson);
28618
+ }
28609
28619
  }).catch(reject);
28610
28620
  } else {
28611
28621
  reject(`${response.status} ${response.text}`);
@@ -28623,7 +28633,7 @@ class StaticJsonRpcSequentialProvider extends Connection {
28623
28633
  .then((result) => {
28624
28634
  chunk.forEach((inflightRequest, index) => {
28625
28635
  const payload = result[index];
28626
- if (_optionalChain$2$2([payload, 'optionalAccess', _ => _.error])) {
28636
+ if (_optionalChain$3$3([payload, 'optionalAccess', _2 => _2.error])) {
28627
28637
  const error = new Error(payload.error.message);
28628
28638
  error.code = payload.error.code;
28629
28639
  error.data = payload.error.data;
@@ -28680,6 +28690,7 @@ class StaticJsonRpcSequentialProvider extends Connection {
28680
28690
  }
28681
28691
  }
28682
28692
 
28693
+ function _optionalChain$2$2(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
28683
28694
  const getAllProviders = ()=> {
28684
28695
  if(getWindow$1()._Web3ClientProviders == undefined) {
28685
28696
  getWindow$1()._Web3ClientProviders = {};
@@ -28725,17 +28736,20 @@ const setProviderEndpoints$1 = async (blockchain, endpoints, detectFastest = tru
28725
28736
  let timeout = 900;
28726
28737
  let before = new Date().getTime();
28727
28738
  setTimeout(()=>resolve(timeout), timeout);
28728
- const response = await fetch(endpoint, {
28729
- method: 'POST',
28730
- headers: {
28731
- 'Accept': 'application/json',
28732
- 'Content-Type': 'application/json'
28733
- },
28734
- referrer: "",
28735
- referrerPolicy: "no-referrer",
28736
- body: JSON.stringify({ method: 'getIdentity', id: 1, jsonrpc: '2.0' })
28737
- });
28738
- if(!response.ok) { return resolve(999) }
28739
+ let response;
28740
+ try {
28741
+ response = await fetch(endpoint, {
28742
+ method: 'POST',
28743
+ headers: {
28744
+ 'Accept': 'application/json',
28745
+ 'Content-Type': 'application/json'
28746
+ },
28747
+ referrer: "",
28748
+ referrerPolicy: "no-referrer",
28749
+ body: JSON.stringify({ method: 'getIdentity', id: 1, jsonrpc: '2.0' })
28750
+ });
28751
+ } catch (e) {}
28752
+ if(!_optionalChain$2$2([response, 'optionalAccess', _ => _.ok])) { return resolve(999) }
28739
28753
  let after = new Date().getTime();
28740
28754
  resolve(after-before);
28741
28755
  })
@@ -32335,6 +32349,10 @@ const getPrice = async ({
32335
32349
  amountSpecifiedIsInput,
32336
32350
  });
32337
32351
 
32352
+ if(amountCalculated.toString() == "0"){
32353
+ throw('amountCalculated cant be zero!')
32354
+ }
32355
+
32338
32356
  return {
32339
32357
  price: amountCalculated.toString(),
32340
32358
  tickArrays,