@lucid-evolution/provider 0.1.43 → 0.1.45
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 +418 -205
- package/dist/index.js +344 -131
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -7,14 +7,14 @@ var __export = (target, all) => {
|
|
|
7
7
|
// src/core.ts
|
|
8
8
|
import * as CML from "@anastasia-labs/cardano-multiplatform-lib-nodejs";
|
|
9
9
|
|
|
10
|
-
// src/blockfrost.ts
|
|
10
|
+
// src/blockfrost/blockfrost.ts
|
|
11
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.45",
|
|
18
18
|
description: "",
|
|
19
19
|
main: "./dist/index.js",
|
|
20
20
|
types: "./dist/index.d.ts",
|
|
@@ -62,7 +62,8 @@ var package_default = {
|
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
// src/blockfrost.ts
|
|
65
|
+
// src/blockfrost/blockfrost.ts
|
|
66
|
+
import { pipe, Record } from "effect";
|
|
66
67
|
var Blockfrost = class {
|
|
67
68
|
url;
|
|
68
69
|
projectId;
|
|
@@ -288,6 +289,11 @@ var Blockfrost = class {
|
|
|
288
289
|
type: "PlutusV2",
|
|
289
290
|
script: applyDoubleCborEncoding(script)
|
|
290
291
|
};
|
|
292
|
+
case "plutusV3":
|
|
293
|
+
return {
|
|
294
|
+
type: "PlutusV3",
|
|
295
|
+
script: applyDoubleCborEncoding(script)
|
|
296
|
+
};
|
|
291
297
|
}
|
|
292
298
|
})() : void 0
|
|
293
299
|
};
|
|
@@ -298,19 +304,9 @@ var Blockfrost = class {
|
|
|
298
304
|
return utxos;
|
|
299
305
|
}
|
|
300
306
|
async evaluateTx(tx, additionalUTxOs) {
|
|
301
|
-
const additionalUTxOSet = (additionalUTxOs || []).map((utxo) => [
|
|
302
|
-
{ txId: utxo.txHash, index: utxo.outputIndex },
|
|
303
|
-
{
|
|
304
|
-
address: utxo.address,
|
|
305
|
-
value: { coins: utxo.assets.lovelace, assets: utxo.assets.restAssets },
|
|
306
|
-
datum_hash: utxo.datumHash,
|
|
307
|
-
datum: utxo.datum,
|
|
308
|
-
script: utxo.scriptRef
|
|
309
|
-
}
|
|
310
|
-
]);
|
|
311
307
|
const payload = {
|
|
312
308
|
cbor: tx,
|
|
313
|
-
|
|
309
|
+
additionalUtxoSet: toAditionalUTXOs(additionalUTxOs)
|
|
314
310
|
};
|
|
315
311
|
const res = await fetch(`${this.url}/utils/txs/evaluate/utxos`, {
|
|
316
312
|
method: "POST",
|
|
@@ -319,10 +315,7 @@ var Blockfrost = class {
|
|
|
319
315
|
project_id: this.projectId,
|
|
320
316
|
lucid
|
|
321
317
|
},
|
|
322
|
-
body: JSON.stringify(
|
|
323
|
-
payload,
|
|
324
|
-
(_, value) => typeof value === "bigint" ? value.toString() : value
|
|
325
|
-
)
|
|
318
|
+
body: JSON.stringify(payload)
|
|
326
319
|
}).then((res2) => res2.json());
|
|
327
320
|
if (!res || res.error) {
|
|
328
321
|
const message = res?.status_code === 400 ? res.message : `Could not evaluate the transaction: ${JSON.stringify(res)}`;
|
|
@@ -386,17 +379,55 @@ function datumJsonToCbor(json) {
|
|
|
386
379
|
}
|
|
387
380
|
var handleRateLimit = async (count) => {
|
|
388
381
|
if (count % 100 === 0) {
|
|
389
|
-
await sleep(
|
|
382
|
+
await sleep(5e3);
|
|
390
383
|
} else if (count % 10 === 0) {
|
|
391
|
-
await sleep(
|
|
384
|
+
await sleep(500);
|
|
392
385
|
}
|
|
393
386
|
};
|
|
394
387
|
var lucid = package_default.version;
|
|
388
|
+
var toAditionalUTXOs = (utxos) => (utxos || []).map((utxo) => [
|
|
389
|
+
{
|
|
390
|
+
txId: utxo.txHash,
|
|
391
|
+
index: utxo.outputIndex
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
address: utxo.address,
|
|
395
|
+
value: {
|
|
396
|
+
coins: Number(utxo.assets["lovelace"]),
|
|
397
|
+
assets: fromAssets(utxo.assets)
|
|
398
|
+
},
|
|
399
|
+
datumHash: utxo.datumHash,
|
|
400
|
+
datum: utxo.datum,
|
|
401
|
+
script: toTxOutScript(utxo.scriptRef)
|
|
402
|
+
}
|
|
403
|
+
]);
|
|
404
|
+
var toTxOutScript = (scriptRef) => {
|
|
405
|
+
if (scriptRef) {
|
|
406
|
+
switch (scriptRef.type) {
|
|
407
|
+
case "PlutusV1":
|
|
408
|
+
return { "plutus:v1": scriptRef.script };
|
|
409
|
+
case "PlutusV2":
|
|
410
|
+
return { "plutus:v2": scriptRef.script };
|
|
411
|
+
case "PlutusV3":
|
|
412
|
+
return { "plutus:v3": scriptRef.script };
|
|
413
|
+
default:
|
|
414
|
+
return void 0;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
var fromAssets = (assets) => pipe(
|
|
419
|
+
Record.remove(assets, "lovelace"),
|
|
420
|
+
Record.mapEntries((amount, unit) => [
|
|
421
|
+
unit.length === 56 ? unit.slice(0, 56) : unit.slice(0, 56) + "." + unit.slice(56),
|
|
422
|
+
Number(amount)
|
|
423
|
+
]),
|
|
424
|
+
(r) => Record.isEmptyRecord(r) ? void 0 : r
|
|
425
|
+
);
|
|
395
426
|
|
|
396
427
|
// src/kupmios/kupmios.ts
|
|
397
|
-
import { fromUnit } from "@lucid-evolution/utils";
|
|
428
|
+
import { applyDoubleCborEncoding as applyDoubleCborEncoding2, fromUnit } from "@lucid-evolution/utils";
|
|
398
429
|
import * as S2 from "@effect/schema/Schema";
|
|
399
|
-
import { Effect, pipe, Array as _Array, Schedule, Data } from "effect";
|
|
430
|
+
import { Effect, pipe as pipe2, Array as _Array, Schedule, Data } from "effect";
|
|
400
431
|
|
|
401
432
|
// src/kupmios/schema.ts
|
|
402
433
|
import * as S from "@effect/schema/Schema";
|
|
@@ -417,6 +448,51 @@ var TupleNumberFromString = S.compose(
|
|
|
417
448
|
);
|
|
418
449
|
var ProtocolParametersSchema = S.Struct({
|
|
419
450
|
minFeeCoefficient: S.Number,
|
|
451
|
+
minFeeReferenceScripts: S.Struct({
|
|
452
|
+
base: S.Number,
|
|
453
|
+
range: S.Number,
|
|
454
|
+
multiplier: S.Number
|
|
455
|
+
}),
|
|
456
|
+
maxReferenceScriptsSize: S.Struct({
|
|
457
|
+
bytes: S.Number
|
|
458
|
+
}),
|
|
459
|
+
stakePoolVotingThresholds: S.Struct({
|
|
460
|
+
noConfidence: TupleNumberFromString,
|
|
461
|
+
constitutionalCommittee: S.Struct({
|
|
462
|
+
default: TupleNumberFromString,
|
|
463
|
+
stateOfNoConfidence: TupleNumberFromString
|
|
464
|
+
}),
|
|
465
|
+
hardForkInitiation: TupleNumberFromString,
|
|
466
|
+
protocolParametersUpdate: S.Struct({
|
|
467
|
+
security: TupleNumberFromString
|
|
468
|
+
})
|
|
469
|
+
}),
|
|
470
|
+
delegateRepresentativeVotingThresholds: S.Struct({
|
|
471
|
+
noConfidence: TupleNumberFromString,
|
|
472
|
+
constitutionalCommittee: S.Struct({
|
|
473
|
+
default: TupleNumberFromString,
|
|
474
|
+
stateOfNoConfidence: TupleNumberFromString
|
|
475
|
+
}),
|
|
476
|
+
constitution: TupleNumberFromString,
|
|
477
|
+
hardForkInitiation: TupleNumberFromString,
|
|
478
|
+
protocolParametersUpdate: S.Struct({
|
|
479
|
+
network: TupleNumberFromString,
|
|
480
|
+
economic: TupleNumberFromString,
|
|
481
|
+
technical: TupleNumberFromString,
|
|
482
|
+
governance: TupleNumberFromString
|
|
483
|
+
}),
|
|
484
|
+
treasuryWithdrawals: TupleNumberFromString
|
|
485
|
+
}),
|
|
486
|
+
constitutionalCommitteeMinSize: S.Number,
|
|
487
|
+
constitutionalCommitteeMaxTermLength: S.Number,
|
|
488
|
+
governanceActionLifetime: S.Number,
|
|
489
|
+
governanceActionDeposit: S.Struct({
|
|
490
|
+
ada: LovelaceAsset
|
|
491
|
+
}),
|
|
492
|
+
delegateRepresentativeDeposit: S.Struct({
|
|
493
|
+
ada: LovelaceAsset
|
|
494
|
+
}),
|
|
495
|
+
delegateRepresentativeMaxIdleTime: S.Number,
|
|
420
496
|
minFeeConstant: S.Struct({ ada: LovelaceAsset }),
|
|
421
497
|
maxBlockBodySize: S.Struct({ bytes: S.Number }),
|
|
422
498
|
maxBlockHeaderSize: S.Struct({ bytes: S.Number }),
|
|
@@ -433,7 +509,8 @@ var ProtocolParametersSchema = S.Struct({
|
|
|
433
509
|
minUtxoDepositCoefficient: S.Number,
|
|
434
510
|
plutusCostModels: S.Struct({
|
|
435
511
|
"plutus:v1": S.Array(S.Number),
|
|
436
|
-
"plutus:v2": S.Array(S.Number)
|
|
512
|
+
"plutus:v2": S.Array(S.Number),
|
|
513
|
+
"plutus:v3": S.Array(S.Number)
|
|
437
514
|
}),
|
|
438
515
|
scriptExecutionPrices: S.Struct({
|
|
439
516
|
memory: TupleNumberFromString,
|
|
@@ -466,11 +543,16 @@ var KupoUTxO = S.Struct({
|
|
|
466
543
|
slot_no: S.Number,
|
|
467
544
|
header_hash: S.String
|
|
468
545
|
}),
|
|
469
|
-
spent_at: S.NullOr(
|
|
546
|
+
spent_at: S.NullOr(
|
|
547
|
+
S.Struct({
|
|
548
|
+
slot_no: S.Number,
|
|
549
|
+
header_hash: S.String
|
|
550
|
+
})
|
|
551
|
+
)
|
|
470
552
|
});
|
|
471
553
|
var KupoScriptSchema = S.NullOr(
|
|
472
554
|
S.Struct({
|
|
473
|
-
language: S.Literal("native", "plutus:v1", "plutus:v2"),
|
|
555
|
+
language: S.Literal("native", "plutus:v1", "plutus:v2", "plutus:v3"),
|
|
474
556
|
script: S.String
|
|
475
557
|
})
|
|
476
558
|
);
|
|
@@ -492,6 +574,7 @@ import {
|
|
|
492
574
|
HttpClientRequest,
|
|
493
575
|
HttpClientResponse
|
|
494
576
|
} from "@effect/platform";
|
|
577
|
+
import { ArrayFormatter } from "@effect/schema";
|
|
495
578
|
var KupmiosError = class extends Data.TaggedError("KupmiosError") {
|
|
496
579
|
get message() {
|
|
497
580
|
return `${this.cause}`;
|
|
@@ -628,7 +711,7 @@ var Kupmios = class {
|
|
|
628
711
|
return result.datum;
|
|
629
712
|
}
|
|
630
713
|
async awaitTx(txHash, checkInterval = 2e4) {
|
|
631
|
-
const pattern = `${this.kupoUrl}/matches/*@${txHash}
|
|
714
|
+
const pattern = `${this.kupoUrl}/matches/*@${txHash}`;
|
|
632
715
|
const schema = S2.Array(KupoUTxO).annotations({
|
|
633
716
|
identifier: "Array<KupmiosSchema.KupoUTxO>"
|
|
634
717
|
});
|
|
@@ -739,28 +822,34 @@ var getDatumEffect = (kupoUrl, datum_type, datum_hash) => Effect.gen(function* (
|
|
|
739
822
|
Effect.map((result) => result.datum),
|
|
740
823
|
Effect.timeout(1e4)
|
|
741
824
|
);
|
|
742
|
-
} else return
|
|
825
|
+
} else return void 0;
|
|
743
826
|
});
|
|
744
827
|
var getScriptEffect = (kupoUrl, script_hash) => Effect.gen(function* () {
|
|
745
828
|
if (script_hash) {
|
|
746
829
|
const pattern = `${kupoUrl}/scripts/${script_hash}`;
|
|
747
830
|
const schema = KupoScriptSchema;
|
|
748
|
-
return yield*
|
|
831
|
+
return yield* pipe2(
|
|
749
832
|
fetchKupoParse(pattern, schema),
|
|
750
833
|
Effect.flatMap(Effect.fromNullable),
|
|
751
834
|
Effect.timeout(1e4),
|
|
752
835
|
Effect.map(({ language, script }) => {
|
|
753
836
|
switch (language) {
|
|
754
837
|
case "native":
|
|
755
|
-
return
|
|
838
|
+
return void 0;
|
|
756
839
|
case "plutus:v1":
|
|
757
|
-
return {
|
|
840
|
+
return {
|
|
841
|
+
type: "PlutusV1",
|
|
842
|
+
script: applyDoubleCborEncoding2(script)
|
|
843
|
+
};
|
|
758
844
|
case "plutus:v2":
|
|
759
|
-
return {
|
|
845
|
+
return {
|
|
846
|
+
type: "PlutusV2",
|
|
847
|
+
script: applyDoubleCborEncoding2(script)
|
|
848
|
+
};
|
|
760
849
|
}
|
|
761
850
|
})
|
|
762
851
|
);
|
|
763
|
-
} else return
|
|
852
|
+
} else return void 0;
|
|
764
853
|
});
|
|
765
854
|
var toAssets = (value) => {
|
|
766
855
|
const assets = { lovelace: BigInt(value.coins) };
|
|
@@ -801,35 +890,45 @@ var toProtocolParameters = (result) => {
|
|
|
801
890
|
index.toString(),
|
|
802
891
|
value
|
|
803
892
|
])
|
|
893
|
+
),
|
|
894
|
+
PlutusV3: Object.fromEntries(
|
|
895
|
+
result.plutusCostModels["plutus:v3"].map((value, index) => [
|
|
896
|
+
index.toString(),
|
|
897
|
+
value
|
|
898
|
+
])
|
|
804
899
|
)
|
|
805
900
|
}
|
|
806
901
|
};
|
|
807
902
|
};
|
|
808
|
-
var fetchOgmiosParse = (url, data, schema) =>
|
|
903
|
+
var fetchOgmiosParse = (url, data, schema) => pipe2(
|
|
809
904
|
HttpClientRequest.post(url),
|
|
810
905
|
HttpClientRequest.jsonBody(data),
|
|
811
906
|
Effect.flatMap(HttpClient.fetch),
|
|
812
907
|
HttpClientResponse.json,
|
|
813
|
-
Effect.flatMap(
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
908
|
+
Effect.flatMap(
|
|
909
|
+
S2.decodeUnknown(schema, { onExcessProperty: "error", errors: "first" })
|
|
910
|
+
),
|
|
911
|
+
Effect.catchTag(
|
|
912
|
+
"ParseError",
|
|
913
|
+
(e) => Effect.fail(ArrayFormatter.formatErrorSync(e))
|
|
914
|
+
)
|
|
817
915
|
// Effect.scoped
|
|
818
916
|
);
|
|
819
|
-
var fetchKupoParse = (url, schema) =>
|
|
917
|
+
var fetchKupoParse = (url, schema) => pipe2(
|
|
820
918
|
HttpClientRequest.get(url),
|
|
821
919
|
HttpClient.fetchOk,
|
|
822
920
|
HttpClientResponse.json,
|
|
823
|
-
Effect.flatMap(S2.decodeUnknown(schema))
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
921
|
+
Effect.flatMap(S2.decodeUnknown(schema, { onExcessProperty: "error" })),
|
|
922
|
+
Effect.catchTag(
|
|
923
|
+
"ParseError",
|
|
924
|
+
(e) => Effect.fail(ArrayFormatter.formatErrorSync(e))
|
|
925
|
+
)
|
|
827
926
|
// Effect.scoped
|
|
828
927
|
);
|
|
829
928
|
var kupmiosUtxosToUtxos = (kupoURL, utxos) => Effect.forEach(
|
|
830
929
|
utxos,
|
|
831
930
|
(utxo) => {
|
|
832
|
-
return
|
|
931
|
+
return pipe2(
|
|
833
932
|
Effect.all([
|
|
834
933
|
getDatumEffect(kupoURL, utxo.datum_type, utxo.datum_hash),
|
|
835
934
|
getScriptEffect(kupoURL, utxo.script_hash)
|
|
@@ -840,7 +939,7 @@ var kupmiosUtxosToUtxos = (kupoURL, utxos) => Effect.forEach(
|
|
|
840
939
|
outputIndex: utxo.output_index,
|
|
841
940
|
address: utxo.address,
|
|
842
941
|
assets: toAssets(utxo.value),
|
|
843
|
-
datumHash: utxo.datum_type === "hash" ? utxo.datum_hash :
|
|
942
|
+
datumHash: utxo.datum_type === "hash" ? utxo.datum_hash : void 0,
|
|
844
943
|
datum,
|
|
845
944
|
scriptRef: script
|
|
846
945
|
})
|
|
@@ -1200,12 +1299,27 @@ It does not exist or was already spent.`
|
|
|
1200
1299
|
3: "Reward"
|
|
1201
1300
|
};
|
|
1202
1301
|
const collected = [];
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1302
|
+
const redeemers2 = witnesses.redeemers();
|
|
1303
|
+
const arrLegacyRedeemer = redeemers2?.as_arr_legacy_redeemer();
|
|
1304
|
+
if (arrLegacyRedeemer) {
|
|
1305
|
+
for (let i = 0; i < (arrLegacyRedeemer.len() || 0); i++) {
|
|
1306
|
+
const redeemer = arrLegacyRedeemer.get(i);
|
|
1307
|
+
collected.push({
|
|
1308
|
+
tag: tagMap[redeemer.tag()],
|
|
1309
|
+
index: Number(redeemer.index())
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
const mapRedeemerKeyToRedeemerVal = redeemers2?.as_map_redeemer_key_to_redeemer_val();
|
|
1314
|
+
if (mapRedeemerKeyToRedeemerVal) {
|
|
1315
|
+
const keys = mapRedeemerKeyToRedeemerVal.keys();
|
|
1316
|
+
for (let i = 0; i < (keys.len() || 0); i++) {
|
|
1317
|
+
const key = keys.get(i);
|
|
1318
|
+
collected.push({
|
|
1319
|
+
tag: tagMap[key.tag()],
|
|
1320
|
+
index: Number(key.index())
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1209
1323
|
}
|
|
1210
1324
|
return collected;
|
|
1211
1325
|
})();
|
|
@@ -1575,7 +1689,7 @@ function redeemerTagToString(tag) {
|
|
|
1575
1689
|
}
|
|
1576
1690
|
|
|
1577
1691
|
// src/maestro.ts
|
|
1578
|
-
import { applyDoubleCborEncoding as
|
|
1692
|
+
import { applyDoubleCborEncoding as applyDoubleCborEncoding3, utxoToCore } from "@lucid-evolution/utils";
|
|
1579
1693
|
import { fromHex as fromHex3 } from "@lucid-evolution/core-utils";
|
|
1580
1694
|
var Maestro = class {
|
|
1581
1695
|
url;
|
|
@@ -1587,7 +1701,7 @@ var Maestro = class {
|
|
|
1587
1701
|
this.turboSubmit = turboSubmit;
|
|
1588
1702
|
}
|
|
1589
1703
|
async getProtocolParameters() {
|
|
1590
|
-
const timestampedResult = await fetch(`${this.url}/protocol-
|
|
1704
|
+
const timestampedResult = await fetch(`${this.url}/protocol-parameters`, {
|
|
1591
1705
|
headers: this.commonHeaders()
|
|
1592
1706
|
}).then((res) => res.json());
|
|
1593
1707
|
const result = timestampedResult.data;
|
|
@@ -1595,37 +1709,39 @@ var Maestro = class {
|
|
|
1595
1709
|
const forwardSlashIndex = str.indexOf("/");
|
|
1596
1710
|
return parseInt(str.slice(0, forwardSlashIndex)) / parseInt(str.slice(forwardSlashIndex + 1));
|
|
1597
1711
|
};
|
|
1598
|
-
const renameKeysAndSort = (obj, newKeys) => {
|
|
1599
|
-
const entries = Object.keys(obj).sort().map((key) => {
|
|
1600
|
-
const newKey = newKeys[key] || key;
|
|
1601
|
-
return {
|
|
1602
|
-
[newKey]: Object.fromEntries(
|
|
1603
|
-
Object.entries(obj[key]).sort(
|
|
1604
|
-
([k, _v], [k2, _v2]) => k.localeCompare(k2)
|
|
1605
|
-
)
|
|
1606
|
-
)
|
|
1607
|
-
};
|
|
1608
|
-
});
|
|
1609
|
-
return Object.assign({}, ...entries);
|
|
1610
|
-
};
|
|
1611
1712
|
return {
|
|
1612
1713
|
minFeeA: parseInt(result.min_fee_coefficient),
|
|
1613
|
-
minFeeB: parseInt(result.min_fee_constant),
|
|
1614
|
-
maxTxSize: parseInt(result.
|
|
1615
|
-
maxValSize: parseInt(result.max_value_size),
|
|
1616
|
-
keyDeposit: BigInt(result.
|
|
1617
|
-
poolDeposit: BigInt(result.
|
|
1618
|
-
priceMem: decimalFromRationalString(
|
|
1619
|
-
|
|
1714
|
+
minFeeB: parseInt(result.min_fee_constant.ada.lovelace),
|
|
1715
|
+
maxTxSize: parseInt(result.max_transaction_size.bytes),
|
|
1716
|
+
maxValSize: parseInt(result.max_value_size.bytes),
|
|
1717
|
+
keyDeposit: BigInt(result.stake_credential_deposit.ada.lovelace),
|
|
1718
|
+
poolDeposit: BigInt(result.stake_pool_deposit.ada.lovelace),
|
|
1719
|
+
priceMem: decimalFromRationalString(
|
|
1720
|
+
result.script_execution_prices.memory
|
|
1721
|
+
),
|
|
1722
|
+
priceStep: decimalFromRationalString(result.script_execution_prices.cpu),
|
|
1620
1723
|
maxTxExMem: BigInt(result.max_execution_units_per_transaction.memory),
|
|
1621
|
-
maxTxExSteps: BigInt(result.max_execution_units_per_transaction.
|
|
1622
|
-
coinsPerUtxoByte: BigInt(result.
|
|
1724
|
+
maxTxExSteps: BigInt(result.max_execution_units_per_transaction.cpu),
|
|
1725
|
+
coinsPerUtxoByte: BigInt(result.min_utxo_deposit_coefficient),
|
|
1623
1726
|
collateralPercentage: parseInt(result.collateral_percentage),
|
|
1624
1727
|
maxCollateralInputs: parseInt(result.max_collateral_inputs),
|
|
1625
|
-
costModels:
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1728
|
+
costModels: {
|
|
1729
|
+
PlutusV1: Object.fromEntries(
|
|
1730
|
+
result.plutus_cost_models.plutus_v1.map(
|
|
1731
|
+
(value, index) => [index.toString(), value]
|
|
1732
|
+
)
|
|
1733
|
+
),
|
|
1734
|
+
PlutusV2: Object.fromEntries(
|
|
1735
|
+
result.plutus_cost_models.plutus_v2.map(
|
|
1736
|
+
(value, index) => [index.toString(), value]
|
|
1737
|
+
)
|
|
1738
|
+
),
|
|
1739
|
+
PlutusV3: Object.fromEntries(
|
|
1740
|
+
result.plutus_cost_models.plutus_v2.map(
|
|
1741
|
+
(value, index) => [index.toString(), value]
|
|
1742
|
+
)
|
|
1743
|
+
)
|
|
1744
|
+
}
|
|
1629
1745
|
};
|
|
1630
1746
|
}
|
|
1631
1747
|
async getUtxosInternal(addressOrCredential, unit) {
|
|
@@ -1808,10 +1924,7 @@ var Maestro = class {
|
|
|
1808
1924
|
address: result.address,
|
|
1809
1925
|
datumHash: result.datum ? result.datum.type == "inline" ? void 0 : result.datum.hash : void 0,
|
|
1810
1926
|
datum: result.datum?.bytes,
|
|
1811
|
-
scriptRef: result.reference_script
|
|
1812
|
-
type: result.reference_script.type == "plutusv1" ? "PlutusV1" : "PlutusV2",
|
|
1813
|
-
script: applyDoubleCborEncoding2(result.reference_script.bytes)
|
|
1814
|
-
} : void 0
|
|
1927
|
+
scriptRef: toScriptRef(result.reference_script)
|
|
1815
1928
|
};
|
|
1816
1929
|
}
|
|
1817
1930
|
async getAllPagesData(getResponse, qry, paramsGiven, errorMsg) {
|
|
@@ -1862,16 +1975,61 @@ var Maestro = class {
|
|
|
1862
1975
|
return result;
|
|
1863
1976
|
}
|
|
1864
1977
|
};
|
|
1978
|
+
var toScriptRef = (reference_script) => {
|
|
1979
|
+
if (reference_script && reference_script.bytes) {
|
|
1980
|
+
switch (reference_script.type) {
|
|
1981
|
+
case "plutusv1":
|
|
1982
|
+
return {
|
|
1983
|
+
type: "PlutusV1",
|
|
1984
|
+
script: applyDoubleCborEncoding3(reference_script.bytes)
|
|
1985
|
+
};
|
|
1986
|
+
case "plutusv2":
|
|
1987
|
+
return {
|
|
1988
|
+
type: "PlutusV2",
|
|
1989
|
+
script: applyDoubleCborEncoding3(reference_script.bytes)
|
|
1990
|
+
};
|
|
1991
|
+
case "plutusv3":
|
|
1992
|
+
return {
|
|
1993
|
+
type: "PlutusV3",
|
|
1994
|
+
script: applyDoubleCborEncoding3(reference_script.bytes)
|
|
1995
|
+
};
|
|
1996
|
+
default:
|
|
1997
|
+
return void 0;
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
};
|
|
1865
2001
|
var lucid2 = package_default.version;
|
|
1866
2002
|
|
|
1867
2003
|
// src/koios/koios.ts
|
|
1868
2004
|
import * as S4 from "@effect/schema/Schema";
|
|
1869
2005
|
import { fromHex as fromHex4 } from "@lucid-evolution/core-utils";
|
|
1870
|
-
import { applyDoubleCborEncoding as
|
|
2006
|
+
import { applyDoubleCborEncoding as applyDoubleCborEncoding4, fromUnit as fromUnit2 } from "@lucid-evolution/utils";
|
|
1871
2007
|
|
|
1872
2008
|
// src/koios/schema.ts
|
|
1873
2009
|
import * as S3 from "@effect/schema/Schema";
|
|
1874
2010
|
var ProtocolParametersSchema2 = S3.Struct({
|
|
2011
|
+
pvt_motion_no_confidence: S3.Number,
|
|
2012
|
+
pvt_committee_normal: S3.Number,
|
|
2013
|
+
pvt_committee_no_confidence: S3.Number,
|
|
2014
|
+
pvt_hard_fork_initiation: S3.Number,
|
|
2015
|
+
pvtpp_security_group: S3.Number,
|
|
2016
|
+
dvt_motion_no_confidence: S3.Number,
|
|
2017
|
+
dvt_committee_normal: S3.Number,
|
|
2018
|
+
dvt_committee_no_confidence: S3.Number,
|
|
2019
|
+
dvt_update_to_constitution: S3.Number,
|
|
2020
|
+
dvt_hard_fork_initiation: S3.Number,
|
|
2021
|
+
dvt_p_p_network_group: S3.Number,
|
|
2022
|
+
dvt_p_p_economic_group: S3.Number,
|
|
2023
|
+
dvt_p_p_technical_group: S3.Number,
|
|
2024
|
+
dvt_p_p_gov_group: S3.Number,
|
|
2025
|
+
dvt_treasury_withdrawal: S3.Number,
|
|
2026
|
+
committee_min_size: S3.Number,
|
|
2027
|
+
committee_max_term_length: S3.Number,
|
|
2028
|
+
gov_action_lifetime: S3.Number,
|
|
2029
|
+
gov_action_deposit: S3.NumberFromString,
|
|
2030
|
+
drep_deposit: S3.NumberFromString,
|
|
2031
|
+
drep_activity: S3.Number,
|
|
2032
|
+
min_fee_ref_script_cost_per_byte: S3.Number,
|
|
1875
2033
|
epoch_no: S3.Number,
|
|
1876
2034
|
min_fee_a: S3.Number,
|
|
1877
2035
|
min_fee_b: S3.Number,
|
|
@@ -1895,7 +2053,8 @@ var ProtocolParametersSchema2 = S3.Struct({
|
|
|
1895
2053
|
block_hash: S3.NullOr(S3.String),
|
|
1896
2054
|
cost_models: S3.Struct({
|
|
1897
2055
|
PlutusV1: S3.Array(S3.Number),
|
|
1898
|
-
PlutusV2: S3.Array(S3.Number)
|
|
2056
|
+
PlutusV2: S3.Array(S3.Number),
|
|
2057
|
+
PlutusV3: S3.Array(S3.Number)
|
|
1899
2058
|
}),
|
|
1900
2059
|
price_mem: S3.Number,
|
|
1901
2060
|
price_step: S3.Number,
|
|
@@ -1915,9 +2074,17 @@ var KoiosAssetSchema = S3.Struct({
|
|
|
1915
2074
|
decimals: S3.Number,
|
|
1916
2075
|
quantity: S3.String
|
|
1917
2076
|
});
|
|
2077
|
+
var ReferenceScriptSchema = S3.Struct({
|
|
2078
|
+
hash: S3.NullOr(S3.String),
|
|
2079
|
+
size: S3.NullOr(S3.Number),
|
|
2080
|
+
type: S3.NullOr(S3.String),
|
|
2081
|
+
bytes: S3.NullOr(S3.String),
|
|
2082
|
+
value: S3.NullOr(S3.Object)
|
|
2083
|
+
});
|
|
1918
2084
|
var KoiosUTxOSchema = S3.Struct({
|
|
1919
2085
|
tx_hash: S3.String,
|
|
1920
2086
|
tx_index: S3.Number,
|
|
2087
|
+
block_time: S3.Number,
|
|
1921
2088
|
block_height: S3.NullOr(S3.Number),
|
|
1922
2089
|
value: S3.String,
|
|
1923
2090
|
datum_hash: S3.NullOr(S3.String),
|
|
@@ -1927,15 +2094,7 @@ var KoiosUTxOSchema = S3.Struct({
|
|
|
1927
2094
|
value: S3.Object
|
|
1928
2095
|
})
|
|
1929
2096
|
),
|
|
1930
|
-
reference_script: S3.NullOr(
|
|
1931
|
-
S3.Struct({
|
|
1932
|
-
hash: S3.String,
|
|
1933
|
-
size: S3.Number,
|
|
1934
|
-
type: S3.String,
|
|
1935
|
-
bytes: S3.String,
|
|
1936
|
-
value: S3.NullOr(S3.Object)
|
|
1937
|
-
})
|
|
1938
|
-
),
|
|
2097
|
+
reference_script: S3.NullOr(ReferenceScriptSchema),
|
|
1939
2098
|
asset_list: S3.NullOr(S3.Array(KoiosAssetSchema))
|
|
1940
2099
|
});
|
|
1941
2100
|
var KoiosAddressInfoSchema = S3.Array(
|
|
@@ -1965,16 +2124,8 @@ var KoiosInputOutputSchema = S3.Struct({
|
|
|
1965
2124
|
value: S3.Object
|
|
1966
2125
|
})
|
|
1967
2126
|
),
|
|
1968
|
-
reference_script: S3.NullOr(
|
|
1969
|
-
|
|
1970
|
-
hash: S3.String,
|
|
1971
|
-
size: S3.Number,
|
|
1972
|
-
type: S3.String,
|
|
1973
|
-
bytes: S3.String,
|
|
1974
|
-
value: S3.NullOr(S3.Object)
|
|
1975
|
-
})
|
|
1976
|
-
),
|
|
1977
|
-
asset_list: S3.Union(S3.Array(KoiosAssetSchema), S3.String)
|
|
2127
|
+
reference_script: S3.NullOr(ReferenceScriptSchema),
|
|
2128
|
+
asset_list: S3.Array(KoiosAssetSchema)
|
|
1978
2129
|
});
|
|
1979
2130
|
var KoiosTxInfoSchema = S3.Struct({
|
|
1980
2131
|
tx_hash: S3.String,
|
|
@@ -1988,6 +2139,7 @@ var KoiosTxInfoSchema = S3.Struct({
|
|
|
1988
2139
|
tx_size: S3.Number,
|
|
1989
2140
|
total_output: S3.String,
|
|
1990
2141
|
fee: S3.String,
|
|
2142
|
+
treasury_donation: S3.String,
|
|
1991
2143
|
deposit: S3.String,
|
|
1992
2144
|
invalid_before: S3.NullOr(S3.String),
|
|
1993
2145
|
invalid_after: S3.NullOr(S3.String),
|
|
@@ -2057,12 +2209,18 @@ var KoiosTxInfoSchema = S3.Struct({
|
|
|
2057
2209
|
})
|
|
2058
2210
|
})
|
|
2059
2211
|
)
|
|
2060
|
-
)
|
|
2212
|
+
),
|
|
2213
|
+
//TODO: add S.Struct
|
|
2214
|
+
// https://preprod.koios.rest/#post-/tx_info
|
|
2215
|
+
voting_procedures: S3.Array(S3.Object),
|
|
2216
|
+
//TODO: add S.Struct
|
|
2217
|
+
// https://preprod.koios.rest/#post-/tx_info
|
|
2218
|
+
proposal_procedures: S3.Object
|
|
2061
2219
|
});
|
|
2062
2220
|
|
|
2063
2221
|
// src/koios/koios.ts
|
|
2064
|
-
import { Effect as Effect3, pipe as
|
|
2065
|
-
import { ArrayFormatter } from "@effect/schema";
|
|
2222
|
+
import { Effect as Effect3, pipe as pipe4, Schedule as Schedule2 } from "effect";
|
|
2223
|
+
import { ArrayFormatter as ArrayFormatter2 } from "@effect/schema";
|
|
2066
2224
|
|
|
2067
2225
|
// src/fetch.ts
|
|
2068
2226
|
var fetch_exports = {};
|
|
@@ -2072,14 +2230,14 @@ __export(fetch_exports, {
|
|
|
2072
2230
|
ResponseError: () => ResponseError,
|
|
2073
2231
|
fetchEffect: () => fetchEffect
|
|
2074
2232
|
});
|
|
2075
|
-
import { Data as Data2, Effect as Effect2, pipe as
|
|
2233
|
+
import { Data as Data2, Effect as Effect2, pipe as pipe3 } from "effect";
|
|
2076
2234
|
var FetchError = class extends Data2.TaggedError("FetchError") {
|
|
2077
2235
|
};
|
|
2078
2236
|
var ResponseError = class extends Data2.TaggedError("ResponseError") {
|
|
2079
2237
|
};
|
|
2080
2238
|
var JsonError = class extends Data2.TaggedError("JsonError") {
|
|
2081
2239
|
};
|
|
2082
|
-
var fetchEffect = (input, requestInit) =>
|
|
2240
|
+
var fetchEffect = (input, requestInit) => pipe3(
|
|
2083
2241
|
Effect2.tryPromise({
|
|
2084
2242
|
try: () => fetch(input, requestInit),
|
|
2085
2243
|
catch: (error) => new FetchError({
|
|
@@ -2109,7 +2267,17 @@ var Koios = class {
|
|
|
2109
2267
|
const result = await fetch(`${this.baseUrl}/epoch_params?limit=1`).then(
|
|
2110
2268
|
(res) => res.json()
|
|
2111
2269
|
);
|
|
2112
|
-
const param =
|
|
2270
|
+
const param = await pipe4(
|
|
2271
|
+
S4.decodeUnknown(ProtocolParametersSchema2, {
|
|
2272
|
+
onExcessProperty: "error",
|
|
2273
|
+
errors: "first"
|
|
2274
|
+
})(result[0]),
|
|
2275
|
+
Effect3.catchTag(
|
|
2276
|
+
"ParseError",
|
|
2277
|
+
(e) => Effect3.fail(ArrayFormatter2.formatErrorSync(e))
|
|
2278
|
+
),
|
|
2279
|
+
Effect3.runPromise
|
|
2280
|
+
);
|
|
2113
2281
|
return {
|
|
2114
2282
|
minFeeA: param.min_fee_a,
|
|
2115
2283
|
minFeeB: param.min_fee_b,
|
|
@@ -2136,6 +2304,12 @@ var Koios = class {
|
|
|
2136
2304
|
index.toString(),
|
|
2137
2305
|
value
|
|
2138
2306
|
])
|
|
2307
|
+
),
|
|
2308
|
+
PlutusV3: Object.fromEntries(
|
|
2309
|
+
param.cost_models.PlutusV3.map((value, index) => [
|
|
2310
|
+
index.toString(),
|
|
2311
|
+
value
|
|
2312
|
+
])
|
|
2139
2313
|
)
|
|
2140
2314
|
}
|
|
2141
2315
|
};
|
|
@@ -2153,9 +2327,17 @@ var Koios = class {
|
|
|
2153
2327
|
method: "POST",
|
|
2154
2328
|
body: JSON.stringify(body)
|
|
2155
2329
|
}).then((res) => res.json());
|
|
2156
|
-
const parsedResult =
|
|
2157
|
-
|
|
2158
|
-
|
|
2330
|
+
const [parsedResult] = await pipe4(
|
|
2331
|
+
S4.decodeUnknown(KoiosAddressInfoSchema, {
|
|
2332
|
+
onExcessProperty: "error",
|
|
2333
|
+
errors: "first"
|
|
2334
|
+
})(result),
|
|
2335
|
+
Effect3.catchTag(
|
|
2336
|
+
"ParseError",
|
|
2337
|
+
(e) => Effect3.fail(ArrayFormatter2.formatErrorSync(e))
|
|
2338
|
+
),
|
|
2339
|
+
Effect3.runPromise
|
|
2340
|
+
);
|
|
2159
2341
|
return parsedResult ? parsedResult.utxo_set.map(
|
|
2160
2342
|
(koiosUTXO) => toUTxO(koiosUTXO, parsedResult.address)
|
|
2161
2343
|
) : [];
|
|
@@ -2204,9 +2386,10 @@ var Koios = class {
|
|
|
2204
2386
|
throw new Error("Unit not found.");
|
|
2205
2387
|
}
|
|
2206
2388
|
async getUtxosByOutRef(outRefs) {
|
|
2207
|
-
const utxos = [];
|
|
2208
2389
|
const body = {
|
|
2209
|
-
_tx_hashes: [...new Set(outRefs.map((outRef) => outRef.txHash))]
|
|
2390
|
+
_tx_hashes: [...new Set(outRefs.map((outRef) => outRef.txHash))],
|
|
2391
|
+
_assets: true,
|
|
2392
|
+
_scripts: true
|
|
2210
2393
|
};
|
|
2211
2394
|
const result = await fetch(`${this.baseUrl}/tx_info`, {
|
|
2212
2395
|
headers: {
|
|
@@ -2216,26 +2399,39 @@ var Koios = class {
|
|
|
2216
2399
|
method: "POST",
|
|
2217
2400
|
body: JSON.stringify(body)
|
|
2218
2401
|
}).then((res) => res.json());
|
|
2219
|
-
const parsedResult =
|
|
2220
|
-
|
|
2221
|
-
|
|
2402
|
+
const [parsedResult] = await pipe4(
|
|
2403
|
+
S4.decodeUnknown(S4.Array(KoiosTxInfoSchema), {
|
|
2404
|
+
onExcessProperty: "error",
|
|
2405
|
+
errors: "first"
|
|
2406
|
+
})(result),
|
|
2407
|
+
Effect3.catchTag(
|
|
2408
|
+
"ParseError",
|
|
2409
|
+
(e) => Effect3.fail(ArrayFormatter2.formatErrorSync(e))
|
|
2410
|
+
),
|
|
2411
|
+
Effect3.runPromise
|
|
2412
|
+
);
|
|
2222
2413
|
if (parsedResult) {
|
|
2223
|
-
|
|
2414
|
+
const utxos = parsedResult.outputs.map(
|
|
2224
2415
|
(koiosInputOutput) => toUTxO(
|
|
2225
2416
|
{
|
|
2226
2417
|
tx_hash: koiosInputOutput.tx_hash,
|
|
2227
2418
|
tx_index: koiosInputOutput.tx_index,
|
|
2228
|
-
|
|
2419
|
+
block_time: 0,
|
|
2420
|
+
block_height: parsedResult.block_height,
|
|
2229
2421
|
value: koiosInputOutput.value,
|
|
2230
2422
|
datum_hash: koiosInputOutput.datum_hash,
|
|
2231
2423
|
inline_datum: koiosInputOutput.inline_datum,
|
|
2232
2424
|
reference_script: koiosInputOutput.reference_script,
|
|
2233
|
-
|
|
2234
|
-
asset_list: typeof koiosInputOutput.asset_list === "string" ? [] : koiosInputOutput.asset_list
|
|
2425
|
+
asset_list: koiosInputOutput.asset_list
|
|
2235
2426
|
},
|
|
2236
2427
|
koiosInputOutput.payment_addr.bech32
|
|
2237
2428
|
)
|
|
2238
2429
|
);
|
|
2430
|
+
return utxos.filter(
|
|
2431
|
+
(utxo) => outRefs.some(
|
|
2432
|
+
(outRef) => utxo.txHash === outRef.txHash && utxo.outputIndex === outRef.outputIndex
|
|
2433
|
+
)
|
|
2434
|
+
);
|
|
2239
2435
|
} else {
|
|
2240
2436
|
return [];
|
|
2241
2437
|
}
|
|
@@ -2291,14 +2487,14 @@ var Koios = class {
|
|
|
2291
2487
|
method: "POST",
|
|
2292
2488
|
body: JSON.stringify(body)
|
|
2293
2489
|
};
|
|
2294
|
-
const program =
|
|
2490
|
+
const program = pipe4(
|
|
2295
2491
|
fetchEffect(`${this.baseUrl}/tx_info`, request),
|
|
2296
2492
|
Effect3.flatMap(
|
|
2297
2493
|
(json) => S4.decodeUnknown(S4.Array(KoiosTxInfoSchema))(json)
|
|
2298
2494
|
),
|
|
2299
2495
|
Effect3.catchTag(
|
|
2300
2496
|
"ParseError",
|
|
2301
|
-
(e) => Effect3.fail(
|
|
2497
|
+
(e) => Effect3.fail(ArrayFormatter2.formatErrorSync(e))
|
|
2302
2498
|
),
|
|
2303
2499
|
Effect3.repeat({
|
|
2304
2500
|
schedule: Schedule2.exponential(checkInterval),
|
|
@@ -2397,16 +2593,33 @@ var toUTxO = (koiosUTxO, address) => ({
|
|
|
2397
2593
|
return a;
|
|
2398
2594
|
})(),
|
|
2399
2595
|
address,
|
|
2400
|
-
datumHash: koiosUTxO.inline_datum ? void 0 : koiosUTxO.datum_hash,
|
|
2596
|
+
datumHash: koiosUTxO.inline_datum ? void 0 : koiosUTxO.datum_hash || void 0,
|
|
2401
2597
|
datum: koiosUTxO.inline_datum ? koiosUTxO.inline_datum.bytes : void 0,
|
|
2402
|
-
scriptRef: koiosUTxO.reference_script
|
|
2403
|
-
type: "PlutusV1",
|
|
2404
|
-
script: applyDoubleCborEncoding3(koiosUTxO.reference_script.bytes)
|
|
2405
|
-
} : {
|
|
2406
|
-
type: "PlutusV2",
|
|
2407
|
-
script: applyDoubleCborEncoding3(koiosUTxO.reference_script.bytes)
|
|
2408
|
-
} : void 0
|
|
2598
|
+
scriptRef: toScriptRef2(koiosUTxO.reference_script)
|
|
2409
2599
|
});
|
|
2600
|
+
var toScriptRef2 = (reference_script) => {
|
|
2601
|
+
if (reference_script && reference_script.bytes && reference_script.type) {
|
|
2602
|
+
switch (reference_script.type) {
|
|
2603
|
+
case "plutusV1":
|
|
2604
|
+
return {
|
|
2605
|
+
type: "PlutusV1",
|
|
2606
|
+
script: applyDoubleCborEncoding4(reference_script.bytes)
|
|
2607
|
+
};
|
|
2608
|
+
case "plutusV2":
|
|
2609
|
+
return {
|
|
2610
|
+
type: "PlutusV2",
|
|
2611
|
+
script: applyDoubleCborEncoding4(reference_script.bytes)
|
|
2612
|
+
};
|
|
2613
|
+
case "plutusV3":
|
|
2614
|
+
return {
|
|
2615
|
+
type: "PlutusV3",
|
|
2616
|
+
script: applyDoubleCborEncoding4(reference_script.bytes)
|
|
2617
|
+
};
|
|
2618
|
+
default:
|
|
2619
|
+
return void 0;
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2622
|
+
};
|
|
2410
2623
|
export {
|
|
2411
2624
|
Blockfrost,
|
|
2412
2625
|
Emulator,
|