@aastar/sdk 0.22.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/dist/UserClient-KYDCMAIU.js +6 -0
  2. package/dist/{UserClient-Y65JLJ23.js.map → UserClient-KYDCMAIU.js.map} +1 -1
  3. package/dist/UserClient-S6LS3CB6.cjs +15 -0
  4. package/dist/{UserClient-AJOGJXOC.cjs.map → UserClient-S6LS3CB6.cjs.map} +1 -1
  5. package/dist/account.cjs +7 -7
  6. package/dist/account.js +2 -2
  7. package/dist/admin.cjs +3 -3
  8. package/dist/admin.js +2 -2
  9. package/dist/airaccount.cjs +117 -97
  10. package/dist/airaccount.d.cts +2 -1
  11. package/dist/airaccount.d.ts +2 -1
  12. package/dist/airaccount.js +2 -2
  13. package/dist/channel.cjs +6 -6
  14. package/dist/channel.js +2 -2
  15. package/dist/{chunk-RF3MSLRW.cjs → chunk-5PH5CSM7.cjs} +16 -16
  16. package/dist/{chunk-RF3MSLRW.cjs.map → chunk-5PH5CSM7.cjs.map} +1 -1
  17. package/dist/{chunk-LKSQASFZ.js → chunk-654GQ7G7.js} +3 -3
  18. package/dist/{chunk-LKSQASFZ.js.map → chunk-654GQ7G7.js.map} +1 -1
  19. package/dist/{chunk-3OIVYXUG.cjs → chunk-72JZKARR.cjs} +6 -6
  20. package/dist/{chunk-3OIVYXUG.cjs.map → chunk-72JZKARR.cjs.map} +1 -1
  21. package/dist/{chunk-JCK7VAZF.js → chunk-7RVONA2R.js} +8 -8
  22. package/dist/{chunk-JCK7VAZF.js.map → chunk-7RVONA2R.js.map} +1 -1
  23. package/dist/{chunk-MG72SGVS.cjs → chunk-A4ICWCHR.cjs} +5 -5
  24. package/dist/{chunk-MG72SGVS.cjs.map → chunk-A4ICWCHR.cjs.map} +1 -1
  25. package/dist/{chunk-6ISQM3SF.cjs → chunk-BOVDJSMK.cjs} +26 -26
  26. package/dist/{chunk-6ISQM3SF.cjs.map → chunk-BOVDJSMK.cjs.map} +1 -1
  27. package/dist/{chunk-2TS6T2WY.js → chunk-BYVG7MO7.js} +35 -4
  28. package/dist/chunk-BYVG7MO7.js.map +1 -0
  29. package/dist/{chunk-7RNOKMAJ.cjs → chunk-D667CUUS.cjs} +9 -9
  30. package/dist/{chunk-7RNOKMAJ.cjs.map → chunk-D667CUUS.cjs.map} +1 -1
  31. package/dist/{chunk-XZDMKHKG.js → chunk-DAMWXGKD.js} +3 -3
  32. package/dist/{chunk-XZDMKHKG.js.map → chunk-DAMWXGKD.js.map} +1 -1
  33. package/dist/{chunk-BLA57KBS.cjs → chunk-GDH4DSVM.cjs} +12 -12
  34. package/dist/{chunk-BLA57KBS.cjs.map → chunk-GDH4DSVM.cjs.map} +1 -1
  35. package/dist/{chunk-FZLBMUPN.cjs → chunk-HNJBQR5U.cjs} +5 -5
  36. package/dist/{chunk-FZLBMUPN.cjs.map → chunk-HNJBQR5U.cjs.map} +1 -1
  37. package/dist/{chunk-VUNNHEND.js → chunk-JMW5AHLC.js} +9 -9
  38. package/dist/{chunk-VUNNHEND.js.map → chunk-JMW5AHLC.js.map} +1 -1
  39. package/dist/{chunk-SNVHOCU6.js → chunk-LDARLWS3.js} +3 -3
  40. package/dist/{chunk-SNVHOCU6.js.map → chunk-LDARLWS3.js.map} +1 -1
  41. package/dist/{chunk-TS5CXRNI.cjs → chunk-MOJJ7QF6.cjs} +40 -3
  42. package/dist/{chunk-TS5CXRNI.cjs.map → chunk-MOJJ7QF6.cjs.map} +1 -1
  43. package/dist/{chunk-BBZAD5G2.cjs → chunk-NVYVTCHJ.cjs} +11 -11
  44. package/dist/{chunk-BBZAD5G2.cjs.map → chunk-NVYVTCHJ.cjs.map} +1 -1
  45. package/dist/{chunk-MQMTICTP.js → chunk-PNBK2CLK.js} +3 -3
  46. package/dist/{chunk-MQMTICTP.js.map → chunk-PNBK2CLK.js.map} +1 -1
  47. package/dist/{chunk-T2GF4S3E.js → chunk-PXQDAFXD.js} +6 -6
  48. package/dist/{chunk-T2GF4S3E.js.map → chunk-PXQDAFXD.js.map} +1 -1
  49. package/dist/{chunk-XTF6MNIK.js → chunk-RZ2M2RVP.js} +3 -3
  50. package/dist/{chunk-XTF6MNIK.js.map → chunk-RZ2M2RVP.js.map} +1 -1
  51. package/dist/{chunk-7HO4IUHZ.cjs → chunk-VHY6R2PI.cjs} +32 -32
  52. package/dist/{chunk-7HO4IUHZ.cjs.map → chunk-VHY6R2PI.cjs.map} +1 -1
  53. package/dist/{chunk-R3N7L7RE.js → chunk-WC25H5VG.js} +4 -4
  54. package/dist/{chunk-R3N7L7RE.js.map → chunk-WC25H5VG.js.map} +1 -1
  55. package/dist/{chunk-UUT246S2.js → chunk-WVJ4LQVB.js} +3 -3
  56. package/dist/{chunk-UUT246S2.js.map → chunk-WVJ4LQVB.js.map} +1 -1
  57. package/dist/{chunk-DOVGH7HB.cjs → chunk-WVOJV4Q5.cjs} +4 -4
  58. package/dist/{chunk-DOVGH7HB.cjs.map → chunk-WVOJV4Q5.cjs.map} +1 -1
  59. package/dist/{chunk-OVNOSAL3.cjs → chunk-Y5U7URNZ.cjs} +260 -6
  60. package/dist/chunk-Y5U7URNZ.cjs.map +1 -0
  61. package/dist/{chunk-6OWZOTE7.js → chunk-YUFQIYLR.js} +258 -9
  62. package/dist/chunk-YUFQIYLR.js.map +1 -0
  63. package/dist/core.cjs +226 -202
  64. package/dist/core.d.cts +100 -513
  65. package/dist/core.d.ts +100 -513
  66. package/dist/core.js +1 -1
  67. package/dist/dapp.cjs +5 -5
  68. package/dist/dapp.js +2 -2
  69. package/dist/enduser.cjs +6 -6
  70. package/dist/enduser.js +3 -3
  71. package/dist/identity.cjs +5 -5
  72. package/dist/identity.js +2 -2
  73. package/dist/index.cjs +327 -303
  74. package/dist/index.d.cts +4 -2
  75. package/dist/index.d.ts +4 -2
  76. package/dist/index.js +15 -15
  77. package/dist/initConfig-D8jgrcDb.d.cts +518 -0
  78. package/dist/initConfig-D8jgrcDb.d.ts +518 -0
  79. package/dist/kms.cjs +117 -97
  80. package/dist/kms.d.cts +223 -3
  81. package/dist/kms.d.ts +223 -3
  82. package/dist/kms.js +2 -2
  83. package/dist/operator.cjs +6 -6
  84. package/dist/operator.js +2 -2
  85. package/dist/paymaster.cjs +15 -15
  86. package/dist/paymaster.js +2 -2
  87. package/dist/src-5URXSFKD.js +5 -0
  88. package/dist/src-5URXSFKD.js.map +1 -0
  89. package/dist/{src-WGYHZSLY.cjs → src-72GWEAPA.cjs} +17 -17
  90. package/dist/src-72GWEAPA.cjs.map +1 -0
  91. package/dist/{src-UQ4RDCJG.cjs → src-N72HAQXS.cjs} +228 -204
  92. package/dist/src-N72HAQXS.cjs.map +1 -0
  93. package/dist/{src-MDGW57S5.js → src-UNS5B7FX.js} +4 -4
  94. package/dist/{src-UQ4RDCJG.cjs.map → src-UNS5B7FX.js.map} +1 -1
  95. package/dist/tokens.cjs +3 -3
  96. package/dist/tokens.js +2 -2
  97. package/dist/x402.cjs +25 -25
  98. package/dist/x402.js +2 -2
  99. package/package.json +1 -1
  100. package/dist/UserClient-AJOGJXOC.cjs +0 -15
  101. package/dist/UserClient-Y65JLJ23.js +0 -6
  102. package/dist/chunk-2TS6T2WY.js.map +0 -1
  103. package/dist/chunk-6OWZOTE7.js.map +0 -1
  104. package/dist/chunk-OVNOSAL3.cjs.map +0 -1
  105. package/dist/src-MDGW57S5.js.map +0 -1
  106. package/dist/src-SCR3OCME.js +0 -5
  107. package/dist/src-SCR3OCME.js.map +0 -1
  108. package/dist/src-WGYHZSLY.cjs.map +0 -1
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkXQROKLZI_cjs = require('./chunk-XQROKLZI.cjs');
4
+ var chunkMOJJ7QF6_cjs = require('./chunk-MOJJ7QF6.cjs');
4
5
  var chunkMXJEULSE_cjs = require('./chunk-MXJEULSE.cjs');
