@lucid-evolution/utils 0.1.53 → 0.1.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
+ CBOREncodingLevel: () => CBOREncodingLevel,
33
34
  PROTOCOL_PARAMETERS_DEFAULT: () => PROTOCOL_PARAMETERS_DEFAULT,
34
35
  addAssets: () => addAssets,
35
36
  addressFromHexOrBech32: () => addressFromHexOrBech32,
@@ -192,13 +193,31 @@ function networkToId(network) {
192
193
 
193
194
  // src/cbor.ts
194
195
  var import_core_utils = require("@lucid-evolution/core-utils");
195
- var import_cborg = require("cborg");
196
+ var import_cbor_x = require("cbor-x");
196
197
  var applyDoubleCborEncoding = (script) => {
197
198
  try {
198
- (0, import_cborg.decode)((0, import_cborg.decode)((0, import_core_utils.fromHex)(script)));
199
+ (0, import_cbor_x.decode)((0, import_cbor_x.decode)((0, import_core_utils.fromHex)(script)));
199
200
  return script;
200
201
  } catch (error) {
201
- return (0, import_core_utils.toHex)((0, import_cborg.encode)((0, import_core_utils.fromHex)(script)));
202
+ try {
203
+ (0, import_cbor_x.decode)((0, import_core_utils.fromHex)(script));
204
+ return (0, import_core_utils.toHex)(Uint8Array.from((0, import_cbor_x.encode)((0, import_core_utils.fromHex)(script).buffer)));
205
+ } catch (error2) {
206
+ return (0, import_core_utils.toHex)(Uint8Array.from((0, import_cbor_x.encode)((0, import_cbor_x.encode)((0, import_core_utils.fromHex)(script).buffer))));
207
+ }
208
+ }
209
+ };
210
+ var CBOREncodingLevel = (script) => {
211
+ try {
212
+ (0, import_cbor_x.decode)((0, import_cbor_x.decode)((0, import_core_utils.fromHex)(script)));
213
+ return "double";
214
+ } catch (error) {
215
+ try {
216
+ (0, import_cbor_x.decode)((0, import_core_utils.fromHex)(script));
217
+ return "single";
218
+ } catch (error2) {
219
+ throw new Error("Script is not CBOR-encoded or invalid format.");
220
+ }
202
221
  }
203
222
  };
204
223
  function datumJsonToCbor(json) {
@@ -247,7 +266,7 @@ function datumJsonToCbor(json) {
247
266
  var import_plutus = require("@lucid-evolution/plutus");
248
267
  var import_uplc = require("@harmoniclabs/uplc");
249
268
  var import_core_utils2 = require("@lucid-evolution/core-utils");
250
- var import_cborg2 = require("cborg");
269
+ var import_cbor_x2 = require("cbor-x");
251
270
  var import_plutus_data = require("@harmoniclabs/plutus-data");
252
271
  function validatorToAddress(network, validator, stakeCredential) {
253
272
  const validatorHash = validatorToScriptHash(validator);
@@ -274,21 +293,15 @@ function validatorToScriptHash(validator) {
274
293
  return CML.NativeScript.from_cbor_hex(validator.script).hash().to_hex();
275
294
  case "PlutusV1":
276
295
  return CML.PlutusScript.from_v1(
277
- CML.PlutusV1Script.from_cbor_hex(
278
- applyDoubleCborEncoding(validator.script)
279
- )
296
+ CML.PlutusV1Script.from_cbor_hex(validator.script)
280
297
  ).hash().to_hex();
281
298
  case "PlutusV2":
282
299
  return CML.PlutusScript.from_v2(
283
- CML.PlutusV2Script.from_cbor_hex(
284
- applyDoubleCborEncoding(validator.script)
285
- )
300
+ CML.PlutusV2Script.from_cbor_hex(validator.script)
286
301
  ).hash().to_hex();
287
302
  case "PlutusV3":
288
303
  return CML.PlutusScript.from_v3(
289
- CML.PlutusV3Script.from_cbor_hex(
290
- applyDoubleCborEncoding(validator.script)
291
- )
304
+ CML.PlutusV3Script.from_cbor_hex(validator.script)
292
305
  ).hash().to_hex();
293
306
  default:
294
307
  throw new Error("No variant matched");
@@ -302,21 +315,15 @@ function toScriptRef(script) {
302
315
  );
303
316
  case "PlutusV1":
304
317
  return CML.Script.new_plutus_v1(
305
- CML.PlutusV1Script.from_cbor_hex(
306
- applyDoubleCborEncoding(script.script)
307
- )
318
+ CML.PlutusV1Script.from_cbor_hex(script.script)
308
319
  );
309
320
  case "PlutusV2":
310
321
  return CML.Script.new_plutus_v2(
311
- CML.PlutusV2Script.from_cbor_hex(
312
- applyDoubleCborEncoding(script.script)
313
- )
322
+ CML.PlutusV2Script.from_cbor_hex(script.script)
314
323
  );
315
324
  case "PlutusV3":
316
325
  return CML.Script.new_plutus_v3(
317
- CML.PlutusV3Script.from_cbor_hex(
318
- applyDoubleCborEncoding(script.script)
319
- )
326
+ CML.PlutusV3Script.from_cbor_hex(script.script)
320
327
  );
321
328
  default:
322
329
  throw new Error("No variant matched.");
@@ -353,23 +360,26 @@ function mintingPolicyToId(mintingPolicy) {
353
360
  return validatorToScriptHash(mintingPolicy);
354
361
  }
355
362
  function applyParamsToScript(plutusScript, params, type) {
356
- const program = (0, import_uplc.parseUPLC)(
357
- (0, import_cborg2.decode)((0, import_cborg2.decode)((0, import_core_utils2.fromHex)(applyDoubleCborEncoding(plutusScript)))),
358
- "flat"
359
- );
363
+ const encodingLevel = CBOREncodingLevel(plutusScript);
364
+ const program = encodingLevel === "double" ? (0, import_uplc.parseUPLC)((0, import_cbor_x2.decode)((0, import_cbor_x2.decode)((0, import_core_utils2.fromHex)(plutusScript))), "flat") : (0, import_uplc.parseUPLC)((0, import_cbor_x2.decode)((0, import_core_utils2.fromHex)(plutusScript)), "flat");
360
365
  const parameters = type ? import_plutus.Data.castTo(params, type) : params;
361
- const appliedProgram = parameters.reduce((body, currentParameter) => {
362
- const data = import_uplc.UPLCConst.data((0, import_plutus_data.dataFromCbor)(import_plutus.Data.to(currentParameter)));
363
- const appliedParameter = new import_uplc.Application(body, data);
364
- return appliedParameter;
365
- }, program.body);
366
- return (0, import_core_utils2.toHex)(
367
- (0, import_cborg2.encode)(
368
- (0, import_cborg2.encode)(
369
- (0, import_uplc.encodeUPLC)(new import_uplc.UPLCProgram(program.version, appliedProgram)).toBuffer().buffer
370
- )
371
- )
366
+ const appliedProgram = parameters.reduce(
367
+ (body, currentParameter) => {
368
+ const data = import_uplc.UPLCConst.data((0, import_plutus_data.dataFromCbor)(import_plutus.Data.to(currentParameter)));
369
+ const appliedParameter = new import_uplc.Application(body, data);
370
+ return appliedParameter;
371
+ },
372
+ program.body
372
373
  );
374
+ const compiledUPLC = (0, import_uplc.encodeUPLC)(
375
+ new import_uplc.UPLCProgram(program.version, appliedProgram)
376
+ ).toBuffer().buffer.buffer;
377
+ switch (encodingLevel) {
378
+ case "double":
379
+ return (0, import_core_utils2.toHex)((0, import_cbor_x2.encode)((0, import_cbor_x2.encode)(compiledUPLC)));
380
+ case "single":
381
+ return (0, import_core_utils2.toHex)((0, import_cbor_x2.encode)(compiledUPLC));
382
+ }
373
383
  }
374
384
 
375
385
  // src/address.ts
@@ -1176,7 +1186,53 @@ var PROTOCOL_PARAMETERS_DEFAULT = {
1176
1186
  "247": 43623,
1177
1187
  "248": 251,
1178
1188
  "249": 0,
1179
- "250": 1
1189
+ "250": 1,
1190
+ "251": 100181,
1191
+ "252": 726,
1192
+ "253": 719,
1193
+ "254": 0,
1194
+ "255": 1,
1195
+ "256": 100181,
1196
+ "257": 726,
1197
+ "258": 719,
1198
+ "259": 0,
1199
+ "260": 1,
1200
+ "261": 100181,
1201
+ "262": 726,
1202
+ "263": 719,
1203
+ "264": 0,
1204
+ "265": 1,
1205
+ "266": 107878,
1206
+ "267": 680,
1207
+ "268": 0,
1208
+ "269": 1,
1209
+ "270": 95336,
1210
+ "271": 1,
1211
+ "272": 281145,
1212
+ "273": 18848,
1213
+ "274": 0,
1214
+ "275": 1,
1215
+ "276": 180194,
1216
+ "277": 159,
1217
+ "278": 1,
1218
+ "279": 1,
1219
+ "280": 158519,
1220
+ "281": 8942,
1221
+ "282": 0,
1222
+ "283": 1,
1223
+ "284": 159378,
1224
+ "285": 8813,
1225
+ "286": 0,
1226
+ "287": 1,
1227
+ "288": 107490,
1228
+ "289": 3298,
1229
+ "290": 1,
1230
+ "291": 106057,
1231
+ "292": 655,
1232
+ "293": 1,
1233
+ "294": 1964219,
1234
+ "295": 24520,
1235
+ "296": 3
1180
1236
  }
1181
1237
  }
1182
1238
  };
@@ -1315,7 +1371,7 @@ function valueToAssets(value) {
1315
1371
  }
1316
1372
  function assetsToValue(assets) {
1317
1373
  const multiAsset = CML.MultiAsset.new();
1318
- const lovelace = assets["lovelace"] ? assets["lovelace"] : 0n;
1374
+ const lovelace = assets["lovelace"] ? BigInt(assets["lovelace"]) : 0n;
1319
1375
  const units = Object.keys(assets);
1320
1376
  const policies = Array.from(
1321
1377
  new Set(
@@ -1607,6 +1663,7 @@ var fromCMLRedeemerTag = (tag) => {
1607
1663
  };
1608
1664
  // Annotate the CommonJS export names for ESM import in node:
1609
1665
  0 && (module.exports = {
1666
+ CBOREncodingLevel,
1610
1667
  PROTOCOL_PARAMETERS_DEFAULT,
1611
1668
  addAssets,
1612
1669
  addressFromHexOrBech32,
package/dist/index.d.cts CHANGED
@@ -66,6 +66,7 @@ declare function validatorToRewardAddress(network: Network, validator: Certifica
66
66
  declare function getAddressDetails(address: string): AddressDetails;
67
67
 
68
68
  declare const applyDoubleCborEncoding: (script: string) => string;
69
+ declare const CBOREncodingLevel: (script: string) => "double" | "single";
69
70
  declare function datumJsonToCbor(json: DatumJson): Datum;
70
71
 
71
72
  declare function createCostModels(costModels: CostModels): CML.CostModels;
@@ -95,8 +96,6 @@ declare function fromScriptRef(scriptRef: CML.Script): Script;
95
96
  declare function mintingPolicyToId(mintingPolicy: MintingPolicy): PolicyId;
96
97
  /**
97
98
  * Applies a list of parameters, in the form of the `Data` type, to a CBOR encoded script.
98
- *
99
- * The `plutusScript` must be double CBOR encoded(bytes). Ensure to use the `applyDoubleCborEncoding` function.
100
99
  */
101
100
  declare function applyParamsToScript<T extends unknown[] = Data[]>(plutusScript: string, params: Exact<[...T]>, type?: T): string;
102
101
 
@@ -193,4 +192,4 @@ declare const stringify: (data: any) => string;
193
192
  declare const toCMLRedeemerTag: (tag: string) => CML.RedeemerTag;
194
193
  declare const fromCMLRedeemerTag: (tag: CML.RedeemerTag) => RedeemerTag;
195
194
 
196
- export { type CMLNative, PROTOCOL_PARAMETERS_DEFAULT, type SortOrder, addAssets, addressFromHexOrBech32, applyDoubleCborEncoding, applyParamsToScript, assetsToValue, calculateMinLovelaceFromUTxO, coreToOutRef, coreToTxOutput, coreToUtxo, coresToOutRefs, coresToTxOutputs, coresToUtxos, createCostModels, credentialToAddress, credentialToRewardAddress, datumJsonToCbor, datumToHash, fromCMLRedeemerTag, fromLabel, fromScriptRef, fromUnit, generatePrivateKey, generateSeedPhrase, getAddressDetails, getInputIndices, getUniqueTokenName, isEqualUTxO, keyHashToCredential, mintingPolicyToId, networkToId, parseCMLNative, paymentCredentialOf, scriptFromCMLNative, scriptFromNative, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortCanonical, sortUTxOs, stakeCredentialOf, stringify, toCMLNativeScript, toCMLRedeemerTag, toLabel, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
195
+ export { CBOREncodingLevel, type CMLNative, PROTOCOL_PARAMETERS_DEFAULT, type SortOrder, addAssets, addressFromHexOrBech32, applyDoubleCborEncoding, applyParamsToScript, assetsToValue, calculateMinLovelaceFromUTxO, coreToOutRef, coreToTxOutput, coreToUtxo, coresToOutRefs, coresToTxOutputs, coresToUtxos, createCostModels, credentialToAddress, credentialToRewardAddress, datumJsonToCbor, datumToHash, fromCMLRedeemerTag, fromLabel, fromScriptRef, fromUnit, generatePrivateKey, generateSeedPhrase, getAddressDetails, getInputIndices, getUniqueTokenName, isEqualUTxO, keyHashToCredential, mintingPolicyToId, networkToId, parseCMLNative, paymentCredentialOf, scriptFromCMLNative, scriptFromNative, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortCanonical, sortUTxOs, stakeCredentialOf, stringify, toCMLNativeScript, toCMLRedeemerTag, toLabel, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
package/dist/index.d.ts CHANGED
@@ -66,6 +66,7 @@ declare function validatorToRewardAddress(network: Network, validator: Certifica
66
66
  declare function getAddressDetails(address: string): AddressDetails;
67
67
 
68
68
  declare const applyDoubleCborEncoding: (script: string) => string;
69
+ declare const CBOREncodingLevel: (script: string) => "double" | "single";
69
70
  declare function datumJsonToCbor(json: DatumJson): Datum;
70
71
 
71
72
  declare function createCostModels(costModels: CostModels): CML.CostModels;
@@ -95,8 +96,6 @@ declare function fromScriptRef(scriptRef: CML.Script): Script;
95
96
  declare function mintingPolicyToId(mintingPolicy: MintingPolicy): PolicyId;
96
97
  /**
97
98
  * Applies a list of parameters, in the form of the `Data` type, to a CBOR encoded script.
98
- *
99
- * The `plutusScript` must be double CBOR encoded(bytes). Ensure to use the `applyDoubleCborEncoding` function.
100
99
  */
101
100
  declare function applyParamsToScript<T extends unknown[] = Data[]>(plutusScript: string, params: Exact<[...T]>, type?: T): string;
102
101
 
@@ -193,4 +192,4 @@ declare const stringify: (data: any) => string;
193
192
  declare const toCMLRedeemerTag: (tag: string) => CML.RedeemerTag;
194
193
  declare const fromCMLRedeemerTag: (tag: CML.RedeemerTag) => RedeemerTag;
195
194
 
196
- export { type CMLNative, PROTOCOL_PARAMETERS_DEFAULT, type SortOrder, addAssets, addressFromHexOrBech32, applyDoubleCborEncoding, applyParamsToScript, assetsToValue, calculateMinLovelaceFromUTxO, coreToOutRef, coreToTxOutput, coreToUtxo, coresToOutRefs, coresToTxOutputs, coresToUtxos, createCostModels, credentialToAddress, credentialToRewardAddress, datumJsonToCbor, datumToHash, fromCMLRedeemerTag, fromLabel, fromScriptRef, fromUnit, generatePrivateKey, generateSeedPhrase, getAddressDetails, getInputIndices, getUniqueTokenName, isEqualUTxO, keyHashToCredential, mintingPolicyToId, networkToId, parseCMLNative, paymentCredentialOf, scriptFromCMLNative, scriptFromNative, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortCanonical, sortUTxOs, stakeCredentialOf, stringify, toCMLNativeScript, toCMLRedeemerTag, toLabel, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
195
+ export { CBOREncodingLevel, type CMLNative, PROTOCOL_PARAMETERS_DEFAULT, type SortOrder, addAssets, addressFromHexOrBech32, applyDoubleCborEncoding, applyParamsToScript, assetsToValue, calculateMinLovelaceFromUTxO, coreToOutRef, coreToTxOutput, coreToUtxo, coresToOutRefs, coresToTxOutputs, coresToUtxos, createCostModels, credentialToAddress, credentialToRewardAddress, datumJsonToCbor, datumToHash, fromCMLRedeemerTag, fromLabel, fromScriptRef, fromUnit, generatePrivateKey, generateSeedPhrase, getAddressDetails, getInputIndices, getUniqueTokenName, isEqualUTxO, keyHashToCredential, mintingPolicyToId, networkToId, parseCMLNative, paymentCredentialOf, scriptFromCMLNative, scriptFromNative, scriptHashToCredential, selectUTxOs, slotToUnixTime, sortCanonical, sortUTxOs, stakeCredentialOf, stringify, toCMLNativeScript, toCMLRedeemerTag, toLabel, toPublicKey, toScriptRef, toUnit, unixTimeToSlot, utxoToCore, utxoToTransactionInput, utxoToTransactionOutput, utxosToCores, validatorToAddress, validatorToRewardAddress, validatorToScriptHash, valueToAssets };
package/dist/index.js CHANGED
@@ -100,13 +100,31 @@ function networkToId(network) {
100
100
 
101
101
  // src/cbor.ts
102
102
  import { fromHex, toHex } from "@lucid-evolution/core-utils";
103
- import { decode, encode } from "cborg";
103
+ import { decode, encode } from "cbor-x";
104
104
  var applyDoubleCborEncoding = (script) => {
105
105
  try {
106
106
  decode(decode(fromHex(script)));
107
107
  return script;
108
108
  } catch (error) {
109
- return toHex(encode(fromHex(script)));
109
+ try {
110
+ decode(fromHex(script));
111
+ return toHex(Uint8Array.from(encode(fromHex(script).buffer)));
112
+ } catch (error2) {
113
+ return toHex(Uint8Array.from(encode(encode(fromHex(script).buffer))));
114
+ }
115
+ }
116
+ };
117
+ var CBOREncodingLevel = (script) => {
118
+ try {
119
+ decode(decode(fromHex(script)));
120
+ return "double";
121
+ } catch (error) {
122
+ try {
123
+ decode(fromHex(script));
124
+ return "single";
125
+ } catch (error2) {
126
+ throw new Error("Script is not CBOR-encoded or invalid format.");
127
+ }
110
128
  }
111
129
  };
112
130
  function datumJsonToCbor(json) {
@@ -161,7 +179,7 @@ import {
161
179
  UPLCProgram
162
180
  } from "@harmoniclabs/uplc";
163
181
  import { fromHex as fromHex2, toHex as toHex2 } from "@lucid-evolution/core-utils";
164
- import { decode as decode2, encode as encode2 } from "cborg";
182
+ import { decode as decode2, encode as encode2 } from "cbor-x";
165
183
  import { dataFromCbor } from "@harmoniclabs/plutus-data";
166
184
  function validatorToAddress(network, validator, stakeCredential) {
167
185
  const validatorHash = validatorToScriptHash(validator);
@@ -188,21 +206,15 @@ function validatorToScriptHash(validator) {
188
206
  return CML.NativeScript.from_cbor_hex(validator.script).hash().to_hex();
189
207
  case "PlutusV1":
190
208
  return CML.PlutusScript.from_v1(
191
- CML.PlutusV1Script.from_cbor_hex(
192
- applyDoubleCborEncoding(validator.script)
193
- )
209
+ CML.PlutusV1Script.from_cbor_hex(validator.script)
194
210
  ).hash().to_hex();
195
211
  case "PlutusV2":
196
212
  return CML.PlutusScript.from_v2(
197
- CML.PlutusV2Script.from_cbor_hex(
198
- applyDoubleCborEncoding(validator.script)
199
- )
213
+ CML.PlutusV2Script.from_cbor_hex(validator.script)
200
214
  ).hash().to_hex();
201
215
  case "PlutusV3":
202
216
  return CML.PlutusScript.from_v3(
203
- CML.PlutusV3Script.from_cbor_hex(
204
- applyDoubleCborEncoding(validator.script)
205
- )
217
+ CML.PlutusV3Script.from_cbor_hex(validator.script)
206
218
  ).hash().to_hex();
207
219
  default:
208
220
  throw new Error("No variant matched");
@@ -216,21 +228,15 @@ function toScriptRef(script) {
216
228
  );
217
229
  case "PlutusV1":
218
230
  return CML.Script.new_plutus_v1(
219
- CML.PlutusV1Script.from_cbor_hex(
220
- applyDoubleCborEncoding(script.script)
221
- )
231
+ CML.PlutusV1Script.from_cbor_hex(script.script)
222
232
  );
223
233
  case "PlutusV2":
224
234
  return CML.Script.new_plutus_v2(
225
- CML.PlutusV2Script.from_cbor_hex(
226
- applyDoubleCborEncoding(script.script)
227
- )
235
+ CML.PlutusV2Script.from_cbor_hex(script.script)
228
236
  );
229
237
  case "PlutusV3":
230
238
  return CML.Script.new_plutus_v3(
231
- CML.PlutusV3Script.from_cbor_hex(
232
- applyDoubleCborEncoding(script.script)
233
- )
239
+ CML.PlutusV3Script.from_cbor_hex(script.script)
234
240
  );
235
241
  default:
236
242
  throw new Error("No variant matched.");
@@ -267,23 +273,26 @@ function mintingPolicyToId(mintingPolicy) {
267
273
  return validatorToScriptHash(mintingPolicy);
268
274
  }
269
275
  function applyParamsToScript(plutusScript, params, type) {
270
- const program = parseUPLC(
271
- decode2(decode2(fromHex2(applyDoubleCborEncoding(plutusScript)))),
272
- "flat"
273
- );
276
+ const encodingLevel = CBOREncodingLevel(plutusScript);
277
+ const program = encodingLevel === "double" ? parseUPLC(decode2(decode2(fromHex2(plutusScript))), "flat") : parseUPLC(decode2(fromHex2(plutusScript)), "flat");
274
278
  const parameters = type ? Data.castTo(params, type) : params;
275
- const appliedProgram = parameters.reduce((body, currentParameter) => {
276
- const data = UPLCConst.data(dataFromCbor(Data.to(currentParameter)));
277
- const appliedParameter = new Application(body, data);
278
- return appliedParameter;
279
- }, program.body);
280
- return toHex2(
281
- encode2(
282
- encode2(
283
- encodeUPLC(new UPLCProgram(program.version, appliedProgram)).toBuffer().buffer
284
- )
285
- )
279
+ const appliedProgram = parameters.reduce(
280
+ (body, currentParameter) => {
281
+ const data = UPLCConst.data(dataFromCbor(Data.to(currentParameter)));
282
+ const appliedParameter = new Application(body, data);
283
+ return appliedParameter;
284
+ },
285
+ program.body
286
286
  );
287
+ const compiledUPLC = encodeUPLC(
288
+ new UPLCProgram(program.version, appliedProgram)
289
+ ).toBuffer().buffer.buffer;
290
+ switch (encodingLevel) {
291
+ case "double":
292
+ return toHex2(encode2(encode2(compiledUPLC)));
293
+ case "single":
294
+ return toHex2(encode2(compiledUPLC));
295
+ }
287
296
  }
288
297
 
289
298
  // src/address.ts
@@ -1090,7 +1099,53 @@ var PROTOCOL_PARAMETERS_DEFAULT = {
1090
1099
  "247": 43623,
1091
1100
  "248": 251,
1092
1101
  "249": 0,
1093
- "250": 1
1102
+ "250": 1,
1103
+ "251": 100181,
1104
+ "252": 726,
1105
+ "253": 719,
1106
+ "254": 0,
1107
+ "255": 1,
1108
+ "256": 100181,
1109
+ "257": 726,
1110
+ "258": 719,
1111
+ "259": 0,
1112
+ "260": 1,
1113
+ "261": 100181,
1114
+ "262": 726,
1115
+ "263": 719,
1116
+ "264": 0,
1117
+ "265": 1,
1118
+ "266": 107878,
1119
+ "267": 680,
1120
+ "268": 0,
1121
+ "269": 1,
1122
+ "270": 95336,
1123
+ "271": 1,
1124
+ "272": 281145,
1125
+ "273": 18848,
1126
+ "274": 0,
1127
+ "275": 1,
1128
+ "276": 180194,
1129
+ "277": 159,
1130
+ "278": 1,
1131
+ "279": 1,
1132
+ "280": 158519,
1133
+ "281": 8942,
1134
+ "282": 0,
1135
+ "283": 1,
1136
+ "284": 159378,
1137
+ "285": 8813,
1138
+ "286": 0,
1139
+ "287": 1,
1140
+ "288": 107490,
1141
+ "289": 3298,
1142
+ "290": 1,
1143
+ "291": 106057,
1144
+ "292": 655,
1145
+ "293": 1,
1146
+ "294": 1964219,
1147
+ "295": 24520,
1148
+ "296": 3
1094
1149
  }
1095
1150
  }
1096
1151
  };
@@ -1233,7 +1288,7 @@ function valueToAssets(value) {
1233
1288
  }
1234
1289
  function assetsToValue(assets) {
1235
1290
  const multiAsset = CML.MultiAsset.new();
1236
- const lovelace = assets["lovelace"] ? assets["lovelace"] : 0n;
1291
+ const lovelace = assets["lovelace"] ? BigInt(assets["lovelace"]) : 0n;
1237
1292
  const units = Object.keys(assets);
1238
1293
  const policies = Array.from(
1239
1294
  new Set(
@@ -1524,6 +1579,7 @@ var fromCMLRedeemerTag = (tag) => {
1524
1579
  }
1525
1580
  };
1526
1581
  export {
1582
+ CBOREncodingLevel,
1527
1583
  PROTOCOL_PARAMETERS_DEFAULT,
1528
1584
  addAssets,
1529
1585
  addressFromHexOrBech32,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucid-evolution/utils",
3
- "version": "0.1.53",
3
+ "version": "0.1.56",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -26,13 +26,13 @@
26
26
  "@emurgo/cardano-serialization-lib-nodejs": "@emurgo/cardano-serialization-lib-browser"
27
27
  },
28
28
  "dependencies": {
29
- "@anastasia-labs/cardano-multiplatform-lib-browser": "6.0.2-2",
30
- "@anastasia-labs/cardano-multiplatform-lib-nodejs": "6.0.2-2",
29
+ "@anastasia-labs/cardano-multiplatform-lib-browser": "6.0.2-3",
30
+ "@anastasia-labs/cardano-multiplatform-lib-nodejs": "6.0.2-3",
31
31
  "@effect/schema": "^0.68.16",
32
32
  "@harmoniclabs/plutus-data": "^1.2.4",
33
33
  "@harmoniclabs/uplc": "^1.2.4",
34
34
  "bip39": "^3.1.0",
35
- "cborg": "^4.2.0",
35
+ "cbor-x": "^1.6.0",
36
36
  "effect": "^3.10.4",
37
37
  "@lucid-evolution/core-types": "0.1.21",
38
38
  "@lucid-evolution/core-utils": "0.1.16",
@@ -47,7 +47,7 @@
47
47
  "vitest": "^1.6.0"
48
48
  },
49
49
  "scripts": {
50
- "build": "tsup src/index.ts --format esm,cjs --dts --clean",
50
+ "build": "tsup src/index.ts",
51
51
  "lint": "tsc --noEmit",
52
52
  "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
53
53
  "test": "vitest run"