@account-kit/smart-contracts 4.12.1-alpha.0 → 4.13.1-alpha.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/esm/src/index.d.ts +5 -0
- package/dist/esm/src/index.js +2 -0
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/ma-v2/account/common/modularAccountV2Base.d.ts +39 -0
- package/dist/esm/src/ma-v2/account/{semiModularAccountV2.js → common/modularAccountV2Base.js} +32 -61
- package/dist/esm/src/ma-v2/account/common/modularAccountV2Base.js.map +1 -0
- package/dist/esm/src/ma-v2/account/modularAccountV2.d.ts +16 -0
- package/dist/esm/src/ma-v2/account/modularAccountV2.js +113 -0
- package/dist/esm/src/ma-v2/account/modularAccountV2.js.map +1 -0
- package/dist/esm/src/ma-v2/account/nativeSMASigner.d.ts +1 -1
- package/dist/esm/src/ma-v2/account/nativeSMASigner.js +1 -1
- package/dist/esm/src/ma-v2/account/nativeSMASigner.js.map +1 -1
- package/dist/esm/src/ma-v2/actions/install-validation/installValidation.d.ts +11 -9
- package/dist/esm/src/ma-v2/actions/install-validation/installValidation.js +43 -23
- package/dist/esm/src/ma-v2/actions/install-validation/installValidation.js.map +1 -1
- package/dist/esm/src/ma-v2/client/client.d.ts +7 -6
- package/dist/esm/src/ma-v2/client/client.js +21 -18
- package/dist/esm/src/ma-v2/client/client.js.map +1 -1
- package/dist/esm/src/ma-v2/index.d.ts +0 -4
- package/dist/esm/src/ma-v2/index.js +0 -2
- package/dist/esm/src/ma-v2/index.js.map +1 -1
- package/dist/esm/src/ma-v2/modules/allowlist-module/module.d.ts +14 -0
- package/dist/esm/src/ma-v2/modules/allowlist-module/module.js +14 -0
- package/dist/esm/src/ma-v2/modules/allowlist-module/module.js.map +1 -1
- package/dist/esm/src/ma-v2/modules/single-signer-validation/signer.d.ts +1 -1
- package/dist/esm/src/ma-v2/modules/single-signer-validation/signer.js +1 -1
- package/dist/esm/src/ma-v2/modules/single-signer-validation/signer.js.map +1 -1
- package/dist/esm/src/ma-v2/modules/time-range-module/module.d.ts +10 -1
- package/dist/esm/src/ma-v2/modules/time-range-module/module.js +20 -0
- package/dist/esm/src/ma-v2/modules/time-range-module/module.js.map +1 -1
- package/dist/types/src/index.d.ts +5 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/ma-v2/account/common/modularAccountV2Base.d.ts +40 -0
- package/dist/types/src/ma-v2/account/common/modularAccountV2Base.d.ts.map +1 -0
- package/dist/types/src/ma-v2/account/modularAccountV2.d.ts +17 -0
- package/dist/types/src/ma-v2/account/modularAccountV2.d.ts.map +1 -0
- package/dist/types/src/ma-v2/account/nativeSMASigner.d.ts +1 -1
- package/dist/types/src/ma-v2/actions/install-validation/installValidation.d.ts +11 -9
- package/dist/types/src/ma-v2/actions/install-validation/installValidation.d.ts.map +1 -1
- package/dist/types/src/ma-v2/client/client.d.ts +7 -6
- package/dist/types/src/ma-v2/client/client.d.ts.map +1 -1
- package/dist/types/src/ma-v2/index.d.ts +0 -4
- package/dist/types/src/ma-v2/index.d.ts.map +1 -1
- package/dist/types/src/ma-v2/modules/allowlist-module/module.d.ts +14 -0
- package/dist/types/src/ma-v2/modules/allowlist-module/module.d.ts.map +1 -1
- package/dist/types/src/ma-v2/modules/single-signer-validation/signer.d.ts +1 -1
- package/dist/types/src/ma-v2/modules/time-range-module/module.d.ts +10 -1
- package/dist/types/src/ma-v2/modules/time-range-module/module.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +7 -0
- package/src/ma-v2/account/{semiModularAccountV2.ts → common/modularAccountV2Base.ts} +62 -105
- package/src/ma-v2/account/modularAccountV2.ts +193 -0
- package/src/ma-v2/account/nativeSMASigner.ts +1 -1
- package/src/ma-v2/actions/install-validation/installValidation.ts +75 -36
- package/src/ma-v2/client/client.ts +54 -34
- package/src/ma-v2/index.ts +0 -5
- package/src/ma-v2/modules/allowlist-module/module.ts +29 -0
- package/src/ma-v2/modules/single-signer-validation/signer.ts +1 -1
- package/src/ma-v2/modules/time-range-module/module.ts +34 -1
- package/dist/esm/src/ma-v2/account/semiModularAccountV2.d.ts +0 -41
- package/dist/esm/src/ma-v2/account/semiModularAccountV2.js.map +0 -1
- package/dist/types/src/ma-v2/account/semiModularAccountV2.d.ts +0 -42
- package/dist/types/src/ma-v2/account/semiModularAccountV2.d.ts.map +0 -1
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { EntryPointDef, SmartAccountSigner, SmartContractAccountWithSigner, ToSmartContractAccountParams } from "@aa-sdk/core";
|
|
2
|
-
import { type Address, type Chain, type Hex, type Transport } from "viem";
|
|
3
|
-
export type SignerEntity = {
|
|
4
|
-
isGlobalValidation: boolean;
|
|
5
|
-
entityId: number;
|
|
6
|
-
};
|
|
7
|
-
export type ExecutionDataView = {
|
|
8
|
-
module: Address;
|
|
9
|
-
skipRuntimeValidation: boolean;
|
|
10
|
-
allowGlobalValidation: boolean;
|
|
11
|
-
executionHooks: readonly Hex[];
|
|
12
|
-
};
|
|
13
|
-
export type ValidationDataView = {
|
|
14
|
-
validationHooks: readonly Hex[];
|
|
15
|
-
executionHooks: readonly Hex[];
|
|
16
|
-
selectors: readonly Hex[];
|
|
17
|
-
validationFlags: number;
|
|
18
|
-
};
|
|
19
|
-
export type ValidationDataParams = {
|
|
20
|
-
validationModuleAddress: Address;
|
|
21
|
-
entityId?: never;
|
|
22
|
-
} | {
|
|
23
|
-
validationModuleAddress?: never;
|
|
24
|
-
entityId: number;
|
|
25
|
-
};
|
|
26
|
-
export type MAV2Account<TSigner extends SmartAccountSigner = SmartAccountSigner> = SmartContractAccountWithSigner<"MAV2Account", TSigner, "0.7.0"> & {
|
|
27
|
-
signerEntity: SignerEntity;
|
|
28
|
-
getExecutionData: (selector: Hex) => Promise<ExecutionDataView>;
|
|
29
|
-
getValidationData: (args: ValidationDataParams) => Promise<ValidationDataView>;
|
|
30
|
-
encodeCallData: (callData: Hex) => Promise<Hex>;
|
|
31
|
-
};
|
|
32
|
-
export type CreateSMAV2AccountParams<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner> = Pick<ToSmartContractAccountParams<"MAV2Account", TTransport, Chain, "0.7.0">, "transport" | "chain" | "accountAddress"> & {
|
|
33
|
-
signer: TSigner;
|
|
34
|
-
salt?: bigint;
|
|
35
|
-
factoryAddress?: Address;
|
|
36
|
-
initCode?: Hex;
|
|
37
|
-
initialOwner?: Address;
|
|
38
|
-
entryPoint?: EntryPointDef<"0.7.0", Chain>;
|
|
39
|
-
signerEntity?: SignerEntity;
|
|
40
|
-
};
|
|
41
|
-
export declare function createSMAV2Account<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner>(config: CreateSMAV2AccountParams<TTransport, TSigner>): Promise<MAV2Account<TSigner>>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"semiModularAccountV2.js","sourceRoot":"","sources":["../../../../../src/ma-v2/account/semiModularAccountV2.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,UAAU,EACV,WAAW,GAKZ,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,yBAAyB,EAAE,MAAM,+CAA+C,CAAC;AAC1F,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,qBAAqB,GAAQ,YAAY,CAAC;AAiEhD;;;;;;G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CAAC;QACnD,OAAO,MAAM,eAAe,CAAC,IAAI,CAAC,iBAAiB,CAAC;YAClD,qBAAqB,CAAC;gBACpB,aAAa,EAAE,uBAAuB,IAAI,WAAW;gBACrD,QAAQ,EAAE,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC;aACxC,CAAC;SACH,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,cAAc,GAAG,KAAK,EAAE,QAAa,EAAgB,EAAE;QAC3D,MAAM,cAAc,GAAG,MAAM,iBAAiB,CAAC;YAC7C,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;SAC3B,CAAC,CAAC;QAEH,OAAO,cAAc,CAAC,cAAc,CAAC,MAAM;YACzC,CAAC,CAAC,SAAS,CAAC,CAAC,qBAAqB,EAAE,QAAQ,CAAC,CAAC;YAC9C,CAAC,CAAC,QAAQ,CAAC;IACf,CAAC,CAAC;IAEF,OAAO;QACL,GAAG,WAAW;QACd,eAAe;QACf,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM;QACvB,YAAY;QACZ,gBAAgB;QAChB,iBAAiB;QACjB,cAAc;KACf,CAAC;AACJ,CAAC","sourcesContent":["import type {\n EntryPointDef,\n SmartAccountSigner,\n AccountOp,\n SmartContractAccountWithSigner,\n ToSmartContractAccountParams,\n} from \"@aa-sdk/core\";\nimport {\n createBundlerClient,\n getEntryPoint,\n toSmartContractAccount,\n InvalidEntityIdError,\n InvalidNonceKeyError,\n getAccountAddress,\n} from \"@aa-sdk/core\";\nimport {\n concatHex,\n encodeFunctionData,\n getContract,\n maxUint32,\n maxUint152,\n zeroAddress,\n type Address,\n type Chain,\n type Hex,\n type Transport,\n} from \"viem\";\nimport { accountFactoryAbi } from \"../abis/accountFactoryAbi.js\";\nimport {\n getDefaultMAV2FactoryAddress,\n DEFAULT_OWNER_ENTITY_ID,\n} from \"../utils.js\";\nimport { singleSignerMessageSigner } from \"../modules/single-signer-validation/signer.js\";\nimport { nativeSMASigner } from \"./nativeSMASigner.js\";\nimport { modularAccountAbi } from \"../abis/modularAccountAbi.js\";\nimport { serializeModuleEntity } from \"../actions/common/utils.js\";\n\nconst executeUserOpSelector: Hex = \"0x8DD7712F\";\n\nexport type SignerEntity = {\n isGlobalValidation: boolean;\n entityId: number;\n};\n\nexport type ExecutionDataView = {\n module: Address;\n skipRuntimeValidation: boolean;\n allowGlobalValidation: boolean;\n executionHooks: readonly Hex[];\n};\n\nexport type ValidationDataView = {\n validationHooks: readonly Hex[];\n executionHooks: readonly Hex[];\n selectors: readonly Hex[];\n validationFlags: number;\n};\n\nexport type ValidationDataParams =\n | {\n validationModuleAddress: Address;\n entityId?: never;\n }\n | {\n validationModuleAddress?: never;\n entityId: number;\n };\n\nexport type MAV2Account<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = SmartContractAccountWithSigner<\"MAV2Account\", TSigner, \"0.7.0\"> & {\n signerEntity: SignerEntity;\n getExecutionData: (selector: Hex) => Promise<ExecutionDataView>;\n getValidationData: (\n args: ValidationDataParams\n ) => Promise<ValidationDataView>;\n encodeCallData: (callData: Hex) => Promise<Hex>;\n};\n\nexport type CreateSMAV2AccountParams<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = Pick<\n ToSmartContractAccountParams<\"MAV2Account\", TTransport, Chain, \"0.7.0\">,\n \"transport\" | \"chain\" | \"accountAddress\"\n> & {\n signer: TSigner;\n salt?: bigint;\n factoryAddress?: Address;\n initCode?: Hex;\n initialOwner?: Address;\n entryPoint?: EntryPointDef<\"0.7.0\", Chain>;\n signerEntity?: SignerEntity;\n};\n\nexport async function createSMAV2Account<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>(\n config: CreateSMAV2AccountParams<TTransport, TSigner>\n): Promise<MAV2Account<TSigner>>;\n\n/**\n * Creates an SMAV2 account using defined parameters including chain, signer, salt, factory address, and more.\n * Handles account initialization code, nonce generation, transaction encoding, and more to construct a modular account with optional validation hooks.\n *\n * @param {CreateSMAV2AccountParams} config Configuration parameters for creating an SMAV2 account. Includes chain details, signer, salt, factory address, and more.\n * @returns {Promise<MAV2Account>} A promise that resolves to an `MAV2Account` providing methods for nonce retrieval, transaction execution, and more.\n */\nexport async function createSMAV2Account(\n config: CreateSMAV2AccountParams\n): Promise<MAV2Account> {\n const {\n transport,\n chain,\n signer,\n salt = 0n,\n factoryAddress = getDefaultMAV2FactoryAddress(chain),\n initCode,\n initialOwner,\n accountAddress,\n entryPoint = getEntryPoint(chain, { version: \"0.7.0\" }),\n signerEntity = {\n isGlobalValidation: true,\n entityId: DEFAULT_OWNER_ENTITY_ID,\n },\n signerEntity: {\n isGlobalValidation = true,\n entityId = DEFAULT_OWNER_ENTITY_ID,\n } = {},\n } = config;\n\n if (entityId > Number(maxUint32)) {\n throw new InvalidEntityIdError(entityId);\n }\n\n const client = createBundlerClient({\n transport,\n chain,\n });\n\n const getAccountInitCode = async () => {\n if (initCode) {\n return initCode;\n }\n\n // If an initial owner is not provided, use the signer's address\n const ownerAddress = initialOwner ?? (await signer.getAddress());\n\n return concatHex([\n factoryAddress,\n encodeFunctionData({\n abi: accountFactoryAbi,\n functionName: \"createSemiModularAccount\",\n args: [ownerAddress, salt],\n }),\n ]);\n };\n\n const encodeExecute: (tx: AccountOp) => Promise<Hex> = async ({\n target,\n data,\n value,\n }) =>\n await encodeCallData(\n encodeFunctionData({\n abi: modularAccountAbi,\n functionName: \"execute\",\n args: [target, value ?? 0n, data],\n })\n );\n\n const encodeBatchExecute: (txs: AccountOp[]) => Promise<Hex> = async (txs) =>\n await encodeCallData(\n encodeFunctionData({\n abi: modularAccountAbi,\n functionName: \"executeBatch\",\n args: [\n txs.map((tx) => ({\n target: tx.target,\n data: tx.data,\n value: tx.value ?? 0n,\n })),\n ],\n })\n );\n\n const _accountAddress = await getAccountAddress({\n client,\n entryPoint,\n accountAddress,\n getAccountInitCode,\n });\n\n const baseAccount = await toSmartContractAccount({\n transport,\n chain,\n entryPoint,\n accountAddress: _accountAddress,\n source: `MAV2Account`,\n encodeExecute,\n encodeBatchExecute,\n getAccountInitCode,\n ...(entityId === DEFAULT_OWNER_ENTITY_ID\n ? nativeSMASigner(signer, chain, _accountAddress)\n : singleSignerMessageSigner(signer, chain, _accountAddress, entityId)),\n });\n\n // TODO: add deferred action flag\n const getAccountNonce = async (nonceKey: bigint = 0n): Promise<bigint> => {\n if (nonceKey > maxUint152) {\n throw new InvalidNonceKeyError(nonceKey);\n }\n\n const entryPointContract = getContract({\n address: entryPoint.address,\n abi: entryPoint.abi,\n client,\n });\n\n const fullNonceKey: bigint =\n (nonceKey << 40n) +\n BigInt(entityId << 8) +\n (isGlobalValidation ? 1n : 0n);\n\n return entryPointContract.read.getNonce([\n _accountAddress,\n fullNonceKey,\n ]) as Promise<bigint>;\n };\n\n const accountContract = getContract({\n address: _accountAddress,\n abi: modularAccountAbi,\n client,\n });\n\n const getExecutionData = async (selector: Hex) => {\n if (!(await baseAccount.isAccountDeployed())) {\n return {\n module: zeroAddress,\n skipRuntimeValidation: false,\n allowGlobalValidation: false,\n executionHooks: [],\n };\n }\n\n return await accountContract.read.getExecutionData([selector]);\n };\n\n const getValidationData = async (args: ValidationDataParams) => {\n if (!(await baseAccount.isAccountDeployed())) {\n return {\n validationHooks: [],\n executionHooks: [],\n selectors: [],\n validationFlags: 0,\n };\n }\n\n const { validationModuleAddress, entityId } = args;\n return await accountContract.read.getValidationData([\n serializeModuleEntity({\n moduleAddress: validationModuleAddress ?? zeroAddress,\n entityId: entityId ?? Number(maxUint32),\n }),\n ]);\n };\n\n const encodeCallData = async (callData: Hex): Promise<Hex> => {\n const validationData = await getValidationData({\n entityId: Number(entityId),\n });\n\n return validationData.executionHooks.length\n ? concatHex([executeUserOpSelector, callData])\n : callData;\n };\n\n return {\n ...baseAccount,\n getAccountNonce,\n getSigner: () => signer,\n signerEntity,\n getExecutionData,\n getValidationData,\n encodeCallData,\n };\n}\n"]}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { EntryPointDef, SmartAccountSigner, SmartContractAccountWithSigner, ToSmartContractAccountParams } from "@aa-sdk/core";
|
|
2
|
-
import { type Address, type Chain, type Hex, type Transport } from "viem";
|
|
3
|
-
export type SignerEntity = {
|
|
4
|
-
isGlobalValidation: boolean;
|
|
5
|
-
entityId: number;
|
|
6
|
-
};
|
|
7
|
-
export type ExecutionDataView = {
|
|
8
|
-
module: Address;
|
|
9
|
-
skipRuntimeValidation: boolean;
|
|
10
|
-
allowGlobalValidation: boolean;
|
|
11
|
-
executionHooks: readonly Hex[];
|
|
12
|
-
};
|
|
13
|
-
export type ValidationDataView = {
|
|
14
|
-
validationHooks: readonly Hex[];
|
|
15
|
-
executionHooks: readonly Hex[];
|
|
16
|
-
selectors: readonly Hex[];
|
|
17
|
-
validationFlags: number;
|
|
18
|
-
};
|
|
19
|
-
export type ValidationDataParams = {
|
|
20
|
-
validationModuleAddress: Address;
|
|
21
|
-
entityId?: never;
|
|
22
|
-
} | {
|
|
23
|
-
validationModuleAddress?: never;
|
|
24
|
-
entityId: number;
|
|
25
|
-
};
|
|
26
|
-
export type MAV2Account<TSigner extends SmartAccountSigner = SmartAccountSigner> = SmartContractAccountWithSigner<"MAV2Account", TSigner, "0.7.0"> & {
|
|
27
|
-
signerEntity: SignerEntity;
|
|
28
|
-
getExecutionData: (selector: Hex) => Promise<ExecutionDataView>;
|
|
29
|
-
getValidationData: (args: ValidationDataParams) => Promise<ValidationDataView>;
|
|
30
|
-
encodeCallData: (callData: Hex) => Promise<Hex>;
|
|
31
|
-
};
|
|
32
|
-
export type CreateSMAV2AccountParams<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner> = Pick<ToSmartContractAccountParams<"MAV2Account", TTransport, Chain, "0.7.0">, "transport" | "chain" | "accountAddress"> & {
|
|
33
|
-
signer: TSigner;
|
|
34
|
-
salt?: bigint;
|
|
35
|
-
factoryAddress?: Address;
|
|
36
|
-
initCode?: Hex;
|
|
37
|
-
initialOwner?: Address;
|
|
38
|
-
entryPoint?: EntryPointDef<"0.7.0", Chain>;
|
|
39
|
-
signerEntity?: SignerEntity;
|
|
40
|
-
};
|
|
41
|
-
export declare function createSMAV2Account<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner>(config: CreateSMAV2AccountParams<TTransport, TSigner>): Promise<MAV2Account<TSigner>>;
|
|
42
|
-
//# sourceMappingURL=semiModularAccountV2.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"semiModularAccountV2.d.ts","sourceRoot":"","sources":["../../../../../src/ma-v2/account/semiModularAccountV2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAElB,8BAA8B,EAC9B,4BAA4B,EAC7B,MAAM,cAAc,CAAC;AAStB,OAAO,EAOL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,GAAG,EACR,KAAK,SAAS,EACf,MAAM,MAAM,CAAC;AAad,MAAM,MAAM,YAAY,GAAG;IACzB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,qBAAqB,EAAE,OAAO,CAAC;IAC/B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,cAAc,EAAE,SAAS,GAAG,EAAE,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,eAAe,EAAE,SAAS,GAAG,EAAE,CAAC;IAChC,cAAc,EAAE,SAAS,GAAG,EAAE,CAAC;IAC/B,SAAS,EAAE,SAAS,GAAG,EAAE,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAC5B;IACE,uBAAuB,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,GACD;IACE,uBAAuB,CAAC,EA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