@depay/widgets 12.10.9 → 12.10.10
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/umd/index.solana.js
CHANGED
|
@@ -28428,30 +28428,55 @@
|
|
|
28428
28428
|
this._rpcRequest = this._rpcRequestReplacement.bind(this);
|
|
28429
28429
|
}
|
|
28430
28430
|
|
|
28431
|
+
handleError(error, attempt, chunk) {
|
|
28432
|
+
if(attempt < MAX_RETRY && error && [
|
|
28433
|
+
'Failed to fetch', 'limit reached', '504', '503', '502', '500', '429', '426', '422', '413', '409', '408', '406', '405', '404', '403', '402', '401', '400'
|
|
28434
|
+
].some((errorType)=>error.toString().match(errorType))) {
|
|
28435
|
+
const index = this._endpoints.indexOf(this._endpoint)+1;
|
|
28436
|
+
this._endpoint = index >= this._endpoints.length ? this._endpoints[0] : this._endpoints[index];
|
|
28437
|
+
this._provider = new solanaWeb3_js.Connection(this._endpoint);
|
|
28438
|
+
this.requestChunk(chunk, attempt+1);
|
|
28439
|
+
} else {
|
|
28440
|
+
chunk.forEach((inflightRequest) => {
|
|
28441
|
+
inflightRequest.reject(error);
|
|
28442
|
+
});
|
|
28443
|
+
}
|
|
28444
|
+
}
|
|
28445
|
+
|
|
28446
|
+
batchRequest(requests, attempt) {
|
|
28447
|
+
return new Promise((resolve, reject) => {
|
|
28448
|
+
if (requests.length === 0) resolve([]); // Do nothing if requests is empty
|
|
28449
|
+
|
|
28450
|
+
const batch = requests.map(params => {
|
|
28451
|
+
return this._rpcClient.request(params.methodName, params.args)
|
|
28452
|
+
});
|
|
28453
|
+
|
|
28454
|
+
fetch(
|
|
28455
|
+
this._endpoint,
|
|
28456
|
+
{
|
|
28457
|
+
method: 'POST',
|
|
28458
|
+
body: JSON.stringify(batch),
|
|
28459
|
+
headers: { 'Content-Type': 'application/json' },
|
|
28460
|
+
}
|
|
28461
|
+
).then((response)=>{
|
|
28462
|
+
if(response.ok) {
|
|
28463
|
+
response.json().then((parsedJson)=>{
|
|
28464
|
+
resolve(parsedJson);
|
|
28465
|
+
}).catch(reject);
|
|
28466
|
+
} else {
|
|
28467
|
+
reject(`${response.status} ${response.text}`);
|
|
28468
|
+
}
|
|
28469
|
+
}).catch(reject);
|
|
28470
|
+
})
|
|
28471
|
+
}
|
|
28472
|
+
|
|
28431
28473
|
requestChunk(chunk, attempt) {
|
|
28432
28474
|
|
|
28433
28475
|
const batch = chunk.map((inflight) => inflight.request);
|
|
28434
28476
|
|
|
28435
|
-
const handleError = (error)=>{
|
|
28436
|
-
if(attempt < MAX_RETRY && error && [
|
|
28437
|
-
'Failed to fetch', 'limit reached', '504', '503', '502', '500', '429', '426', '422', '413', '409', '408', '406', '405', '404', '403', '402', '401', '400'
|
|
28438
|
-
].some((errorType)=>error.toString().match(errorType))) {
|
|
28439
|
-
const index = this._endpoints.indexOf(this._endpoint)+1;
|
|
28440
|
-
this._endpoint = index >= this._endpoints.length ? this._endpoints[0] : this._endpoints[index];
|
|
28441
|
-
this._provider = new solanaWeb3_js.Connection(this._endpoint);
|
|
28442
|
-
this.requestChunk(chunk, attempt+1);
|
|
28443
|
-
} else {
|
|
28444
|
-
chunk.forEach((inflightRequest) => {
|
|
28445
|
-
inflightRequest.reject(error);
|
|
28446
|
-
});
|
|
28447
|
-
}
|
|
28448
|
-
};
|
|
28449
|
-
|
|
28450
28477
|
try {
|
|
28451
|
-
return this.
|
|
28478
|
+
return this.batchRequest(batch, attempt)
|
|
28452
28479
|
.then((result) => {
|
|
28453
|
-
// For each result, feed it to the correct Promise, depending
|
|
28454
|
-
// on whether it was a success or error
|
|
28455
28480
|
chunk.forEach((inflightRequest, index) => {
|
|
28456
28481
|
const payload = result[index];
|
|
28457
28482
|
if (_optionalChain$2$2([payload, 'optionalAccess', _ => _.error])) {
|
|
@@ -28465,8 +28490,8 @@
|
|
|
28465
28490
|
inflightRequest.reject();
|
|
28466
28491
|
}
|
|
28467
28492
|
});
|
|
28468
|
-
}).catch(handleError)
|
|
28469
|
-
} catch (error){ return handleError(error) }
|
|
28493
|
+
}).catch((error)=>this.handleError(error, attempt, chunk))
|
|
28494
|
+
} catch (error){ return this.handleError(error, attempt, chunk) }
|
|
28470
28495
|
}
|
|
28471
28496
|
|
|
28472
28497
|
_rpcRequestReplacement(methodName, args) {
|