5
6
  var viem = require('viem');
6
7
  var axios = require('axios');
@@ -196,8 +197,8 @@ var AIRACCOUNT_ABI = [
196
197
  ];
197
198
  var AIRACCOUNT_FACTORY_ABI = [
198
199
  // Full config creation
199
- "function createAccount(address owner, uint256 salt, (address[3] guardians, bytes32[3] guardianP256X, bytes32[3] guardianP256Y, uint256 dailyLimit, uint8[] approvedAlgIds, uint256 minDailyLimit, address[] initialTokens, (uint256 tier1Limit, uint256 tier2Limit, uint256 dailyLimit)[] initialTokenConfigs) config) external returns (address)",
200
- "function getAddress(address owner, uint256 salt, (address[3] guardians, bytes32[3] guardianP256X, bytes32[3] guardianP256Y, uint256 dailyLimit, uint8[] approvedAlgIds, uint256 minDailyLimit, address[] initialTokens, (uint256 tier1Limit, uint256 tier2Limit, uint256 dailyLimit)[] initialTokenConfigs) config) external view returns (address)",
200
+ "function createAccount(address owner, uint256 salt, (address[3] guardians, bytes32[3] guardianP256X, bytes32[3] guardianP256Y, uint256 dailyLimit, uint8[] approvedAlgIds, uint256 minDailyLimit, address[] initialTokens, (uint128 tier1Limit, uint128 tier2Limit, uint256 dailyLimit)[] initialTokenConfigs) config) external returns (address)",
201
+ "function getAddress(address owner, uint256 salt, (address[3] guardians, bytes32[3] guardianP256X, bytes32[3] guardianP256Y, uint256 dailyLimit, uint8[] approvedAlgIds, uint256 minDailyLimit, address[] initialTokens, (uint128 tier1Limit, uint128 tier2Limit, uint256 dailyLimit)[] initialTokenConfigs) config) external view returns (address)",
201
202
  // Default guardian setup (requires guardian acceptance sigs — M5.3+)
202
203
  "function createAccountWithDefaults(address owner, uint256 salt, address guardian1, bytes guardian1Sig, address guardian2, bytes guardian2Sig, uint256 dailyLimit) external returns (address)",
203
204
  "function getAddressWithDefaults(address owner, uint256 salt, address guardian1, address guardian2, uint256 dailyLimit) external view returns (address)",
@@ -214,7 +215,7 @@ var AIRACCOUNT_FACTORY_ABI = [
214
215
  "function defaultHookModule() external view returns (address)",
215
216
  // M7.4 ERC-7828 chain-qualified address helpers
216
217
  "function getChainQualifiedAddress(address account) external view returns (bytes32)",
217
- "function getAddressWithChainId(address owner, uint256 salt, (address[3] guardians, bytes32[3] guardianP256X, bytes32[3] guardianP256Y, uint256 dailyLimit, uint8[] approvedAlgIds, uint256 minDailyLimit, address[] initialTokens, (uint256 tier1Limit, uint256 tier2Limit, uint256 dailyLimit)[] initialTokenConfigs) config) external view returns (address account, bytes32 chainQualified)",
218
+ "function getAddressWithChainId(address owner, uint256 salt, (address[3] guardians, bytes32[3] guardianP256X, bytes32[3] guardianP256Y, uint256 dailyLimit, uint8[] approvedAlgIds, uint256 minDailyLimit, address[] initialTokens, (uint128 tier1Limit, uint128 tier2Limit, uint256 dailyLimit)[] initialTokenConfigs) config) external view returns (address account, bytes32 chainQualified)",
218
219
  // Events
219
220
  "event AccountCreated(address indexed account, address indexed owner, uint256 salt)"
220
221
  ];
@@ -470,6 +471,10 @@ var EthereumProvider = class {
470
471
  getBundlerProvider() {
471
472
  return this.bundlerProvider;
472
473
  }
474
+ /** EVM chain id from the validated ServerConfig (deterministic — no RPC round-trip). */
475
+ getChainId() {
476
+ return this.config.chainId;
477
+ }
473
478
  /**
474
479
  * Raw bundler JSON-RPC call. The bundler exposes non-standard methods
475
480
  * (eth_sendUserOperation, pimlico_getUserOperationGasPrice, ...) that are not in
@@ -715,6 +720,55 @@ function readBuildP256GrantHash(validator, account, keyX, keyY, cfg) {
715
720
  return readFn(validator, "buildP256GrantHash")([account, keyX, keyY, cfg]);
716
721
  }
717
722
 
723
+ // ../airaccount/src/server/services/account-init-config.ts
724
+ function toGuardianSpecs(p) {
725
+ const specs = [];
726
+ for (const e of p.ecdsaGuardians ?? []) specs.push({ ecdsa: e });
727
+ for (const k of p.p256Guardians) specs.push({ p256: { x: k.x, y: k.y } });
728
+ return specs;
729
+ }
730
+ function buildFullInitConfig(p) {
731
+ return chunkMOJJ7QF6_cjs.buildInitConfig({
732
+ guardians: toGuardianSpecs(p),
733
+ dailyLimit: p.dailyLimit,
734
+ ...p.approvedAlgIds ? { approvedAlgIds: p.approvedAlgIds } : {},
735
+ ...p.minDailyLimit !== void 0 ? { minDailyLimit: p.minDailyLimit } : {}
736
+ });
737
+ }
738
+ function initConfigToTuple(c) {
739
+ return [
740
+ c.guardians,
741
+ c.guardianP256X,
742
+ c.guardianP256Y,
743
+ c.dailyLimit,
744
+ c.approvedAlgIds,
745
+ c.minDailyLimit,
746
+ c.initialTokens,
747
+ c.initialTokenConfigs.map((t) => [t.tier1Limit, t.tier2Limit, t.dailyLimit])
748
+ ];
749
+ }
750
+ function serializeGuardianSpecs(specs) {
751
+ return specs.map(
752
+ (s) => s.p256 ? { p256: { x: s.p256.x, y: s.p256.y } } : { ecdsa: s.ecdsa }
753
+ );
754
+ }
755
+ function initConfigFromRecord(record) {
756
+ if (!record.guardianSpecs || record.guardianSpecs.length === 0) {
757
+ throw new Error(
758
+ "initConfigFromRecord: record has no guardianSpecs (not a full-config / P-256 account)"
759
+ );
760
+ }
761
+ const guardians = record.guardianSpecs.map(
762
+ (s) => "p256" in s ? { p256: { x: s.p256.x, y: s.p256.y } } : { ecdsa: s.ecdsa }
763
+ );
764
+ return chunkMOJJ7QF6_cjs.buildInitConfig({
765
+ guardians,
766
+ dailyLimit: record.dailyLimit ? BigInt(record.dailyLimit) : 0n,
767
+ ...record.approvedAlgIds ? { approvedAlgIds: record.approvedAlgIds } : {},
768
+ ...record.minDailyLimit !== void 0 ? { minDailyLimit: BigInt(record.minDailyLimit) } : {}
769
+ });
770
+ }
771
+
718
772
  // ../airaccount/src/server/services/account-manager.ts
719
773
  var ZERO32 = "0x" + "0".repeat(64);
720
774
  var EMPTY_P256 = [ZERO32, ZERO32, ZERO32];
@@ -727,6 +781,17 @@ var AccountManager = class {
727
781
  }
728
782
  logger;
729
783
  async createAccount(userId, options) {
784
+ if (options?.p256Guardians && options.p256Guardians.length > 0) {
785
+ return this.createAccountWithP256Guardians(userId, {
786
+ p256Guardians: options.p256Guardians,
787
+ ecdsaGuardians: options.ecdsaGuardians,
788
+ dailyLimit: options.dailyLimit ?? 0n,
789
+ approvedAlgIds: options.approvedAlgIds,
790
+ minDailyLimit: options.minDailyLimit,
791
+ salt: options.salt,
792
+ entryPointVersion: options.entryPointVersion
793
+ });
794
+ }
730
795
  const version = options?.entryPointVersion ?? this.ethereum.getDefaultVersion();
731
796
  const versionStr = version;
732
797
  const existingAccounts = await this.storage.getAccounts();
@@ -943,6 +1008,183 @@ var AccountManager = class {
943
1008
  this.logger.log(`[AccountManager] account created with guardians: ${accountAddress}`);
944
1009
  return account;
945
1010
  }
1011
+ /**
1012
+ * Create an AirAccount with one or more P-256 (WebAuthn passkey) guardians installed at
1013
+ * DEPLOY time — the server-client path #118 adds for KMS-custodied / counterfactual accounts
1014
+ * (e.g. YAA) that cannot drive the viem extension layer for account creation.
1015
+ *
1016
+ * Uses the factory's full-config `createAccount(owner, salt, config)` path because it is the
1017
+ * ONLY entrypoint that accepts an 8-field `InitConfig` (and therefore `guardianP256X/Y`). The
1018
+ * 8-field config is built by the core `buildInitConfig` (0.22.0) — never hand-rolled — and the
1019
+ * address is predicted via the factory's full-config `getAddress(owner, salt, config)` (NOT
1020
+ * `getAddressWithDefaults`), binding the address to `keccak256(config)`.
1021
+ *
1022
+ * ### Acceptance-signature semantics (verified against AAStarAirAccountFactoryV7.sol)
1023
+ * On this path the contract performs NO guardian-acceptance signature check — for P-256 OR ECDSA
1024
+ * guardians. Front-run protection comes from `_getSalt(owner, salt, _getConfigHash(config))`:
1025
+ * any change to the guardian set (or any other config field) yields a different CREATE2 address,
1026
+ * so an attacker cannot collide on the victim's counterfactual address with a weaker config.
1027
+ * P-256 guardians are an owner-bootstrap (single guardian can't form a recovery quorum), so no
1028
+ * acceptance ceremony exists for them by design (#110④). This is why optional ECDSA guardians may
1029
+ * also be passed here WITHOUT signatures — distinct from createAccountWithGuardians(), which uses
1030
+ * the owner-only-salt `createAccountWithDefaults` path and DOES require ECDSA acceptance sigs.
1031
+ *
1032
+ * The deploy UserOp is still signed by the existing KMS owner-key path (unchanged): this method
1033
+ * only predicts the address and persists the full config; transfer-manager rebuilds the
1034
+ * byte-identical initCode (via {@link initConfigFromRecord}) at first-UserOp deploy time.
1035
+ *
1036
+ * @throws if no P-256 guardian is supplied, dailyLimit <= 0, or EntryPoint is v0.6.
1037
+ */
1038
+ async createAccountWithP256Guardians(userId, params) {
1039
+ if (!params.p256Guardians || params.p256Guardians.length === 0) {
1040
+ throw new Error("createAccountWithP256Guardians requires at least one P-256 guardian");
1041
+ }
1042
+ if (params.dailyLimit <= 0n) {
1043
+ throw new Error(
1044
+ "P-256 guardian accounts require dailyLimit > 0 (a guardian set enables the on-chain guard)"
1045
+ );
1046
+ }
1047
+ const version = params.entryPointVersion ?? this.ethereum.getDefaultVersion();
1048
+ if (version === "0.6" /* V0_6 */) {
1049
+ throw new Error(
1050
+ "createAccountWithP256Guardians requires EntryPoint v0.7 or v0.8; the v0.6 factory does not support the full-config createAccount(InitConfig) path"
1051
+ );
1052
+ }
1053
+ const versionStr = version;
1054
+ const fullParams = {
1055
+ p256Guardians: params.p256Guardians,
1056
+ ecdsaGuardians: params.ecdsaGuardians,
1057
+ dailyLimit: params.dailyLimit,
1058
+ approvedAlgIds: params.approvedAlgIds,
1059
+ minDailyLimit: params.minDailyLimit
1060
+ };
1061
+ const specs = toGuardianSpecs(fullParams);
1062
+ const config = buildFullInitConfig(fullParams);
1063
+ const existingAccounts = await this.storage.getAccounts();
1064
+ const existing = existingAccounts.find(
1065
+ (a) => a.userId === userId && a.entryPointVersion === versionStr && !!a.guardianSpecs && a.guardianSpecs.length > 0
1066
+ );
1067
+ if (existing) return existing;
1068
+ const { address: signerAddress } = await this.signer.ensureSigner(userId);
1069
+ if (typeof params.salt === "number" && !Number.isSafeInteger(params.salt)) {
1070
+ throw new Error(
1071
+ `salt value ${params.salt} exceeds Number.MAX_SAFE_INTEGER; pass it as a bigint to avoid precision loss`
1072
+ );
1073
+ }
1074
+ const saltBig = BigInt(params.salt ?? Math.floor(Math.random() * 1e6));
1075
+ const factory = this.ethereum.getFactoryContract(version);
1076
+ const factoryAddress = factory.address ?? this.ethereum.getFactoryAddress(version);
1077
+ const accountAddress = await readPredictedAddress(
1078
+ factory,
1079
+ signerAddress,
1080
+ saltBig,
1081
+ initConfigToTuple(config)
1082
+ );
1083
+ let deployed = false;
1084
+ try {
1085
+ const code = await this.ethereum.getProvider().getCode({ address: accountAddress });
1086
+ deployed = !!code && code !== "0x";
1087
+ } catch {
1088
+ }
1089
+ const validatorAddress = this.ethereum.getValidatorAddress(version);
1090
+ const account = {
1091
+ userId,
1092
+ address: accountAddress,
1093
+ signerAddress,
1094
+ // Persist as a lossless decimal string (#118 M2); transfer-manager rebuilds via BigInt(account.salt).
1095
+ salt: saltBig.toString(),
1096
+ deployed,
1097
+ deploymentTxHash: null,
1098
+ validatorAddress,
1099
+ entryPointVersion: versionStr,
1100
+ factoryAddress,
1101
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1102
+ dailyLimit: params.dailyLimit.toString(),
1103
+ // Persist the RESOLVED config so transfer-manager rebuilds byte-identical initCode at deploy.
1104
+ guardianSpecs: serializeGuardianSpecs(specs),
1105
+ approvedAlgIds: [...config.approvedAlgIds],
1106
+ minDailyLimit: config.minDailyLimit.toString()
1107
+ };
1108
+ await this.storage.saveAccount(account);
1109
+ this.logger.log(
1110
+ `[AccountManager] account created with ${params.p256Guardians.length} P-256 guardian(s): ${accountAddress}`
1111
+ );
1112
+ if (chunkMOJJ7QF6_cjs.needsValidatorRouter(config.approvedAlgIds)) {
1113
+ this.logger.log(
1114
+ `[AccountManager] account ${accountAddress} approved a router-delegated algorithm (approvedAlgIds=[${config.approvedAlgIds.join(", ")}]); call ensureValidatorRouter(userId) AFTER the account is deployed to wire setValidator(router) \u2014 required for those algIds to validate.`
1115
+ );
1116
+ }
1117
+ return account;
1118
+ }
1119
+ /**
1120
+ * Gap B — wire the validator router for an account that approved a ROUTER-DELEGATED signature
1121
+ * algorithm (BLS 0x01, cumulative T2 0x04, T3 0x05, weighted 0x07, session 0x08, ...). Such an
1122
+ * account's `_validateTripleSignature` / `_callBLSValidator` return `1` (FAIL) while
1123
+ * `validator() == address(0)`, so the algorithm is non-functional until the owner calls
1124
+ * `setValidator(router)` (onlyOwner, SET-ONCE). Inline algIds (ECDSA 0x02, P256 0x03, COMBINED_T1
1125
+ * 0x06) need no router and are a no-op here.
1126
+ *
1127
+ * MUST be called AFTER the account is deployed (setValidator is onlyOwner and needs code) — the
1128
+ * lazy/counterfactual deploy path cannot setValidator at predict-time. Idempotent: re-running after
1129
+ * the validator is set is a no-op (`reason: 'validator already set'`).
1130
+ *
1131
+ * On-chain access matches the rest of this package: reads via the EthereumProvider's PublicClient
1132
+ * (`getAccountContract(...).read.validator()` and `getProvider().getCode()`); the state-changing
1133
+ * `setValidator` is sent through a caller-supplied `WalletClient` whose account is the owner —
1134
+ * the same convention used by `PaymasterManager.updatePrice` / `ForceExitService` (this manager's
1135
+ * narrow `ISignerAdapter` only EIP-191 personal-signs and cannot send transactions).
1136
+ *
1137
+ * @param userId the account owner's user id (storage key)
1138
+ * @param opts.router override the router address (defaults to the chain's canonical
1139
+ * `aaStarValidator`); pass to target a non-canonical router
1140
+ * @param opts.walletClient viem WalletClient signing as the account OWNER — REQUIRED to send the tx
1141
+ */
1142
+ async ensureValidatorRouter(userId, opts) {
1143
+ const account = await this.storage.findAccountByUserId(userId);
1144
+ if (!account) throw new Error("Account not found");
1145
+ const approvedAlgIds = account.approvedAlgIds;
1146
+ if (!approvedAlgIds || approvedAlgIds.length === 0) {
1147
+ return { set: false, reason: "no approvedAlgIds / not router-delegated" };
1148
+ }
1149
+ if (!chunkMOJJ7QF6_cjs.needsValidatorRouter(approvedAlgIds)) {
1150
+ return { set: false, reason: "no router-delegated algorithm" };
1151
+ }
1152
+ const chainId = this.ethereum.getChainId();
1153
+ const canonicalRouter = chunkMXJEULSE_cjs.getCanonicalAddresses(chainId)?.aaStarValidator;
1154
+ const router = opts?.router ?? canonicalRouter;
1155
+ if (!router || router.toLowerCase() === viem.zeroAddress) {
1156
+ return { set: false, reason: `no canonical validator router for chain ${chainId}` };
1157
+ }
1158
+ let deployed = false;
1159
+ try {
1160
+ const code = await this.ethereum.getProvider().getCode({ address: account.address });
1161
+ deployed = !!code && code !== "0x";
1162
+ } catch {
1163
+ }
1164
+ if (!deployed) {
1165
+ return { set: false, reason: "account not deployed yet \u2014 call after deploy" };
1166
+ }
1167
+ const current = await this.ethereum.getAccountContract(account.address).read.validator([]);
1168
+ if (current && current.toLowerCase() !== viem.zeroAddress) {
1169
+ return { set: false, reason: "validator already set" };
1170
+ }
1171
+ const walletClient = opts?.walletClient;
1172
+ if (!walletClient || !walletClient.account) {
1173
+ return {
1174
+ set: false,
1175
+ reason: "walletClient (account owner) required to send setValidator",
1176
+ router
1177
+ };
1178
+ }
1179
+ const tx = await chunkMOJJ7QF6_cjs.airAccountActions(account.address)(walletClient).setValidator({
1180
+ validator: router,
1181
+ account: walletClient.account
1182
+ });
1183
+ this.logger.log(
1184
+ `[AccountManager] setValidator(${router}) sent for account ${account.address} (tx ${tx})`
1185
+ );
1186
+ return { set: true, tx, router };
1187
+ }
946
1188
  };
947
1189
  var EXECUTE_USER_OP_SELECTOR = chunkXQROKLZI_cjs.selectorFromId(
948
1190
  "executeUserOp((address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes),bytes32)"
@@ -1546,7 +1788,14 @@ var TransferManager = class {
1546
1788
  let deployCalldata;
1547
1789
  if (version === "0.7" /* V0_7 */ || version === "0.8" /* V0_8 */) {
1548
1790
  const storedDailyLimit = account.dailyLimit ? BigInt(account.dailyLimit) : 0n;
1549
- if (account.guardian1 && account.guardian2 && account.guardian1Sig && account.guardian2Sig) {
1791
+ if (account.guardianSpecs && account.guardianSpecs.length > 0) {
1792
+ const rebuilt = initConfigFromRecord(account);
1793
+ deployCalldata = encodeFn(AIRACCOUNT_FACTORY_ABI_PARSED, "createAccount", [
1794
+ account.signerAddress,
1795
+ BigInt(account.salt),
1796
+ initConfigToTuple(rebuilt)
1797
+ ]);
1798
+ } else if (account.guardian1 && account.guardian2 && account.guardian1Sig && account.guardian2Sig) {
1550
1799
  const sig1 = account.guardian1Sig.startsWith("0x") ? account.guardian1Sig : `0x${account.guardian1Sig}`;
1551
1800
  const sig2 = account.guardian2Sig.startsWith("0x") ? account.guardian2Sig : `0x${account.guardian2Sig}`;
1552
1801
  deployCalldata = encodeFn(AIRACCOUNT_FACTORY_ABI_PARSED, "createAccountWithDefaults", [
@@ -4776,12 +5025,15 @@ exports.beginGrantSessionChallenge = beginGrantSessionChallenge;
4776
5025
  exports.buildAuthenticationCredential = buildAuthenticationCredential;
4777
5026
  exports.buildAuthenticatorData = buildAuthenticatorData;
4778
5027
  exports.buildClientDataJSON = buildClientDataJSON;
5028
+ exports.buildFullInitConfig = buildFullInitConfig;
4779
5029
  exports.buildInstallModuleHash = buildInstallModuleHash;
4780
5030
  exports.buildUninstallModuleHash = buildUninstallModuleHash;
4781
5031
  exports.computeOapdSalt = computeOapdSalt;
4782
5032
  exports.erc8004AddressesForChain = erc8004AddressesForChain;
4783
5033
  exports.getOapdAddress = getOapdAddress;
4784
5034
  exports.getOapdAddressWithChainId = getOapdAddressWithChainId;
5035
+ exports.initConfigFromRecord = initConfigFromRecord;
5036
+ exports.initConfigToTuple = initConfigToTuple;
4785
5037
  exports.isExecuteUserOpWrapped = isExecuteUserOpWrapped;
4786
5038
  exports.isOapdDeployed = isOapdDeployed;
4787
5039
  exports.isPendingConfirmation = isPendingConfirmation;
@@ -4791,7 +5043,9 @@ exports.runAuthenticationCeremony = runAuthenticationCeremony;
4791
5043
  exports.runGrantSessionCeremony = runGrantSessionCeremony;
4792
5044
  exports.runWebAuthnCeremony = runWebAuthnCeremony;
4793
5045
  exports.sepoliaV07Config = sepoliaV07Config;
5046
+ exports.serializeGuardianSpecs = serializeGuardianSpecs;
5047
+ exports.toGuardianSpecs = toGuardianSpecs;
4794
5048
  exports.validateConfig = validateConfig;
4795
5049
  exports.wrapExecuteUserOp = wrapExecuteUserOp;
4796
- //# sourceMappingURL=chunk-OVNOSAL3.cjs.map
4797
- //# sourceMappingURL=chunk-OVNOSAL3.cjs.map
5050
+ //# sourceMappingURL=chunk-Y5U7URNZ.cjs.map
5051
+ //# sourceMappingURL=chunk-Y5U7URNZ.cjs.map