@settlemint/sdk-cli 2.4.0-pra6821f69 → 2.4.0-praf6ea8ac

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/cli.js +652 -579
  2. package/dist/cli.js.map +51 -51
  3. package/package.json +10 -8
package/dist/cli.js CHANGED
@@ -5149,7 +5149,7 @@ var require_sha2 = __commonJS((exports) => {
5149
5149
  exports.sha512_224 = (0, utils_ts_1.createHasher)(() => new SHA512_224);
5150
5150
  });
5151
5151
 
5152
- // ../../node_modules/@noble/curves/abstract/utils.js
5152
+ // ../../node_modules/eciesjs/node_modules/@noble/curves/abstract/utils.js
5153
5153
  var require_utils5 = __commonJS((exports) => {
5154
5154
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
5155
5155
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -5423,7 +5423,7 @@ var require_utils5 = __commonJS((exports) => {
5423
5423
  }
5424
5424
  });
5425
5425
 
5426
- // ../../node_modules/@noble/curves/abstract/modular.js
5426
+ // ../../node_modules/eciesjs/node_modules/@noble/curves/abstract/modular.js
5427
5427
  var require_modular = __commonJS((exports) => {
5428
5428
  Object.defineProperty(exports, "__esModule", { value: true });
5429
5429
  exports.isNegativeLE = undefined;
@@ -5753,7 +5753,7 @@ var require_modular = __commonJS((exports) => {
5753
5753
  }
5754
5754
  });
5755
5755
 
5756
- // ../../node_modules/@noble/curves/abstract/curve.js
5756
+ // ../../node_modules/eciesjs/node_modules/@noble/curves/abstract/curve.js
5757
5757
  var require_curve = __commonJS((exports) => {
5758
5758
  Object.defineProperty(exports, "__esModule", { value: true });
5759
5759
  exports.wNAF = wNAF;
@@ -6002,7 +6002,7 @@ var require_curve = __commonJS((exports) => {
6002
6002
  }
6003
6003
  });
6004
6004
 
6005
- // ../../node_modules/@noble/curves/abstract/edwards.js
6005
+ // ../../node_modules/eciesjs/node_modules/@noble/curves/abstract/edwards.js
6006
6006
  var require_edwards = __commonJS((exports) => {
6007
6007
  Object.defineProperty(exports, "__esModule", { value: true });
6008
6008
  exports.twistedEdwards = twistedEdwards;
@@ -6361,7 +6361,7 @@ var require_edwards = __commonJS((exports) => {
6361
6361
  }
6362
6362
  });
6363
6363
 
6364
- // ../../node_modules/@noble/curves/abstract/hash-to-curve.js
6364
+ // ../../node_modules/eciesjs/node_modules/@noble/curves/abstract/hash-to-curve.js
6365
6365
  var require_hash_to_curve = __commonJS((exports) => {
6366
6366
  Object.defineProperty(exports, "__esModule", { value: true });
6367
6367
  exports.expand_message_xmd = expand_message_xmd;
@@ -6514,7 +6514,7 @@ var require_hash_to_curve = __commonJS((exports) => {
6514
6514
  }
6515
6515
  });
6516
6516
 
6517
- // ../../node_modules/@noble/curves/abstract/montgomery.js
6517
+ // ../../node_modules/eciesjs/node_modules/@noble/curves/abstract/montgomery.js
6518
6518
  var require_montgomery = __commonJS((exports) => {
6519
6519
  Object.defineProperty(exports, "__esModule", { value: true });
6520
6520
  exports.montgomery = montgomery;
@@ -6621,7 +6621,7 @@ var require_montgomery = __commonJS((exports) => {
6621
6621
  }
6622
6622
  });
6623
6623
 
6624
- // ../../node_modules/@noble/curves/ed25519.js
6624
+ // ../../node_modules/eciesjs/node_modules/@noble/curves/ed25519.js
6625
6625
  var require_ed25519 = __commonJS((exports) => {
6626
6626
  Object.defineProperty(exports, "__esModule", { value: true });
6627
6627
  exports.hash_to_ristretto255 = exports.hashToRistretto255 = exports.RistrettoPoint = exports.encodeToCurve = exports.hashToCurve = exports.ed25519_hasher = exports.edwardsToMontgomery = exports.x25519 = exports.ed25519ph = exports.ed25519ctx = exports.ed25519 = exports.ED25519_TORSION_SUBGROUP = undefined;
@@ -7061,7 +7061,7 @@ var require_hmac = __commonJS((exports) => {
7061
7061
  exports.hmac.create = (hash, key) => new HMAC(hash, key);
7062
7062
  });
7063
7063
 
7064
- // ../../node_modules/@noble/curves/abstract/weierstrass.js
7064
+ // ../../node_modules/eciesjs/node_modules/@noble/curves/abstract/weierstrass.js
7065
7065
  var require_weierstrass = __commonJS((exports) => {
7066
7066
  Object.defineProperty(exports, "__esModule", { value: true });
7067
7067
  exports.DER = exports.DERErr = undefined;
@@ -7980,7 +7980,7 @@ var require_weierstrass = __commonJS((exports) => {
7980
7980
  }
7981
7981
  });
7982
7982
 
7983
- // ../../node_modules/@noble/curves/_shortw_utils.js
7983
+ // ../../node_modules/eciesjs/node_modules/@noble/curves/_shortw_utils.js
7984
7984
  var require__shortw_utils = __commonJS((exports) => {
7985
7985
  Object.defineProperty(exports, "__esModule", { value: true });
7986
7986
  exports.getHash = getHash;
@@ -8002,7 +8002,7 @@ var require__shortw_utils = __commonJS((exports) => {
8002
8002
  }
8003
8003
  });
8004
8004
 
8005
- // ../../node_modules/@noble/curves/secp256k1.js
8005
+ // ../../node_modules/eciesjs/node_modules/@noble/curves/secp256k1.js
8006
8006
  var require_secp256k1 = __commonJS((exports) => {
8007
8007
  Object.defineProperty(exports, "__esModule", { value: true });
8008
8008
  exports.encodeToCurve = exports.hashToCurve = exports.secp256k1_hasher = exports.schnorr = exports.secp256k1 = undefined;
@@ -231623,7 +231623,7 @@ function size(value4) {
231623
231623
  var init_size = () => {};
231624
231624
 
231625
231625
  // ../../node_modules/viem/_esm/errors/version.js
231626
- var version5 = "2.31.1";
231626
+ var version5 = "2.31.4";
231627
231627
 
231628
231628
  // ../../node_modules/viem/_esm/errors/base.js
231629
231629
  function walk(err, fn) {
@@ -232421,6 +232421,46 @@ function byteSwap32(arr) {
232421
232421
  }
232422
232422
  return arr;
232423
232423
  }
232424
+ function bytesToHex2(bytes) {
232425
+ abytes(bytes);
232426
+ if (hasHexBuiltin)
232427
+ return bytes.toHex();
232428
+ let hex = "";
232429
+ for (let i6 = 0;i6 < bytes.length; i6++) {
232430
+ hex += hexes2[bytes[i6]];
232431
+ }
232432
+ return hex;
232433
+ }
232434
+ function asciiToBase16(ch) {
232435
+ if (ch >= asciis._0 && ch <= asciis._9)
232436
+ return ch - asciis._0;
232437
+ if (ch >= asciis.A && ch <= asciis.F)
232438
+ return ch - (asciis.A - 10);
232439
+ if (ch >= asciis.a && ch <= asciis.f)
232440
+ return ch - (asciis.a - 10);
232441
+ return;
232442
+ }
232443
+ function hexToBytes2(hex) {
232444
+ if (typeof hex !== "string")
232445
+ throw new Error("hex string expected, got " + typeof hex);
232446
+ if (hasHexBuiltin)
232447
+ return Uint8Array.fromHex(hex);
232448
+ const hl = hex.length;
232449
+ const al = hl / 2;
232450
+ if (hl % 2)
232451
+ throw new Error("hex string expected, got unpadded hex of length " + hl);
232452
+ const array4 = new Uint8Array(al);
232453
+ for (let ai = 0, hi = 0;ai < al; ai++, hi += 2) {
232454
+ const n1 = asciiToBase16(hex.charCodeAt(hi));
232455
+ const n22 = asciiToBase16(hex.charCodeAt(hi + 1));
232456
+ if (n1 === undefined || n22 === undefined) {
232457
+ const char = hex[hi] + hex[hi + 1];
232458
+ throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
232459
+ }
232460
+ array4[ai] = n1 * 16 + n22;
232461
+ }
232462
+ return array4;
232463
+ }
232424
232464
  function utf8ToBytes(str) {
232425
232465
  if (typeof str !== "string")
232426
232466
  throw new Error("string expected");
@@ -232467,12 +232507,15 @@ function randomBytes(bytesLength = 32) {
232467
232507
  }
232468
232508
  throw new Error("crypto.getRandomValues must be defined");
232469
232509
  }
232470
- var isLE, swap32IfBE;
232510
+ var isLE, swap32IfBE, hasHexBuiltin, hexes2, asciis;
232471
232511
  var init_utils2 = __esm(() => {
232472
232512
  init_cryptoNode();
232473
232513
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
232474
232514
  isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
232475
232515
  swap32IfBE = isLE ? (u6) => u6 : byteSwap32;
232516
+ hasHexBuiltin = /* @__PURE__ */ (() => typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function")();
232517
+ hexes2 = /* @__PURE__ */ Array.from({ length: 256 }, (_5, i6) => i6.toString(16).padStart(2, "0"));
232518
+ asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
232476
232519
  });
232477
232520
 
232478
232521
  // ../../node_modules/@noble/hashes/esm/sha3.js
@@ -235138,14 +235181,7 @@ var init_hmac = __esm(() => {
235138
235181
  hmac.create = (hash2, key2) => new HMAC(hash2, key2);
235139
235182
  });
235140
235183
 
235141
- // ../../node_modules/@noble/curves/esm/abstract/utils.js
235142
- function isBytes2(a7) {
235143
- return a7 instanceof Uint8Array || ArrayBuffer.isView(a7) && a7.constructor.name === "Uint8Array";
235144
- }
235145
- function abytes2(item) {
235146
- if (!isBytes2(item))
235147
- throw new Error("Uint8Array expected");
235148
- }
235184
+ // ../../node_modules/@noble/curves/esm/utils.js
235149
235185
  function abool(title, value4) {
235150
235186
  if (typeof value4 !== "boolean")
235151
235187
  throw new Error(title + " boolean expected, got " + value4);
@@ -235159,51 +235195,11 @@ function hexToNumber2(hex) {
235159
235195
  throw new Error("hex string expected, got " + typeof hex);
235160
235196
  return hex === "" ? _0n2 : BigInt("0x" + hex);
235161
235197
  }
235162
- function bytesToHex2(bytes) {
235163
- abytes2(bytes);
235164
- if (hasHexBuiltin)
235165
- return bytes.toHex();
235166
- let hex = "";
235167
- for (let i6 = 0;i6 < bytes.length; i6++) {
235168
- hex += hexes2[bytes[i6]];
235169
- }
235170
- return hex;
235171
- }
235172
- function asciiToBase16(ch) {
235173
- if (ch >= asciis._0 && ch <= asciis._9)
235174
- return ch - asciis._0;
235175
- if (ch >= asciis.A && ch <= asciis.F)
235176
- return ch - (asciis.A - 10);
235177
- if (ch >= asciis.a && ch <= asciis.f)
235178
- return ch - (asciis.a - 10);
235179
- return;
235180
- }
235181
- function hexToBytes2(hex) {
235182
- if (typeof hex !== "string")
235183
- throw new Error("hex string expected, got " + typeof hex);
235184
- if (hasHexBuiltin)
235185
- return Uint8Array.fromHex(hex);
235186
- const hl = hex.length;
235187
- const al = hl / 2;
235188
- if (hl % 2)
235189
- throw new Error("hex string expected, got unpadded hex of length " + hl);
235190
- const array4 = new Uint8Array(al);
235191
- for (let ai = 0, hi = 0;ai < al; ai++, hi += 2) {
235192
- const n1 = asciiToBase16(hex.charCodeAt(hi));
235193
- const n22 = asciiToBase16(hex.charCodeAt(hi + 1));
235194
- if (n1 === undefined || n22 === undefined) {
235195
- const char = hex[hi] + hex[hi + 1];
235196
- throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
235197
- }
235198
- array4[ai] = n1 * 16 + n22;
235199
- }
235200
- return array4;
235201
- }
235202
235198
  function bytesToNumberBE(bytes) {
235203
235199
  return hexToNumber2(bytesToHex2(bytes));
235204
235200
  }
235205
235201
  function bytesToNumberLE(bytes) {
235206
- abytes2(bytes);
235202
+ abytes(bytes);
235207
235203
  return hexToNumber2(bytesToHex2(Uint8Array.from(bytes).reverse()));
235208
235204
  }
235209
235205
  function numberToBytesBE(n6, len) {
@@ -235220,7 +235216,7 @@ function ensureBytes(title, hex, expectedLength) {
235220
235216
  } catch (e10) {
235221
235217
  throw new Error(title + " must be hex string or Uint8Array, cause: " + e10);
235222
235218
  }
235223
- } else if (isBytes2(hex)) {
235219
+ } else if (isBytes(hex)) {
235224
235220
  res = Uint8Array.from(hex);
235225
235221
  } else {
235226
235222
  throw new Error(title + " must be hex string or Uint8Array");
@@ -235230,26 +235226,6 @@ function ensureBytes(title, hex, expectedLength) {
235230
235226
  throw new Error(title + " of length " + expectedLength + " expected, got " + len);
235231
235227
  return res;
235232
235228
  }
235233
- function concatBytes3(...arrays) {
235234
- let sum = 0;
235235
- for (let i6 = 0;i6 < arrays.length; i6++) {
235236
- const a7 = arrays[i6];
235237
- abytes2(a7);
235238
- sum += a7.length;
235239
- }
235240
- const res = new Uint8Array(sum);
235241
- for (let i6 = 0, pad2 = 0;i6 < arrays.length; i6++) {
235242
- const a7 = arrays[i6];
235243
- res.set(a7, pad2);
235244
- pad2 += a7.length;
235245
- }
235246
- return res;
235247
- }
235248
- function utf8ToBytes2(str) {
235249
- if (typeof str !== "string")
235250
- throw new Error("string expected");
235251
- return new Uint8Array(new TextEncoder().encode(str));
235252
- }
235253
235229
  function inRange(n6, min, max) {
235254
235230
  return isPosBig(n6) && isPosBig(min) && isPosBig(max) && min <= n6 && n6 < max;
235255
235231
  }
@@ -235270,6 +235246,8 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
235270
235246
  throw new Error("qByteLen must be a number");
235271
235247
  if (typeof hmacFn !== "function")
235272
235248
  throw new Error("hmacFn must be a function");
235249
+ const u8n = (len) => new Uint8Array(len);
235250
+ const u8of = (byte) => Uint8Array.of(byte);
235273
235251
  let v6 = u8n(hashLen);
235274
235252
  let k5 = u8n(hashLen);
235275
235253
  let i6 = 0;
@@ -235280,11 +235258,11 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
235280
235258
  };
235281
235259
  const h8 = (...b4) => hmacFn(k5, v6, ...b4);
235282
235260
  const reseed = (seed = u8n(0)) => {
235283
- k5 = h8(u8fr([0]), seed);
235261
+ k5 = h8(u8of(0), seed);
235284
235262
  v6 = h8();
235285
235263
  if (seed.length === 0)
235286
235264
  return;
235287
- k5 = h8(u8fr([1]), seed);
235265
+ k5 = h8(u8of(1), seed);
235288
235266
  v6 = h8();
235289
235267
  };
235290
235268
  const gen2 = () => {
@@ -235298,7 +235276,7 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
235298
235276
  out.push(sl);
235299
235277
  len += v6.length;
235300
235278
  }
235301
- return concatBytes3(...out);
235279
+ return concatBytes(...out);
235302
235280
  };
235303
235281
  const genUntil = (seed, pred) => {
235304
235282
  reset2();
@@ -235311,23 +235289,22 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
235311
235289
  };
235312
235290
  return genUntil;
235313
235291
  }
235314
- function validateObject(object4, validators, optValidators = {}) {
235315
- const checkField = (fieldName, type4, isOptional) => {
235316
- const checkVal = validatorFns[type4];
235317
- if (typeof checkVal !== "function")
235318
- throw new Error("invalid validator function");
235292
+ function isHash(val) {
235293
+ return typeof val === "function" && Number.isSafeInteger(val.outputLen);
235294
+ }
235295
+ function _validateObject(object4, fields, optFields = {}) {
235296
+ if (!object4 || typeof object4 !== "object")
235297
+ throw new Error("expected valid options object");
235298
+ function checkField(fieldName, expectedType, isOpt) {
235319
235299
  const val = object4[fieldName];
235320
- if (isOptional && val === undefined)
235300
+ if (isOpt && val === undefined)
235321
235301
  return;
235322
- if (!checkVal(val, object4)) {
235323
- throw new Error("param " + String(fieldName) + " is invalid. Expected " + type4 + ", got " + val);
235324
- }
235325
- };
235326
- for (const [fieldName, type4] of Object.entries(validators))
235327
- checkField(fieldName, type4, false);
235328
- for (const [fieldName, type4] of Object.entries(optValidators))
235329
- checkField(fieldName, type4, true);
235330
- return object4;
235302
+ const current = typeof val;
235303
+ if (current !== expectedType || val === null)
235304
+ throw new Error(`param "${fieldName}" is invalid: expected ${expectedType}, got ${current}`);
235305
+ }
235306
+ Object.entries(fields).forEach(([k5, v6]) => checkField(k5, v6, false));
235307
+ Object.entries(optFields).forEach(([k5, v6]) => checkField(k5, v6, true));
235331
235308
  }
235332
235309
  function memoized(fn) {
235333
235310
  const map6 = new WeakMap;
@@ -235340,25 +235317,13 @@ function memoized(fn) {
235340
235317
  return computed;
235341
235318
  };
235342
235319
  }
235343
- var _0n2, _1n2, hasHexBuiltin, hexes2, asciis, isPosBig = (n6) => typeof n6 === "bigint" && _0n2 <= n6, bitMask = (n6) => (_1n2 << BigInt(n6)) - _1n2, u8n = (len) => new Uint8Array(len), u8fr = (arr) => Uint8Array.from(arr), validatorFns;
235320
+ var _0n2, _1n2, isPosBig = (n6) => typeof n6 === "bigint" && _0n2 <= n6, bitMask = (n6) => (_1n2 << BigInt(n6)) - _1n2;
235344
235321
  var init_utils3 = __esm(() => {
235322
+ init_utils2();
235323
+ init_utils2();
235345
235324
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
235346
235325
  _0n2 = /* @__PURE__ */ BigInt(0);
235347
235326
  _1n2 = /* @__PURE__ */ BigInt(1);
235348
- hasHexBuiltin = typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function";
235349
- hexes2 = /* @__PURE__ */ Array.from({ length: 256 }, (_5, i6) => i6.toString(16).padStart(2, "0"));
235350
- asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
235351
- validatorFns = {
235352
- bigint: (val) => typeof val === "bigint",
235353
- function: (val) => typeof val === "function",
235354
- boolean: (val) => typeof val === "boolean",
235355
- string: (val) => typeof val === "string",
235356
- stringOrUint8Array: (val) => typeof val === "string" || isBytes2(val),
235357
- isSafeInteger: (val) => Number.isSafeInteger(val),
235358
- array: (val) => Array.isArray(val),
235359
- field: (val, object4) => object4.Fp.isValid(val),
235360
- hash: (val) => typeof val === "function" && Number.isSafeInteger(val.outputLen)
235361
- };
235362
235327
  });
235363
235328
 
235364
235329
  // ../../node_modules/@noble/curves/esm/abstract/modular.js
@@ -235472,14 +235437,15 @@ function validateField(field2) {
235472
235437
  const initial = {
235473
235438
  ORDER: "bigint",
235474
235439
  MASK: "bigint",
235475
- BYTES: "isSafeInteger",
235476
- BITS: "isSafeInteger"
235440
+ BYTES: "number",
235441
+ BITS: "number"
235477
235442
  };
235478
235443
  const opts = FIELD_FIELDS.reduce((map6, val) => {
235479
235444
  map6[val] = "function";
235480
235445
  return map6;
235481
235446
  }, initial);
235482
- return validateObject(field2, opts);
235447
+ _validateObject(field2, opts);
235448
+ return field2;
235483
235449
  }
235484
235450
  function FpPow(Fp, num, power) {
235485
235451
  if (power < _0n3)
@@ -235532,10 +235498,28 @@ function nLength(n6, nBitLength) {
235532
235498
  const nByteLength = Math.ceil(_nBitLength / 8);
235533
235499
  return { nBitLength: _nBitLength, nByteLength };
235534
235500
  }
235535
- function Field(ORDER, bitLen2, isLE2 = false, redef = {}) {
235501
+ function Field(ORDER, bitLenOrOpts, isLE2 = false, opts = {}) {
235536
235502
  if (ORDER <= _0n3)
235537
235503
  throw new Error("invalid field: expected ORDER > 0, got " + ORDER);
235538
- const { nBitLength: BITS, nByteLength: BYTES } = nLength(ORDER, bitLen2);
235504
+ let _nbitLength = undefined;
235505
+ let _sqrt = undefined;
235506
+ if (typeof bitLenOrOpts === "object" && bitLenOrOpts != null) {
235507
+ if (opts.sqrt || isLE2)
235508
+ throw new Error("cannot specify opts in two arguments");
235509
+ const _opts = bitLenOrOpts;
235510
+ if (_opts.BITS)
235511
+ _nbitLength = _opts.BITS;
235512
+ if (_opts.sqrt)
235513
+ _sqrt = _opts.sqrt;
235514
+ if (typeof _opts.isLE === "boolean")
235515
+ isLE2 = _opts.isLE;
235516
+ } else {
235517
+ if (typeof bitLenOrOpts === "number")
235518
+ _nbitLength = bitLenOrOpts;
235519
+ if (opts.sqrt)
235520
+ _sqrt = opts.sqrt;
235521
+ }
235522
+ const { nBitLength: BITS, nByteLength: BYTES } = nLength(ORDER, _nbitLength);
235539
235523
  if (BYTES > 2048)
235540
235524
  throw new Error("invalid field: expected ORDER of <= 2048 bytes");
235541
235525
  let sqrtP;
@@ -235554,6 +235538,7 @@ function Field(ORDER, bitLen2, isLE2 = false, redef = {}) {
235554
235538
  return _0n3 <= num && num < ORDER;
235555
235539
  },
235556
235540
  is0: (num) => num === _0n3,
235541
+ isValidNot0: (num) => !f5.is0(num) && f5.isValid(num),
235557
235542
  isOdd: (num) => (num & _1n3) === _1n3,
235558
235543
  neg: (num) => mod(-num, ORDER),
235559
235544
  eql: (lhs, rhs) => lhs === rhs,
@@ -235568,7 +235553,7 @@ function Field(ORDER, bitLen2, isLE2 = false, redef = {}) {
235568
235553
  subN: (lhs, rhs) => lhs - rhs,
235569
235554
  mulN: (lhs, rhs) => lhs * rhs,
235570
235555
  inv: (num) => invert(num, ORDER),
235571
- sqrt: redef.sqrt || ((n6) => {
235556
+ sqrt: _sqrt || ((n6) => {
235572
235557
  if (!sqrtP)
235573
235558
  sqrtP = FpSqrt(ORDER);
235574
235559
  return sqrtP(f5, n6);
@@ -235606,7 +235591,6 @@ function mapHashToField(key2, fieldOrder, isLE2 = false) {
235606
235591
  }
235607
235592
  var _0n3, _1n3, _2n2, _3n, _4n, _5n, _8n, FIELD_FIELDS;
235608
235593
  var init_modular = __esm(() => {
235609
- init_utils2();
235610
235594
  init_utils3();
235611
235595
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
235612
235596
  _0n3 = BigInt(0);
@@ -235638,10 +235622,16 @@ var init_modular = __esm(() => {
235638
235622
  });
235639
235623
 
235640
235624
  // ../../node_modules/@noble/curves/esm/abstract/curve.js
235641
- function constTimeNegate(condition, item) {
235625
+ function negateCt(condition, item) {
235642
235626
  const neg = item.negate();
235643
235627
  return condition ? neg : item;
235644
235628
  }
235629
+ function normalizeZ(c3, property, points) {
235630
+ const getz = property === "pz" ? (p5) => p5.pz : (p5) => p5.ez;
235631
+ const toInv = FpInvertBatch(c3.Fp, points.map(getz));
235632
+ const affined = points.map((p5, i6) => p5.toAffine(toInv[i6]));
235633
+ return affined.map(c3.fromAffine);
235634
+ }
235645
235635
  function validateW(W5, bits) {
235646
235636
  if (!Number.isSafeInteger(W5) || W5 <= 0 || W5 > bits)
235647
235637
  throw new Error("invalid window size, expected [1.." + bits + "], got W=" + W5);
@@ -235690,9 +235680,13 @@ function validateMSMScalars(scalars, field2) {
235690
235680
  function getW(P5) {
235691
235681
  return pointWindowSizes.get(P5) || 1;
235692
235682
  }
235683
+ function assert0(n6) {
235684
+ if (n6 !== _0n4)
235685
+ throw new Error("invalid wNAF");
235686
+ }
235693
235687
  function wNAF(c3, bits) {
235694
235688
  return {
235695
- constTimeNegate,
235689
+ constTimeNegate: negateCt,
235696
235690
  hasPrecomputes(elm) {
235697
235691
  return getW(elm) !== 1;
235698
235692
  },
@@ -235730,11 +235724,12 @@ function wNAF(c3, bits) {
235730
235724
  const { nextN, offset, isZero, isNeg, isNegF, offsetF } = calcOffsets(n6, window2, wo);
235731
235725
  n6 = nextN;
235732
235726
  if (isZero) {
235733
- f5 = f5.add(constTimeNegate(isNegF, precomputes[offsetF]));
235727
+ f5 = f5.add(negateCt(isNegF, precomputes[offsetF]));
235734
235728
  } else {
235735
- p5 = p5.add(constTimeNegate(isNeg, precomputes[offset]));
235729
+ p5 = p5.add(negateCt(isNeg, precomputes[offset]));
235736
235730
  }
235737
235731
  }
235732
+ assert0(n6);
235738
235733
  return { p: p5, f: f5 };
235739
235734
  },
235740
235735
  wNAFUnsafe(W5, precomputes, n6, acc = c3.ZERO) {
@@ -235751,14 +235746,18 @@ function wNAF(c3, bits) {
235751
235746
  acc = acc.add(isNeg ? item.negate() : item);
235752
235747
  }
235753
235748
  }
235749
+ assert0(n6);
235754
235750
  return acc;
235755
235751
  },
235756
235752
  getPrecomputes(W5, P5, transform5) {
235757
235753
  let comp = pointPrecomputes.get(P5);
235758
235754
  if (!comp) {
235759
235755
  comp = this.precomputeWindow(P5, W5);
235760
- if (W5 !== 1)
235761
- pointPrecomputes.set(P5, transform5(comp));
235756
+ if (W5 !== 1) {
235757
+ if (typeof transform5 === "function")
235758
+ comp = transform5(comp);
235759
+ pointPrecomputes.set(P5, comp);
235760
+ }
235762
235761
  }
235763
235762
  return comp;
235764
235763
  },
@@ -235779,6 +235778,21 @@ function wNAF(c3, bits) {
235779
235778
  }
235780
235779
  };
235781
235780
  }
235781
+ function mulEndoUnsafe(c3, point, k1, k22) {
235782
+ let acc = point;
235783
+ let p1 = c3.ZERO;
235784
+ let p22 = c3.ZERO;
235785
+ while (k1 > _0n4 || k22 > _0n4) {
235786
+ if (k1 & _1n4)
235787
+ p1 = p1.add(acc);
235788
+ if (k22 & _1n4)
235789
+ p22 = p22.add(acc);
235790
+ acc = acc.double();
235791
+ k1 >>= _1n4;
235792
+ k22 >>= _1n4;
235793
+ }
235794
+ return { p1, p2: p22 };
235795
+ }
235782
235796
  function pippenger(c3, fieldN, points, scalars) {
235783
235797
  validateMSMPoints(points, c3);
235784
235798
  validateMSMScalars(scalars, fieldN);
@@ -235818,27 +235832,38 @@ function pippenger(c3, fieldN, points, scalars) {
235818
235832
  }
235819
235833
  return sum;
235820
235834
  }
235821
- function validateBasic(curve) {
235822
- validateField(curve.Fp);
235823
- validateObject(curve, {
235824
- n: "bigint",
235825
- h: "bigint",
235826
- Gx: "field",
235827
- Gy: "field"
235828
- }, {
235829
- nBitLength: "isSafeInteger",
235830
- nByteLength: "isSafeInteger"
235831
- });
235832
- return Object.freeze({
235833
- ...nLength(curve.n, curve.nBitLength),
235834
- ...curve,
235835
- ...{ p: curve.Fp.ORDER }
235836
- });
235835
+ function createField(order, field2) {
235836
+ if (field2) {
235837
+ if (field2.ORDER !== order)
235838
+ throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
235839
+ validateField(field2);
235840
+ return field2;
235841
+ } else {
235842
+ return Field(order);
235843
+ }
235844
+ }
235845
+ function _createCurveFields(type4, CURVE, curveOpts = {}) {
235846
+ if (!CURVE || typeof CURVE !== "object")
235847
+ throw new Error(`expected valid ${type4} CURVE object`);
235848
+ for (const p5 of ["p", "n", "h"]) {
235849
+ const val = CURVE[p5];
235850
+ if (!(typeof val === "bigint" && val > _0n4))
235851
+ throw new Error(`CURVE.${p5} must be positive bigint`);
235852
+ }
235853
+ const Fp = createField(CURVE.p, curveOpts.Fp);
235854
+ const Fn = createField(CURVE.n, curveOpts.Fn);
235855
+ const _b = type4 === "weierstrass" ? "b" : "d";
235856
+ const params = ["Gx", "Gy", "a", _b];
235857
+ for (const p5 of params) {
235858
+ if (!Fp.isValid(CURVE[p5]))
235859
+ throw new Error(`CURVE.${p5} must be valid field element of CURVE.Fp`);
235860
+ }
235861
+ return { Fp, Fn };
235837
235862
  }
235838
235863
  var _0n4, _1n4, pointPrecomputes, pointWindowSizes;
235839
235864
  var init_curve = __esm(() => {
235840
- init_modular();
235841
235865
  init_utils3();
235866
+ init_modular();
235842
235867
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
235843
235868
  _0n4 = BigInt(0);
235844
235869
  _1n4 = BigInt(1);
@@ -235853,54 +235878,116 @@ function validateSigVerOpts(opts) {
235853
235878
  if (opts.prehash !== undefined)
235854
235879
  abool("prehash", opts.prehash);
235855
235880
  }
235856
- function validatePointOpts(curve) {
235857
- const opts = validateBasic(curve);
235858
- validateObject(opts, {
235859
- a: "field",
235860
- b: "field"
235861
- }, {
235881
+ function _legacyHelperEquat(Fp, a7, b4) {
235882
+ function weierstrassEquation(x6) {
235883
+ const x22 = Fp.sqr(x6);
235884
+ const x32 = Fp.mul(x22, x6);
235885
+ return Fp.add(Fp.add(x32, Fp.mul(x6, a7)), b4);
235886
+ }
235887
+ return weierstrassEquation;
235888
+ }
235889
+ function _legacyHelperNormPriv(Fn, allowedPrivateKeyLengths, wrapPrivateKey) {
235890
+ const { BYTES: expected } = Fn;
235891
+ function normPrivateKeyToScalar(key2) {
235892
+ let num;
235893
+ if (typeof key2 === "bigint") {
235894
+ num = key2;
235895
+ } else {
235896
+ let bytes = ensureBytes("private key", key2);
235897
+ if (allowedPrivateKeyLengths) {
235898
+ if (!allowedPrivateKeyLengths.includes(bytes.length * 2))
235899
+ throw new Error("invalid private key");
235900
+ const padded = new Uint8Array(expected);
235901
+ padded.set(bytes, padded.length - bytes.length);
235902
+ bytes = padded;
235903
+ }
235904
+ try {
235905
+ num = Fn.fromBytes(bytes);
235906
+ } catch (error44) {
235907
+ throw new Error(`invalid private key: expected ui8a of size ${expected}, got ${typeof key2}`);
235908
+ }
235909
+ }
235910
+ if (wrapPrivateKey)
235911
+ num = Fn.create(num);
235912
+ if (!Fn.isValidNot0(num))
235913
+ throw new Error("invalid private key: out of range [1..N-1]");
235914
+ return num;
235915
+ }
235916
+ return normPrivateKeyToScalar;
235917
+ }
235918
+ function weierstrassN(CURVE, curveOpts = {}) {
235919
+ const { Fp, Fn } = _createCurveFields("weierstrass", CURVE, curveOpts);
235920
+ const { h: cofactor, n: CURVE_ORDER } = CURVE;
235921
+ _validateObject(curveOpts, {}, {
235862
235922
  allowInfinityPoint: "boolean",
235863
- allowedPrivateKeyLengths: "array",
235864
235923
  clearCofactor: "function",
235865
- fromBytes: "function",
235866
235924
  isTorsionFree: "function",
235925
+ fromBytes: "function",
235867
235926
  toBytes: "function",
235927
+ endo: "object",
235868
235928
  wrapPrivateKey: "boolean"
235869
235929
  });
235870
- const { endo, Fp, a: a7 } = opts;
235930
+ const { endo } = curveOpts;
235871
235931
  if (endo) {
235872
- if (!Fp.eql(a7, Fp.ZERO)) {
235873
- throw new Error("invalid endo: CURVE.a must be 0");
235874
- }
235875
- if (typeof endo !== "object" || typeof endo.beta !== "bigint" || typeof endo.splitScalar !== "function") {
235932
+ if (!Fp.is0(CURVE.a) || typeof endo.beta !== "bigint" || typeof endo.splitScalar !== "function") {
235876
235933
  throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function');
235877
235934
  }
235878
235935
  }
235879
- return Object.freeze({ ...opts });
235880
- }
235881
- function numToSizedHex(num, size2) {
235882
- return bytesToHex2(numberToBytesBE(num, size2));
235883
- }
235884
- function weierstrassPoints(opts) {
235885
- const CURVE = validatePointOpts(opts);
235886
- const { Fp } = CURVE;
235887
- const Fn = Field(CURVE.n, CURVE.nBitLength);
235888
- const toBytes3 = CURVE.toBytes || ((_c, point, _isCompressed) => {
235889
- const a7 = point.toAffine();
235890
- return concatBytes3(Uint8Array.from([4]), Fp.toBytes(a7.x), Fp.toBytes(a7.y));
235891
- });
235892
- const fromBytes = CURVE.fromBytes || ((bytes) => {
235936
+ function assertCompressionIsSupported() {
235937
+ if (!Fp.isOdd)
235938
+ throw new Error("compression is not supported: Field does not have .isOdd()");
235939
+ }
235940
+ function pointToBytes(_c, point, isCompressed) {
235941
+ const { x: x6, y: y4 } = point.toAffine();
235942
+ const bx = Fp.toBytes(x6);
235943
+ abool("isCompressed", isCompressed);
235944
+ if (isCompressed) {
235945
+ assertCompressionIsSupported();
235946
+ const hasEvenY = !Fp.isOdd(y4);
235947
+ return concatBytes(pprefix(hasEvenY), bx);
235948
+ } else {
235949
+ return concatBytes(Uint8Array.of(4), bx, Fp.toBytes(y4));
235950
+ }
235951
+ }
235952
+ function pointFromBytes(bytes) {
235953
+ abytes(bytes);
235954
+ const L5 = Fp.BYTES;
235955
+ const LC = L5 + 1;
235956
+ const LU = 2 * L5 + 1;
235957
+ const length = bytes.length;
235958
+ const head = bytes[0];
235893
235959
  const tail = bytes.subarray(1);
235894
- const x6 = Fp.fromBytes(tail.subarray(0, Fp.BYTES));
235895
- const y4 = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES));
235896
- return { x: x6, y: y4 };
235897
- });
235898
- function weierstrassEquation(x6) {
235899
- const { a: a7, b: b4 } = CURVE;
235900
- const x22 = Fp.sqr(x6);
235901
- const x32 = Fp.mul(x22, x6);
235902
- return Fp.add(Fp.add(x32, Fp.mul(x6, a7)), b4);
235960
+ if (length === LC && (head === 2 || head === 3)) {
235961
+ const x6 = Fp.fromBytes(tail);
235962
+ if (!Fp.isValid(x6))
235963
+ throw new Error("bad point: is not on curve, wrong x");
235964
+ const y22 = weierstrassEquation(x6);
235965
+ let y4;
235966
+ try {
235967
+ y4 = Fp.sqrt(y22);
235968
+ } catch (sqrtError) {
235969
+ const err = sqrtError instanceof Error ? ": " + sqrtError.message : "";
235970
+ throw new Error("bad point: is not on curve, sqrt error" + err);
235971
+ }
235972
+ assertCompressionIsSupported();
235973
+ const isYOdd = Fp.isOdd(y4);
235974
+ const isHeadOdd = (head & 1) === 1;
235975
+ if (isHeadOdd !== isYOdd)
235976
+ y4 = Fp.neg(y4);
235977
+ return { x: x6, y: y4 };
235978
+ } else if (length === LU && head === 4) {
235979
+ const x6 = Fp.fromBytes(tail.subarray(L5 * 0, L5 * 1));
235980
+ const y4 = Fp.fromBytes(tail.subarray(L5 * 1, L5 * 2));
235981
+ if (!isValidXY(x6, y4))
235982
+ throw new Error("bad point: is not on curve");
235983
+ return { x: x6, y: y4 };
235984
+ } else {
235985
+ throw new Error(`bad point: got length ${length}, expected compressed=${LC} or uncompressed=${LU}`);
235986
+ }
235903
235987
  }
235988
+ const toBytes3 = curveOpts.toBytes || pointToBytes;
235989
+ const fromBytes = curveOpts.fromBytes || pointFromBytes;
235990
+ const weierstrassEquation = _legacyHelperEquat(Fp, CURVE.a, CURVE.b);
235904
235991
  function isValidXY(x6, y4) {
235905
235992
  const left = Fp.sqr(y4);
235906
235993
  const right = weierstrassEquation(x6);
@@ -235912,28 +235999,10 @@ function weierstrassPoints(opts) {
235912
235999
  const _27b2 = Fp.mul(Fp.sqr(CURVE.b), BigInt(27));
235913
236000
  if (Fp.is0(Fp.add(_4a3, _27b2)))
235914
236001
  throw new Error("bad curve params: a or b");
235915
- function isWithinCurveOrder(num) {
235916
- return inRange(num, _1n5, CURVE.n);
235917
- }
235918
- function normPrivateKeyToScalar(key2) {
235919
- const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n: N6 } = CURVE;
235920
- if (lengths && typeof key2 !== "bigint") {
235921
- if (isBytes2(key2))
235922
- key2 = bytesToHex2(key2);
235923
- if (typeof key2 !== "string" || !lengths.includes(key2.length))
235924
- throw new Error("invalid private key");
235925
- key2 = key2.padStart(nByteLength * 2, "0");
235926
- }
235927
- let num;
235928
- try {
235929
- num = typeof key2 === "bigint" ? key2 : bytesToNumberBE(ensureBytes("private key", key2, nByteLength));
235930
- } catch (error44) {
235931
- throw new Error("invalid private key, expected hex or " + nByteLength + " bytes, got " + typeof key2);
235932
- }
235933
- if (wrapPrivateKey)
235934
- num = mod(num, N6);
235935
- aInRange("private key", num, _1n5, N6);
235936
- return num;
236002
+ function acoord(title, n6, banZero = false) {
236003
+ if (!Fp.isValid(n6) || banZero && Fp.is0(n6))
236004
+ throw new Error(`bad point coordinate ${title}`);
236005
+ return n6;
235937
236006
  }
235938
236007
  function aprjpoint(other) {
235939
236008
  if (!(other instanceof Point))
@@ -235957,31 +236026,31 @@ function weierstrassPoints(opts) {
235957
236026
  });
235958
236027
  const assertValidMemo = memoized((p5) => {
235959
236028
  if (p5.is0()) {
235960
- if (CURVE.allowInfinityPoint && !Fp.is0(p5.py))
236029
+ if (curveOpts.allowInfinityPoint && !Fp.is0(p5.py))
235961
236030
  return;
235962
236031
  throw new Error("bad point: ZERO");
235963
236032
  }
235964
236033
  const { x: x6, y: y4 } = p5.toAffine();
235965
236034
  if (!Fp.isValid(x6) || !Fp.isValid(y4))
235966
- throw new Error("bad point: x or y not FE");
236035
+ throw new Error("bad point: x or y not field elements");
235967
236036
  if (!isValidXY(x6, y4))
235968
236037
  throw new Error("bad point: equation left != right");
235969
236038
  if (!p5.isTorsionFree())
235970
236039
  throw new Error("bad point: not in prime-order subgroup");
235971
236040
  return true;
235972
236041
  });
236042
+ function finishEndo(endoBeta, k1p, k2p, k1neg, k2neg) {
236043
+ k2p = new Point(Fp.mul(k2p.px, endoBeta), k2p.py, k2p.pz);
236044
+ k1p = negateCt(k1neg, k1p);
236045
+ k2p = negateCt(k2neg, k2p);
236046
+ return k1p.add(k2p);
236047
+ }
235973
236048
 
235974
236049
  class Point {
235975
236050
  constructor(px, py, pz) {
235976
- if (px == null || !Fp.isValid(px))
235977
- throw new Error("x required");
235978
- if (py == null || !Fp.isValid(py) || Fp.is0(py))
235979
- throw new Error("y required");
235980
- if (pz == null || !Fp.isValid(pz))
235981
- throw new Error("z required");
235982
- this.px = px;
235983
- this.py = py;
235984
- this.pz = pz;
236051
+ this.px = acoord("x", px);
236052
+ this.py = acoord("y", py, true);
236053
+ this.pz = acoord("z", pz);
235985
236054
  Object.freeze(this);
235986
236055
  }
235987
236056
  static fromAffine(p5) {
@@ -235990,8 +236059,7 @@ function weierstrassPoints(opts) {
235990
236059
  throw new Error("invalid affine point");
235991
236060
  if (p5 instanceof Point)
235992
236061
  throw new Error("projective point not allowed");
235993
- const is0 = (i6) => Fp.eql(i6, Fp.ZERO);
235994
- if (is0(x6) && is0(y4))
236062
+ if (Fp.is0(x6) && Fp.is0(y4))
235995
236063
  return Point.ZERO;
235996
236064
  return new Point(x6, y4, Fp.ONE);
235997
236065
  }
@@ -236002,8 +236070,11 @@ function weierstrassPoints(opts) {
236002
236070
  return this.toAffine().y;
236003
236071
  }
236004
236072
  static normalizeZ(points) {
236005
- const toInv = FpInvertBatch(Fp, points.map((p5) => p5.pz));
236006
- return points.map((p5, i6) => p5.toAffine(toInv[i6])).map(Point.fromAffine);
236073
+ return normalizeZ(Point, "pz", points);
236074
+ }
236075
+ static fromBytes(bytes) {
236076
+ abytes(bytes);
236077
+ return Point.fromHex(bytes);
236007
236078
  }
236008
236079
  static fromHex(hex) {
236009
236080
  const P5 = Point.fromAffine(fromBytes(ensureBytes("pointHex", hex)));
@@ -236011,22 +236082,29 @@ function weierstrassPoints(opts) {
236011
236082
  return P5;
236012
236083
  }
236013
236084
  static fromPrivateKey(privateKey) {
236085
+ const normPrivateKeyToScalar = _legacyHelperNormPriv(Fn, curveOpts.allowedPrivateKeyLengths, curveOpts.wrapPrivateKey);
236014
236086
  return Point.BASE.multiply(normPrivateKeyToScalar(privateKey));
236015
236087
  }
236016
236088
  static msm(points, scalars) {
236017
236089
  return pippenger(Point, Fn, points, scalars);
236018
236090
  }
236019
- _setWindowSize(windowSize) {
236091
+ precompute(windowSize = 8, isLazy = true) {
236020
236092
  wnaf.setWindowSize(this, windowSize);
236093
+ if (!isLazy)
236094
+ this.multiply(_3n2);
236095
+ return this;
236096
+ }
236097
+ _setWindowSize(windowSize) {
236098
+ this.precompute(windowSize);
236021
236099
  }
236022
236100
  assertValidity() {
236023
236101
  assertValidMemo(this);
236024
236102
  }
236025
236103
  hasEvenY() {
236026
236104
  const { y: y4 } = this.toAffine();
236027
- if (Fp.isOdd)
236028
- return !Fp.isOdd(y4);
236029
- throw new Error("Field doesn't support isOdd");
236105
+ if (!Fp.isOdd)
236106
+ throw new Error("Field doesn't support isOdd");
236107
+ return !Fp.isOdd(y4);
236030
236108
  }
236031
236109
  equals(other) {
236032
236110
  aprjpoint(other);
@@ -236132,188 +236210,121 @@ function weierstrassPoints(opts) {
236132
236210
  is0() {
236133
236211
  return this.equals(Point.ZERO);
236134
236212
  }
236135
- wNAF(n6) {
236136
- return wnaf.wNAFCached(this, n6, Point.normalizeZ);
236137
- }
236138
- multiplyUnsafe(sc) {
236139
- const { endo: endo2, n: N6 } = CURVE;
236140
- aInRange("scalar", sc, _0n5, N6);
236141
- const I6 = Point.ZERO;
236142
- if (sc === _0n5)
236143
- return I6;
236144
- if (this.is0() || sc === _1n5)
236145
- return this;
236146
- if (!endo2 || wnaf.hasPrecomputes(this))
236147
- return wnaf.wNAFCachedUnsafe(this, sc, Point.normalizeZ);
236148
- let { k1neg, k1, k2neg, k2: k22 } = endo2.splitScalar(sc);
236149
- let k1p = I6;
236150
- let k2p = I6;
236151
- let d6 = this;
236152
- while (k1 > _0n5 || k22 > _0n5) {
236153
- if (k1 & _1n5)
236154
- k1p = k1p.add(d6);
236155
- if (k22 & _1n5)
236156
- k2p = k2p.add(d6);
236157
- d6 = d6.double();
236158
- k1 >>= _1n5;
236159
- k22 >>= _1n5;
236160
- }
236161
- if (k1neg)
236162
- k1p = k1p.negate();
236163
- if (k2neg)
236164
- k2p = k2p.negate();
236165
- k2p = new Point(Fp.mul(k2p.px, endo2.beta), k2p.py, k2p.pz);
236166
- return k1p.add(k2p);
236167
- }
236168
236213
  multiply(scalar) {
236169
- const { endo: endo2, n: N6 } = CURVE;
236170
- aInRange("scalar", scalar, _1n5, N6);
236214
+ const { endo: endo2 } = curveOpts;
236215
+ if (!Fn.isValidNot0(scalar))
236216
+ throw new Error("invalid scalar: out of range");
236171
236217
  let point, fake;
236218
+ const mul = (n6) => wnaf.wNAFCached(this, n6, Point.normalizeZ);
236172
236219
  if (endo2) {
236173
236220
  const { k1neg, k1, k2neg, k2: k22 } = endo2.splitScalar(scalar);
236174
- let { p: k1p, f: f1p } = this.wNAF(k1);
236175
- let { p: k2p, f: f2p } = this.wNAF(k22);
236176
- k1p = wnaf.constTimeNegate(k1neg, k1p);
236177
- k2p = wnaf.constTimeNegate(k2neg, k2p);
236178
- k2p = new Point(Fp.mul(k2p.px, endo2.beta), k2p.py, k2p.pz);
236179
- point = k1p.add(k2p);
236180
- fake = f1p.add(f2p);
236221
+ const { p: k1p, f: k1f } = mul(k1);
236222
+ const { p: k2p, f: k2f } = mul(k22);
236223
+ fake = k1f.add(k2f);
236224
+ point = finishEndo(endo2.beta, k1p, k2p, k1neg, k2neg);
236181
236225
  } else {
236182
- const { p: p5, f: f5 } = this.wNAF(scalar);
236226
+ const { p: p5, f: f5 } = mul(scalar);
236183
236227
  point = p5;
236184
236228
  fake = f5;
236185
236229
  }
236186
236230
  return Point.normalizeZ([point, fake])[0];
236187
236231
  }
236232
+ multiplyUnsafe(sc) {
236233
+ const { endo: endo2 } = curveOpts;
236234
+ const p5 = this;
236235
+ if (!Fn.isValid(sc))
236236
+ throw new Error("invalid scalar: out of range");
236237
+ if (sc === _0n5 || p5.is0())
236238
+ return Point.ZERO;
236239
+ if (sc === _1n5)
236240
+ return p5;
236241
+ if (wnaf.hasPrecomputes(this))
236242
+ return this.multiply(sc);
236243
+ if (endo2) {
236244
+ const { k1neg, k1, k2neg, k2: k22 } = endo2.splitScalar(sc);
236245
+ const { p1, p2: p22 } = mulEndoUnsafe(Point, p5, k1, k22);
236246
+ return finishEndo(endo2.beta, p1, p22, k1neg, k2neg);
236247
+ } else {
236248
+ return wnaf.wNAFCachedUnsafe(p5, sc);
236249
+ }
236250
+ }
236188
236251
  multiplyAndAddUnsafe(Q4, a7, b4) {
236189
- const G4 = Point.BASE;
236190
- const mul = (P5, a8) => a8 === _0n5 || a8 === _1n5 || !P5.equals(G4) ? P5.multiplyUnsafe(a8) : P5.multiply(a8);
236191
- const sum = mul(this, a7).add(mul(Q4, b4));
236252
+ const sum = this.multiplyUnsafe(a7).add(Q4.multiplyUnsafe(b4));
236192
236253
  return sum.is0() ? undefined : sum;
236193
236254
  }
236194
- toAffine(iz) {
236195
- return toAffineMemo(this, iz);
236255
+ toAffine(invertedZ) {
236256
+ return toAffineMemo(this, invertedZ);
236196
236257
  }
236197
236258
  isTorsionFree() {
236198
- const { h: cofactor, isTorsionFree } = CURVE;
236259
+ const { isTorsionFree } = curveOpts;
236199
236260
  if (cofactor === _1n5)
236200
236261
  return true;
236201
236262
  if (isTorsionFree)
236202
236263
  return isTorsionFree(Point, this);
236203
- throw new Error("isTorsionFree() has not been declared for the elliptic curve");
236264
+ return wnaf.wNAFCachedUnsafe(this, CURVE_ORDER).is0();
236204
236265
  }
236205
236266
  clearCofactor() {
236206
- const { h: cofactor, clearCofactor } = CURVE;
236267
+ const { clearCofactor } = curveOpts;
236207
236268
  if (cofactor === _1n5)
236208
236269
  return this;
236209
236270
  if (clearCofactor)
236210
236271
  return clearCofactor(Point, this);
236211
- return this.multiplyUnsafe(CURVE.h);
236272
+ return this.multiplyUnsafe(cofactor);
236212
236273
  }
236213
- toRawBytes(isCompressed = true) {
236274
+ toBytes(isCompressed = true) {
236214
236275
  abool("isCompressed", isCompressed);
236215
236276
  this.assertValidity();
236216
236277
  return toBytes3(Point, this, isCompressed);
236217
236278
  }
236279
+ toRawBytes(isCompressed = true) {
236280
+ return this.toBytes(isCompressed);
236281
+ }
236218
236282
  toHex(isCompressed = true) {
236219
- abool("isCompressed", isCompressed);
236220
- return bytesToHex2(this.toRawBytes(isCompressed));
236283
+ return bytesToHex2(this.toBytes(isCompressed));
236284
+ }
236285
+ toString() {
236286
+ return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
236221
236287
  }
236222
236288
  }
236223
236289
  Point.BASE = new Point(CURVE.Gx, CURVE.Gy, Fp.ONE);
236224
236290
  Point.ZERO = new Point(Fp.ZERO, Fp.ONE, Fp.ZERO);
236225
- const { endo, nBitLength } = CURVE;
236226
- const wnaf = wNAF(Point, endo ? Math.ceil(nBitLength / 2) : nBitLength);
236227
- return {
236228
- CURVE,
236229
- ProjectivePoint: Point,
236230
- normPrivateKeyToScalar,
236231
- weierstrassEquation,
236232
- isWithinCurveOrder
236233
- };
236291
+ Point.Fp = Fp;
236292
+ Point.Fn = Fn;
236293
+ const bits = Fn.BITS;
236294
+ const wnaf = wNAF(Point, curveOpts.endo ? Math.ceil(bits / 2) : bits);
236295
+ return Point;
236296
+ }
236297
+ function pprefix(hasEvenY) {
236298
+ return Uint8Array.of(hasEvenY ? 2 : 3);
236234
236299
  }
236235
- function validateOpts(curve) {
236236
- const opts = validateBasic(curve);
236237
- validateObject(opts, {
236238
- hash: "hash",
236300
+ function ecdsa(Point, ecdsaOpts, curveOpts = {}) {
236301
+ _validateObject(ecdsaOpts, { hash: "function" }, {
236239
236302
  hmac: "function",
236240
- randomBytes: "function"
236241
- }, {
236303
+ lowS: "boolean",
236304
+ randomBytes: "function",
236242
236305
  bits2int: "function",
236243
- bits2int_modN: "function",
236244
- lowS: "boolean"
236245
- });
236246
- return Object.freeze({ lowS: true, ...opts });
236247
- }
236248
- function weierstrass(curveDef) {
236249
- const CURVE = validateOpts(curveDef);
236250
- const { Fp, n: CURVE_ORDER, nByteLength, nBitLength } = CURVE;
236251
- const compressedLen = Fp.BYTES + 1;
236252
- const uncompressedLen = 2 * Fp.BYTES + 1;
236253
- function modN(a7) {
236254
- return mod(a7, CURVE_ORDER);
236255
- }
236256
- function invN(a7) {
236257
- return invert(a7, CURVE_ORDER);
236258
- }
236259
- const { ProjectivePoint: Point, normPrivateKeyToScalar, weierstrassEquation, isWithinCurveOrder } = weierstrassPoints({
236260
- ...CURVE,
236261
- toBytes(_c, point, isCompressed) {
236262
- const a7 = point.toAffine();
236263
- const x6 = Fp.toBytes(a7.x);
236264
- const cat = concatBytes3;
236265
- abool("isCompressed", isCompressed);
236266
- if (isCompressed) {
236267
- return cat(Uint8Array.from([point.hasEvenY() ? 2 : 3]), x6);
236268
- } else {
236269
- return cat(Uint8Array.from([4]), x6, Fp.toBytes(a7.y));
236270
- }
236271
- },
236272
- fromBytes(bytes) {
236273
- const len = bytes.length;
236274
- const head = bytes[0];
236275
- const tail = bytes.subarray(1);
236276
- if (len === compressedLen && (head === 2 || head === 3)) {
236277
- const x6 = bytesToNumberBE(tail);
236278
- if (!inRange(x6, _1n5, Fp.ORDER))
236279
- throw new Error("Point is not on curve");
236280
- const y22 = weierstrassEquation(x6);
236281
- let y4;
236282
- try {
236283
- y4 = Fp.sqrt(y22);
236284
- } catch (sqrtError) {
236285
- const suffix = sqrtError instanceof Error ? ": " + sqrtError.message : "";
236286
- throw new Error("Point is not on curve" + suffix);
236287
- }
236288
- const isYOdd = (y4 & _1n5) === _1n5;
236289
- const isHeadOdd = (head & 1) === 1;
236290
- if (isHeadOdd !== isYOdd)
236291
- y4 = Fp.neg(y4);
236292
- return { x: x6, y: y4 };
236293
- } else if (len === uncompressedLen && head === 4) {
236294
- const x6 = Fp.fromBytes(tail.subarray(0, Fp.BYTES));
236295
- const y4 = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES));
236296
- return { x: x6, y: y4 };
236297
- } else {
236298
- const cl = compressedLen;
236299
- const ul = uncompressedLen;
236300
- throw new Error("invalid Point, expected length of " + cl + ", or uncompressed " + ul + ", got " + len);
236301
- }
236302
- }
236306
+ bits2int_modN: "function"
236303
236307
  });
236308
+ const randomBytes_ = ecdsaOpts.randomBytes || randomBytes;
236309
+ const hmac_ = ecdsaOpts.hmac || ((key2, ...msgs) => hmac(ecdsaOpts.hash, key2, concatBytes(...msgs)));
236310
+ const { Fp, Fn } = Point;
236311
+ const { ORDER: CURVE_ORDER, BITS: fnBits } = Fn;
236304
236312
  function isBiggerThanHalfOrder(number6) {
236305
236313
  const HALF = CURVE_ORDER >> _1n5;
236306
236314
  return number6 > HALF;
236307
236315
  }
236308
236316
  function normalizeS(s7) {
236309
- return isBiggerThanHalfOrder(s7) ? modN(-s7) : s7;
236317
+ return isBiggerThanHalfOrder(s7) ? Fn.neg(s7) : s7;
236318
+ }
236319
+ function aValidRS(title, num) {
236320
+ if (!Fn.isValidNot0(num))
236321
+ throw new Error(`invalid signature ${title}: out of range 1..CURVE.n`);
236310
236322
  }
236311
- const slcNum = (b4, from, to) => bytesToNumberBE(b4.slice(from, to));
236312
236323
 
236313
236324
  class Signature {
236314
236325
  constructor(r6, s7, recovery) {
236315
- aInRange("r", r6, _1n5, CURVE_ORDER);
236316
- aInRange("s", s7, _1n5, CURVE_ORDER);
236326
+ aValidRS("r", r6);
236327
+ aValidRS("s", s7);
236317
236328
  this.r = r6;
236318
236329
  this.s = s7;
236319
236330
  if (recovery != null)
@@ -236321,9 +236332,9 @@ function weierstrass(curveDef) {
236321
236332
  Object.freeze(this);
236322
236333
  }
236323
236334
  static fromCompact(hex) {
236324
- const l3 = nByteLength;
236325
- hex = ensureBytes("compactSignature", hex, l3 * 2);
236326
- return new Signature(slcNum(hex, 0, l3), slcNum(hex, l3, 2 * l3));
236335
+ const L5 = Fn.BYTES;
236336
+ const b4 = ensureBytes("compactSignature", hex, L5 * 2);
236337
+ return new Signature(Fn.fromBytes(b4.subarray(0, L5)), Fn.fromBytes(b4.subarray(L5, L5 * 2)));
236327
236338
  }
236328
236339
  static fromDER(hex) {
236329
236340
  const { r: r6, s: s7 } = DER.toSig(ensureBytes("DER", hex));
@@ -236334,20 +236345,24 @@ function weierstrass(curveDef) {
236334
236345
  return new Signature(this.r, this.s, recovery);
236335
236346
  }
236336
236347
  recoverPublicKey(msgHash) {
236348
+ const FIELD_ORDER = Fp.ORDER;
236337
236349
  const { r: r6, s: s7, recovery: rec } = this;
236338
- const h8 = bits2int_modN(ensureBytes("msgHash", msgHash));
236339
236350
  if (rec == null || ![0, 1, 2, 3].includes(rec))
236340
236351
  throw new Error("recovery id invalid");
236341
- const radj = rec === 2 || rec === 3 ? r6 + CURVE.n : r6;
236342
- if (radj >= Fp.ORDER)
236352
+ const hasCofactor = CURVE_ORDER * _2n3 < FIELD_ORDER;
236353
+ if (hasCofactor && rec > 1)
236354
+ throw new Error("recovery id is ambiguous for h>1 curve");
236355
+ const radj = rec === 2 || rec === 3 ? r6 + CURVE_ORDER : r6;
236356
+ if (!Fp.isValid(radj))
236343
236357
  throw new Error("recovery id 2 or 3 invalid");
236344
- const prefix = (rec & 1) === 0 ? "02" : "03";
236345
- const R7 = Point.fromHex(prefix + numToSizedHex(radj, Fp.BYTES));
236346
- const ir2 = invN(radj);
236347
- const u1 = modN(-h8 * ir2);
236348
- const u22 = modN(s7 * ir2);
236349
- const Q4 = Point.BASE.multiplyAndAddUnsafe(R7, u1, u22);
236350
- if (!Q4)
236358
+ const x6 = Fp.toBytes(radj);
236359
+ const R7 = Point.fromHex(concatBytes(pprefix((rec & 1) === 0), x6));
236360
+ const ir2 = Fn.inv(radj);
236361
+ const h8 = bits2int_modN(ensureBytes("msgHash", msgHash));
236362
+ const u1 = Fn.create(-h8 * ir2);
236363
+ const u22 = Fn.create(s7 * ir2);
236364
+ const Q4 = Point.BASE.multiplyUnsafe(u1).add(R7.multiplyUnsafe(u22));
236365
+ if (Q4.is0())
236351
236366
  throw new Error("point at infinify");
236352
236367
  Q4.assertValidity();
236353
236368
  return Q4;
@@ -236356,22 +236371,29 @@ function weierstrass(curveDef) {
236356
236371
  return isBiggerThanHalfOrder(this.s);
236357
236372
  }
236358
236373
  normalizeS() {
236359
- return this.hasHighS() ? new Signature(this.r, modN(-this.s), this.recovery) : this;
236374
+ return this.hasHighS() ? new Signature(this.r, Fn.neg(this.s), this.recovery) : this;
236375
+ }
236376
+ toBytes(format2) {
236377
+ if (format2 === "compact")
236378
+ return concatBytes(Fn.toBytes(this.r), Fn.toBytes(this.s));
236379
+ if (format2 === "der")
236380
+ return hexToBytes2(DER.hexFromSig(this));
236381
+ throw new Error("invalid format");
236360
236382
  }
236361
236383
  toDERRawBytes() {
236362
- return hexToBytes2(this.toDERHex());
236384
+ return this.toBytes("der");
236363
236385
  }
236364
236386
  toDERHex() {
236365
- return DER.hexFromSig(this);
236387
+ return bytesToHex2(this.toBytes("der"));
236366
236388
  }
236367
236389
  toCompactRawBytes() {
236368
- return hexToBytes2(this.toCompactHex());
236390
+ return this.toBytes("compact");
236369
236391
  }
236370
236392
  toCompactHex() {
236371
- const l3 = nByteLength;
236372
- return numToSizedHex(this.r, l3) + numToSizedHex(this.s, l3);
236393
+ return bytesToHex2(this.toBytes("compact"));
236373
236394
  }
236374
236395
  }
236396
+ const normPrivateKeyToScalar = _legacyHelperNormPriv(Fn, curveOpts.allowedPrivateKeyLengths, curveOpts.wrapPrivateKey);
236375
236397
  const utils = {
236376
236398
  isValidPrivateKey(privateKey) {
236377
236399
  try {
@@ -236383,17 +236405,15 @@ function weierstrass(curveDef) {
236383
236405
  },
236384
236406
  normPrivateKeyToScalar,
236385
236407
  randomPrivateKey: () => {
236386
- const length = getMinHashLength(CURVE.n);
236387
- return mapHashToField(CURVE.randomBytes(length), CURVE.n);
236408
+ const n6 = CURVE_ORDER;
236409
+ return mapHashToField(randomBytes_(getMinHashLength(n6)), n6);
236388
236410
  },
236389
236411
  precompute(windowSize = 8, point = Point.BASE) {
236390
- point._setWindowSize(windowSize);
236391
- point.multiply(BigInt(3));
236392
- return point;
236412
+ return point.precompute(windowSize, false);
236393
236413
  }
236394
236414
  };
236395
236415
  function getPublicKey(privateKey, isCompressed = true) {
236396
- return Point.fromPrivateKey(privateKey).toRawBytes(isCompressed);
236416
+ return Point.fromPrivateKey(privateKey).toBytes(isCompressed);
236397
236417
  }
236398
236418
  function isProbPub(item) {
236399
236419
  if (typeof item === "bigint")
@@ -236401,14 +236421,14 @@ function weierstrass(curveDef) {
236401
236421
  if (item instanceof Point)
236402
236422
  return true;
236403
236423
  const arr = ensureBytes("key", item);
236404
- const len = arr.length;
236405
- const fpl = Fp.BYTES;
236406
- const compLen = fpl + 1;
236407
- const uncompLen = 2 * fpl + 1;
236408
- if (CURVE.allowedPrivateKeyLengths || nByteLength === compLen) {
236424
+ const length = arr.length;
236425
+ const L5 = Fp.BYTES;
236426
+ const LC = L5 + 1;
236427
+ const LU = 2 * L5 + 1;
236428
+ if (curveOpts.allowedPrivateKeyLengths || Fn.BYTES === LC) {
236409
236429
  return;
236410
236430
  } else {
236411
- return len === compLen || len === uncompLen;
236431
+ return length === LC || length === LU;
236412
236432
  }
236413
236433
  }
236414
236434
  function getSharedSecret(privateA, publicB, isCompressed = true) {
@@ -236417,27 +236437,27 @@ function weierstrass(curveDef) {
236417
236437
  if (isProbPub(publicB) === false)
236418
236438
  throw new Error("second arg must be public key");
236419
236439
  const b4 = Point.fromHex(publicB);
236420
- return b4.multiply(normPrivateKeyToScalar(privateA)).toRawBytes(isCompressed);
236440
+ return b4.multiply(normPrivateKeyToScalar(privateA)).toBytes(isCompressed);
236421
236441
  }
236422
- const bits2int = CURVE.bits2int || function(bytes) {
236442
+ const bits2int = ecdsaOpts.bits2int || function(bytes) {
236423
236443
  if (bytes.length > 8192)
236424
236444
  throw new Error("input is too large");
236425
236445
  const num = bytesToNumberBE(bytes);
236426
- const delta = bytes.length * 8 - nBitLength;
236446
+ const delta = bytes.length * 8 - fnBits;
236427
236447
  return delta > 0 ? num >> BigInt(delta) : num;
236428
236448
  };
236429
- const bits2int_modN = CURVE.bits2int_modN || function(bytes) {
236430
- return modN(bits2int(bytes));
236449
+ const bits2int_modN = ecdsaOpts.bits2int_modN || function(bytes) {
236450
+ return Fn.create(bits2int(bytes));
236431
236451
  };
236432
- const ORDER_MASK = bitMask(nBitLength);
236452
+ const ORDER_MASK = bitMask(fnBits);
236433
236453
  function int2octets(num) {
236434
- aInRange("num < 2^" + nBitLength, num, _0n5, ORDER_MASK);
236435
- return numberToBytesBE(num, nByteLength);
236454
+ aInRange("num < 2^" + fnBits, num, _0n5, ORDER_MASK);
236455
+ return Fn.toBytes(num);
236436
236456
  }
236437
236457
  function prepSig(msgHash, privateKey, opts = defaultSigOpts) {
236438
236458
  if (["recovered", "canonical"].some((k5) => (k5 in opts)))
236439
236459
  throw new Error("sign() legacy options not supported");
236440
- const { hash: hash2, randomBytes: randomBytes2 } = CURVE;
236460
+ const { hash: hash2 } = ecdsaOpts;
236441
236461
  let { lowS, prehash, extraEntropy: ent } = opts;
236442
236462
  if (lowS == null)
236443
236463
  lowS = true;
@@ -236449,21 +236469,21 @@ function weierstrass(curveDef) {
236449
236469
  const d6 = normPrivateKeyToScalar(privateKey);
236450
236470
  const seedArgs = [int2octets(d6), int2octets(h1int)];
236451
236471
  if (ent != null && ent !== false) {
236452
- const e10 = ent === true ? randomBytes2(Fp.BYTES) : ent;
236472
+ const e10 = ent === true ? randomBytes_(Fp.BYTES) : ent;
236453
236473
  seedArgs.push(ensureBytes("extraEntropy", e10));
236454
236474
  }
236455
- const seed = concatBytes3(...seedArgs);
236475
+ const seed = concatBytes(...seedArgs);
236456
236476
  const m7 = h1int;
236457
236477
  function k2sig(kBytes) {
236458
236478
  const k5 = bits2int(kBytes);
236459
- if (!isWithinCurveOrder(k5))
236479
+ if (!Fn.isValidNot0(k5))
236460
236480
  return;
236461
- const ik = invN(k5);
236481
+ const ik = Fn.inv(k5);
236462
236482
  const q6 = Point.BASE.multiply(k5).toAffine();
236463
- const r6 = modN(q6.x);
236483
+ const r6 = Fn.create(q6.x);
236464
236484
  if (r6 === _0n5)
236465
236485
  return;
236466
- const s7 = modN(ik * modN(m7 + r6 * d6));
236486
+ const s7 = Fn.create(ik * Fn.create(m7 + r6 * d6));
236467
236487
  if (s7 === _0n5)
236468
236488
  return;
236469
236489
  let recovery = (q6.x === r6 ? 0 : 2) | Number(q6.y & _1n5);
@@ -236476,34 +236496,38 @@ function weierstrass(curveDef) {
236476
236496
  }
236477
236497
  return { seed, k2sig };
236478
236498
  }
236479
- const defaultSigOpts = { lowS: CURVE.lowS, prehash: false };
236480
- const defaultVerOpts = { lowS: CURVE.lowS, prehash: false };
236499
+ const defaultSigOpts = { lowS: ecdsaOpts.lowS, prehash: false };
236500
+ const defaultVerOpts = { lowS: ecdsaOpts.lowS, prehash: false };
236481
236501
  function sign(msgHash, privKey, opts = defaultSigOpts) {
236482
236502
  const { seed, k2sig } = prepSig(msgHash, privKey, opts);
236483
- const C4 = CURVE;
236484
- const drbg = createHmacDrbg(C4.hash.outputLen, C4.nByteLength, C4.hmac);
236503
+ const drbg = createHmacDrbg(ecdsaOpts.hash.outputLen, Fn.BYTES, hmac_);
236485
236504
  return drbg(seed, k2sig);
236486
236505
  }
236487
- Point.BASE._setWindowSize(8);
236506
+ Point.BASE.precompute(8);
236488
236507
  function verify(signature, msgHash, publicKey, opts = defaultVerOpts) {
236489
236508
  const sg = signature;
236490
236509
  msgHash = ensureBytes("msgHash", msgHash);
236491
236510
  publicKey = ensureBytes("publicKey", publicKey);
236492
- const { lowS, prehash, format: format2 } = opts;
236493
236511
  validateSigVerOpts(opts);
236512
+ const { lowS, prehash, format: format2 } = opts;
236494
236513
  if ("strict" in opts)
236495
236514
  throw new Error("options.strict was renamed to lowS");
236496
- if (format2 !== undefined && format2 !== "compact" && format2 !== "der")
236497
- throw new Error("format must be compact or der");
236498
- const isHex2 = typeof sg === "string" || isBytes2(sg);
236515
+ if (format2 !== undefined && !["compact", "der", "js"].includes(format2))
236516
+ throw new Error('format must be "compact", "der" or "js"');
236517
+ const isHex2 = typeof sg === "string" || isBytes(sg);
236499
236518
  const isObj = !isHex2 && !format2 && typeof sg === "object" && sg !== null && typeof sg.r === "bigint" && typeof sg.s === "bigint";
236500
236519
  if (!isHex2 && !isObj)
236501
236520
  throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");
236502
236521
  let _sig = undefined;
236503
236522
  let P5;
236504
236523
  try {
236505
- if (isObj)
236506
- _sig = new Signature(sg.r, sg.s);
236524
+ if (isObj) {
236525
+ if (format2 === undefined || format2 === "js") {
236526
+ _sig = new Signature(sg.r, sg.s);
236527
+ } else {
236528
+ throw new Error("invalid format");
236529
+ }
236530
+ }
236507
236531
  if (isHex2) {
236508
236532
  try {
236509
236533
  if (format2 !== "compact")
@@ -236524,28 +236548,77 @@ function weierstrass(curveDef) {
236524
236548
  if (lowS && _sig.hasHighS())
236525
236549
  return false;
236526
236550
  if (prehash)
236527
- msgHash = CURVE.hash(msgHash);
236551
+ msgHash = ecdsaOpts.hash(msgHash);
236528
236552
  const { r: r6, s: s7 } = _sig;
236529
236553
  const h8 = bits2int_modN(msgHash);
236530
- const is = invN(s7);
236531
- const u1 = modN(h8 * is);
236532
- const u22 = modN(r6 * is);
236533
- const R7 = Point.BASE.multiplyAndAddUnsafe(P5, u1, u22)?.toAffine();
236534
- if (!R7)
236554
+ const is = Fn.inv(s7);
236555
+ const u1 = Fn.create(h8 * is);
236556
+ const u22 = Fn.create(r6 * is);
236557
+ const R7 = Point.BASE.multiplyUnsafe(u1).add(P5.multiplyUnsafe(u22));
236558
+ if (R7.is0())
236535
236559
  return false;
236536
- const v6 = modN(R7.x);
236560
+ const v6 = Fn.create(R7.x);
236537
236561
  return v6 === r6;
236538
236562
  }
236539
- return {
236540
- CURVE,
236563
+ return Object.freeze({
236541
236564
  getPublicKey,
236542
236565
  getSharedSecret,
236543
236566
  sign,
236544
236567
  verify,
236545
- ProjectivePoint: Point,
236546
- Signature,
236547
- utils
236548
- };
236568
+ utils,
236569
+ Point,
236570
+ Signature
236571
+ });
236572
+ }
236573
+ function _weierstrass_legacy_opts_to_new(c3) {
236574
+ const CURVE = {
236575
+ a: c3.a,
236576
+ b: c3.b,
236577
+ p: c3.Fp.ORDER,
236578
+ n: c3.n,
236579
+ h: c3.h,
236580
+ Gx: c3.Gx,
236581
+ Gy: c3.Gy
236582
+ };
236583
+ const Fp = c3.Fp;
236584
+ const Fn = Field(CURVE.n, c3.nBitLength);
236585
+ const curveOpts = {
236586
+ Fp,
236587
+ Fn,
236588
+ allowedPrivateKeyLengths: c3.allowedPrivateKeyLengths,
236589
+ allowInfinityPoint: c3.allowInfinityPoint,
236590
+ endo: c3.endo,
236591
+ wrapPrivateKey: c3.wrapPrivateKey,
236592
+ isTorsionFree: c3.isTorsionFree,
236593
+ clearCofactor: c3.clearCofactor,
236594
+ fromBytes: c3.fromBytes,
236595
+ toBytes: c3.toBytes
236596
+ };
236597
+ return { CURVE, curveOpts };
236598
+ }
236599
+ function _ecdsa_legacy_opts_to_new(c3) {
236600
+ const { CURVE, curveOpts } = _weierstrass_legacy_opts_to_new(c3);
236601
+ const ecdsaOpts = {
236602
+ hash: c3.hash,
236603
+ hmac: c3.hmac,
236604
+ randomBytes: c3.randomBytes,
236605
+ lowS: c3.lowS,
236606
+ bits2int: c3.bits2int,
236607
+ bits2int_modN: c3.bits2int_modN
236608
+ };
236609
+ return { CURVE, curveOpts, ecdsaOpts };
236610
+ }
236611
+ function _ecdsa_new_output_to_legacy(c3, ecdsa2) {
236612
+ return Object.assign({}, ecdsa2, {
236613
+ ProjectivePoint: ecdsa2.Point,
236614
+ CURVE: c3
236615
+ });
236616
+ }
236617
+ function weierstrass(c3) {
236618
+ const { CURVE, curveOpts, ecdsaOpts } = _ecdsa_legacy_opts_to_new(c3);
236619
+ const Point = weierstrassN(CURVE, curveOpts);
236620
+ const signs = ecdsa(Point, ecdsaOpts, curveOpts);
236621
+ return _ecdsa_new_output_to_legacy(c3, signs);
236549
236622
  }
236550
236623
  function SWUFpSqrtRatio(Fp, Z4) {
236551
236624
  const q6 = Fp.ORDER;
@@ -236611,28 +236684,29 @@ function SWUFpSqrtRatio(Fp, Z4) {
236611
236684
  }
236612
236685
  function mapToCurveSimpleSWU(Fp, opts) {
236613
236686
  validateField(Fp);
236614
- if (!Fp.isValid(opts.A) || !Fp.isValid(opts.B) || !Fp.isValid(opts.Z))
236687
+ const { A: A5, B: B4, Z: Z4 } = opts;
236688
+ if (!Fp.isValid(A5) || !Fp.isValid(B4) || !Fp.isValid(Z4))
236615
236689
  throw new Error("mapToCurveSimpleSWU: invalid opts");
236616
- const sqrtRatio = SWUFpSqrtRatio(Fp, opts.Z);
236690
+ const sqrtRatio = SWUFpSqrtRatio(Fp, Z4);
236617
236691
  if (!Fp.isOdd)
236618
- throw new Error("Fp.isOdd is not implemented!");
236692
+ throw new Error("Field does not have .isOdd()");
236619
236693
  return (u6) => {
236620
236694
  let tv1, tv2, tv3, tv4, tv5, tv6, x6, y4;
236621
236695
  tv1 = Fp.sqr(u6);
236622
- tv1 = Fp.mul(tv1, opts.Z);
236696
+ tv1 = Fp.mul(tv1, Z4);
236623
236697
  tv2 = Fp.sqr(tv1);
236624
236698
  tv2 = Fp.add(tv2, tv1);
236625
236699
  tv3 = Fp.add(tv2, Fp.ONE);
236626
- tv3 = Fp.mul(tv3, opts.B);
236627
- tv4 = Fp.cmov(opts.Z, Fp.neg(tv2), !Fp.eql(tv2, Fp.ZERO));
236628
- tv4 = Fp.mul(tv4, opts.A);
236700
+ tv3 = Fp.mul(tv3, B4);
236701
+ tv4 = Fp.cmov(Z4, Fp.neg(tv2), !Fp.eql(tv2, Fp.ZERO));
236702
+ tv4 = Fp.mul(tv4, A5);
236629
236703
  tv2 = Fp.sqr(tv3);
236630
236704
  tv6 = Fp.sqr(tv4);
236631
- tv5 = Fp.mul(tv6, opts.A);
236705
+ tv5 = Fp.mul(tv6, A5);
236632
236706
  tv2 = Fp.add(tv2, tv5);
236633
236707
  tv2 = Fp.mul(tv2, tv3);
236634
236708
  tv6 = Fp.mul(tv6, tv4);
236635
- tv5 = Fp.mul(tv6, opts.B);
236709
+ tv5 = Fp.mul(tv6, B4);
236636
236710
  tv2 = Fp.add(tv2, tv5);
236637
236711
  x6 = Fp.mul(tv1, tv3);
236638
236712
  const { isValid, value: value4 } = sqrtRatio(tv2, tv6);
@@ -236649,9 +236723,10 @@ function mapToCurveSimpleSWU(Fp, opts) {
236649
236723
  }
236650
236724
  var DERErr, DER, _0n5, _1n5, _2n3, _3n2, _4n2;
236651
236725
  var init_weierstrass = __esm(() => {
236726
+ init_hmac();
236727
+ init_utils3();
236652
236728
  init_curve();
236653
236729
  init_modular();
236654
- init_utils3();
236655
236730
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
236656
236731
  DERErr = class DERErr extends Error {
236657
236732
  constructor(m7 = "") {
@@ -236759,20 +236834,11 @@ var init_weierstrass = __esm(() => {
236759
236834
  });
236760
236835
 
236761
236836
  // ../../node_modules/@noble/curves/esm/_shortw_utils.js
236762
- function getHash(hash2) {
236763
- return {
236764
- hash: hash2,
236765
- hmac: (key2, ...msgs) => hmac(hash2, key2, concatBytes(...msgs)),
236766
- randomBytes
236767
- };
236768
- }
236769
236837
  function createCurve(curveDef, defHash) {
236770
- const create2 = (hash2) => weierstrass({ ...curveDef, ...getHash(hash2) });
236838
+ const create2 = (hash2) => weierstrass({ ...curveDef, hash: hash2 });
236771
236839
  return { ...create2(defHash), create: create2 };
236772
236840
  }
236773
236841
  var init__shortw_utils = __esm(() => {
236774
- init_hmac();
236775
- init_utils2();
236776
236842
  init_weierstrass();
236777
236843
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
236778
236844
  });
@@ -236802,52 +236868,55 @@ function anum(item) {
236802
236868
  throw new Error("number expected");
236803
236869
  }
236804
236870
  function expand_message_xmd(msg, DST, lenInBytes, H4) {
236805
- abytes2(msg);
236806
- abytes2(DST);
236871
+ abytes(msg);
236872
+ abytes(DST);
236807
236873
  anum(lenInBytes);
236808
236874
  if (DST.length > 255)
236809
- DST = H4(concatBytes3(utf8ToBytes2("H2C-OVERSIZE-DST-"), DST));
236875
+ DST = H4(concatBytes(utf8ToBytes("H2C-OVERSIZE-DST-"), DST));
236810
236876
  const { outputLen: b_in_bytes, blockLen: r_in_bytes } = H4;
236811
236877
  const ell = Math.ceil(lenInBytes / b_in_bytes);
236812
236878
  if (lenInBytes > 65535 || ell > 255)
236813
236879
  throw new Error("expand_message_xmd: invalid lenInBytes");
236814
- const DST_prime = concatBytes3(DST, i2osp(DST.length, 1));
236880
+ const DST_prime = concatBytes(DST, i2osp(DST.length, 1));
236815
236881
  const Z_pad = i2osp(0, r_in_bytes);
236816
236882
  const l_i_b_str = i2osp(lenInBytes, 2);
236817
236883
  const b4 = new Array(ell);
236818
- const b_0 = H4(concatBytes3(Z_pad, msg, l_i_b_str, i2osp(0, 1), DST_prime));
236819
- b4[0] = H4(concatBytes3(b_0, i2osp(1, 1), DST_prime));
236884
+ const b_0 = H4(concatBytes(Z_pad, msg, l_i_b_str, i2osp(0, 1), DST_prime));
236885
+ b4[0] = H4(concatBytes(b_0, i2osp(1, 1), DST_prime));
236820
236886
  for (let i6 = 1;i6 <= ell; i6++) {
236821
236887
  const args = [strxor(b_0, b4[i6 - 1]), i2osp(i6 + 1, 1), DST_prime];
236822
- b4[i6] = H4(concatBytes3(...args));
236888
+ b4[i6] = H4(concatBytes(...args));
236823
236889
  }
236824
- const pseudo_random_bytes = concatBytes3(...b4);
236890
+ const pseudo_random_bytes = concatBytes(...b4);
236825
236891
  return pseudo_random_bytes.slice(0, lenInBytes);
236826
236892
  }
236827
236893
  function expand_message_xof(msg, DST, lenInBytes, k5, H4) {
236828
- abytes2(msg);
236829
- abytes2(DST);
236894
+ abytes(msg);
236895
+ abytes(DST);
236830
236896
  anum(lenInBytes);
236831
236897
  if (DST.length > 255) {
236832
236898
  const dkLen = Math.ceil(2 * k5 / 8);
236833
- DST = H4.create({ dkLen }).update(utf8ToBytes2("H2C-OVERSIZE-DST-")).update(DST).digest();
236899
+ DST = H4.create({ dkLen }).update(utf8ToBytes("H2C-OVERSIZE-DST-")).update(DST).digest();
236834
236900
  }
236835
236901
  if (lenInBytes > 65535 || DST.length > 255)
236836
236902
  throw new Error("expand_message_xof: invalid lenInBytes");
236837
236903
  return H4.create({ dkLen: lenInBytes }).update(msg).update(i2osp(lenInBytes, 2)).update(DST).update(i2osp(DST.length, 1)).digest();
236838
236904
  }
236839
236905
  function hash_to_field(msg, count, options) {
236840
- validateObject(options, {
236841
- DST: "stringOrUint8Array",
236906
+ _validateObject(options, {
236842
236907
  p: "bigint",
236843
- m: "isSafeInteger",
236844
- k: "isSafeInteger",
236845
- hash: "hash"
236908
+ m: "number",
236909
+ k: "number",
236910
+ hash: "function"
236846
236911
  });
236847
236912
  const { p: p5, k: k5, m: m7, hash: hash2, expand, DST: _DST } = options;
236848
- abytes2(msg);
236913
+ if (!isBytes(_DST) && typeof _DST !== "string")
236914
+ throw new Error("DST must be string or uint8array");
236915
+ if (!isHash(options.hash))
236916
+ throw new Error("expected valid hash");
236917
+ abytes(msg);
236849
236918
  anum(count);
236850
- const DST = typeof _DST === "string" ? utf8ToBytes2(_DST) : _DST;
236919
+ const DST = typeof _DST === "string" ? utf8ToBytes(_DST) : _DST;
236851
236920
  const log2p = p5.toString(2).length;
236852
236921
  const L5 = Math.ceil((log2p + k5) / 8);
236853
236922
  const len_in_bytes = count * m7 * L5;
@@ -236899,13 +236968,17 @@ function createHasher2(Point, mapToCurve, defaults4) {
236899
236968
  return {
236900
236969
  defaults: defaults4,
236901
236970
  hashToCurve(msg, options) {
236902
- const u6 = hash_to_field(msg, 2, { ...defaults4, DST: defaults4.DST, ...options });
236971
+ const dst = defaults4.DST ? defaults4.DST : {};
236972
+ const opts = Object.assign({}, defaults4, dst, options);
236973
+ const u6 = hash_to_field(msg, 2, opts);
236903
236974
  const u0 = map6(u6[0]);
236904
236975
  const u1 = map6(u6[1]);
236905
236976
  return clear(u0.add(u1));
236906
236977
  },
236907
236978
  encodeToCurve(msg, options) {
236908
- const u6 = hash_to_field(msg, 1, { ...defaults4, DST: defaults4.encodeDST, ...options });
236979
+ const dst = defaults4.encodeDST ? defaults4.encodeDST : {};
236980
+ const opts = Object.assign({}, defaults4, dst, options);
236981
+ const u6 = hash_to_field(msg, 1, opts);
236909
236982
  return clear(map6(u6[0]));
236910
236983
  },
236911
236984
  mapToCurve(scalars) {
@@ -236920,8 +236993,8 @@ function createHasher2(Point, mapToCurve, defaults4) {
236920
236993
  }
236921
236994
  var os2ip;
236922
236995
  var init_hash_to_curve = __esm(() => {
236923
- init_modular();
236924
236996
  init_utils3();
236997
+ init_modular();
236925
236998
  os2ip = bytesToNumberBE;
236926
236999
  });
236927
237000
 
@@ -236935,7 +237008,7 @@ __export(exports_secp256k1, {
236935
237008
  encodeToCurve: () => encodeToCurve
236936
237009
  });
236937
237010
  function sqrtMod(y4) {
236938
- const P5 = secp256k1P;
237011
+ const P5 = secp256k1_CURVE.p;
236939
237012
  const _3n3 = BigInt(3), _6n = BigInt(6), _11n = BigInt(11), _22n = BigInt(22);
236940
237013
  const _23n = BigInt(23), _44n = BigInt(44), _88n = BigInt(88);
236941
237014
  const b22 = y4 * y4 * y4 % P5;
@@ -236960,25 +237033,25 @@ function taggedHash(tag, ...messages) {
236960
237033
  let tagP = TAGGED_HASH_PREFIXES[tag];
236961
237034
  if (tagP === undefined) {
236962
237035
  const tagH = sha256(Uint8Array.from(tag, (c3) => c3.charCodeAt(0)));
236963
- tagP = concatBytes3(tagH, tagH);
237036
+ tagP = concatBytes(tagH, tagH);
236964
237037
  TAGGED_HASH_PREFIXES[tag] = tagP;
236965
237038
  }
236966
- return sha256(concatBytes3(tagP, ...messages));
237039
+ return sha256(concatBytes(tagP, ...messages));
236967
237040
  }
236968
237041
  function schnorrGetExtPubKey(priv) {
236969
237042
  let d_ = secp256k1.utils.normPrivateKeyToScalar(priv);
236970
237043
  let p5 = Point.fromPrivateKey(d_);
236971
- const scalar = p5.hasEvenY() ? d_ : modN(-d_);
237044
+ const scalar = hasEven(p5.y) ? d_ : modN(-d_);
236972
237045
  return { scalar, bytes: pointToBytes(p5) };
236973
237046
  }
236974
237047
  function lift_x(x6) {
236975
- aInRange("x", x6, _1n6, secp256k1P);
237048
+ aInRange("x", x6, _1n6, secp256k1_CURVE.p);
236976
237049
  const xx = modP(x6 * x6);
236977
237050
  const c3 = modP(xx * x6 + BigInt(7));
236978
237051
  let y4 = sqrtMod(c3);
236979
- if (y4 % _2n4 !== _0n6)
237052
+ if (!hasEven(y4))
236980
237053
  y4 = modP(-y4);
236981
- const p5 = new Point(x6, y4, _1n6);
237054
+ const p5 = Point.fromAffine({ x: x6, y: y4 });
236982
237055
  p5.assertValidity();
236983
237056
  return p5;
236984
237057
  }
@@ -237013,49 +237086,52 @@ function schnorrVerify(signature, message, publicKey) {
237013
237086
  try {
237014
237087
  const P5 = lift_x(num(pub));
237015
237088
  const r6 = num(sig.subarray(0, 32));
237016
- if (!inRange(r6, _1n6, secp256k1P))
237089
+ if (!inRange(r6, _1n6, secp256k1_CURVE.p))
237017
237090
  return false;
237018
237091
  const s7 = num(sig.subarray(32, 64));
237019
- if (!inRange(s7, _1n6, secp256k1N))
237092
+ if (!inRange(s7, _1n6, secp256k1_CURVE.n))
237020
237093
  return false;
237021
237094
  const e10 = challenge(numTo32b(r6), pointToBytes(P5), m7);
237022
- const R7 = GmulAdd(P5, s7, modN(-e10));
237023
- if (!R7 || !R7.hasEvenY() || R7.toAffine().x !== r6)
237095
+ const R7 = Point.BASE.multiplyUnsafe(s7).add(P5.multiplyUnsafe(modN(-e10)));
237096
+ const { x: x6, y: y4 } = R7.toAffine();
237097
+ if (R7.is0() || !hasEven(y4) || x6 !== r6)
237024
237098
  return false;
237025
237099
  return true;
237026
237100
  } catch (error44) {
237027
237101
  return false;
237028
237102
  }
237029
237103
  }
237030
- var secp256k1P, secp256k1N, _0n6, _1n6, _2n4, divNearest = (a7, b4) => (a7 + b4 / _2n4) / b4, Fpk1, secp256k1, TAGGED_HASH_PREFIXES, pointToBytes = (point) => point.toRawBytes(true).slice(1), numTo32b = (n6) => numberToBytesBE(n6, 32), modP = (x6) => mod(x6, secp256k1P), modN = (x6) => mod(x6, secp256k1N), Point, GmulAdd = (Q4, a7, b4) => Point.BASE.multiplyAndAddUnsafe(Q4, a7, b4), num, schnorr, isoMap, mapSWU, secp256k1_hasher, hashToCurve, encodeToCurve;
237104
+ var secp256k1_CURVE, _0n6, _1n6, _2n4, divNearest = (a7, b4) => (a7 + b4 / _2n4) / b4, Fpk1, secp256k1, TAGGED_HASH_PREFIXES, pointToBytes = (point) => point.toBytes(true).slice(1), numTo32b = (n6) => numberToBytesBE(n6, 32), modP = (x6) => mod(x6, secp256k1_CURVE.p), modN = (x6) => mod(x6, secp256k1_CURVE.n), Point, hasEven = (y4) => y4 % _2n4 === _0n6, num, schnorr, isoMap, mapSWU, secp256k1_hasher, hashToCurve, encodeToCurve;
237031
237105
  var init_secp256k1 = __esm(() => {
237032
237106
  init_sha2();
237033
237107
  init_utils2();
237034
237108
  init__shortw_utils();
237035
237109
  init_hash_to_curve();
237036
237110
  init_modular();
237037
- init_utils3();
237038
237111
  init_weierstrass();
237112
+ init_utils3();
237039
237113
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
237040
- secp256k1P = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f");
237041
- secp256k1N = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");
237114
+ secp256k1_CURVE = {
237115
+ p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),
237116
+ n: BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),
237117
+ h: BigInt(1),
237118
+ a: BigInt(0),
237119
+ b: BigInt(7),
237120
+ Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
237121
+ Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")
237122
+ };
237042
237123
  _0n6 = BigInt(0);
237043
237124
  _1n6 = BigInt(1);
237044
237125
  _2n4 = BigInt(2);
237045
- Fpk1 = Field(secp256k1P, undefined, undefined, { sqrt: sqrtMod });
237126
+ Fpk1 = Field(secp256k1_CURVE.p, undefined, undefined, { sqrt: sqrtMod });
237046
237127
  secp256k1 = createCurve({
237047
- a: _0n6,
237048
- b: BigInt(7),
237128
+ ...secp256k1_CURVE,
237049
237129
  Fp: Fpk1,
237050
- n: secp256k1N,
237051
- Gx: BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),
237052
- Gy: BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),
237053
- h: BigInt(1),
237054
237130
  lowS: true,
237055
237131
  endo: {
237056
237132
  beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
237057
237133
  splitScalar: (k5) => {
237058
- const n6 = secp256k1N;
237134
+ const n6 = secp256k1_CURVE.n;
237059
237135
  const a1 = BigInt("0x3086d221a7d46bcde86c90e49284eb15");
237060
237136
  const b1 = -_1n6 * BigInt("0xe4437ed6010e88286f547fa90abfe4c3");
237061
237137
  const a22 = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8");
@@ -237079,7 +237155,7 @@ var init_secp256k1 = __esm(() => {
237079
237155
  }
237080
237156
  }, sha256);
237081
237157
  TAGGED_HASH_PREFIXES = {};
237082
- Point = /* @__PURE__ */ (() => secp256k1.ProjectivePoint)();
237158
+ Point = /* @__PURE__ */ (() => secp256k1.Point)();
237083
237159
  num = bytesToNumberBE;
237084
237160
  schnorr = /* @__PURE__ */ (() => ({
237085
237161
  getPublicKey: schnorrGetPublicKey,
@@ -237125,7 +237201,7 @@ var init_secp256k1 = __esm(() => {
237125
237201
  B: BigInt("1771"),
237126
237202
  Z: Fpk1.create(BigInt("-11"))
237127
237203
  }))();
237128
- secp256k1_hasher = /* @__PURE__ */ (() => createHasher2(secp256k1.ProjectivePoint, (scalars) => {
237204
+ secp256k1_hasher = /* @__PURE__ */ (() => createHasher2(secp256k1.Point, (scalars) => {
237129
237205
  const { x: x6, y: y4 } = mapSWU(Fpk1.create(scalars[0]));
237130
237206
  return isoMap(x6, y4);
237131
237207
  }, {
@@ -258053,9 +258129,9 @@ ${formattedErrors}`);
258053
258129
  throw error$37;
258054
258130
  }
258055
258131
  }
258056
- var ApplicationAccessTokenSchema = string$1().regex(/^sm_aat_.*$/);
258057
- var PersonalAccessTokenSchema = string$1().regex(/^sm_pat_.*$/);
258058
- var AccessTokenSchema = string$1().regex(/^sm_pat_.*|sm_aat_.*$/);
258132
+ var ApplicationAccessTokenSchema = string$1().regex(/^sm_aat_.+$/);
258133
+ var PersonalAccessTokenSchema = string$1().regex(/^sm_pat_.+$/);
258134
+ var AccessTokenSchema = string$1().regex(/^(sm_pat_.+|sm_aat_.+)$/);
258059
258135
  function tryParseJson(value, defaultValue = null) {
258060
258136
  try {
258061
258137
  const parsed = JSON.parse(value);
@@ -258063,7 +258139,7 @@ function tryParseJson(value, defaultValue = null) {
258063
258139
  return defaultValue;
258064
258140
  }
258065
258141
  return parsed;
258066
- } catch (err) {
258142
+ } catch (_err) {
258067
258143
  return defaultValue;
258068
258144
  }
258069
258145
  }
@@ -263693,7 +263769,7 @@ async function findMonoRepoPackages(projectDir) {
263693
263769
  }));
263694
263770
  const allPaths = packagePaths.flat();
263695
263771
  return allPaths.length === 0 ? [projectDir] : [monoRepoRoot, ...allPaths];
263696
- } catch (error$37) {
263772
+ } catch (_error) {
263697
263773
  return [projectDir];
263698
263774
  }
263699
263775
  }
@@ -263764,7 +263840,7 @@ function pruneCurrentEnv(currentEnv, env2) {
263764
263840
  var package_default = {
263765
263841
  name: "@settlemint/sdk-cli",
263766
263842
  description: "Command-line interface for SettleMint SDK, providing development tools and project management capabilities",
263767
- version: "2.4.0-pra6821f69",
263843
+ version: "2.4.0-praf6ea8ac",
263768
263844
  type: "module",
263769
263845
  private: false,
263770
263846
  license: "FSL-1.1-MIT",
@@ -263783,7 +263859,9 @@ var package_default = {
263783
263859
  url: "https://github.com/settlemint/sdk/issues",
263784
263860
  email: "support@settlemint.com"
263785
263861
  },
263786
- files: ["dist"],
263862
+ files: [
263863
+ "dist"
263864
+ ],
263787
263865
  exports: {
263788
263866
  "./*": {
263789
263867
  types: "./dist/*.d.ts",
@@ -263813,10 +263891,10 @@ var package_default = {
263813
263891
  "@inquirer/input": "4.1.12",
263814
263892
  "@inquirer/password": "4.0.15",
263815
263893
  "@inquirer/select": "4.2.3",
263816
- "@settlemint/sdk-js": "2.4.0-pra6821f69",
263817
- "@settlemint/sdk-utils": "2.4.0-pra6821f69",
263818
- "@settlemint/sdk-viem": "2.4.0-pra6821f69",
263819
- "@types/node": "24.0.1",
263894
+ "@settlemint/sdk-js": "2.4.0-praf6ea8ac",
263895
+ "@settlemint/sdk-utils": "2.4.0-praf6ea8ac",
263896
+ "@settlemint/sdk-viem": "2.4.0-praf6ea8ac",
263897
+ "@types/node": "24.0.7",
263820
263898
  "@types/semver": "7.7.0",
263821
263899
  "@types/which": "3.0.4",
263822
263900
  "get-tsconfig": "4.10.1",
@@ -263824,13 +263902,13 @@ var package_default = {
263824
263902
  "is-in-ci": "1.0.0",
263825
263903
  semver: "7.7.2",
263826
263904
  slugify: "1.6.6",
263827
- viem: "2.31.1",
263905
+ viem: "2.31.4",
263828
263906
  which: "5.0.0",
263829
263907
  yaml: "2.8.0",
263830
263908
  yoctocolors: "2.1.1"
263831
263909
  },
263832
263910
  peerDependencies: {
263833
- hardhat: "2.24.3"
263911
+ hardhat: "2.25.0"
263834
263912
  },
263835
263913
  peerDependenciesMeta: {
263836
263914
  hardhat: {
@@ -263885,7 +263963,7 @@ async function telemetry(data) {
263885
263963
  signal: controller.signal
263886
263964
  });
263887
263965
  clearTimeout(timeout);
263888
- } catch (error2) {}
263966
+ } catch (_error) {}
263889
263967
  }
263890
263968
 
263891
263969
  // ../../node_modules/@commander-js/extra-typings/esm.mjs
@@ -276437,9 +276515,9 @@ ${formattedErrors}`);
276437
276515
  throw error$372;
276438
276516
  }
276439
276517
  }
276440
- var ApplicationAccessTokenSchema2 = string$12().regex(/^sm_aat_.*$/);
276441
- var PersonalAccessTokenSchema2 = string$12().regex(/^sm_pat_.*$/);
276442
- var AccessTokenSchema2 = string$12().regex(/^sm_pat_.*|sm_aat_.*$/);
276518
+ var ApplicationAccessTokenSchema2 = string$12().regex(/^sm_aat_.+$/);
276519
+ var PersonalAccessTokenSchema2 = string$12().regex(/^sm_pat_.+$/);
276520
+ var AccessTokenSchema2 = string$12().regex(/^(sm_pat_.+|sm_aat_.+)$/);
276443
276521
  function tryParseJson2(value, defaultValue = null) {
276444
276522
  try {
276445
276523
  const parsed = JSON.parse(value);
@@ -276447,7 +276525,7 @@ function tryParseJson2(value, defaultValue = null) {
276447
276525
  return defaultValue;
276448
276526
  }
276449
276527
  return parsed;
276450
- } catch (err) {
276528
+ } catch (_err) {
276451
276529
  return defaultValue;
276452
276530
  }
276453
276531
  }
@@ -295793,17 +295871,6 @@ async function exists3(path$1) {
295793
295871
  return false;
295794
295872
  }
295795
295873
  }
295796
- function tryParseJson3(value2, defaultValue = null) {
295797
- try {
295798
- const parsed = JSON.parse(value2);
295799
- if (parsed === undefined || parsed === null) {
295800
- return defaultValue;
295801
- }
295802
- return parsed;
295803
- } catch (err) {
295804
- return defaultValue;
295805
- }
295806
- }
295807
295874
  var require_balanced_match4 = __commonJS4({ "../../node_modules/balanced-match/index.js"(exports, module) {
295808
295875
  module.exports = balanced$1;
295809
295876
  function balanced$1(a3, b, str) {
@@ -301282,6 +301349,17 @@ var glob3 = Object.assign(glob_3, {
301282
301349
  unescape: unescape4
301283
301350
  });
301284
301351
  glob3.glob = glob3;
301352
+ function tryParseJson3(value2, defaultValue = null) {
301353
+ try {
301354
+ const parsed = JSON.parse(value2);
301355
+ if (parsed === undefined || parsed === null) {
301356
+ return defaultValue;
301357
+ }
301358
+ return parsed;
301359
+ } catch (_err) {
301360
+ return defaultValue;
301361
+ }
301362
+ }
301285
301363
  async function findMonoRepoRoot2(startDir) {
301286
301364
  const lockFilePath = await findUp([
301287
301365
  "package-lock.json",
@@ -301327,7 +301405,7 @@ function tryParseJson4(value2, defaultValue = null) {
301327
301405
  return defaultValue;
301328
301406
  }
301329
301407
  return parsed;
301330
- } catch (err) {
301408
+ } catch (_err) {
301331
301409
  return defaultValue;
301332
301410
  }
301333
301411
  }
@@ -301355,7 +301433,7 @@ async function readConfig() {
301355
301433
  try {
301356
301434
  const content = await readFile4(CONFIG_FILE, "utf-8");
301357
301435
  return tryParseJson4(content, { instances: {} });
301358
- } catch (error41) {
301436
+ } catch (_error) {
301359
301437
  return { instances: {} };
301360
301438
  }
301361
301439
  }
@@ -304935,8 +305013,11 @@ function observe(observerId, callbacks, fn) {
304935
305013
  if (!listeners2.some((cb) => cb.id === callbackId))
304936
305014
  return;
304937
305015
  const cleanup2 = cleanupCache.get(observerId);
304938
- if (listeners2.length === 1 && cleanup2)
304939
- cleanup2();
305016
+ if (listeners2.length === 1 && cleanup2) {
305017
+ const p5 = cleanup2();
305018
+ if (p5 instanceof Promise)
305019
+ p5.catch(() => {});
305020
+ }
304940
305021
  unsubscribe();
304941
305022
  };
304942
305023
  const listeners = getListeners();
@@ -305075,9 +305156,9 @@ function watchContractEvent(client, parameters) {
305075
305156
  return poll_;
305076
305157
  if (typeof fromBlock === "bigint")
305077
305158
  return true;
305078
- if (client.transport.type === "webSocket")
305159
+ if (client.transport.type === "webSocket" || client.transport.type === "ipc")
305079
305160
  return false;
305080
- if (client.transport.type === "fallback" && client.transport.transports[0].config.type === "webSocket")
305161
+ if (client.transport.type === "fallback" && (client.transport.transports[0].config.type === "webSocket" || client.transport.transports[0].config.type === "ipc"))
305081
305162
  return false;
305082
305163
  return true;
305083
305164
  })();
@@ -305178,7 +305259,7 @@ function watchContractEvent(client, parameters) {
305178
305259
  try {
305179
305260
  const transport = (() => {
305180
305261
  if (client.transport.type === "fallback") {
305181
- const transport2 = client.transport.transports.find((transport3) => transport3.config.type === "webSocket");
305262
+ const transport2 = client.transport.transports.find((transport3) => transport3.config.type === "webSocket" || transport3.config.type === "ipc");
305182
305263
  if (!transport2)
305183
305264
  return client.transport;
305184
305265
  return transport2.value;
@@ -307066,9 +307147,10 @@ async function simulateBlocks(client, parameters) {
307066
307147
  const calls = block2.calls.map((call_) => {
307067
307148
  const call2 = call_;
307068
307149
  const account = call2.account ? parseAccount(call2.account) : undefined;
307150
+ const data = call2.abi ? encodeFunctionData(call2) : call2.data;
307069
307151
  const request2 = {
307070
307152
  ...call2,
307071
- data: call2.abi ? encodeFunctionData(call2) : call2.data,
307153
+ data: call2.dataSuffix ? concat2([data || "0x", call2.dataSuffix]) : data,
307072
307154
  from: call2.from ?? account?.address
307073
307155
  };
307074
307156
  assertRequest(request2);
@@ -307115,7 +307197,7 @@ async function simulateBlocks(client, parameters) {
307115
307197
  return;
307116
307198
  return getContractError(error45, {
307117
307199
  abi: abi2 ?? [],
307118
- address: to,
307200
+ address: to ?? "0x",
307119
307201
  args,
307120
307202
  functionName: functionName ?? "<unknown>"
307121
307203
  });
@@ -308057,14 +308139,6 @@ async function simulateCalls(client, parameters) {
308057
308139
  });
308058
308140
  return accessList.map(({ address, storageKeys }) => storageKeys.length > 0 ? address : null);
308059
308141
  })).then((x6) => x6.flat().filter(Boolean)) : [];
308060
- const resultsStateOverrides = stateOverrides?.map((override) => {
308061
- if (override.address === account?.address)
308062
- return {
308063
- ...override,
308064
- nonce: 0
308065
- };
308066
- return override;
308067
- });
308068
308142
  const blocks = await simulateBlocks(client, {
308069
308143
  blockNumber,
308070
308144
  blockTag,
@@ -308094,12 +308168,11 @@ async function simulateCalls(client, parameters) {
308094
308168
  }
308095
308169
  ] : [],
308096
308170
  {
308097
- calls: [...calls, {}].map((call2, index2) => ({
308171
+ calls: [...calls, {}].map((call2) => ({
308098
308172
  ...call2,
308099
- from: account?.address,
308100
- nonce: index2
308173
+ from: account?.address
308101
308174
  })),
308102
- stateOverrides: resultsStateOverrides
308175
+ stateOverrides
308103
308176
  },
308104
308177
  ...traceAssetChanges ? [
308105
308178
  {
@@ -308347,9 +308420,9 @@ function watchBlockNumber(client, { emitOnBegin = false, emitMissed = false, onB
308347
308420
  const enablePolling = (() => {
308348
308421
  if (typeof poll_ !== "undefined")
308349
308422
  return poll_;
308350
- if (client.transport.type === "webSocket")
308423
+ if (client.transport.type === "webSocket" || client.transport.type === "ipc")
308351
308424
  return false;
308352
- if (client.transport.type === "fallback" && client.transport.transports[0].config.type === "webSocket")
308425
+ if (client.transport.type === "fallback" && (client.transport.transports[0].config.type === "webSocket" || client.transport.transports[0].config.type === "ipc"))
308353
308426
  return false;
308354
308427
  return true;
308355
308428
  })();
@@ -308401,7 +308474,7 @@ function watchBlockNumber(client, { emitOnBegin = false, emitMissed = false, onB
308401
308474
  try {
308402
308475
  const transport = (() => {
308403
308476
  if (client.transport.type === "fallback") {
308404
- const transport2 = client.transport.transports.find((transport3) => transport3.config.type === "webSocket");
308477
+ const transport2 = client.transport.transports.find((transport3) => transport3.config.type === "webSocket" || transport3.config.type === "ipc");
308405
308478
  if (!transport2)
308406
308479
  return client.transport;
308407
308480
  return transport2.value;
@@ -308554,9 +308627,9 @@ function watchBlocks(client, { blockTag = "latest", emitMissed = false, emitOnBe
308554
308627
  const enablePolling = (() => {
308555
308628
  if (typeof poll_ !== "undefined")
308556
308629
  return poll_;
308557
- if (client.transport.type === "webSocket")
308630
+ if (client.transport.type === "webSocket" || client.transport.type === "ipc")
308558
308631
  return false;
308559
- if (client.transport.type === "fallback" && client.transport.transports[0].config.type === "webSocket")
308632
+ if (client.transport.type === "fallback" && (client.transport.transports[0].config.type === "webSocket" || client.transport.transports[0].config.type === "ipc"))
308560
308633
  return false;
308561
308634
  return true;
308562
308635
  })();
@@ -308625,7 +308698,7 @@ function watchBlocks(client, { blockTag = "latest", emitMissed = false, emitOnBe
308625
308698
  }
308626
308699
  const transport = (() => {
308627
308700
  if (client.transport.type === "fallback") {
308628
- const transport2 = client.transport.transports.find((transport3) => transport3.config.type === "webSocket");
308701
+ const transport2 = client.transport.transports.find((transport3) => transport3.config.type === "webSocket" || transport3.config.type === "ipc");
308629
308702
  if (!transport2)
308630
308703
  return client.transport;
308631
308704
  return transport2.value;
@@ -308638,7 +308711,7 @@ function watchBlocks(client, { blockTag = "latest", emitMissed = false, emitOnBe
308638
308711
  if (!active)
308639
308712
  return;
308640
308713
  const block = await getAction(client, getBlock, "getBlock")({
308641
- blockNumber: data.blockNumber,
308714
+ blockNumber: data.result?.number,
308642
308715
  includeTransactions
308643
308716
  }).catch(() => {});
308644
308717
  if (!active)
@@ -308672,9 +308745,9 @@ function watchEvent(client, { address, args, batch = true, event, events, fromBl
308672
308745
  return poll_;
308673
308746
  if (typeof fromBlock === "bigint")
308674
308747
  return true;
308675
- if (client.transport.type === "webSocket")
308748
+ if (client.transport.type === "webSocket" || client.transport.type === "ipc")
308676
308749
  return false;
308677
- if (client.transport.type === "fallback" && client.transport.transports[0].config.type === "webSocket")
308750
+ if (client.transport.type === "fallback" && (client.transport.transports[0].config.type === "webSocket" || client.transport.transports[0].config.type === "ipc"))
308678
308751
  return false;
308679
308752
  return true;
308680
308753
  })();
@@ -308761,7 +308834,7 @@ function watchEvent(client, { address, args, batch = true, event, events, fromBl
308761
308834
  try {
308762
308835
  const transport = (() => {
308763
308836
  if (client.transport.type === "fallback") {
308764
- const transport2 = client.transport.transports.find((transport3) => transport3.config.type === "webSocket");
308837
+ const transport2 = client.transport.transports.find((transport3) => transport3.config.type === "webSocket" || transport3.config.type === "ipc");
308765
308838
  if (!transport2)
308766
308839
  return client.transport;
308767
308840
  return transport2.value;
@@ -308828,7 +308901,7 @@ function watchEvent(client, { address, args, batch = true, event, events, fromBl
308828
308901
  }
308829
308902
  // ../../node_modules/viem/_esm/actions/public/watchPendingTransactions.js
308830
308903
  function watchPendingTransactions(client, { batch = true, onError, onTransactions, poll: poll_, pollingInterval = client.pollingInterval }) {
308831
- const enablePolling = typeof poll_ !== "undefined" ? poll_ : client.transport.type !== "webSocket";
308904
+ const enablePolling = typeof poll_ !== "undefined" ? poll_ : client.transport.type !== "webSocket" && client.transport.type !== "ipc";
308832
308905
  const pollPendingTransactions = () => {
308833
308906
  const observerId = stringify3([
308834
308907
  "watchPendingTransactions",
@@ -320486,7 +320559,7 @@ async function applicationAccessTokenPrompt(env2, application, settlemint, accep
320486
320559
  try {
320487
320560
  validate2(exports_external.string(), value4);
320488
320561
  return true;
320489
- } catch (error45) {
320562
+ } catch (_error) {
320490
320563
  return "Invalid token name";
320491
320564
  }
320492
320565
  }
@@ -320539,7 +320612,7 @@ async function applicationAccessTokenPrompt(env2, application, settlemint, accep
320539
320612
  try {
320540
320613
  validate2(ApplicationAccessTokenSchema2, aat);
320541
320614
  return aat;
320542
- } catch (error45) {}
320615
+ } catch (_error) {}
320543
320616
  }
320544
320617
  return esm_default5({
320545
320618
  message: "What is the application access token for your application in SettleMint? (format: sm_aat_...)",
@@ -320547,7 +320620,7 @@ async function applicationAccessTokenPrompt(env2, application, settlemint, accep
320547
320620
  try {
320548
320621
  validate2(ApplicationAccessTokenSchema2, value4);
320549
320622
  return true;
320550
- } catch (error45) {
320623
+ } catch (_error) {
320551
320624
  return "Invalid application access token, it should start with sm_aat_...";
320552
320625
  }
320553
320626
  }
@@ -320952,7 +321025,7 @@ async function instancePrompt({
320952
321025
  try {
320953
321026
  validate2(UrlSchema2, value4);
320954
321027
  return true;
320955
- } catch (error45) {
321028
+ } catch (_error) {
320956
321029
  return "Invalid URL";
320957
321030
  }
320958
321031
  },
@@ -321036,7 +321109,7 @@ async function serviceUrlPrompt({
321036
321109
  try {
321037
321110
  validate2(UrlSchema2, value4);
321038
321111
  return true;
321039
- } catch (error45) {
321112
+ } catch (_error) {
321040
321113
  return "Invalid URL";
321041
321114
  }
321042
321115
  },
@@ -321980,7 +322053,7 @@ async function projectNamePrompt(env2, argument) {
321980
322053
  try {
321981
322054
  validate2(exports_external.string(), value4);
321982
322055
  return true;
321983
- } catch (error45) {
322056
+ } catch (_error) {
321984
322057
  return "Invalid projectname";
321985
322058
  }
321986
322059
  }
@@ -325968,7 +326041,7 @@ async function personalAccessTokenPrompt(env2, instance, accept) {
325968
326041
  try {
325969
326042
  validate2(PersonalAccessTokenSchema2, value4);
325970
326043
  return true;
325971
- } catch (error45) {
326044
+ } catch (_error) {
325972
326045
  return "Invalid personal access token, it should start with sm_pat_...";
325973
326046
  }
325974
326047
  }
@@ -326049,7 +326122,7 @@ function loginCommand() {
326049
326122
  });
326050
326123
  try {
326051
326124
  await loginSpinner(client);
326052
- } catch (error45) {
326125
+ } catch (_error) {
326053
326126
  cancel2(`Invalid personal access token for instance ${selectedInstance}`);
326054
326127
  }
326055
326128
  await storeCredentials(personalAccessToken, selectedInstance);
@@ -326245,7 +326318,7 @@ async function waitForCompletion({
326245
326318
  } else {
326246
326319
  note(`${capitalizeFirstLetter2(type4)} is not ready yet (status: ${resource.status})`);
326247
326320
  }
326248
- } catch (error45) {
326321
+ } catch (_error) {
326249
326322
  if (spinner2) {
326250
326323
  spinner2.text = `${capitalizeFirstLetter2(type4)} is not ready yet (status: UNKNOWN)`;
326251
326324
  } else {
@@ -326376,8 +326449,8 @@ function getCreateCommand({
326376
326449
  instance
326377
326450
  });
326378
326451
  const platformConfig = await settlemint.platform.config();
326379
- let selectedProvider = undefined;
326380
- let selectedRegion = undefined;
326452
+ let selectedProvider;
326453
+ let selectedRegion;
326381
326454
  if (cmd2.options.some((option) => option.long === "--provider")) {
326382
326455
  selectedProvider = await providerPrompt(platformConfig, provider);
326383
326456
  if (!selectedProvider) {
@@ -327588,7 +327661,7 @@ function privateKeyHsmCreateCommand() {
327588
327661
  return baseAction({
327589
327662
  ...defaultArgs,
327590
327663
  acceptDefaults
327591
- }, async ({ settlemint, env: env2, showSpinner, provider, region }) => {
327664
+ }, async ({ settlemint, env: env2, showSpinner, provider: _provider, region: _region }) => {
327592
327665
  const applicationUniqueName = application ?? env2.SETTLEMINT_APPLICATION;
327593
327666
  if (!applicationUniqueName) {
327594
327667
  return missingApplication();
@@ -328488,7 +328561,7 @@ function servicesCommand() {
328488
328561
  if (!applicationUniqueName) {
328489
328562
  return nothingSelectedError("application");
328490
328563
  }
328491
- let effectiveTypes = undefined;
328564
+ let effectiveTypes;
328492
328565
  if (options.type && options.type.length > 0) {
328493
328566
  effectiveTypes = options.type;
328494
328567
  } else if (typeOperands && typeOperands.length > 0) {
@@ -328546,7 +328619,7 @@ async function getServicesAndMapResults({
328546
328619
  const application = await settlemint.application.read(applicationUniqueName);
328547
328620
  const services = await servicesSpinner(settlemint, applicationUniqueName, types4);
328548
328621
  const results = (types4 ?? SERVICE_TYPES).filter((serviceType) => !types4 || types4.includes(serviceType)).map((serviceType) => {
328549
- const [_6, labels] = Object.entries(LABELS_MAP).find(([key2, value4]) => value4.command === serviceType) ?? [
328622
+ const [_6, labels] = Object.entries(LABELS_MAP).find(([_key, value4]) => value4.command === serviceType) ?? [
328550
328623
  null,
328551
328624
  { plural: serviceType }
328552
328625
  ];
@@ -328723,7 +328796,7 @@ var import_which = __toESM(require_lib5(), 1);
328723
328796
  async function executeFoundryCommand(command, args) {
328724
328797
  try {
328725
328798
  await import_which.default(command);
328726
- } catch (error45) {
328799
+ } catch (_error) {
328727
328800
  cancel2("Foundry is not installed. Instructions to install Foundry can be found here: https://book.getfoundry.sh/getting-started/installation");
328728
328801
  }
328729
328802
  return executeCommand(command, args);
@@ -328811,7 +328884,7 @@ function foundryBuildCommand() {
328811
328884
  description: "Build the smart contracts with additional Forge options",
328812
328885
  command: "scs foundry build --optimize --force"
328813
328886
  }
328814
- ])).helpOption(false).option("-h, --help", "Get list of possible forge options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options, cmd2) => {
328887
+ ])).helpOption(false).option("-h, --help", "Get list of possible forge options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options, _cmd) => {
328815
328888
  intro("Building smart contracts using Foundry");
328816
328889
  const forgeOptions = mapPassthroughOptions(options, { args: operands });
328817
328890
  await executeFoundryCommand("forge", ["build", ...forgeOptions]);
@@ -328834,7 +328907,7 @@ function foundryFormatCommand() {
328834
328907
  description: "Format the smart contracts with additional Forge options",
328835
328908
  command: "scs foundry format --check"
328836
328909
  }
328837
- ])).helpOption(false).option("-h, --help", "Get list of possible forge options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options, cmd2) => {
328910
+ ])).helpOption(false).option("-h, --help", "Get list of possible forge options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options, _cmd) => {
328838
328911
  intro("Formatting smart contracts using Foundry");
328839
328912
  const forgeOptions = mapPassthroughOptions(options, { args: operands });
328840
328913
  await executeFoundryCommand("forge", ["fmt", ...forgeOptions]);
@@ -328857,7 +328930,7 @@ function foundryNetworkCommand() {
328857
328930
  description: "Start a development network using Foundry with a specific port",
328858
328931
  command: "scs foundry network --port 3000"
328859
328932
  }
328860
- ])).helpOption(false).option("-h, --help", "Get list of possible anvil options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options, cmd2) => {
328933
+ ])).helpOption(false).option("-h, --help", "Get list of possible anvil options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options, _cmd) => {
328861
328934
  const anvilOptions = mapPassthroughOptions(options, { args: operands });
328862
328935
  await executeFoundryCommand("anvil", anvilOptions);
328863
328936
  });
@@ -328878,7 +328951,7 @@ function foundryTestCommand() {
328878
328951
  description: "Run a specific test function",
328879
328952
  command: "scs foundry test --match-test testToken"
328880
328953
  }
328881
- ])).helpOption(false).option("-h, --help", "Get list of possible forge options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options, cmd2) => {
328954
+ ])).helpOption(false).option("-h, --help", "Get list of possible forge options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options, _cmd) => {
328882
328955
  intro("Running smart contract tests using Foundry");
328883
328956
  const forgeOptions = mapPassthroughOptions(options, { args: operands });
328884
328957
  await executeFoundryCommand("forge", ["test", ...forgeOptions]);
@@ -328892,7 +328965,7 @@ var validateIfRequiredPackagesAreInstalled = async (packages, cwd2) => {
328892
328965
  try {
328893
328966
  const isInstalled = await isPackageInstalled(pkg, cwd2);
328894
328967
  return { packageName: pkg, isInstalled };
328895
- } catch (err) {
328968
+ } catch (_err) {
328896
328969
  return { packageName: pkg, isInstalled: false };
328897
328970
  }
328898
328971
  }));
@@ -328917,7 +328990,7 @@ function hardhatBuildCommand() {
328917
328990
  description: "Build the smart contracts using additional options to the Hardhat compile command",
328918
328991
  command: "scs hardhat build --concurrency 2"
328919
328992
  }
328920
- ])).helpOption(false).option("-h, --help", "Get list of possible hardhat compile options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options, cmd2) => {
328993
+ ])).helpOption(false).option("-h, --help", "Get list of possible hardhat compile options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options, _cmd) => {
328921
328994
  intro("Building smart contracts using Hardhat");
328922
328995
  await validateIfRequiredPackagesAreInstalled(["hardhat"]);
328923
328996
  const hardhatOptions = mapPassthroughOptions(options, { args: operands });
@@ -328988,7 +329061,7 @@ async function selectTargetNode({
328988
329061
  settlemint
328989
329062
  }) {
328990
329063
  const nodeUniqueName = blockchainNodeUniqueName ?? (autoAccept ? env2.SETTLEMINT_BLOCKCHAIN_NODE : undefined);
328991
- let node = undefined;
329064
+ let node;
328992
329065
  if (!nodeUniqueName) {
328993
329066
  if (!env2.SETTLEMINT_APPLICATION) {
328994
329067
  return missingApplication();
@@ -329212,7 +329285,7 @@ function hardhatDeployRemoteCommand() {
329212
329285
  } else {
329213
329286
  note("Smart contract deployment was cancelled");
329214
329287
  }
329215
- } catch (error45) {
329288
+ } catch (_error) {
329216
329289
  cancel2("The smart contract deployment was unsuccessful. Please check the error details above and try again. You may need to review your contract code or deployment configuration.");
329217
329290
  }
329218
329291
  });
@@ -329242,7 +329315,7 @@ function hardhatNetworkCommand() {
329242
329315
  description: "Start a development network using Hardhat with a specific port",
329243
329316
  command: "scs hardhat network --port 3000"
329244
329317
  }
329245
- ])).helpOption(false).option("-h, --help", "Get list of possible hardhat node options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options, cmd2) => {
329318
+ ])).helpOption(false).option("-h, --help", "Get list of possible hardhat node options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options, _cmd) => {
329246
329319
  intro("Starting development network using Hardhat");
329247
329320
  await validateIfRequiredPackagesAreInstalled(["hardhat"]);
329248
329321
  const hardhatOptions = mapPassthroughOptions(options, { args: operands });
@@ -329351,7 +329424,7 @@ function hardhatTestCommand() {
329351
329424
  description: "Run a specific test file",
329352
329425
  command: "scs hardhat test test/token.test.ts"
329353
329426
  }
329354
- ])).helpOption(false).option("-h, --help", "Get list of possible hardhat test options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options, cmd2) => {
329427
+ ])).helpOption(false).option("-h, --help", "Get list of possible hardhat test options").passThroughOptions().allowUnknownOption(true).arguments("[operands...]").action(async (operands, options, _cmd) => {
329355
329428
  intro("Running smart contract tests using Hardhat");
329356
329429
  await validateIfRequiredPackagesAreInstalled(["hardhat"]);
329357
329430
  const hardhatOptions = mapPassthroughOptions(options, { args: operands });
@@ -330019,4 +330092,4 @@ async function sdkCliCommand(argv = process.argv) {
330019
330092
  // src/cli.ts
330020
330093
  sdkCliCommand();
330021
330094
 
330022
- //# debugId=752E0471C745FE3A64756E2164756E21
330095
+ //# debugId=6F57897A3E92B9C464756E2164756E21