@lucid-evolution/provider 0.1.44 → 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 +284 -94
  2. package/dist/index.js +284 -94
  3. 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.44",
55
+ version: "0.1.45",
56
56
  description: "",
57
57
  main: "./dist/index.js",
58
58
  types: "./dist/index.d.ts",
@@ -327,6 +327,11 @@ var Blockfrost = class {
327
327
  type: "PlutusV2",
328
328
  script: (0, import_utils.applyDoubleCborEncoding)(script)
329
329
  };
330
+ case "plutusV3":
331
+ return {
332
+ type: "PlutusV3",
333
+ script: (0, import_utils.applyDoubleCborEncoding)(script)
334
+ };
330
335
  }
331
336
  })() : void 0
332
337
  };
@@ -431,9 +436,23 @@ var toAditionalUTXOs = (utxos) => (utxos || []).map((utxo) => [
431
436
  },
432
437
  datumHash: utxo.datumHash,
433
438
  datum: utxo.datum,
434
- script: utxo.scriptRef ? utxo.scriptRef.type === "PlutusV1" ? { "plutus:v1": utxo.scriptRef.script } : { "plutus:v2": utxo.scriptRef.script } : void 0
439
+ script: toTxOutScript(utxo.scriptRef)
435
440
  }
436
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
+ };
437
456
  var fromAssets = (assets) => (0, import_effect.pipe)(
438
457
  import_effect.Record.remove(assets, "lovelace"),
439
458
  import_effect.Record.mapEntries((amount, unit) => [
@@ -467,6 +486,51 @@ var TupleNumberFromString = S.compose(
467
486
  );
468
487
  var ProtocolParametersSchema = S.Struct({
469
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,
470
534
  minFeeConstant: S.Struct({ ada: LovelaceAsset }),
471
535
  maxBlockBodySize: S.Struct({ bytes: S.Number }),
472
536
  maxBlockHeaderSize: S.Struct({ bytes: S.Number }),
@@ -483,7 +547,8 @@ var ProtocolParametersSchema = S.Struct({
483
547
  minUtxoDepositCoefficient: S.Number,
484
548
  plutusCostModels: S.Struct({
485
549
  "plutus:v1": S.Array(S.Number),
486
- "plutus:v2": S.Array(S.Number)
550
+ "plutus:v2": S.Array(S.Number),
551
+ "plutus:v3": S.Array(S.Number)
487
552
  }),
488
553
  scriptExecutionPrices: S.Struct({
489
554
  memory: TupleNumberFromString,
@@ -525,7 +590,7 @@ var KupoUTxO = S.Struct({
525
590
  });
526
591
  var KupoScriptSchema = S.NullOr(
527
592
  S.Struct({
528
- language: S.Literal("native", "plutus:v1", "plutus:v2"),
593
+ language: S.Literal("native", "plutus:v1", "plutus:v2", "plutus:v3"),
529
594
  script: S.String
530
595
  })
531
596
  );
@@ -543,6 +608,7 @@ var KupoDelegation = S.NullOr(
543
608
 
544
609
  // src/kupmios/kupmios.ts
545
610
  var import_platform = require("@effect/platform");
611
+ var import_schema = require("@effect/schema");
546
612
  var KupmiosError = class extends import_effect2.Data.TaggedError("KupmiosError") {
547
613
  get message() {
548
614
  return `${this.cause}`;
@@ -679,7 +745,7 @@ var Kupmios = class {
679
745
  return result.datum;
680
746
  }
681
747
  async awaitTx(txHash, checkInterval = 2e4) {
682
- const pattern = `${this.kupoUrl}/matches/*@${txHash}?spent`;
748
+ const pattern = `${this.kupoUrl}/matches/*@${txHash}`;
683
749
  const schema = S2.Array(KupoUTxO).annotations({
684
750
  identifier: "Array<KupmiosSchema.KupoUTxO>"
685
751
  });
@@ -858,6 +924,12 @@ var toProtocolParameters = (result) => {
858
924
  index.toString(),
859
925
  value
860
926
  ])
927
+ ),
928
+ PlutusV3: Object.fromEntries(
929
+ result.plutusCostModels["plutus:v3"].map((value, index) => [
930
+ index.toString(),
931
+ value
932
+ ])
861
933
  )
862
934
  }
863
935
  };
@@ -867,20 +939,24 @@ var fetchOgmiosParse = (url, data, schema) => (0, import_effect2.pipe)(
867
939
  import_platform.HttpClientRequest.jsonBody(data),
868
940
  import_effect2.Effect.flatMap(import_platform.HttpClient.fetch),
869
941
  import_platform.HttpClientResponse.json,
870
- import_effect2.Effect.flatMap(S2.decodeUnknown(schema))
871
- // Effect.catchTag("ParseError", (e) =>
872
- // Effect.fail(ArrayFormatter.formatIssueSync(e.issue)),
873
- // ),
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
+ )
874
949
  // Effect.scoped
875
950
  );
876
951
  var fetchKupoParse = (url, schema) => (0, import_effect2.pipe)(
877
952
  import_platform.HttpClientRequest.get(url),
878
953
  import_platform.HttpClient.fetchOk,
879
954
  import_platform.HttpClientResponse.json,
880
- import_effect2.Effect.flatMap(S2.decodeUnknown(schema))
881
- // Effect.catchTag("ParseError", (e) =>
882
- // Effect.fail(ArrayFormatter.formatIssueSync(e.issue)),
883
- // ),
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
+ )
884
960
  // Effect.scoped
885
961
  );
886
962
  var kupmiosUtxosToUtxos = (kupoURL, utxos) => import_effect2.Effect.forEach(
@@ -1254,12 +1330,27 @@ It does not exist or was already spent.`
1254
1330
  3: "Reward"
1255
1331
  };
1256
1332
  const collected = [];
1257
- for (let i = 0; i < (witnesses.redeemers()?.to_js_value().len() || 0); i++) {
1258
- const redeemer = witnesses.redeemers().to_js_value().get(i);
1259
- collected.push({
1260
- tag: tagMap[redeemer.tag().kind()],
1261
- index: parseInt(redeemer.index().to_str())
1262
- });
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
+ }
1263
1354
  }
1264
1355
  return collected;
1265
1356
  })();
@@ -1641,7 +1732,7 @@ var Maestro = class {
1641
1732
  this.turboSubmit = turboSubmit;
1642
1733
  }
1643
1734
  async getProtocolParameters() {
1644
- const timestampedResult = await fetch(`${this.url}/protocol-params`, {
1735
+ const timestampedResult = await fetch(`${this.url}/protocol-parameters`, {
1645
1736
  headers: this.commonHeaders()
1646
1737
  }).then((res) => res.json());
1647
1738
  const result = timestampedResult.data;
@@ -1649,37 +1740,39 @@ var Maestro = class {
1649
1740
  const forwardSlashIndex = str.indexOf("/");
1650
1741
  return parseInt(str.slice(0, forwardSlashIndex)) / parseInt(str.slice(forwardSlashIndex + 1));
1651
1742
  };
1652
- const renameKeysAndSort = (obj, newKeys) => {
1653
- const entries = Object.keys(obj).sort().map((key) => {
1654
- const newKey = newKeys[key] || key;
1655
- return {
1656
- [newKey]: Object.fromEntries(
1657
- Object.entries(obj[key]).sort(
1658
- ([k, _v], [k2, _v2]) => k.localeCompare(k2)
1659
- )
1660
- )
1661
- };
1662
- });
1663
- return Object.assign({}, ...entries);
1664
- };
1665
1743
  return {
1666
1744
  minFeeA: parseInt(result.min_fee_coefficient),
1667
- minFeeB: parseInt(result.min_fee_constant),
1668
- maxTxSize: parseInt(result.max_tx_size),
1669
- maxValSize: parseInt(result.max_value_size),
1670
- keyDeposit: BigInt(result.stake_key_deposit),
1671
- poolDeposit: BigInt(result.pool_deposit),
1672
- priceMem: decimalFromRationalString(result.prices.memory),
1673
- 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),
1674
1754
  maxTxExMem: BigInt(result.max_execution_units_per_transaction.memory),
1675
- maxTxExSteps: BigInt(result.max_execution_units_per_transaction.steps),
1676
- 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),
1677
1757
  collateralPercentage: parseInt(result.collateral_percentage),
1678
1758
  maxCollateralInputs: parseInt(result.max_collateral_inputs),
1679
- costModels: renameKeysAndSort(result.cost_models, {
1680
- "plutus:v1": "PlutusV1",
1681
- "plutus:v2": "PlutusV2"
1682
- })
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
+ }
1683
1776
  };
1684
1777
  }
1685
1778
  async getUtxosInternal(addressOrCredential, unit) {
@@ -1862,10 +1955,7 @@ var Maestro = class {
1862
1955
  address: result.address,
1863
1956
  datumHash: result.datum ? result.datum.type == "inline" ? void 0 : result.datum.hash : void 0,
1864
1957
  datum: result.datum?.bytes,
1865
- scriptRef: result.reference_script ? result.reference_script.type == "native" ? void 0 : {
1866
- type: result.reference_script.type == "plutusv1" ? "PlutusV1" : "PlutusV2",
1867
- script: (0, import_utils5.applyDoubleCborEncoding)(result.reference_script.bytes)
1868
- } : void 0
1958
+ scriptRef: toScriptRef(result.reference_script)
1869
1959
  };
1870
1960
  }
1871
1961
  async getAllPagesData(getResponse, qry, paramsGiven, errorMsg) {
@@ -1916,6 +2006,29 @@ var Maestro = class {
1916
2006
  return result;
1917
2007
  }
1918
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
+ };
1919
2032
  var lucid2 = package_default.version;
1920
2033
 
1921
2034
  // src/koios/koios.ts
@@ -1926,6 +2039,28 @@ var import_utils6 = require("@lucid-evolution/utils");
1926
2039
  // src/koios/schema.ts
1927
2040
  var S3 = __toESM(require("@effect/schema/Schema"), 1);
1928
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,
1929
2064
  epoch_no: S3.Number,
1930
2065
  min_fee_a: S3.Number,
1931
2066
  min_fee_b: S3.Number,
@@ -1949,7 +2084,8 @@ var ProtocolParametersSchema2 = S3.Struct({
1949
2084
  block_hash: S3.NullOr(S3.String),
1950
2085
  cost_models: S3.Struct({
1951
2086
  PlutusV1: S3.Array(S3.Number),
1952
- PlutusV2: S3.Array(S3.Number)
2087
+ PlutusV2: S3.Array(S3.Number),
2088
+ PlutusV3: S3.Array(S3.Number)
1953
2089
  }),
1954
2090
  price_mem: S3.Number,
1955
2091
  price_step: S3.Number,
@@ -1969,9 +2105,17 @@ var KoiosAssetSchema = S3.Struct({
1969
2105
  decimals: S3.Number,
1970
2106
  quantity: S3.String
1971
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
+ });
1972
2115
  var KoiosUTxOSchema = S3.Struct({
1973
2116
  tx_hash: S3.String,
1974
2117
  tx_index: S3.Number,
2118
+ block_time: S3.Number,
1975
2119
  block_height: S3.NullOr(S3.Number),
1976
2120
  value: S3.String,
1977
2121
  datum_hash: S3.NullOr(S3.String),
@@ -1981,15 +2125,7 @@ var KoiosUTxOSchema = S3.Struct({
1981
2125
  value: S3.Object
1982
2126
  })
1983
2127
  ),
1984
- reference_script: S3.NullOr(
1985
- S3.Struct({
1986
- hash: S3.String,
1987
- size: S3.Number,
1988
- type: S3.String,
1989
- bytes: S3.String,
1990
- value: S3.NullOr(S3.Object)
1991
- })
1992
- ),
2128
+ reference_script: S3.NullOr(ReferenceScriptSchema),
1993
2129
  asset_list: S3.NullOr(S3.Array(KoiosAssetSchema))
1994
2130
  });
1995
2131
  var KoiosAddressInfoSchema = S3.Array(
@@ -2019,16 +2155,8 @@ var KoiosInputOutputSchema = S3.Struct({
2019
2155
  value: S3.Object
2020
2156
  })
2021
2157
  ),
2022
- reference_script: S3.NullOr(
2023
- S3.Struct({
2024
- hash: S3.String,
2025
- size: S3.Number,
2026
- type: S3.String,
2027
- bytes: S3.String,
2028
- value: S3.NullOr(S3.Object)
2029
- })
2030
- ),
2031
- asset_list: S3.Union(S3.Array(KoiosAssetSchema), S3.String)
2158
+ reference_script: S3.NullOr(ReferenceScriptSchema),
2159
+ asset_list: S3.Array(KoiosAssetSchema)
2032
2160
  });
2033
2161
  var KoiosTxInfoSchema = S3.Struct({
2034
2162
  tx_hash: S3.String,
@@ -2042,6 +2170,7 @@ var KoiosTxInfoSchema = S3.Struct({
2042
2170
  tx_size: S3.Number,
2043
2171
  total_output: S3.String,
2044
2172
  fee: S3.String,
2173
+ treasury_donation: S3.String,
2045
2174
  deposit: S3.String,
2046
2175
  invalid_before: S3.NullOr(S3.String),
2047
2176
  invalid_after: S3.NullOr(S3.String),
@@ -2111,12 +2240,18 @@ var KoiosTxInfoSchema = S3.Struct({
2111
2240
  })
2112
2241
  })
2113
2242
  )
2114
- )
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
2115
2250
  });
2116
2251
 
2117
2252
  // src/koios/koios.ts
2118
2253
  var import_effect4 = require("effect");
2119
- var import_schema2 = require("@effect/schema");
2254
+ var import_schema3 = require("@effect/schema");
2120
2255
 
2121
2256
  // src/fetch.ts
2122
2257
  var fetch_exports = {};
@@ -2163,7 +2298,17 @@ var Koios = class {
2163
2298
  const result = await fetch(`${this.baseUrl}/epoch_params?limit=1`).then(
2164
2299
  (res) => res.json()
2165
2300
  );
2166
- 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
+ );
2167
2312
  return {
2168
2313
  minFeeA: param.min_fee_a,
2169
2314
  minFeeB: param.min_fee_b,
@@ -2190,6 +2335,12 @@ var Koios = class {
2190
2335
  index.toString(),
2191
2336
  value
2192
2337
  ])
2338
+ ),
2339
+ PlutusV3: Object.fromEntries(
2340
+ param.cost_models.PlutusV3.map((value, index) => [
2341
+ index.toString(),
2342
+ value
2343
+ ])
2193
2344
  )
2194
2345
  }
2195
2346
  };
@@ -2207,9 +2358,17 @@ var Koios = class {
2207
2358
  method: "POST",
2208
2359
  body: JSON.stringify(body)
2209
2360
  }).then((res) => res.json());
2210
- const parsedResult = S4.decodeUnknownSync(KoiosAddressInfoSchema)(
2211
- result
2212
- )[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
+ );
2213
2372
  return parsedResult ? parsedResult.utxo_set.map(
2214
2373
  (koiosUTXO) => toUTxO(koiosUTXO, parsedResult.address)
2215
2374
  ) : [];
@@ -2258,9 +2417,10 @@ var Koios = class {
2258
2417
  throw new Error("Unit not found.");
2259
2418
  }
2260
2419
  async getUtxosByOutRef(outRefs) {
2261
- const utxos = [];
2262
2420
  const body = {
2263
- _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
2264
2424
  };
2265
2425
  const result = await fetch(`${this.baseUrl}/tx_info`, {
2266
2426
  headers: {
@@ -2270,26 +2430,39 @@ var Koios = class {
2270
2430
  method: "POST",
2271
2431
  body: JSON.stringify(body)
2272
2432
  }).then((res) => res.json());
2273
- const parsedResult = S4.decodeUnknownSync(S4.Array(KoiosTxInfoSchema))(
2274
- result
2275
- )[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
+ );
2276
2444
  if (parsedResult) {
2277
- return parsedResult.outputs.map(
2445
+ const utxos = parsedResult.outputs.map(
2278
2446
  (koiosInputOutput) => toUTxO(
2279
2447
  {
2280
2448
  tx_hash: koiosInputOutput.tx_hash,
2281
2449
  tx_index: koiosInputOutput.tx_index,
2282
- block_height: null,
2450
+ block_time: 0,
2451
+ block_height: parsedResult.block_height,
2283
2452
  value: koiosInputOutput.value,
2284
2453
  datum_hash: koiosInputOutput.datum_hash,
2285
2454
  inline_datum: koiosInputOutput.inline_datum,
2286
2455
  reference_script: koiosInputOutput.reference_script,
2287
- //NOTE: Koios api returns collateral_output like asset_list: "[]", instead of asset_list: []
2288
- asset_list: typeof koiosInputOutput.asset_list === "string" ? [] : koiosInputOutput.asset_list
2456
+ asset_list: koiosInputOutput.asset_list
2289
2457
  },
2290
2458
  koiosInputOutput.payment_addr.bech32
2291
2459
  )
2292
2460
  );
2461
+ return utxos.filter(
2462
+ (utxo) => outRefs.some(
2463
+ (outRef) => utxo.txHash === outRef.txHash && utxo.outputIndex === outRef.outputIndex
2464
+ )
2465
+ );
2293
2466
  } else {
2294
2467
  return [];
2295
2468
  }
@@ -2352,7 +2525,7 @@ var Koios = class {
2352
2525
  ),
2353
2526
  import_effect4.Effect.catchTag(
2354
2527
  "ParseError",
2355
- (e) => import_effect4.Effect.fail(import_schema2.ArrayFormatter.formatErrorSync(e))
2528
+ (e) => import_effect4.Effect.fail(import_schema3.ArrayFormatter.formatErrorSync(e))
2356
2529
  ),
2357
2530
  import_effect4.Effect.repeat({
2358
2531
  schedule: import_effect4.Schedule.exponential(checkInterval),
@@ -2451,16 +2624,33 @@ var toUTxO = (koiosUTxO, address) => ({
2451
2624
  return a;
2452
2625
  })(),
2453
2626
  address,
2454
- datumHash: koiosUTxO.inline_datum ? void 0 : koiosUTxO.datum_hash,
2627
+ datumHash: koiosUTxO.inline_datum ? void 0 : koiosUTxO.datum_hash || void 0,
2455
2628
  datum: koiosUTxO.inline_datum ? koiosUTxO.inline_datum.bytes : void 0,
2456
- scriptRef: koiosUTxO.reference_script ? koiosUTxO.reference_script.type == "plutusV1" ? {
2457
- type: "PlutusV1",
2458
- script: (0, import_utils6.applyDoubleCborEncoding)(koiosUTxO.reference_script.bytes)
2459
- } : {
2460
- type: "PlutusV2",
2461
- script: (0, import_utils6.applyDoubleCborEncoding)(koiosUTxO.reference_script.bytes)
2462
- } : void 0
2629
+ scriptRef: toScriptRef2(koiosUTxO.reference_script)
2463
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
+ };
2464
2654
  // Annotate the CommonJS export names for ESM import in node:
2465
2655
  0 && (module.exports = {
2466
2656
  Blockfrost,
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ import { applyDoubleCborEncoding } from "@lucid-evolution/utils";
14
14
  // package.json
15
15
  var package_default = {
16
16
  name: "@lucid-evolution/provider",
17
- version: "0.1.44",
17
+ version: "0.1.45",
18
18
  description: "",
19
19
  main: "./dist/index.js",
20
20
  types: "./dist/index.d.ts",
@@ -289,6 +289,11 @@ var Blockfrost = class {
289
289
  type: "PlutusV2",
290
290
  script: applyDoubleCborEncoding(script)
291
291
  };
292
+ case "plutusV3":
293
+ return {
294
+ type: "PlutusV3",
295
+ script: applyDoubleCborEncoding(script)
296
+ };
292
297
  }
293
298
  })() : void 0
294
299
  };
@@ -393,9 +398,23 @@ var toAditionalUTXOs = (utxos) => (utxos || []).map((utxo) => [
393
398
  },
394
399
  datumHash: utxo.datumHash,
395
400
  datum: utxo.datum,
396
- script: utxo.scriptRef ? utxo.scriptRef.type === "PlutusV1" ? { "plutus:v1": utxo.scriptRef.script } : { "plutus:v2": utxo.scriptRef.script } : void 0
401
+ script: toTxOutScript(utxo.scriptRef)
397
402
  }
398
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
+ };
399
418
  var fromAssets = (assets) => pipe(
400
419
  Record.remove(assets, "lovelace"),
401
420
  Record.mapEntries((amount, unit) => [
@@ -429,6 +448,51 @@ var TupleNumberFromString = S.compose(
429
448
  );
430
449
  var ProtocolParametersSchema = S.Struct({
431
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,
432
496
  minFeeConstant: S.Struct({ ada: LovelaceAsset }),
433
497
  maxBlockBodySize: S.Struct({ bytes: S.Number }),
434
498
  maxBlockHeaderSize: S.Struct({ bytes: S.Number }),
@@ -445,7 +509,8 @@ var ProtocolParametersSchema = S.Struct({
445
509
  minUtxoDepositCoefficient: S.Number,
446
510
  plutusCostModels: S.Struct({
447
511
  "plutus:v1": S.Array(S.Number),
448
- "plutus:v2": S.Array(S.Number)
512
+ "plutus:v2": S.Array(S.Number),
513
+ "plutus:v3": S.Array(S.Number)
449
514
  }),
450
515
  scriptExecutionPrices: S.Struct({
451
516
  memory: TupleNumberFromString,
@@ -487,7 +552,7 @@ var KupoUTxO = S.Struct({
487
552
  });
488
553
  var KupoScriptSchema = S.NullOr(
489
554
  S.Struct({
490
- language: S.Literal("native", "plutus:v1", "plutus:v2"),
555
+ language: S.Literal("native", "plutus:v1", "plutus:v2", "plutus:v3"),
491
556
  script: S.String
492
557
  })
493
558
  );
@@ -509,6 +574,7 @@ import {
509
574
  HttpClientRequest,
510
575
  HttpClientResponse
511
576
  } from "@effect/platform";
577
+ import { ArrayFormatter } from "@effect/schema";
512
578
  var KupmiosError = class extends Data.TaggedError("KupmiosError") {
513
579
  get message() {
514
580
  return `${this.cause}`;
@@ -645,7 +711,7 @@ var Kupmios = class {
645
711
  return result.datum;
646
712
  }
647
713
  async awaitTx(txHash, checkInterval = 2e4) {
648
- const pattern = `${this.kupoUrl}/matches/*@${txHash}?spent`;
714
+ const pattern = `${this.kupoUrl}/matches/*@${txHash}`;
649
715
  const schema = S2.Array(KupoUTxO).annotations({
650
716
  identifier: "Array<KupmiosSchema.KupoUTxO>"
651
717
  });
@@ -824,6 +890,12 @@ var toProtocolParameters = (result) => {
824
890
  index.toString(),
825
891
  value
826
892
  ])
893
+ ),
894
+ PlutusV3: Object.fromEntries(
895
+ result.plutusCostModels["plutus:v3"].map((value, index) => [
896
+ index.toString(),
897
+ value
898
+ ])
827
899
  )
828
900
  }
829
901
  };
@@ -833,20 +905,24 @@ var fetchOgmiosParse = (url, data, schema) => pipe2(
833
905
  HttpClientRequest.jsonBody(data),
834
906
  Effect.flatMap(HttpClient.fetch),
835
907
  HttpClientResponse.json,
836
- Effect.flatMap(S2.decodeUnknown(schema))
837
- // Effect.catchTag("ParseError", (e) =>
838
- // Effect.fail(ArrayFormatter.formatIssueSync(e.issue)),
839
- // ),
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
+ )
840
915
  // Effect.scoped
841
916
  );
842
917
  var fetchKupoParse = (url, schema) => pipe2(
843
918
  HttpClientRequest.get(url),
844
919
  HttpClient.fetchOk,
845
920
  HttpClientResponse.json,
846
- Effect.flatMap(S2.decodeUnknown(schema))
847
- // Effect.catchTag("ParseError", (e) =>
848
- // Effect.fail(ArrayFormatter.formatIssueSync(e.issue)),
849
- // ),
921
+ Effect.flatMap(S2.decodeUnknown(schema, { onExcessProperty: "error" })),
922
+ Effect.catchTag(
923
+ "ParseError",
924
+ (e) => Effect.fail(ArrayFormatter.formatErrorSync(e))
925
+ )
850
926
  // Effect.scoped
851
927
  );
852
928
  var kupmiosUtxosToUtxos = (kupoURL, utxos) => Effect.forEach(
@@ -1223,12 +1299,27 @@ It does not exist or was already spent.`
1223
1299
  3: "Reward"
1224
1300
  };
1225
1301
  const collected = [];
1226
- for (let i = 0; i < (witnesses.redeemers()?.to_js_value().len() || 0); i++) {
1227
- const redeemer = witnesses.redeemers().to_js_value().get(i);
1228
- collected.push({
1229
- tag: tagMap[redeemer.tag().kind()],
1230
- index: parseInt(redeemer.index().to_str())
1231
- });
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
+ }
1232
1323
  }
1233
1324
  return collected;
1234
1325
  })();
@@ -1610,7 +1701,7 @@ var Maestro = class {
1610
1701
  this.turboSubmit = turboSubmit;
1611
1702
  }
1612
1703
  async getProtocolParameters() {
1613
- const timestampedResult = await fetch(`${this.url}/protocol-params`, {
1704
+ const timestampedResult = await fetch(`${this.url}/protocol-parameters`, {
1614
1705
  headers: this.commonHeaders()
1615
1706
  }).then((res) => res.json());
1616
1707
  const result = timestampedResult.data;
@@ -1618,37 +1709,39 @@ var Maestro = class {
1618
1709
  const forwardSlashIndex = str.indexOf("/");
1619
1710
  return parseInt(str.slice(0, forwardSlashIndex)) / parseInt(str.slice(forwardSlashIndex + 1));
1620
1711
  };
1621
- const renameKeysAndSort = (obj, newKeys) => {
1622
- const entries = Object.keys(obj).sort().map((key) => {
1623
- const newKey = newKeys[key] || key;
1624
- return {
1625
- [newKey]: Object.fromEntries(
1626
- Object.entries(obj[key]).sort(
1627
- ([k, _v], [k2, _v2]) => k.localeCompare(k2)
1628
- )
1629
- )
1630
- };
1631
- });
1632
- return Object.assign({}, ...entries);
1633
- };
1634
1712
  return {
1635
1713
  minFeeA: parseInt(result.min_fee_coefficient),
1636
- minFeeB: parseInt(result.min_fee_constant),
1637
- maxTxSize: parseInt(result.max_tx_size),
1638
- maxValSize: parseInt(result.max_value_size),
1639
- keyDeposit: BigInt(result.stake_key_deposit),
1640
- poolDeposit: BigInt(result.pool_deposit),
1641
- priceMem: decimalFromRationalString(result.prices.memory),
1642
- priceStep: decimalFromRationalString(result.prices.steps),
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),
1643
1723
  maxTxExMem: BigInt(result.max_execution_units_per_transaction.memory),
1644
- maxTxExSteps: BigInt(result.max_execution_units_per_transaction.steps),
1645
- coinsPerUtxoByte: BigInt(result.coins_per_utxo_byte),
1724
+ maxTxExSteps: BigInt(result.max_execution_units_per_transaction.cpu),
1725
+ coinsPerUtxoByte: BigInt(result.min_utxo_deposit_coefficient),
1646
1726
  collateralPercentage: parseInt(result.collateral_percentage),
1647
1727
  maxCollateralInputs: parseInt(result.max_collateral_inputs),
1648
- costModels: renameKeysAndSort(result.cost_models, {
1649
- "plutus:v1": "PlutusV1",
1650
- "plutus:v2": "PlutusV2"
1651
- })
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
+ }
1652
1745
  };
1653
1746
  }
1654
1747
  async getUtxosInternal(addressOrCredential, unit) {
@@ -1831,10 +1924,7 @@ var Maestro = class {
1831
1924
  address: result.address,
1832
1925
  datumHash: result.datum ? result.datum.type == "inline" ? void 0 : result.datum.hash : void 0,
1833
1926
  datum: result.datum?.bytes,
1834
- scriptRef: result.reference_script ? result.reference_script.type == "native" ? void 0 : {
1835
- type: result.reference_script.type == "plutusv1" ? "PlutusV1" : "PlutusV2",
1836
- script: applyDoubleCborEncoding3(result.reference_script.bytes)
1837
- } : void 0
1927
+ scriptRef: toScriptRef(result.reference_script)
1838
1928
  };
1839
1929
  }
1840
1930
  async getAllPagesData(getResponse, qry, paramsGiven, errorMsg) {
@@ -1885,6 +1975,29 @@ var Maestro = class {
1885
1975
  return result;
1886
1976
  }
1887
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
+ };
1888
2001
  var lucid2 = package_default.version;
1889
2002
 
1890
2003
  // src/koios/koios.ts
@@ -1895,6 +2008,28 @@ import { applyDoubleCborEncoding as applyDoubleCborEncoding4, fromUnit as fromUn
1895
2008
  // src/koios/schema.ts
1896
2009
  import * as S3 from "@effect/schema/Schema";
1897
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,
1898
2033
  epoch_no: S3.Number,
1899
2034
  min_fee_a: S3.Number,
1900
2035
  min_fee_b: S3.Number,
@@ -1918,7 +2053,8 @@ var ProtocolParametersSchema2 = S3.Struct({
1918
2053
  block_hash: S3.NullOr(S3.String),
1919
2054
  cost_models: S3.Struct({
1920
2055
  PlutusV1: S3.Array(S3.Number),
1921
- PlutusV2: S3.Array(S3.Number)
2056
+ PlutusV2: S3.Array(S3.Number),
2057
+ PlutusV3: S3.Array(S3.Number)
1922
2058
  }),
1923
2059
  price_mem: S3.Number,
1924
2060
  price_step: S3.Number,
@@ -1938,9 +2074,17 @@ var KoiosAssetSchema = S3.Struct({
1938
2074
  decimals: S3.Number,
1939
2075
  quantity: S3.String
1940
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
+ });
1941
2084
  var KoiosUTxOSchema = S3.Struct({
1942
2085
  tx_hash: S3.String,
1943
2086
  tx_index: S3.Number,
2087
+ block_time: S3.Number,
1944
2088
  block_height: S3.NullOr(S3.Number),
1945
2089
  value: S3.String,
1946
2090
  datum_hash: S3.NullOr(S3.String),
@@ -1950,15 +2094,7 @@ var KoiosUTxOSchema = S3.Struct({
1950
2094
  value: S3.Object
1951
2095
  })
1952
2096
  ),
1953
- reference_script: S3.NullOr(
1954
- S3.Struct({
1955
- hash: S3.String,
1956
- size: S3.Number,
1957
- type: S3.String,
1958
- bytes: S3.String,
1959
- value: S3.NullOr(S3.Object)
1960
- })
1961
- ),
2097
+ reference_script: S3.NullOr(ReferenceScriptSchema),
1962
2098
  asset_list: S3.NullOr(S3.Array(KoiosAssetSchema))
1963
2099
  });
1964
2100
  var KoiosAddressInfoSchema = S3.Array(
@@ -1988,16 +2124,8 @@ var KoiosInputOutputSchema = S3.Struct({
1988
2124
  value: S3.Object
1989
2125
  })
1990
2126
  ),
1991
- reference_script: S3.NullOr(
1992
- S3.Struct({
1993
- hash: S3.String,
1994
- size: S3.Number,
1995
- type: S3.String,
1996
- bytes: S3.String,
1997
- value: S3.NullOr(S3.Object)
1998
- })
1999
- ),
2000
- asset_list: S3.Union(S3.Array(KoiosAssetSchema), S3.String)
2127
+ reference_script: S3.NullOr(ReferenceScriptSchema),
2128
+ asset_list: S3.Array(KoiosAssetSchema)
2001
2129
  });
2002
2130
  var KoiosTxInfoSchema = S3.Struct({
2003
2131
  tx_hash: S3.String,
@@ -2011,6 +2139,7 @@ var KoiosTxInfoSchema = S3.Struct({
2011
2139
  tx_size: S3.Number,
2012
2140
  total_output: S3.String,
2013
2141
  fee: S3.String,
2142
+ treasury_donation: S3.String,
2014
2143
  deposit: S3.String,
2015
2144
  invalid_before: S3.NullOr(S3.String),
2016
2145
  invalid_after: S3.NullOr(S3.String),
@@ -2080,12 +2209,18 @@ var KoiosTxInfoSchema = S3.Struct({
2080
2209
  })
2081
2210
  })
2082
2211
  )
2083
- )
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
2084
2219
  });
2085
2220
 
2086
2221
  // src/koios/koios.ts
2087
2222
  import { Effect as Effect3, pipe as pipe4, Schedule as Schedule2 } from "effect";
2088
- import { ArrayFormatter } from "@effect/schema";
2223
+ import { ArrayFormatter as ArrayFormatter2 } from "@effect/schema";
2089
2224
 
2090
2225
  // src/fetch.ts
2091
2226
  var fetch_exports = {};
@@ -2132,7 +2267,17 @@ var Koios = class {
2132
2267
  const result = await fetch(`${this.baseUrl}/epoch_params?limit=1`).then(
2133
2268
  (res) => res.json()
2134
2269
  );
2135
- const param = S4.decodeUnknownSync(ProtocolParametersSchema2)(result[0]);
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
+ );
2136
2281
  return {
2137
2282
  minFeeA: param.min_fee_a,
2138
2283
  minFeeB: param.min_fee_b,
@@ -2159,6 +2304,12 @@ var Koios = class {
2159
2304
  index.toString(),
2160
2305
  value
2161
2306
  ])
2307
+ ),
2308
+ PlutusV3: Object.fromEntries(
2309
+ param.cost_models.PlutusV3.map((value, index) => [
2310
+ index.toString(),
2311
+ value
2312
+ ])
2162
2313
  )
2163
2314
  }
2164
2315
  };
@@ -2176,9 +2327,17 @@ var Koios = class {
2176
2327
  method: "POST",
2177
2328
  body: JSON.stringify(body)
2178
2329
  }).then((res) => res.json());
2179
- const parsedResult = S4.decodeUnknownSync(KoiosAddressInfoSchema)(
2180
- result
2181
- )[0];
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
+ );
2182
2341
  return parsedResult ? parsedResult.utxo_set.map(
2183
2342
  (koiosUTXO) => toUTxO(koiosUTXO, parsedResult.address)
2184
2343
  ) : [];
@@ -2227,9 +2386,10 @@ var Koios = class {
2227
2386
  throw new Error("Unit not found.");
2228
2387
  }
2229
2388
  async getUtxosByOutRef(outRefs) {
2230
- const utxos = [];
2231
2389
  const body = {
2232
- _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
2233
2393
  };
2234
2394
  const result = await fetch(`${this.baseUrl}/tx_info`, {
2235
2395
  headers: {
@@ -2239,26 +2399,39 @@ var Koios = class {
2239
2399
  method: "POST",
2240
2400
  body: JSON.stringify(body)
2241
2401
  }).then((res) => res.json());
2242
- const parsedResult = S4.decodeUnknownSync(S4.Array(KoiosTxInfoSchema))(
2243
- result
2244
- )[0];
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
+ );
2245
2413
  if (parsedResult) {
2246
- return parsedResult.outputs.map(
2414
+ const utxos = parsedResult.outputs.map(
2247
2415
  (koiosInputOutput) => toUTxO(
2248
2416
  {
2249
2417
  tx_hash: koiosInputOutput.tx_hash,
2250
2418
  tx_index: koiosInputOutput.tx_index,
2251
- block_height: null,
2419
+ block_time: 0,
2420
+ block_height: parsedResult.block_height,
2252
2421
  value: koiosInputOutput.value,
2253
2422
  datum_hash: koiosInputOutput.datum_hash,
2254
2423
  inline_datum: koiosInputOutput.inline_datum,
2255
2424
  reference_script: koiosInputOutput.reference_script,
2256
- //NOTE: Koios api returns collateral_output like asset_list: "[]", instead of asset_list: []
2257
- asset_list: typeof koiosInputOutput.asset_list === "string" ? [] : koiosInputOutput.asset_list
2425
+ asset_list: koiosInputOutput.asset_list
2258
2426
  },
2259
2427
  koiosInputOutput.payment_addr.bech32
2260
2428
  )
2261
2429
  );
2430
+ return utxos.filter(
2431
+ (utxo) => outRefs.some(
2432
+ (outRef) => utxo.txHash === outRef.txHash && utxo.outputIndex === outRef.outputIndex
2433
+ )
2434
+ );
2262
2435
  } else {
2263
2436
  return [];
2264
2437
  }
@@ -2321,7 +2494,7 @@ var Koios = class {
2321
2494
  ),
2322
2495
  Effect3.catchTag(
2323
2496
  "ParseError",
2324
- (e) => Effect3.fail(ArrayFormatter.formatErrorSync(e))
2497
+ (e) => Effect3.fail(ArrayFormatter2.formatErrorSync(e))
2325
2498
  ),
2326
2499
  Effect3.repeat({
2327
2500
  schedule: Schedule2.exponential(checkInterval),
@@ -2420,16 +2593,33 @@ var toUTxO = (koiosUTxO, address) => ({
2420
2593
  return a;
2421
2594
  })(),
2422
2595
  address,
2423
- datumHash: koiosUTxO.inline_datum ? void 0 : koiosUTxO.datum_hash,
2596
+ datumHash: koiosUTxO.inline_datum ? void 0 : koiosUTxO.datum_hash || void 0,
2424
2597
  datum: koiosUTxO.inline_datum ? koiosUTxO.inline_datum.bytes : void 0,
2425
- scriptRef: koiosUTxO.reference_script ? koiosUTxO.reference_script.type == "plutusV1" ? {
2426
- type: "PlutusV1",
2427
- script: applyDoubleCborEncoding4(koiosUTxO.reference_script.bytes)
2428
- } : {
2429
- type: "PlutusV2",
2430
- script: applyDoubleCborEncoding4(koiosUTxO.reference_script.bytes)
2431
- } : void 0
2598
+ scriptRef: toScriptRef2(koiosUTxO.reference_script)
2432
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
+ };
2433
2623
  export {
2434
2624
  Blockfrost,
2435
2625
  Emulator,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucid-evolution/provider",
3
- "version": "0.1.44",
3
+ "version": "0.1.45",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -30,10 +30,10 @@
30
30
  "@effect/platform": "^0.59.2",
31
31
  "@effect/schema": "^0.68.26",
32
32
  "effect": "^3.5.6",
33
- "@lucid-evolution/core-types": "0.1.13",
33
+ "@lucid-evolution/core-types": "0.1.14",
34
34
  "@lucid-evolution/core-utils": "0.1.13",
35
- "@lucid-evolution/utils": "0.1.35",
36
- "@lucid-evolution/wallet": "0.1.39"
35
+ "@lucid-evolution/utils": "0.1.36",
36
+ "@lucid-evolution/wallet": "0.1.40"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/node": "^20.12.8",