alkanesjs 1.1.7 → 1.1.8
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.browser.mjs +47 -12
- package/dist/index.browser.mjs.map +2 -2
- package/dist/index.js +47 -12
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -42485,23 +42485,58 @@ var ElectrumApiProvider = class {
|
|
|
42485
42485
|
);
|
|
42486
42486
|
}
|
|
42487
42487
|
}
|
|
42488
|
+
/*
|
|
42489
|
+
async esplora_getbulktransactions(
|
|
42490
|
+
transactionIds: string[],
|
|
42491
|
+
): Promise<BoxedResponse<IEsploraTransaction[], EsploraFetchError>> {
|
|
42492
|
+
try {
|
|
42493
|
+
const requestUrl = `${this.electrumApiUrl}/txs`;
|
|
42494
|
+
|
|
42495
|
+
const httpResponse = await fetch(requestUrl, {
|
|
42496
|
+
method: "POST",
|
|
42497
|
+
headers: { "Content-Type": "application/json" },
|
|
42498
|
+
body: JSON.stringify({ txs: transactionIds }),
|
|
42499
|
+
});
|
|
42500
|
+
|
|
42501
|
+
if (!httpResponse.ok) {
|
|
42502
|
+
return new BoxedError(
|
|
42503
|
+
EsploraFetchError.UnknownError,
|
|
42504
|
+
`Failed to fetch transactions from ${requestUrl}: ${httpResponse.statusText}`,
|
|
42505
|
+
);
|
|
42506
|
+
}
|
|
42507
|
+
|
|
42508
|
+
const transactions = (await httpResponse.json()) as IEsploraTransaction[];
|
|
42509
|
+
return new BoxedSuccess(transactions);
|
|
42510
|
+
|
|
42511
|
+
|
|
42512
|
+
const txs = await Promise.all(
|
|
42513
|
+
transactionIds.map((txid) => this.esplora_gettransaction(txid)),
|
|
42514
|
+
);
|
|
42515
|
+
|
|
42516
|
+
} catch (error) {
|
|
42517
|
+
return new BoxedError(
|
|
42518
|
+
EsploraFetchError.UnknownError,
|
|
42519
|
+
`Failed to fetch bulk transactions: ${(error as Error).message}`,
|
|
42520
|
+
);
|
|
42521
|
+
}
|
|
42522
|
+
}
|
|
42523
|
+
*/
|
|
42488
42524
|
async esplora_getbulktransactions(transactionIds) {
|
|
42489
42525
|
try {
|
|
42490
|
-
const
|
|
42491
|
-
|
|
42492
|
-
|
|
42493
|
-
|
|
42494
|
-
|
|
42495
|
-
});
|
|
42496
|
-
if (!httpResponse.ok) {
|
|
42497
|
-
return new BoxedError(
|
|
42498
|
-
"UnknownError" /* UnknownError */,
|
|
42499
|
-
`Failed to fetch transactions from ${requestUrl}: ${httpResponse.statusText}`
|
|
42526
|
+
const allTxs = [];
|
|
42527
|
+
for (let i = 0; i < transactionIds.length; i += 10) {
|
|
42528
|
+
const batch = transactionIds.slice(i, i + 10);
|
|
42529
|
+
const batchResponses = await Promise.all(
|
|
42530
|
+
batch.map((txid) => this.esplora_gettransaction(txid))
|
|
42500
42531
|
);
|
|
42532
|
+
const batchTxs = consumeAll(batchResponses);
|
|
42533
|
+
allTxs.push(...batchTxs);
|
|
42501
42534
|
}
|
|
42502
|
-
|
|
42503
|
-
return new BoxedSuccess(transactions);
|
|
42535
|
+
return new BoxedSuccess(allTxs);
|
|
42504
42536
|
} catch (error) {
|
|
42537
|
+
if (error instanceof BoxedError) {
|
|
42538
|
+
return error;
|
|
42539
|
+
}
|
|
42505
42540
|
return new BoxedError(
|
|
42506
42541
|
"UnknownError" /* UnknownError */,
|
|
42507
42542
|
`Failed to fetch bulk transactions: ${error.message}`
|