@lucid-evolution/utils 0.1.54 → 0.1.58

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
@@ -192,14 +192,18 @@ function networkToId(network) {
192
192
 
193
193
  // src/cbor.ts
194
194
  var import_core_utils = require("@lucid-evolution/core-utils");
195
- var cbors = __toESM(require("@stricahq/cbors"), 1);
196
- var { Decoder, Encoder } = cbors;
195
+ var import_cbor_x = require("cbor-x");
197
196
  var applyDoubleCborEncoding = (script) => {
198
197
  try {
199
- Decoder.decode(Decoder.decode(Buffer.from((0, import_core_utils.fromHex)(script))).value);
198
+ (0, import_cbor_x.decode)((0, import_cbor_x.decode)((0, import_core_utils.fromHex)(script)));
200
199
  return script;
201
200
  } catch (error) {
202
- return (0, import_core_utils.toHex)(Encoder.encode((0, import_core_utils.fromHex)(script)));
201
+ try {
202
+ (0, import_cbor_x.decode)((0, import_core_utils.fromHex)(script));
203
+ return (0, import_core_utils.toHex)(Uint8Array.from((0, import_cbor_x.encode)((0, import_core_utils.fromHex)(script).buffer)));
204
+ } catch (error2) {
205
+ 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))));
206
+ }
203
207
  }
204
208
  };
