@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.
- package/dist/UserClient-KYDCMAIU.js +6 -0
- package/dist/{UserClient-Y65JLJ23.js.map → UserClient-KYDCMAIU.js.map} +1 -1
- package/dist/UserClient-S6LS3CB6.cjs +15 -0
- package/dist/{UserClient-AJOGJXOC.cjs.map → UserClient-S6LS3CB6.cjs.map} +1 -1
- package/dist/account.cjs +7 -7
- package/dist/account.js +2 -2
- package/dist/admin.cjs +3 -3
- package/dist/admin.js +2 -2
- package/dist/airaccount.cjs +117 -97
- package/dist/airaccount.d.cts +2 -1
- package/dist/airaccount.d.ts +2 -1
- package/dist/airaccount.js +2 -2
- package/dist/channel.cjs +6 -6
- package/dist/channel.js +2 -2
- package/dist/{chunk-RF3MSLRW.cjs → chunk-5PH5CSM7.cjs} +16 -16
- package/dist/{chunk-RF3MSLRW.cjs.map → chunk-5PH5CSM7.cjs.map} +1 -1
- package/dist/{chunk-LKSQASFZ.js → chunk-654GQ7G7.js} +3 -3
- package/dist/{chunk-LKSQASFZ.js.map → chunk-654GQ7G7.js.map} +1 -1
- package/dist/{chunk-3OIVYXUG.cjs → chunk-72JZKARR.cjs} +6 -6
- package/dist/{chunk-3OIVYXUG.cjs.map → chunk-72JZKARR.cjs.map} +1 -1
- package/dist/{chunk-JCK7VAZF.js → chunk-7RVONA2R.js} +8 -8
- package/dist/{chunk-JCK7VAZF.js.map → chunk-7RVONA2R.js.map} +1 -1
- package/dist/{chunk-MG72SGVS.cjs → chunk-A4ICWCHR.cjs} +5 -5
- package/dist/{chunk-MG72SGVS.cjs.map → chunk-A4ICWCHR.cjs.map} +1 -1
- package/dist/{chunk-6ISQM3SF.cjs → chunk-BOVDJSMK.cjs} +26 -26
- package/dist/{chunk-6ISQM3SF.cjs.map → chunk-BOVDJSMK.cjs.map} +1 -1
- package/dist/{chunk-2TS6T2WY.js → chunk-BYVG7MO7.js} +35 -4
- package/dist/chunk-BYVG7MO7.js.map +1 -0
- package/dist/{chunk-7RNOKMAJ.cjs → chunk-D667CUUS.cjs} +9 -9
- package/dist/{chunk-7RNOKMAJ.cjs.map → chunk-D667CUUS.cjs.map} +1 -1
- package/dist/{chunk-XZDMKHKG.js → chunk-DAMWXGKD.js} +3 -3
- package/dist/{chunk-XZDMKHKG.js.map → chunk-DAMWXGKD.js.map} +1 -1
- package/dist/{chunk-BLA57KBS.cjs → chunk-GDH4DSVM.cjs} +12 -12
- package/dist/{chunk-BLA57KBS.cjs.map → chunk-GDH4DSVM.cjs.map} +1 -1
- package/dist/{chunk-FZLBMUPN.cjs → chunk-HNJBQR5U.cjs} +5 -5
- package/dist/{chunk-FZLBMUPN.cjs.map → chunk-HNJBQR5U.cjs.map} +1 -1
- package/dist/{chunk-VUNNHEND.js → chunk-JMW5AHLC.js} +9 -9
- package/dist/{chunk-VUNNHEND.js.map → chunk-JMW5AHLC.js.map} +1 -1
- package/dist/{chunk-SNVHOCU6.js → chunk-LDARLWS3.js} +3 -3
- package/dist/{chunk-SNVHOCU6.js.map → chunk-LDARLWS3.js.map} +1 -1
- package/dist/{chunk-TS5CXRNI.cjs → chunk-MOJJ7QF6.cjs} +40 -3
- package/dist/{chunk-TS5CXRNI.cjs.map → chunk-MOJJ7QF6.cjs.map} +1 -1
- package/dist/{chunk-BBZAD5G2.cjs → chunk-NVYVTCHJ.cjs} +11 -11
- package/dist/{chunk-BBZAD5G2.cjs.map → chunk-NVYVTCHJ.cjs.map} +1 -1
- package/dist/{chunk-MQMTICTP.js → chunk-PNBK2CLK.js} +3 -3
- package/dist/{chunk-MQMTICTP.js.map → chunk-PNBK2CLK.js.map} +1 -1
- package/dist/{chunk-T2GF4S3E.js → chunk-PXQDAFXD.js} +6 -6
- package/dist/{chunk-T2GF4S3E.js.map → chunk-PXQDAFXD.js.map} +1 -1
- package/dist/{chunk-XTF6MNIK.js → chunk-RZ2M2RVP.js} +3 -3
- package/dist/{chunk-XTF6MNIK.js.map → chunk-RZ2M2RVP.js.map} +1 -1
- package/dist/{chunk-7HO4IUHZ.cjs → chunk-VHY6R2PI.cjs} +32 -32
- package/dist/{chunk-7HO4IUHZ.cjs.map → chunk-VHY6R2PI.cjs.map} +1 -1
- package/dist/{chunk-R3N7L7RE.js → chunk-WC25H5VG.js} +4 -4
- package/dist/{chunk-R3N7L7RE.js.map → chunk-WC25H5VG.js.map} +1 -1
- package/dist/{chunk-UUT246S2.js → chunk-WVJ4LQVB.js} +3 -3
- package/dist/{chunk-UUT246S2.js.map → chunk-WVJ4LQVB.js.map} +1 -1
- package/dist/{chunk-DOVGH7HB.cjs → chunk-WVOJV4Q5.cjs} +4 -4
- package/dist/{chunk-DOVGH7HB.cjs.map → chunk-WVOJV4Q5.cjs.map} +1 -1
- package/dist/{chunk-OVNOSAL3.cjs → chunk-Y5U7URNZ.cjs} +260 -6
- package/dist/chunk-Y5U7URNZ.cjs.map +1 -0
- package/dist/{chunk-6OWZOTE7.js → chunk-YUFQIYLR.js} +258 -9
- package/dist/chunk-YUFQIYLR.js.map +1 -0
- package/dist/core.cjs +226 -202
- package/dist/core.d.cts +100 -513
- package/dist/core.d.ts +100 -513
- package/dist/core.js +1 -1
- package/dist/dapp.cjs +5 -5
- package/dist/dapp.js +2 -2
- package/dist/enduser.cjs +6 -6
- package/dist/enduser.js +3 -3
- package/dist/identity.cjs +5 -5
- package/dist/identity.js +2 -2
- package/dist/index.cjs +327 -303
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +15 -15
- package/dist/initConfig-D8jgrcDb.d.cts +518 -0
- package/dist/initConfig-D8jgrcDb.d.ts +518 -0
- package/dist/kms.cjs +117 -97
- package/dist/kms.d.cts +223 -3
- package/dist/kms.d.ts +223 -3
- package/dist/kms.js +2 -2
- package/dist/operator.cjs +6 -6
- package/dist/operator.js +2 -2
- package/dist/paymaster.cjs +15 -15
- package/dist/paymaster.js +2 -2
- package/dist/src-5URXSFKD.js +5 -0
- package/dist/src-5URXSFKD.js.map +1 -0
- package/dist/{src-WGYHZSLY.cjs → src-72GWEAPA.cjs} +17 -17
- package/dist/src-72GWEAPA.cjs.map +1 -0
- package/dist/{src-UQ4RDCJG.cjs → src-N72HAQXS.cjs} +228 -204
- package/dist/src-N72HAQXS.cjs.map +1 -0
- package/dist/{src-MDGW57S5.js → src-UNS5B7FX.js} +4 -4
- package/dist/{src-UQ4RDCJG.cjs.map → src-UNS5B7FX.js.map} +1 -1
- package/dist/tokens.cjs +3 -3
- package/dist/tokens.js +2 -2
- package/dist/x402.cjs +25 -25
- package/dist/x402.js +2 -2
- package/package.json +1 -1
- package/dist/UserClient-AJOGJXOC.cjs +0 -15
- package/dist/UserClient-Y65JLJ23.js +0 -6
- package/dist/chunk-2TS6T2WY.js.map +0 -1
- package/dist/chunk-6OWZOTE7.js.map +0 -1
- package/dist/chunk-OVNOSAL3.cjs.map +0 -1
- package/dist/src-MDGW57S5.js.map +0 -1
- package/dist/src-SCR3OCME.js +0 -5
- package/dist/src-SCR3OCME.js.map +0 -1
- package/dist/src-WGYHZSLY.cjs.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
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 {
|
|
3
|
-
import {
|
|
2
|
+
import { buildInitConfig, needsValidatorRouter, airAccountActions } from './chunk-BYVG7MO7.js';
|
|
3
|
+
import { CANONICAL_ADDRESSES, getCanonicalAddresses } from './chunk-UCLK6LTB.js';
|
|
4
|
+
import { parseAbi, createPublicClient, http, getContract, formatEther, parseUnits, parseEther, encodeFunctionData, zeroAddress, concat, numberToHex, hexToBytes, formatUnits, encodeAbiParameters, keccak256 as keccak256$1, hashMessage as hashMessage$1, toRlp, concatHex, recoverAddress as recoverAddress$1 } from 'viem';
|
|
4
5
|
import axios from 'axios';
|
|
5
6
|
import { createHash } from 'crypto';
|
|
6
7
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
@@ -190,8 +191,8 @@ var AIRACCOUNT_ABI = [
|
|
|
190
191
|
];
|
|
191
192
|
var AIRACCOUNT_FACTORY_ABI = [
|
|
192
193
|
// Full config creation
|
|
193
|
-
"function createAccount(address owner, uint256 salt, (address[3] guardians, bytes32[3] guardianP256X, bytes32[3] guardianP256Y, uint256 dailyLimit, uint8[] approvedAlgIds, uint256 minDailyLimit, address[] initialTokens, (
|
|
194
|
-
"function getAddress(address owner, uint256 salt, (address[3] guardians, bytes32[3] guardianP256X, bytes32[3] guardianP256Y, uint256 dailyLimit, uint8[] approvedAlgIds, uint256 minDailyLimit, address[] initialTokens, (
|
|
194
|
+
"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)",
|
|
195
|
+
"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)",
|
|
195
196
|
// Default guardian setup (requires guardian acceptance sigs — M5.3+)
|
|
196
197
|
"function createAccountWithDefaults(address owner, uint256 salt, address guardian1, bytes guardian1Sig, address guardian2, bytes guardian2Sig, uint256 dailyLimit) external returns (address)",
|
|
197
198
|
"function getAddressWithDefaults(address owner, uint256 salt, address guardian1, address guardian2, uint256 dailyLimit) external view returns (address)",
|
|
@@ -208,7 +209,7 @@ var AIRACCOUNT_FACTORY_ABI = [
|
|
|
208
209
|
"function defaultHookModule() external view returns (address)",
|
|
209
210
|
// M7.4 ERC-7828 chain-qualified address helpers
|
|
210
211
|
"function getChainQualifiedAddress(address account) external view returns (bytes32)",
|
|
211
|
-
"function getAddressWithChainId(address owner, uint256 salt, (address[3] guardians, bytes32[3] guardianP256X, bytes32[3] guardianP256Y, uint256 dailyLimit, uint8[] approvedAlgIds, uint256 minDailyLimit, address[] initialTokens, (
|
|
212
|
+
"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)",
|
|
212
213
|
// Events
|
|
213
214
|
"event AccountCreated(address indexed account, address indexed owner, uint256 salt)"
|
|
214
215
|
];
|
|
@@ -464,6 +465,10 @@ var EthereumProvider = class {
|
|
|
464
465
|
getBundlerProvider() {
|
|
465
466
|
return this.bundlerProvider;
|
|
466
467
|
}
|
|
468
|
+
/** EVM chain id from the validated ServerConfig (deterministic — no RPC round-trip). */
|
|
469
|
+
getChainId() {
|
|
470
|
+
return this.config.chainId;
|
|
471
|
+
}
|
|
467
472
|
/**
|
|
468
473
|
* Raw bundler JSON-RPC call. The bundler exposes non-standard methods
|
|
469
474
|
* (eth_sendUserOperation, pimlico_getUserOperationGasPrice, ...) that are not in
|
|
@@ -709,6 +714,55 @@ function readBuildP256GrantHash(validator, account, keyX, keyY, cfg) {
|
|
|
709
714
|
return readFn(validator, "buildP256GrantHash")([account, keyX, keyY, cfg]);
|
|
710
715
|
}
|
|
711
716
|
|
|
717
|
+
// ../airaccount/src/server/services/account-init-config.ts
|
|
718
|
+
function toGuardianSpecs(p) {
|
|
719
|
+
const specs = [];
|
|
720
|
+
for (const e of p.ecdsaGuardians ?? []) specs.push({ ecdsa: e });
|
|
721
|
+
for (const k of p.p256Guardians) specs.push({ p256: { x: k.x, y: k.y } });
|
|
722
|
+
return specs;
|
|
723
|
+
}
|
|
724
|
+
function buildFullInitConfig(p) {
|
|
725
|
+
return buildInitConfig({
|
|
726
|
+
guardians: toGuardianSpecs(p),
|
|
727
|
+
dailyLimit: p.dailyLimit,
|
|
728
|
+
...p.approvedAlgIds ? { approvedAlgIds: p.approvedAlgIds } : {},
|
|
729
|
+
...p.minDailyLimit !== void 0 ? { minDailyLimit: p.minDailyLimit } : {}
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
function initConfigToTuple(c) {
|
|
733
|
+
return [
|
|
734
|
+
c.guardians,
|
|
735
|
+
c.guardianP256X,
|
|
736
|
+
c.guardianP256Y,
|
|
737
|
+
c.dailyLimit,
|
|
738
|
+
c.approvedAlgIds,
|
|
739
|
+
c.minDailyLimit,
|
|
740
|
+
c.initialTokens,
|
|
741
|
+
c.initialTokenConfigs.map((t) => [t.tier1Limit, t.tier2Limit, t.dailyLimit])
|
|
742
|
+
];
|
|
743
|
+
}
|
|
744
|
+
function serializeGuardianSpecs(specs) {
|
|
745
|
+
return specs.map(
|
|
746
|
+
(s) => s.p256 ? { p256: { x: s.p256.x, y: s.p256.y } } : { ecdsa: s.ecdsa }
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
function initConfigFromRecord(record) {
|
|
750
|
+
if (!record.guardianSpecs || record.guardianSpecs.length === 0) {
|
|
751
|
+
throw new Error(
|
|
752
|
+
"initConfigFromRecord: record has no guardianSpecs (not a full-config / P-256 account)"
|
|
753
|
+
);
|
|
754
|
+
}
|
|
755
|
+
const guardians = record.guardianSpecs.map(
|
|
756
|
+
(s) => "p256" in s ? { p256: { x: s.p256.x, y: s.p256.y } } : { ecdsa: s.ecdsa }
|
|
757
|
+
);
|
|
758
|
+
return buildInitConfig({
|
|
759
|
+
guardians,
|
|
760
|
+
dailyLimit: record.dailyLimit ? BigInt(record.dailyLimit) : 0n,
|
|
761
|
+
...record.approvedAlgIds ? { approvedAlgIds: record.approvedAlgIds } : {},
|
|
762
|
+
...record.minDailyLimit !== void 0 ? { minDailyLimit: BigInt(record.minDailyLimit) } : {}
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
|
|
712
766
|
// ../airaccount/src/server/services/account-manager.ts
|
|
713
767
|
var ZERO32 = "0x" + "0".repeat(64);
|
|
714
768
|
var EMPTY_P256 = [ZERO32, ZERO32, ZERO32];
|
|
@@ -721,6 +775,17 @@ var AccountManager = class {
|
|
|
721
775
|
}
|
|
722
776
|
logger;
|
|
723
777
|
async createAccount(userId, options) {
|
|
778
|
+
if (options?.p256Guardians && options.p256Guardians.length > 0) {
|
|
779
|
+
return this.createAccountWithP256Guardians(userId, {
|
|
780
|
+
p256Guardians: options.p256Guardians,
|
|
781
|
+
ecdsaGuardians: options.ecdsaGuardians,
|
|
782
|
+
dailyLimit: options.dailyLimit ?? 0n,
|
|
783
|
+
approvedAlgIds: options.approvedAlgIds,
|
|
784
|
+
minDailyLimit: options.minDailyLimit,
|
|
785
|
+
salt: options.salt,
|
|
786
|
+
entryPointVersion: options.entryPointVersion
|
|
787
|
+
});
|
|
788
|
+
}
|
|
724
789
|
const version = options?.entryPointVersion ?? this.ethereum.getDefaultVersion();
|
|
725
790
|
const versionStr = version;
|
|
726
791
|
const existingAccounts = await this.storage.getAccounts();
|
|
@@ -937,6 +1002,183 @@ var AccountManager = class {
|
|
|
937
1002
|
this.logger.log(`[AccountManager] account created with guardians: ${accountAddress}`);
|
|
938
1003
|
return account;
|
|
939
1004
|
}
|
|
1005
|
+
/**
|
|
1006
|
+
* Create an AirAccount with one or more P-256 (WebAuthn passkey) guardians installed at
|
|
1007
|
+
* DEPLOY time — the server-client path #118 adds for KMS-custodied / counterfactual accounts
|
|
1008
|
+
* (e.g. YAA) that cannot drive the viem extension layer for account creation.
|
|
1009
|
+
*
|
|
1010
|
+
* Uses the factory's full-config `createAccount(owner, salt, config)` path because it is the
|
|
1011
|
+
* ONLY entrypoint that accepts an 8-field `InitConfig` (and therefore `guardianP256X/Y`). The
|
|
1012
|
+
* 8-field config is built by the core `buildInitConfig` (0.22.0) — never hand-rolled — and the
|
|
1013
|
+
* address is predicted via the factory's full-config `getAddress(owner, salt, config)` (NOT
|
|
1014
|
+
* `getAddressWithDefaults`), binding the address to `keccak256(config)`.
|
|
1015
|
+
*
|
|
1016
|
+
* ### Acceptance-signature semantics (verified against AAStarAirAccountFactoryV7.sol)
|
|
1017
|
+
* On this path the contract performs NO guardian-acceptance signature check — for P-256 OR ECDSA
|
|
1018
|
+
* guardians. Front-run protection comes from `_getSalt(owner, salt, _getConfigHash(config))`:
|
|
1019
|
+
* any change to the guardian set (or any other config field) yields a different CREATE2 address,
|
|
1020
|
+
* so an attacker cannot collide on the victim's counterfactual address with a weaker config.
|
|
1021
|
+
* P-256 guardians are an owner-bootstrap (single guardian can't form a recovery quorum), so no
|
|
1022
|
+
* acceptance ceremony exists for them by design (#110④). This is why optional ECDSA guardians may
|
|
1023
|
+
* also be passed here WITHOUT signatures — distinct from createAccountWithGuardians(), which uses
|
|
1024
|
+
* the owner-only-salt `createAccountWithDefaults` path and DOES require ECDSA acceptance sigs.
|
|
1025
|
+
*
|
|
1026
|
+
* The deploy UserOp is still signed by the existing KMS owner-key path (unchanged): this method
|
|
1027
|
+
* only predicts the address and persists the full config; transfer-manager rebuilds the
|
|
1028
|
+
* byte-identical initCode (via {@link initConfigFromRecord}) at first-UserOp deploy time.
|
|
1029
|
+
*
|
|
1030
|
+
* @throws if no P-256 guardian is supplied, dailyLimit <= 0, or EntryPoint is v0.6.
|
|
1031
|
+
*/
|
|
1032
|
+
async createAccountWithP256Guardians(userId, params) {
|
|
1033
|
+
if (!params.p256Guardians || params.p256Guardians.length === 0) {
|
|
1034
|
+
throw new Error("createAccountWithP256Guardians requires at least one P-256 guardian");
|
|
1035
|
+
}
|
|
1036
|
+
if (params.dailyLimit <= 0n) {
|
|
1037
|
+
throw new Error(
|
|
1038
|
+
"P-256 guardian accounts require dailyLimit > 0 (a guardian set enables the on-chain guard)"
|
|
1039
|
+
);
|
|
1040
|
+
}
|
|
1041
|
+
const version = params.entryPointVersion ?? this.ethereum.getDefaultVersion();
|
|
1042
|
+
if (version === "0.6" /* V0_6 */) {
|
|
1043
|
+
throw new Error(
|
|
1044
|
+
"createAccountWithP256Guardians requires EntryPoint v0.7 or v0.8; the v0.6 factory does not support the full-config createAccount(InitConfig) path"
|
|
1045
|
+
);
|
|
1046
|
+
}
|
|
1047
|
+
const versionStr = version;
|
|
1048
|
+
const fullParams = {
|
|
1049
|
+
p256Guardians: params.p256Guardians,
|
|
1050
|
+
ecdsaGuardians: params.ecdsaGuardians,
|
|
1051
|
+
dailyLimit: params.dailyLimit,
|
|
1052
|
+
approvedAlgIds: params.approvedAlgIds,
|
|
1053
|
+
minDailyLimit: params.minDailyLimit
|
|
1054
|
+
};
|
|
1055
|
+
const specs = toGuardianSpecs(fullParams);
|
|
1056
|
+
const config = buildFullInitConfig(fullParams);
|
|
1057
|
+
const existingAccounts = await this.storage.getAccounts();
|
|
1058
|
+
const existing = existingAccounts.find(
|
|
1059
|
+
(a) => a.userId === userId && a.entryPointVersion === versionStr && !!a.guardianSpecs && a.guardianSpecs.length > 0
|
|
1060
|
+
);
|
|
1061
|
+
if (existing) return existing;
|
|
1062
|
+
const { address: signerAddress } = await this.signer.ensureSigner(userId);
|
|
1063
|
+
if (typeof params.salt === "number" && !Number.isSafeInteger(params.salt)) {
|
|
1064
|
+
throw new Error(
|
|
1065
|
+
`salt value ${params.salt} exceeds Number.MAX_SAFE_INTEGER; pass it as a bigint to avoid precision loss`
|
|
1066
|
+
);
|
|
1067
|
+
}
|
|
1068
|
+
const saltBig = BigInt(params.salt ?? Math.floor(Math.random() * 1e6));
|
|
1069
|
+
const factory = this.ethereum.getFactoryContract(version);
|
|
1070
|
+
const factoryAddress = factory.address ?? this.ethereum.getFactoryAddress(version);
|
|
1071
|
+
const accountAddress = await readPredictedAddress(
|
|
1072
|
+
factory,
|
|
1073
|
+
signerAddress,
|
|
1074
|
+
saltBig,
|
|
1075
|
+
initConfigToTuple(config)
|
|
1076
|
+
);
|
|
1077
|
+
let deployed = false;
|
|
1078
|
+
try {
|
|
1079
|
+
const code = await this.ethereum.getProvider().getCode({ address: accountAddress });
|
|
1080
|
+
deployed = !!code && code !== "0x";
|
|
1081
|
+
} catch {
|
|
1082
|
+
}
|
|
1083
|
+
const validatorAddress = this.ethereum.getValidatorAddress(version);
|
|
1084
|
+
const account = {
|
|
1085
|
+
userId,
|
|
1086
|
+
address: accountAddress,
|
|
1087
|
+
signerAddress,
|
|
1088
|
+
// Persist as a lossless decimal string (#118 M2); transfer-manager rebuilds via BigInt(account.salt).
|
|
1089
|
+
salt: saltBig.toString(),
|
|
1090
|
+
deployed,
|
|
1091
|
+
deploymentTxHash: null,
|
|
1092
|
+
validatorAddress,
|
|
1093
|
+
entryPointVersion: versionStr,
|
|
1094
|
+
factoryAddress,
|
|
1095
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1096
|
+
dailyLimit: params.dailyLimit.toString(),
|
|
1097
|
+
// Persist the RESOLVED config so transfer-manager rebuilds byte-identical initCode at deploy.
|
|
1098
|
+
guardianSpecs: serializeGuardianSpecs(specs),
|
|
1099
|
+
approvedAlgIds: [...config.approvedAlgIds],
|
|
1100
|
+
minDailyLimit: config.minDailyLimit.toString()
|
|
1101
|
+
};
|
|
1102
|
+
await this.storage.saveAccount(account);
|
|
1103
|
+
this.logger.log(
|
|
1104
|
+
`[AccountManager] account created with ${params.p256Guardians.length} P-256 guardian(s): ${accountAddress}`
|
|
1105
|
+
);
|
|
1106
|
+
if (needsValidatorRouter(config.approvedAlgIds)) {
|
|
1107
|
+
this.logger.log(
|
|
1108
|
+
`[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.`
|
|
1109
|
+
);
|
|
1110
|
+
}
|
|
1111
|
+
return account;
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* Gap B — wire the validator router for an account that approved a ROUTER-DELEGATED signature
|
|
1115
|
+
* algorithm (BLS 0x01, cumulative T2 0x04, T3 0x05, weighted 0x07, session 0x08, ...). Such an
|
|
1116
|
+
* account's `_validateTripleSignature` / `_callBLSValidator` return `1` (FAIL) while
|
|
1117
|
+
* `validator() == address(0)`, so the algorithm is non-functional until the owner calls
|
|
1118
|
+
* `setValidator(router)` (onlyOwner, SET-ONCE). Inline algIds (ECDSA 0x02, P256 0x03, COMBINED_T1
|
|
1119
|
+
* 0x06) need no router and are a no-op here.
|
|
1120
|
+
*
|
|
1121
|
+
* MUST be called AFTER the account is deployed (setValidator is onlyOwner and needs code) — the
|
|
1122
|
+
* lazy/counterfactual deploy path cannot setValidator at predict-time. Idempotent: re-running after
|
|
1123
|
+
* the validator is set is a no-op (`reason: 'validator already set'`).
|
|
1124
|
+
*
|
|
1125
|
+
* On-chain access matches the rest of this package: reads via the EthereumProvider's PublicClient
|
|
1126
|
+
* (`getAccountContract(...).read.validator()` and `getProvider().getCode()`); the state-changing
|
|
1127
|
+
* `setValidator` is sent through a caller-supplied `WalletClient` whose account is the owner —
|
|
1128
|
+
* the same convention used by `PaymasterManager.updatePrice` / `ForceExitService` (this manager's
|
|
1129
|
+
* narrow `ISignerAdapter` only EIP-191 personal-signs and cannot send transactions).
|
|
1130
|
+
*
|
|
1131
|
+
* @param userId the account owner's user id (storage key)
|
|
1132
|
+
* @param opts.router override the router address (defaults to the chain's canonical
|
|
1133
|
+
* `aaStarValidator`); pass to target a non-canonical router
|
|
1134
|
+
* @param opts.walletClient viem WalletClient signing as the account OWNER — REQUIRED to send the tx
|
|
1135
|
+
*/
|
|
1136
|
+
async ensureValidatorRouter(userId, opts) {
|
|
1137
|
+
const account = await this.storage.findAccountByUserId(userId);
|
|
1138
|
+
if (!account) throw new Error("Account not found");
|
|
1139
|
+
const approvedAlgIds = account.approvedAlgIds;
|
|
1140
|
+
if (!approvedAlgIds || approvedAlgIds.length === 0) {
|
|
1141
|
+
return { set: false, reason: "no approvedAlgIds / not router-delegated" };
|
|
1142
|
+
}
|
|
1143
|
+
if (!needsValidatorRouter(approvedAlgIds)) {
|
|
1144
|
+
return { set: false, reason: "no router-delegated algorithm" };
|
|
1145
|
+
}
|
|
1146
|
+
const chainId = this.ethereum.getChainId();
|
|
1147
|
+
const canonicalRouter = getCanonicalAddresses(chainId)?.aaStarValidator;
|
|
1148
|
+
const router = opts?.router ?? canonicalRouter;
|
|
1149
|
+
if (!router || router.toLowerCase() === zeroAddress) {
|
|
1150
|
+
return { set: false, reason: `no canonical validator router for chain ${chainId}` };
|
|
1151
|
+
}
|
|
1152
|
+
let deployed = false;
|
|
1153
|
+
try {
|
|
1154
|
+
const code = await this.ethereum.getProvider().getCode({ address: account.address });
|
|
1155
|
+
deployed = !!code && code !== "0x";
|
|
1156
|
+
} catch {
|
|
1157
|
+
}
|
|
1158
|
+
if (!deployed) {
|
|
1159
|
+
return { set: false, reason: "account not deployed yet \u2014 call after deploy" };
|
|
1160
|
+
}
|
|
1161
|
+
const current = await this.ethereum.getAccountContract(account.address).read.validator([]);
|
|
1162
|
+
if (current && current.toLowerCase() !== zeroAddress) {
|
|
1163
|
+
return { set: false, reason: "validator already set" };
|
|
1164
|
+
}
|
|
1165
|
+
const walletClient = opts?.walletClient;
|
|
1166
|
+
if (!walletClient || !walletClient.account) {
|
|
1167
|
+
return {
|
|
1168
|
+
set: false,
|
|
1169
|
+
reason: "walletClient (account owner) required to send setValidator",
|
|
1170
|
+
router
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
const tx = await airAccountActions(account.address)(walletClient).setValidator({
|
|
1174
|
+
validator: router,
|
|
1175
|
+
account: walletClient.account
|
|
1176
|
+
});
|
|
1177
|
+
this.logger.log(
|
|
1178
|
+
`[AccountManager] setValidator(${router}) sent for account ${account.address} (tx ${tx})`
|
|
1179
|
+
);
|
|
1180
|
+
return { set: true, tx, router };
|
|
1181
|
+
}
|
|
940
1182
|
};
|
|
941
1183
|
var EXECUTE_USER_OP_SELECTOR = selectorFromId(
|
|
942
1184
|
"executeUserOp((address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes),bytes32)"
|
|
@@ -1540,7 +1782,14 @@ var TransferManager = class {
|
|
|
1540
1782
|
let deployCalldata;
|
|
1541
1783
|
if (version === "0.7" /* V0_7 */ || version === "0.8" /* V0_8 */) {
|
|
1542
1784
|
const storedDailyLimit = account.dailyLimit ? BigInt(account.dailyLimit) : 0n;
|
|
1543
|
-
if (account.
|
|
1785
|
+
if (account.guardianSpecs && account.guardianSpecs.length > 0) {
|
|
1786
|
+
const rebuilt = initConfigFromRecord(account);
|
|
1787
|
+
deployCalldata = encodeFn(AIRACCOUNT_FACTORY_ABI_PARSED, "createAccount", [
|
|
1788
|
+
account.signerAddress,
|
|
1789
|
+
BigInt(account.salt),
|
|
1790
|
+
initConfigToTuple(rebuilt)
|
|
1791
|
+
]);
|
|
1792
|
+
} else if (account.guardian1 && account.guardian2 && account.guardian1Sig && account.guardian2Sig) {
|
|
1544
1793
|
const sig1 = account.guardian1Sig.startsWith("0x") ? account.guardian1Sig : `0x${account.guardian1Sig}`;
|
|
1545
1794
|
const sig2 = account.guardian2Sig.startsWith("0x") ? account.guardian2Sig : `0x${account.guardian2Sig}`;
|
|
1546
1795
|
deployCalldata = encodeFn(AIRACCOUNT_FACTORY_ABI_PARSED, "createAccountWithDefaults", [
|
|
@@ -4692,6 +4941,6 @@ var LocalWalletSigner = class {
|
|
|
4692
4941
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
4693
4942
|
*/
|
|
4694
4943
|
|
|
4695
|
-
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 };
|
|
4696
|
-
//# sourceMappingURL=chunk-
|
|
4697
|
-
//# sourceMappingURL=chunk-
|
|
4944
|
+
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, buildFullInitConfig, buildInstallModuleHash, buildUninstallModuleHash, computeOapdSalt, erc8004AddressesForChain, getOapdAddress, getOapdAddressWithChainId, initConfigFromRecord, initConfigToTuple, isExecuteUserOpWrapped, isOapdDeployed, isPendingConfirmation, packP256SessionSignature, packSecp256k1SessionSignature, runAuthenticationCeremony, runGrantSessionCeremony, runWebAuthnCeremony, sepoliaV07Config, serializeGuardianSpecs, toGuardianSpecs, validateConfig, wrapExecuteUserOp };
|
|
4945
|
+
//# sourceMappingURL=chunk-YUFQIYLR.js.map
|
|
4946
|
+
//# sourceMappingURL=chunk-YUFQIYLR.js.map
|