@toruslabs/ethereum-controllers 7.0.0-alpha.3 → 7.0.0

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.
@@ -79,7 +79,7 @@ const functionModifiers = new Set([
79
79
  ]);
80
80
  //# sourceMappingURL=signatures.js.map
81
81
  ;// ../../node_modules/abitype/dist/esm/version.js
82
- const version = '1.0.6';
82
+ const version = '1.0.7';
83
83
  //# sourceMappingURL=version.js.map
84
84
  ;// ../../node_modules/abitype/dist/esm/errors.js
85
85
 
@@ -378,9 +378,20 @@ class InvalidParenthesisError extends BaseError {
378
378
  * @param type ABI parameter type
379
379
  * @returns Cache key for {@link parameterCache}
380
380
  */
381
- function getParameterCacheKey(param, type) {
381
+ function getParameterCacheKey(param, type, structs) {
382
+ let structKey = '';
383
+ if (structs)
384
+ for (const struct of Object.entries(structs)) {
385
+ if (!struct)
386
+ continue;
387
+ let propertyKey = '';
388
+ for (const property of struct[1]) {
389
+ propertyKey += `[${property.type}${property.name ? `:${property.name}` : ''}]`;
390
+ }
391
+ structKey += `(${struct[0]}{${propertyKey}})`;
392
+ }
382
393
  if (type)
383
- return `${type}:${param}`;
394
+ return `${type}:${param}${structKey}`;
384
395
  return param;
385
396
  }
386
397
  /**
@@ -544,7 +555,7 @@ const abiParameterWithTupleRegex = /^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?
544
555
  const dynamicIntegerRegex = /^u?int$/;
545
556
  function parseAbiParameter(param, options) {
546
557
  // optional namespace cache by `type`
547
- const parameterCacheKey = getParameterCacheKey(param, options?.type);
558
+ const parameterCacheKey = getParameterCacheKey(param, options?.type, options?.structs);
548
559
  if (parameterCache.has(parameterCacheKey))
549
560
  return parameterCache.get(parameterCacheKey);
550
561
  const isTuple = regex/* isTupleRegex */.wj.test(param);
@@ -3644,7 +3655,7 @@ __webpack_require__.d(__webpack_exports__, {
3644
3655
  // UNUSED EXPORTS: setErrorConfig
3645
3656
 
3646
3657
  ;// ../../node_modules/viem/_esm/errors/version.js
3647
- const version = '2.21.51';
3658
+ const version = '2.21.55';
3648
3659
  //# sourceMappingURL=version.js.map
3649
3660
  ;// ../../node_modules/viem/_esm/errors/base.js
3650
3661
 
@@ -4101,7 +4112,7 @@ class InvalidBytesLengthError extends _base_js__WEBPACK_IMPORTED_MODULE_0__/* .B
4101
4112
 
4102
4113
  /***/ }),
4103
4114
 
4104
- /***/ 675:
4115
+ /***/ 704:
4105
4116
  /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
4106
4117
 
4107
4118
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
@@ -4731,7 +4742,7 @@ function trim(hexOrBytes, { dir = 'left' } = {}) {
4731
4742
  }
4732
4743
  //# sourceMappingURL=trim.js.map
4733
4744
  // EXTERNAL MODULE: ../../node_modules/viem/_esm/errors/encoding.js
4734
- var encoding = __webpack_require__(675);
4745
+ var encoding = __webpack_require__(704);
4735
4746
  // EXTERNAL MODULE: ../../node_modules/viem/_esm/utils/encoding/fromHex.js
4736
4747
  var fromHex = __webpack_require__(756);
4737
4748
  // EXTERNAL MODULE: ../../node_modules/viem/_esm/utils/encoding/toHex.js
@@ -5199,14 +5210,18 @@ function decodeFunctionResult(parameters) {
5199
5210
  /* harmony export */ k: () => (/* binding */ getArrayComponents)
5200
5211
  /* harmony export */ });
5201
5212
  /* harmony import */ var _errors_abi_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(663);
5202
- /* harmony import */ var _errors_address_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(77);
5203
- /* harmony import */ var _errors_base_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(323);
5204
- /* harmony import */ var _address_isAddress_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(68);
5205
- /* harmony import */ var _data_concat_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(666);
5206
- /* harmony import */ var _data_pad_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(577);
5207
- /* harmony import */ var _data_size_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(943);
5208
- /* harmony import */ var _data_slice_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(846);
5209
- /* harmony import */ var _encoding_toHex_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(903);
5213
+ /* harmony import */ var _errors_address_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(77);
5214
+ /* harmony import */ var _errors_base_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(323);
5215
+ /* harmony import */ var _errors_encoding_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(704);
5216
+ /* harmony import */ var _address_isAddress_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(68);
5217
+ /* harmony import */ var _data_concat_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(666);
5218
+ /* harmony import */ var _data_pad_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(577);
5219
+ /* harmony import */ var _data_size_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(943);
5220
+ /* harmony import */ var _data_slice_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(846);
5221
+ /* harmony import */ var _encoding_toHex_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(903);
5222
+ /* harmony import */ var _regex_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(976);
5223
+
5224
+
5210
5225
 
5211
5226
 
5212
5227
 
@@ -5293,7 +5308,11 @@ function prepareParam({ param, value, }) {
5293
5308
  }
5294
5309
  if (param.type.startsWith('uint') || param.type.startsWith('int')) {
5295
5310
  const signed = param.type.startsWith('int');
5296
- return encodeNumber(value, { signed });
5311
+ const [, , size = '256'] = _regex_js__WEBPACK_IMPORTED_MODULE_1__/* .integerRegex */ .Ge.exec(param.type) ?? [];
5312
+ return encodeNumber(value, {
5313
+ signed,
5314
+ size: Number(size),
5315
+ });
5297
5316
  }
5298
5317
  if (param.type.startsWith('bytes')) {
5299
5318
  return encodeBytes(value, { param });
@@ -5313,7 +5332,7 @@ function encodeParams(preparedParams) {
5313
5332
  if (dynamic)
5314
5333
  staticSize += 32;
5315
5334
  else
5316
- staticSize += (0,_data_size_js__WEBPACK_IMPORTED_MODULE_1__/* .size */ .E)(encoded);
5335
+ staticSize += (0,_data_size_js__WEBPACK_IMPORTED_MODULE_2__/* .size */ .E)(encoded);
5317
5336
  }
5318
5337
  // 2. Split the parameters into static and dynamic parts.
5319
5338
  const staticParams = [];
@@ -5322,21 +5341,21 @@ function encodeParams(preparedParams) {
5322
5341
  for (let i = 0; i < preparedParams.length; i++) {
5323
5342
  const { dynamic, encoded } = preparedParams[i];
5324
5343
  if (dynamic) {
5325
- staticParams.push((0,_encoding_toHex_js__WEBPACK_IMPORTED_MODULE_2__/* .numberToHex */ .cK)(staticSize + dynamicSize, { size: 32 }));
5344
+ staticParams.push((0,_encoding_toHex_js__WEBPACK_IMPORTED_MODULE_3__/* .numberToHex */ .cK)(staticSize + dynamicSize, { size: 32 }));
5326
5345
  dynamicParams.push(encoded);
5327
- dynamicSize += (0,_data_size_js__WEBPACK_IMPORTED_MODULE_1__/* .size */ .E)(encoded);
5346
+ dynamicSize += (0,_data_size_js__WEBPACK_IMPORTED_MODULE_2__/* .size */ .E)(encoded);
5328
5347
  }
5329
5348
  else {
5330
5349
  staticParams.push(encoded);
5331
5350
  }
5332
5351
  }
5333
5352
  // 3. Concatenate static and dynamic parts.
5334
- return (0,_data_concat_js__WEBPACK_IMPORTED_MODULE_3__/* .concat */ .xW)([...staticParams, ...dynamicParams]);
5353
+ return (0,_data_concat_js__WEBPACK_IMPORTED_MODULE_4__/* .concat */ .xW)([...staticParams, ...dynamicParams]);
5335
5354
  }
5336
5355
  function encodeAddress(value) {
5337
- if (!(0,_address_isAddress_js__WEBPACK_IMPORTED_MODULE_4__/* .isAddress */ .P)(value))
5338
- throw new _errors_address_js__WEBPACK_IMPORTED_MODULE_5__/* .InvalidAddressError */ .M({ address: value });
5339
- return { dynamic: false, encoded: (0,_data_pad_js__WEBPACK_IMPORTED_MODULE_6__/* .padHex */ .db)(value.toLowerCase()) };
5356
+ if (!(0,_address_isAddress_js__WEBPACK_IMPORTED_MODULE_5__/* .isAddress */ .P)(value))
5357
+ throw new _errors_address_js__WEBPACK_IMPORTED_MODULE_6__/* .InvalidAddressError */ .M({ address: value });
5358
+ return { dynamic: false, encoded: (0,_data_pad_js__WEBPACK_IMPORTED_MODULE_7__/* .padHex */ .db)(value.toLowerCase()) };
5340
5359
  }
5341
5360
  function encodeArray(value, { length, param, }) {
5342
5361
  const dynamic = length === null;
@@ -5359,10 +5378,10 @@ function encodeArray(value, { length, param, }) {
5359
5378
  if (dynamic || dynamicChild) {
5360
5379
  const data = encodeParams(preparedParams);
5361
5380
  if (dynamic) {
5362
- const length = (0,_encoding_toHex_js__WEBPACK_IMPORTED_MODULE_2__/* .numberToHex */ .cK)(preparedParams.length, { size: 32 });
5381
+ const length = (0,_encoding_toHex_js__WEBPACK_IMPORTED_MODULE_3__/* .numberToHex */ .cK)(preparedParams.length, { size: 32 });
5363
5382
  return {
5364
5383
  dynamic: true,
5365
- encoded: preparedParams.length > 0 ? (0,_data_concat_js__WEBPACK_IMPORTED_MODULE_3__/* .concat */ .xW)([length, data]) : length,
5384
+ encoded: preparedParams.length > 0 ? (0,_data_concat_js__WEBPACK_IMPORTED_MODULE_4__/* .concat */ .xW)([length, data]) : length,
5366
5385
  };
5367
5386
  }
5368
5387
  if (dynamicChild)
@@ -5370,24 +5389,24 @@ function encodeArray(value, { length, param, }) {
5370
5389
  }
5371
5390
  return {
5372
5391
  dynamic: false,
5373
- encoded: (0,_data_concat_js__WEBPACK_IMPORTED_MODULE_3__/* .concat */ .xW)(preparedParams.map(({ encoded }) => encoded)),
5392
+ encoded: (0,_data_concat_js__WEBPACK_IMPORTED_MODULE_4__/* .concat */ .xW)(preparedParams.map(({ encoded }) => encoded)),
5374
5393
  };
5375
5394
  }
5376
5395
  function encodeBytes(value, { param }) {
5377
5396
  const [, paramSize] = param.type.split('bytes');
5378
- const bytesSize = (0,_data_size_js__WEBPACK_IMPORTED_MODULE_1__/* .size */ .E)(value);
5397
+ const bytesSize = (0,_data_size_js__WEBPACK_IMPORTED_MODULE_2__/* .size */ .E)(value);
5379
5398
  if (!paramSize) {
5380
5399
  let value_ = value;
5381
5400
  // If the size is not divisible by 32 bytes, pad the end
5382
5401
  // with empty bytes to the ceiling 32 bytes.
5383
5402
  if (bytesSize % 32 !== 0)
5384
- value_ = (0,_data_pad_js__WEBPACK_IMPORTED_MODULE_6__/* .padHex */ .db)(value_, {
5403
+ value_ = (0,_data_pad_js__WEBPACK_IMPORTED_MODULE_7__/* .padHex */ .db)(value_, {
5385
5404
  dir: 'right',
5386
5405
  size: Math.ceil((value.length - 2) / 2 / 32) * 32,
5387
5406
  });
5388
5407
  return {
5389
5408
  dynamic: true,
5390
- encoded: (0,_data_concat_js__WEBPACK_IMPORTED_MODULE_3__/* .concat */ .xW)([(0,_data_pad_js__WEBPACK_IMPORTED_MODULE_6__/* .padHex */ .db)((0,_encoding_toHex_js__WEBPACK_IMPORTED_MODULE_2__/* .numberToHex */ .cK)(bytesSize, { size: 32 })), value_]),
5409
+ encoded: (0,_data_concat_js__WEBPACK_IMPORTED_MODULE_4__/* .concat */ .xW)([(0,_data_pad_js__WEBPACK_IMPORTED_MODULE_7__/* .padHex */ .db)((0,_encoding_toHex_js__WEBPACK_IMPORTED_MODULE_3__/* .numberToHex */ .cK)(bytesSize, { size: 32 })), value_]),
5391
5410
  };
5392
5411
  }
5393
5412
  if (bytesSize !== Number.parseInt(paramSize))
@@ -5395,35 +5414,47 @@ function encodeBytes(value, { param }) {
5395
5414
  expectedSize: Number.parseInt(paramSize),
5396
5415
  value,
5397
5416
  });
5398
- return { dynamic: false, encoded: (0,_data_pad_js__WEBPACK_IMPORTED_MODULE_6__/* .padHex */ .db)(value, { dir: 'right' }) };
5417
+ return { dynamic: false, encoded: (0,_data_pad_js__WEBPACK_IMPORTED_MODULE_7__/* .padHex */ .db)(value, { dir: 'right' }) };
5399
5418
  }
5400
5419
  function encodeBool(value) {
5401
5420
  if (typeof value !== 'boolean')
5402
- throw new _errors_base_js__WEBPACK_IMPORTED_MODULE_7__/* .BaseError */ .C(`Invalid boolean value: "${value}" (type: ${typeof value}). Expected: \`true\` or \`false\`.`);
5403
- return { dynamic: false, encoded: (0,_data_pad_js__WEBPACK_IMPORTED_MODULE_6__/* .padHex */ .db)((0,_encoding_toHex_js__WEBPACK_IMPORTED_MODULE_2__/* .boolToHex */ .$P)(value)) };
5404
- }
5405
- function encodeNumber(value, { signed }) {
5421
+ throw new _errors_base_js__WEBPACK_IMPORTED_MODULE_8__/* .BaseError */ .C(`Invalid boolean value: "${value}" (type: ${typeof value}). Expected: \`true\` or \`false\`.`);
5422
+ return { dynamic: false, encoded: (0,_data_pad_js__WEBPACK_IMPORTED_MODULE_7__/* .padHex */ .db)((0,_encoding_toHex_js__WEBPACK_IMPORTED_MODULE_3__/* .boolToHex */ .$P)(value)) };
5423
+ }
5424
+ function encodeNumber(value, { signed, size = 256 }) {
5425
+ if (typeof size === 'number') {
5426
+ const max = 2n ** (BigInt(size) - (signed ? 1n : 0n)) - 1n;
5427
+ const min = signed ? -max - 1n : 0n;
5428
+ if (value > max || value < min)
5429
+ throw new _errors_encoding_js__WEBPACK_IMPORTED_MODULE_9__/* .IntegerOutOfRangeError */ .Ty({
5430
+ max: max.toString(),
5431
+ min: min.toString(),
5432
+ signed,
5433
+ size: size / 8,
5434
+ value: value.toString(),
5435
+ });
5436
+ }
5406
5437
  return {
5407
5438
  dynamic: false,
5408
- encoded: (0,_encoding_toHex_js__WEBPACK_IMPORTED_MODULE_2__/* .numberToHex */ .cK)(value, {
5439
+ encoded: (0,_encoding_toHex_js__WEBPACK_IMPORTED_MODULE_3__/* .numberToHex */ .cK)(value, {
5409
5440
  size: 32,
5410
5441
  signed,
5411
5442
  }),
5412
5443
  };
5413
5444
  }
5414
5445
  function encodeString(value) {
5415
- const hexValue = (0,_encoding_toHex_js__WEBPACK_IMPORTED_MODULE_2__/* .stringToHex */ .i3)(value);
5416
- const partsLength = Math.ceil((0,_data_size_js__WEBPACK_IMPORTED_MODULE_1__/* .size */ .E)(hexValue) / 32);
5446
+ const hexValue = (0,_encoding_toHex_js__WEBPACK_IMPORTED_MODULE_3__/* .stringToHex */ .i3)(value);
5447
+ const partsLength = Math.ceil((0,_data_size_js__WEBPACK_IMPORTED_MODULE_2__/* .size */ .E)(hexValue) / 32);
5417
5448
  const parts = [];
5418
5449
  for (let i = 0; i < partsLength; i++) {
5419
- parts.push((0,_data_pad_js__WEBPACK_IMPORTED_MODULE_6__/* .padHex */ .db)((0,_data_slice_js__WEBPACK_IMPORTED_MODULE_8__/* .slice */ .di)(hexValue, i * 32, (i + 1) * 32), {
5450
+ parts.push((0,_data_pad_js__WEBPACK_IMPORTED_MODULE_7__/* .padHex */ .db)((0,_data_slice_js__WEBPACK_IMPORTED_MODULE_10__/* .slice */ .di)(hexValue, i * 32, (i + 1) * 32), {
5420
5451
  dir: 'right',
5421
5452
  }));
5422
5453
  }
5423
5454
  return {
5424
5455
  dynamic: true,
5425
- encoded: (0,_data_concat_js__WEBPACK_IMPORTED_MODULE_3__/* .concat */ .xW)([
5426
- (0,_data_pad_js__WEBPACK_IMPORTED_MODULE_6__/* .padHex */ .db)((0,_encoding_toHex_js__WEBPACK_IMPORTED_MODULE_2__/* .numberToHex */ .cK)((0,_data_size_js__WEBPACK_IMPORTED_MODULE_1__/* .size */ .E)(hexValue), { size: 32 })),
5456
+ encoded: (0,_data_concat_js__WEBPACK_IMPORTED_MODULE_4__/* .concat */ .xW)([
5457
+ (0,_data_pad_js__WEBPACK_IMPORTED_MODULE_7__/* .padHex */ .db)((0,_encoding_toHex_js__WEBPACK_IMPORTED_MODULE_3__/* .numberToHex */ .cK)((0,_data_size_js__WEBPACK_IMPORTED_MODULE_2__/* .size */ .E)(hexValue), { size: 32 })),
5427
5458
  ...parts,
5428
5459
  ]),
5429
5460
  };
@@ -5446,7 +5477,7 @@ function encodeTuple(value, { param }) {
5446
5477
  dynamic,
5447
5478
  encoded: dynamic
5448
5479
  ? encodeParams(preparedParams)
5449
- : (0,_data_concat_js__WEBPACK_IMPORTED_MODULE_3__/* .concat */ .xW)(preparedParams.map(({ encoded }) => encoded)),
5480
+ : (0,_data_concat_js__WEBPACK_IMPORTED_MODULE_4__/* .concat */ .xW)(preparedParams.map(({ encoded }) => encoded)),
5450
5481
  };
5451
5482
  }
5452
5483
  function getArrayComponents(type) {
@@ -5739,7 +5770,7 @@ function getAmbiguousTypes(sourceParameters, targetParameters, args) {
5739
5770
  /* harmony export */ });
5740
5771
  /* unused harmony export getAddress */
5741
5772
  /* harmony import */ var _encoding_toBytes_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(421);
5742
- /* harmony import */ var _hash_keccak256_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(849);
5773
+ /* harmony import */ var _hash_keccak256_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(859);
5743
5774
  /* harmony import */ var _lru_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(394);
5744
5775
 
5745
5776
 
@@ -6046,7 +6077,7 @@ function sliceHex(value_, start, end, { strict } = {}) {
6046
6077
  /* harmony export */ uU: () => (/* binding */ hexToBigInt)
6047
6078
  /* harmony export */ });
6048
6079
  /* unused harmony exports fromHex, hexToBool, hexToString */
6049
- /* harmony import */ var _errors_encoding_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(675);
6080
+ /* harmony import */ var _errors_encoding_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(704);
6050
6081
  /* harmony import */ var _data_size_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(943);
6051
6082
 
6052
6083
 
@@ -6422,7 +6453,7 @@ function stringToBytes(value, opts = {}) {
6422
6453
  /* harmony export */ i3: () => (/* binding */ stringToHex),
6423
6454
  /* harmony export */ nj: () => (/* binding */ toHex)
6424
6455
  /* harmony export */ });
6425
- /* harmony import */ var _errors_encoding_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(675);
6456
+ /* harmony import */ var _errors_encoding_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(704);
6426
6457
  /* harmony import */ var _data_pad_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(577);
6427
6458
  /* harmony import */ var _fromHex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(756);
6428
6459
 
@@ -6603,7 +6634,7 @@ function stringToHex(value_, opts = {}) {
6603
6634
 
6604
6635
  /***/ }),
6605
6636
 
6606
- /***/ 849:
6637
+ /***/ 859:
6607
6638
  /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
6608
6639
 
6609
6640
 
@@ -6612,53 +6643,55 @@ __webpack_require__.d(__webpack_exports__, {
6612
6643
  S: () => (/* binding */ keccak256)
6613
6644
  });
6614
6645
 
6615
- ;// ../../node_modules/@noble/hashes/esm/_assert.js
6616
- function number(n) {
6646
+ ;// ../../node_modules/viem/node_modules/@noble/hashes/esm/_assert.js
6647
+ function anumber(n) {
6617
6648
  if (!Number.isSafeInteger(n) || n < 0)
6618
- throw new Error(`positive integer expected, not ${n}`);
6619
- }
6620
- function bool(b) {
6621
- if (typeof b !== 'boolean')
6622
- throw new Error(`boolean expected, not ${b}`);
6649
+ throw new Error('positive integer expected, got ' + n);
6623
6650
  }
6624
6651
  // copied from utils
6625
6652
  function isBytes(a) {
6626
- return (a instanceof Uint8Array ||
6627
- (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
6653
+ return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
6628
6654
  }
6629
- function bytes(b, ...lengths) {
6655
+ function _assert_abytes(b, ...lengths) {
6630
6656
  if (!isBytes(b))
6631
6657
  throw new Error('Uint8Array expected');
6632
6658
  if (lengths.length > 0 && !lengths.includes(b.length))
6633
- throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);
6659
+ throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);
6634
6660
  }
6635
- function hash(h) {
6661
+ function ahash(h) {
6636
6662
  if (typeof h !== 'function' || typeof h.create !== 'function')
6637
6663
  throw new Error('Hash should be wrapped by utils.wrapConstructor');
6638
- number(h.outputLen);
6639
- number(h.blockLen);
6664
+ anumber(h.outputLen);
6665
+ anumber(h.blockLen);
6640
6666
  }
6641
- function exists(instance, checkFinished = true) {
6667
+ function aexists(instance, checkFinished = true) {
6642
6668
  if (instance.destroyed)
6643
6669
  throw new Error('Hash instance has been destroyed');
6644
6670
  if (checkFinished && instance.finished)
6645
6671
  throw new Error('Hash#digest() has already been called');
6646
6672
  }
6647
- function output(out, instance) {
6648
- bytes(out);
6673
+ function aoutput(out, instance) {
6674
+ _assert_abytes(out);
6649
6675
  const min = instance.outputLen;
6650
6676
  if (out.length < min) {
6651
- throw new Error(`digestInto() expects output buffer of length at least ${min}`);
6677
+ throw new Error('digestInto() expects output buffer of length at least ' + min);
6652
6678
  }
6653
6679
  }
6654
6680
 
6655
- const assert = { number, bool, bytes, hash, exists, output };
6681
+ const assert = {
6682
+ number: anumber,
6683
+ bytes: _assert_abytes,
6684
+ hash: ahash,
6685
+ exists: aexists,
6686
+ output: aoutput,
6687
+ };
6656
6688
  /* harmony default export */ const _assert = ((/* unused pure expression or super */ null && (assert)));
6657
6689
  //# sourceMappingURL=_assert.js.map
6658
- ;// ../../node_modules/@noble/hashes/esm/_u64.js
6690
+ ;// ../../node_modules/viem/node_modules/@noble/hashes/esm/_u64.js
6659
6691
  const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
6660
6692
  const _32n = /* @__PURE__ */ BigInt(32);
6661
- // We are not using BigUint64Array, because they are extremely slow as per 2022
6693
+ // BigUint64Array is too slow as per 2024, so we implement it using Uint32Array.
6694
+ // TODO: re-check https://issues.chromium.org/issues/42212588
6662
6695
  function fromBig(n, le = false) {
6663
6696
  if (le)
6664
6697
  return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
@@ -6718,7 +6751,7 @@ const u64 = {
6718
6751
  };
6719
6752
  /* harmony default export */ const _u64 = ((/* unused pure expression or super */ null && (u64)));
6720
6753
  //# sourceMappingURL=_u64.js.map
6721
- ;// ../../node_modules/@noble/hashes/esm/utils.js
6754
+ ;// ../../node_modules/viem/node_modules/@noble/hashes/esm/utils.js
6722
6755
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
6723
6756
  // We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
6724
6757
  // node.js versions earlier than v19 don't declare it in global scope.
@@ -6731,8 +6764,7 @@ const u64 = {
6731
6764
  // export { isBytes } from './_assert.js';
6732
6765
  // We can't reuse isBytes from _assert, because somehow this causes huge perf issues
6733
6766
  function utils_isBytes(a) {
6734
- return (a instanceof Uint8Array ||
6735
- (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
6767
+ return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
6736
6768
  }
6737
6769
  // Cast array to different type
6738
6770
  const u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
@@ -6743,7 +6775,7 @@ const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLen
6743
6775
  const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);
6744
6776
  // The rotate left (circular left shift) operation for uint32
6745
6777
  const rotl = (word, shift) => (word << shift) | ((word >>> (32 - shift)) >>> 0);
6746
- const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
6778
+ const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();
6747
6779
  // The byte swap operation for uint32
6748
6780
  const byteSwap = (word) => ((word << 24) & 0xff000000) |
6749
6781
  ((word << 8) & 0xff0000) |
@@ -6772,14 +6804,14 @@ function bytesToHex(bytes) {
6772
6804
  return hex;
6773
6805
  }
6774
6806
  // We use optimized technique to convert hex string to byte array
6775
- const asciis = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 };
6776
- function asciiToBase16(char) {
6777
- if (char >= asciis._0 && char <= asciis._9)
6778
- return char - asciis._0;
6779
- if (char >= asciis._A && char <= asciis._F)
6780
- return char - (asciis._A - 10);
6781
- if (char >= asciis._a && char <= asciis._f)
6782
- return char - (asciis._a - 10);
6807
+ const asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
6808
+ function asciiToBase16(ch) {
6809
+ if (ch >= asciis._0 && ch <= asciis._9)
6810
+ return ch - asciis._0; // '2' => 50-48
6811
+ if (ch >= asciis.A && ch <= asciis.F)
6812
+ return ch - (asciis.A - 10); // 'B' => 66-(65-10)
6813
+ if (ch >= asciis.a && ch <= asciis.f)
6814
+ return ch - (asciis.a - 10); // 'b' => 98-(97-10)
6783
6815
  return;
6784
6816
  }
6785
6817
  /**
@@ -6791,7 +6823,7 @@ function hexToBytes(hex) {
6791
6823
  const hl = hex.length;
6792
6824
  const al = hl / 2;
6793
6825
  if (hl % 2)
6794
- throw new Error('padded hex string expected, got unpadded hex of length ' + hl);
6826
+ throw new Error('hex string expected, got unpadded hex of length ' + hl);
6795
6827
  const array = new Uint8Array(al);
6796
6828
  for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
6797
6829
  const n1 = asciiToBase16(hex.charCodeAt(hi));
@@ -6800,7 +6832,7 @@ function hexToBytes(hex) {
6800
6832
  const char = hex[hi] + hex[hi + 1];
6801
6833
  throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
6802
6834
  }
6803
- array[ai] = n1 * 16 + n2;
6835
+ array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163
6804
6836
  }
6805
6837
  return array;
6806
6838
  }
@@ -6826,7 +6858,7 @@ async function asyncLoop(iters, tick, cb) {
6826
6858
  */
6827
6859
  function utf8ToBytes(str) {
6828
6860
  if (typeof str !== 'string')
6829
- throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
6861
+ throw new Error('utf8ToBytes expected string, got ' + typeof str);
6830
6862
  return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
6831
6863
  }
6832
6864
  /**
@@ -6837,7 +6869,7 @@ function utf8ToBytes(str) {
6837
6869
  function toBytes(data) {
6838
6870
  if (typeof data === 'string')
6839
6871
  data = utf8ToBytes(data);
6840
- bytes(data);
6872
+ _assert_abytes(data);
6841
6873
  return data;
6842
6874
  }
6843
6875
  /**
@@ -6865,9 +6897,8 @@ class Hash {
6865
6897
  return this._cloneInto();
6866
6898
  }
6867
6899
  }
6868
- const toStr = {}.toString;
6869
6900
  function checkOpts(defaults, opts) {
6870
- if (opts !== undefined && toStr.call(opts) !== '[object Object]')
6901
+ if (opts !== undefined && {}.toString.call(opts) !== '[object Object]')
6871
6902
  throw new Error('Options should be object or undefined');
6872
6903
  const merged = Object.assign(defaults, opts);
6873
6904
  return merged;
@@ -6910,7 +6941,7 @@ function randomBytes(bytesLength = 32) {
6910
6941
  throw new Error('crypto.getRandomValues must be defined');
6911
6942
  }
6912
6943
  //# sourceMappingURL=utils.js.map
6913
- ;// ../../node_modules/@noble/hashes/esm/sha3.js
6944
+ ;// ../../node_modules/viem/node_modules/@noble/hashes/esm/sha3.js
6914
6945
 
6915
6946
 
6916
6947
 
@@ -7005,7 +7036,7 @@ class Keccak extends Hash {
7005
7036
  this.finished = false;
7006
7037
  this.destroyed = false;
7007
7038
  // Can be passed from user as dkLen
7008
- number(outputLen);
7039
+ anumber(outputLen);
7009
7040
  // 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes
7010
7041
  if (0 >= this.blockLen || this.blockLen >= 200)
7011
7042
  throw new Error('Sha3 supports only keccak-f1600 function');
@@ -7022,7 +7053,7 @@ class Keccak extends Hash {
7022
7053
  this.pos = 0;
7023
7054
  }
7024
7055
  update(data) {
7025
- exists(this);
7056
+ aexists(this);
7026
7057
  const { blockLen, state } = this;
7027
7058
  data = toBytes(data);
7028
7059
  const len = data.length;
@@ -7048,8 +7079,8 @@ class Keccak extends Hash {
7048
7079
  this.keccak();
7049
7080
  }
7050
7081
  writeInto(out) {
7051
- exists(this, false);
7052
- bytes(out);
7082
+ aexists(this, false);
7083
+ _assert_abytes(out);
7053
7084
  this.finish();
7054
7085
  const bufferOut = this.state;
7055
7086
  const { blockLen } = this;
@@ -7070,11 +7101,11 @@ class Keccak extends Hash {
7070
7101
  return this.writeInto(out);
7071
7102
  }
7072
7103
  xof(bytes) {
7073
- number(bytes);
7104
+ anumber(bytes);
7074
7105
  return this.xofInto(new Uint8Array(bytes));
7075
7106
  }
7076
7107
  digestInto(out) {
7077
- output(out, this);
7108
+ aoutput(out, this);
7078
7109
  if (this.finished)
7079
7110
  throw new Error('digest() was already called');
7080
7111
  this.writeInto(out);
@@ -7181,7 +7212,7 @@ __webpack_require__.d(__webpack_exports__, {
7181
7212
  // EXTERNAL MODULE: ../../node_modules/viem/_esm/utils/encoding/toBytes.js
7182
7213
  var toBytes = __webpack_require__(421);
7183
7214
  // EXTERNAL MODULE: ../../node_modules/viem/_esm/utils/hash/keccak256.js + 4 modules
7184
- var keccak256 = __webpack_require__(849);
7215
+ var keccak256 = __webpack_require__(859);
7185
7216
  ;// ../../node_modules/viem/_esm/utils/hash/hashSignature.js
7186
7217
 
7187
7218
 
@@ -7272,7 +7303,7 @@ function formatAbiItem(abiItem) {
7272
7303
  if (abiItem.type === 'function')
7273
7304
  return `function ${abiItem.name}(${formatAbiParameters(abiItem.inputs)})${abiItem.stateMutability && abiItem.stateMutability !== 'nonpayable'
7274
7305
  ? ` ${abiItem.stateMutability}`
7275
- : ''}${abiItem.outputs.length
7306
+ : ''}${abiItem.outputs?.length
7276
7307
  ? ` returns (${formatAbiParameters(abiItem.outputs)})`
7277
7308
  : ''}`;
7278
7309
  if (abiItem.type === 'event')
@@ -7282,7 +7313,7 @@ function formatAbiItem(abiItem) {
7282
7313
  if (abiItem.type === 'constructor')
7283
7314
  return `constructor(${formatAbiParameters(abiItem.inputs)})${abiItem.stateMutability === 'payable' ? ' payable' : ''}`;
7284
7315
  if (abiItem.type === 'fallback')
7285
- return 'fallback()';
7316
+ return `fallback() external${abiItem.stateMutability === 'payable' ? ' payable' : ''}`;
7286
7317
  return 'receive() external payable';
7287
7318
  }
7288
7319
  //# sourceMappingURL=formatAbiItem.js.map
@@ -7426,6 +7457,25 @@ class LruMap extends Map {
7426
7457
 
7427
7458
  /***/ }),
7428
7459
 
7460
+ /***/ 976:
7461
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7462
+
7463
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7464
+ /* harmony export */ BD: () => (/* binding */ bytesRegex),
7465
+ /* harmony export */ Ge: () => (/* binding */ integerRegex)
7466
+ /* harmony export */ });
7467
+ /* unused harmony export arrayRegex */
7468
+ const arrayRegex = /^(.*)\[([0-9]*)\]$/;
7469
+ // `bytes<M>`: binary type of `M` bytes, `0 < M <= 32`
7470
+ // https://regexr.com/6va55
7471
+ const bytesRegex = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/;
7472
+ // `(u)int<M>`: (un)signed integer type of `M` bits, `0 < M <= 256`, `M % 8 == 0`
7473
+ // https://regexr.com/6v8hp
7474
+ const integerRegex = /^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;
7475
+ //# sourceMappingURL=regex.js.map
7476
+
7477
+ /***/ }),
7478
+
7429
7479
  /***/ 274:
7430
7480
  /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
7431
7481
 
@@ -11250,7 +11300,7 @@ function src_formatUserOperation(parameters) {
11250
11300
  /**
11251
11301
  * Retrieves information about a User Operation given a hash.
11252
11302
  *
11253
- * - Docs: https://viem.sh/docs/actions/bundler/getUserOperation
11303
+ * - Docs: https://viem.sh/account-abstraction/actions/bundler/getUserOperation
11254
11304
  *
11255
11305
  * @param client - Client to use
11256
11306
  * @param parameters - {@link GetUserOperationParameters}
@@ -11489,8 +11539,11 @@ function src_observe(observerId, callbacks, fn) {
11489
11539
  src_listenersCache.set(observerId, listeners.filter((cb) => cb.id !== callbackId));
11490
11540
  };
11491
11541
  const unwatch = () => {
11542
+ const listeners = getListeners();
11543
+ if (!listeners.some((cb) => cb.id === callbackId))
11544
+ return;
11492
11545
  const cleanup = src_cleanupCache.get(observerId);
11493
- if (getListeners().length === 1 && cleanup)
11546
+ if (listeners.length === 1 && cleanup)
11494
11547
  cleanup();
11495
11548
  unsubscribe();
11496
11549
  };
@@ -13978,7 +14031,7 @@ async function src_toSmartAccount(implementation) {
13978
14031
  // EXTERNAL MODULE: ../../node_modules/viem/_esm/utils/data/pad.js
13979
14032
  var src_pad = __webpack_require__(577);
13980
14033
  // EXTERNAL MODULE: ../../node_modules/viem/_esm/utils/hash/keccak256.js + 4 modules
13981
- var src_keccak256 = __webpack_require__(849);
14034
+ var src_keccak256 = __webpack_require__(859);
13982
14035
  ;// ../../node_modules/viem/_esm/account-abstraction/utils/userOperation/getUserOperationHash.js
13983
14036
 
13984
14037
 
@@ -14263,15 +14316,8 @@ class src_InvalidStructTypeError extends src_base/* BaseError */.C {
14263
14316
  //# sourceMappingURL=typedData.js.map
14264
14317
  // EXTERNAL MODULE: ../../node_modules/viem/_esm/utils/data/size.js
14265
14318
  var src_data_size = __webpack_require__(943);
14266
- ;// ../../node_modules/viem/_esm/utils/regex.js
14267
- const src_arrayRegex = /^(.*)\[([0-9]*)\]$/;
14268
- // `bytes<M>`: binary type of `M` bytes, `0 < M <= 32`
14269
- // https://regexr.com/6va55
14270
- const src_bytesRegex = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/;
14271
- // `(u)int<M>`: (un)signed integer type of `M` bits, `0 < M <= 256`, `M % 8 == 0`
14272
- // https://regexr.com/6v8hp
14273
- const src_integerRegex = /^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;
14274
- //# sourceMappingURL=regex.js.map
14319
+ // EXTERNAL MODULE: ../../node_modules/viem/_esm/utils/regex.js
14320
+ var src_regex = __webpack_require__(976);
14275
14321
  ;// ../../node_modules/viem/_esm/utils/typedData.js
14276
14322
 
14277
14323
 
@@ -14313,7 +14359,7 @@ function src_validateTypedData(parameters) {
14313
14359
  for (const param of struct) {
14314
14360
  const { name, type } = param;
14315
14361
  const value = data[name];
14316
- const integerMatch = type.match(src_integerRegex);
14362
+ const integerMatch = type.match(src_regex/* integerRegex */.Ge);
14317
14363
  if (integerMatch &&
14318
14364
  (typeof value === 'number' || typeof value === 'bigint')) {
14319
14365
  const [_type, base, size_] = integerMatch;
@@ -14326,7 +14372,7 @@ function src_validateTypedData(parameters) {
14326
14372
  }
14327
14373
  if (type === 'address' && typeof value === 'string' && !(0,src_isAddress/* isAddress */.P)(value))
14328
14374
  throw new src_address/* InvalidAddressError */.M({ address: value });
14329
- const bytesMatch = type.match(src_bytesRegex);
14375
+ const bytesMatch = type.match(src_regex/* bytesRegex */.BD);
14330
14376
  if (bytesMatch) {
14331
14377
  const [_type, size_] = bytesMatch;
14332
14378
  if (size_ && (0,src_data_size/* size */.E)(value) !== Number.parseInt(size_))
@@ -14919,6 +14965,321 @@ class src_BiconomySmartAccount {
14919
14965
  }));
14920
14966
  }
14921
14967
  }
14968
+ ;// ../../node_modules/@noble/hashes/esm/_assert.js
14969
+ function src_anumber(n) {
14970
+ if (!Number.isSafeInteger(n) || n < 0)
14971
+ throw new Error('positive integer expected, got ' + n);
14972
+ }
14973
+ // copied from utils
14974
+ function src_isBytes(a) {
14975
+ return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
14976
+ }
14977
+ function src_assert_abytes(b, ...lengths) {
14978
+ if (!src_isBytes(b))
14979
+ throw new Error('Uint8Array expected');
14980
+ if (lengths.length > 0 && !lengths.includes(b.length))
14981
+ throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);
14982
+ }
14983
+ function src_ahash(h) {
14984
+ if (typeof h !== 'function' || typeof h.create !== 'function')
14985
+ throw new Error('Hash should be wrapped by utils.wrapConstructor');
14986
+ src_anumber(h.outputLen);
14987
+ src_anumber(h.blockLen);
14988
+ }
14989
+ function src_aexists(instance, checkFinished = true) {
14990
+ if (instance.destroyed)
14991
+ throw new Error('Hash instance has been destroyed');
14992
+ if (checkFinished && instance.finished)
14993
+ throw new Error('Hash#digest() has already been called');
14994
+ }
14995
+ function src_aoutput(out, instance) {
14996
+ src_assert_abytes(out);
14997
+ const min = instance.outputLen;
14998
+ if (out.length < min) {
14999
+ throw new Error('digestInto() expects output buffer of length at least ' + min);
15000
+ }
15001
+ }
15002
+
15003
+ const src_assert = {
15004
+ number: src_anumber,
15005
+ bytes: src_assert_abytes,
15006
+ hash: src_ahash,
15007
+ exists: src_aexists,
15008
+ output: src_aoutput,
15009
+ };
15010
+ /* harmony default export */ const src_assert_0 = ((/* unused pure expression or super */ null && (src_assert)));
15011
+ //# sourceMappingURL=_assert.js.map
15012
+ ;// ../../node_modules/@noble/hashes/esm/utils.js
15013
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
15014
+ // We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
15015
+ // node.js versions earlier than v19 don't declare it in global scope.
15016
+ // For node.js, package.json#exports field mapping rewrites import
15017
+ // from `crypto` to `cryptoNode`, which imports native module.
15018
+ // Makes the utils un-importable in browsers without a bundler.
15019
+ // Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
15020
+
15021
+
15022
+ // export { isBytes } from './_assert.js';
15023
+ // We can't reuse isBytes from _assert, because somehow this causes huge perf issues
15024
+ function src_utils_isBytes(a) {
15025
+ return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
15026
+ }
15027
+ // Cast array to different type
15028
+ const src_u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
15029
+ const src_u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
15030
+ // Cast array to view
15031
+ const src_createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
15032
+ // The rotate right (circular right shift) operation for uint32
15033
+ const src_rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);
15034
+ // The rotate left (circular left shift) operation for uint32
15035
+ const src_rotl = (word, shift) => (word << shift) | ((word >>> (32 - shift)) >>> 0);
15036
+ const src_isLE = /* @__PURE__ */ (/* unused pure expression or super */ null && ((() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)()));
15037
+ // The byte swap operation for uint32
15038
+ const src_byteSwap = (word) => ((word << 24) & 0xff000000) |
15039
+ ((word << 8) & 0xff0000) |
15040
+ ((word >>> 8) & 0xff00) |
15041
+ ((word >>> 24) & 0xff);
15042
+ // Conditionally byte swap if on a big-endian platform
15043
+ const src_byteSwapIfBE = (/* unused pure expression or super */ null && (src_isLE ? (n) => n : (n) => src_byteSwap(n)));
15044
+ // In place byte swap for Uint32Array
15045
+ function src_byteSwap32(arr) {
15046
+ for (let i = 0; i < arr.length; i++) {
15047
+ arr[i] = src_byteSwap(arr[i]);
15048
+ }
15049
+ }
15050
+ // Array where index 0xf0 (240) is mapped to string 'f0'
15051
+ const src_hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));
15052
+ /**
15053
+ * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
15054
+ */
15055
+ function src_utils_bytesToHex(bytes) {
15056
+ src_assert_abytes(bytes);
15057
+ // pre-caching improves the speed 6x
15058
+ let hex = '';
15059
+ for (let i = 0; i < bytes.length; i++) {
15060
+ hex += src_hexes[bytes[i]];
15061
+ }
15062
+ return hex;
15063
+ }
15064
+ // We use optimized technique to convert hex string to byte array
15065
+ const src_asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
15066
+ function src_asciiToBase16(ch) {
15067
+ if (ch >= src_asciis._0 && ch <= src_asciis._9)
15068
+ return ch - src_asciis._0; // '2' => 50-48
15069
+ if (ch >= src_asciis.A && ch <= src_asciis.F)
15070
+ return ch - (src_asciis.A - 10); // 'B' => 66-(65-10)
15071
+ if (ch >= src_asciis.a && ch <= src_asciis.f)
15072
+ return ch - (src_asciis.a - 10); // 'b' => 98-(97-10)
15073
+ return;
15074
+ }
15075
+ /**
15076
+ * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
15077
+ */
15078
+ function src_utils_hexToBytes(hex) {
15079
+ if (typeof hex !== 'string')
15080
+ throw new Error('hex string expected, got ' + typeof hex);
15081
+ const hl = hex.length;
15082
+ const al = hl / 2;
15083
+ if (hl % 2)
15084
+ throw new Error('padded hex string expected, got unpadded hex of length ' + hl);
15085
+ const array = new Uint8Array(al);
15086
+ for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
15087
+ const n1 = src_asciiToBase16(hex.charCodeAt(hi));
15088
+ const n2 = src_asciiToBase16(hex.charCodeAt(hi + 1));
15089
+ if (n1 === undefined || n2 === undefined) {
15090
+ const char = hex[hi] + hex[hi + 1];
15091
+ throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
15092
+ }
15093
+ array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163
15094
+ }
15095
+ return array;
15096
+ }
15097
+ // There is no setImmediate in browser and setTimeout is slow.
15098
+ // call of async fn will return Promise, which will be fullfiled only on
15099
+ // next scheduler queue processing step and this is exactly what we need.
15100
+ const src_nextTick = async () => { };
15101
+ // Returns control to thread each 'tick' ms to avoid blocking
15102
+ async function src_asyncLoop(iters, tick, cb) {
15103
+ let ts = Date.now();
15104
+ for (let i = 0; i < iters; i++) {
15105
+ cb(i);
15106
+ // Date.now() is not monotonic, so in case if clock goes backwards we return return control too
15107
+ const diff = Date.now() - ts;
15108
+ if (diff >= 0 && diff < tick)
15109
+ continue;
15110
+ await src_nextTick();
15111
+ ts += diff;
15112
+ }
15113
+ }
15114
+ /**
15115
+ * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
15116
+ */
15117
+ function src_utf8ToBytes(str) {
15118
+ if (typeof str !== 'string')
15119
+ throw new Error('utf8ToBytes expected string, got ' + typeof str);
15120
+ return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
15121
+ }
15122
+ /**
15123
+ * Normalizes (non-hex) string or Uint8Array to Uint8Array.
15124
+ * Warning: when Uint8Array is passed, it would NOT get copied.
15125
+ * Keep in mind for future mutable operations.
15126
+ */
15127
+ function src_utils_toBytes(data) {
15128
+ if (typeof data === 'string')
15129
+ data = src_utf8ToBytes(data);
15130
+ abytes(data);
15131
+ return data;
15132
+ }
15133
+ /**
15134
+ * Copies several Uint8Arrays into one.
15135
+ */
15136
+ function src_concatBytes(...arrays) {
15137
+ let sum = 0;
15138
+ for (let i = 0; i < arrays.length; i++) {
15139
+ const a = arrays[i];
15140
+ abytes(a);
15141
+ sum += a.length;
15142
+ }
15143
+ const res = new Uint8Array(sum);
15144
+ for (let i = 0, pad = 0; i < arrays.length; i++) {
15145
+ const a = arrays[i];
15146
+ res.set(a, pad);
15147
+ pad += a.length;
15148
+ }
15149
+ return res;
15150
+ }
15151
+ // For runtime check if class implements interface
15152
+ class src_Hash {
15153
+ // Safe version that clones internal state
15154
+ clone() {
15155
+ return this._cloneInto();
15156
+ }
15157
+ }
15158
+ function src_checkOpts(defaults, opts) {
15159
+ if (opts !== undefined && {}.toString.call(opts) !== '[object Object]')
15160
+ throw new Error('Options should be object or undefined');
15161
+ const merged = Object.assign(defaults, opts);
15162
+ return merged;
15163
+ }
15164
+ function src_wrapConstructor(hashCons) {
15165
+ const hashC = (msg) => hashCons().update(src_utils_toBytes(msg)).digest();
15166
+ const tmp = hashCons();
15167
+ hashC.outputLen = tmp.outputLen;
15168
+ hashC.blockLen = tmp.blockLen;
15169
+ hashC.create = () => hashCons();
15170
+ return hashC;
15171
+ }
15172
+ function src_wrapConstructorWithOpts(hashCons) {
15173
+ const hashC = (msg, opts) => hashCons(opts).update(src_utils_toBytes(msg)).digest();
15174
+ const tmp = hashCons({});
15175
+ hashC.outputLen = tmp.outputLen;
15176
+ hashC.blockLen = tmp.blockLen;
15177
+ hashC.create = (opts) => hashCons(opts);
15178
+ return hashC;
15179
+ }
15180
+ function src_wrapXOFConstructorWithOpts(hashCons) {
15181
+ const hashC = (msg, opts) => hashCons(opts).update(src_utils_toBytes(msg)).digest();
15182
+ const tmp = hashCons({});
15183
+ hashC.outputLen = tmp.outputLen;
15184
+ hashC.blockLen = tmp.blockLen;
15185
+ hashC.create = (opts) => hashCons(opts);
15186
+ return hashC;
15187
+ }
15188
+ /**
15189
+ * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS.
15190
+ */
15191
+ function src_randomBytes(bytesLength = 32) {
15192
+ if (crypto && typeof crypto.getRandomValues === 'function') {
15193
+ return crypto.getRandomValues(new Uint8Array(bytesLength));
15194
+ }
15195
+ // Legacy Node.js compatibility
15196
+ if (crypto && typeof crypto.randomBytes === 'function') {
15197
+ return crypto.randomBytes(bytesLength);
15198
+ }
15199
+ throw new Error('crypto.getRandomValues must be defined');
15200
+ }
15201
+ //# sourceMappingURL=utils.js.map
15202
+ ;// ../../node_modules/webauthn-p256/_esm/utils.js
15203
+
15204
+ function src_esm_utils_bytesToHex(bytes) {
15205
+ return `0x${src_utils_bytesToHex(bytes)}`;
15206
+ }
15207
+ function src_esm_utils_hexToBytes(value) {
15208
+ return src_utils_hexToBytes(value.slice(2));
15209
+ }
15210
+ function src_utils_base64UrlToBytes(base64Url) {
15211
+ const base64 = src_base64UrlToBase64(base64Url);
15212
+ const utf8 = src_base64ToUtf8(base64);
15213
+ return Uint8Array.from(utf8, (c) => c.charCodeAt(0));
15214
+ }
15215
+ function src_utils_bytesToBase64Url(bytes) {
15216
+ const base64 = src_utf8ToBase64(String.fromCharCode(...bytes));
15217
+ return src_base64ToBase64Url(base64);
15218
+ }
15219
+ function src_base64UrlToBase64(base64Url) {
15220
+ return base64Url.replaceAll('-', '+').replaceAll('_', '/');
15221
+ }
15222
+ function src_base64ToBase64Url(base64) {
15223
+ return base64.replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, '');
15224
+ }
15225
+ function src_base64ToUtf8(base64) {
15226
+ return atob(base64);
15227
+ }
15228
+ function src_utf8ToBase64(base64) {
15229
+ return btoa(base64);
15230
+ }
15231
+ async function src_utils_bytesToCryptoKey(bytes) {
15232
+ return await crypto.subtle.importKey('spki', bytes, {
15233
+ name: 'ECDSA',
15234
+ namedCurve: 'P-256',
15235
+ hash: 'SHA-256',
15236
+ }, true, ['verify']);
15237
+ }
15238
+ async function src_utils_cryptoKeyToBytes(key) {
15239
+ return new Uint8Array(await crypto.subtle.exportKey('raw', key));
15240
+ }
15241
+ //# sourceMappingURL=utils.js.map
15242
+ ;// ../../node_modules/webauthn-p256/_esm/publicKey.js
15243
+
15244
+
15245
+ /**
15246
+ * Parses a public key into x and y coordinates from the public key
15247
+ * defined on the credential.
15248
+ */
15249
+ async function src_parseCredentialPublicKey(cPublicKey) {
15250
+ const base64Url = bytesToBase64Url(new Uint8Array(cPublicKey));
15251
+ const bytes = base64UrlToBytes(base64Url);
15252
+ const cryptoKey = await bytesToCryptoKey(bytes);
15253
+ const publicKey = await cryptoKeyToBytes(cryptoKey);
15254
+ return src_parsePublicKey(publicKey);
15255
+ }
15256
+ /**
15257
+ * Parses a serialized public key into x and y coordinates.
15258
+ */
15259
+ function src_parsePublicKey(publicKey) {
15260
+ const bytes = typeof publicKey === 'string' ? src_esm_utils_hexToBytes(publicKey) : publicKey;
15261
+ const offset = bytes.length === 65 ? 1 : 0;
15262
+ const x = bytes.slice(offset, 32 + offset);
15263
+ const y = bytes.slice(32 + offset, 64 + offset);
15264
+ return {
15265
+ prefix: bytes.length === 65 ? bytes[0] : undefined,
15266
+ x: BigInt(src_esm_utils_bytesToHex(x)),
15267
+ y: BigInt(src_esm_utils_bytesToHex(y)),
15268
+ };
15269
+ }
15270
+ /**
15271
+ * Serializes a public key into a hex string or bytes.
15272
+ */
15273
+ function src_serializePublicKey(publicKey, options = {}) {
15274
+ const { compressed = false, to = 'hex' } = options;
15275
+ const result = Uint8Array.from([
15276
+ ...(publicKey.prefix && !compressed ? [publicKey.prefix] : []),
15277
+ ...numberToBytesBE(publicKey.x, 32),
15278
+ ...numberToBytesBE(publicKey.y, 32),
15279
+ ]);
15280
+ return (to === 'hex' ? bytesToHex(result) : result);
15281
+ }
15282
+ //# sourceMappingURL=publicKey.js.map
14922
15283
  ;// ../../node_modules/permissionless/_esm/actions/public/getSenderAddress.js
14923
15284
 
14924
15285
 
@@ -16177,6 +16538,129 @@ const src_getNonceKeyWithEncoding = (kernelVersion, validatorAddress, nonceKey =
16177
16538
  return BigInt(encoding);
16178
16539
  };
16179
16540
  //# sourceMappingURL=getNonceKey.js.map
16541
+ ;// ../../node_modules/permissionless/_esm/accounts/kernel/utils/isWebAuthnAccount.js
16542
+ const src_isWebAuthnAccount = (owner) => {
16543
+ return owner.type === "webAuthn";
16544
+ };
16545
+ //# sourceMappingURL=isWebAuthnAccount.js.map
16546
+ ;// ../../node_modules/webauthn-p256/_esm/sign.js
16547
+
16548
+
16549
+
16550
+ /**
16551
+ * Signs a hash using a stored credential. If no credential is provided,
16552
+ * a prompt will be displayed for the user to select an existing credential
16553
+ * that was previously registered.
16554
+ *
16555
+ * @example
16556
+ * ```ts
16557
+ * import { credential } from './credential'
16558
+ *
16559
+ * const signature = await sign({
16560
+ * credentialId: credential.id,
16561
+ * hash: '0x...',
16562
+ * })
16563
+ * ```
16564
+ */
16565
+ async function src_sign(parameters) {
16566
+ const { getFn = window.navigator.credentials.get.bind(window.navigator.credentials), ...rest } = parameters;
16567
+ const options = src_getCredentialSignRequestOptions(rest);
16568
+ try {
16569
+ const credential = (await getFn(options));
16570
+ if (!credential)
16571
+ throw new Error('credential request failed.');
16572
+ const response = credential.response;
16573
+ const clientDataJSON = String.fromCharCode(...new Uint8Array(response.clientDataJSON));
16574
+ const challengeIndex = clientDataJSON.indexOf('"challenge"');
16575
+ const typeIndex = clientDataJSON.indexOf('"type"');
16576
+ const signature = src_parseAsn1Signature(base64UrlToBytes(bytesToBase64Url(new Uint8Array(response.signature))));
16577
+ return {
16578
+ signature: src_serializeSignature(signature),
16579
+ webauthn: {
16580
+ authenticatorData: bytesToHex(new Uint8Array(response.authenticatorData)),
16581
+ clientDataJSON,
16582
+ challengeIndex,
16583
+ typeIndex,
16584
+ userVerificationRequired: options.publicKey.userVerification === 'required',
16585
+ },
16586
+ raw: credential,
16587
+ };
16588
+ }
16589
+ catch (error) {
16590
+ throw new Error('credential request failed.', { cause: error });
16591
+ }
16592
+ }
16593
+ /**
16594
+ * Returns the request options to sign a hash using a stored credential
16595
+ * with a P256 public key.
16596
+ *
16597
+ * @example
16598
+ * ```ts
16599
+ * const options = getCredentialSignRequestOptions({ hash: '0x...' })
16600
+ * const credentials = window.navigator.credentials.get(options)
16601
+ * ```
16602
+ */
16603
+ function src_getCredentialSignRequestOptions(parameters) {
16604
+ const { credentialId, hash, rpId = window.location.hostname, userVerification = 'required', } = parameters;
16605
+ const challenge = base64UrlToBytes(bytesToBase64Url(hexToBytes(hash)));
16606
+ return {
16607
+ publicKey: {
16608
+ ...(credentialId
16609
+ ? {
16610
+ allowCredentials: [
16611
+ {
16612
+ id: base64UrlToBytes(credentialId),
16613
+ type: 'public-key',
16614
+ },
16615
+ ],
16616
+ }
16617
+ : {}),
16618
+ challenge,
16619
+ rpId,
16620
+ userVerification,
16621
+ },
16622
+ };
16623
+ }
16624
+ /**
16625
+ * @internal
16626
+ * Parses an ASN.1 signature into a r and s value.
16627
+ */
16628
+ function src_parseAsn1Signature(bytes) {
16629
+ const r_start = bytes[4] === 0 ? 5 : 4;
16630
+ const r_end = r_start + 32;
16631
+ const s_start = bytes[r_end + 2] === 0 ? r_end + 3 : r_end + 2;
16632
+ const r = BigInt(bytesToHex(bytes.slice(r_start, r_end)));
16633
+ const s = BigInt(bytesToHex(bytes.slice(s_start)));
16634
+ const n = p256.CURVE.n;
16635
+ return {
16636
+ r,
16637
+ s: s > n / 2n ? n - s : s,
16638
+ };
16639
+ }
16640
+ /**
16641
+ * Parses a serialized signature into r and s values.
16642
+ */
16643
+ function src_parseSignature(signature) {
16644
+ const bytes = typeof signature === 'string' ? src_esm_utils_hexToBytes(signature) : signature;
16645
+ const r = bytes.slice(0, 32);
16646
+ const s = bytes.slice(32, 64);
16647
+ return {
16648
+ r: BigInt(src_esm_utils_bytesToHex(r)),
16649
+ s: BigInt(src_esm_utils_bytesToHex(s)),
16650
+ };
16651
+ }
16652
+ /**
16653
+ * Serializes a signature into a hex string or bytes.
16654
+ */
16655
+ function src_serializeSignature(signature, options = {}) {
16656
+ const { to = 'hex' } = options;
16657
+ const result = new Uint8Array([
16658
+ ...numberToBytesBE(signature.r, 32),
16659
+ ...numberToBytesBE(signature.s, 32),
16660
+ ]);
16661
+ return (to === 'hex' ? bytesToHex(result) : result);
16662
+ }
16663
+ //# sourceMappingURL=sign.js.map
16180
16664
  ;// ../../node_modules/permissionless/_esm/accounts/kernel/utils/wrapMessageHash.js
16181
16665
 
16182
16666
 
@@ -16201,7 +16685,55 @@ const src_wrapMessageHash = (messageHash, { accountAddress, kernelVersion, chain
16201
16685
 
16202
16686
 
16203
16687
 
16688
+
16689
+
16204
16690
  async function src_signMessage_signMessage({ message, owner, accountAddress, kernelVersion: accountVersion, chainId }) {
16691
+ if (src_isWebAuthnAccount(owner)) {
16692
+ let messageContent;
16693
+ if (typeof message === "string") {
16694
+ // message is a string
16695
+ messageContent = src_wrapMessageHash((0,src_external_viem_namespaceObject.hashMessage)(message), {
16696
+ kernelVersion: accountVersion,
16697
+ accountAddress,
16698
+ chainId
16699
+ // chainId: client.chain
16700
+ // ? client.chain.id
16701
+ // : await client.extend(publicActions).getChainId()
16702
+ });
16703
+ }
16704
+ else if ("raw" in message && typeof message.raw === "string") {
16705
+ // message.raw is a Hex string
16706
+ messageContent = message.raw;
16707
+ }
16708
+ else if ("raw" in message && message.raw instanceof Uint8Array) {
16709
+ // message.raw is a ByteArray
16710
+ messageContent = message.raw.toString();
16711
+ }
16712
+ else {
16713
+ throw new Error("Unsupported message format");
16714
+ }
16715
+ const { signature: signatureData, webauthn } = await owner.sign({
16716
+ hash: messageContent
16717
+ });
16718
+ const signature = src_parseSignature(signatureData);
16719
+ // encode signature
16720
+ const encodedSignature = (0,src_external_viem_namespaceObject.encodeAbiParameters)([
16721
+ { name: "authenticatorData", type: "bytes" },
16722
+ { name: "clientDataJSON", type: "string" },
16723
+ { name: "responseTypeLocation", type: "uint256" },
16724
+ { name: "r", type: "uint256" },
16725
+ { name: "s", type: "uint256" },
16726
+ { name: "usePrecompiled", type: "bool" }
16727
+ ], [
16728
+ webauthn.authenticatorData,
16729
+ webauthn.clientDataJSON,
16730
+ BigInt(webauthn.typeIndex),
16731
+ BigInt(signature.r),
16732
+ BigInt(signature.s),
16733
+ false // TODO: check if it is a RIP 7212 supported network
16734
+ ]);
16735
+ return encodedSignature;
16736
+ }
16205
16737
  if (accountVersion === "0.2.1" || accountVersion === "0.2.2") {
16206
16738
  return owner.signMessage({
16207
16739
  message
@@ -16223,9 +16755,12 @@ async function src_signMessage_signMessage({ message, owner, accountAddress, ker
16223
16755
  ;// ../../node_modules/permissionless/_esm/accounts/kernel/utils/signTypedData.js
16224
16756
 
16225
16757
 
16758
+
16759
+
16226
16760
  async function src_signTypedData_signTypedData(parameters) {
16227
16761
  const { owner, accountAddress, kernelVersion: accountVersion, chainId, ...typedData } = parameters;
16228
- if (accountVersion === "0.2.1" || accountVersion === "0.2.2") {
16762
+ if ((accountVersion === "0.2.1" || accountVersion === "0.2.2") &&
16763
+ !src_isWebAuthnAccount(owner)) {
16229
16764
  return owner.signTypedData({
16230
16765
  ...typedData
16231
16766
  });
@@ -16251,12 +16786,23 @@ async function src_signTypedData_signTypedData(parameters) {
16251
16786
  accountAddress,
16252
16787
  chainId: chainId
16253
16788
  });
16789
+ if (src_isWebAuthnAccount(owner)) {
16790
+ return src_signMessage_signMessage({
16791
+ message: { raw: wrappedMessageHash },
16792
+ owner,
16793
+ accountAddress,
16794
+ kernelVersion: accountVersion,
16795
+ chainId
16796
+ });
16797
+ }
16254
16798
  return owner.signMessage({
16255
16799
  message: { raw: wrappedMessageHash }
16256
16800
  });
16257
16801
  }
16258
16802
  //# sourceMappingURL=signTypedData.js.map
16259
- ;// ../../node_modules/permissionless/_esm/accounts/kernel/toEcdsaKernelSmartAccount.js
16803
+ ;// ../../node_modules/permissionless/_esm/accounts/kernel/toKernelSmartAccount.js
16804
+
16805
+
16260
16806
 
16261
16807
 
16262
16808
 
@@ -16335,13 +16881,15 @@ const src_KERNEL_VERSION_TO_ADDRESSES_MAP = {
16335
16881
  ECDSA_VALIDATOR: "0x8104e3Ad430EA6d354d013A6789fDFc71E671c43",
16336
16882
  ACCOUNT_LOGIC: "0x94F097E1ebEB4ecA3AAE54cabb08905B239A7D27",
16337
16883
  FACTORY_ADDRESS: "0x6723b44Abeec4E71eBE3232BD5B455805baDD22f",
16338
- META_FACTORY_ADDRESS: "0xd703aaE79538628d27099B8c4f621bE4CCd142d5"
16884
+ META_FACTORY_ADDRESS: "0xd703aaE79538628d27099B8c4f621bE4CCd142d5",
16885
+ WEB_AUTHN_VALIDATOR: "0xbA45a2BFb8De3D24cA9D7F1B551E14dFF5d690Fd"
16339
16886
  },
16340
16887
  "0.3.1": {
16341
16888
  ECDSA_VALIDATOR: "0x845ADb2C711129d4f3966735eD98a9F09fC4cE57",
16342
16889
  ACCOUNT_LOGIC: "0xBAC849bB641841b44E965fB01A4Bf5F074f84b4D",
16343
16890
  FACTORY_ADDRESS: "0xaac5D4240AF87249B3f71BC8E4A2cae074A3E419",
16344
- META_FACTORY_ADDRESS: "0xd703aaE79538628d27099B8c4f621bE4CCd142d5"
16891
+ META_FACTORY_ADDRESS: "0xd703aaE79538628d27099B8c4f621bE4CCd142d5",
16892
+ WEB_AUTHN_VALIDATOR: "0xbA45a2BFb8De3D24cA9D7F1B551E14dFF5d690Fd"
16345
16893
  }
16346
16894
  };
16347
16895
  /**
@@ -16362,14 +16910,15 @@ const src_getDefaultKernelVersion = (entryPointVersion, version) => {
16362
16910
  * @param factoryAddress
16363
16911
  * @param metaFactoryAddress
16364
16912
  */
16365
- const src_getDefaultAddresses = ({ ecdsaValidatorAddress: _ecdsaValidatorAddress, accountLogicAddress: _accountLogicAddress, factoryAddress: _factoryAddress, metaFactoryAddress: _metaFactoryAddress, kernelVersion }) => {
16913
+ const src_getDefaultAddresses = ({ validatorAddress: _validatorAddress, accountLogicAddress: _accountLogicAddress, factoryAddress: _factoryAddress, metaFactoryAddress: _metaFactoryAddress, kernelVersion, isWebAuthn }) => {
16366
16914
  const addresses = src_KERNEL_VERSION_TO_ADDRESSES_MAP[kernelVersion];
16367
- const ecdsaValidatorAddress = _ecdsaValidatorAddress ?? addresses.ECDSA_VALIDATOR;
16915
+ const validatorAddress = _validatorAddress ??
16916
+ (isWebAuthn ? addresses.WEB_AUTHN_VALIDATOR : addresses.ECDSA_VALIDATOR);
16368
16917
  const accountLogicAddress = _accountLogicAddress ?? addresses.ACCOUNT_LOGIC;
16369
16918
  const factoryAddress = _factoryAddress ?? addresses.FACTORY_ADDRESS;
16370
16919
  const metaFactoryAddress = _metaFactoryAddress ?? addresses?.META_FACTORY_ADDRESS ?? src_external_viem_namespaceObject.zeroAddress; // Meta Factory doesn't exists for Kernel v2.2
16371
16920
  return {
16372
- ecdsaValidatorAddress,
16921
+ validatorAddress,
16373
16922
  accountLogicAddress,
16374
16923
  factoryAddress,
16375
16924
  metaFactoryAddress
@@ -16384,12 +16933,12 @@ const src_getEcdsaRootIdentifierForKernelV3 = (validatorAddress) => {
16384
16933
  * @param owner
16385
16934
  * @param ecdsaValidatorAddress
16386
16935
  */
16387
- const src_getInitializationData = ({ entryPoint: { version: entryPointVersion }, kernelVersion, owner, ecdsaValidatorAddress }) => {
16936
+ const src_getInitializationData = ({ entryPoint: { version: entryPointVersion }, kernelVersion, validatorData, validatorAddress }) => {
16388
16937
  if (entryPointVersion === "0.6") {
16389
16938
  return (0,src_external_viem_namespaceObject.encodeFunctionData)({
16390
16939
  abi: src_KernelInitAbi,
16391
16940
  functionName: "initialize",
16392
- args: [ecdsaValidatorAddress, owner]
16941
+ args: [validatorAddress, validatorData]
16393
16942
  });
16394
16943
  }
16395
16944
  if (kernelVersion === "0.3.0-beta") {
@@ -16397,9 +16946,9 @@ const src_getInitializationData = ({ entryPoint: { version: entryPointVersion },
16397
16946
  abi: src_KernelV3InitAbi,
16398
16947
  functionName: "initialize",
16399
16948
  args: [
16400
- src_getEcdsaRootIdentifierForKernelV3(ecdsaValidatorAddress),
16949
+ src_getEcdsaRootIdentifierForKernelV3(validatorAddress),
16401
16950
  src_external_viem_namespaceObject.zeroAddress,
16402
- owner,
16951
+ validatorData,
16403
16952
  "0x"
16404
16953
  ]
16405
16954
  });
@@ -16408,14 +16957,44 @@ const src_getInitializationData = ({ entryPoint: { version: entryPointVersion },
16408
16957
  abi: src_KernelV3_1AccountAbi,
16409
16958
  functionName: "initialize",
16410
16959
  args: [
16411
- src_getEcdsaRootIdentifierForKernelV3(ecdsaValidatorAddress),
16960
+ src_getEcdsaRootIdentifierForKernelV3(validatorAddress),
16412
16961
  src_external_viem_namespaceObject.zeroAddress,
16413
- owner,
16962
+ validatorData,
16414
16963
  "0x",
16415
16964
  []
16416
16965
  ]
16417
16966
  });
16418
16967
  };
16968
+ const src_getValidatorData = async (owner) => {
16969
+ if (owner.type === "local") {
16970
+ return owner.address;
16971
+ }
16972
+ if (src_isWebAuthnAccount(owner)) {
16973
+ const parsedPublicKey = src_parsePublicKey(owner.publicKey);
16974
+ const authenticatorIdHash = (0,src_external_viem_namespaceObject.keccak256)(src_esm_utils_bytesToHex(src_utils_base64UrlToBytes(owner.id)));
16975
+ return (0,src_external_viem_namespaceObject.encodeAbiParameters)([
16976
+ {
16977
+ components: [
16978
+ { name: "x", type: "uint256" },
16979
+ { name: "y", type: "uint256" }
16980
+ ],
16981
+ name: "webAuthnData",
16982
+ type: "tuple"
16983
+ },
16984
+ {
16985
+ name: "authenticatorIdHash",
16986
+ type: "bytes32"
16987
+ }
16988
+ ], [
16989
+ {
16990
+ x: parsedPublicKey.x,
16991
+ y: parsedPublicKey.y
16992
+ },
16993
+ authenticatorIdHash
16994
+ ]);
16995
+ }
16996
+ throw new Error("Invalid owner type");
16997
+ };
16419
16998
  /**
16420
16999
  * Get the account initialization code for a kernel smart account
16421
17000
  * @param entryPoint
@@ -16425,13 +17004,13 @@ const src_getInitializationData = ({ entryPoint: { version: entryPointVersion },
16425
17004
  * @param accountLogicAddress
16426
17005
  * @param ecdsaValidatorAddress
16427
17006
  */
16428
- const src_toEcdsaKernelSmartAccount_getAccountInitCode = async ({ entryPointVersion, kernelVersion, owner, index, factoryAddress, accountLogicAddress, ecdsaValidatorAddress }) => {
17007
+ const src_toKernelSmartAccount_getAccountInitCode = async ({ entryPointVersion, kernelVersion, validatorData, index, factoryAddress, accountLogicAddress, validatorAddress }) => {
16429
17008
  // Build the account initialization data
16430
17009
  const initializationData = src_getInitializationData({
16431
17010
  entryPoint: { version: entryPointVersion },
16432
17011
  kernelVersion,
16433
- ecdsaValidatorAddress,
16434
- owner
17012
+ validatorAddress,
17013
+ validatorData
16435
17014
  });
16436
17015
  // Build the account init code
16437
17016
  if (entryPointVersion === "0.6") {
@@ -16448,18 +17027,23 @@ const src_toEcdsaKernelSmartAccount_getAccountInitCode = async ({ entryPointVers
16448
17027
  });
16449
17028
  };
16450
17029
  /**
16451
- * Build a kernel smart account from a private key, that use the ECDSA signer behind the scene
17030
+ * Build a kernel smart account from a private key, that use the ECDSA or passkeys signer behind the scene
16452
17031
  * @param client
16453
17032
  * @param privateKey
16454
17033
  * @param entryPoint
16455
17034
  * @param index
16456
17035
  * @param factoryAddress
16457
17036
  * @param accountLogicAddress
16458
- * @param ecdsaValidatorAddress
17037
+ * @param validatorAddress
16459
17038
  */
16460
- async function src_toEcdsaKernelSmartAccount(parameters) {
16461
- const { client, address, index = 0n, owners, version, ecdsaValidatorAddress: _ecdsaValidatorAddress, factoryAddress: _factoryAddress, metaFactoryAddress: _metaFactoryAddress, accountLogicAddress: _accountLogicAddress } = parameters;
16462
- const localOwner = await src_toOwner({ owner: owners[0] });
17039
+ async function src_toKernelSmartAccount(parameters) {
17040
+ const { client, address, index = 0n, owners, version, validatorAddress: _validatorAddress, factoryAddress: _factoryAddress, metaFactoryAddress: _metaFactoryAddress, accountLogicAddress: _accountLogicAddress } = parameters;
17041
+ const isWebAuthn = owners[0].type === "webAuthn";
17042
+ const owner = isWebAuthn
17043
+ ? owners[0]
17044
+ : await src_toOwner({
17045
+ owner: owners[0]
17046
+ });
16463
17047
  const entryPoint = {
16464
17048
  address: parameters.entryPoint?.address ?? src_entryPoint07Address,
16465
17049
  abi: (parameters.entryPoint?.version ?? "0.7") === "0.6"
@@ -16468,22 +17052,26 @@ async function src_toEcdsaKernelSmartAccount(parameters) {
16468
17052
  version: parameters.entryPoint?.version ?? "0.7"
16469
17053
  };
16470
17054
  const kernelVersion = src_getDefaultKernelVersion(entryPoint.version, version);
16471
- const { accountLogicAddress, ecdsaValidatorAddress, factoryAddress, metaFactoryAddress } = src_getDefaultAddresses({
16472
- ecdsaValidatorAddress: _ecdsaValidatorAddress,
17055
+ const { accountLogicAddress, validatorAddress, factoryAddress, metaFactoryAddress } = src_getDefaultAddresses({
17056
+ validatorAddress: _validatorAddress,
16473
17057
  accountLogicAddress: _accountLogicAddress,
16474
17058
  factoryAddress: _factoryAddress,
16475
17059
  metaFactoryAddress: _metaFactoryAddress,
16476
- kernelVersion
17060
+ kernelVersion,
17061
+ isWebAuthn
16477
17062
  });
17063
+ if (!validatorAddress) {
17064
+ throw new Error("Validator address is required");
17065
+ }
16478
17066
  // Helper to generate the init code for the smart account
16479
- const generateInitCode = () => src_toEcdsaKernelSmartAccount_getAccountInitCode({
17067
+ const generateInitCode = async () => src_toKernelSmartAccount_getAccountInitCode({
16480
17068
  entryPointVersion: entryPoint.version,
16481
17069
  kernelVersion,
16482
- owner: localOwner.address,
17070
+ validatorData: await src_getValidatorData(owner),
16483
17071
  index,
16484
17072
  factoryAddress,
16485
17073
  accountLogicAddress,
16486
- ecdsaValidatorAddress
17074
+ validatorAddress
16487
17075
  });
16488
17076
  let accountAddress = address;
16489
17077
  let chainId;
@@ -16526,7 +17114,7 @@ async function src_toEcdsaKernelSmartAccount(parameters) {
16526
17114
  return src_getAccountNonce(client, {
16527
17115
  address: await this.getAddress(),
16528
17116
  entryPointAddress: entryPoint.address,
16529
- key: src_getNonceKeyWithEncoding(kernelVersion, ecdsaValidatorAddress,
17117
+ key: src_getNonceKeyWithEncoding(kernelVersion, validatorAddress,
16530
17118
  /*args?.key ?? */ parameters.nonceKey ?? 0n)
16531
17119
  });
16532
17120
  },
@@ -16534,6 +17122,23 @@ async function src_toEcdsaKernelSmartAccount(parameters) {
16534
17122
  if (src_isKernelV2(kernelVersion)) {
16535
17123
  return (0,src_external_viem_namespaceObject.concatHex)([src_ROOT_MODE_KERNEL_V2, src_DUMMY_ECDSA_SIGNATURE]);
16536
17124
  }
17125
+ if (src_isWebAuthnAccount(owner)) {
17126
+ return (0,src_external_viem_namespaceObject.encodeAbiParameters)([
17127
+ { name: "authenticatorData", type: "bytes" },
17128
+ { name: "clientDataJSON", type: "string" },
17129
+ { name: "responseTypeLocation", type: "uint256" },
17130
+ { name: "r", type: "uint256" },
17131
+ { name: "s", type: "uint256" },
17132
+ { name: "usePrecompiled", type: "bool" }
17133
+ ], [
17134
+ "0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d00000000",
17135
+ '{"type":"webauthn.get","challenge":"tbxXNFS9X_4Byr1cMwqKrIGB-_30a0QhZ6y7ucM0BOE","origin":"http://localhost:3000","crossOrigin":false, "other_keys_can_be_added_here":"do not compare clientDataJSON against a template. See https://goo.gl/yabPex"}',
17136
+ 1n,
17137
+ 44941127272049826721201904734628716258498742255959991581049806490182030242267n,
17138
+ 9910254599581058084911561569808925251374718953855182016200087235935345969636n,
17139
+ false
17140
+ ]);
17141
+ }
16537
17142
  return src_DUMMY_ECDSA_SIGNATURE;
16538
17143
  },
16539
17144
  async sign({ hash }) {
@@ -16541,7 +17146,7 @@ async function src_toEcdsaKernelSmartAccount(parameters) {
16541
17146
  },
16542
17147
  async signMessage({ message }) {
16543
17148
  const signature = await src_signMessage_signMessage({
16544
- owner: localOwner,
17149
+ owner,
16545
17150
  message,
16546
17151
  accountAddress: await this.getAddress(),
16547
17152
  kernelVersion,
@@ -16551,13 +17156,13 @@ async function src_toEcdsaKernelSmartAccount(parameters) {
16551
17156
  return signature;
16552
17157
  }
16553
17158
  return (0,src_external_viem_namespaceObject.concatHex)([
16554
- src_getEcdsaRootIdentifierForKernelV3(ecdsaValidatorAddress),
17159
+ src_getEcdsaRootIdentifierForKernelV3(validatorAddress),
16555
17160
  signature
16556
17161
  ]);
16557
17162
  },
16558
17163
  async signTypedData(typedData) {
16559
17164
  const signature = await src_signTypedData_signTypedData({
16560
- owner: localOwner,
17165
+ owner: owner,
16561
17166
  chainId: await getMemoizedChainId(),
16562
17167
  ...typedData,
16563
17168
  accountAddress: await this.getAddress(),
@@ -16567,7 +17172,7 @@ async function src_toEcdsaKernelSmartAccount(parameters) {
16567
17172
  return signature;
16568
17173
  }
16569
17174
  return (0,src_external_viem_namespaceObject.concatHex)([
16570
- src_getEcdsaRootIdentifierForKernelV3(ecdsaValidatorAddress),
17175
+ src_getEcdsaRootIdentifierForKernelV3(validatorAddress),
16571
17176
  signature
16572
17177
  ]);
16573
17178
  },
@@ -16584,9 +17189,17 @@ async function src_toEcdsaKernelSmartAccount(parameters) {
16584
17189
  entryPointVersion: entryPoint.version,
16585
17190
  chainId: chainId
16586
17191
  });
16587
- const signature = await localOwner.signMessage({
16588
- message: { raw: hash }
16589
- });
17192
+ const signature = src_isWebAuthnAccount(owner)
17193
+ ? await src_signMessage_signMessage({
17194
+ owner,
17195
+ message: { raw: hash },
17196
+ chainId,
17197
+ accountAddress: await this.getAddress(),
17198
+ kernelVersion
17199
+ })
17200
+ : await owner.signMessage({
17201
+ message: { raw: hash }
17202
+ });
16590
17203
  // Always use the sudo mode, since we will use external paymaster
16591
17204
  if (src_isKernelV2(kernelVersion)) {
16592
17205
  return (0,src_external_viem_namespaceObject.concatHex)(["0x00000000", signature]);
@@ -16595,6 +17208,19 @@ async function src_toEcdsaKernelSmartAccount(parameters) {
16595
17208
  }
16596
17209
  });
16597
17210
  }
17211
+ //# sourceMappingURL=toKernelSmartAccount.js.map
17212
+ ;// ../../node_modules/permissionless/_esm/accounts/kernel/toEcdsaKernelSmartAccount.js
17213
+
17214
+ /**
17215
+ * @deprecated ECDSA Kernel Smart Account is deprecated. Please use toKernelSmartAccount instead.
17216
+ * @see toKernelSmartAccount
17217
+ */
17218
+ async function src_toEcdsaKernelSmartAccount(parameters) {
17219
+ return src_toKernelSmartAccount({
17220
+ ...parameters,
17221
+ validatorAddress: parameters.validatorAddress ?? parameters.ecdsaValidatorAddress
17222
+ });
17223
+ }
16598
17224
  //# sourceMappingURL=toEcdsaKernelSmartAccount.js.map
16599
17225
  ;// ./src/AccountAbstraction/smartAccounts/KernelSmartAccount.ts
16600
17226