205
209
  function datumJsonToCbor(json) {
@@ -248,9 +252,8 @@ function datumJsonToCbor(json) {
248
252
  var import_plutus = require("@lucid-evolution/plutus");
249
253
  var import_uplc = require("@harmoniclabs/uplc");
250
254
  var import_core_utils2 = require("@lucid-evolution/core-utils");
251
- var cbors2 = __toESM(require("@stricahq/cbors"), 1);
255
+ var import_cbor_x2 = require("cbor-x");
252
256
  var import_plutus_data = require("@harmoniclabs/plutus-data");
253
- var { Encoder: Encoder2, Decoder: Decoder2 } = cbors2;
254
257
  function validatorToAddress(network, validator, stakeCredential) {
255
258
  const validatorHash = validatorToScriptHash(validator);
256
259
  if (stakeCredential) {
@@ -356,11 +359,7 @@ function mintingPolicyToId(mintingPolicy) {
356
359
  }
357
360
  function applyParamsToScript(plutusScript, params, type) {
358
361
  const program = (0, import_uplc.parseUPLC)(
359
- Decoder2.decode(
360
- Decoder2.decode(
361
- Buffer.from((0, import_core_utils2.fromHex)(applyDoubleCborEncoding(plutusScript)))
362
- ).value
363
- ).value,
362
+ (0, import_cbor_x2.decode)((0, import_cbor_x2.decode)((0, import_core_utils2.fromHex)(applyDoubleCborEncoding(plutusScript)))),
364
363
  "flat"
365
364
  );
366
365
  const parameters = type ? import_plutus.Data.castTo(params, type) : params;
@@ -369,11 +368,9 @@ function applyParamsToScript(plutusScript, params, type) {
369
368
  const appliedParameter = new import_uplc.Application(body, data);
370
369
  return appliedParameter;
371
370
  }, program.body);
372
- return (0, import_core_utils2.toHex)(
373
- Encoder2.encode(
374
- Encoder2.encode(
375
- (0, import_uplc.encodeUPLC)(new import_uplc.UPLCProgram(program.version, appliedProgram)).toBuffer().buffer
376
- )
371
+ return applyDoubleCborEncoding(
372
+ (0, import_core_utils2.toHex)(
373
+ (0, import_uplc.encodeUPLC)(new import_uplc.UPLCProgram(program.version, appliedProgram)).toBuffer().buffer
377
374
  )
378
375
  );
379
376
  }
@@ -1182,7 +1179,53 @@ var PROTOCOL_PARAMETERS_DEFAULT = {
1182
1179
  "247": 43623,
1183
1180
  "248": 251,
1184
1181
  "249": 0,
1185
- "250": 1
1182
+ "250": 1,
1183
+ "251": 100181,
1184
+ "252": 726,
1185
+ "253": 719,
1186
+ "254": 0,
1187
+ "255": 1,
1188
+ "256": 100181,
1189
+ "257": 726,
1190
+ "258": 719,
1191
+ "259": 0,
1192
+ "260": 1,
1193
+ "261": 100181,
1194
+ "262": 726,
1195
+ "263": 719,
1196
+ "264": 0,
1197
+ "265": 1,
1198
+ "266": 107878,
1199
+ "267": 680,
1200
+ "268": 0,
1201
+ "269": 1,
1202
+ "270": 95336,
1203
+ "271": 1,
1204
+ "272": 281145,
1205
+ "273": 18848,
1206
+ "274": 0,
1207
+ "275": 1,
1208
+ "276": 180194,
1209
+ "277": 159,
1210
+ "278": 1,
1211
+ "279": 1,
1212
+ "280": 158519,
1213
+ "281": 8942,
1214
+ "282": 0,
1215
+ "283": 1,
1216
+ "284": 159378,
1217
+ "285": 8813,
1218
+ "286": 0,
1219
+ "287": 1,
1220
+ "288": 107490,
1221
+ "289": 3298,
1222
+ "290": 1,
1223
+ "291": 106057,
1224
+ "292": 655,
1225
+ "293": 1,
1226
+ "294": 1964219,
1227
+ "295": 24520,
1228
+ "296": 3
1186
1229
  }
1187
1230
  }
1188
1231
  };
@@ -1321,7 +1364,7 @@ function valueToAssets(value) {
1321
1364
  }
1322
1365
  function assetsToValue(assets) {
1323
1366
  const multiAsset = CML.MultiAsset.new();
1324
- const lovelace = assets["lovelace"] ? assets["lovelace"] : 0n;
1367
+ const lovelace = assets["lovelace"] ? BigInt(assets["lovelace"]) : 0n;
1325
1368
  const units = Object.keys(assets);
1326
1369
  const policies = Array.from(
1327
1370
  new Set(
package/dist/index.js CHANGED
@@ -100,14 +100,18 @@ function networkToId(network) {
100
100
 
101
101
  // src/cbor.ts
102
102
  import { fromHex, toHex } from "@lucid-evolution/core-utils";
103
- import * as cbors from "@stricahq/cbors";
104
- var { Decoder, Encoder } = cbors;
103
+ import { decode, encode } from "cbor-x";
105
104
  var applyDoubleCborEncoding = (script) => {
106
105
  try {
107
- Decoder.decode(Decoder.decode(Buffer.from(fromHex(script))).value);
106
+ decode(decode(fromHex(script)));
108
107
  return script;
109
108
  } catch (error) {
110
- return toHex(Encoder.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
+ }
111
115
  }
112
116
  };
113
117
  function datumJsonToCbor(json) {
@@ -162,9 +166,8 @@ import {
162
166
  UPLCProgram
163
167
  } from "@harmoniclabs/uplc";
164
168
  import { fromHex as fromHex2, toHex as toHex2 } from "@lucid-evolution/core-utils";
165
- import * as cbors2 from "@stricahq/cbors";
169
+ import { decode as decode2 } from "cbor-x";
166
170
  import { dataFromCbor } from "@harmoniclabs/plutus-data";
167
- var { Encoder: Encoder2, Decoder: Decoder2 } = cbors2;
168
171
  function validatorToAddress(network, validator, stakeCredential) {
169
172
  const validatorHash = validatorToScriptHash(validator);
170
173
  if (stakeCredential) {
@@ -270,11 +273,7 @@ function mintingPolicyToId(mintingPolicy) {
270
273
  }
271
274
  function applyParamsToScript(plutusScript, params, type) {
272
275
  const program = parseUPLC(
273
- Decoder2.decode(
274
- Decoder2.decode(
275
- Buffer.from(fromHex2(applyDoubleCborEncoding(plutusScript)))
276
- ).value
277
- ).value,
276
+ decode2(decode2(fromHex2(applyDoubleCborEncoding(plutusScript)))),
278
277
  "flat"
279
278
  );
280
279
  const parameters = type ? Data.castTo(params, type) : params;
@@ -283,11 +282,9 @@ function applyParamsToScript(plutusScript, params, type) {
283
282
  const appliedParameter = new Application(body, data);
284
283
  return appliedParameter;
285
284
  }, program.body);
286
- return toHex2(
287
- Encoder2.encode(
288
- Encoder2.encode(
289
- encodeUPLC(new UPLCProgram(program.version, appliedProgram)).toBuffer().buffer
290
- )
285
+ return applyDoubleCborEncoding(
286
+ toHex2(
287
+ encodeUPLC(new UPLCProgram(program.version, appliedProgram)).toBuffer().buffer
291
288
  )
292
289
  );
293
290
  }
@@ -1096,7 +1093,53 @@ var PROTOCOL_PARAMETERS_DEFAULT = {
1096
1093
  "247": 43623,
1097
1094
  "248": 251,
1098
1095
  "249": 0,
1099
- "250": 1
1096
+ "250": 1,
1097
+ "251": 100181,
1098
+ "252": 726,
1099
+ "253": 719,
1100
+ "254": 0,
1101
+ "255": 1,
1102
+ "256": 100181,
1103
+ "257": 726,
1104
+ "258": 719,
1105
+ "259": 0,
1106
+ "260": 1,
1107
+ "261": 100181,
1108
+ "262": 726,
1109
+ "263": 719,
1110
+ "264": 0,
1111
+ "265": 1,
1112
+ "266": 107878,
1113
+ "267": 680,
1114
+ "268": 0,
1115
+ "269": 1,
1116
+ "270": 95336,
1117
+ "271": 1,
1118
+ "272": 281145,
1119
+ "273": 18848,
1120
+ "274": 0,
1121
+ "275": 1,
1122
+ "276": 180194,
1123
+ "277": 159,
1124
+ "278": 1,
1125
+ "279": 1,
1126
+ "280": 158519,
1127
+ "281": 8942,
1128
+ "282": 0,
1129
+ "283": 1,
1130
+ "284": 159378,
1131
+ "285": 8813,
1132
+ "286": 0,
1133
+ "287": 1,
1134
+ "288": 107490,
1135
+ "289": 3298,
1136
+ "290": 1,
1137
+ "291": 106057,
1138
+ "292": 655,
1139
+ "293": 1,
1140
+ "294": 1964219,
1141
+ "295": 24520,
1142
+ "296": 3
1100
1143
  }
1101
1144
  }
1102
1145
  };
@@ -1239,7 +1282,7 @@ function valueToAssets(value) {
1239
1282
  }
1240
1283
  function assetsToValue(assets) {
1241
1284
  const multiAsset = CML.MultiAsset.new();
1242
- const lovelace = assets["lovelace"] ? assets["lovelace"] : 0n;
1285
+ const lovelace = assets["lovelace"] ? BigInt(assets["lovelace"]) : 0n;
1243
1286
  const units = Object.keys(assets);
1244
1287
  const policies = Array.from(
1245
1288
  new Set(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucid-evolution/utils",
3
- "version": "0.1.54",
3
+ "version": "0.1.58",
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
- "@stricahq/cbors": "^1.0.3",
35
34
  "bip39": "^3.1.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"