@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.
Files changed (3) hide show
  1. package/dist/index.cjs +418 -205
  2. package/dist/index.js +344 -131
  3. package/package.json +4 -4
package/dist/index.cjs CHANGED
@@ -45,14 +45,14 @@ module.exports = __toCommonJS(src_exports);
45
45
  // src/core.ts
46
46
  var CML = __toESM(require("@anastasia-labs/cardano-multiplatform-lib-nodejs"), 1);
47
47
 
48
- // src/blockfrost.ts
48
+ // src/blockfrost/blockfrost.ts
49
49
  var import_core_utils = require("@lucid-evolution/core-utils");
50
50
  var import_utils = require("@lucid-evolution/utils");
51
51
 
52
52
  // package.json
53
53
  var package_default = {
54
54
  name: "@lucid-evolution/provider",
55
- version: "0.1.43",
55
+ version: "0.1.45",
56
56
  description: "",
57
57
  main: "./dist/index.js",
58
58
  types: "./dist/index.d.ts",
@@ -100,7 +100,8 @@ var package_default = {
100
100
  }
101
101
  };
102
102
 
103
- // src/blockfrost.ts
103
+ // src/blockfrost/blockfrost.ts
104
+ var import_effect = require("effect");
104
105
  var Blockfrost = class {
105
106
  url;
106
107
  projectId;
@@ -326,6 +327,11 @@ var Blockfrost = class {
326
327
  type: "PlutusV2",
327
328
  script: (0, import_utils.applyDoubleCborEncoding)(script)
328
329
  };
330
+ case "plutusV3":
331
+ return {
332
+ type: "PlutusV3",
333
+ script: (0, import_utils.applyDoubleCborEncoding)(script)
334
+ };
329
335
  }
330
336
  })() : void 0
331
337
  };
@@ -336,19 +342,9 @@ var Blockfrost = class {
336
342
  return utxos;
337
343
  }
