@aastar/sdk 0.20.5 → 0.20.7

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 (89) hide show
  1. package/dist/BaseClient-BjbYP0cf.d.ts +88 -0
  2. package/dist/UserClient-AIIHB54I.js +6 -0
  3. package/dist/{UserClient-UYIHF6UJ.js.map → UserClient-AIIHB54I.js.map} +1 -1
  4. package/dist/account.d.ts +48 -1
  5. package/dist/account.js +3 -3
  6. package/dist/admin.d.ts +62 -1
  7. package/dist/admin.js +3 -3
  8. package/dist/airaccount.d.ts +4 -2
  9. package/dist/airaccount.js +2 -2
  10. package/dist/channel-CkRRbzT8.d.ts +77 -0
  11. package/dist/channel.d.ts +64 -1
  12. package/dist/channel.js +3 -3
  13. package/dist/{chunk-FBDMID2J.js → chunk-4EZD7LPE.js} +30 -24
  14. package/dist/chunk-4EZD7LPE.js.map +1 -0
  15. package/dist/{chunk-TIH7D4FQ.js → chunk-6QYXGMCR.js} +513 -322
  16. package/dist/chunk-6QYXGMCR.js.map +1 -0
  17. package/dist/{chunk-6UHVUGDT.js → chunk-7ARJ3OSU.js} +29 -21
  18. package/dist/chunk-7ARJ3OSU.js.map +1 -0
  19. package/dist/{chunk-VYU6P7HB.js → chunk-BN5WY5GM.js} +16 -14
  20. package/dist/chunk-BN5WY5GM.js.map +1 -0
  21. package/dist/{chunk-ZFIKBDBT.js → chunk-FJ7XECC5.js} +4 -4
  22. package/dist/chunk-FJ7XECC5.js.map +1 -0
  23. package/dist/{chunk-NRH56SAJ.js → chunk-G3UJC4EL.js} +6 -7
  24. package/dist/chunk-G3UJC4EL.js.map +1 -0
  25. package/dist/{chunk-QJT4IOIS.js → chunk-KDH3UPKD.js} +10 -13
  26. package/dist/chunk-KDH3UPKD.js.map +1 -0
  27. package/dist/{chunk-ZGOEADCO.js → chunk-LXWIPTPX.js} +5 -5
  28. package/dist/chunk-LXWIPTPX.js.map +1 -0
  29. package/dist/{chunk-I3VRFZA4.js → chunk-MVEWJIPY.js} +124 -110
  30. package/dist/chunk-MVEWJIPY.js.map +1 -0
  31. package/dist/{chunk-FIS3RUGL.js → chunk-PAABYXS6.js} +33 -40
  32. package/dist/chunk-PAABYXS6.js.map +1 -0
  33. package/dist/{chunk-HNTLDUL7.js → chunk-PKCHRXFR.js} +8 -12
  34. package/dist/chunk-PKCHRXFR.js.map +1 -0
  35. package/dist/{chunk-42KVVOOU.js → chunk-TENYCMJ3.js} +31 -31
  36. package/dist/chunk-TENYCMJ3.js.map +1 -0
  37. package/dist/{chunk-WPSWFZKF.js → chunk-UIFMIVDK.js} +1033 -937
  38. package/dist/chunk-UIFMIVDK.js.map +1 -0
  39. package/dist/{chunk-4KRQXOTI.js → chunk-X3AMH53O.js} +248 -195
  40. package/dist/chunk-X3AMH53O.js.map +1 -0
  41. package/dist/{contract-addresses-ADEWLDHE.js → contract-addresses-N3TOL2WL.js} +3 -3
  42. package/dist/{contract-addresses-ADEWLDHE.js.map → contract-addresses-N3TOL2WL.js.map} +1 -1
  43. package/dist/core.d.ts +6930 -13
  44. package/dist/core.js +2 -2
  45. package/dist/dapp.d.ts +127 -1
  46. package/dist/dapp.js +12 -13
  47. package/dist/dapp.js.map +1 -1
  48. package/dist/doc-types-471vSmPO.d.ts +16 -0
  49. package/dist/enduser.d.ts +261 -1
  50. package/dist/enduser.js +4 -4
  51. package/dist/identity.d.ts +81 -1
  52. package/dist/identity.js +3 -3
  53. package/dist/index-B6SfEQxo.d.ts +47 -0
  54. package/dist/index.d.ts +59 -15
  55. package/dist/index.js +18 -18
  56. package/dist/index.js.map +1 -1
  57. package/dist/kms.d.ts +3054 -2
  58. package/dist/kms.js +2 -2
  59. package/dist/operator.d.ts +164 -1
  60. package/dist/operator.js +3 -3
  61. package/dist/paymaster.d.ts +312 -1
  62. package/dist/paymaster.js +3 -3
  63. package/dist/{index.node-KIKM4EG6.js → src-L5SI5WNB.js} +4 -4
  64. package/dist/src-L5SI5WNB.js.map +1 -0
  65. package/dist/{dist-GVWCRI4F.js → src-X5MIV3EB.js} +5 -5
  66. package/dist/src-X5MIV3EB.js.map +1 -0
  67. package/dist/tier-router-DeeVg69O.d.ts +370 -0
  68. package/dist/tokens.d.ts +64 -1
  69. package/dist/tokens.js +3 -3
  70. package/dist/x402.d.ts +373 -1
  71. package/dist/x402.js +3 -3
  72. package/package.json +1 -2
  73. package/dist/UserClient-UYIHF6UJ.js +0 -6
  74. package/dist/chunk-42KVVOOU.js.map +0 -1
  75. package/dist/chunk-4KRQXOTI.js.map +0 -1
  76. package/dist/chunk-6UHVUGDT.js.map +0 -1
  77. package/dist/chunk-FBDMID2J.js.map +0 -1
  78. package/dist/chunk-FIS3RUGL.js.map +0 -1
  79. package/dist/chunk-HNTLDUL7.js.map +0 -1
  80. package/dist/chunk-I3VRFZA4.js.map +0 -1
  81. package/dist/chunk-NRH56SAJ.js.map +0 -1
  82. package/dist/chunk-QJT4IOIS.js.map +0 -1
  83. package/dist/chunk-TIH7D4FQ.js.map +0 -1
  84. package/dist/chunk-VYU6P7HB.js.map +0 -1
  85. package/dist/chunk-WPSWFZKF.js.map +0 -1
  86. package/dist/chunk-ZFIKBDBT.js.map +0 -1
  87. package/dist/chunk-ZGOEADCO.js.map +0 -1
  88. package/dist/dist-GVWCRI4F.js.map +0 -1
  89. package/dist/index.node-KIKM4EG6.js.map +0 -1
@@ -1,22 +1,10 @@
1
- import { ecdsa, bls12_381, weierstrass, sha256 } from './chunk-4KRQXOTI.js';
2
- import { ethers } from 'ethers';
1
+ import { selectorFromId, keccak256, solidityPacked, ERC4337Utils, BLSManager, resolveTier, algIdForTier, encodeAbiParams, ecdsa, ALG_CUMULATIVE_T3, ALG_CUMULATIVE_T2, ALG_P256, ALG_ECDSA, ALG_BLS, weierstrass, sha256 } from './chunk-X3AMH53O.js';
2
+ import { parseAbi, createPublicClient, http, getContract, formatEther, parseUnits, parseEther, encodeFunctionData, concat, numberToHex, zeroAddress, hexToBytes, formatUnits, hashMessage as hashMessage$1, toRlp, keccak256 as keccak256$1, concatHex, recoverAddress as recoverAddress$1 } from 'viem';
3
3
  import axios from 'axios';
4
4
  import { createHash } from 'crypto';
5
+ import { privateKeyToAccount } from 'viem/accounts';
5
6
 
