@lucid-evolution/provider 0.1.41 → 0.1.43

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.cjs CHANGED
@@ -52,7 +52,7 @@ var import_utils = require("@lucid-evolution/utils");
52
52
  // package.json
53
53
  var package_default = {
54
54
  name: "@lucid-evolution/provider",
55
- version: "0.1.41",
55
+ version: "0.1.43",
56
56
  description: "",
57
57
  main: "./dist/index.js",
58
58
  types: "./dist/index.d.ts",
@@ -284,37 +284,56 @@ var Blockfrost = class {
284
284
  return result;
285
285
  }
286
286
  async blockfrostUtxosToUtxos(result) {
287
- return await Promise.all(
288
- result.map(async (r) => ({
289
- txHash: r.tx_hash,
290
- outputIndex: r.output_index,
291
- assets: Object.fromEntries(
292
- r.amount.map(({ unit, quantity }) => [unit, BigInt(quantity)])
293
- ),
294
- address: r.address,
295
- datumHash: !r.inline_datum && r.data_hash || void 0,
296
- datum: r.inline_datum || void 0,
297
- scriptRef: r.reference_script_hash ? await (async () => {
298
- const { type } = await fetch(
299
- `${this.url}/scripts/${r.reference_script_hash}`,
300
- {
301
- headers: { project_id: this.projectId, lucid }
302
- }
303
- ).then((res) => res.json());
304
- if (type === "Native" || type === "native") {
305
- throw new Error("Native script ref not implemented!");
306
- }
307
- const { cbor: script } = await fetch(
308
- `${this.url}/scripts/${r.reference_script_hash}/cbor`,
309
- { headers: { project_id: this.projectId, lucid } }
310
- ).then((res) => res.json());
287
+ const utxos = [];
288
+ const batchSize = 10;
289
+ let count = 0;
290
+ for (let i = 0; i < result.length; i += batchSize) {
291
+ const batch = result.slice(i, i + batchSize);
292
+ count += batchSize;
293
+ await handleRateLimit(count);
294
+ const batchResults = await Promise.all(
295
+ batch.map(async (r) => {
311
296
  return {
312
- type: type === "plutusV1" ? "PlutusV1" : "PlutusV2",
313
- script: (0, import_utils.applyDoubleCborEncoding)(script)
297
+ txHash: r.tx_hash,
298
+ outputIndex: r.output_index,
299
+ assets: Object.fromEntries(
300
+ r.amount.map(({ unit, quantity }) => [unit, BigInt(quantity)])
301
+ ),
302
+ address: r.address,
303
+ datumHash: !r.inline_datum && r.data_hash || void 0,
304
+ datum: r.inline_datum || void 0,
305
+ scriptRef: r.reference_script_hash ? await (async () => {
306
+ const { type } = await fetch(
307
+ `${this.url}/scripts/${r.reference_script_hash}`,
308
+ {
309
+ headers: { project_id: this.projectId, lucid }
310
+ }
311
+ ).then((res) => res.json());
312
+ const { cbor: script } = await fetch(
313
+ `${this.url}/scripts/${r.reference_script_hash}/cbor`,
314
+ { headers: { project_id: this.projectId, lucid } }
315
+ ).then((res) => res.json());
316
+ switch (type) {
317
+ case "timelock":
318
+ return void 0;
319
+ case "plutusV1":
320
+ return {
321
+ type: "PlutusV1",
322
+ script: (0, import_utils.applyDoubleCborEncoding)(script)
323
+ };
324
+ case "plutusV2":
325
+ return {
326
+ type: "PlutusV2",
327
+ script: (0, import_utils.applyDoubleCborEncoding)(script)
328
+ };
329
+ }
330
+ })() : void 0
314
331
  };
315
- })() : void 0
316
- }))
317
- );
332
+ })
333
+ );
334
+ utxos.push(...batchResults);
335
+ }
336
+ return utxos;
318
337
  }
319
338
  async evaluateTx(tx, additionalUTxOs) {
320
339
  const additionalUTxOSet = (additionalUTxOs || []).map((utxo) => [
@@ -403,6 +422,13 @@ function datumJsonToCbor(json) {
403
422
  };
404
423
  return convert(json).to_cbor_hex();
405
424
  }
425
+ var handleRateLimit = async (count) => {
426
+ if (count % 100 === 0) {
427
+ await (0, import_core_utils.sleep)(1e3);
428
+ } else if (count % 10 === 0) {
429
+ await (0, import_core_utils.sleep)(100);
430
+ }
431
+ };
406
432
  var lucid = package_default.version;
407
433
 
408
434
  // src/kupmios/kupmios.ts
package/dist/index.js CHANGED
@@ -8,13 +8,13 @@ var __export = (target, all) => {
8
8
  import * as CML from "@anastasia-labs/cardano-multiplatform-lib-nodejs";
9
9
 
10
10
  // src/blockfrost.ts
11
- import { fromHex } from "@lucid-evolution/core-utils";
11
+ import { fromHex, sleep } from "@lucid-evolution/core-utils";
12
12
  import { applyDoubleCborEncoding } from "@lucid-evolution/utils";
13
13
 
14
14
  // package.json
15
15
  var package_default = {
16
16
  name: "@lucid-evolution/provider",
17
- version: "0.1.41",
17
+ version: "0.1.43",
18
18
  description: "",
19
19
  main: "./dist/index.js",
20
20
  types: "./dist/index.d.ts",
@@ -246,37 +246,56 @@ var Blockfrost = class {
246
246
  return result;
247
247
  }
248
248
  async blockfrostUtxosToUtxos(result) {
249
- return await Promise.all(
250
- result.map(async (r) => ({
251
- txHash: r.tx_hash,
252
- outputIndex: r.output_index,
253
- assets: Object.fromEntries(
254
- r.amount.map(({ unit, quantity }) => [unit, BigInt(quantity)])
255
- ),
256
- address: r.address,
257
- datumHash: !r.inline_datum && r.data_hash || void 0,
258
- datum: r.inline_datum || void 0,
259
- scriptRef: r.reference_script_hash ? await (async () => {
260
- const { type } = await fetch(
261
- `${this.url}/scripts/${r.reference_script_hash}`,
262
- {
263
- headers: { project_id: this.projectId, lucid }
264
- }
265
- ).then((res) => res.json());
266
- if (type === "Native" || type === "native") {
267
- throw new Error("Native script ref not implemented!");
268
- }
269
- const { cbor: script } = await fetch(
270
- `${this.url}/scripts/${r.reference_script_hash}/cbor`,
271
- { headers: { project_id: this.projectId, lucid } }
272
- ).then((res) => res.json());
249
+ const utxos = [];
250
+ const batchSize = 10;
251
+ let count = 0;
252
+ for (let i = 0; i < result.length; i += batchSize) {
253
+ const batch = result.slice(i, i + batchSize);
254
+ count += batchSize;
255
+ await handleRateLimit(count);
256
+ const batchResults = await Promise.all(
257
+ batch.map(async (r) => {
273
258
  return {
274
- type: type === "plutusV1" ? "PlutusV1" : "PlutusV2",
275
- script: applyDoubleCborEncoding(script)
259
+ txHash: r.tx_hash,
260
+ outputIndex: r.output_index,
261
+ assets: Object.fromEntries(
262
+ r.amount.map(({ unit, quantity }) => [unit, BigInt(quantity)])
263
+ ),
264
+ address: r.address,
265
+ datumHash: !r.inline_datum && r.data_hash || void 0,
266
+ datum: r.inline_datum || void 0,
267
+ scriptRef: r.reference_script_hash ? await (async () => {
268
+ const { type } = await fetch(
269
+ `${this.url}/scripts/${r.reference_script_hash}`,
270
+ {
271
+ headers: { project_id: this.projectId, lucid }
272
+ }
273
+ ).then((res) => res.json());
274
+ const { cbor: script } = await fetch(
275
+ `${this.url}/scripts/${r.reference_script_hash}/cbor`,
276
+ { headers: { project_id: this.projectId, lucid } }
277
+ ).then((res) => res.json());
278
+ switch (type) {
279
+ case "timelock":
280
+ return void 0;
281
+ case "plutusV1":
282
+ return {
283
+ type: "PlutusV1",
284
+ script: applyDoubleCborEncoding(script)
285
+ };
286
+ case "plutusV2":
287
+ return {
288
+ type: "PlutusV2",
289
+ script: applyDoubleCborEncoding(script)
290
+ };
291
+ }
292
+ })() : void 0
276
293
  };
277
- })() : void 0
278
- }))
279
- );
294
+ })
295
+ );
296
+ utxos.push(...batchResults);
297
+ }
298
+ return utxos;
280
299
  }
281
300
  async evaluateTx(tx, additionalUTxOs) {
282
301
  const additionalUTxOSet = (additionalUTxOs || []).map((utxo) => [
@@ -365,6 +384,13 @@ function datumJsonToCbor(json) {
365
384
  };
366
385
  return convert(json).to_cbor_hex();
367
386
  }
387
+ var handleRateLimit = async (count) => {
388
+ if (count % 100 === 0) {
389
+ await sleep(1e3);
390
+ } else if (count % 10 === 0) {
391
+ await sleep(100);
392
+ }
393
+ };
368
394
  var lucid = package_default.version;
369
395
 
370
396
  // src/kupmios/kupmios.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucid-evolution/provider",
3
- "version": "0.1.41",
3
+ "version": "0.1.43",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -31,9 +31,9 @@
31
31
  "@effect/schema": "^0.68.26",
32
32
  "effect": "^3.5.6",
33
33
  "@lucid-evolution/core-types": "0.1.13",
34
- "@lucid-evolution/core-utils": "0.1.12",
35
- "@lucid-evolution/utils": "0.1.32",
36
- "@lucid-evolution/wallet": "0.1.36"
34
+ "@lucid-evolution/core-utils": "0.1.13",
35
+ "@lucid-evolution/utils": "0.1.34",
36
+ "@lucid-evolution/wallet": "0.1.38"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/node": "^20.12.8",