@lucid-evolution/provider 0.1.41 → 0.1.42
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 +49 -30
- package/dist/index.js +50 -31
- package/package.json +4 -4
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.
|
|
55
|
+
version: "0.1.42",
|
|
56
56
|
description: "",
|
|
57
57
|
main: "./dist/index.js",
|
|
58
58
|
types: "./dist/index.d.ts",
|
|
@@ -284,37 +284,49 @@ var Blockfrost = class {
|
|
|
284
284
|
return result;
|
|
285
285
|
}
|
|
286
286
|
async blockfrostUtxosToUtxos(result) {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
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
|
-
|
|
313
|
-
|
|
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
|
+
if (type.toLowerCase() === "native") {
|
|
313
|
+
throw new Error("Native script ref not implemented!");
|
|
314
|
+
}
|
|
315
|
+
const { cbor: script } = await fetch(
|
|
316
|
+
`${this.url}/scripts/${r.reference_script_hash}/cbor`,
|
|
317
|
+
{ headers: { project_id: this.projectId, lucid } }
|
|
318
|
+
).then((res) => res.json());
|
|
319
|
+
return {
|
|
320
|
+
type: type === "plutusV1" ? "PlutusV1" : "PlutusV2",
|
|
321
|
+
script: (0, import_utils.applyDoubleCborEncoding)(script)
|
|
322
|
+
};
|
|
323
|
+
})() : void 0
|
|
314
324
|
};
|
|
315
|
-
})
|
|
316
|
-
|
|
317
|
-
|
|
325
|
+
})
|
|
326
|
+
);
|
|
327
|
+
utxos.push(...batchResults);
|
|
328
|
+
}
|
|
329
|
+
return utxos;
|
|
318
330
|
}
|
|
319
331
|
async evaluateTx(tx, additionalUTxOs) {
|
|
320
332
|
const additionalUTxOSet = (additionalUTxOs || []).map((utxo) => [
|
|
@@ -403,6 +415,13 @@ function datumJsonToCbor(json) {
|
|
|
403
415
|
};
|
|
404
416
|
return convert(json).to_cbor_hex();
|
|
405
417
|
}
|
|
418
|
+
var handleRateLimit = async (count) => {
|
|
419
|
+
if (count % 100 === 0) {
|
|
420
|
+
await (0, import_core_utils.sleep)(2e3);
|
|
421
|
+
} else if (count % 10 === 0) {
|
|
422
|
+
await (0, import_core_utils.sleep)(200);
|
|
423
|
+
}
|
|
424
|
+
};
|
|
406
425
|
var lucid = package_default.version;
|
|
407
426
|
|
|
408
427
|
// 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.
|
|
17
|
+
version: "0.1.42",
|
|
18
18
|
description: "",
|
|
19
19
|
main: "./dist/index.js",
|
|
20
20
|
types: "./dist/index.d.ts",
|
|
@@ -246,37 +246,49 @@ var Blockfrost = class {
|
|
|
246
246
|
return result;
|
|
247
247
|
}
|
|
248
248
|
async blockfrostUtxosToUtxos(result) {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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
|
-
|
|
275
|
-
|
|
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
|
+
if (type.toLowerCase() === "native") {
|
|
275
|
+
throw new Error("Native script ref not implemented!");
|
|
276
|
+
}
|
|
277
|
+
const { cbor: script } = await fetch(
|
|
278
|
+
`${this.url}/scripts/${r.reference_script_hash}/cbor`,
|
|
279
|
+
{ headers: { project_id: this.projectId, lucid } }
|
|
280
|
+
).then((res) => res.json());
|
|
281
|
+
return {
|
|
282
|
+
type: type === "plutusV1" ? "PlutusV1" : "PlutusV2",
|
|
283
|
+
script: applyDoubleCborEncoding(script)
|
|
284
|
+
};
|
|
285
|
+
})() : void 0
|
|
276
286
|
};
|
|
277
|
-
})
|
|
278
|
-
|
|
279
|
-
|
|
287
|
+
})
|
|
288
|
+
);
|
|
289
|
+
utxos.push(...batchResults);
|
|
290
|
+
}
|
|
291
|
+
return utxos;
|
|
280
292
|
}
|
|
281
293
|
async evaluateTx(tx, additionalUTxOs) {
|
|
282
294
|
const additionalUTxOSet = (additionalUTxOs || []).map((utxo) => [
|
|
@@ -365,6 +377,13 @@ function datumJsonToCbor(json) {
|
|
|
365
377
|
};
|
|
366
378
|
return convert(json).to_cbor_hex();
|
|
367
379
|
}
|
|
380
|
+
var handleRateLimit = async (count) => {
|
|
381
|
+
if (count % 100 === 0) {
|
|
382
|
+
await sleep(2e3);
|
|
383
|
+
} else if (count % 10 === 0) {
|
|
384
|
+
await sleep(200);
|
|
385
|
+
}
|
|
386
|
+
};
|
|
368
387
|
var lucid = package_default.version;
|
|
369
388
|
|
|
370
389
|
// src/kupmios/kupmios.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lucid-evolution/provider",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.42",
|
|
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.
|
|
35
|
-
"@lucid-evolution/utils": "0.1.
|
|
36
|
-
"@lucid-evolution/wallet": "0.1.
|
|
34
|
+
"@lucid-evolution/core-utils": "0.1.13",
|
|
35
|
+
"@lucid-evolution/utils": "0.1.33",
|
|
36
|
+
"@lucid-evolution/wallet": "0.1.37"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^20.12.8",
|