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.browser.mjs
CHANGED
|
@@ -52646,23 +52646,58 @@ var ElectrumApiProvider = class {
|
|
|
52646
52646
|
);
|
|
52647
52647
|
}
|
|
52648
52648
|
}
|
|
52649
|
+
/*
|
|
52650
|
+
async esplora_getbulktransactions(
|
|
52651
|
+
transactionIds: string[],
|
|
52652
|
+
): Promise<BoxedResponse<IEsploraTransaction[], EsploraFetchError>> {
|
|
52653
|
+
try {
|
|
52654
|
+
const requestUrl = `${this.electrumApiUrl}/txs`;
|
|
52655
|
+
|
|
52656
|
+
const httpResponse = await fetch(requestUrl, {
|
|
52657
|
+
method: "POST",
|
|
52658
|
+
headers: { "Content-Type": "application/json" },
|
|
52659
|
+
body: JSON.stringify({ txs: transactionIds }),
|
|
52660
|
+
});
|
|
52661
|
+
|
|
52662
|
+
if (!httpResponse.ok) {
|
|
52663
|
+
return new BoxedError(
|
|
52664
|
+
EsploraFetchError.UnknownError,
|
|
52665
|
+
`Failed to fetch transactions from ${requestUrl}: ${httpResponse.statusText}`,
|
|
52666
|
+
);
|
|
52667
|
+
}
|
|
52668
|
+
|
|
52669
|
+
const transactions = (await httpResponse.json()) as IEsploraTransaction[];
|
|
52670
|
+
return new BoxedSuccess(transactions);
|
|
52671
|
+
|
|
52672
|
+
|
|
52673
|
+
const txs = await Promise.all(
|
|
52674
|
+
transactionIds.map((txid) => this.esplora_gettransaction(txid)),
|
|
52675
|
+
);
|
|
52676
|
+
|
|
52677
|
+
} catch (error) {
|
|
52678
|
+
return new BoxedError(
|
|
52679
|
+
EsploraFetchError.UnknownError,
|
|
52680
|
+
`Failed to fetch bulk transactions: ${(error as Error).message}`,
|
|
52681
|
+
);
|
|
52682
|
+
}
|
|
52683
|
+
}
|
|
52684
|
+
*/
|
|
52649
52685
|
async esplora_getbulktransactions(transactionIds) {
|
|
52650
52686
|
try {
|
|
52651
|
-
const
|
|
52652
|
-
|
|
52653
|
-
|
|
52654
|
-
|
|
52655
|
-
|
|
52656
|
-
});
|
|
52657
|
-
if (!httpResponse.ok) {
|
|
52658
|
-
return new BoxedError(
|
|
52659
|
-
"UnknownError" /* UnknownError */,
|
|
52660
|
-
`Failed to fetch transactions from ${requestUrl}: ${httpResponse.statusText}`
|
|
52687
|
+
const allTxs = [];
|
|
52688
|
+
for (let i = 0; i < transactionIds.length; i += 10) {
|
|
52689
|
+
const batch = transactionIds.slice(i, i + 10);
|
|
52690
|
+
const batchResponses = await Promise.all(
|
|
52691
|
+
batch.map((txid) => this.esplora_gettransaction(txid))
|
|
52661
52692
|
);
|
|
52693
|
+
const batchTxs = consumeAll(batchResponses);
|
|
52694
|
+
allTxs.push(...batchTxs);
|
|
52662
52695
|
}
|
|
52663
|
-
|
|
52664
|
-
return new BoxedSuccess(transactions);
|
|
52696
|
+
return new BoxedSuccess(allTxs);
|
|
52665
52697
|
} catch (error) {
|
|
52698
|
+
if (error instanceof BoxedError) {
|
|
52699
|
+
return error;
|
|
52700
|
+
}
|
|
52666
52701
|
return new BoxedError(
|
|
52667
52702
|
"UnknownError" /* UnknownError */,
|
|
52668
52703
|
`Failed to fetch bulk transactions: ${error.message}`
|