338
344
  async evaluateTx(tx, additionalUTxOs) {
339
- const additionalUTxOSet = (additionalUTxOs || []).map((utxo) => [
340
- { txId: utxo.txHash, index: utxo.outputIndex },
341
- {
342
- address: utxo.address,
343
- value: { coins: utxo.assets.lovelace, assets: utxo.assets.restAssets },
344
- datum_hash: utxo.datumHash,
345
- datum: utxo.datum,
346
- script: utxo.scriptRef
347
- }
348
- ]);
349
345
  const payload = {
350
346
  cbor: tx,
351
- additionalUTxOSet
347
+ additionalUtxoSet: toAditionalUTXOs(additionalUTxOs)
352
348
  };
353
349
  const res = await fetch(`${this.url}/utils/txs/evaluate/utxos`, {
354
350
  method: "POST",
@@ -357,10 +353,7 @@ var Blockfrost = class {
357
353
  project_id: this.projectId,
358
354
  lucid
359
355
  },
360
- body: JSON.stringify(
361
- payload,
362
- (_, value) => typeof value === "bigint" ? value.toString() : value
363
- )
356
+ body: JSON.stringify(payload)
364
357
  }).then((res2) => res2.json());
365
358
  if (!res || res.error) {
366
359
  const message = res?.status_code === 400 ? res.message : `Could not evaluate the transaction: ${JSON.stringify(res)}`;
@@ -424,17 +417,55 @@ function datumJsonToCbor(json) {
424
417
  }
425
418
  var handleRateLimit = async (count) => {
426
419
  if (count % 100 === 0) {
427
- await (0, import_core_utils.sleep)(1e3);
420
+ await (0, import_core_utils.sleep)(5e3);
428
421
  } else if (count % 10 === 0) {
429
- await (0, import_core_utils.sleep)(100);
422
+ await (0, import_core_utils.sleep)(500);
430
423
  }
431
424
  };
432
425
  var lucid = package_default.version;
426
+ var toAditionalUTXOs = (utxos) => (utxos || []).map((utxo) => [
427
+ {
428
+ txId: utxo.txHash,
429
+ index: utxo.outputIndex
430
+ },
431
+ {
432
+ address: utxo.address,
433
+ value: {
434
+ coins: Number(utxo.assets["lovelace"]),
435
+ assets: fromAssets(utxo.assets)
436
+ },
437
+ datumHash: utxo.datumHash,
438
+ datum: utxo.datum,
439
+ script: toTxOutScript(utxo.scriptRef)
440
+ }
441
+ ]);
442
+ var toTxOutScript = (scriptRef) => {
443
+ if (scriptRef) {
444
+ switch (scriptRef.type) {
445
+ case "PlutusV1":
446
+ return { "plutus:v1": scriptRef.script };
447
+ case "PlutusV2":
448
+ return { "plutus:v2": scriptRef.script };
449
+ case "PlutusV3":
450
+ return { "plutus:v3": scriptRef.script };
451
+ default:
452
+ return void 0;
453
+ }
454
+ }
455
+ };
456
+ var fromAssets = (assets) => (0, import_effect.pipe)(
457
+ import_effect.Record.remove(assets, "lovelace"),
458
+ import_effect.Record.mapEntries((amount, unit) => [
459
+ unit.length === 56 ? unit.slice(0, 56) : unit.slice(0, 56) + "." + unit.slice(56),
460
+ Number(amount)
461
+ ]),
462
+ (r) => import_effect.Record.isEmptyRecord(r) ? void 0 : r
463
+ );
433
464
 
434
465
  // src/kupmios/kupmios.ts
435
466
  var import_utils2 = require("@lucid-evolution/utils");
436
467
  var S2 = __toESM(require("@effect/schema/Schema"), 1);
437
- var import_effect = require("effect");
468
+ var import_effect2 = require("effect");
438
469
 
439
470
  // src/kupmios/schema.ts
440
471
  var S = __toESM(require("@effect/schema/Schema"), 1);
@@ -455,6 +486,51 @@ var TupleNumberFromString = S.compose(
455
486
  );
456
487
  var ProtocolParametersSchema = S.Struct({
457
488
  minFeeCoefficient: S.Number,
489
+ minFeeReferenceScripts: S.Struct({
490
+ base: S.Number,
491
+ range: S.Number,
492
+ multiplier: S.Number
493
+ }),
494
+ maxReferenceScriptsSize: S.Struct({
495
+ bytes: S.Number
496
+ }),
497
+ stakePoolVotingThresholds: S.Struct({
498
+ noConfidence: TupleNumberFromString,
499
+ constitutionalCommittee: S.Struct({
500
+ default: TupleNumberFromString,
501
+ stateOfNoConfidence: TupleNumberFromString
502
+ }),
503
+ hardForkInitiation: TupleNumberFromString,
504
+ protocolParametersUpdate: S.Struct({
505
+ security: TupleNumberFromString
506
+ })
507
+ }),
508
+ delegateRepresentativeVotingThresholds: S.Struct({
509
+ noConfidence: TupleNumberFromString,
510
+ constitutionalCommittee: S.Struct({
511
+ default: TupleNumberFromString,
512
+ stateOfNoConfidence: TupleNumberFromString
513
+ }),
514
+ constitution: TupleNumberFromString,
515
+ hardForkInitiation: TupleNumberFromString,
516
+ protocolParametersUpdate: S.Struct({
517
+ network: TupleNumberFromString,
518
+ economic: TupleNumberFromString,
519
+ technical: TupleNumberFromString,
520
+ governance: TupleNumberFromString
521
+ }),
522
+ treasuryWithdrawals: TupleNumberFromString
523
+ }),
524
+ constitutionalCommitteeMinSize: S.Number,
525
+ constitutionalCommitteeMaxTermLength: S.Number,
526
+ governanceActionLifetime: S.Number,
527
+ governanceActionDeposit: S.Struct({
528
+ ada: LovelaceAsset
529
+ }),
530
+ delegateRepresentativeDeposit: S.Struct({
531
+ ada: LovelaceAsset
532
+ }),
533
+ delegateRepresentativeMaxIdleTime: S.Number,
458
534
  minFeeConstant: S.Struct({ ada: LovelaceAsset }),
459
535
  maxBlockBodySize: S.Struct({ bytes: S.Number }),
460
536
  maxBlockHeaderSize: S.Struct({ bytes: S.Number }),
@@ -471,7 +547,8 @@ var ProtocolParametersSchema = S.Struct({
471
547
  minUtxoDepositCoefficient: S.Number,
472
548
  plutusCostModels: S.Struct({
473
549
  "plutus:v1": S.Array(S.Number),
474
- "plutus:v2": S.Array(S.Number)
550
+ "plutus:v2": S.Array(S.Number),
551
+ "plutus:v3": S.Array(S.Number)
475
552
  }),
476
553
  scriptExecutionPrices: S.Struct({
477
554
  memory: TupleNumberFromString,
@@ -504,11 +581,16 @@ var KupoUTxO = S.Struct({
504
581
  slot_no: S.Number,
505
582
  header_hash: S.String
506
583
  }),
507
- spent_at: S.NullOr(S.Number)
584
+ spent_at: S.NullOr(
585
+ S.Struct({
586
+ slot_no: S.Number,
587
+ header_hash: S.String
588
+ })
589
+ )
508
590
  });
509
591
  var KupoScriptSchema = S.NullOr(
510
592
  S.Struct({
511
- language: S.Literal("native", "plutus:v1", "plutus:v2"),
593
+ language: S.Literal("native", "plutus:v1", "plutus:v2", "plutus:v3"),
512
594
  script: S.String
513
595
  })
514
596
  );
@@ -526,7 +608,8 @@ var KupoDelegation = S.NullOr(
526
608
 
527
609
  // src/kupmios/kupmios.ts
528
610
  var import_platform = require("@effect/platform");
529
- var KupmiosError = class extends import_effect.Data.TaggedError("KupmiosError") {
611
+ var import_schema = require("@effect/schema");
612
+ var KupmiosError = class extends import_effect2.Data.TaggedError("KupmiosError") {
530
613
  get message() {
531
614
  return `${this.cause}`;
532
615
  }
@@ -556,13 +639,13 @@ var Kupmios = class {
556
639
  ProtocolParametersSchema
557
640
  );
558
641
  const program = fetchOgmiosParse(this.ogmiosUrl, data, schema).pipe(
559
- import_effect.Effect.flatMap(
560
- (response) => "error" in response ? kupmiosError(response.error) : import_effect.Effect.succeed(response.result)
642
+ import_effect2.Effect.flatMap(
643
+ (response) => "error" in response ? kupmiosError(response.error) : import_effect2.Effect.succeed(response.result)
561
644
  ),
562
- import_effect.Effect.timeout(1e4),
563
- import_effect.Effect.catchAll(kupmiosError)
645
+ import_effect2.Effect.timeout(1e4),
646
+ import_effect2.Effect.catchAll(kupmiosError)
564
647
  );
565
- const result = await import_effect.Effect.runPromise(program);
648
+ const result = await import_effect2.Effect.runPromise(program);
566
649
  return toProtocolParameters(result);
567
650
  }
568
651
  async getUtxos(addressOrCredential) {
@@ -571,11 +654,11 @@ var Kupmios = class {
571
654
  const pattern = `${this.kupoUrl}/matches/${queryPredicate}${isAddress ? "" : "/*"}?unspent`;
572
655
  const schema = S2.Array(KupoUTxO);
573
656
  const program = fetchKupoParse(pattern, schema).pipe(
574
- import_effect.Effect.flatMap((u) => kupmiosUtxosToUtxos(this.kupoUrl, u)),
575
- import_effect.Effect.timeout(1e4),
576
- import_effect.Effect.catchAll(kupmiosError)
657
+ import_effect2.Effect.flatMap((u) => kupmiosUtxosToUtxos(this.kupoUrl, u)),
658
+ import_effect2.Effect.timeout(1e4),
659
+ import_effect2.Effect.catchAll(kupmiosError)
577
660
  );
578
- const utxos = await import_effect.Effect.runPromise(program);
661
+ const utxos = await import_effect2.Effect.runPromise(program);
579
662
  return utxos;
580
663
  }
581
664
  async getUtxosWithUnit(addressOrCredential, unit) {
@@ -585,11 +668,11 @@ var Kupmios = class {
585
668
  const pattern = `${this.kupoUrl}/matches/${queryPredicate}${isAddress ? "" : "/*"}?unspent&policy_id=${policyId}${assetName ? `&asset_name=${assetName}` : ""}`;
586
669
  const schema = S2.Array(KupoUTxO);
587
670
  const program = fetchKupoParse(pattern, schema).pipe(
588
- import_effect.Effect.flatMap((u) => kupmiosUtxosToUtxos(this.kupoUrl, u)),
589
- import_effect.Effect.timeout(1e4),
590
- import_effect.Effect.catchAll(kupmiosError)
671
+ import_effect2.Effect.flatMap((u) => kupmiosUtxosToUtxos(this.kupoUrl, u)),
672
+ import_effect2.Effect.timeout(1e4),
673
+ import_effect2.Effect.catchAll(kupmiosError)
591
674
  );
592
- const utxos = await import_effect.Effect.runPromise(program);
675
+ const utxos = await import_effect2.Effect.runPromise(program);
593
676
  return utxos;
594
677
  }
595
678
  async getUtxoByUnit(unit) {
@@ -597,11 +680,11 @@ var Kupmios = class {
597
680
  const pattern = `${this.kupoUrl}/matches/${policyId}.${assetName ? `${assetName}` : "*"}?unspent`;
598
681
  const schema = S2.Array(KupoUTxO);
599
682
  const program = fetchKupoParse(pattern, schema).pipe(
600
- import_effect.Effect.flatMap((u) => kupmiosUtxosToUtxos(this.kupoUrl, u)),
601
- import_effect.Effect.timeout(1e4),
602
- import_effect.Effect.catchAll(kupmiosError)
683
+ import_effect2.Effect.flatMap((u) => kupmiosUtxosToUtxos(this.kupoUrl, u)),
684
+ import_effect2.Effect.timeout(1e4),
685
+ import_effect2.Effect.catchAll(kupmiosError)
603
686
  );
604
- const utxos = await import_effect.Effect.runPromise(program);
687
+ const utxos = await import_effect2.Effect.runPromise(program);
605
688
  if (utxos.length > 1) {
606
689
  throw new Error("Unit needs to be an NFT or only held by one address.");
607
690
  }
@@ -613,16 +696,16 @@ var Kupmios = class {
613
696
  ];
614
697
  const mkPattern = (txHash) => `${this.kupoUrl}/matches/*@${txHash}?unspent`;
615
698
  const schema = S2.Array(KupoUTxO);
616
- const program = import_effect.Effect.forEach(
699
+ const program = import_effect2.Effect.forEach(
617
700
  queryHashes,
618
701
  (txHash) => fetchKupoParse(mkPattern(txHash), schema).pipe(
619
- import_effect.Effect.flatMap((u) => kupmiosUtxosToUtxos(this.kupoUrl, u)),
620
- import_effect.Effect.timeout(1e4),
621
- import_effect.Effect.catchAll(kupmiosError)
702
+ import_effect2.Effect.flatMap((u) => kupmiosUtxosToUtxos(this.kupoUrl, u)),
703
+ import_effect2.Effect.timeout(1e4),
704
+ import_effect2.Effect.catchAll(kupmiosError)
622
705
  )
623
706
  );
624
- const utxos = await import_effect.Effect.runPromise(program);
625
- return import_effect.Array.flatten(utxos).filter(
707
+ const utxos = await import_effect2.Effect.runPromise(program);
708
+ return import_effect2.Array.flatten(utxos).filter(
626
709
  (utxo) => outRefs.some(
627
710
  (outRef) => utxo.txHash === outRef.txHash && utxo.outputIndex === outRef.outputIndex
628
711
  )
@@ -637,13 +720,13 @@ var Kupmios = class {
637
720
  };
638
721
  const schema = JSONRPCSchema(KupoDelegation);
639
722
  const program = fetchOgmiosParse(this.ogmiosUrl, data, schema).pipe(
640
- import_effect.Effect.flatMap(
641
- (response) => "error" in response ? kupmiosError(response.error) : import_effect.Effect.succeed(response.result)
723
+ import_effect2.Effect.flatMap(
724
+ (response) => "error" in response ? kupmiosError(response.error) : import_effect2.Effect.succeed(response.result)
642
725
  ),
643
- import_effect.Effect.timeout(1e4),
644
- import_effect.Effect.catchAll(kupmiosError)
726
+ import_effect2.Effect.timeout(1e4),
727
+ import_effect2.Effect.catchAll(kupmiosError)
645
728
  );
646
- const result = await import_effect.Effect.runPromise(program);
729
+ const result = await import_effect2.Effect.runPromise(program);
647
730
  const delegation = result ? Object.values(result)[0] : null;
648
731
  return {
649
732
  poolId: delegation?.delegate?.id || null,
@@ -654,28 +737,28 @@ var Kupmios = class {
654
737
  const pattern = `${this.kupoUrl}/datums/${datumHash}`;
655
738
  const schema = KupoDatumSchema;
656
739
  const program = fetchKupoParse(pattern, schema).pipe(
657
- import_effect.Effect.timeout(1e4),
658
- import_effect.Effect.flatMap(import_effect.Effect.fromNullable),
659
- import_effect.Effect.catchAll(kupmiosError)
740
+ import_effect2.Effect.timeout(1e4),
741
+ import_effect2.Effect.flatMap(import_effect2.Effect.fromNullable),
742
+ import_effect2.Effect.catchAll(kupmiosError)
660
743
  );
661
- const result = await import_effect.Effect.runPromise(program);
744
+ const result = await import_effect2.Effect.runPromise(program);
662
745
  return result.datum;
663
746
  }
664
747
  async awaitTx(txHash, checkInterval = 2e4) {
665
- const pattern = `${this.kupoUrl}/matches/*@${txHash}?unspent`;
748
+ const pattern = `${this.kupoUrl}/matches/*@${txHash}`;
666
749
  const schema = S2.Array(KupoUTxO).annotations({
667
750
  identifier: "Array<KupmiosSchema.KupoUTxO>"
668
751
  });
669
752
  const program = fetchKupoParse(pattern, schema).pipe(
670
- import_effect.Effect.repeat({
671
- schedule: import_effect.Schedule.exponential(checkInterval),
753
+ import_effect2.Effect.repeat({
754
+ schedule: import_effect2.Schedule.exponential(checkInterval),
672
755
  until: (result) => result.length > 0
673
756
  }),
674
- import_effect.Effect.timeout(16e4),
675
- import_effect.Effect.catchAll(kupmiosError),
676
- import_effect.Effect.as(true)
757
+ import_effect2.Effect.timeout(16e4),
758
+ import_effect2.Effect.catchAll(kupmiosError),
759
+ import_effect2.Effect.as(true)
677
760
  );
678
- return await import_effect.Effect.runPromise(program);
761
+ return await import_effect2.Effect.runPromise(program);
679
762
  }
680
763
  async submitTx(cbor) {
681
764
  const data = {
@@ -694,13 +777,13 @@ var Kupmios = class {
694
777
  })
695
778
  );
696
779
  const program = fetchOgmiosParse(this.ogmiosUrl, data, schema).pipe(
697
- import_effect.Effect.flatMap(
698
- (response) => "error" in response ? import_effect.Effect.fail(response.error) : import_effect.Effect.succeed(response)
780
+ import_effect2.Effect.flatMap(
781
+ (response) => "error" in response ? import_effect2.Effect.fail(response.error) : import_effect2.Effect.succeed(response)
699
782
  ),
700
- import_effect.Effect.timeout(1e4),
701
- import_effect.Effect.catchAll(kupmiosError)
783
+ import_effect2.Effect.timeout(1e4),
784
+ import_effect2.Effect.catchAll(kupmiosError)
702
785
  );
703
- const { result } = await import_effect.Effect.runPromise(program);
786
+ const { result } = await import_effect2.Effect.runPromise(program);
704
787
  return result.transaction.id;
705
788
  }
706
789
  async evaluateTx(tx, additionalUTxOs) {
@@ -746,13 +829,13 @@ var Kupmios = class {
746
829
  )
747
830
  );
748
831
  const program = fetchOgmiosParse(this.ogmiosUrl, data, schema).pipe(
749
- import_effect.Effect.flatMap(
750
- (response) => "error" in response ? kupmiosError(response.error) : import_effect.Effect.succeed(response.result)
832
+ import_effect2.Effect.flatMap(
833
+ (response) => "error" in response ? kupmiosError(response.error) : import_effect2.Effect.succeed(response.result)
751
834
  ),
752
- import_effect.Effect.timeout(1e4),
753
- import_effect.Effect.catchAll(kupmiosError)
835
+ import_effect2.Effect.timeout(1e4),
836
+ import_effect2.Effect.catchAll(kupmiosError)
754
837
  );
755
- const result = await import_effect.Effect.runPromise(program);
838
+ const result = await import_effect2.Effect.runPromise(program);
756
839
  const evalRedeemers = result.map((item) => ({
757
840
  ex_units: {
758
841
  mem: item.budget.memory,
@@ -764,37 +847,43 @@ var Kupmios = class {
764
847
  return evalRedeemers;
765
848
  }
766
849
  };
767
- var getDatumEffect = (kupoUrl, datum_type, datum_hash) => import_effect.Effect.gen(function* () {
850
+ var getDatumEffect = (kupoUrl, datum_type, datum_hash) => import_effect2.Effect.gen(function* () {
768
851
  if (datum_type === "inline" && datum_hash) {
769
852
  const pattern = `${kupoUrl}/datums/${datum_hash}`;
770
853
  const schema = KupoDatumSchema;
771
854
  return yield* fetchKupoParse(pattern, schema).pipe(
772
- import_effect.Effect.flatMap(import_effect.Effect.fromNullable),
773
- import_effect.Effect.map((result) => result.datum),
774
- import_effect.Effect.timeout(1e4)
855
+ import_effect2.Effect.flatMap(import_effect2.Effect.fromNullable),
856
+ import_effect2.Effect.map((result) => result.datum),
857
+ import_effect2.Effect.timeout(1e4)
775
858
  );
776
- } else return null;
859
+ } else return void 0;
777
860
  });
778
- var getScriptEffect = (kupoUrl, script_hash) => import_effect.Effect.gen(function* () {
861
+ var getScriptEffect = (kupoUrl, script_hash) => import_effect2.Effect.gen(function* () {
779
862
  if (script_hash) {
780
863
  const pattern = `${kupoUrl}/scripts/${script_hash}`;
781
864
  const schema = KupoScriptSchema;
782
- return yield* (0, import_effect.pipe)(
865
+ return yield* (0, import_effect2.pipe)(
783
866
  fetchKupoParse(pattern, schema),
784
- import_effect.Effect.flatMap(import_effect.Effect.fromNullable),
785
- import_effect.Effect.timeout(1e4),
786
- import_effect.Effect.map(({ language, script }) => {
867
+ import_effect2.Effect.flatMap(import_effect2.Effect.fromNullable),
868
+ import_effect2.Effect.timeout(1e4),
869
+ import_effect2.Effect.map(({ language, script }) => {
787
870
  switch (language) {
788
871
  case "native":
789
- return { type: "Native", script };
872
+ return void 0;
790
873
  case "plutus:v1":
791
- return { type: "PlutusV1", script };
874
+ return {
875
+ type: "PlutusV1",
876
+ script: (0, import_utils2.applyDoubleCborEncoding)(script)
877
+ };
792
878
  case "plutus:v2":
793
- return { type: "PlutusV2", script };
879
+ return {
880
+ type: "PlutusV2",
881
+ script: (0, import_utils2.applyDoubleCborEncoding)(script)
882
+ };
794
883
  }
795
884
  })
796
885
  );
797
- } else return null;
886
+ } else return void 0;
798
887
  });
799
888
  var toAssets = (value) => {
800
889
  const assets = { lovelace: BigInt(value.coins) };
@@ -835,46 +924,56 @@ var toProtocolParameters = (result) => {
835
924
  index.toString(),
836
925
  value
837
926
  ])
927
+ ),
928
+ PlutusV3: Object.fromEntries(
929
+ result.plutusCostModels["plutus:v3"].map((value, index) => [
930
+ index.toString(),
931
+ value
932
+ ])
838
933
  )
839
934
  }
840
935
  };
841
936
  };
842
- var fetchOgmiosParse = (url, data, schema) => (0, import_effect.pipe)(
937
+ var fetchOgmiosParse = (url, data, schema) => (0, import_effect2.pipe)(
843
938
  import_platform.HttpClientRequest.post(url),
844
939
  import_platform.HttpClientRequest.jsonBody(data),
845
- import_effect.Effect.flatMap(import_platform.HttpClient.fetch),
940
+ import_effect2.Effect.flatMap(import_platform.HttpClient.fetch),
846
941
  import_platform.HttpClientResponse.json,
847
- import_effect.Effect.flatMap(S2.decodeUnknown(schema))
848
- // Effect.catchTag("ParseError", (e) =>
849
- // Effect.fail(ArrayFormatter.formatIssueSync(e.issue)),
850
- // ),
942
+ import_effect2.Effect.flatMap(
943
+ S2.decodeUnknown(schema, { onExcessProperty: "error", errors: "first" })
944
+ ),
945
+ import_effect2.Effect.catchTag(
946
+ "ParseError",
947
+ (e) => import_effect2.Effect.fail(import_schema.ArrayFormatter.formatErrorSync(e))
948
+ )
851
949
  // Effect.scoped
852
950
  );
853
- var fetchKupoParse = (url, schema) => (0, import_effect.pipe)(
951
+ var fetchKupoParse = (url, schema) => (0, import_effect2.pipe)(
854
952
  import_platform.HttpClientRequest.get(url),
855
953
  import_platform.HttpClient.fetchOk,
856
954
  import_platform.HttpClientResponse.json,
857
- import_effect.Effect.flatMap(S2.decodeUnknown(schema))
858
- // Effect.catchTag("ParseError", (e) =>
859
- // Effect.fail(ArrayFormatter.formatIssueSync(e.issue)),
860
- // ),
955
+ import_effect2.Effect.flatMap(S2.decodeUnknown(schema, { onExcessProperty: "error" })),
956
+ import_effect2.Effect.catchTag(
957
+ "ParseError",
958
+ (e) => import_effect2.Effect.fail(import_schema.ArrayFormatter.formatErrorSync(e))
959
+ )
861
960
  // Effect.scoped
862
961
  );
863
- var kupmiosUtxosToUtxos = (kupoURL, utxos) => import_effect.Effect.forEach(
962
+ var kupmiosUtxosToUtxos = (kupoURL, utxos) => import_effect2.Effect.forEach(
864
963
  utxos,
865
964
  (utxo) => {
866
- return (0, import_effect.pipe)(
867
- import_effect.Effect.all([
965
+ return (0, import_effect2.pipe)(
966
+ import_effect2.Effect.all([
868
967
  getDatumEffect(kupoURL, utxo.datum_type, utxo.datum_hash),
869
968
  getScriptEffect(kupoURL, utxo.script_hash)
870
969
  ]),
871
- import_effect.Effect.map(
970
+ import_effect2.Effect.map(
872
971
  ([datum, script]) => ({
873
972
  txHash: utxo.transaction_id,
874
973
  outputIndex: utxo.output_index,
875
974
  address: utxo.address,
876
975
  assets: toAssets(utxo.value),
877
- datumHash: utxo.datum_type === "hash" ? utxo.datum_hash : null,
976
+ datumHash: utxo.datum_type === "hash" ? utxo.datum_hash : void 0,
878
977
  datum,
879
978
  scriptRef: script
880
979
  })
@@ -1231,12 +1330,27 @@ It does not exist or was already spent.`
1231
1330
  3: "Reward"
1232
1331
  };
1233
1332
  const collected = [];
1234
- for (let i = 0; i < (witnesses.redeemers()?.to_js_value().len() || 0); i++) {
1235
- const redeemer = witnesses.redeemers().to_js_value().get(i);
1236
- collected.push({
1237
- tag: tagMap[redeemer.tag().kind()],
1238
- index: parseInt(redeemer.index().to_str())
1239
- });
1333
+ const redeemers2 = witnesses.redeemers();
1334
+ const arrLegacyRedeemer = redeemers2?.as_arr_legacy_redeemer();
1335
+ if (arrLegacyRedeemer) {
1336
+ for (let i = 0; i < (arrLegacyRedeemer.len() || 0); i++) {
1337
+ const redeemer = arrLegacyRedeemer.get(i);
1338
+ collected.push({
1339
+ tag: tagMap[redeemer.tag()],
1340
+ index: Number(redeemer.index())
1341
+ });
1342
+ }
1343
+ }
1344
+ const mapRedeemerKeyToRedeemerVal = redeemers2?.as_map_redeemer_key_to_redeemer_val();
1345
+ if (mapRedeemerKeyToRedeemerVal) {
1346
+ const keys = mapRedeemerKeyToRedeemerVal.keys();
1347
+ for (let i = 0; i < (keys.len() || 0); i++) {
1348
+ const key = keys.get(i);
1349
+ collected.push({
1350
+ tag: tagMap[key.tag()],
1351
+ index: Number(key.index())
1352
+ });
1353
+ }
1240
1354
  }
1241
1355
  return collected;
1242
1356
  })();
@@ -1618,7 +1732,7 @@ var Maestro = class {
1618
1732
  this.turboSubmit = turboSubmit;
1619
1733
  }
1620
1734
  async getProtocolParameters() {
1621
- const timestampedResult = await fetch(`${this.url}/protocol-params`, {
1735
+ const timestampedResult = await fetch(`${this.url}/protocol-parameters`, {
1622
1736
  headers: this.commonHeaders()
1623
1737
  }).then((res) => res.json());
1624
1738
  const result = timestampedResult.data;
@@ -1626,37 +1740,39 @@ var Maestro = class {
1626
1740
  const forwardSlashIndex = str.indexOf("/");
1627
1741
  return parseInt(str.slice(0, forwardSlashIndex)) / parseInt(str.slice(forwardSlashIndex + 1));
1628
1742
  };
1629
- const renameKeysAndSort = (obj, newKeys) => {
1630
- const entries = Object.keys(obj).sort().map((key) => {
1631
- const newKey = newKeys[key] || key;
1632
- return {
1633
- [newKey]: Object.fromEntries(
1634
- Object.entries(obj[key]).sort(
1635
- ([k, _v], [k2, _v2]) => k.localeCompare(k2)
1636
- )
1637
- )
1638
- };
1639
- });
1640
- return Object.assign({}, ...entries);
1641
- };
1642
1743
  return {
1643
1744
  minFeeA: parseInt(result.min_fee_coefficient),
1644
- minFeeB: parseInt(result.min_fee_constant),
1645
- maxTxSize: parseInt(result.max_tx_size),
1646
- maxValSize: parseInt(result.max_value_size),
1647
- keyDeposit: BigInt(result.stake_key_deposit),
1648
- poolDeposit: BigInt(result.pool_deposit),
1649
- priceMem: decimalFromRationalString(result.prices.memory),
1650
- priceStep: decimalFromRationalString(result.prices.steps),
1745
+ minFeeB: parseInt(result.min_fee_constant.ada.lovelace),
1746
+ maxTxSize: parseInt(result.max_transaction_size.bytes),
1747
+ maxValSize: parseInt(result.max_value_size.bytes),
1748
+ keyDeposit: BigInt(result.stake_credential_deposit.ada.lovelace),
1749
+ poolDeposit: BigInt(result.stake_pool_deposit.ada.lovelace),
1750
+ priceMem: decimalFromRationalString(
1751
+ result.script_execution_prices.memory
1752
+ ),
1753
+ priceStep: decimalFromRationalString(result.script_execution_prices.cpu),
1651
1754
  maxTxExMem: BigInt(result.max_execution_units_per_transaction.memory),
1652
- maxTxExSteps: BigInt(result.max_execution_units_per_transaction.steps),
1653
- coinsPerUtxoByte: BigInt(result.coins_per_utxo_byte),
1755
+ maxTxExSteps: BigInt(result.max_execution_units_per_transaction.cpu),
1756
+ coinsPerUtxoByte: BigInt(result.min_utxo_deposit_coefficient),
1654
1757
  collateralPercentage: parseInt(result.collateral_percentage),
1655
1758
  maxCollateralInputs: parseInt(result.max_collateral_inputs),
1656
- costModels: renameKeysAndSort(result.cost_models, {
1657
- "plutus:v1": "PlutusV1",
1658
- "plutus:v2": "PlutusV2"
1659
- })
1759
+ costModels: {
1760
+ PlutusV1: Object.fromEntries(
1761
+ result.plutus_cost_models.plutus_v1.map(
1762
+ (value, index) => [index.toString(), value]
1763
+ )
1764
+ ),
1765
+ PlutusV2: Object.fromEntries(
1766
+ result.plutus_cost_models.plutus_v2.map(
1767
+ (value, index) => [index.toString(), value]
1768
+ )
1769
+ ),
1770
+ PlutusV3: Object.fromEntries(
1771
+ result.plutus_cost_models.plutus_v2.map(
1772
+ (value, index) => [index.toString(), value]
1773
+ )
1774
+ )
1775
+ }
1660
1776
  };
1661
1777
  }
1662
1778
  async getUtxosInternal(addressOrCredential, unit) {
@@ -1839,10 +1955,7 @@ var Maestro = class {
1839
1955
  address: result.address,
1840
1956
  datumHash: result.datum ? result.datum.type == "inline" ? void 0 : result.datum.hash : void 0,
1841
1957
  datum: result.datum?.bytes,
1842
- scriptRef: result.reference_script ? result.reference_script.type == "native" ? void 0 : {
1843
- type: result.reference_script.type == "plutusv1" ? "PlutusV1" : "PlutusV2",
1844
- script: (0, import_utils5.applyDoubleCborEncoding)(result.reference_script.bytes)
1845
- } : void 0
1958
+ scriptRef: toScriptRef(result.reference_script)
1846
1959
  };
1847
1960
  }
1848
1961
  async getAllPagesData(getResponse, qry, paramsGiven, errorMsg) {
@@ -1893,6 +2006,29 @@ var Maestro = class {
1893
2006
  return result;
1894
2007
  }
1895
2008
  };
2009
+ var toScriptRef = (reference_script) => {
2010
+ if (reference_script && reference_script.bytes) {
2011
+ switch (reference_script.type) {
2012
+ case "plutusv1":
2013
+ return {
2014
+ type: "PlutusV1",
2015
+ script: (0, import_utils5.applyDoubleCborEncoding)(reference_script.bytes)
2016
+ };
2017
+ case "plutusv2":
2018
+ return {
2019
+ type: "PlutusV2",
2020
+ script: (0, import_utils5.applyDoubleCborEncoding)(reference_script.bytes)
2021
+ };
2022
+ case "plutusv3":
2023
+ return {
2024
+ type: "PlutusV3",
2025
+ script: (0, import_utils5.applyDoubleCborEncoding)(reference_script.bytes)
2026
+ };
2027
+ default:
2028
+ return void 0;
2029
+ }
2030
+ }
2031
+ };
1896
2032
  var lucid2 = package_default.version;
1897
2033
 
1898
2034
  // src/koios/koios.ts
@@ -1903,6 +2039,28 @@ var import_utils6 = require("@lucid-evolution/utils");
1903
2039
  // src/koios/schema.ts
1904
2040
  var S3 = __toESM(require("@effect/schema/Schema"), 1);
1905
2041
  var ProtocolParametersSchema2 = S3.Struct({
2042
+ pvt_motion_no_confidence: S3.Number,
2043
+ pvt_committee_normal: S3.Number,
2044
+ pvt_committee_no_confidence: S3.Number,
2045
+ pvt_hard_fork_initiation: S3.Number,
2046
+ pvtpp_security_group: S3.Number,
2047
+ dvt_motion_no_confidence: S3.Number,
2048
+ dvt_committee_normal: S3.Number,
2049
+ dvt_committee_no_confidence: S3.Number,
2050
+ dvt_update_to_constitution: S3.Number,
2051
+ dvt_hard_fork_initiation: S3.Number,
2052
+ dvt_p_p_network_group: S3.Number,
2053
+ dvt_p_p_economic_group: S3.Number,
2054
+ dvt_p_p_technical_group: S3.Number,
2055
+ dvt_p_p_gov_group: S3.Number,
2056
+ dvt_treasury_withdrawal: S3.Number,
2057
+ committee_min_size: S3.Number,
2058
+ committee_max_term_length: S3.Number,
2059
+ gov_action_lifetime: S3.Number,
2060
+ gov_action_deposit: S3.NumberFromString,
2061
+ drep_deposit: S3.NumberFromString,
2062
+ drep_activity: S3.Number,
2063
+ min_fee_ref_script_cost_per_byte: S3.Number,
1906
2064
  epoch_no: S3.Number,
1907
2065
  min_fee_a: S3.Number,
1908
2066
  min_fee_b: S3.Number,
@@ -1926,7 +2084,8 @@ var ProtocolParametersSchema2 = S3.Struct({
1926
2084
  block_hash: S3.NullOr(S3.String),
1927
2085
  cost_models: S3.Struct({
1928
2086
  PlutusV1: S3.Array(S3.Number),
1929
- PlutusV2: S3.Array(S3.Number)
2087
+ PlutusV2: S3.Array(S3.Number),
2088
+ PlutusV3: S3.Array(S3.Number)
1930
2089
  }),
1931
2090
  price_mem: S3.Number,
1932
2091
  price_step: S3.Number,
@@ -1946,9 +2105,17 @@ var KoiosAssetSchema = S3.Struct({
1946
2105
  decimals: S3.Number,
1947
2106
  quantity: S3.String
1948
2107
  });
2108
+ var ReferenceScriptSchema = S3.Struct({
2109
+ hash: S3.NullOr(S3.String),
2110
+ size: S3.NullOr(S3.Number),
2111
+ type: S3.NullOr(S3.String),
2112
+ bytes: S3.NullOr(S3.String),
2113
+ value: S3.NullOr(S3.Object)
2114
+ });
1949
2115
  var KoiosUTxOSchema = S3.Struct({
1950
2116
  tx_hash: S3.String,
1951
2117
  tx_index: S3.Number,
2118
+ block_time: S3.Number,
1952
2119
  block_height: S3.NullOr(S3.Number),
1953
2120
  value: S3.String,
1954
2121
  datum_hash: S3.NullOr(S3.String),
@@ -1958,15 +2125,7 @@ var KoiosUTxOSchema = S3.Struct({
1958
2125
  value: S3.Object
1959
2126
  })
1960
2127
  ),
1961
- reference_script: S3.NullOr(
1962
- S3.Struct({
1963
- hash: S3.String,
1964
- size: S3.Number,
1965
- type: S3.String,
1966
- bytes: S3.String,
1967
- value: S3.NullOr(S3.Object)
1968
- })
1969
- ),
2128
+ reference_script: S3.NullOr(ReferenceScriptSchema),
1970
2129
  asset_list: S3.NullOr(S3.Array(KoiosAssetSchema))
1971
2130
  });
1972
2131
  var KoiosAddressInfoSchema = S3.Array(
@@ -1996,16 +2155,8 @@ var KoiosInputOutputSchema = S3.Struct({
1996
2155
  value: S3.Object
1997
2156
  })
1998
2157
  ),
1999
- reference_script: S3.NullOr(
2000
- S3.Struct({
2001
- hash: S3.String,
2002
- size: S3.Number,
2003
- type: S3.String,
2004
- bytes: S3.String,
2005
- value: S3.NullOr(S3.Object)
2006
- })
2007
- ),
2008
- asset_list: S3.Union(S3.Array(KoiosAssetSchema), S3.String)
2158
+ reference_script: S3.NullOr(ReferenceScriptSchema),
2159
+ asset_list: S3.Array(KoiosAssetSchema)
2009
2160
  });
2010
2161
  var KoiosTxInfoSchema = S3.Struct({
2011
2162
  tx_hash: S3.String,
@@ -2019,6 +2170,7 @@ var KoiosTxInfoSchema = S3.Struct({
2019
2170
  tx_size: S3.Number,
2020
2171
  total_output: S3.String,
2021
2172
  fee: S3.String,
2173
+ treasury_donation: S3.String,
2022
2174
  deposit: S3.String,
2023
2175
  invalid_before: S3.NullOr(S3.String),
2024
2176
  invalid_after: S3.NullOr(S3.String),
@@ -2088,12 +2240,18 @@ var KoiosTxInfoSchema = S3.Struct({
2088
2240
  })
2089
2241
  })
2090
2242
  )
2091
- )
2243
+ ),
2244
+ //TODO: add S.Struct
2245
+ // https://preprod.koios.rest/#post-/tx_info
2246
+ voting_procedures: S3.Array(S3.Object),
2247
+ //TODO: add S.Struct
2248
+ // https://preprod.koios.rest/#post-/tx_info
2249
+ proposal_procedures: S3.Object
2092
2250
  });
2093
2251
 
2094
2252
  // src/koios/koios.ts
2095
- var import_effect3 = require("effect");
2096
- var import_schema2 = require("@effect/schema");
2253
+ var import_effect4 = require("effect");
2254
+ var import_schema3 = require("@effect/schema");
2097
2255
 
2098
2256
  // src/fetch.ts
2099
2257
  var fetch_exports = {};
@@ -2103,27 +2261,27 @@ __export(fetch_exports, {
2103
2261
  ResponseError: () => ResponseError,
2104
2262
  fetchEffect: () => fetchEffect
2105
2263
  });
2106
- var import_effect2 = require("effect");
2107
- var FetchError = class extends import_effect2.Data.TaggedError("FetchError") {
2264
+ var import_effect3 = require("effect");
2265
+ var FetchError = class extends import_effect3.Data.TaggedError("FetchError") {
2108
2266
  };
2109
- var ResponseError = class extends import_effect2.Data.TaggedError("ResponseError") {
2267
+ var ResponseError = class extends import_effect3.Data.TaggedError("ResponseError") {
2110
2268
  };
2111
- var JsonError = class extends import_effect2.Data.TaggedError("JsonError") {
2269
+ var JsonError = class extends import_effect3.Data.TaggedError("JsonError") {
2112
2270
  };
2113
- var fetchEffect = (input, requestInit) => (0, import_effect2.pipe)(
2114
- import_effect2.Effect.tryPromise({
2271
+ var fetchEffect = (input, requestInit) => (0, import_effect3.pipe)(
2272
+ import_effect3.Effect.tryPromise({
2115
2273
  try: () => fetch(input, requestInit),
2116
2274
  catch: (error) => new FetchError({
2117
2275
  message: `${String(error)}. Please ensure the server is operational or check the validity of the input:${input}.`
2118
2276
  })
2119
2277
  }),
2120
- import_effect2.Effect.flatMap(
2278
+ import_effect3.Effect.flatMap(
2121
2279
  (response) => !response.ok ? new ResponseError({
2122
2280
  message: `${response.status} ${response.statusText}`
2123
- }) : import_effect2.Effect.succeed(response)
2281
+ }) : import_effect3.Effect.succeed(response)
2124
2282
  ),
2125
- import_effect2.Effect.flatMap(
2126
- (response) => import_effect2.Effect.tryPromise({
2283
+ import_effect3.Effect.flatMap(
2284
+ (response) => import_effect3.Effect.tryPromise({
2127
2285
  try: () => response.json(),
2128
2286
  catch: (error) => new JsonError({ message: String(error) })
2129
2287
  })
@@ -2140,7 +2298,17 @@ var Koios = class {
2140
2298
  const result = await fetch(`${this.baseUrl}/epoch_params?limit=1`).then(
2141
2299
  (res) => res.json()
2142
2300
  );
2143
- const param = S4.decodeUnknownSync(ProtocolParametersSchema2)(result[0]);
2301
+ const param = await (0, import_effect4.pipe)(
2302
+ S4.decodeUnknown(ProtocolParametersSchema2, {
2303
+ onExcessProperty: "error",
2304
+ errors: "first"
2305
+ })(result[0]),
2306
+ import_effect4.Effect.catchTag(
2307
+ "ParseError",
2308
+ (e) => import_effect4.Effect.fail(import_schema3.ArrayFormatter.formatErrorSync(e))
2309
+ ),
2310
+ import_effect4.Effect.runPromise
2311
+ );
2144
2312
  return {
2145
2313
  minFeeA: param.min_fee_a,
2146
2314
  minFeeB: param.min_fee_b,
@@ -2167,6 +2335,12 @@ var Koios = class {
2167
2335
  index.toString(),
2168
2336
  value
2169
2337
  ])
2338
+ ),
2339
+ PlutusV3: Object.fromEntries(
2340
+ param.cost_models.PlutusV3.map((value, index) => [
2341
+ index.toString(),
2342
+ value
2343
+ ])
2170
2344
  )
2171
2345
  }
2172
2346
  };
@@ -2184,9 +2358,17 @@ var Koios = class {
2184
2358
  method: "POST",
2185
2359
  body: JSON.stringify(body)
2186
2360
  }).then((res) => res.json());
2187
- const parsedResult = S4.decodeUnknownSync(KoiosAddressInfoSchema)(
2188
- result
2189
- )[0];
2361
+ const [parsedResult] = await (0, import_effect4.pipe)(
2362
+ S4.decodeUnknown(KoiosAddressInfoSchema, {
2363
+ onExcessProperty: "error",
2364
+ errors: "first"
2365
+ })(result),
2366
+ import_effect4.Effect.catchTag(
2367
+ "ParseError",
2368
+ (e) => import_effect4.Effect.fail(import_schema3.ArrayFormatter.formatErrorSync(e))
2369
+ ),
2370
+ import_effect4.Effect.runPromise
2371
+ );
2190
2372
  return parsedResult ? parsedResult.utxo_set.map(
2191
2373
  (koiosUTXO) => toUTxO(koiosUTXO, parsedResult.address)
2192
2374
  ) : [];
@@ -2235,9 +2417,10 @@ var Koios = class {
2235
2417
  throw new Error("Unit not found.");
2236
2418
  }
2237
2419
  async getUtxosByOutRef(outRefs) {
2238
- const utxos = [];
2239
2420
  const body = {
2240
- _tx_hashes: [...new Set(outRefs.map((outRef) => outRef.txHash))]
2421
+ _tx_hashes: [...new Set(outRefs.map((outRef) => outRef.txHash))],
2422
+ _assets: true,
2423
+ _scripts: true
2241
2424
  };
2242
2425
  const result = await fetch(`${this.baseUrl}/tx_info`, {
2243
2426
  headers: {
@@ -2247,26 +2430,39 @@ var Koios = class {
2247
2430
  method: "POST",
2248
2431
  body: JSON.stringify(body)
2249
2432
  }).then((res) => res.json());
2250
- const parsedResult = S4.decodeUnknownSync(S4.Array(KoiosTxInfoSchema))(
2251
- result
2252
- )[0];
2433
+ const [parsedResult] = await (0, import_effect4.pipe)(
2434
+ S4.decodeUnknown(S4.Array(KoiosTxInfoSchema), {
2435
+ onExcessProperty: "error",
2436
+ errors: "first"
2437
+ })(result),
2438
+ import_effect4.Effect.catchTag(
2439
+ "ParseError",
2440
+ (e) => import_effect4.Effect.fail(import_schema3.ArrayFormatter.formatErrorSync(e))
2441
+ ),
2442
+ import_effect4.Effect.runPromise
2443
+ );
2253
2444
  if (parsedResult) {
2254
- return parsedResult.outputs.map(
2445
+ const utxos = parsedResult.outputs.map(
2255
2446
  (koiosInputOutput) => toUTxO(
2256
2447
  {
2257
2448
  tx_hash: koiosInputOutput.tx_hash,
2258
2449
  tx_index: koiosInputOutput.tx_index,
2259
- block_height: null,
2450
+ block_time: 0,
2451
+ block_height: parsedResult.block_height,
2260
2452
  value: koiosInputOutput.value,
2261
2453
  datum_hash: koiosInputOutput.datum_hash,
2262
2454
  inline_datum: koiosInputOutput.inline_datum,
2263
2455
  reference_script: koiosInputOutput.reference_script,
2264
- //NOTE: Koios api returns collateral_output like asset_list: "[]", instead of asset_list: []
2265
- asset_list: typeof koiosInputOutput.asset_list === "string" ? [] : koiosInputOutput.asset_list
2456
+ asset_list: koiosInputOutput.asset_list
2266
2457
  },
2267
2458
  koiosInputOutput.payment_addr.bech32
2268
2459
  )
2269
2460
  );
2461
+ return utxos.filter(
2462
+ (utxo) => outRefs.some(
2463
+ (outRef) => utxo.txHash === outRef.txHash && utxo.outputIndex === outRef.outputIndex
2464
+ )
2465
+ );
2270
2466
  } else {
2271
2467
  return [];
2272
2468
  }
@@ -2322,24 +2518,24 @@ var Koios = class {
2322
2518
  method: "POST",
2323
2519
  body: JSON.stringify(body)
2324
2520
  };
2325
- const program = (0, import_effect3.pipe)(
2521
+ const program = (0, import_effect4.pipe)(
2326
2522
  fetchEffect(`${this.baseUrl}/tx_info`, request),
2327
- import_effect3.Effect.flatMap(
2523
+ import_effect4.Effect.flatMap(
2328
2524
  (json) => S4.decodeUnknown(S4.Array(KoiosTxInfoSchema))(json)
2329
2525
  ),
2330
- import_effect3.Effect.catchTag(
2526
+ import_effect4.Effect.catchTag(
2331
2527
  "ParseError",
2332
- (e) => import_effect3.Effect.fail(import_schema2.ArrayFormatter.formatErrorSync(e))
2528
+ (e) => import_effect4.Effect.fail(import_schema3.ArrayFormatter.formatErrorSync(e))
2333
2529
  ),
2334
- import_effect3.Effect.repeat({
2335
- schedule: import_effect3.Schedule.exponential(checkInterval),
2530
+ import_effect4.Effect.repeat({
2531
+ schedule: import_effect4.Schedule.exponential(checkInterval),
2336
2532
  until: (result) => result.length > 0
2337
2533
  }),
2338
- import_effect3.Effect.timeout(16e4),
2339
- import_effect3.Effect.orDie,
2340
- import_effect3.Effect.as(true)
2534
+ import_effect4.Effect.timeout(16e4),
2535
+ import_effect4.Effect.orDie,
2536
+ import_effect4.Effect.as(true)
2341
2537
  );
2342
- return import_effect3.Effect.runPromise(program);
2538
+ return import_effect4.Effect.runPromise(program);
2343
2539
  }
2344
2540
  async submitTx(tx) {
2345
2541
  const result = await fetch(`${this.baseUrl}/submittx`, {
@@ -2428,16 +2624,33 @@ var toUTxO = (koiosUTxO, address) => ({
2428
2624
  return a;
2429
2625
  })(),
2430
2626
  address,
2431
- datumHash: koiosUTxO.inline_datum ? void 0 : koiosUTxO.datum_hash,
2627
+ datumHash: koiosUTxO.inline_datum ? void 0 : koiosUTxO.datum_hash || void 0,
2432
2628
  datum: koiosUTxO.inline_datum ? koiosUTxO.inline_datum.bytes : void 0,
2433
- scriptRef: koiosUTxO.reference_script ? koiosUTxO.reference_script.type == "plutusV1" ? {
2434
- type: "PlutusV1",
2435
- script: (0, import_utils6.applyDoubleCborEncoding)(koiosUTxO.reference_script.bytes)
2436
- } : {
2437
- type: "PlutusV2",
2438
- script: (0, import_utils6.applyDoubleCborEncoding)(koiosUTxO.reference_script.bytes)
2439
- } : void 0
2629
+ scriptRef: toScriptRef2(koiosUTxO.reference_script)
2440
2630
  });
2631
+ var toScriptRef2 = (reference_script) => {
2632
+ if (reference_script && reference_script.bytes && reference_script.type) {
2633
+ switch (reference_script.type) {
2634
+ case "plutusV1":
2635
+ return {
2636
+ type: "PlutusV1",
2637
+ script: (0, import_utils6.applyDoubleCborEncoding)(reference_script.bytes)
2638
+ };
2639
+ case "plutusV2":
2640
+ return {
2641
+ type: "PlutusV2",
2642
+ script: (0, import_utils6.applyDoubleCborEncoding)(reference_script.bytes)
2643
+ };
2644
+ case "plutusV3":
2645
+ return {
2646
+ type: "PlutusV3",
2647
+ script: (0, import_utils6.applyDoubleCborEncoding)(reference_script.bytes)
2648
+ };
2649
+ default:
2650
+ return void 0;
2651
+ }
2652
+ }
2653
+ };
2441
2654
  // Annotate the CommonJS export names for ESM import in node:
2442
2655
  0 && (module.exports = {
2443
2656
  Blockfrost,