6
- // ../../node_modules/.pnpm/@noble+curves@2.0.1/node_modules/@noble/curves/nist.js
7
- var p256_CURVE = /* @__PURE__ */ (() => ({
8
- p: BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),
9
- n: BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),
10
- h: BigInt(1),
11
- a: BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),
12
- b: BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),
13
- Gx: BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),
14
- Gy: BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")
15
- }))();
16
- var p256_Point = /* @__PURE__ */ weierstrass(p256_CURVE);
17
- var p256 = /* @__PURE__ */ ecdsa(p256_Point, sha256);
18
-
19
- // ../airaccount/dist/server/index.js
7
+ // ../airaccount/src/server/constants/entrypoint.ts
20
8
  var EntryPointVersion = /* @__PURE__ */ ((EntryPointVersion2) => {
21
9
  EntryPointVersion2["V0_6"] = "0.6";
22
10
  EntryPointVersion2["V0_7"] = "0.7";
@@ -24,26 +12,17 @@ var EntryPointVersion = /* @__PURE__ */ ((EntryPointVersion2) => {
24
12
  return EntryPointVersion2;
25
13
  })(EntryPointVersion || {});
26
14
  var ENTRYPOINT_ADDRESSES = {
27
- [
28
- "0.6"
29
- /* V0_6 */
30
- ]: {
15
+ ["0.6" /* V0_6 */]: {
31
16
  sepolia: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
32
17
  mainnet: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
33
18
  optimism: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
34
19
  },
35
- [
36
- "0.7"
37
- /* V0_7 */
38
- ]: {
20
+ ["0.7" /* V0_7 */]: {
39
21
  sepolia: "0x0000000071727De22E5E9d8BAf0edAc6f37da032",
40
22
  mainnet: "0x0000000071727De22E5E9d8BAf0edAc6f37da032",
41
23
  optimism: "0x0000000071727De22E5E9d8BAf0edAc6f37da032"
42
24
  },
43
- [
44
- "0.8"
45
- /* V0_8 */
46
- ]: {
25
+ ["0.8" /* V0_8 */]: {
47
26
  sepolia: "0x0576a174D229E3cFA37253523E645A78A0C91B57",
48
27
  mainnet: "0x0576a174D229E3cFA37253523E645A78A0C91B57",
49
28
  optimism: "0x0576a174D229E3cFA37253523E645A78A0C91B57"
@@ -161,7 +140,9 @@ var AIRACCOUNT_ABI = [
161
140
  "function guardians(uint256 index) external view returns (address)",
162
141
  "function p256KeyX() external view returns (bytes32)",
163
142
  "function p256KeyY() external view returns (bytes32)",
164
- "function getConfigDescription() external view returns (tuple(address accountOwner, address guardAddress, uint256 dailyLimit, uint256 dailyRemaining, uint256 tier1Limit, uint256 tier2Limit, address[3] guardianAddresses, uint8 guardianCount, bool hasP256Key, bool hasValidator, bool hasAggregator, bool hasActiveRecovery))",
143
+ // abitype/viem human-readable ABIs use a bare parenthesised tuple `(...)`, not the
144
+ // ethers-style `tuple(...)` keyword (which parseAbi rejects with "Invalid ABI parameter").
145
+ "function getConfigDescription() external view returns ((address accountOwner, address guardAddress, uint256 dailyLimit, uint256 dailyRemaining, uint256 tier1Limit, uint256 tier2Limit, address[3] guardianAddresses, uint8 guardianCount, bool hasP256Key, bool hasValidator, bool hasAggregator, bool hasActiveRecovery))",
165
146
  // ── Owner / key management ──
166
147
  "function setValidator(address _validator) external",
167
148
  "function setP256Key(bytes32 _x, bytes32 _y) external",
@@ -386,13 +367,12 @@ var AIR_ACCOUNT_DELEGATE_ABI = [
386
367
  "event RescueExecuted(address indexed eoa, address rescueTo, uint256 ethAmount)",
387
368
  "event RescueCancelled(address indexed eoa)"
388
369
  ];
370
+
371
+ // ../airaccount/src/server/config.ts
389
372
  function sepoliaV07Config(version = "M7") {
390
373
  const factoryAddress = version === "M5" ? AIRACCOUNT_ADDRESSES.sepolia.factoryM5 : version === "M7r6" ? AIRACCOUNT_ADDRESSES.sepolia.factoryM7r6 : AIRACCOUNT_ADDRESSES.sepolia.factory;
391
374
  return {
392
- entryPointAddress: ENTRYPOINT_ADDRESSES[
393
- "0.7"
394
- /* V0_7 */
395
- ].sepolia,
375
+ entryPointAddress: ENTRYPOINT_ADDRESSES["0.7" /* V0_7 */].sepolia,
396
376
  factoryAddress,
397
377
  validatorAddress: AIRACCOUNT_ADDRESSES.sepolia.validatorRouter
398
378
  };
@@ -431,6 +411,8 @@ function validateConfig(config) {
431
411
  throw new Error("ServerConfig: signer adapter is required");
432
412
  }
433
413
  }
414
+
415
+ // ../airaccount/src/server/interfaces/logger.ts
434
416
  var ConsoleLogger = class {
435
417
  constructor(prefix = "[YAAA]") {
436
418
  this.prefix = prefix;
@@ -459,37 +441,43 @@ var SilentLogger = class {
459
441
  }
460
442
  };
461
443
  var EthereumProvider = class {
444
+ /** Main-network read client. Pass to viem getContract / readContract calls. */
462
445
  provider;
446
+ /** Bundler client — used only for raw eth_ / pimlico_ userOp JSON-RPC. */
463
447
  bundlerProvider;
464
448
  config;
465
449
  logger;
466
450
  constructor(config) {
467
451
  this.config = config;
468
452
  this.logger = config.logger ?? new ConsoleLogger("[EthereumProvider]");
469
- this.provider = new ethers.JsonRpcProvider(config.rpcUrl);
470
- this.bundlerProvider = new ethers.JsonRpcProvider(config.bundlerRpcUrl);
453
+ this.provider = createPublicClient({ transport: http(config.rpcUrl) });
454
+ this.bundlerProvider = createPublicClient({ transport: http(config.bundlerRpcUrl) });
471
455
  }
456
+ /** Returns the viem PublicClient for the main network RPC. */
472
457
  getProvider() {
473
458
  return this.provider;
474
459
  }
460
+ /** Returns the viem PublicClient bound to the bundler RPC (raw .request only). */
475
461
  getBundlerProvider() {
476
462
  return this.bundlerProvider;
477
463
  }
464
+ /**
465
+ * Raw bundler JSON-RPC call. The bundler exposes non-standard methods
466
+ * (eth_sendUserOperation, pimlico_getUserOperationGasPrice, ...) that are not in
467
+ * viem's typed RPC schema, so we go through the transport's request fn untyped.
468
+ */
469
+ async bundlerRequest(method, params) {
470
+ return await this.bundlerProvider.request({
471
+ method,
472
+ params
473
+ });
474
+ }
478
475
  // ── Config helpers ──────────────────────────────────────────────
479
476
  getVersionConfig(version) {
480
477
  const map = {
481
- [
482
- "0.6"
483
- /* V0_6 */
484
- ]: this.config.entryPoints.v06,
485
- [
486
- "0.7"
487
- /* V0_7 */
488
- ]: this.config.entryPoints.v07,
489
- [
490
- "0.8"
491
- /* V0_8 */
492
- ]: this.config.entryPoints.v08
478
+ ["0.6" /* V0_6 */]: this.config.entryPoints.v06,
479
+ ["0.7" /* V0_7 */]: this.config.entryPoints.v07,
480
+ ["0.8" /* V0_8 */]: this.config.entryPoints.v08
493
481
  };
494
482
  const versionConfig = map[version];
495
483
  if (!versionConfig) {
@@ -508,91 +496,103 @@ var EthereumProvider = class {
508
496
  }
509
497
  getDefaultVersion() {
510
498
  const v = this.config.defaultVersion;
511
- if (v === "0.7") return "0.7";
512
- if (v === "0.8") return "0.8";
513
- return "0.6";
499
+ if (v === "0.7") return "0.7" /* V0_7 */;
500
+ if (v === "0.8") return "0.8" /* V0_8 */;
501
+ return "0.6" /* V0_6 */;
514
502
  }
515
503
  // ── Contract factories ──────────────────────────────────────────
516
- getFactoryContract(version = "0.6") {
504
+ /** Build a read-only viem contract bound to the main-network PublicClient. */
505
+ contractAt(address, abi) {
506
+ return getContract({
507
+ address,
508
+ abi: parseAbi(abi),
509
+ client: this.provider
510
+ });
511
+ }
512
+ getFactoryContract(version = "0.6" /* V0_6 */) {
517
513
  const address = this.getFactoryAddress(version);
518
- const abi = version === "0.6" ? FACTORY_ABI_V6 : AIRACCOUNT_FACTORY_ABI;
519
- return new ethers.Contract(address, abi, this.provider);
514
+ const abi = version === "0.6" /* V0_6 */ ? FACTORY_ABI_V6 : AIRACCOUNT_FACTORY_ABI;
515
+ return this.contractAt(address, abi);
520
516
  }
521
- getEntryPointContract(version = "0.6") {
517
+ getEntryPointContract(version = "0.6" /* V0_6 */) {
522
518
  const address = this.getEntryPointAddress(version);
523
- const abi = version === "0.6" ? ENTRYPOINT_ABI_V6 : ENTRYPOINT_ABI_V7_V8;
524
- return new ethers.Contract(address, abi, this.provider);
519
+ const abi = version === "0.6" /* V0_6 */ ? ENTRYPOINT_ABI_V6 : ENTRYPOINT_ABI_V7_V8;
520
+ return this.contractAt(address, abi);
525
521
  }
526
- getValidatorContract(version = "0.6") {
522
+ getValidatorContract(version = "0.6" /* V0_6 */) {
527
523
  const address = this.getValidatorAddress(version);
528
- return new ethers.Contract(address, VALIDATOR_ABI, this.provider);
524
+ return this.contractAt(address, VALIDATOR_ABI);
529
525
  }
530
526
  getAccountContract(address) {
531
- return new ethers.Contract(address, AIRACCOUNT_ABI, this.provider);
527
+ return this.contractAt(address, AIRACCOUNT_ABI);
532
528
  }
533
529
  // ── M7 Module contracts ─────────────────────────────────────────
534
530
  // M7 r4 module helpers — addresses renamed to *M7r4 suffix in beta.3 to avoid ambiguity.
535
531
  // These methods are retained for backwards compatibility; callers should pass an explicit address.
536
532
  getAgentSessionKeyValidatorContract(address = AIRACCOUNT_ADDRESSES.sepolia.agentSessionKeyValidatorM7r4) {
537
- return new ethers.Contract(address, AGENT_SESSION_KEY_VALIDATOR_ABI, this.provider);
533
+ return this.contractAt(address, AGENT_SESSION_KEY_VALIDATOR_ABI);
538
534
  }
539
535
  getTierGuardHookContract(address = AIRACCOUNT_ADDRESSES.sepolia.tierGuardHookM7r4) {
540
- return new ethers.Contract(address, TIER_GUARD_HOOK_ABI, this.provider);
536
+ return this.contractAt(address, TIER_GUARD_HOOK_ABI);
541
537
  }
542
538
  getCompositeValidatorContract(address = AIRACCOUNT_ADDRESSES.sepolia.compositeValidatorM7r4) {
543
- return new ethers.Contract(address, AIR_ACCOUNT_COMPOSITE_VALIDATOR_ABI, this.provider);
539
+ return this.contractAt(address, AIR_ACCOUNT_COMPOSITE_VALIDATOR_ABI);
544
540
  }
545
541
  getForceExitModuleContract(address) {
546
- return new ethers.Contract(address, FORCE_EXIT_MODULE_ABI, this.provider);
542
+ return this.contractAt(address, FORCE_EXIT_MODULE_ABI);
547
543
  }
548
544
  // ── On-chain queries ────────────────────────────────────────────
549
545
  async getBalance(address) {
550
- const balance = await this.provider.getBalance(address);
551
- return ethers.formatEther(balance);
546
+ const balance = await this.provider.getBalance({ address });
547
+ return formatEther(balance);
552
548
  }
553
- async getNonce(accountAddress, key = 0, version = "0.6") {
549
+ async getNonce(accountAddress, key = 0, version = "0.6" /* V0_6 */) {
554
550
  const entryPoint = this.getEntryPointContract(version);
555
- return await entryPoint.getNonce(accountAddress, key);
551
+ return await entryPoint.read.getNonce([
552
+ accountAddress,
553
+ BigInt(key)
554
+ ]);
556
555
  }
557
- async getUserOpHash(userOp, version = "0.6") {
556
+ async getUserOpHash(userOp, version = "0.6" /* V0_6 */) {
558
557
  const entryPoint = this.getEntryPointContract(version);
559
- if (version === "0.6") {
558
+ const read = entryPoint.read;
559
+ if (version === "0.6" /* V0_6 */) {
560
560
  const op = userOp;
561
561
  const userOpArray = [
562
562
  op.sender,
563
- op.nonce,
563
+ BigInt(op.nonce),
564
564
  op.initCode || "0x",
565
565
  op.callData,
566
- op.callGasLimit,
567
- op.verificationGasLimit,
568
- op.preVerificationGas,
569
- op.maxFeePerGas,
570
- op.maxPriorityFeePerGas,
566
+ BigInt(op.callGasLimit),
567
+ BigInt(op.verificationGasLimit),
568
+ BigInt(op.preVerificationGas),
569
+ BigInt(op.maxFeePerGas),
570
+ BigInt(op.maxPriorityFeePerGas),
571
571
  op.paymasterAndData || "0x",
572
572
  "0x"
573
573
  // Always use empty signature for hash calculation
574
574
  ];
575
- return await entryPoint.getUserOpHash(userOpArray);
575
+ return await read.getUserOpHash([userOpArray]);
576
576
  } else {
577
577
  const packedOp = userOp;
578
578
  const packedOpArray = [
579
579
  packedOp.sender,
580
- packedOp.nonce,
580
+ BigInt(packedOp.nonce),
581
581
  packedOp.initCode || "0x",
582
582
  packedOp.callData,
583
583
  packedOp.accountGasLimits,
584
- packedOp.preVerificationGas,
584
+ BigInt(packedOp.preVerificationGas),
585
585
  packedOp.gasFees,
586
586
  packedOp.paymasterAndData || "0x",
587
587
  "0x"
588
588
  ];
589
- return await entryPoint.getUserOpHash(packedOpArray);
589
+ return await read.getUserOpHash([packedOpArray]);
590
590
  }
591
591
  }
592
592
  // ── Bundler RPC ─────────────────────────────────────────────────
593
- async estimateUserOperationGas(userOp, version = "0.6") {
593
+ async estimateUserOperationGas(userOp, version = "0.6" /* V0_6 */) {
594
594
  try {
595
- return await this.bundlerProvider.send("eth_estimateUserOperationGas", [
595
+ return await this.bundlerRequest("eth_estimateUserOperationGas", [
596
596
  userOp,
597
597
  this.getEntryPointAddress(version)
598
598
  ]);
@@ -605,14 +605,14 @@ var EthereumProvider = class {
605
605
  };
606
606
  }
607
607
  }
608
- async sendUserOperation(userOp, version = "0.6") {
609
- return await this.bundlerProvider.send("eth_sendUserOperation", [
608
+ async sendUserOperation(userOp, version = "0.6" /* V0_6 */) {
609
+ return await this.bundlerRequest("eth_sendUserOperation", [
610
610
  userOp,
611
611
  this.getEntryPointAddress(version)
612
612
  ]);
613
613
  }
614
614
  async getUserOperationReceipt(userOpHash) {
615
- return await this.bundlerProvider.send("eth_getUserOperationReceipt", [userOpHash]);
615
+ return await this.bundlerRequest("eth_getUserOperationReceipt", [userOpHash]);
616
616
  }
617
617
  async waitForUserOp(userOpHash, maxAttempts = 60) {
618
618
  const pollInterval = 2e3;
@@ -631,16 +631,16 @@ var EthereumProvider = class {
631
631
  }
632
632
  async getUserOperationGasPrice() {
633
633
  try {
634
- const gasPrice = await this.bundlerProvider.send("pimlico_getUserOperationGasPrice", []);
634
+ const gasPrice = await this.bundlerRequest("pimlico_getUserOperationGasPrice", []);
635
635
  return {
636
636
  maxFeePerGas: gasPrice.fast.maxFeePerGas,
637
637
  maxPriorityFeePerGas: gasPrice.fast.maxPriorityFeePerGas
638
638
  };
639
639
  } catch {
640
640
  try {
641
- const feeData = await this.provider.getFeeData();
642
- const baseFee = feeData.maxFeePerGas || ethers.parseUnits("20", "gwei");
643
- const priorityFee = feeData.maxPriorityFeePerGas || ethers.parseUnits("2", "gwei");
641
+ const feeData = await this.provider.estimateFeesPerGas();
642
+ const baseFee = feeData.maxFeePerGas || parseUnits("20", 9);
643
+ const priorityFee = feeData.maxPriorityFeePerGas || parseUnits("2", 9);
644
644
  const maxFeePerGas = baseFee * 3n / 2n;
645
645
  const maxPriorityFeePerGas = priorityFee * 3n / 2n;
646
646
  return {
@@ -649,13 +649,64 @@ var EthereumProvider = class {
649
649
  };
650
650
  } catch {
651
651
  return {
652
- maxFeePerGas: "0x" + ethers.parseUnits("3", "gwei").toString(16),
653
- maxPriorityFeePerGas: "0x" + ethers.parseUnits("1", "gwei").toString(16)
652
+ maxFeePerGas: "0x" + parseUnits("3", 9).toString(16),
653
+ // gwei
654
+ maxPriorityFeePerGas: "0x" + parseUnits("1", 9).toString(16)
655
+ // gwei
654
656
  };
655
657
  }
656
658
  }
657
659
  }
658
660
  };
661
+
662
+ // ../airaccount/src/server/providers/typed-reads.ts
663
+ function readFn(contract, name) {
664
+ return contract.read[name];
665
+ }
666
+ function readValidatorGasEstimate(validator, nodeCount) {
667
+ return readFn(validator, "getGasEstimate")([nodeCount]);
668
+ }
669
+ function readPredictedAddress(factory, owner, salt, config) {
670
+ return readFn(factory, "getAddress")([owner, salt, config]);
671
+ }
672
+ function readPredictedAddressWithDefaults(factory, owner, salt, guardian1, guardian2, dailyLimit) {
673
+ return readFn(factory, "getAddressWithDefaults")([
674
+ owner,
675
+ salt,
676
+ guardian1,
677
+ guardian2,
678
+ dailyLimit
679
+ ]);
680
+ }
681
+ async function readAccountTierLimits(account) {
682
+ const [tier1Limit, tier2Limit] = await Promise.all([
683
+ readFn(account, "tier1Limit")([]),
684
+ readFn(account, "tier2Limit")([])
685
+ ]);
686
+ return { tier1Limit, tier2Limit };
687
+ }
688
+ function readAlgorithmApproved(account, algId) {
689
+ return readFn(account, "approvedAlgorithms")([algId]);
690
+ }
691
+ async function readAccountGuardAddress(account) {
692
+ const config = await readFn(account, "getConfigDescription")([]);
693
+ return config.guardAddress;
694
+ }
695
+ async function readGuardDailyAllowance(guard) {
696
+ const [dailyLimit, dailyRemaining] = await Promise.all([
697
+ readFn(guard, "dailyLimit")([]),
698
+ readFn(guard, "remainingDailyAllowance")([])
699
+ ]);
700
+ return { dailyLimit, dailyRemaining };
701
+ }
702
+ function readBuildGrantHash(validator, account, sessionKey, cfg) {
703
+ return readFn(validator, "buildGrantHash")([account, sessionKey, cfg]);
704
+ }
705
+ function readBuildP256GrantHash(validator, account, keyX, keyY, cfg) {
706
+ return readFn(validator, "buildP256GrantHash")([account, keyX, keyY, cfg]);
707
+ }
708
+
709
+ // ../airaccount/src/server/services/account-manager.ts
659
710
  var AccountManager = class {
660
711
  constructor(ethereum, storage, signer, logger) {
661
712
  this.ethereum = ethereum;
@@ -673,12 +724,12 @@ var AccountManager = class {
673
724
  );
674
725
  if (existing) return existing;
675
726
  const factory = this.ethereum.getFactoryContract(version);
676
- const validatorAddress = this.ethereum.getValidatorContract(version).target || this.ethereum.getValidatorAddress(version);
727
+ const validatorAddress = this.ethereum.getValidatorContract(version).address || this.ethereum.getValidatorAddress(version);
677
728
  const { address: signerAddress } = await this.signer.ensureSigner(userId);
678
729
  const salt = options?.salt ?? Math.floor(Math.random() * 1e6);
679
730
  const dailyLimitValue = options?.dailyLimit ?? 0n;
680
731
  const minimalConfig = [
681
- [ethers.ZeroAddress, ethers.ZeroAddress, ethers.ZeroAddress],
732
+ [zeroAddress, zeroAddress, zeroAddress],
682
733
  // guardians (address[3])
683
734
  dailyLimitValue,
684
735
  // dailyLimit (0 = no guard)
@@ -691,11 +742,16 @@ var AccountManager = class {
691
742
  []
692
743
  // initialTokenConfigs
693
744
  ];
694
- const accountAddress = await factory.getFunction("getAddress")(signerAddress, salt, minimalConfig);
745
+ const accountAddress = await readPredictedAddress(
746
+ factory,
747
+ signerAddress,
748
+ BigInt(salt),
749
+ minimalConfig
750
+ );
695
751
  let deployed = false;
696
752
  try {
697
- const code = await this.ethereum.getProvider().getCode(accountAddress);
698
- deployed = code !== "0x";
753
+ const code = await this.ethereum.getProvider().getCode({ address: accountAddress });
754
+ deployed = !!code && code !== "0x";
699
755
  } catch {
700
756
  }
701
757
  const account = {
@@ -707,7 +763,7 @@ var AccountManager = class {
707
763
  deploymentTxHash: null,
708
764
  validatorAddress,
709
765
  entryPointVersion: versionStr,
710
- factoryAddress: factory.target || this.ethereum.getFactoryAddress(version),
766
+ factoryAddress: factory.address || this.ethereum.getFactoryAddress(version),
711
767
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
712
768
  // Persist dailyLimit so buildUserOperation can reconstruct identical initCode at deploy time.
713
769
  ...dailyLimitValue > 0n ? { dailyLimit: dailyLimitValue.toString() } : {}
@@ -739,7 +795,7 @@ var AccountManager = class {
739
795
  return {
740
796
  address: account.address,
741
797
  balance,
742
- balanceInWei: ethers.parseEther(balance).toString()
798
+ balanceInWei: parseEther(balance).toString()
743
799
  };
744
800
  }
745
801
  async getAccountNonce(userId) {
@@ -775,10 +831,10 @@ var AccountManager = class {
775
831
  `salt value ${salt} exceeds Number.MAX_SAFE_INTEGER; pass as bigint to avoid precision loss`
776
832
  );
777
833
  }
778
- return ethers.keccak256(
779
- ethers.solidityPacked(
834
+ return keccak256(
835
+ solidityPacked(
780
836
  ["string", "uint256", "address", "address", "uint256", "uint256"],
781
- ["ACCEPT_GUARDIAN", chainId, factoryAddress, owner, salt, dailyLimit]
837
+ ["ACCEPT_GUARDIAN", BigInt(chainId), factoryAddress, owner, BigInt(salt), dailyLimit]
782
838
  )
783
839
  );
784
840
  }
@@ -794,13 +850,11 @@ var AccountManager = class {
794
850
  * @param guardianSigs 65-byte EIP-191 hex signatures from required guardians
795
851
  */
796
852
  encodeModifyTierLimits(tier1, tier2, deadline, guardianSigs) {
797
- const iface = new ethers.Interface(AIRACCOUNT_ABI);
798
- return iface.encodeFunctionData("modifyTierLimitsWithGuardians", [
799
- tier1,
800
- tier2,
801
- deadline,
802
- guardianSigs
803
- ]);
853
+ return encodeFunctionData({
854
+ abi: parseAbi(AIRACCOUNT_ABI),
855
+ functionName: "modifyTierLimitsWithGuardians",
856
+ args: [tier1, tier2, deadline, guardianSigs]
857
+ });
804
858
  }
805
859
  /**
806
860
  * Create an AirAccount with 3 on-chain guardians:
@@ -820,7 +874,7 @@ var AccountManager = class {
820
874
  throw new Error("Guardian accounts require dailyLimit > 0 (on-chain enforcement)");
821
875
  }
822
876
  const version = params.entryPointVersion ?? this.ethereum.getDefaultVersion();
823
- if (version === "0.6") {
877
+ if (version === "0.6" /* V0_6 */) {
824
878
  throw new Error(
825
879
  "createAccountWithGuardians requires EntryPoint v0.7 or v0.8; v0.6 factory does not support getAddressWithDefaults"
826
880
  );
@@ -834,18 +888,19 @@ var AccountManager = class {
834
888
  const { address: signerAddress } = await this.signer.ensureSigner(userId);
835
889
  const salt = params.salt ?? Math.floor(Math.random() * 1e6);
836
890
  const factory = this.ethereum.getFactoryContract(version);
837
- const factoryAddress = factory.target ?? this.ethereum.getFactoryAddress(version);
838
- const accountAddress = await factory.getFunction("getAddressWithDefaults")(
891
+ const factoryAddress = factory.address ?? this.ethereum.getFactoryAddress(version);
892
+ const accountAddress = await readPredictedAddressWithDefaults(
893
+ factory,
839
894
  signerAddress,
840
- salt,
895
+ BigInt(salt),
841
896
  params.guardian1,
842
897
  params.guardian2,
843
898
  params.dailyLimit
844
899
  );
845
900
  let deployed = false;
846
901
  try {
847
- const code = await this.ethereum.getProvider().getCode(accountAddress);
848
- deployed = code !== "0x";
902
+ const code = await this.ethereum.getProvider().getCode({ address: accountAddress });
903
+ deployed = !!code && code !== "0x";
849
904
  } catch {
850
905
  }
851
906
  const validatorAddress = this.ethereum.getValidatorAddress(version);
@@ -874,9 +929,13 @@ var AccountManager = class {
874
929
  return account;
875
930
  }
876
931
  };
877
- var EXECUTE_USER_OP_SELECTOR = ethers.id("executeUserOp((address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes),bytes32)").slice(0, 10);
878
- var EXECUTE_SELECTOR = ethers.id("execute(address,uint256,bytes)").slice(0, 10);
879
- var EXECUTE_BATCH_SELECTOR = ethers.id("executeBatch(address[],uint256[],bytes[])").slice(0, 10);
932
+ var EXECUTE_USER_OP_SELECTOR = selectorFromId(
933
+ "executeUserOp((address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes),bytes32)"
934
+ );
935
+ var EXECUTE_SELECTOR = selectorFromId("execute(address,uint256,bytes)");
936
+ var EXECUTE_BATCH_SELECTOR = selectorFromId(
937
+ "executeBatch(address[],uint256[],bytes[])"
938
+ );
880
939
  function wrapExecuteUserOp(innerCallData) {
881
940
  if (!/^0x[0-9a-fA-F]*$/.test(innerCallData) || innerCallData.length < 10) {
882
941
  throw new Error("wrapExecuteUserOp: innerCallData must be 0x-prefixed calldata with a 4-byte selector");
@@ -887,7 +946,7 @@ function wrapExecuteUserOp(innerCallData) {
887
946
  `wrapExecuteUserOp: only execute()/executeBatch() may be wrapped (got selector ${sel}); the account reverts UnsupportedInnerSelector otherwise`
888
947
  );
889
948
  }
890
- return ethers.concat([EXECUTE_USER_OP_SELECTOR, innerCallData]);
949
+ return concat([EXECUTE_USER_OP_SELECTOR, innerCallData]);
891
950
  }
892
951
  function isExecuteUserOpWrapped(callData) {
893
952
  return callData.slice(0, 10).toLowerCase() === EXECUTE_USER_OP_SELECTOR;
@@ -903,12 +962,16 @@ var PaymasterPriceStalenessError = class extends Error {
903
962
  this.name = "PaymasterPriceStalenessError";
904
963
  }
905
964
  };
906
- var PAYMASTER_PRICE_ABI = [
965
+ var PAYMASTER_PRICE_ABI = parseAbi([
907
966
  "function token() view returns (address)",
908
967
  "function cachedPriceTimestamp() view returns (uint256)",
909
968
  "function priceStalenessThreshold() view returns (uint256)",
910
969
  "function updatePrice() external"
911
- ];
970
+ ]);
971
+ var SUPER_PAYMASTER_DETECT_ABI = parseAbi([
972
+ "function owner() view returns (address)",
973
+ "function operators(address) view returns (bool,uint256,address,uint256)"
974
+ ]);
912
975
  var PaymasterManager = class {
913
976
  constructor(ethereum, storage, logger) {
914
977
  this.ethereum = ethereum;
@@ -946,10 +1009,14 @@ var PaymasterManager = class {
946
1009
  */
947
1010
  async checkPriceFreshness(paymasterAddress) {
948
1011
  const provider = this.ethereum.getProvider();
949
- const contract = new ethers.Contract(paymasterAddress, PAYMASTER_PRICE_ABI, provider);
1012
+ const contract = getContract({
1013
+ address: paymasterAddress,
1014
+ abi: PAYMASTER_PRICE_ABI,
1015
+ client: provider
1016
+ });
950
1017
  const [timestamp, threshold] = await Promise.all([
951
- contract.cachedPriceTimestamp(),
952
- contract.priceStalenessThreshold()
1018
+ contract.read.cachedPriceTimestamp(),
1019
+ contract.read.priceStalenessThreshold()
953
1020
  ]);
954
1021
  const nowSeconds = Math.floor(Date.now() / 1e3);
955
1022
  const ageSeconds = nowSeconds - Number(timestamp);
@@ -964,14 +1031,26 @@ var PaymasterManager = class {
964
1031
  * Call `updatePrice()` on a paymaster contract (permissionless).
965
1032
  * Useful when `checkPriceFreshness()` reports stale price.
966
1033
  *
967
- * @param signer - An ethers Signer that will send the transaction (must have gas).
1034
+ * @param walletClient - A viem WalletClient (with an account) that will send
1035
+ * the transaction (must have gas). Replaces the former ethers Signer param.
968
1036
  */
969
- async updatePrice(paymasterAddress, signer) {
970
- const contract = new ethers.Contract(paymasterAddress, PAYMASTER_PRICE_ABI, signer);
971
- const tx = await contract.updatePrice({ gasLimit: 3e5 });
972
- await tx.wait();
973
- this.logger.log(`Paymaster ${paymasterAddress} price updated, tx: ${tx.hash}`);
974
- return tx.hash;
1037
+ async updatePrice(paymasterAddress, walletClient) {
1038
+ const account = walletClient.account;
1039
+ if (!account) {
1040
+ throw new Error("updatePrice requires a WalletClient with a configured account");
1041
+ }
1042
+ const hash = await walletClient.writeContract({
1043
+ address: paymasterAddress,
1044
+ abi: PAYMASTER_PRICE_ABI,
1045
+ functionName: "updatePrice",
1046
+ args: [],
1047
+ gas: BigInt(3e5),
1048
+ account,
1049
+ chain: walletClient.chain
1050
+ });
1051
+ await this.ethereum.getProvider().waitForTransactionReceipt({ hash });
1052
+ this.logger.log(`Paymaster ${paymasterAddress} price updated, tx: ${hash}`);
1053
+ return hash;
975
1054
  }
976
1055
  async getPaymasterData(userId, paymasterName, userOp, entryPoint, customAddress, options) {
977
1056
  if (paymasterName === "custom-user-provided" && customAddress) {
@@ -985,16 +1064,13 @@ var PaymasterManager = class {
985
1064
  let isSuperPaymaster = false;
986
1065
  let operatorAddress = "0x";
987
1066
  try {
988
- const spContract = new ethers.Contract(
989
- formattedAddress,
990
- [
991
- "function owner() view returns (address)",
992
- "function operators(address) view returns (bool,uint256,address,uint256)"
993
- ],
994
- provider
995
- );
996
- const owner = await spContract.owner();
997
- const opInfo = await spContract.operators(owner);
1067
+ const spContract = getContract({
1068
+ address: formattedAddress,
1069
+ abi: SUPER_PAYMASTER_DETECT_ABI,
1070
+ client: provider
1071
+ });
1072
+ const owner = await spContract.read.owner();
1073
+ const opInfo = await spContract.read.operators([owner]);
998
1074
  if (opInfo && opInfo[0] === true) {
999
1075
  isSuperPaymaster = true;
1000
1076
  operatorAddress = owner;
@@ -1006,12 +1082,12 @@ var PaymasterManager = class {
1006
1082
  const verGas = BigInt(8e4);
1007
1083
  const postGas = BigInt(3e5);
1008
1084
  const maxRate = (BigInt(1) << BigInt(256)) - BigInt(1);
1009
- return ethers.concat([
1085
+ return concat([
1010
1086
  formattedAddress,
1011
- ethers.zeroPadValue(ethers.toBeHex(verGas), 16),
1012
- ethers.zeroPadValue(ethers.toBeHex(postGas), 16),
1087
+ numberToHex(verGas, { size: 16 }),
1088
+ numberToHex(postGas, { size: 16 }),
1013
1089
  operatorAddress,
1014
- ethers.zeroPadValue(ethers.toBeHex(maxRate), 32)
1090
+ numberToHex(maxRate, { size: 32 })
1015
1091
  ]);
1016
1092
  }
1017
1093
  const paymasterVerificationGasLimit = BigInt(196608);
@@ -1021,13 +1097,13 @@ var PaymasterManager = class {
1021
1097
  this.logger.log(`PaymasterV4 token from options: ${tokenAddress}`);
1022
1098
  } else {
1023
1099
  try {
1024
- const pmContract = new ethers.Contract(
1025
- formattedAddress,
1026
- PAYMASTER_PRICE_ABI,
1027
- provider
1028
- );
1029
- tokenAddress = await pmContract.token();
1030
- if (tokenAddress === ethers.ZeroAddress) tokenAddress = null;
1100
+ const pmContract = getContract({
1101
+ address: formattedAddress,
1102
+ abi: PAYMASTER_PRICE_ABI,
1103
+ client: provider
1104
+ });
1105
+ tokenAddress = await pmContract.read.token();
1106
+ if (tokenAddress === zeroAddress) tokenAddress = null;
1031
1107
  if (tokenAddress) {
1032
1108
  this.logger.log(`PaymasterV4 token auto-detected: ${tokenAddress}`);
1033
1109
  }
@@ -1037,13 +1113,13 @@ var PaymasterManager = class {
1037
1113
  }
1038
1114
  const parts = [
1039
1115
  formattedAddress,
1040
- ethers.zeroPadValue(ethers.toBeHex(paymasterVerificationGasLimit), 16),
1041
- ethers.zeroPadValue(ethers.toBeHex(paymasterPostOpGasLimit), 16)
1116
+ numberToHex(paymasterVerificationGasLimit, { size: 16 }),
1117
+ numberToHex(paymasterPostOpGasLimit, { size: 16 })
1042
1118
  ];
1043
1119
  if (tokenAddress) {
1044
1120
  parts.push(tokenAddress);
1045
1121
  }
1046
- return ethers.concat(parts);
1122
+ return concat(parts);
1047
1123
  }
1048
1124
  return formattedAddress;
1049
1125
  }
@@ -1098,16 +1174,12 @@ var PaymasterManager = class {
1098
1174
  return result.result.paymasterAndData;
1099
1175
  }
1100
1176
  if (result.result.paymaster) {
1101
- return ethers.concat([
1177
+ return concat([
1102
1178
  result.result.paymaster,
1103
- ethers.zeroPadValue(
1104
- ethers.toBeHex(BigInt(result.result.paymasterVerificationGasLimit || "0x30000")),
1105
- 16
1106
- ),
1107
- ethers.zeroPadValue(
1108
- ethers.toBeHex(BigInt(result.result.paymasterPostOpGasLimit || "0x30000")),
1109
- 16
1110
- ),
1179
+ numberToHex(BigInt(result.result.paymasterVerificationGasLimit || "0x30000"), {
1180
+ size: 16
1181
+ }),
1182
+ numberToHex(BigInt(result.result.paymasterPostOpGasLimit || "0x30000"), { size: 16 }),
1111
1183
  result.result.paymasterData || "0x"
1112
1184
  ]);
1113
1185
  }
@@ -1153,80 +1225,27 @@ var PaymasterManager = class {
1153
1225
  }
1154
1226
  }
1155
1227
  };
1156
- var ERC4337Utils = class _ERC4337Utils {
1157
- static packAccountGasLimits(verificationGasLimit, callGasLimit) {
1158
- const vgl = BigInt(verificationGasLimit);
1159
- const cgl = BigInt(callGasLimit);
1160
- const packed = vgl << 128n | cgl;
1161
- return "0x" + packed.toString(16).padStart(64, "0");
1162
- }
1163
- static unpackAccountGasLimits(accountGasLimits) {
1164
- const packed = BigInt(accountGasLimits);
1165
- return {
1166
- verificationGasLimit: packed >> 128n,
1167
- callGasLimit: packed & (1n << 128n) - 1n
1168
- };
1169
- }
1170
- static packGasFees(maxPriorityFeePerGas, maxFeePerGas) {
1171
- const priority = BigInt(maxPriorityFeePerGas);
1172
- const max = BigInt(maxFeePerGas);
1173
- const packed = priority << 128n | max;
1174
- return "0x" + packed.toString(16).padStart(64, "0");
1175
- }
1176
- static unpackGasFees(gasFees) {
1177
- const packed = BigInt(gasFees);
1178
- return {
1179
- maxPriorityFeePerGas: packed >> 128n,
1180
- maxFeePerGas: packed & (1n << 128n) - 1n
1181
- };
1182
- }
1183
- static packUserOperation(userOp) {
1184
- return {
1185
- sender: userOp.sender,
1186
- nonce: userOp.nonce,
1187
- initCode: userOp.initCode || "0x",
1188
- callData: userOp.callData,
1189
- accountGasLimits: _ERC4337Utils.packAccountGasLimits(
1190
- userOp.verificationGasLimit,
1191
- userOp.callGasLimit
1192
- ),
1193
- preVerificationGas: userOp.preVerificationGas,
1194
- gasFees: _ERC4337Utils.packGasFees(userOp.maxPriorityFeePerGas, userOp.maxFeePerGas),
1195
- paymasterAndData: userOp.paymasterAndData || "0x",
1196
- signature: userOp.signature || "0x"
1197
- };
1198
- }
1199
- static unpackUserOperation(packedOp) {
1200
- const gasLimits = _ERC4337Utils.unpackAccountGasLimits(packedOp.accountGasLimits);
1201
- const gasFees = _ERC4337Utils.unpackGasFees(packedOp.gasFees);
1202
- return {
1203
- sender: packedOp.sender,
1204
- nonce: packedOp.nonce,
1205
- initCode: packedOp.initCode,
1206
- callData: packedOp.callData,
1207
- callGasLimit: "0x" + gasLimits.callGasLimit.toString(16),
1208
- verificationGasLimit: "0x" + gasLimits.verificationGasLimit.toString(16),
1209
- preVerificationGas: packedOp.preVerificationGas,
1210
- maxFeePerGas: "0x" + gasFees.maxFeePerGas.toString(16),
1211
- maxPriorityFeePerGas: "0x" + gasFees.maxPriorityFeePerGas.toString(16),
1212
- paymasterAndData: packedOp.paymasterAndData,
1213
- signature: packedOp.signature
1214
- };
1215
- }
1216
- };
1228
+
1229
+ // ../airaccount/src/server/services/transfer-manager.ts
1230
+ var AIRACCOUNT_ABI_PARSED = parseAbi(AIRACCOUNT_ABI);
1231
+ var AIRACCOUNT_FACTORY_ABI_PARSED = parseAbi(AIRACCOUNT_FACTORY_ABI);
1232
+ var FACTORY_ABI_V6_PARSED = parseAbi(FACTORY_ABI_V6);
1233
+ var VALIDATOR_GETTER_ABI = parseAbi(["function validator() view returns (address)"]);
1234
+ function encodeFn(abi, functionName, args) {
1235
+ return encodeFunctionData({ abi, functionName, args });
1236
+ }
1217
1237
  async function detectSignatureStrategy(provider, accountAddress) {
1218
1238
  try {
1219
- const accountCode = await provider.getCode(accountAddress);
1220
- if (accountCode === "0x") {
1239
+ const accountCode = await provider.getCode({ address: accountAddress });
1240
+ if (!accountCode || accountCode === "0x") {
1221
1241
  return { useECDSA: true, isCompositeValidator: true };
1222
1242
  }
1223
- const acc = new ethers.Contract(
1224
- accountAddress,
1225
- ["function validator() view returns (address)"],
1226
- provider
1227
- );
1228
- const v = await acc.validator();
1229
- return { useECDSA: v === ethers.ZeroAddress, isCompositeValidator: true };
1243
+ const v = await provider.readContract({
1244
+ address: accountAddress,
1245
+ abi: VALIDATOR_GETTER_ABI,
1246
+ functionName: "validator"
1247
+ });
1248
+ return { useECDSA: v === zeroAddress, isCompositeValidator: true };
1230
1249
  } catch {
1231
1250
  return { useECDSA: true, isCompositeValidator: false };
1232
1251
  }
@@ -1252,8 +1271,8 @@ var TransferManager = class {
1252
1271
  async executeTransfer(userId, params) {
1253
1272
  const account = await this.accountManager.getAccountByUserId(userId);
1254
1273
  if (!account) throw new Error("User account not found");
1255
- const code = await this.ethereum.getProvider().getCode(account.address);
1256
- const needsDeployment = code === "0x";
1274
+ const code = await this.ethereum.getProvider().getCode({ address: account.address });
1275
+ const needsDeployment = !code || code === "0x";
1257
1276
  if (needsDeployment) {
1258
1277
  this.logger.log("Account needs deployment, will deploy with first transaction");
1259
1278
  }
@@ -1293,7 +1312,7 @@ var TransferManager = class {
1293
1312
  const assertionCtx = params.passkeyAssertion ? { assertion: params.passkeyAssertion } : void 0;
1294
1313
  let useECDSA = false;
1295
1314
  let isCompositeValidator = false;
1296
- if (version === "0.7" || version === "0.8") {
1315
+ if (version === "0.7" /* V0_7 */ || version === "0.8" /* V0_8 */) {
1297
1316
  const provider = this.ethereum.getProvider();
1298
1317
  ({ useECDSA, isCompositeValidator } = await detectSignatureStrategy(
1299
1318
  provider,
@@ -1301,17 +1320,23 @@ var TransferManager = class {
1301
1320
  ));
1302
1321
  }
1303
1322
  if (useECDSA) {
1304
- const signer = await this.signer.getSigner(userId, assertionCtx);
1305
- const ecdsaSig = await signer.signMessage(ethers.getBytes(userOpHash));
1323
+ const ecdsaSig = await this.signer.signMessage(
1324
+ userId,
1325
+ hexToBytes(userOpHash),
1326
+ assertionCtx
1327
+ );
1306
1328
  if (isCompositeValidator) {
1307
1329
  this.logger.log("ECDSA path for compositeValidator: prepending algId prefix");
1308
- userOp.signature = ethers.concat([ethers.toBeHex(ALG_ID.ECDSA, 1), ecdsaSig]);
1330
+ userOp.signature = concat([
1331
+ numberToHex(ALG_ID.ECDSA, { size: 1 }),
1332
+ ecdsaSig
1333
+ ]);
1309
1334
  } else {
1310
1335
  this.logger.log("ECDSA path for non-compositeValidator: raw signature");
1311
1336
  userOp.signature = ecdsaSig;
1312
1337
  }
1313
1338
  } else if (params.useAirAccountTiering && this.guardChecker) {
1314
- const transferValue = params.tokenAddress ? 0n : ethers.parseEther(params.amount);
1339
+ const transferValue = params.tokenAddress ? 0n : parseEther(params.amount);
1315
1340
  const preCheck = await this.guardChecker.preCheck(account.address, transferValue);
1316
1341
  if (!preCheck.ok) {
1317
1342
  throw new Error(`Guard pre-check failed: ${preCheck.errors.join("; ")}`);
@@ -1330,7 +1355,10 @@ var TransferManager = class {
1330
1355
  } else {
1331
1356
  const blsData = await this.blsService.generateBLSSignature(userId, userOpHash, assertionCtx);
1332
1357
  const packedBls = await this.blsService.packSignature(blsData);
1333
- userOp.signature = ethers.concat([ethers.toBeHex(ALG_ID.BLS, 1), packedBls]);
1358
+ userOp.signature = concat([
1359
+ numberToHex(ALG_ID.BLS, { size: 1 }),
1360
+ packedBls
1361
+ ]);
1334
1362
  }
1335
1363
  const transferId = generateId();
1336
1364
  let tokenSymbol = "ETH";
@@ -1383,8 +1411,8 @@ var TransferManager = class {
1383
1411
  status: "completed",
1384
1412
  completedAt: (/* @__PURE__ */ new Date()).toISOString()
1385
1413
  });
1386
- const code = await this.ethereum.getProvider().getCode(from);
1387
- if (code !== "0x") {
1414
+ const code = await this.ethereum.getProvider().getCode({ address: from });
1415
+ if (code && code !== "0x") {
1388
1416
  const account = (await this.storage.getAccounts()).find((a) => a.address === from);
1389
1417
  if (account && !account.deployed) {
1390
1418
  await this.storage.updateAccount(account.userId, {
@@ -1436,7 +1464,7 @@ var TransferManager = class {
1436
1464
  const gasEstimates = await this.ethereum.estimateUserOperationGas(formatted, version);
1437
1465
  const gasPrices = await this.ethereum.getUserOperationGasPrice();
1438
1466
  const validatorContract = this.ethereum.getValidatorContract(version);
1439
- const validatorGasEstimate = await validatorContract.getGasEstimate(3);
1467
+ const validatorGasEstimate = await readValidatorGasEstimate(validatorContract, 3n);
1440
1468
  return {
1441
1469
  callGasLimit: gasEstimates.callGasLimit,
1442
1470
  verificationGasLimit: gasEstimates.verificationGasLimit,
@@ -1486,28 +1514,27 @@ var TransferManager = class {
1486
1514
  };
1487
1515
  }
1488
1516
  // ── Private helpers ─────────────────────────────────────────────
1489
- async buildUserOperation(userId, sender, to, amount, data, usePaymaster, paymasterAddress, _paymasterData, tokenAddress, version = "0.6", paymasterTokenAddress, wrapExecuteUserOpFlag = false) {
1490
- const accountContract = this.ethereum.getAccountContract(sender);
1517
+ async buildUserOperation(userId, sender, to, amount, data, usePaymaster, paymasterAddress, _paymasterData, tokenAddress, version = "0.6" /* V0_6 */, paymasterTokenAddress, wrapExecuteUserOpFlag = false) {
1491
1518
  const nonce = await this.ethereum.getNonce(sender, 0, version);
1492
1519
  const provider = this.ethereum.getProvider();
1493
- const code = await provider.getCode(sender);
1494
- const needsDeployment = code === "0x";
1520
+ const code = await provider.getCode({ address: sender });
1521
+ const needsDeployment = !code || code === "0x";
1495
1522
  let initCode = "0x";
1496
1523
  if (needsDeployment) {
1497
1524
  const accounts = await this.storage.getAccounts();
1498
1525
  const account = accounts.find((a) => a.address === sender);
1499
1526
  if (account) {
1500
1527
  const factory = this.ethereum.getFactoryContract(version);
1501
- const factoryAddress = await factory.getAddress();
1528
+ const factoryAddress = factory.address;
1502
1529
  let deployCalldata;
1503
- if (version === "0.7" || version === "0.8") {
1530
+ if (version === "0.7" /* V0_7 */ || version === "0.8" /* V0_8 */) {
1504
1531
  const storedDailyLimit = account.dailyLimit ? BigInt(account.dailyLimit) : 0n;
1505
1532
  if (account.guardian1 && account.guardian2 && account.guardian1Sig && account.guardian2Sig) {
1506
1533
  const sig1 = account.guardian1Sig.startsWith("0x") ? account.guardian1Sig : `0x${account.guardian1Sig}`;
1507
1534
  const sig2 = account.guardian2Sig.startsWith("0x") ? account.guardian2Sig : `0x${account.guardian2Sig}`;
1508
- deployCalldata = factory.interface.encodeFunctionData("createAccountWithDefaults", [
1535
+ deployCalldata = encodeFn(AIRACCOUNT_FACTORY_ABI_PARSED, "createAccountWithDefaults", [
1509
1536
  account.signerAddress,
1510
- account.salt,
1537
+ BigInt(account.salt),
1511
1538
  account.guardian1,
1512
1539
  sig1,
1513
1540
  account.guardian2,
@@ -1516,7 +1543,7 @@ var TransferManager = class {
1516
1543
  ]);
1517
1544
  } else {
1518
1545
  const minimalConfig = [
1519
- [ethers.ZeroAddress, ethers.ZeroAddress, ethers.ZeroAddress],
1546
+ [zeroAddress, zeroAddress, zeroAddress],
1520
1547
  // guardians (address[3])
1521
1548
  storedDailyLimit,
1522
1549
  [],
@@ -1528,25 +1555,22 @@ var TransferManager = class {
1528
1555
  []
1529
1556
  // initialTokenConfigs
1530
1557
  ];
1531
- deployCalldata = factory.interface.encodeFunctionData("createAccount", [
1558
+ deployCalldata = encodeFn(AIRACCOUNT_FACTORY_ABI_PARSED, "createAccount", [
1532
1559
  account.signerAddress,
1533
- account.salt,
1560
+ BigInt(account.salt),
1534
1561
  minimalConfig
1535
1562
  ]);
1536
1563
  }
1537
1564
  } else {
1538
- deployCalldata = factory.interface.encodeFunctionData(
1539
- "createAccountWithAAStarValidator",
1540
- [
1541
- account.signerAddress,
1542
- account.signerAddress,
1543
- account.validatorAddress,
1544
- true,
1545
- account.salt
1546
- ]
1547
- );
1565
+ deployCalldata = encodeFn(FACTORY_ABI_V6_PARSED, "createAccountWithAAStarValidator", [
1566
+ account.signerAddress,
1567
+ account.signerAddress,
1568
+ account.validatorAddress,
1569
+ true,
1570
+ BigInt(account.salt)
1571
+ ]);
1548
1572
  }
1549
- initCode = ethers.concat([factoryAddress, deployCalldata]);
1573
+ initCode = concat([factoryAddress, deployCalldata]);
1550
1574
  }
1551
1575
  }
1552
1576
  let callData;
@@ -1557,23 +1581,15 @@ var TransferManager = class {
1557
1581
  amount,
1558
1582
  tokenInfo.decimals
1559
1583
  );
1560
- callData = accountContract.interface.encodeFunctionData("execute", [
1561
- tokenAddress,
1562
- 0,
1563
- transferCalldata
1564
- ]);
1584
+ callData = encodeFn(AIRACCOUNT_ABI_PARSED, "execute", [tokenAddress, 0n, transferCalldata]);
1565
1585
  } else {
1566
- callData = accountContract.interface.encodeFunctionData("execute", [
1567
- to,
1568
- ethers.parseEther(amount),
1569
- data
1570
- ]);
1586
+ callData = encodeFn(AIRACCOUNT_ABI_PARSED, "execute", [to, parseEther(amount), data]);
1571
1587
  }
1572
1588
  if (wrapExecuteUserOpFlag) {
1573
1589
  callData = wrapExecuteUserOp(callData);
1574
1590
  }
1575
1591
  const gasPrices = await this.ethereum.getUserOperationGasPrice();
1576
- const isV07 = version === "0.7" || version === "0.8";
1592
+ const isV07 = version === "0.7" /* V0_7 */ || version === "0.8" /* V0_8 */;
1577
1593
  let baseUserOp;
1578
1594
  if (isV07) {
1579
1595
  let factory;
@@ -1670,13 +1686,13 @@ var TransferManager = class {
1670
1686
  paymasterAndData,
1671
1687
  signature: "0x"
1672
1688
  };
1673
- if (version === "0.7" || version === "0.8") {
1689
+ if (version === "0.7" /* V0_7 */ || version === "0.8" /* V0_8 */) {
1674
1690
  return ERC4337Utils.packUserOperation(standardUserOp);
1675
1691
  }
1676
1692
  return standardUserOp;
1677
1693
  }
1678
- formatUserOpForBundler(userOp, version = "0.6") {
1679
- if (version === "0.7" || version === "0.8") {
1694
+ formatUserOpForBundler(userOp, version = "0.6" /* V0_6 */) {
1695
+ if (version === "0.7" /* V0_7 */ || version === "0.8" /* V0_8 */) {
1680
1696
  const packedOp = userOp;
1681
1697
  const gasLimits = ERC4337Utils.unpackAccountGasLimits(packedOp.accountGasLimits);
1682
1698
  const gasFees = ERC4337Utils.unpackGasFees(packedOp.gasFees);
@@ -1743,181 +1759,6 @@ var TransferManager = class {
1743
1759
  };
1744
1760
  }
1745
1761
  };
1746
- var BLSManager = class {
1747
- config;
1748
- constructor(config) {
1749
- this.config = config;
1750
- }
1751
- /**
1752
- * Discover available BLS nodes from seed nodes (Gossip network)
1753
- */
1754
- async getAvailableNodes() {
1755
- const { seedNodes, discoveryTimeout = 5e3 } = this.config;
1756
- for (const seedEndpoint of seedNodes) {
1757
- try {
1758
- const response = await axios.get(`${seedEndpoint}/gossip/peers`, {
1759
- timeout: discoveryTimeout
1760
- });
1761
- const peers = response.data.peers || [];
1762
- const activeNodes = peers.filter((p) => p.status === "active" && p.apiEndpoint && p.publicKey).map((p, index) => ({
1763
- index: index + 1,
1764
- // 1-based index likely expected by contract if using bitmap
1765
- nodeId: p.nodeId,
1766
- nodeName: p.nodeName,
1767
- apiEndpoint: p.apiEndpoint,
1768
- status: "active",
1769
- publicKey: p.publicKey
1770
- }));
1771
- if (activeNodes.length > 0) {
1772
- return activeNodes;
1773
- }
1774
- } catch {
1775
- continue;
1776
- }
1777
- }
1778
- return [];
1779
- }
1780
- /**
1781
- * Helper to pack the full signature for ERC-4337 UserOp
1782
- * Format: [nodeIdsLength][nodeIds...][blsSignature][messagePoint][aaSignature][messagePointSignature]
1783
- */
1784
- packSignature(data) {
1785
- if (!data.nodeIds || !data.aaSignature || !data.messagePointSignature) {
1786
- throw new Error("Missing required signature components");
1787
- }
1788
- const nodeIdsLength = ethers.solidityPacked(["uint256"], [data.nodeIds.length]);
1789
- const nodeIdsBytes = ethers.solidityPacked(
1790
- Array(data.nodeIds.length).fill("bytes32"),
1791
- data.nodeIds
1792
- );
1793
- return ethers.solidityPacked(
1794
- ["bytes", "bytes", "bytes", "bytes", "bytes", "bytes"],
1795
- [
1796
- nodeIdsLength,
1797
- nodeIdsBytes,
1798
- data.signature,
1799
- data.messagePoint,
1800
- data.aaSignature,
1801
- data.messagePointSignature
1802
- ]
1803
- );
1804
- }
1805
- /**
1806
- * Calculate the MessagePoint G2 point for a given message (UserOpHash)
1807
- */
1808
- async generateMessagePoint(message) {
1809
- const messageBytes = typeof message === "string" ? ethers.getBytes(message) : message;
1810
- const DST = "BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_";
1811
- const messagePointBLS = await bls12_381.G2.hashToCurve(messageBytes, { DST });
1812
- const messageG2EIP = this.encodeG2Point(messagePointBLS);
1813
- return "0x" + Buffer.from(messageG2EIP).toString("hex");
1814
- }
1815
- /**
1816
- * Encode G2 Point to bytes for EIP-2537 format
1817
- */
1818
- encodeG2Point(point) {
1819
- const result = new Uint8Array(256);
1820
- const affine = point.toAffine();
1821
- const x0Bytes = this.hexToBytes(affine.x.c0.toString(16).padStart(96, "0"));
1822
- const x1Bytes = this.hexToBytes(affine.x.c1.toString(16).padStart(96, "0"));
1823
- const y0Bytes = this.hexToBytes(affine.y.c0.toString(16).padStart(96, "0"));
1824
- const y1Bytes = this.hexToBytes(affine.y.c1.toString(16).padStart(96, "0"));
1825
- result.set(x0Bytes, 16);
1826
- result.set(x1Bytes, 80);
1827
- result.set(y0Bytes, 144);
1828
- result.set(y1Bytes, 208);
1829
- return result;
1830
- }
1831
- hexToBytes(hex) {
1832
- if (hex.startsWith("0x")) hex = hex.slice(2);
1833
- const bytes = new Uint8Array(hex.length / 2);
1834
- for (let i = 0; i < hex.length; i += 2) {
1835
- bytes[i / 2] = parseInt(hex.substr(i, 2), 16);
1836
- }
1837
- return bytes;
1838
- }
1839
- /**
1840
- * Pack cumulative Tier 2 signature (algId 0x04): P256 + BLS.
1841
- *
1842
- * Format:
1843
- * [algId=0x04 (1)] [P256 r (32)] [P256 s (32)]
1844
- * [nodeIdsLength (32)] [nodeIds (N×32)]
1845
- * [blsAggregateSig (256)] [messagePoint (256)]
1846
- * [messagePointECDSA (65)]
1847
- */
1848
- packCumulativeT2Signature(data) {
1849
- const nodeIdsLength = ethers.solidityPacked(["uint256"], [data.nodeIds.length]);
1850
- const nodeIdsBytes = ethers.solidityPacked(
1851
- Array(data.nodeIds.length).fill("bytes32"),
1852
- data.nodeIds
1853
- );
1854
- return ethers.solidityPacked(
1855
- ["bytes1", "bytes", "bytes", "bytes", "bytes", "bytes", "bytes"],
1856
- [
1857
- "0x04",
1858
- data.p256Signature,
1859
- nodeIdsLength,
1860
- nodeIdsBytes,
1861
- data.blsSignature,
1862
- data.messagePoint,
1863
- data.messagePointSignature
1864
- ]
1865
- );
1866
- }
1867
- /**
1868
- * Pack cumulative Tier 3 signature (algId 0x05): P256 + BLS + Guardian.
1869
- *
1870
- * Format:
1871
- * [algId=0x05 (1)] [P256 r (32)] [P256 s (32)]
1872
- * [nodeIdsLength (32)] [nodeIds (N×32)]
1873
- * [blsAggregateSig (256)] [messagePoint (256)]
1874
- * [messagePointECDSA (65)] [guardianECDSA (65)]
1875
- */
1876
- packCumulativeT3Signature(data) {
1877
- const nodeIdsLength = ethers.solidityPacked(["uint256"], [data.nodeIds.length]);
1878
- const nodeIdsBytes = ethers.solidityPacked(
1879
- Array(data.nodeIds.length).fill("bytes32"),
1880
- data.nodeIds
1881
- );
1882
- return ethers.solidityPacked(
1883
- ["bytes1", "bytes", "bytes", "bytes", "bytes", "bytes", "bytes", "bytes"],
1884
- [
1885
- "0x05",
1886
- data.p256Signature,
1887
- nodeIdsLength,
1888
- nodeIdsBytes,
1889
- data.blsSignature,
1890
- data.messagePoint,
1891
- data.messagePointSignature,
1892
- data.guardianSignature
1893
- ]
1894
- );
1895
- }
1896
- /**
1897
- * Request signature from a single node
1898
- */
1899
- async requestNodeSignature(node, message) {
1900
- const response = await axios.post(`${node.apiEndpoint}/signature/sign`, {
1901
- message
1902
- });
1903
- const signatureEIP = response.data.signature;
1904
- const signature = response.data.signatureCompact || signatureEIP;
1905
- return {
1906
- signature: signature.startsWith("0x") ? signature : `0x${signature}`,
1907
- publicKey: response.data.publicKey
1908
- };
1909
- }
1910
- /**
1911
- * Request aggregation from a node
1912
- */
1913
- async aggregateSignatures(node, signatures) {
1914
- const response = await axios.post(`${node.apiEndpoint}/signature/aggregate`, {
1915
- signatures
1916
- });
1917
- const sig = response.data.signature;
1918
- return sig.startsWith("0x") ? sig : `0x${sig}`;
1919
- }
1920
- };
1921
1762
  var DvtPendingConfirmationError = class extends Error {
1922
1763
  constructor(userOpHash, nodeEndpoint) {
1923
1764
  super(
@@ -2016,16 +1857,23 @@ var BLSSignatureService = class {
2016
1857
  if (!account) {
2017
1858
  throw new Error(`User account not found for userId: ${userId}`);
2018
1859
  }
2019
- const wallet = await this.signer.getSigner(userId, ctx);
2020
- const walletAddress = await wallet.getAddress();
1860
+ const walletAddress = await this.signer.getAddress(userId);
2021
1861
  if (walletAddress.toLowerCase() !== account.signerAddress.toLowerCase()) {
2022
1862
  throw new Error(
2023
1863
  `Wallet address mismatch! Wallet: ${walletAddress}, Expected: ${account.signerAddress}`
2024
1864
  );
2025
1865
  }
2026
- const aaSignature = await wallet.signMessage(ethers.getBytes(userOpHash));
2027
- const messagePointHash = ethers.keccak256(messagePoint);
2028
- const messagePointSignature = await wallet.signMessage(ethers.getBytes(messagePointHash));
1866
+ const aaSignature = await this.signer.signMessage(
1867
+ userId,
1868
+ hexToBytes(userOpHash),
1869
+ ctx
1870
+ );
1871
+ const messagePointHash = keccak256(messagePoint);
1872
+ const messagePointSignature = await this.signer.signMessage(
1873
+ userId,
1874
+ hexToBytes(messagePointHash),
1875
+ ctx
1876
+ );
2029
1877
  return {
2030
1878
  nodeIds: signerNodeIds,
2031
1879
  signature: aggregatedSignature,
@@ -2051,7 +1899,7 @@ var BLSSignatureService = class {
2051
1899
  * @param userId - User ID for account lookup
2052
1900
  * @param userOpHash - The UserOp hash to sign
2053
1901
  * @param p256Signature - P256 passkey signature (64 bytes, required for tier 2/3)
2054
- * @param guardianSigner - Guardian ethers.Signer (required for tier 3)
1902
+ * @param guardianSigner - Guardian signer (required for tier 3)
2055
1903
  * @param ctx - Optional passkey assertion context for KMS signing
2056
1904
  */
2057
1905
  async generateTieredSignature(params) {
@@ -2060,8 +1908,7 @@ var BLSSignatureService = class {
2060
1908
  if (tier === 1) {
2061
1909
  const account = await this.storage.findAccountByUserId(userId);
2062
1910
  if (!account) throw new Error(`User account not found for userId: ${userId}`);
2063
- const wallet = await this.signer.getSigner(userId, ctx);
2064
- return wallet.signMessage(ethers.getBytes(userOpHash));
1911
+ return this.signer.signMessage(userId, hexToBytes(userOpHash), ctx);
2065
1912
  }
2066
1913
  if (!p256Signature) {
2067
1914
  throw new Error(`P256 signature required for Tier ${tier}`);
@@ -2080,7 +1927,9 @@ var BLSSignatureService = class {
2080
1927
  if (!guardianSigner) {
2081
1928
  throw new Error("Guardian signer required for Tier 3");
2082
1929
  }
2083
- const guardianSignature = await guardianSigner.signMessage(ethers.getBytes(userOpHash));
1930
+ const guardianSignature = await guardianSigner.signMessage(
1931
+ hexToBytes(userOpHash)
1932
+ );
2084
1933
  const t3Data = {
2085
1934
  p256Signature,
2086
1935
  nodeIds: blsData.nodeIds,
@@ -2092,17 +1941,18 @@ var BLSSignatureService = class {
2092
1941
  return manager.packCumulativeT3Signature(t3Data);
2093
1942
  }
2094
1943
  };
1944
+ var ERC20_ABI_PARSED = parseAbi(ERC20_ABI);
2095
1945
  var TokenService = class {
2096
1946
  constructor(ethereum) {
2097
1947
  this.ethereum = ethereum;
2098
1948
  }
2099
1949
  async getTokenInfo(tokenAddress) {
2100
- const provider = this.ethereum.getProvider();
2101
- const contract = new ethers.Contract(tokenAddress, ERC20_ABI, provider);
1950
+ const client = this.ethereum.getProvider();
1951
+ const address = tokenAddress;
2102
1952
  const [name, symbol, decimals] = await Promise.all([
2103
- contract.name(),
2104
- contract.symbol(),
2105
- contract.decimals()
1953
+ client.readContract({ address, abi: ERC20_ABI_PARSED, functionName: "name" }),
1954
+ client.readContract({ address, abi: ERC20_ABI_PARSED, functionName: "symbol" }),
1955
+ client.readContract({ address, abi: ERC20_ABI_PARSED, functionName: "decimals" })
2106
1956
  ]);
2107
1957
  return {
2108
1958
  address: tokenAddress.toLowerCase(),
@@ -2112,10 +1962,14 @@ var TokenService = class {
2112
1962
  };
2113
1963
  }
2114
1964
  async getTokenBalance(tokenAddress, walletAddress) {
2115
- const provider = this.ethereum.getProvider();
2116
- const contract = new ethers.Contract(tokenAddress, ERC20_ABI, provider);
1965
+ const client = this.ethereum.getProvider();
2117
1966
  try {
2118
- const balance = await contract.balanceOf(walletAddress);
1967
+ const balance = await client.readContract({
1968
+ address: tokenAddress,
1969
+ abi: ERC20_ABI_PARSED,
1970
+ functionName: "balanceOf",
1971
+ args: [walletAddress]
1972
+ });
2119
1973
  return balance.toString();
2120
1974
  } catch {
2121
1975
  return "0";
@@ -2124,20 +1978,27 @@ var TokenService = class {
2124
1978
  async getFormattedTokenBalance(tokenAddress, walletAddress) {
2125
1979
  const tokenInfo = await this.getTokenInfo(tokenAddress);
2126
1980
  const rawBalance = await this.getTokenBalance(tokenAddress, walletAddress);
2127
- const formattedBalance = ethers.formatUnits(rawBalance, tokenInfo.decimals);
1981
+ const formattedBalance = formatUnits(BigInt(rawBalance), tokenInfo.decimals);
2128
1982
  return { token: tokenInfo, balance: rawBalance, formattedBalance };
2129
1983
  }
2130
1984
  generateTransferCalldata(to, amount, decimals) {
2131
- const contract = new ethers.Contract(ethers.ZeroAddress, ERC20_ABI);
2132
- const parsedAmount = ethers.parseUnits(amount, decimals);
2133
- return contract.interface.encodeFunctionData("transfer", [to, parsedAmount]);
1985
+ const parsedAmount = parseUnits(amount, decimals);
1986
+ return encodeFunctionData({
1987
+ abi: ERC20_ABI_PARSED,
1988
+ functionName: "transfer",
1989
+ args: [to, parsedAmount]
1990
+ });
2134
1991
  }
2135
1992
  async validateToken(tokenAddress) {
2136
1993
  try {
2137
- const provider = this.ethereum.getProvider();
2138
- const contract = new ethers.Contract(tokenAddress, ERC20_ABI, provider);
1994
+ const client = this.ethereum.getProvider();
1995
+ const address = tokenAddress;
2139
1996
  const [name, symbol, decimals] = await Promise.race([
2140
- Promise.all([contract.name(), contract.symbol(), contract.decimals()]),
1997
+ Promise.all([
1998
+ client.readContract({ address, abi: ERC20_ABI_PARSED, functionName: "name" }),
1999
+ client.readContract({ address, abi: ERC20_ABI_PARSED, functionName: "symbol" }),
2000
+ client.readContract({ address, abi: ERC20_ABI_PARSED, functionName: "decimals" })
2001
+ ]),
2141
2002
  new Promise((_, reject) => setTimeout(() => reject(new Error("Timeout")), 1e4))
2142
2003
  ]);
2143
2004
  return {
@@ -2157,6 +2018,8 @@ var TokenService = class {
2157
2018
  }
2158
2019
  }
2159
2020
  };
2021
+
2022
+ // ../airaccount/src/server/services/wallet-manager.ts
2160
2023
  var WalletManager = class {
2161
2024
  constructor(signer) {
2162
2025
  this.signer = signer;
@@ -2164,14 +2027,16 @@ var WalletManager = class {
2164
2027
  async getAddress(userId) {
2165
2028
  return this.signer.getAddress(userId);
2166
2029
  }
2167
- async getSigner(userId) {
2168
- return this.signer.getSigner(userId);
2030
+ async signMessage(userId, message, ctx) {
2031
+ return this.signer.signMessage(userId, message, ctx);
2169
2032
  }
2170
2033
  async ensureSigner(userId) {
2171
2034
  return this.signer.ensureSigner(userId);
2172
2035
  }
2173
2036
  };
2174
- var YAAAServerClient = class {
2037
+
2038
+ // ../airaccount/src/server/server-client.ts
2039
+ var AirAccountServerClient = class {
2175
2040
  ethereum;
2176
2041
  accounts;
2177
2042
  transfers;
@@ -2206,24 +2071,47 @@ var YAAAServerClient = class {
2206
2071
  );
2207
2072
  }
2208
2073
  };
2074
+ var YAAAServerClient = AirAccountServerClient;
2075
+ function hashMessage(message) {
2076
+ if (typeof message === "string") return hashMessage$1(message);
2077
+ return hashMessage$1({ raw: message });
2078
+ }
2079
+ async function recoverAddress(hash, signature) {
2080
+ return recoverAddress$1({ hash, signature });
2081
+ }
2082
+ function buildAuthorizationHash(chainId, nonce, delegateAddress) {
2083
+ const encoded = toRlp([
2084
+ chainId === 0 ? "0x" : numberToHex(chainId),
2085
+ delegateAddress,
2086
+ nonce === 0n ? "0x" : numberToHex(nonce)
2087
+ ]);
2088
+ return keccak256$1(concatHex(["0x05", encoded]));
2089
+ }
2090
+ async function verifyAuthorization(eoa, chainId, nonce, signature, delegateAddress) {
2091
+ const hash = buildAuthorizationHash(chainId, nonce, delegateAddress);
2092
+ const recovered = await recoverAddress(hash, signature);
2093
+ return recovered.toLowerCase() === eoa.toLowerCase();
2094
+ }
2095
+
2096
+ // ../airaccount/src/server/services/module-manager.ts
2209
2097
  function buildInstallModuleHash(chainId, account, moduleTypeId, module, moduleInitData = "0x") {
2210
- const moduleInitDataHash = ethers.keccak256(moduleInitData);
2211
- const raw = ethers.keccak256(
2212
- ethers.solidityPacked(
2098
+ const moduleInitDataHash = keccak256(moduleInitData);
2099
+ const raw = keccak256(
2100
+ solidityPacked(
2213
2101
  ["string", "uint256", "address", "uint256", "address", "bytes32"],
2214
- ["INSTALL_MODULE", chainId, account, moduleTypeId, module, moduleInitDataHash]
2102
+ ["INSTALL_MODULE", BigInt(chainId), account, BigInt(moduleTypeId), module, moduleInitDataHash]
2215
2103
  )
2216
2104
  );
2217
- return ethers.hashMessage(ethers.getBytes(raw));
2105
+ return hashMessage(hexToBytes(raw));
2218
2106
  }
2219
2107
  function buildUninstallModuleHash(chainId, account, moduleTypeId, module) {
2220
- const raw = ethers.keccak256(
2221
- ethers.solidityPacked(
2108
+ const raw = keccak256(
2109
+ solidityPacked(
2222
2110
  ["string", "uint256", "address", "uint256", "address"],
2223
- ["UNINSTALL_MODULE", chainId, account, moduleTypeId, module]
2111
+ ["UNINSTALL_MODULE", BigInt(chainId), account, BigInt(moduleTypeId), module]
2224
2112
  )
2225
2113
  );
2226
- return ethers.hashMessage(ethers.getBytes(raw));
2114
+ return hashMessage(hexToBytes(raw));
2227
2115
  }
2228
2116
  var ModuleManager = class {
2229
2117
  provider;
@@ -2239,13 +2127,12 @@ var ModuleManager = class {
2239
2127
  encodeInstall(params) {
2240
2128
  const sigs = params.guardianSigs ?? [];
2241
2129
  const initData = params.moduleInitData ?? "0x";
2242
- const packed = sigs.length > 0 ? ethers.concat([...sigs.map((s) => ethers.getBytes(s)), ethers.getBytes(initData)]) : ethers.getBytes(initData);
2243
- const iface = new ethers.Interface(AIRACCOUNT_ABI);
2244
- return iface.encodeFunctionData("installModule", [
2245
- params.moduleTypeId,
2246
- params.module,
2247
- packed
2248
- ]);
2130
+ const packed = sigs.length > 0 ? concat([...sigs, initData]) : initData;
2131
+ return encodeFunctionData({
2132
+ abi: parseAbi(AIRACCOUNT_ABI),
2133
+ functionName: "installModule",
2134
+ args: [BigInt(params.moduleTypeId), params.module, packed]
2135
+ });
2249
2136
  }
2250
2137
  /**
2251
2138
  * Encode calldata for uninstallModule().
@@ -2253,22 +2140,25 @@ var ModuleManager = class {
2253
2140
  */
2254
2141
  encodeUninstall(params) {
2255
2142
  const deInitData = params.moduleDeInitData ?? "0x";
2256
- const packed = ethers.concat([
2257
- ethers.getBytes(params.guardianSig1),
2258
- ethers.getBytes(params.guardianSig2),
2259
- ethers.getBytes(deInitData)
2260
- ]);
2261
- const iface = new ethers.Interface(AIRACCOUNT_ABI);
2262
- return iface.encodeFunctionData("uninstallModule", [
2263
- params.moduleTypeId,
2264
- params.module,
2265
- packed
2143
+ const packed = concat([
2144
+ params.guardianSig1,
2145
+ params.guardianSig2,
2146
+ deInitData
2266
2147
  ]);
2148
+ return encodeFunctionData({
2149
+ abi: parseAbi(AIRACCOUNT_ABI),
2150
+ functionName: "uninstallModule",
2151
+ args: [BigInt(params.moduleTypeId), params.module, packed]
2152
+ });
2267
2153
  }
2268
2154
  /** Check if a module is currently installed on the account. */
2269
2155
  async isInstalled(account, moduleTypeId, module) {
2270
- const contract = new ethers.Contract(account, AIRACCOUNT_ABI, this.provider);
2271
- return contract.isModuleInstalled(moduleTypeId, module, "0x");
2156
+ return await this.provider.readContract({
2157
+ address: account,
2158
+ abi: parseAbi(AIRACCOUNT_ABI),
2159
+ functionName: "isModuleInstalled",
2160
+ args: [BigInt(moduleTypeId), module, "0x"]
2161
+ });
2272
2162
  }
2273
2163
  /** Return the install hash for a guardian to sign (r5 format, includes moduleInitData hash). */
2274
2164
  installHash(account, moduleTypeId, module, moduleInitData = "0x") {
@@ -2302,10 +2192,12 @@ var ModuleManager = class {
2302
2192
  };
2303
2193
  }
2304
2194
  };
2195
+ var SESSION_KEY_VALIDATOR_VIEM_ABI = parseAbi(SESSION_KEY_VALIDATOR_ABI);
2196
+ var AGENT_SESSION_KEY_VALIDATOR_VIEM_ABI = parseAbi(AGENT_SESSION_KEY_VALIDATOR_ABI);
2305
2197
  function buildSessionStruct(params) {
2306
2198
  return {
2307
2199
  expiry: params.expiry,
2308
- contractScope: params.contractScope ?? ethers.ZeroAddress,
2200
+ contractScope: params.contractScope ?? zeroAddress,
2309
2201
  selectorScope: params.selectorScope ?? "0x00000000",
2310
2202
  revoked: false,
2311
2203
  velocityLimit: params.velocityLimit ?? 0,
@@ -2316,36 +2208,34 @@ function buildSessionStruct(params) {
2316
2208
  }
2317
2209
  function decodeSessionInfo(session) {
2318
2210
  const s = session;
2319
- const expiry = Number(s[0]);
2211
+ const expiry = Number(s.expiry);
2320
2212
  const now = Math.floor(Date.now() / 1e3);
2321
2213
  return {
2322
2214
  expiry,
2323
- contractScope: s[1],
2324
- selectorScope: s[2],
2325
- revoked: s[3],
2326
- velocityLimit: Number(s[4]),
2327
- velocityWindow: Number(s[5]),
2328
- callTargets: [...s[6] ?? []],
2329
- selectorAllowlist: [...s[7] ?? []],
2330
- active: expiry > now && !s[3]
2215
+ contractScope: s.contractScope,
2216
+ selectorScope: s.selectorScope,
2217
+ revoked: s.revoked,
2218
+ velocityLimit: Number(s.velocityLimit),
2219
+ velocityWindow: Number(s.velocityWindow),
2220
+ callTargets: [...s.callTargets ?? []],
2221
+ selectorAllowlist: [...s.selectorAllowlist ?? []],
2222
+ active: expiry > now && !s.revoked
2331
2223
  };
2332
2224
  }
2333
2225
  var SessionKeyService = class {
2334
- provider;
2335
2226
  skValidator;
2336
2227
  askValidator;
2337
2228
  constructor(provider, sessionKeyValidatorAddress, agentSessionKeyValidatorAddress) {
2338
- this.provider = provider;
2339
- this.skValidator = new ethers.Contract(
2340
- sessionKeyValidatorAddress,
2341
- SESSION_KEY_VALIDATOR_ABI,
2342
- provider
2343
- );
2344
- this.askValidator = new ethers.Contract(
2345
- agentSessionKeyValidatorAddress,
2346
- AGENT_SESSION_KEY_VALIDATOR_ABI,
2347
- provider
2348
- );
2229
+ this.skValidator = getContract({
2230
+ address: sessionKeyValidatorAddress,
2231
+ abi: SESSION_KEY_VALIDATOR_VIEM_ABI,
2232
+ client: provider
2233
+ });
2234
+ this.askValidator = getContract({
2235
+ address: agentSessionKeyValidatorAddress,
2236
+ abi: AGENT_SESSION_KEY_VALIDATOR_VIEM_ABI,
2237
+ client: provider
2238
+ });
2349
2239
  }
2350
2240
  // ── M6: Basic Session Keys ────────────────────────────────────
2351
2241
  /**
@@ -2353,7 +2243,8 @@ var SessionKeyService = class {
2353
2243
  * Use grantSession() with this sig, or grantSessionDirect() from the account itself.
2354
2244
  */
2355
2245
  async buildGrantHash(params) {
2356
- return this.skValidator.buildGrantHash(
2246
+ return readBuildGrantHash(
2247
+ this.skValidator,
2357
2248
  params.account,
2358
2249
  params.sessionKey,
2359
2250
  buildSessionStruct(params)
@@ -2361,12 +2252,12 @@ var SessionKeyService = class {
2361
2252
  }
2362
2253
  /** Query an ECDSA session key state (decodes the 8-field Session tuple). */
2363
2254
  async getSession(account, sessionKey) {
2364
- const session = await this.skValidator.getSession(account, sessionKey);
2255
+ const session = await this.skValidator.read.getSession([account, sessionKey]);
2365
2256
  return decodeSessionInfo(session);
2366
2257
  }
2367
2258
  /** Check if an ECDSA session is currently active. */
2368
2259
  async isSessionActive(account, sessionKey) {
2369
- return this.skValidator.isSessionActive(account, sessionKey);
2260
+ return this.skValidator.read.isSessionActive([account, sessionKey]);
2370
2261
  }
2371
2262
  /**
2372
2263
  * Encode calldata for session grant.
@@ -2382,26 +2273,27 @@ var SessionKeyService = class {
2382
2273
  * Do NOT encode this for a UserOp callData; the EntryPoint is not the owner EOA.
2383
2274
  */
2384
2275
  encodeGrantSession(params) {
2385
- const iface = new ethers.Interface(SESSION_KEY_VALIDATOR_ABI);
2386
2276
  const cfg = buildSessionStruct(params);
2387
2277
  if (params.ownerSig) {
2388
- return iface.encodeFunctionData("grantSession", [
2389
- params.account,
2390
- params.sessionKey,
2391
- cfg,
2392
- params.ownerSig
2393
- ]);
2278
+ return encodeFunctionData({
2279
+ abi: SESSION_KEY_VALIDATOR_VIEM_ABI,
2280
+ functionName: "grantSession",
2281
+ args: [params.account, params.sessionKey, cfg, params.ownerSig]
2282
+ });
2394
2283
  }
2395
- return iface.encodeFunctionData("grantSessionDirect", [
2396
- params.account,
2397
- params.sessionKey,
2398
- cfg
2399
- ]);
2284
+ return encodeFunctionData({
2285
+ abi: SESSION_KEY_VALIDATOR_VIEM_ABI,
2286
+ functionName: "grantSessionDirect",
2287
+ args: [params.account, params.sessionKey, cfg]
2288
+ });
2400
2289
  }
2401
2290
  /** Encode calldata for revokeSession(). */
2402
2291
  encodeRevokeSession(account, sessionKey) {
2403
- const iface = new ethers.Interface(SESSION_KEY_VALIDATOR_ABI);
2404
- return iface.encodeFunctionData("revokeSession", [account, sessionKey]);
2292
+ return encodeFunctionData({
2293
+ abi: SESSION_KEY_VALIDATOR_VIEM_ABI,
2294
+ functionName: "revokeSession",
2295
+ args: [account, sessionKey]
2296
+ });
2405
2297
  }
2406
2298
  // ── M6: P256 / Passkey Session Keys ───────────────────────────
2407
2299
  /**
@@ -2410,7 +2302,8 @@ var SessionKeyService = class {
2410
2302
  * The owner/KMS signs this hash to authorize a gasless grantP256Session().
2411
2303
  */
2412
2304
  async buildP256GrantHash(params) {
2413
- return this.skValidator.buildP256GrantHash(
2305
+ return readBuildP256GrantHash(
2306
+ this.skValidator,
2414
2307
  params.account,
2415
2308
  params.keyX,
2416
2309
  params.keyY,
@@ -2422,12 +2315,12 @@ var SessionKeyService = class {
2422
2315
  * @param keyHash The keccak256 hash of (keyX, keyY) used as the on-chain session id.
2423
2316
  */
2424
2317
  async getP256Session(account, keyHash) {
2425
- const session = await this.skValidator.getP256Session(account, keyHash);
2318
+ const session = await this.skValidator.read.getP256Session([account, keyHash]);
2426
2319
  return decodeSessionInfo(session);
2427
2320
  }
2428
2321
  /** Check if a P256 session is currently active. */
2429
2322
  async isP256SessionActive(account, keyX, keyY) {
2430
- return this.skValidator.isP256SessionActive(account, keyX, keyY);
2323
+ return this.skValidator.read.isP256SessionActive([account, keyX, keyY]);
2431
2324
  }
2432
2325
  /**
2433
2326
  * Encode calldata for a P256/passkey session grant.
@@ -2443,28 +2336,27 @@ var SessionKeyService = class {
2443
2336
  * Do NOT encode this for a UserOp callData; the EntryPoint is not the owner EOA.
2444
2337
  */
2445
2338
  encodeGrantP256Session(params) {
2446
- const iface = new ethers.Interface(SESSION_KEY_VALIDATOR_ABI);
2447
2339
  const cfg = buildSessionStruct(params);
2448
2340
  if (params.ownerSig) {
2449
- return iface.encodeFunctionData("grantP256Session", [
2450
- params.account,
2451
- params.keyX,
2452
- params.keyY,
2453
- cfg,
2454
- params.ownerSig
2455
- ]);
2341
+ return encodeFunctionData({
2342
+ abi: SESSION_KEY_VALIDATOR_VIEM_ABI,
2343
+ functionName: "grantP256Session",
2344
+ args: [params.account, params.keyX, params.keyY, cfg, params.ownerSig]
2345
+ });
2456
2346
  }
2457
- return iface.encodeFunctionData("grantP256SessionDirect", [
2458
- params.account,
2459
- params.keyX,
2460
- params.keyY,
2461
- cfg
2462
- ]);
2347
+ return encodeFunctionData({
2348
+ abi: SESSION_KEY_VALIDATOR_VIEM_ABI,
2349
+ functionName: "grantP256SessionDirect",
2350
+ args: [params.account, params.keyX, params.keyY, cfg]
2351
+ });
2463
2352
  }
2464
2353
  /** Encode calldata for revokeP256Session(). */
2465
2354
  encodeRevokeP256Session(account, keyX, keyY) {
2466
- const iface = new ethers.Interface(SESSION_KEY_VALIDATOR_ABI);
2467
- return iface.encodeFunctionData("revokeP256Session", [account, keyX, keyY]);
2355
+ return encodeFunctionData({
2356
+ abi: SESSION_KEY_VALIDATOR_VIEM_ABI,
2357
+ functionName: "revokeP256Session",
2358
+ args: [account, keyX, keyY]
2359
+ });
2468
2360
  }
2469
2361
  // ── M7: Agent Session Keys ────────────────────────────────────
2470
2362
  /**
@@ -2473,18 +2365,21 @@ var SessionKeyService = class {
2473
2365
  * The contract uses msg.sender as the account — no account param needed.
2474
2366
  */
2475
2367
  encodeGrantAgentSession(sessionKey, cfg) {
2476
- const iface = new ethers.Interface(AGENT_SESSION_KEY_VALIDATOR_ABI);
2477
- return iface.encodeFunctionData("grantAgentSession", [
2478
- sessionKey,
2479
- {
2480
- expiry: cfg.expiry,
2481
- velocityLimit: cfg.velocityLimit,
2482
- velocityWindow: cfg.velocityWindow,
2483
- revoked: false,
2484
- callTargets: cfg.callTargets,
2485
- selectorAllowlist: cfg.selectorAllowlist
2486
- }
2487
- ]);
2368
+ return encodeFunctionData({
2369
+ abi: AGENT_SESSION_KEY_VALIDATOR_VIEM_ABI,
2370
+ functionName: "grantAgentSession",
2371
+ args: [
2372
+ sessionKey,
2373
+ {
2374
+ expiry: cfg.expiry,
2375
+ velocityLimit: cfg.velocityLimit,
2376
+ velocityWindow: cfg.velocityWindow,
2377
+ revoked: false,
2378
+ callTargets: cfg.callTargets,
2379
+ selectorAllowlist: cfg.selectorAllowlist
2380
+ }
2381
+ ]
2382
+ });
2488
2383
  }
2489
2384
  /**
2490
2385
  * Encode calldata for delegateSession() — sub-agent delegation.
@@ -2493,29 +2388,35 @@ var SessionKeyService = class {
2493
2388
  * @param account The smart account under which the parent session was granted.
2494
2389
  */
2495
2390
  encodeDelegateSession(account, subKey, subCfg) {
2496
- const iface = new ethers.Interface(AGENT_SESSION_KEY_VALIDATOR_ABI);
2497
- return iface.encodeFunctionData("delegateSession", [
2498
- account,
2499
- subKey,
2500
- {
2501
- expiry: subCfg.expiry,
2502
- velocityLimit: subCfg.velocityLimit,
2503
- velocityWindow: subCfg.velocityWindow,
2504
- revoked: false,
2505
- callTargets: subCfg.callTargets,
2506
- selectorAllowlist: subCfg.selectorAllowlist
2507
- }
2508
- ]);
2391
+ return encodeFunctionData({
2392
+ abi: AGENT_SESSION_KEY_VALIDATOR_VIEM_ABI,
2393
+ functionName: "delegateSession",
2394
+ args: [
2395
+ account,
2396
+ subKey,
2397
+ {
2398
+ expiry: subCfg.expiry,
2399
+ velocityLimit: subCfg.velocityLimit,
2400
+ velocityWindow: subCfg.velocityWindow,
2401
+ revoked: false,
2402
+ callTargets: subCfg.callTargets,
2403
+ selectorAllowlist: subCfg.selectorAllowlist
2404
+ }
2405
+ ]
2406
+ });
2509
2407
  }
2510
2408
  /** Encode calldata for revokeAgentSession(). */
2511
2409
  encodeRevokeAgentSession(sessionKey) {
2512
- const iface = new ethers.Interface(AGENT_SESSION_KEY_VALIDATOR_ABI);
2513
- return iface.encodeFunctionData("revokeAgentSession", [sessionKey]);
2410
+ return encodeFunctionData({
2411
+ abi: AGENT_SESSION_KEY_VALIDATOR_VIEM_ABI,
2412
+ functionName: "revokeAgentSession",
2413
+ args: [sessionKey]
2414
+ });
2514
2415
  }
2515
2416
  /** Query agent session config + runtime state. */
2516
2417
  async getAgentSession(account, sessionKey) {
2517
- const [expiry, velocityLimit, velocityWindow, revoked, callTargets, selectorAllowlist] = await this.askValidator.agentSessions(account, sessionKey);
2518
- const [callCount, windowStart] = await this.askValidator.sessionStates(account, sessionKey);
2418
+ const [expiry, velocityLimit, velocityWindow, revoked, callTargets, selectorAllowlist] = await this.askValidator.read.agentSessions([account, sessionKey]);
2419
+ const [callCount, windowStart] = await this.askValidator.read.sessionStates([account, sessionKey]);
2519
2420
  return {
2520
2421
  expiry: Number(expiry),
2521
2422
  velocityLimit: Number(velocityLimit),
@@ -2534,11 +2435,11 @@ var SessionKeyService = class {
2534
2435
  }
2535
2436
  /** Return the parent account of a delegated session key. */
2536
2437
  async getSessionKeyOwner(sessionKey) {
2537
- return this.askValidator.sessionKeyOwner(sessionKey);
2438
+ return this.askValidator.read.sessionKeyOwner([sessionKey]);
2538
2439
  }
2539
2440
  /** Return the parent key that delegated to subKey, or ZeroAddress if not delegated. */
2540
2441
  async getDelegatedBy(account, subKey) {
2541
- return this.askValidator.delegatedBy(account, subKey);
2442
+ return this.askValidator.read.delegatedBy([account, subKey]);
2542
2443
  }
2543
2444
  };
2544
2445
  function packSecp256k1SessionSignature(account, sessionKey, signature) {
@@ -2575,28 +2476,46 @@ var GuardStateReader = class {
2575
2476
  constructor(provider) {
2576
2477
  this.provider = provider;
2577
2478
  }
2479
+ accountContract(accountAddress) {
2480
+ return getContract({
2481
+ address: accountAddress,
2482
+ abi: parseAbi(AIRACCOUNT_ABI),
2483
+ client: this.provider
2484
+ });
2485
+ }
2486
+ guardContract(guardAddress) {
2487
+ return getContract({
2488
+ address: guardAddress,
2489
+ abi: parseAbi(EXTENDED_GUARD_ABI),
2490
+ client: this.provider
2491
+ });
2492
+ }
2578
2493
  /**
2579
2494
  * Read the full ETH guard state for an account.
2580
2495
  * Returns null if the account has no guard (dailyLimit=0).
2581
2496
  */
2582
2497
  async getGuardState(accountAddress) {
2583
- const account = new ethers.Contract(accountAddress, AIRACCOUNT_ABI, this.provider);
2584
- const guardAddress = await account.guard();
2585
- if (guardAddress === ethers.ZeroAddress) return null;
2586
- const guard = new ethers.Contract(guardAddress, EXTENDED_GUARD_ABI, this.provider);
2498
+ const account = this.accountContract(accountAddress).read;
2499
+ const guardAddress = await account.guard([]);
2500
+ if (guardAddress === zeroAddress) return null;
2501
+ const guard = this.guardContract(guardAddress).read;
2587
2502
  const [dailyLimit, remaining, todaySpent, tier1Limit, tier2Limit, minDailyLimit] = await Promise.all([
2588
- guard.dailyLimit(),
2589
- guard.remainingDailyAllowance(),
2590
- guard.todaySpent(),
2591
- guard.tier1Limit().catch(() => 0n),
2592
- guard.tier2Limit().catch(() => 0n),
2593
- guard.minDailyLimit().catch(() => 0n)
2503
+ guard.dailyLimit([]),
2504
+ guard.remainingDailyAllowance([]),
2505
+ guard.todaySpent([]),
2506
+ guard.tier1Limit([]).catch(() => 0n),
2507
+ guard.tier2Limit([]).catch(() => 0n),
2508
+ guard.minDailyLimit([]).catch(() => 0n)
2594
2509
  ]);
2595
2510
  return {
2596
2511
  dailyLimit: BigInt(dailyLimit),
2597
2512
  todaySpent: BigInt(todaySpent),
2598
2513
  remaining: BigInt(remaining),
2599
- currentTier: resolveTierFromSpend(BigInt(todaySpent), BigInt(tier1Limit), BigInt(tier2Limit)),
2514
+ currentTier: resolveTierFromSpend(
2515
+ BigInt(todaySpent),
2516
+ BigInt(tier1Limit),
2517
+ BigInt(tier2Limit)
2518
+ ),
2600
2519
  tier1Limit: BigInt(tier1Limit),
2601
2520
  tier2Limit: BigInt(tier2Limit),
2602
2521
  minDailyLimit: BigInt(minDailyLimit),
@@ -2608,12 +2527,12 @@ var GuardStateReader = class {
2608
2527
  * Returns null if the token is not configured on the guard.
2609
2528
  */
2610
2529
  async getTokenGuardState(accountAddress, token) {
2611
- const account = new ethers.Contract(accountAddress, AIRACCOUNT_ABI, this.provider);
2612
- const guardAddress = await account.guard();
2613
- if (guardAddress === ethers.ZeroAddress) return null;
2614
- const guard = new ethers.Contract(guardAddress, EXTENDED_GUARD_ABI, this.provider);
2530
+ const account = this.accountContract(accountAddress).read;
2531
+ const guardAddress = await account.guard([]);
2532
+ if (guardAddress === zeroAddress) return null;
2533
+ const guard = this.guardContract(guardAddress).read;
2615
2534
  try {
2616
- const todaySpent = await guard.tokenTodaySpent(token);
2535
+ const todaySpent = await guard.tokenTodaySpent([token]);
2617
2536
  return {
2618
2537
  token,
2619
2538
  todaySpent: BigInt(todaySpent),
@@ -2642,8 +2561,8 @@ var GuardStateReader = class {
2642
2561
  * Check if a given algorithm ID is approved on the guard.
2643
2562
  */
2644
2563
  async isAlgorithmApproved(accountAddress, algId) {
2645
- const account = new ethers.Contract(accountAddress, AIRACCOUNT_ABI, this.provider);
2646
- return account.approvedAlgorithms(algId);
2564
+ const account = this.accountContract(accountAddress).read;
2565
+ return await account.approvedAlgorithms([BigInt(algId)]);
2647
2566
  }
2648
2567
  };
2649
2568
  function resolveTierFromSpend(spent, tier1Limit, tier2Limit) {
@@ -2652,52 +2571,36 @@ function resolveTierFromSpend(spent, tier1Limit, tier2Limit) {
2652
2571
  if (tier2Limit === 0n || spent < tier2Limit) return 2;
2653
2572
  return 3;
2654
2573
  }
2574
+ var FACTORY_ABI = parseAbi(AIRACCOUNT_FACTORY_ABI);
2655
2575
  function computeOapdSalt(owner, dappId) {
2656
- const packed = ethers.solidityPacked(["address", "string"], [owner, dappId]);
2657
- return BigInt(ethers.keccak256(packed));
2576
+ const packed = solidityPacked(["address", "string"], [owner, dappId]);
2577
+ return BigInt(keccak256(packed));
2658
2578
  }
2659
2579
  async function getOapdAddress(provider, config) {
2660
2580
  const factoryAddress = config.factoryAddress ?? AIRACCOUNT_ADDRESSES.sepolia.factory;
2661
- const factory = new ethers.Contract(factoryAddress, AIRACCOUNT_FACTORY_ABI, provider);
2662
2581
  const salt = computeOapdSalt(config.owner, config.dappId);
2663
- return factory.getFunction("getAddress")(config.owner, salt, config.initConfig);
2582
+ return provider.readContract({
2583
+ address: factoryAddress,
2584
+ abi: FACTORY_ABI,
2585
+ functionName: "getAddress",
2586
+ args: [config.owner, salt, config.initConfig]
2587
+ });
2664
2588
  }
2665
2589
  async function getOapdAddressWithChainId(provider, config) {
2666
2590
  const factoryAddress = config.factoryAddress ?? AIRACCOUNT_ADDRESSES.sepolia.factory;
2667
- const factory = new ethers.Contract(factoryAddress, AIRACCOUNT_FACTORY_ABI, provider);
2668
2591
  const salt = computeOapdSalt(config.owner, config.dappId);
2669
- const result = await factory.getFunction("getAddressWithChainId")(
2670
- config.owner,
2671
- salt,
2672
- config.initConfig
2673
- );
2592
+ const result = await provider.readContract({
2593
+ address: factoryAddress,
2594
+ abi: FACTORY_ABI,
2595
+ functionName: "getAddressWithChainId",
2596
+ args: [config.owner, salt, config.initConfig]
2597
+ });
2674
2598
  return { address: result[0], chainQualified: result[1] };
2675
2599
  }
2676
2600
  async function isOapdDeployed(provider, config) {
2677
2601
  const address = await getOapdAddress(provider, config);
2678
- const code = await provider.getCode(address);
2679
- return code !== "0x";
2680
- }
2681
- var ALG_BLS = 1;
2682
- var ALG_ECDSA = 2;
2683
- var ALG_P256 = 3;
2684
- var ALG_CUMULATIVE_T2 = 4;
2685
- var ALG_CUMULATIVE_T3 = 5;
2686
- function resolveTier(value, config) {
2687
- if (config.tier1Limit === 0n && config.tier2Limit === 0n) return 1;
2688
- if (config.tier1Limit > 0n && value <= config.tier1Limit) return 1;
2689
- if (config.tier2Limit > 0n && value <= config.tier2Limit) return 2;
2690
- return 3;
2691
- }
2692
- function algIdForTier(tier) {
2693
- switch (tier) {
2694
- case 1:
2695
- return ALG_ECDSA;
2696
- case 2:
2697
- return ALG_CUMULATIVE_T2;
2698
- case 3:
2699
- return ALG_CUMULATIVE_T3;
2700
- }
2602
+ const code = await provider.getCode({ address });
2603
+ return code !== void 0 && code !== "0x";
2701
2604
  }
2702
2605
  var ALG_NAMES = {
2703
2606
  [ALG_BLS]: "BLS (0x01)",
@@ -2716,43 +2619,34 @@ var GuardChecker = class {
2716
2619
  * Fetch tier limits from an AirAccount contract.
2717
2620
  */
2718
2621
  async fetchTierConfig(accountAddress) {
2719
- const provider = this.ethereum.getProvider();
2720
- const account = new ethers.Contract(accountAddress, AIRACCOUNT_ABI, provider);
2721
- const [tier1Limit, tier2Limit] = await Promise.all([
2722
- account.tier1Limit(),
2723
- account.tier2Limit()
2724
- ]);
2725
- return {
2726
- tier1Limit: BigInt(tier1Limit),
2727
- tier2Limit: BigInt(tier2Limit)
2728
- };
2622
+ const account = this.ethereum.getAccountContract(accountAddress);
2623
+ return readAccountTierLimits(account);
2729
2624
  }
2730
2625
  /**
2731
2626
  * Fetch guard status from the account's GlobalGuard.
2732
2627
  */
2733
2628
  async fetchGuardStatus(accountAddress) {
2734
- const provider = this.ethereum.getProvider();
2735
- const account = new ethers.Contract(accountAddress, AIRACCOUNT_ABI, provider);
2736
- const config = await account.getConfigDescription();
2737
- const guardAddress = config.guardAddress;
2738
- if (guardAddress === ethers.ZeroAddress) {
2629
+ const account = this.ethereum.getAccountContract(accountAddress);
2630
+ const guardAddress = await readAccountGuardAddress(account);
2631
+ if (guardAddress === zeroAddress) {
2739
2632
  return {
2740
2633
  hasGuard: false,
2741
- guardAddress: ethers.ZeroAddress,
2634
+ guardAddress: zeroAddress,
2742
2635
  dailyLimit: 0n,
2743
2636
  dailyRemaining: 0n
2744
2637
  };
2745
2638
  }
2746
- const guard = new ethers.Contract(guardAddress, GLOBAL_GUARD_ABI, provider);
2747
- const [dailyLimit, dailyRemaining] = await Promise.all([
2748
- guard.dailyLimit(),
2749
- guard.remainingDailyAllowance()
2750
- ]);
2639
+ const guard = getContract({
2640
+ address: guardAddress,
2641
+ abi: parseAbi(GLOBAL_GUARD_ABI),
2642
+ client: this.ethereum.getProvider()
2643
+ });
2644
+ const { dailyLimit, dailyRemaining } = await readGuardDailyAllowance(guard);
2751
2645
  return {
2752
2646
  hasGuard: true,
2753
2647
  guardAddress,
2754
- dailyLimit: BigInt(dailyLimit),
2755
- dailyRemaining: BigInt(dailyRemaining)
2648
+ dailyLimit,
2649
+ dailyRemaining
2756
2650
  };
2757
2651
  }
2758
2652
  /**
@@ -2773,9 +2667,8 @@ var GuardChecker = class {
2773
2667
  `Daily limit exceeded: requesting ${value} wei but only ${guard.dailyRemaining} remaining (limit: ${guard.dailyLimit})`
2774
2668
  );
2775
2669
  }
2776
- const provider = this.ethereum.getProvider();
2777
- const accountContract = new ethers.Contract(accountAddress, AIRACCOUNT_ABI, provider);
2778
- const isApproved = await accountContract.approvedAlgorithms(algId);
2670
+ const accountContract = this.ethereum.getAccountContract(accountAddress);
2671
+ const isApproved = await readAlgorithmApproved(accountContract, algId);
2779
2672
  if (!isApproved) {
2780
2673
  errors.push(
2781
2674
  `Algorithm ${ALG_NAMES[algId] ?? `0x${algId.toString(16)}`} is not approved by the account`
@@ -2816,24 +2709,29 @@ var FORCE_EXIT_ABI = [
2816
2709
  "error SignerNoLongerGuardian()",
2817
2710
  "error UnsupportedL2Type()"
2818
2711
  ];
2712
+ var FORCE_EXIT_PARSED_ABI = parseAbi(FORCE_EXIT_ABI);
2819
2713
  var L2_TYPE = {
2820
2714
  OPTIMISM: 1,
2821
2715
  ARBITRUM: 2
2822
2716
  };
2823
2717
  var ForceExitService = class {
2824
- constructor(moduleAddress, providerOrSigner) {
2718
+ constructor(moduleAddress, client) {
2825
2719
  this.moduleAddress = moduleAddress;
2826
- this.contract = new ethers.Contract(moduleAddress, FORCE_EXIT_ABI, providerOrSigner);
2827
- this.iface = new ethers.Interface(FORCE_EXIT_ABI);
2720
+ this.contract = getContract({
2721
+ address: moduleAddress,
2722
+ abi: FORCE_EXIT_PARSED_ABI,
2723
+ // viem inspects the client's actions at runtime to expose read/write; the
2724
+ // cast only satisfies the static union — a wallet client still yields writes.
2725
+ client
2726
+ });
2828
2727
  }
2829
2728
  contract;
2830
- iface;
2831
2729
  // ── On-chain reads ──────────────────────────────────────────────
2832
2730
  async isInitialized(smartAccount) {
2833
- return this.contract.isInitialized(smartAccount);
2731
+ return await this.contract.read.isInitialized([smartAccount]);
2834
2732
  }
2835
2733
  async getPendingExit(account) {
2836
- const [target, value, data, proposedAt, approvalBitmap, guardians] = await this.contract.getPendingExit(account);
2734
+ const [target, value, data, proposedAt, approvalBitmap, guardians] = await this.contract.read.getPendingExit([account]);
2837
2735
  return {
2838
2736
  target,
2839
2737
  value: BigInt(value),
@@ -2844,13 +2742,13 @@ var ForceExitService = class {
2844
2742
  };
2845
2743
  }
2846
2744
  async getAccountL2Type(account) {
2847
- return Number(await this.contract.accountL2Type(account));
2745
+ return Number(await this.contract.read.accountL2Type([account]));
2848
2746
  }
2849
2747
  async getApprovalThreshold() {
2850
- return Number(await this.contract.APPROVAL_THRESHOLD());
2748
+ return Number(await this.contract.read.APPROVAL_THRESHOLD([]));
2851
2749
  }
2852
2750
  async getModuleVersion() {
2853
- return this.contract.MODULE_VERSION();
2751
+ return await this.contract.read.MODULE_VERSION([]);
2854
2752
  }
2855
2753
  // ── Calldata encoders (for UserOp or direct tx submission) ─────
2856
2754
  /**
@@ -2863,47 +2761,77 @@ var ForceExitService = class {
2863
2761
  * // account.installModule(2, forceExitModuleAddress, calldata)
2864
2762
  */
2865
2763
  encodeOnInstall(l2Type) {
2866
- return this.iface.encodeFunctionData("onInstall", [
2867
- ethers.AbiCoder.defaultAbiCoder().encode(["uint8"], [l2Type])
2868
- ]);
2764
+ return encodeFunctionData({
2765
+ abi: FORCE_EXIT_PARSED_ABI,
2766
+ functionName: "onInstall",
2767
+ args: [encodeAbiParams(["uint8"], [l2Type])]
2768
+ });
2869
2769
  }
2870
2770
  encodeOnUninstall() {
2871
- return this.iface.encodeFunctionData("onUninstall", ["0x"]);
2771
+ return encodeFunctionData({
2772
+ abi: FORCE_EXIT_PARSED_ABI,
2773
+ functionName: "onUninstall",
2774
+ args: ["0x"]
2775
+ });
2872
2776
  }
2873
2777
  /**
2874
2778
  * Encode calldata for proposeForceExit — the exit payload to bridge out of L2.
2875
2779
  * `target` is the L2→L1 bridge contract; `data` is the bridge call payload.
2876
2780
  */
2877
2781
  encodeProposeForceExit(target, value, data) {
2878
- return this.iface.encodeFunctionData("proposeForceExit", [target, value, data]);
2782
+ return encodeFunctionData({
2783
+ abi: FORCE_EXIT_PARSED_ABI,
2784
+ functionName: "proposeForceExit",
2785
+ args: [target, value, data]
2786
+ });
2879
2787
  }
2880
2788
  /**
2881
2789
  * Encode calldata for approveForceExit — guardian signs off on the pending proposal.
2882
2790
  * `guardianSig` must be an EIP-191 personal_sign over the proposal hash.
2883
2791
  */
2884
2792
  encodeApproveForceExit(account, guardianSig) {
2885
- return this.iface.encodeFunctionData("approveForceExit", [account, guardianSig]);
2793
+ return encodeFunctionData({
2794
+ abi: FORCE_EXIT_PARSED_ABI,
2795
+ functionName: "approveForceExit",
2796
+ args: [account, guardianSig]
2797
+ });
2886
2798
  }
2887
2799
  encodeExecuteForceExit(account) {
2888
- return this.iface.encodeFunctionData("executeForceExit", [account]);
2800
+ return encodeFunctionData({
2801
+ abi: FORCE_EXIT_PARSED_ABI,
2802
+ functionName: "executeForceExit",
2803
+ args: [account]
2804
+ });
2889
2805
  }
2890
2806
  encodeCancelForceExit(account) {
2891
- return this.iface.encodeFunctionData("cancelForceExit", [account]);
2807
+ return encodeFunctionData({
2808
+ abi: FORCE_EXIT_PARSED_ABI,
2809
+ functionName: "cancelForceExit",
2810
+ args: [account]
2811
+ });
2892
2812
  }
2893
- // ── Convenience: send transactions (requires Signer) ──────────
2813
+ // ── Convenience: send transactions (requires a WalletClient) ──────────
2894
2814
  async proposeForceExit(target, value, data) {
2895
- return this.contract.proposeForceExit(target, value, data);
2815
+ return await this.contract.write.proposeForceExit([
2816
+ target,
2817
+ value,
2818
+ data
2819
+ ]);
2896
2820
  }
2897
2821
  async approveForceExit(account, guardianSig) {
2898
- return this.contract.approveForceExit(account, guardianSig);
2822
+ return await this.contract.write.approveForceExit([
2823
+ account,
2824
+ guardianSig
2825
+ ]);
2899
2826
  }
2900
2827
  async executeForceExit(account) {
2901
- return this.contract.executeForceExit(account);
2828
+ return await this.contract.write.executeForceExit([account]);
2902
2829
  }
2903
2830
  async cancelForceExit(account) {
2904
- return this.contract.cancelForceExit(account);
2831
+ return await this.contract.write.cancelForceExit([account]);
2905
2832
  }
2906
2833
  };
2834
+ var AIRACCOUNT_ABI_PARSED2 = parseAbi(AIRACCOUNT_ABI);
2907
2835
  var RECOVERY_THRESHOLD = 2;
2908
2836
  var MAX_GUARDIANS = 3;
2909
2837
  var RECOVERY_TIMELOCK_SECONDS = 2n * 24n * 60n * 60n;
@@ -2917,11 +2845,14 @@ function popcount(value) {
2917
2845
  return count;
2918
2846
  }
2919
2847
  var RecoveryService = class {
2920
- constructor(providerOrSigner) {
2921
- this.providerOrSigner = providerOrSigner;
2922
- this.iface = new ethers.Interface(AIRACCOUNT_ABI);
2848
+ /**
2849
+ * @param client viem read client (was `ethers.Provider | ethers.Signer`). Only
2850
+ * on-chain reads are performed here; calldata encoders are pure and never
2851
+ * touch the client.
2852
+ */
2853
+ constructor(client) {
2854
+ this.client = client;
2923
2855
  }
2924
- iface;
2925
2856
  // ── Calldata encoders (submit TO the account address) ─────────────
2926
2857
  /**
2927
2858
  * Encode `addGuardian(guardian)` calldata. **Owner only.**
@@ -2929,7 +2860,11 @@ var RecoveryService = class {
2929
2860
  * guardian is `address(0)`, the owner, or already registered.
2930
2861
  */
2931
2862
  encodeAddGuardian(guardian) {
2932
- return this.iface.encodeFunctionData("addGuardian", [guardian]);
2863
+ return encodeFunctionData({
2864
+ abi: AIRACCOUNT_ABI_PARSED2,
2865
+ functionName: "addGuardian",
2866
+ args: [guardian]
2867
+ });
2933
2868
  }
2934
2869
  /**
2935
2870
  * Encode `removeGuardian(index, guardianSigs)` calldata. **Owner only**, and
@@ -2940,7 +2875,11 @@ var RecoveryService = class {
2940
2875
  * @param guardianSigs EIP-191 guardian signatures over the removal hash.
2941
2876
  */
2942
2877
  encodeRemoveGuardian(index, guardianSigs) {
2943
- return this.iface.encodeFunctionData("removeGuardian", [index, guardianSigs]);
2878
+ return encodeFunctionData({
2879
+ abi: AIRACCOUNT_ABI_PARSED2,
2880
+ functionName: "removeGuardian",
2881
+ args: [index, guardianSigs]
2882
+ });
2944
2883
  }
2945
2884
  /**
2946
2885
  * Encode `proposeRecovery(newOwner)` calldata. **Any guardian** may call.
@@ -2948,14 +2887,22 @@ var RecoveryService = class {
2948
2887
  * proposer's approval (1 of {@link RECOVERY_THRESHOLD}).
2949
2888
  */
2950
2889
  encodeProposeRecovery(newOwner) {
2951
- return this.iface.encodeFunctionData("proposeRecovery", [newOwner]);
2890
+ return encodeFunctionData({
2891
+ abi: AIRACCOUNT_ABI_PARSED2,
2892
+ functionName: "proposeRecovery",
2893
+ args: [newOwner]
2894
+ });
2952
2895
  }
2953
2896
  /**
2954
2897
  * Encode `approveRecovery()` calldata. **Another guardian** approves the
2955
2898
  * active proposal, setting its bit in `approvalBitmap`.
2956
2899
  */
2957
2900
  encodeApproveRecovery() {
2958
- return this.iface.encodeFunctionData("approveRecovery", []);
2901
+ return encodeFunctionData({
2902
+ abi: AIRACCOUNT_ABI_PARSED2,
2903
+ functionName: "approveRecovery",
2904
+ args: []
2905
+ });
2959
2906
  }
2960
2907
  /**
2961
2908
  * Encode `cancelRecovery()` calldata. **Guardians only** — each call is one
@@ -2963,7 +2910,11 @@ var RecoveryService = class {
2963
2910
  * reached. The owner cannot cancel.
2964
2911
  */
2965
2912
  encodeCancelRecovery() {
2966
- return this.iface.encodeFunctionData("cancelRecovery", []);
2913
+ return encodeFunctionData({
2914
+ abi: AIRACCOUNT_ABI_PARSED2,
2915
+ functionName: "cancelRecovery",
2916
+ args: []
2917
+ });
2967
2918
  }
2968
2919
  /**
2969
2920
  * Encode `executeRecovery()` calldata. **Anyone** may call, but it only
@@ -2971,7 +2922,11 @@ var RecoveryService = class {
2971
2922
  * Rotates the account owner to the proposed `newOwner`.
2972
2923
  */
2973
2924
  encodeExecuteRecovery() {
2974
- return this.iface.encodeFunctionData("executeRecovery", []);
2925
+ return encodeFunctionData({
2926
+ abi: AIRACCOUNT_ABI_PARSED2,
2927
+ functionName: "executeRecovery",
2928
+ args: []
2929
+ });
2975
2930
  }
2976
2931
  // ── On-chain reads (against the account address) ──────────────────
2977
2932
  /**
@@ -2982,8 +2937,11 @@ var RecoveryService = class {
2982
2937
  * @param account The AirAccount address to query.
2983
2938
  */
2984
2939
  async getActiveRecovery(account) {
2985
- const contract = new ethers.Contract(account, AIRACCOUNT_ABI, this.providerOrSigner);
2986
- const [newOwner, proposedAt, approvalBitmap, cancellationBitmap] = await contract.activeRecovery();
2940
+ const [newOwner, proposedAt, approvalBitmap, cancellationBitmap] = await this.client.readContract({
2941
+ address: account,
2942
+ abi: AIRACCOUNT_ABI_PARSED2,
2943
+ functionName: "activeRecovery"
2944
+ });
2987
2945
  const proposedAtBn = BigInt(proposedAt);
2988
2946
  const approvalBitmapBn = BigInt(approvalBitmap);
2989
2947
  const cancellationBitmapBn = BigInt(cancellationBitmap);
@@ -2995,7 +2953,7 @@ var RecoveryService = class {
2995
2953
  approvalCount: popcount(approvalBitmapBn),
2996
2954
  cancellationCount: popcount(cancellationBitmapBn),
2997
2955
  executeAfter: proposedAtBn + RECOVERY_TIMELOCK_SECONDS,
2998
- isActive: newOwner !== ethers.ZeroAddress
2956
+ isActive: newOwner.toLowerCase() !== zeroAddress
2999
2957
  };
3000
2958
  }
3001
2959
  /**
@@ -3004,8 +2962,12 @@ var RecoveryService = class {
3004
2962
  * @param account The AirAccount address to query.
3005
2963
  */
3006
2964
  async getGuardianCount(account) {
3007
- const contract = new ethers.Contract(account, AIRACCOUNT_ABI, this.providerOrSigner);
3008
- return Number(await contract.guardianCount());
2965
+ const count = await this.client.readContract({
2966
+ address: account,
2967
+ abi: AIRACCOUNT_ABI_PARSED2,
2968
+ functionName: "guardianCount"
2969
+ });
2970
+ return Number(count);
3009
2971
  }
3010
2972
  /**
3011
2973
  * Read the full guardian address list.
@@ -3018,12 +2980,22 @@ var RecoveryService = class {
3018
2980
  * @param account The AirAccount address to query.
3019
2981
  */
3020
2982
  async getGuardians(account) {
3021
- const contract = new ethers.Contract(account, AIRACCOUNT_ABI, this.providerOrSigner);
3022
- const count = Number(await contract.guardianCount());
2983
+ const count = Number(
2984
+ await this.client.readContract({
2985
+ address: account,
2986
+ abi: AIRACCOUNT_ABI_PARSED2,
2987
+ functionName: "guardianCount"
2988
+ })
2989
+ );
3023
2990
  const guardians = [];
3024
2991
  for (let i = 0; i < count; i++) {
3025
- const g = await contract.guardians(i);
3026
- if (g !== ethers.ZeroAddress) guardians.push(g);
2992
+ const g = await this.client.readContract({
2993
+ address: account,
2994
+ abi: AIRACCOUNT_ABI_PARSED2,
2995
+ functionName: "guardians",
2996
+ args: [BigInt(i)]
2997
+ });
2998
+ if (g.toLowerCase() !== zeroAddress) guardians.push(g);
3027
2999
  }
3028
3000
  return guardians;
3029
3001
  }
@@ -3051,17 +3023,15 @@ var DELEGATE_ABI = [
3051
3023
  ];
3052
3024
  var AIR_ACCOUNT_DELEGATE_ADDRESS = "0x8603AAF6C3f07fdae810B323c95a198D796EC52E";
3053
3025
  var EIP7702DelegateService = class {
3054
- constructor(delegateAddress = AIR_ACCOUNT_DELEGATE_ADDRESS, providerOrSigner) {
3026
+ constructor(delegateAddress = AIR_ACCOUNT_DELEGATE_ADDRESS, client) {
3055
3027
  this.delegateAddress = delegateAddress;
3056
- this.iface = new ethers.Interface(DELEGATE_ABI);
3057
- if (providerOrSigner) {
3058
- this.contract = new ethers.Contract(delegateAddress, DELEGATE_ABI, providerOrSigner);
3059
- } else {
3060
- this.contract = new ethers.Contract(delegateAddress, DELEGATE_ABI);
3061
- }
3028
+ this.abi = parseAbi(DELEGATE_ABI);
3029
+ this.client = client;
3062
3030
  }
3063
- iface;
3064
- contract;
3031
+ /** Parsed ABI (loose viem `Abi` shape) used for encoding calldata and on-chain reads. */
3032
+ abi;
3033
+ /** Optional viem read client (was `ethers.Provider | ethers.Signer`). Required only for on-chain reads. */
3034
+ client;
3065
3035
  // ── Calldata encoders ─────────────────────────────────────────
3066
3036
  /**
3067
3037
  * Encode initialize() calldata for the first post-delegation UserOp.
@@ -3069,19 +3039,31 @@ var EIP7702DelegateService = class {
3069
3039
  * Guardian acceptance sigs follow the same EIP-712 scheme as AirAccountV7 createAccount.
3070
3040
  */
3071
3041
  encodeInitialize(params) {
3072
- return this.iface.encodeFunctionData("initialize", [
3073
- params.guardian1,
3074
- params.guardian1Sig,
3075
- params.guardian2,
3076
- params.guardian2Sig,
3077
- params.dailyLimit
3078
- ]);
3042
+ return encodeFunctionData({
3043
+ abi: this.abi,
3044
+ functionName: "initialize",
3045
+ args: [
3046
+ params.guardian1,
3047
+ params.guardian1Sig,
3048
+ params.guardian2,
3049
+ params.guardian2Sig,
3050
+ params.dailyLimit
3051
+ ]
3052
+ });
3079
3053
  }
3080
3054
  encodeExecute(dest, value, data) {
3081
- return this.iface.encodeFunctionData("execute", [dest, value, data]);
3055
+ return encodeFunctionData({
3056
+ abi: this.abi,
3057
+ functionName: "execute",
3058
+ args: [dest, value, data]
3059
+ });
3082
3060
  }
3083
3061
  encodeExecuteBatch(dests, values, datas) {
3084
- return this.iface.encodeFunctionData("executeBatch", [dests, values, datas]);
3062
+ return encodeFunctionData({
3063
+ abi: this.abi,
3064
+ functionName: "executeBatch",
3065
+ args: [dests, values, datas]
3066
+ });
3085
3067
  }
3086
3068
  // ── EIP-7702 authorization hash construction ──────────────────
3087
3069
  /**
@@ -3091,19 +3073,14 @@ var EIP7702DelegateService = class {
3091
3073
  *
3092
3074
  * This is the hash the private key signs to delegate code execution to
3093
3075
  * AirAccountDelegate. Use this hash with your KMS sign-hash endpoint or
3094
- * local ethers Signer.
3076
+ * local viem account.
3095
3077
  *
3096
3078
  * @param chainId - Target chain ID (11155111 for Sepolia)
3097
3079
  * @param nonce - EOA's current transaction nonce
3098
3080
  * @returns 32-byte hash (0x-prefixed) ready for signing
3099
3081
  */
3100
3082
  buildAuthorizationHash(chainId, nonce) {
3101
- const encoded = ethers.encodeRlp([
3102
- chainId === 0 ? "0x" : ethers.toBeHex(chainId),
3103
- this.delegateAddress,
3104
- nonce === 0n ? "0x" : ethers.toBeHex(nonce)
3105
- ]);
3106
- return ethers.keccak256(ethers.concat(["0x05", encoded]));
3083
+ return buildAuthorizationHash(chainId, nonce, this.delegateAddress);
3107
3084
  }
3108
3085
  /**
3109
3086
  * Build the full EIP-7702 authorization object for relay submission.
@@ -3124,30 +3101,42 @@ var EIP7702DelegateService = class {
3124
3101
  /**
3125
3102
  * Verify that a signature is a valid EIP-7702 authorization for the given EOA address.
3126
3103
  * Recovers the signer from the authorization hash and checks it matches `eoa`.
3104
+ *
3105
+ * NOTE: now async — viem's `recoverAddress` is asynchronous (ethers' was sync).
3127
3106
  */
3128
3107
  verifyAuthorization(eoa, chainId, nonce, signature) {
3129
- const hash = this.buildAuthorizationHash(chainId, nonce);
3130
- const recovered = ethers.recoverAddress(hash, signature);
3131
- return recovered.toLowerCase() === eoa.toLowerCase();
3108
+ return verifyAuthorization(
3109
+ eoa,
3110
+ chainId,
3111
+ nonce,
3112
+ signature,
3113
+ this.delegateAddress
3114
+ );
3132
3115
  }
3133
3116
  // ── On-chain reads (requires provider) ───────────────────────
3134
3117
  async isInitialized(eoa) {
3135
- const provider = this.contract.runner;
3136
- if (!provider) throw new Error("EIP7702DelegateService: provider required for on-chain reads");
3137
- const c = new ethers.Contract(eoa, DELEGATE_ABI, provider);
3138
- return c.isInitialized();
3118
+ if (!this.client) throw new Error("EIP7702DelegateService: provider required for on-chain reads");
3119
+ return await this.client.readContract({
3120
+ address: eoa,
3121
+ abi: this.abi,
3122
+ functionName: "isInitialized"
3123
+ });
3139
3124
  }
3140
3125
  async getOwner(eoa) {
3141
- const provider = this.contract.runner;
3142
- if (!provider) throw new Error("EIP7702DelegateService: provider required for on-chain reads");
3143
- const c = new ethers.Contract(eoa, DELEGATE_ABI, provider);
3144
- return c.owner();
3126
+ if (!this.client) throw new Error("EIP7702DelegateService: provider required for on-chain reads");
3127
+ return await this.client.readContract({
3128
+ address: eoa,
3129
+ abi: this.abi,
3130
+ functionName: "owner"
3131
+ });
3145
3132
  }
3146
3133
  async getGuardians(eoa) {
3147
- const provider = this.contract.runner;
3148
- if (!provider) throw new Error("EIP7702DelegateService: provider required for on-chain reads");
3149
- const c = new ethers.Contract(eoa, DELEGATE_ABI, provider);
3150
- return c.getGuardians();
3134
+ if (!this.client) throw new Error("EIP7702DelegateService: provider required for on-chain reads");
3135
+ return await this.client.readContract({
3136
+ address: eoa,
3137
+ abi: this.abi,
3138
+ functionName: "getGuardians"
3139
+ });
3151
3140
  }
3152
3141
  };
3153
3142
  var WEIGHTED_SIGNATURE_ABI = [
@@ -3170,6 +3159,7 @@ var WEIGHTED_SIGNATURE_ABI = [
3170
3159
  "error WeightChangeNotApproved()",
3171
3160
  "error WeightChangeTimelockNotExpired()"
3172
3161
  ];
3162
+ var WEIGHTED_SIGNATURE_ABI_PARSED = parseAbi(WEIGHTED_SIGNATURE_ABI);
3173
3163
  var WEIGHT_CHANGE_TIMELOCK_SECONDS = 2 * 24 * 60 * 60;
3174
3164
  var WEIGHT_CHANGE_THRESHOLD = 2;
3175
3165
  var WEIGHT_CHANGE_EXPIRY_SECONDS = 30 * 24 * 60 * 60;
@@ -3205,17 +3195,20 @@ function fromConfigResult(result) {
3205
3195
  };
3206
3196
  }
3207
3197
  var WeightedSignatureService = class {
3208
- constructor(accountAddress, providerOrSigner) {
3198
+ constructor(accountAddress, client) {
3209
3199
  this.accountAddress = accountAddress;
3210
- this.contract = new ethers.Contract(accountAddress, WEIGHTED_SIGNATURE_ABI, providerOrSigner);
3211
- this.iface = new ethers.Interface(WEIGHTED_SIGNATURE_ABI);
3200
+ this.client = client;
3201
+ this.address = accountAddress;
3212
3202
  }
3213
- contract;
3214
- iface;
3203
+ address;
3215
3204
  // ── On-chain reads ──────────────────────────────────────────────
3216
3205
  /** Read the account's current active WeightConfig. */
3217
3206
  async getWeightConfig() {
3218
- const result = await this.contract.weightConfig();
3207
+ const result = await this.client.readContract({
3208
+ address: this.address,
3209
+ abi: WEIGHTED_SIGNATURE_ABI_PARSED,
3210
+ functionName: "weightConfig"
3211
+ });
3219
3212
  return fromConfigResult(result);
3220
3213
  }
3221
3214
  /**
@@ -3223,7 +3216,11 @@ var WeightedSignatureService = class {
3223
3216
  * active proposal (the returned `proposed` config will be all zeros).
3224
3217
  */
3225
3218
  async getPendingWeightChange() {
3226
- const [proposed, proposedAt, approvalBitmap] = await this.contract.pendingWeightChange();
3219
+ const [proposed, proposedAt, approvalBitmap] = await this.client.readContract({
3220
+ address: this.address,
3221
+ abi: WEIGHTED_SIGNATURE_ABI_PARSED,
3222
+ functionName: "pendingWeightChange"
3223
+ });
3227
3224
  return {
3228
3225
  proposed: fromConfigResult(proposed),
3229
3226
  proposedAt: BigInt(proposedAt),
@@ -3236,29 +3233,46 @@ var WeightedSignatureService = class {
3236
3233
  * Weakening an existing config must go through encodeProposeWeightChange instead.
3237
3234
  */
3238
3235
  encodeSetWeightConfig(config) {
3239
- return this.iface.encodeFunctionData("setWeightConfig", [toConfigTuple(config)]);
3236
+ return encodeFunctionData({
3237
+ abi: WEIGHTED_SIGNATURE_ABI_PARSED,
3238
+ functionName: "setWeightConfig",
3239
+ args: [toConfigTuple(config)]
3240
+ });
3240
3241
  }
3241
3242
  /**
3242
3243
  * Encode proposeWeightChange calldata. OWNER only; opens a guardian-governed proposal
3243
3244
  * (required for any weakening). Subject to 2-of-3 approval + 2-day timelock before execute.
3244
3245
  */
3245
3246
  encodeProposeWeightChange(config) {
3246
- return this.iface.encodeFunctionData("proposeWeightChange", [toConfigTuple(config)]);
3247
+ return encodeFunctionData({
3248
+ abi: WEIGHTED_SIGNATURE_ABI_PARSED,
3249
+ functionName: "proposeWeightChange",
3250
+ args: [toConfigTuple(config)]
3251
+ });
3247
3252
  }
3248
3253
  /** Encode approveWeightChange calldata. GUARDIAN only; each guardian may approve once. */
3249
3254
  encodeApproveWeightChange() {
3250
- return this.iface.encodeFunctionData("approveWeightChange", []);
3255
+ return encodeFunctionData({
3256
+ abi: WEIGHTED_SIGNATURE_ABI_PARSED,
3257
+ functionName: "approveWeightChange"
3258
+ });
3251
3259
  }
3252
3260
  /** Encode cancelWeightChange calldata. OWNER or any GUARDIAN may cancel a pending proposal. */
3253
3261
  encodeCancelWeightChange() {
3254
- return this.iface.encodeFunctionData("cancelWeightChange", []);
3262
+ return encodeFunctionData({
3263
+ abi: WEIGHTED_SIGNATURE_ABI_PARSED,
3264
+ functionName: "cancelWeightChange"
3265
+ });
3255
3266
  }
3256
3267
  /**
3257
3268
  * Encode executeWeightChange calldata. Callable by anyone, but only succeeds once the
3258
3269
  * threshold (2-of-3) and timelock (2 days) are both satisfied and the proposal has not expired.
3259
3270
  */
3260
3271
  encodeExecuteWeightChange() {
3261
- return this.iface.encodeFunctionData("executeWeightChange", []);
3272
+ return encodeFunctionData({
3273
+ abi: WEIGHTED_SIGNATURE_ABI_PARSED,
3274
+ functionName: "executeWeightChange"
3275
+ });
3262
3276
  }
3263
3277
  };
3264
3278
  var AGENT_REGISTRY_ABI = [
@@ -3285,43 +3299,42 @@ var AGENT_REGISTRY_ABI = [
3285
3299
  "error NotAgentOwner()",
3286
3300
  "error SelfRegistrationForbidden()"
3287
3301
  ];
3302
+ var REGISTRY_ABI = parseAbi(AGENT_REGISTRY_ABI);
3303
+ var FACTORY_ABI2 = parseAbi(AIRACCOUNT_FACTORY_ABI);
3304
+ var ACCOUNT_ABI3 = parseAbi(AIRACCOUNT_ABI);
3288
3305
  var AgentRegistryService = class {
3289
3306
  /**
3290
- * @param providerOrSigner ethers Provider (reads only) or Signer (reads + sends).
3291
- * @param registryAddress deployed AgentRegistry contract address.
3307
+ * @param client viem PublicClient for on-chain reads (e.g. `ethereum.getProvider()`).
3308
+ * @param registryAddress deployed AgentRegistry contract address.
3292
3309
  */
3293
- constructor(providerOrSigner, registryAddress) {
3310
+ constructor(client, registryAddress) {
3294
3311
  this.registryAddress = registryAddress;
3295
- this.providerOrSigner = providerOrSigner;
3296
- this.contract = new ethers.Contract(registryAddress, AGENT_REGISTRY_ABI, providerOrSigner);
3297
- this.iface = new ethers.Interface(AGENT_REGISTRY_ABI);
3298
- this.factoryIface = new ethers.Interface(AIRACCOUNT_FACTORY_ABI);
3299
- this.accountIface = new ethers.Interface(AIRACCOUNT_ABI);
3312
+ this.client = client;
3300
3313
  }
3301
- contract;
3302
- iface;
3303
- factoryIface;
3304
- accountIface;
3305
- providerOrSigner;
3314
+ client;
3306
3315
  // ── Composed register/revoke-via-account scenario encoders ──────────────────
3307
3316
  // registerAgent/revokeAgent require msg.sender == the agent account, so they are delivered
3308
3317
  // through the account's execute(registry, 0, calldata). These return the FULL execute
3309
3318
  // calldata to submit TO the agent account (owner-signed) — the scenario-level entry point.
3310
3319
  /** Encode `account.execute(registry, 0, registerAgent(agentWallet, agentWalletSig))`. */
3311
3320
  encodeRegisterAgentViaAccount(agentWallet, agentWalletSig) {
3312
- return this.accountIface.encodeFunctionData("execute", [
3313
- this.registryAddress,
3314
- 0n,
3315
- this.encodeRegisterAgent(agentWallet, agentWalletSig)
3316
- ]);
3321
+ return encodeFunctionData({
3322
+ abi: ACCOUNT_ABI3,
3323
+ functionName: "execute",
3324
+ args: [
3325
+ this.registryAddress,
3326
+ 0n,
3327
+ this.encodeRegisterAgent(agentWallet, agentWalletSig)
3328
+ ]
3329
+ });
3317
3330
  }
3318
3331
  /** Encode `account.execute(registry, 0, revokeAgent(agentWallet))`. */
3319
3332
  encodeRevokeAgentViaAccount(agentWallet) {
3320
- return this.accountIface.encodeFunctionData("execute", [
3321
- this.registryAddress,
3322
- 0n,
3323
- this.encodeRevokeAgent(agentWallet)
3324
- ]);
3333
+ return encodeFunctionData({
3334
+ abi: ACCOUNT_ABI3,
3335
+ functionName: "execute",
3336
+ args: [this.registryAddress, 0n, this.encodeRevokeAgent(agentWallet)]
3337
+ });
3325
3338
  }
3326
3339
  // ── AgentRegistry calldata encoders ─────────────────────────────────────────
3327
3340
  /**
@@ -3333,7 +3346,11 @@ var AgentRegistryService = class {
3333
3346
  * if the wallet is already bound.
3334
3347
  */
3335
3348
  encodeRegisterAgent(agentWallet, agentWalletSig) {
3336
- return this.iface.encodeFunctionData("registerAgent", [agentWallet, agentWalletSig]);
3349
+ return encodeFunctionData({
3350
+ abi: REGISTRY_ABI,
3351
+ functionName: "registerAgent",
3352
+ args: [agentWallet, agentWalletSig]
3353
+ });
3337
3354
  }
3338
3355
  /**
3339
3356
  * Encode calldata for `revokeAgent(agentWallet)`.
@@ -3342,7 +3359,11 @@ var AgentRegistryService = class {
3342
3359
  * agent's human owner (else `NotAgentOwner`).
3343
3360
  */
3344
3361
  encodeRevokeAgent(agentWallet) {
3345
- return this.iface.encodeFunctionData("revokeAgent", [agentWallet]);
3362
+ return encodeFunctionData({
3363
+ abi: REGISTRY_ABI,
3364
+ functionName: "revokeAgent",
3365
+ args: [agentWallet]
3366
+ });
3346
3367
  }
3347
3368
  /**
3348
3369
  * Encode calldata for `deregisterAgent(agentWallet)`.
@@ -3351,32 +3372,68 @@ var AgentRegistryService = class {
3351
3372
  * lighter-weight `revokeAgent`). Caller must be the agent's human owner.
3352
3373
  */
3353
3374
  encodeDeregisterAgent(agentWallet) {
3354
- return this.iface.encodeFunctionData("deregisterAgent", [agentWallet]);
3375
+ return encodeFunctionData({
3376
+ abi: REGISTRY_ABI,
3377
+ functionName: "deregisterAgent",
3378
+ args: [agentWallet]
3379
+ });
3355
3380
  }
3356
3381
  // ── AgentRegistry on-chain reads ────────────────────────────────────────────
3357
3382
  /** Whether `agentWallet` is currently registered in the registry. */
3358
3383
  async isRegisteredAgent(agentWallet) {
3359
- return this.contract.isRegisteredAgent(agentWallet);
3384
+ return await this.client.readContract({
3385
+ address: this.registryAddress,
3386
+ abi: REGISTRY_ABI,
3387
+ functionName: "isRegisteredAgent",
3388
+ args: [agentWallet]
3389
+ });
3360
3390
  }
3361
3391
  /** Whether `account` has been marked valid (e.g. an AirAccount minted by the bound factory). */
3362
3392
  async isValidAccount(account) {
3363
- return this.contract.isValidAccount(account);
3393
+ return await this.client.readContract({
3394
+ address: this.registryAddress,
3395
+ abi: REGISTRY_ABI,
3396
+ functionName: "isValidAccount",
3397
+ args: [account]
3398
+ });
3364
3399
  }
3365
3400
  /** The human owner bound to `agentWallet` (ZeroAddress if unregistered). */
3366
3401
  async getHumanOwner(agentWallet) {
3367
- return this.contract.getHumanOwner(agentWallet);
3402
+ return await this.client.readContract({
3403
+ address: this.registryAddress,
3404
+ abi: REGISTRY_ABI,
3405
+ functionName: "getHumanOwner",
3406
+ args: [agentWallet]
3407
+ });
3368
3408
  }
3369
3409
  /** Number of agents registered under `owner`. */
3370
3410
  async getAgentCount(owner) {
3371
- return BigInt(await this.contract.getAgentCount(owner));
3411
+ return BigInt(
3412
+ await this.client.readContract({
3413
+ address: this.registryAddress,
3414
+ abi: REGISTRY_ABI,
3415
+ functionName: "getAgentCount",
3416
+ args: [owner]
3417
+ })
3418
+ );
3372
3419
  }
3373
3420
  /** The agent wallet at `index` in `owner`'s agent list. */
3374
3421
  async getAgentByIndex(owner, index) {
3375
- return this.contract.getAgentByIndex(owner, index);
3422
+ return await this.client.readContract({
3423
+ address: this.registryAddress,
3424
+ abi: REGISTRY_ABI,
3425
+ functionName: "getAgentByIndex",
3426
+ args: [owner, BigInt(index)]
3427
+ });
3376
3428
  }
3377
3429
  /** Full list of agent wallets registered under `humanOwner`. */
3378
3430
  async getAgents(humanOwner) {
3379
- const result = await this.contract.getAgents(humanOwner);
3431
+ const result = await this.client.readContract({
3432
+ address: this.registryAddress,
3433
+ abi: REGISTRY_ABI,
3434
+ functionName: "getAgents",
3435
+ args: [humanOwner]
3436
+ });
3380
3437
  return Array.from(result);
3381
3438
  }
3382
3439
  /**
@@ -3384,16 +3441,31 @@ var AgentRegistryService = class {
3384
3441
  * The contract clamps `count` to the remaining length, so the returned array may be shorter.
3385
3442
  */
3386
3443
  async getAgentsPage(owner, start, count) {
3387
- const result = await this.contract.getAgentsPage(owner, start, count);
3444
+ const result = await this.client.readContract({
3445
+ address: this.registryAddress,
3446
+ abi: REGISTRY_ABI,
3447
+ functionName: "getAgentsPage",
3448
+ args: [owner, BigInt(start), BigInt(count)]
3449
+ });
3388
3450
  return Array.from(result);
3389
3451
  }
3390
3452
  /** Raw `agentWalletOwner` mapping read (agentWallet → owner). */
3391
3453
  async agentWalletOwner(agentWallet) {
3392
- return this.contract.agentWalletOwner(agentWallet);
3454
+ return await this.client.readContract({
3455
+ address: this.registryAddress,
3456
+ abi: REGISTRY_ABI,
3457
+ functionName: "agentWalletOwner",
3458
+ args: [agentWallet]
3459
+ });
3393
3460
  }
3394
3461
  /** Raw `ownerAgents` array read (owner, index → agentWallet). */
3395
3462
  async ownerAgents(owner, index) {
3396
- return this.contract.ownerAgents(owner, index);
3463
+ return await this.client.readContract({
3464
+ address: this.registryAddress,
3465
+ abi: REGISTRY_ABI,
3466
+ functionName: "ownerAgents",
3467
+ args: [owner, BigInt(index)]
3468
+ });
3397
3469
  }
3398
3470
  // ── Factory agent-account helpers (AAStarAirAccountFactoryV7) ───────────────
3399
3471
  /**
@@ -3404,21 +3476,29 @@ var AgentRegistryService = class {
3404
3476
  * calldata to the factory address (direct tx or via a relayer).
3405
3477
  */
3406
3478
  encodeCreateAgentAccount(params) {
3407
- return this.factoryIface.encodeFunctionData("createAgentAccount", [
3408
- params.agentKey,
3409
- params.agentId,
3410
- params.guardian2,
3411
- params.guardian2Sig,
3412
- params.agentKeySig,
3413
- params.deadline,
3414
- params.dailyLimit
3415
- ]);
3479
+ return encodeFunctionData({
3480
+ abi: FACTORY_ABI2,
3481
+ functionName: "createAgentAccount",
3482
+ args: [
3483
+ params.agentKey,
3484
+ params.agentId,
3485
+ params.guardian2,
3486
+ params.guardian2Sig,
3487
+ params.agentKeySig,
3488
+ BigInt(params.deadline),
3489
+ params.dailyLimit
3490
+ ]
3491
+ });
3416
3492
  }
3417
3493
  /**
3418
3494
  * Encode calldata for the factory's `setAgentRegistry(_agentRegistry)` (factory-admin only).
3419
3495
  */
3420
3496
  encodeSetAgentRegistry(agentRegistry) {
3421
- return this.factoryIface.encodeFunctionData("setAgentRegistry", [agentRegistry]);
3497
+ return encodeFunctionData({
3498
+ abi: FACTORY_ABI2,
3499
+ functionName: "setAgentRegistry",
3500
+ args: [agentRegistry]
3501
+ });
3422
3502
  }
3423
3503
  /**
3424
3504
  * Predict the CREATE2 address of an agent account via the factory's `getAgentAddress(...)`.
@@ -3429,21 +3509,21 @@ var AgentRegistryService = class {
3429
3509
  * @param agentId the bytes32 agent identifier.
3430
3510
  */
3431
3511
  async getAgentAccountAddress(factoryAddress, humanOwner, agentKey, agentId) {
3432
- const factory = new ethers.Contract(
3433
- factoryAddress,
3434
- AIRACCOUNT_FACTORY_ABI,
3435
- this.providerOrSigner
3436
- );
3437
- return factory.getAgentAddress(humanOwner, agentKey, agentId);
3512
+ return await this.client.readContract({
3513
+ address: factoryAddress,
3514
+ abi: FACTORY_ABI2,
3515
+ functionName: "getAgentAddress",
3516
+ args: [humanOwner, agentKey, agentId]
3517
+ });
3438
3518
  }
3439
3519
  /** Read the AgentRegistry address currently bound to the factory. */
3440
3520
  async getFactoryAgentRegistry(factoryAddress) {
3441
- const factory = new ethers.Contract(
3442
- factoryAddress,
3443
- AIRACCOUNT_FACTORY_ABI,
3444
- this.providerOrSigner
3445
- );
3446
- return factory.agentRegistry();
3521
+ return await this.client.readContract({
3522
+ address: factoryAddress,
3523
+ abi: FACTORY_ABI2,
3524
+ functionName: "agentRegistry",
3525
+ args: []
3526
+ });
3447
3527
  }
3448
3528
  };
3449
3529
  var ERC8004_ABI = [
@@ -3474,12 +3554,25 @@ function erc8004AddressesForChain(chainId) {
3474
3554
  throw new Error(`ERC-8004: unsupported chain ${chainId}`);
3475
3555
  }
3476
3556
  var ERC8004Service = class {
3477
- iface;
3557
+ abi;
3478
3558
  provider;
3479
3559
  constructor(provider) {
3480
- this.iface = new ethers.Interface(ERC8004_ABI);
3560
+ this.abi = parseAbi(ERC8004_ABI);
3481
3561
  this.provider = provider;
3482
3562
  }
3563
+ /**
3564
+ * Build a read-only viem contract bound to the account address. The ABI is loaded from
3565
+ * human-readable signatures via `parseAbi` (loose `Abi`), so `read` methods are indexed by
3566
+ * name and return `unknown` — cast at the call site. Mirrors the dynamic surface that
3567
+ * `ethers.Contract` previously exposed. Caller must ensure `this.provider` is set.
3568
+ */
3569
+ contractAt(accountAddress) {
3570
+ return getContract({
3571
+ address: accountAddress,
3572
+ abi: this.abi,
3573
+ client: this.provider
3574
+ });
3575
+ }
3483
3576
  // ── AAStar AgentRegistry path ─────────────────────────────────────────────
3484
3577
  /**
3485
3578
  * Encode calldata for `setAgentWallet`.
@@ -3493,12 +3586,11 @@ var ERC8004Service = class {
3493
3586
  * Callable: owner EOA direct tx OR via UserOp (gasless).
3494
3587
  */
3495
3588
  encodeSetAgentWallet(params) {
3496
- return this.iface.encodeFunctionData("setAgentWallet", [
3497
- params.agentId,
3498
- params.agentWallet,
3499
- params.agentRegistry,
3500
- params.agentWalletSig
3501
- ]);
3589
+ return encodeFunctionData({
3590
+ abi: this.abi,
3591
+ functionName: "setAgentWallet",
3592
+ args: [params.agentId, params.agentWallet, params.agentRegistry, params.agentWalletSig]
3593
+ });
3502
3594
  }
3503
3595
  // ── Official ERC-8004 identity path ──────────────────────────────────────
3504
3596
  /**
@@ -3511,10 +3603,11 @@ var ERC8004Service = class {
3511
3603
  * Callable: owner EOA direct tx OR via UserOp (gasless).
3512
3604
  */
3513
3605
  encodeMintAgentIdentity(params) {
3514
- return this.iface.encodeFunctionData("mintAgentIdentity", [
3515
- params.identityRegistry,
3516
- params.agentURI
3517
- ]);
3606
+ return encodeFunctionData({
3607
+ abi: this.abi,
3608
+ functionName: "mintAgentIdentity",
3609
+ args: [params.identityRegistry, params.agentURI]
3610
+ });
3518
3611
  }
3519
3612
  /**
3520
3613
  * Encode calldata for `bindERC8004AgentWallet`.
@@ -3526,13 +3619,17 @@ var ERC8004Service = class {
3526
3619
  * Callable: owner EOA direct tx OR via UserOp (gasless).
3527
3620
  */
3528
3621
  encodeBindERC8004AgentWallet(params) {
3529
- return this.iface.encodeFunctionData("bindERC8004AgentWallet", [
3530
- params.identityRegistry,
3531
- params.agentId,
3532
- params.agentWallet,
3533
- params.deadline,
3534
- params.signature
3535
- ]);
3622
+ return encodeFunctionData({
3623
+ abi: this.abi,
3624
+ functionName: "bindERC8004AgentWallet",
3625
+ args: [
3626
+ params.identityRegistry,
3627
+ params.agentId,
3628
+ params.agentWallet,
3629
+ params.deadline,
3630
+ params.signature
3631
+ ]
3632
+ });
3536
3633
  }
3537
3634
  // ── Reputation ────────────────────────────────────────────────────────────
3538
3635
  /**
@@ -3544,17 +3641,21 @@ var ERC8004Service = class {
3544
3641
  * Callable: owner EOA direct tx OR via UserOp (gasless).
3545
3642
  */
3546
3643
  encodeSubmitAgentReputation(params) {
3547
- return this.iface.encodeFunctionData("submitAgentReputation", [
3548
- params.reputationRegistry,
3549
- params.agentId,
3550
- params.value,
3551
- params.valueDecimals,
3552
- params.tag1,
3553
- params.tag2,
3554
- params.endpoint,
3555
- params.feedbackURI,
3556
- params.feedbackHash
3557
- ]);
3644
+ return encodeFunctionData({
3645
+ abi: this.abi,
3646
+ functionName: "submitAgentReputation",
3647
+ args: [
3648
+ params.reputationRegistry,
3649
+ params.agentId,
3650
+ params.value,
3651
+ params.valueDecimals,
3652
+ params.tag1,
3653
+ params.tag2,
3654
+ params.endpoint,
3655
+ params.feedbackURI,
3656
+ params.feedbackHash
3657
+ ]
3658
+ });
3558
3659
  }
3559
3660
  /**
3560
3661
  * Query aggregated reputation for an agent from the official ERC-8004 ReputationRegistry.
@@ -3562,35 +3663,40 @@ var ERC8004Service = class {
3562
3663
  */
3563
3664
  async queryAgentReputation(accountAddress, params) {
3564
3665
  if (!this.provider) throw new Error("ERC8004Service: provider required for on-chain reads");
3565
- const contract = new ethers.Contract(accountAddress, ERC8004_ABI, this.provider);
3566
- const [count, summaryValue, summaryDecimals] = await contract.queryAgentReputation(
3666
+ const contract = this.contractAt(accountAddress);
3667
+ const [count, summaryValue, summaryDecimals] = await contract.read.queryAgentReputation([
3567
3668
  params.reputationRegistry,
3568
3669
  params.agentId,
3569
3670
  params.clientAddresses,
3570
3671
  params.tag1,
3571
3672
  params.tag2
3572
- );
3673
+ ]);
3573
3674
  return { count: BigInt(count), summaryValue: BigInt(summaryValue), summaryDecimals: Number(summaryDecimals) };
3574
3675
  }
3575
3676
  /**
3576
3677
  * Encode calldata for `queryAgentReputation` (for static-call or eth_call without a signer).
3577
3678
  */
3578
3679
  encodeQueryAgentReputation(params) {
3579
- return this.iface.encodeFunctionData("queryAgentReputation", [
3580
- params.reputationRegistry,
3581
- params.agentId,
3582
- params.clientAddresses,
3583
- params.tag1,
3584
- params.tag2
3585
- ]);
3680
+ return encodeFunctionData({
3681
+ abi: this.abi,
3682
+ functionName: "queryAgentReputation",
3683
+ args: [
3684
+ params.reputationRegistry,
3685
+ params.agentId,
3686
+ params.clientAddresses,
3687
+ params.tag1,
3688
+ params.tag2
3689
+ ]
3690
+ });
3586
3691
  }
3587
3692
  /**
3588
3693
  * Read the agentExtension implementation address from a deployed AirAccount.
3589
3694
  */
3590
3695
  async getAgentExtensionAddress(accountAddress) {
3591
3696
  if (!this.provider) throw new Error("ERC8004Service: provider required for on-chain reads");
3592
- const contract = new ethers.Contract(accountAddress, ERC8004_ABI, this.provider);
3593
- return contract.agentExtension();
3697
+ const contract = this.contractAt(accountAddress);
3698
+ const extension = await contract.read.agentExtension([]);
3699
+ return extension;
3594
3700
  }
3595
3701
  };
3596
3702
  var DEFAULT_KMS_ENDPOINT = "https://kms.aastar.io";
@@ -3647,6 +3753,21 @@ var KmsHttpClient = class {
3647
3753
  });
3648
3754
  }
3649
3755
  };
3756
+
3757
+ // ../../node_modules/.pnpm/@noble+curves@2.0.1/node_modules/@noble/curves/nist.js
3758
+ var p256_CURVE = /* @__PURE__ */ (() => ({
3759
+ p: BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),
3760
+ n: BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),
3761
+ h: BigInt(1),
3762
+ a: BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),
3763
+ b: BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),
3764
+ Gx: BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),
3765
+ Gy: BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")
3766
+ }))();
3767
+ var p256_Point = /* @__PURE__ */ weierstrass(p256_CURVE);
3768
+ var p256 = /* @__PURE__ */ ecdsa(p256_Point, sha256);
3769
+
3770
+ // ../airaccount/src/server/services/webauthn-ceremony.ts
3650
3771
  var DEFAULT_RP_ID = "aastar.io";
3651
3772
  var DEFAULT_ORIGIN = "https://aastar.io";
3652
3773
  var DEFAULT_CREDENTIAL_ID = "dGVzdC1jcmVkZW50aWFs";
@@ -3656,7 +3777,7 @@ function base64UrlEncode(bytes) {
3656
3777
  function base64UrlDecode(value) {
3657
3778
  return new Uint8Array(Buffer.from(value, "base64url"));
3658
3779
  }
3659
- function hexToBytes(hex) {
3780
+ function hexToBytes4(hex) {
3660
3781
  const clean = hex.startsWith("0x") ? hex.slice(2) : hex;
3661
3782
  if (clean.length % 2 !== 0) {
3662
3783
  throw new Error("hexToBytes: odd-length hex string");
@@ -3675,7 +3796,7 @@ var P256PasskeySigner = class {
3675
3796
  * @param credentialId base64url credential id (defaults to the reference fixture).
3676
3797
  */
3677
3798
  constructor(privateKey, credentialId = DEFAULT_CREDENTIAL_ID) {
3678
- this.privateKey = typeof privateKey === "string" ? hexToBytes(privateKey) : privateKey;
3799
+ this.privateKey = typeof privateKey === "string" ? hexToBytes4(privateKey) : privateKey;
3679
3800
  this.credentialId = credentialId;
3680
3801
  }
3681
3802
  /**
@@ -3741,26 +3862,28 @@ async function runWebAuthnCeremony(begin, options) {
3741
3862
  });
3742
3863
  return { ChallengeId: begun.ChallengeId, Credential: credential };
3743
3864
  }
3744
- function beginAuthenticationChallenge(http, keyId) {
3745
- return http.post("/BeginAuthentication", { KeyId: keyId });
3865
+ function beginAuthenticationChallenge(http2, keyId) {
3866
+ return http2.post("/BeginAuthentication", { KeyId: keyId });
3746
3867
  }
3747
- function beginGrantSessionChallenge(http, keyId) {
3748
- return http.get("/kms/begin-grant-session-auth", {
3868
+ function beginGrantSessionChallenge(http2, keyId) {
3869
+ return http2.get("/kms/begin-grant-session-auth", {
3749
3870
  params: { keyId }
3750
3871
  });
3751
3872
  }
3752
- function runAuthenticationCeremony(http, keyId, signer, options) {
3753
- return runWebAuthnCeremony(() => beginAuthenticationChallenge(http, keyId), {
3873
+ function runAuthenticationCeremony(http2, keyId, signer, options) {
3874
+ return runWebAuthnCeremony(() => beginAuthenticationChallenge(http2, keyId), {
3754
3875
  signer,
3755
3876
  ...options
3756
3877
  });
3757
3878
  }
3758
- function runGrantSessionCeremony(http, keyId, signer, options) {
3759
- return runWebAuthnCeremony(() => beginGrantSessionChallenge(http, keyId), {
3879
+ function runGrantSessionCeremony(http2, keyId, signer, options) {
3880
+ return runWebAuthnCeremony(() => beginGrantSessionChallenge(http2, keyId), {
3760
3881
  signer,
3761
3882
  ...options
3762
3883
  });
3763
3884
  }
3885
+
3886
+ // ../airaccount/src/server/services/kms-signer.ts
3764
3887
  var KmsManager = class {
3765
3888
  client;
3766
3889
  logger;
@@ -4055,14 +4178,13 @@ var KmsManager = class {
4055
4178
  return this.client.post("/BeginAuthentication", { KeyId: keyId });
4056
4179
  }
4057
4180
  // ── Factory ─────────────────────────────────────────────────────
4058
- createKmsSigner(keyId, address, assertionProvider, provider) {
4181
+ createKmsSigner(keyId, address, assertionProvider) {
4059
4182
  this.ensureEnabled();
4060
- return new KmsSigner(keyId, address, this, assertionProvider, provider);
4183
+ return new KmsSigner(keyId, address, this, assertionProvider);
4061
4184
  }
4062
4185
  };
4063
- var KmsSigner = class _KmsSigner extends ethers.AbstractSigner {
4064
- constructor(keyId, _address, kmsManager, assertionProvider, provider) {
4065
- super(provider);
4186
+ var KmsSigner = class {
4187
+ constructor(keyId, _address, kmsManager, assertionProvider) {
4066
4188
  this.keyId = keyId;
4067
4189
  this._address = _address;
4068
4190
  this.kmsManager = kmsManager;
@@ -4072,53 +4194,19 @@ var KmsSigner = class _KmsSigner extends ethers.AbstractSigner {
4072
4194
  return this._address;
4073
4195
  }
4074
4196
  async signMessage(message) {
4075
- const messageBytes = typeof message === "string" ? ethers.toUtf8Bytes(message) : message;
4076
- const messageHash = ethers.hashMessage(messageBytes);
4197
+ const messageHash = hashMessage(message);
4077
4198
  const assertion = await this.assertionProvider();
4078
4199
  const signResponse = await this.kmsManager.signHash(messageHash, assertion, {
4079
4200
  Address: this._address
4080
4201
  });
4081
4202
  return "0x" + signResponse.Signature;
4082
4203
  }
4083
- async signTransaction(tx) {
4084
- if (!this.provider) {
4085
- throw new Error("Provider is required for signing transactions");
4086
- }
4087
- const populated = await this.populateTransaction(tx);
4088
- const unsignedTx = ethers.Transaction.from(populated);
4089
- const txHash = unsignedTx.hash;
4090
- if (!txHash) {
4091
- throw new Error("Failed to compute transaction hash");
4092
- }
4093
- const assertion = await this.assertionProvider();
4094
- const signResponse = await this.kmsManager.signHash(txHash, assertion, {
4095
- Address: this._address
4096
- });
4097
- const sig = ethers.Signature.from("0x" + signResponse.Signature);
4098
- unsignedTx.signature = sig;
4099
- return unsignedTx.serialized;
4100
- }
4101
- async signTypedData(domain, types, value) {
4102
- const hash = ethers.TypedDataEncoder.hash(domain, types, value);
4103
- const assertion = await this.assertionProvider();
4104
- const signResponse = await this.kmsManager.signHash(hash, assertion, {
4105
- Address: this._address
4106
- });
4107
- return "0x" + signResponse.Signature;
4108
- }
4109
- connect(provider) {
4110
- return new _KmsSigner(
4111
- this.keyId,
4112
- this._address,
4113
- this.kmsManager,
4114
- this.assertionProvider,
4115
- provider
4116
- );
4117
- }
4118
4204
  };
4205
+
4206
+ // ../airaccount/src/server/services/kms-agent-service.ts
4119
4207
  var KmsAgentService = class {
4120
- constructor(http) {
4121
- this.http = http;
4208
+ constructor(http2) {
4209
+ this.http = http2;
4122
4210
  }
4123
4211
  /**
4124
4212
  * Mint a new agent key under an existing human key (WebAuthn-gated).
@@ -4205,9 +4293,11 @@ var KmsAgentService = class {
4205
4293
  return this.revokeAgentCredential({ ...params, webAuthnAssertion });
4206
4294
  }
4207
4295
  };
4296
+
4297
+ // ../airaccount/src/server/services/kms-session-service.ts
4208
4298
  var KmsSessionService = class {
4209
- constructor(http) {
4210
- this.http = http;
4299
+ constructor(http2) {
4300
+ this.http = http2;
4211
4301
  }
4212
4302
  /**
4213
4303
  * Create a P-256 session key under a human key (WebAuthn-gated).
@@ -4280,9 +4370,11 @@ var KmsSessionService = class {
4280
4370
  return this.revokeP256SessionKey({ ...params, webAuthnAssertion });
4281
4371
  }
4282
4372
  };
4373
+
4374
+ // ../airaccount/src/server/services/kms-payment-signer.ts
4283
4375
  var KmsPaymentSigner = class {
4284
- constructor(http) {
4285
- this.http = http;
4376
+ constructor(http2) {
4377
+ this.http = http2;
4286
4378
  }
4287
4379
  /**
4288
4380
  * Dispatch a payment-signing request with the chosen auth mode.
@@ -4321,9 +4413,11 @@ var KmsPaymentSigner = class {
4321
4413
  return this.signWithAuth("/kms/SignX402Payment", { ...params }, auth);
4322
4414
  }
4323
4415
  };
4416
+
4417
+ // ../airaccount/src/server/services/kms-monitor-service.ts
4324
4418
  var KmsMonitorService = class {
4325
- constructor(http) {
4326
- this.http = http;
4419
+ constructor(http2) {
4420
+ this.http = http2;
4327
4421
  }
4328
4422
  /**
4329
4423
  * Liveness probe (`GET /health`, no auth). Does NOT require the KMS feature
@@ -4400,6 +4494,8 @@ var KmsMonitorService = class {
4400
4494
  return this.http.postWithBearer("/admin/purge-key", params, adminToken);
4401
4495
  }
4402
4496
  };
4497
+
4498
+ // ../airaccount/src/server/adapters/memory-storage.ts
4403
4499
  var MemoryStorage = class {
4404
4500
  accounts = [];
4405
4501
  transfers = [];
@@ -4474,18 +4570,18 @@ var MemoryStorage = class {
4474
4570
  }
4475
4571
  };
4476
4572
  var LocalWalletSigner = class {
4477
- wallet;
4478
- constructor(privateKey, provider) {
4479
- this.wallet = new ethers.Wallet(privateKey, provider);
4573
+ account;
4574
+ constructor(privateKey) {
4575
+ this.account = privateKeyToAccount(privateKey);
4480
4576
  }
4481
4577
  async getAddress(_userId) {
4482
- return this.wallet.address;
4578
+ return this.account.address;
4483
4579
  }
4484
- async getSigner(_userId, _ctx) {
4485
- return this.wallet;
4580
+ async signMessage(_userId, message, _ctx) {
4581
+ return this.account.signMessage({ message: { raw: message } });
4486
4582
  }
4487
4583
  async ensureSigner(_userId) {
4488
- return { signer: this.wallet, address: this.wallet.address };
4584
+ return { address: this.account.address };
4489
4585
  }
4490
4586
  };
4491
4587
  /*! Bundled license information:
@@ -4494,6 +4590,6 @@ var LocalWalletSigner = class {
4494
4590
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
4495
4591
  */
4496
4592
 
4497
- export { ACCOUNT_ABI, AGENT_SESSION_KEY_VALIDATOR_ABI, AIRACCOUNT_ABI, AIRACCOUNT_ADDRESSES, AIRACCOUNT_FACTORY_ABI, AIR_ACCOUNT_COMPOSITE_VALIDATOR_ABI, AIR_ACCOUNT_DELEGATE_ABI, AIR_ACCOUNT_DELEGATE_ADDRESS, ALG_ID, AccountManager, AgentRegistryService, BLSSignatureService, CALLDATA_PARSER_REGISTRY_ABI, ConsoleLogger, DEFAULT_CREDENTIAL_ID, DEFAULT_KMS_ENDPOINT, DEFAULT_ORIGIN, DEFAULT_RP_ID, DvtPendingConfirmationError, EIP7702DelegateService, ENTRYPOINT_ABI_V6, ENTRYPOINT_ABI_V7_V8, ENTRYPOINT_ADDRESSES, ERC20_ABI, ERC8004Service, ERC8004_ADDRESSES, EXECUTE_BATCH_SELECTOR, EXECUTE_SELECTOR, EXECUTE_USER_OP_SELECTOR, EntryPointVersion, EthereumProvider, FACTORY_ABI_V6, FACTORY_ABI_V7_V8, FORCE_EXIT_MODULE_ABI, ForceExitService, GLOBAL_GUARD_ABI, GuardChecker, GuardStateReader, KmsAgentService, KmsHttpClient, KmsManager, KmsMonitorService, KmsPaymentSigner, KmsSessionService, KmsSigner, L2_TYPE, LocalWalletSigner, MAX_GUARDIANS, MODULE_TYPE, MemoryStorage, ModuleManager, P256PasskeySigner, PaymasterManager, PaymasterPriceStalenessError, RECOVERY_THRESHOLD, RECOVERY_TIMELOCK_SECONDS, RecoveryService, SESSION_KEY_VALIDATOR_ABI, SessionKeyService, SilentLogger, TIER_GUARD_HOOK_ABI, TokenService, TransferManager, VALIDATOR_ABI, WEIGHT_CHANGE_EXPIRY_SECONDS, WEIGHT_CHANGE_THRESHOLD, WEIGHT_CHANGE_TIMELOCK_SECONDS, WalletManager, WeightedSignatureService, YAAAServerClient, base64UrlDecode, base64UrlEncode, beginAuthenticationChallenge, beginGrantSessionChallenge, buildAuthenticationCredential, buildAuthenticatorData, buildClientDataJSON, buildInstallModuleHash, buildUninstallModuleHash, computeOapdSalt, erc8004AddressesForChain, getOapdAddress, getOapdAddressWithChainId, isExecuteUserOpWrapped, isOapdDeployed, isPendingConfirmation, packP256SessionSignature, packSecp256k1SessionSignature, runAuthenticationCeremony, runGrantSessionCeremony, runWebAuthnCeremony, sepoliaV07Config, validateConfig, wrapExecuteUserOp };
4498
- //# sourceMappingURL=chunk-WPSWFZKF.js.map
4499
- //# sourceMappingURL=chunk-WPSWFZKF.js.map
4593
+ export { ACCOUNT_ABI, AGENT_SESSION_KEY_VALIDATOR_ABI, AIRACCOUNT_ABI, AIRACCOUNT_ADDRESSES, AIRACCOUNT_FACTORY_ABI, AIR_ACCOUNT_COMPOSITE_VALIDATOR_ABI, AIR_ACCOUNT_DELEGATE_ABI, AIR_ACCOUNT_DELEGATE_ADDRESS, ALG_ID, AccountManager, AgentRegistryService, AirAccountServerClient, BLSSignatureService, CALLDATA_PARSER_REGISTRY_ABI, ConsoleLogger, DEFAULT_CREDENTIAL_ID, DEFAULT_KMS_ENDPOINT, DEFAULT_ORIGIN, DEFAULT_RP_ID, DvtPendingConfirmationError, EIP7702DelegateService, ENTRYPOINT_ABI_V6, ENTRYPOINT_ABI_V7_V8, ENTRYPOINT_ADDRESSES, ERC20_ABI, ERC8004Service, ERC8004_ADDRESSES, EXECUTE_BATCH_SELECTOR, EXECUTE_SELECTOR, EXECUTE_USER_OP_SELECTOR, EntryPointVersion, EthereumProvider, FACTORY_ABI_V6, FACTORY_ABI_V7_V8, FORCE_EXIT_MODULE_ABI, ForceExitService, GLOBAL_GUARD_ABI, GuardChecker, GuardStateReader, KmsAgentService, KmsHttpClient, KmsManager, KmsMonitorService, KmsPaymentSigner, KmsSessionService, KmsSigner, L2_TYPE, LocalWalletSigner, MAX_GUARDIANS, MODULE_TYPE, MemoryStorage, ModuleManager, P256PasskeySigner, PaymasterManager, PaymasterPriceStalenessError, RECOVERY_THRESHOLD, RECOVERY_TIMELOCK_SECONDS, RecoveryService, SESSION_KEY_VALIDATOR_ABI, SessionKeyService, SilentLogger, TIER_GUARD_HOOK_ABI, TokenService, TransferManager, VALIDATOR_ABI, WEIGHT_CHANGE_EXPIRY_SECONDS, WEIGHT_CHANGE_THRESHOLD, WEIGHT_CHANGE_TIMELOCK_SECONDS, WalletManager, WeightedSignatureService, YAAAServerClient, base64UrlDecode, base64UrlEncode, beginAuthenticationChallenge, beginGrantSessionChallenge, buildAuthenticationCredential, buildAuthenticatorData, buildClientDataJSON, buildInstallModuleHash, buildUninstallModuleHash, computeOapdSalt, erc8004AddressesForChain, getOapdAddress, getOapdAddressWithChainId, isExecuteUserOpWrapped, isOapdDeployed, isPendingConfirmation, packP256SessionSignature, packSecp256k1SessionSignature, runAuthenticationCeremony, runGrantSessionCeremony, runWebAuthnCeremony, sepoliaV07Config, validateConfig, wrapExecuteUserOp };
4594
+ //# sourceMappingURL=chunk-UIFMIVDK.js.map
4595
+ //# sourceMappingURL=chunk-UIFMIVDK.js.map