@account-kit/smart-contracts 4.23.0 → 4.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/esm/src/ma-v2/account/common/modularAccountV2Base.d.ts +1 -0
- package/dist/esm/src/ma-v2/account/common/modularAccountV2Base.js +38 -11
- package/dist/esm/src/ma-v2/account/common/modularAccountV2Base.js.map +1 -1
- package/dist/esm/src/ma-v2/account/modularAccountV2.d.ts +1 -0
- package/dist/esm/src/ma-v2/account/modularAccountV2.js +2 -1
- package/dist/esm/src/ma-v2/account/modularAccountV2.js.map +1 -1
- package/dist/esm/src/ma-v2/account/nativeSMASigner.d.ts +2 -2
- package/dist/esm/src/ma-v2/account/nativeSMASigner.js +11 -8
- package/dist/esm/src/ma-v2/account/nativeSMASigner.js.map +1 -1
- package/dist/esm/src/ma-v2/actions/deferralActions.d.ts +9 -7
- package/dist/esm/src/ma-v2/actions/deferralActions.js +21 -35
- package/dist/esm/src/ma-v2/actions/deferralActions.js.map +1 -1
- package/dist/esm/src/ma-v2/index.d.ts +4 -0
- package/dist/esm/src/ma-v2/index.js +2 -0
- package/dist/esm/src/ma-v2/index.js.map +1 -1
- package/dist/esm/src/ma-v2/modules/single-signer-validation/signer.d.ts +2 -1
- package/dist/esm/src/ma-v2/modules/single-signer-validation/signer.js +10 -6
- package/dist/esm/src/ma-v2/modules/single-signer-validation/signer.js.map +1 -1
- package/dist/esm/src/ma-v2/permissionBuilder.d.ts +115 -0
- package/dist/esm/src/ma-v2/permissionBuilder.js +485 -0
- package/dist/esm/src/ma-v2/permissionBuilder.js.map +1 -0
- package/dist/esm/src/ma-v2/utils.d.ts +37 -0
- package/dist/esm/src/ma-v2/utils.js +7 -1
- package/dist/esm/src/ma-v2/utils.js.map +1 -1
- package/dist/types/src/ma-v2/account/common/modularAccountV2Base.d.ts +1 -0
- package/dist/types/src/ma-v2/account/common/modularAccountV2Base.d.ts.map +1 -1
- package/dist/types/src/ma-v2/account/modularAccountV2.d.ts +1 -0
- package/dist/types/src/ma-v2/account/modularAccountV2.d.ts.map +1 -1
- package/dist/types/src/ma-v2/account/nativeSMASigner.d.ts +2 -2
- package/dist/types/src/ma-v2/account/nativeSMASigner.d.ts.map +1 -1
- package/dist/types/src/ma-v2/actions/deferralActions.d.ts +9 -7
- package/dist/types/src/ma-v2/actions/deferralActions.d.ts.map +1 -1
- package/dist/types/src/ma-v2/index.d.ts +4 -0
- package/dist/types/src/ma-v2/index.d.ts.map +1 -1
- package/dist/types/src/ma-v2/modules/single-signer-validation/signer.d.ts +2 -1
- package/dist/types/src/ma-v2/modules/single-signer-validation/signer.d.ts.map +1 -1
- package/dist/types/src/ma-v2/permissionBuilder.d.ts +116 -0
- package/dist/types/src/ma-v2/permissionBuilder.d.ts.map +1 -0
- package/dist/types/src/ma-v2/utils.d.ts +37 -0
- package/dist/types/src/ma-v2/utils.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/ma-v2/account/common/modularAccountV2Base.ts +52 -10
- package/src/ma-v2/account/modularAccountV2.ts +3 -0
- package/src/ma-v2/account/nativeSMASigner.ts +20 -14
- package/src/ma-v2/actions/deferralActions.ts +38 -51
- package/src/ma-v2/index.ts +4 -0
- package/src/ma-v2/modules/single-signer-validation/signer.ts +19 -13
- package/src/ma-v2/permissionBuilder.ts +724 -0
- package/src/ma-v2/utils.ts +10 -0
|
@@ -34,6 +34,7 @@ export type CreateMAV2BaseParams<TSigner extends SmartAccountSigner = SmartAccou
|
|
|
34
34
|
signer: TSigner;
|
|
35
35
|
signerEntity?: SignerEntity;
|
|
36
36
|
accountAddress: Address;
|
|
37
|
+
deferredAction?: Hex;
|
|
37
38
|
};
|
|
38
39
|
export type CreateMAV2BaseReturnType<TSigner extends SmartAccountSigner = SmartAccountSigner> = Promise<ModularAccountV2<TSigner>>;
|
|
39
40
|
export declare function createMAv2Base<TSigner extends SmartAccountSigner = SmartAccountSigner>(config: CreateMAV2BaseParams<TSigner>): CreateMAV2BaseReturnType<TSigner>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createBundlerClient, getEntryPoint, InvalidEntityIdError, InvalidNonceKeyError, toSmartContractAccount, } from "@aa-sdk/core";
|
|
1
|
+
import { createBundlerClient, getEntryPoint, InvalidEntityIdError, InvalidNonceKeyError, InvalidDeferredActionNonce, InvalidDeferredActionMode, toSmartContractAccount, } from "@aa-sdk/core";
|
|
2
2
|
import { DEFAULT_OWNER_ENTITY_ID } from "../../utils.js";
|
|
3
3
|
import { encodeFunctionData, maxUint32, zeroAddress, getContract, concatHex, maxUint152, } from "viem";
|
|
4
4
|
import { modularAccountAbi } from "../../abis/modularAccountAbi.js";
|
|
@@ -10,7 +10,7 @@ export async function createMAv2Base(config) {
|
|
|
10
10
|
const { transport, chain, signer, entryPoint = getEntryPoint(chain, { version: "0.7.0" }), signerEntity = {
|
|
11
11
|
isGlobalValidation: true,
|
|
12
12
|
entityId: DEFAULT_OWNER_ENTITY_ID,
|
|
13
|
-
}, signerEntity: { isGlobalValidation = true, entityId = DEFAULT_OWNER_ENTITY_ID, } = {}, accountAddress, ...remainingToSmartContractAccountParams } = config;
|
|
13
|
+
}, signerEntity: { isGlobalValidation = true, entityId = DEFAULT_OWNER_ENTITY_ID, } = {}, accountAddress, deferredAction, ...remainingToSmartContractAccountParams } = config;
|
|
14
14
|
if (entityId > Number(maxUint32)) {
|
|
15
15
|
throw new InvalidEntityIdError(entityId);
|
|
16
16
|
}
|
|
@@ -18,6 +18,35 @@ export async function createMAv2Base(config) {
|
|
|
18
18
|
transport,
|
|
19
19
|
chain,
|
|
20
20
|
});
|
|
21
|
+
const entryPointContract = getContract({
|
|
22
|
+
address: entryPoint.address,
|
|
23
|
+
abi: entryPoint.abi,
|
|
24
|
+
client,
|
|
25
|
+
});
|
|
26
|
+
let useDeferredAction = false;
|
|
27
|
+
let nonce = 0n;
|
|
28
|
+
let deferredActionData = "0x";
|
|
29
|
+
let hasAssociatedExecHooks = false;
|
|
30
|
+
if (deferredAction) {
|
|
31
|
+
if (deferredAction.slice(2, 4) !== "00") {
|
|
32
|
+
throw new InvalidDeferredActionMode();
|
|
33
|
+
}
|
|
34
|
+
// Set these values if the deferred action has not been consumed. We check this with the EP
|
|
35
|
+
const nextNonceForDeferredAction = (await entryPointContract.read.getNonce([
|
|
36
|
+
accountAddress,
|
|
37
|
+
nonce >> 64n,
|
|
38
|
+
]));
|
|
39
|
+
// we only add the deferred action in if the nonce has not been consumed
|
|
40
|
+
if (nonce === nextNonceForDeferredAction) {
|
|
41
|
+
nonce = BigInt(`0x${deferredAction.slice(6, 70)}`);
|
|
42
|
+
useDeferredAction = true;
|
|
43
|
+
deferredActionData = `0x${deferredAction.slice(70)}`;
|
|
44
|
+
hasAssociatedExecHooks = deferredAction[5] === "1";
|
|
45
|
+
}
|
|
46
|
+
else if (nonce > nextNonceForDeferredAction) {
|
|
47
|
+
throw new InvalidDeferredActionNonce();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
21
50
|
const encodeExecute = async ({ target, data, value, }) => await encodeCallData(encodeFunctionData({
|
|
22
51
|
abi: modularAccountAbi,
|
|
23
52
|
functionName: "execute",
|
|
@@ -35,16 +64,13 @@ export async function createMAv2Base(config) {
|
|
|
35
64
|
],
|
|
36
65
|
}));
|
|
37
66
|
const isAccountDeployed = async () => !!(await client.getCode({ address: accountAddress }));
|
|
38
|
-
// TODO: add deferred action flag
|
|
39
67
|
const getNonce = async (nonceKey = 0n) => {
|
|
68
|
+
if (useDeferredAction) {
|
|
69
|
+
return nonce;
|
|
70
|
+
}
|
|
40
71
|
if (nonceKey > maxUint152) {
|
|
41
72
|
throw new InvalidNonceKeyError(nonceKey);
|
|
42
73
|
}
|
|
43
|
-
const entryPointContract = getContract({
|
|
44
|
-
address: entryPoint.address,
|
|
45
|
-
abi: entryPoint.abi,
|
|
46
|
-
client,
|
|
47
|
-
});
|
|
48
74
|
const fullNonceKey = (nonceKey << 40n) +
|
|
49
75
|
(BigInt(entityId) << 8n) +
|
|
50
76
|
(isGlobalValidation ? 1n : 0n);
|
|
@@ -90,7 +116,8 @@ export async function createMAv2Base(config) {
|
|
|
90
116
|
const validationData = await getValidationData({
|
|
91
117
|
entityId: Number(entityId),
|
|
92
118
|
});
|
|
93
|
-
return
|
|
119
|
+
return (useDeferredAction && hasAssociatedExecHooks) ||
|
|
120
|
+
validationData.executionHooks.length
|
|
94
121
|
? concatHex([executeUserOpSelector, callData])
|
|
95
122
|
: callData;
|
|
96
123
|
};
|
|
@@ -104,8 +131,8 @@ export async function createMAv2Base(config) {
|
|
|
104
131
|
encodeBatchExecute,
|
|
105
132
|
getNonce,
|
|
106
133
|
...(entityId === DEFAULT_OWNER_ENTITY_ID
|
|
107
|
-
? nativeSMASigner(signer, chain, accountAddress)
|
|
108
|
-
: singleSignerMessageSigner(signer, chain, accountAddress, entityId)),
|
|
134
|
+
? nativeSMASigner(signer, chain, accountAddress, deferredActionData)
|
|
135
|
+
: singleSignerMessageSigner(signer, chain, accountAddress, entityId, deferredActionData)),
|
|
109
136
|
});
|
|
110
137
|
return {
|
|
111
138
|
...baseAccount,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modularAccountV2Base.js","sourceRoot":"","sources":["../../../../../../src/ma-v2/account/common/modularAccountV2Base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,GAKvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAKL,kBAAkB,EAClB,SAAS,EACT,WAAW,EACX,WAAW,EACX,SAAS,EACT,UAAU,GACX,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAA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C,CAAC,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,cAAc,CAAC;YAChD,CAAC,CAAC,yBAAyB,CAAC,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC;KACxE,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,WAAW;QACd,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM;QACvB,YAAY;QACZ,gBAAgB;QAChB,iBAAiB;QACjB,cAAc;KACf,CAAC;AACJ,CAAC","sourcesContent":["import {\n createBundlerClient,\n getEntryPoint,\n InvalidEntityIdError,\n InvalidNonceKeyError,\n toSmartContractAccount,\n type AccountOp,\n type SmartAccountSigner,\n type SmartContractAccountWithSigner,\n type ToSmartContractAccountParams,\n} from \"@aa-sdk/core\";\nimport { DEFAULT_OWNER_ENTITY_ID } from \"../../utils.js\";\nimport {\n type Hex,\n type Address,\n type Chain,\n type Transport,\n encodeFunctionData,\n maxUint32,\n zeroAddress,\n getContract,\n concatHex,\n maxUint152,\n} from \"viem\";\nimport { modularAccountAbi } from \"../../abis/modularAccountAbi.js\";\nimport { serializeModuleEntity } from \"../../actions/common/utils.js\";\nimport { nativeSMASigner } from \"../nativeSMASigner.js\";\nimport { singleSignerMessageSigner } from \"../../modules/single-signer-validation/signer.js\";\n\nexport const 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 ModularAccountV2<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = SmartContractAccountWithSigner<\"ModularAccountV2\", 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 CreateMAV2BaseParams<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TTransport extends Transport = Transport\n> = Omit<\n ToSmartContractAccountParams<\"ModularAccountV2\", TTransport, Chain, \"0.7.0\">,\n // Implements the following methods required by `toSmartContractAccount`, and passes through any other parameters.\n | \"encodeExecute\"\n | \"encodeBatchExecute\"\n | \"getNonce\"\n | \"signMessage\"\n | \"signTypedData\"\n | \"getDummySignature\"\n> & {\n signer: TSigner;\n signerEntity?: SignerEntity;\n accountAddress: Address;\n};\n\nexport type CreateMAV2BaseReturnType<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = Promise<ModularAccountV2<TSigner>>;\n\nexport async function createMAv2Base<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>(config: CreateMAV2BaseParams<TSigner>): CreateMAV2BaseReturnType<TSigner> {\n const {\n transport,\n chain,\n signer,\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 accountAddress,\n ...remainingToSmartContractAccountParams\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 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 isAccountDeployed: () => Promise<boolean> = async () =>\n !!(await client.getCode({ address: accountAddress }));\n // TODO: add deferred action flag\n const getNonce = 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) << 8n) +\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 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 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 const baseAccount = await toSmartContractAccount({\n ...remainingToSmartContractAccountParams,\n transport,\n chain,\n entryPoint,\n accountAddress,\n encodeExecute,\n encodeBatchExecute,\n getNonce,\n ...(entityId === DEFAULT_OWNER_ENTITY_ID\n ? nativeSMASigner(signer, chain, accountAddress)\n : singleSignerMessageSigner(signer, chain, accountAddress, entityId)),\n });\n\n return {\n ...baseAccount,\n getSigner: () => signer,\n signerEntity,\n getExecutionData,\n getValidationData,\n encodeCallData,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"modularAccountV2Base.js","sourceRoot":"","sources":["../../../../../../src/ma-v2/account/common/modularAccountV2Base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,EAC1B,yBAAyB,EACzB,sBAAsB,GAKvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAKL,kBAAkB,EAClB,SAAS,EACT,WAAW,EACX,WAAW,EACX,SAAS,EACT,UAAU,GACX,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kDAAkD,CAAC;AAE7F,MAAM,CAAC,MAAM,qBAAqB,GAAQ,YAAY,CAAC;AAiEvD,MAAM,CAAC,KAAK,UAAU,cAAc,CAElC,MAAqC;IACrC,MAAM,EACJ,SAAS,EACT,KAAK,EACL,MAAM,EACN,UAAU,GAAG,aAAa,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EACvD,YAAY,GAAG;QACb,kBAAkB,EAAE,IAAI;QACxB,QAAQ,EAAE,uBAAuB;KAClC,EACD,YAAY,EAAE,EACZ,kBAAkB,GAAG,IAAI,EACzB,QAAQ,GAAG,uBAAuB,GACnC,GAAG,EAAE,EACN,cAAc,EACd,cAAc,EACd,GAAG,qCAAqC,EACzC,GAAG,MAAM,CAAC;IAEX,IAA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AE;QAC3D,MAAM,cAAc,GAAG,MAAM,iBAAiB,CAAC;YAC7C,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;SAC3B,CAAC,CAAC;QAEH,OAAO,CAAC,iBAAiB,IAAI,sBAAsB,CAAC;YAClD,cAAc,CAAC,cAAc,CAAC,MAAM;YACpC,CAAC,CAAC,SAAS,CAAC,CAAC,qBAAqB,EAAE,QAAQ,CAAC,CAAC;YAC9C,CAAC,CAAC,QAAQ,CAAC;IACf,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,MAAM,sBAAsB,CAAC;QAC/C,GAAG,qCAAqC;QACxC,SAAS;QACT,KAAK;QACL,UAAU;QACV,cAAc;QACd,aAAa;QACb,kBAAkB;QAClB,QAAQ;QACR,GAAG,CAAC,QAAQ,KAAK,uBAAuB;YACtC,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,kBAAkB,CAAC;YACpE,CAAC,CAAC,yBAAyB,CACvB,MAAM,EACN,KAAK,EACL,cAAc,EACd,QAAQ,EACR,kBAAkB,CACnB,CAAC;KACP,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,WAAW;QACd,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM;QACvB,YAAY;QACZ,gBAAgB;QAChB,iBAAiB;QACjB,cAAc;KACf,CAAC;AACJ,CAAC","sourcesContent":["import {\n createBundlerClient,\n getEntryPoint,\n InvalidEntityIdError,\n InvalidNonceKeyError,\n InvalidDeferredActionNonce,\n InvalidDeferredActionMode,\n toSmartContractAccount,\n type AccountOp,\n type SmartAccountSigner,\n type SmartContractAccountWithSigner,\n type ToSmartContractAccountParams,\n} from \"@aa-sdk/core\";\nimport { DEFAULT_OWNER_ENTITY_ID } from \"../../utils.js\";\nimport {\n type Hex,\n type Address,\n type Chain,\n type Transport,\n encodeFunctionData,\n maxUint32,\n zeroAddress,\n getContract,\n concatHex,\n maxUint152,\n} from \"viem\";\nimport { modularAccountAbi } from \"../../abis/modularAccountAbi.js\";\nimport { serializeModuleEntity } from \"../../actions/common/utils.js\";\nimport { nativeSMASigner } from \"../nativeSMASigner.js\";\nimport { singleSignerMessageSigner } from \"../../modules/single-signer-validation/signer.js\";\n\nexport const 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 ModularAccountV2<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = SmartContractAccountWithSigner<\"ModularAccountV2\", 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 CreateMAV2BaseParams<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TTransport extends Transport = Transport\n> = Omit<\n ToSmartContractAccountParams<\"ModularAccountV2\", TTransport, Chain, \"0.7.0\">,\n // Implements the following methods required by `toSmartContractAccount`, and passes through any other parameters.\n | \"encodeExecute\"\n | \"encodeBatchExecute\"\n | \"getNonce\"\n | \"signMessage\"\n | \"signTypedData\"\n | \"getDummySignature\"\n> & {\n signer: TSigner;\n signerEntity?: SignerEntity;\n accountAddress: Address;\n deferredAction?: Hex;\n};\n\nexport type CreateMAV2BaseReturnType<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = Promise<ModularAccountV2<TSigner>>;\n\nexport async function createMAv2Base<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>(config: CreateMAV2BaseParams<TSigner>): CreateMAV2BaseReturnType<TSigner> {\n const {\n transport,\n chain,\n signer,\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 accountAddress,\n deferredAction,\n ...remainingToSmartContractAccountParams\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 entryPointContract = getContract({\n address: entryPoint.address,\n abi: entryPoint.abi,\n client,\n });\n\n let useDeferredAction: boolean = false;\n let nonce: bigint = 0n;\n let deferredActionData: Hex = \"0x\";\n let hasAssociatedExecHooks: boolean = false;\n\n if (deferredAction) {\n if (deferredAction.slice(2, 4) !== \"00\") {\n throw new InvalidDeferredActionMode();\n }\n // Set these values if the deferred action has not been consumed. We check this with the EP\n const nextNonceForDeferredAction: bigint =\n (await entryPointContract.read.getNonce([\n accountAddress,\n nonce >> 64n,\n ])) as bigint;\n\n // we only add the deferred action in if the nonce has not been consumed\n if (nonce === nextNonceForDeferredAction) {\n nonce = BigInt(`0x${deferredAction.slice(6, 70)}`);\n useDeferredAction = true;\n deferredActionData = `0x${deferredAction.slice(70)}`;\n hasAssociatedExecHooks = deferredAction[5] === \"1\";\n } else if (nonce > nextNonceForDeferredAction) {\n throw new InvalidDeferredActionNonce();\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 isAccountDeployed: () => Promise<boolean> = async () =>\n !!(await client.getCode({ address: accountAddress }));\n\n const getNonce = async (nonceKey: bigint = 0n): Promise<bigint> => {\n if (useDeferredAction) {\n return nonce;\n }\n\n if (nonceKey > maxUint152) {\n throw new InvalidNonceKeyError(nonceKey);\n }\n\n const fullNonceKey: bigint =\n (nonceKey << 40n) +\n (BigInt(entityId) << 8n) +\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 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 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 (useDeferredAction && hasAssociatedExecHooks) ||\n validationData.executionHooks.length\n ? concatHex([executeUserOpSelector, callData])\n : callData;\n };\n\n const baseAccount = await toSmartContractAccount({\n ...remainingToSmartContractAccountParams,\n transport,\n chain,\n entryPoint,\n accountAddress,\n encodeExecute,\n encodeBatchExecute,\n getNonce,\n ...(entityId === DEFAULT_OWNER_ENTITY_ID\n ? nativeSMASigner(signer, chain, accountAddress, deferredActionData)\n : singleSignerMessageSigner(\n signer,\n chain,\n accountAddress,\n entityId,\n deferredActionData\n )),\n });\n\n return {\n ...baseAccount,\n getSigner: () => signer,\n signerEntity,\n getExecutionData,\n getValidationData,\n encodeCallData,\n };\n}\n"]}
|
|
@@ -4,6 +4,7 @@ import { type SignerEntity, type ModularAccountV2 } from "./common/modularAccoun
|
|
|
4
4
|
export type CreateModularAccountV2Params<TTransport extends Transport = Transport, TSigner extends SmartAccountSigner = SmartAccountSigner> = (Pick<ToSmartContractAccountParams<"ModularAccountV2", TTransport, Chain, "0.7.0">, "transport" | "chain" | "accountAddress"> & {
|
|
5
5
|
signer: TSigner;
|
|
6
6
|
entryPoint?: EntryPointDef<"0.7.0", Chain>;
|
|
7
|
+
deferredAction?: Hex;
|
|
7
8
|
signerEntity?: SignerEntity;
|
|
8
9
|
}) & ({
|
|
9
10
|
mode?: "default";
|
|
@@ -40,7 +40,7 @@ export async function createModularAccountV2(config) {
|
|
|
40
40
|
const { transport, chain, signer, accountAddress: _accountAddress, entryPoint = getEntryPoint(chain, { version: "0.7.0" }), signerEntity = {
|
|
41
41
|
isGlobalValidation: true,
|
|
42
42
|
entityId: DEFAULT_OWNER_ENTITY_ID,
|
|
43
|
-
}, signerEntity: { entityId = DEFAULT_OWNER_ENTITY_ID } = {}, } = config;
|
|
43
|
+
}, signerEntity: { entityId = DEFAULT_OWNER_ENTITY_ID } = {}, deferredAction, } = config;
|
|
44
44
|
const client = createBundlerClient({
|
|
45
45
|
transport,
|
|
46
46
|
chain,
|
|
@@ -103,6 +103,7 @@ export async function createModularAccountV2(config) {
|
|
|
103
103
|
signer,
|
|
104
104
|
entryPoint,
|
|
105
105
|
signerEntity,
|
|
106
|
+
deferredAction,
|
|
106
107
|
...accountFunctions,
|
|
107
108
|
});
|
|
108
109
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modularAccountV2.js","sourceRoot":"","sources":["../../../../../src/ma-v2/account/modularAccountV2.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,SAAS,EACT,kBAAkB,GAKnB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAGL,cAAc,GACf,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"modularAccountV2.js","sourceRoot":"","sources":["../../../../../src/ma-v2/account/modularAccountV2.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,SAAS,EACT,kBAAkB,GAKnB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAGL,cAAc,GACf,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAiCtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,MAAoC;IAEpC,MAAM,EACJ,SAAS,EACT,KAAK,EACL,MAAM,EACN,cAAc,EAAE,eAAe,EAC/B,UAAU,GAAG,aAAa,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EACvD,YAAY,GAAG;QACb,kBAAkB,EAAE,IAAI;QACxB,QAAQ,EAAE,uBAAuB;KAClC,EACD,YAAY,EAAE,EAAE,QAAQ,GAAG,uBAAuB,EAAE,GAAG,EAAE,EACzD,cAAc,GACf,GAAG,MAAM,CAAC;I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,CAAC,CAAC;gBAEF,MAAM,cAAc,GAAG,MAAM,iBAAiB,CAAC;oBAC7C,MAAM;oBACN,UAAU;oBACV,cAAc,EAAE,eAAe;oBAC/B,kBAAkB;iBACnB,CAAC,CAAC;gBAEH,OAAO;oBACL,kBAAkB;oBAClB,cAAc;iBACf,CAAC;YACJ,CAAC;YACD;gBACE,WAAW,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;IAEL,OAAO,cAAc,CAAC;QACpB,MAAM,EAAE,kBAAkB;QAC1B,SAAS;QACT,KAAK;QACL,MAAM;QACN,UAAU;QACV,YAAY;QACZ,cAAc;QACd,GAAG,gBAAgB;KACpB,CAAC,CAAC;AACL,CAAC;AAED,qKAAqK;AACrK,SAAS,WAAW,CAAC,MAAa;IAChC,MAAM,IAAI,2BAA2B,EAAE,CAAC;AAC1C,CAAC","sourcesContent":["import type {\n EntryPointDef,\n SmartAccountSigner,\n ToSmartContractAccountParams,\n} from \"@aa-sdk/core\";\nimport {\n createBundlerClient,\n getEntryPoint,\n getAccountAddress,\n EntityIdOverrideError,\n InvalidModularAccountV2Mode,\n} from \"@aa-sdk/core\";\nimport {\n concatHex,\n encodeFunctionData,\n type Address,\n type Chain,\n type Hex,\n type Transport,\n} from \"viem\";\nimport { accountFactoryAbi } from \"../abis/accountFactoryAbi.js\";\nimport { getDefaultMAV2FactoryAddress } from \"../utils.js\";\nimport {\n type SignerEntity,\n type ModularAccountV2,\n createMAv2Base,\n} from \"./common/modularAccountV2Base.js\";\nimport { DEFAULT_OWNER_ENTITY_ID } from \"../utils.js\";\n\nexport type CreateModularAccountV2Params<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = (Pick<\n ToSmartContractAccountParams<\"ModularAccountV2\", TTransport, Chain, \"0.7.0\">,\n \"transport\" | \"chain\" | \"accountAddress\"\n> & {\n signer: TSigner;\n entryPoint?: EntryPointDef<\"0.7.0\", Chain>;\n deferredAction?: Hex;\n signerEntity?: SignerEntity;\n}) &\n (\n | {\n mode?: \"default\";\n salt?: bigint;\n factoryAddress?: Address;\n initCode?: Hex;\n }\n | {\n mode: \"7702\";\n }\n );\n\nexport async function createModularAccountV2<\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>(\n config: CreateModularAccountV2Params<TTransport, TSigner>\n): Promise<ModularAccountV2<TSigner>>;\n\n/**\n * Creates a ModularAccount V2 account, with the mode depending on the provided \"mode\" field.\n * Possible modes include: \"default\", which is SMA Bytecode, and \"7702\", which is SMA 7702.\n * Handles nonce generation, transaction encoding, and mode variant-specific behavior like initcode construction.\n *\n * @example\n * ```ts twoslash\n * import { createModularAccountV2 } from \"@account-kit/smart-contracts\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { alchemy, sepolia } from \"@account-kit/infra\";\n *\n * const MNEMONIC = \"...\";\n * const RPC_URL = \"...\";\n *\n * const signer = LocalAccountSigner.mnemonicToAccountSigner(MNEMONIC);\n *\n * const chain = sepolia;\n *\n * const transport = alchemy({ rpcUrl: RPC_URL });\n *\n *\n * const modularAccountV2 = await createModularAccountV2({\n * mode: \"default\", // or \"7702\"\n * chain,\n * signer,\n * transport,\n * });\n * ```\n *\n * @param {CreateModularAccountV2Params} config Configuration parameters for creating a Modular Account V2.\n * @returns {Promise<ModularAccountV2>} A promise that resolves to an `ModularAccountV2` providing methods for nonce retrieval, transaction execution, and more.\n */\nexport async function createModularAccountV2(\n config: CreateModularAccountV2Params\n): Promise<ModularAccountV2> {\n const {\n transport,\n chain,\n signer,\n accountAddress: _accountAddress,\n entryPoint = getEntryPoint(chain, { version: \"0.7.0\" }),\n signerEntity = {\n isGlobalValidation: true,\n entityId: DEFAULT_OWNER_ENTITY_ID,\n },\n signerEntity: { entityId = DEFAULT_OWNER_ENTITY_ID } = {},\n deferredAction,\n } = config;\n\n const client = createBundlerClient({\n transport,\n chain,\n });\n\n const accountFunctions = await (async () => {\n switch (config.mode) {\n case \"7702\": {\n const getAccountInitCode = async (): Promise<Hex> => {\n return \"0x\";\n };\n const signerAddress = await signer.getAddress();\n const accountAddress = _accountAddress ?? signerAddress;\n if (\n entityId === DEFAULT_OWNER_ENTITY_ID &&\n signerAddress !== accountAddress\n ) {\n throw new EntityIdOverrideError();\n }\n\n const implementation: Address =\n \"0x69007702764179f14F51cdce752f4f775d74E139\";\n\n const getImplementationAddress = async () => implementation;\n\n return {\n getAccountInitCode,\n accountAddress,\n getImplementationAddress,\n };\n }\n case \"default\":\n case undefined: {\n const {\n salt = 0n,\n factoryAddress = getDefaultMAV2FactoryAddress(chain),\n initCode,\n } = config;\n\n const getAccountInitCode = async () => {\n if (initCode) {\n return initCode;\n }\n\n return concatHex([\n factoryAddress,\n encodeFunctionData({\n abi: accountFactoryAbi,\n functionName: \"createSemiModularAccount\",\n args: [await signer.getAddress(), salt],\n }),\n ]);\n };\n\n const accountAddress = await getAccountAddress({\n client,\n entryPoint,\n accountAddress: _accountAddress,\n getAccountInitCode,\n });\n\n return {\n getAccountInitCode,\n accountAddress,\n };\n }\n default:\n assertNever(config);\n }\n })();\n\n return createMAv2Base({\n source: \"ModularAccountV2\",\n transport,\n chain,\n signer,\n entryPoint,\n signerEntity,\n deferredAction,\n ...accountFunctions,\n });\n}\n\n// If we add more valid modes, the switch case branch's mode will no longer be `never`, which will cause a compile time error here and ensure we handle the new type.\nfunction assertNever(_valid: never): never {\n throw new InvalidModularAccountV2Mode();\n}\n"]}
|
|
@@ -6,7 +6,6 @@ import { type Hex, type SignableMessage, type TypedDataDefinition, type Chain, t
|
|
|
6
6
|
* @example
|
|
7
7
|
* ```ts
|
|
8
8
|
* import { nativeSMASigner } from "@account-kit/smart-contracts";
|
|
9
|
-
|
|
10
9
|
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
11
10
|
*
|
|
12
11
|
* const MNEMONIC = "...":
|
|
@@ -21,9 +20,10 @@ import { type Hex, type SignableMessage, type TypedDataDefinition, type Chain, t
|
|
|
21
20
|
* @param {SmartAccountSigner} signer Signer to use for signing operations
|
|
22
21
|
* @param {Chain} chain Chain object for the signer
|
|
23
22
|
* @param {Address} accountAddress address of the smart account using this signer
|
|
23
|
+
* @param {Hex} deferredActionData optional deferred action data to prepend to the uo signatures
|
|
24
24
|
* @returns {object} an object with methods for signing operations and managing signatures
|
|
25
25
|
*/
|
|
26
|
-
export declare const nativeSMASigner: (signer: SmartAccountSigner, chain: Chain, accountAddress: Address) => {
|
|
26
|
+
export declare const nativeSMASigner: (signer: SmartAccountSigner, chain: Chain, accountAddress: Address, deferredActionData?: Hex) => {
|
|
27
27
|
getDummySignature: () => Hex;
|
|
28
28
|
signUserOperationHash: (uoHash: Hex) => Promise<Hex>;
|
|
29
29
|
signMessage({ message }: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hashMessage, hashTypedData, concat, } from "viem";
|
|
1
|
+
import { hashMessage, hashTypedData, concat, concatHex, } from "viem";
|
|
2
2
|
import { packUOSignature, pack1271Signature, DEFAULT_OWNER_ENTITY_ID, } from "../utils.js";
|
|
3
3
|
import { SignatureType } from "../modules/utils.js";
|
|
4
4
|
/**
|
|
@@ -7,7 +7,6 @@ import { SignatureType } from "../modules/utils.js";
|
|
|
7
7
|
* @example
|
|
8
8
|
* ```ts
|
|
9
9
|
* import { nativeSMASigner } from "@account-kit/smart-contracts";
|
|
10
|
-
|
|
11
10
|
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
12
11
|
*
|
|
13
12
|
* const MNEMONIC = "...":
|
|
@@ -22,22 +21,26 @@ import { SignatureType } from "../modules/utils.js";
|
|
|
22
21
|
* @param {SmartAccountSigner} signer Signer to use for signing operations
|
|
23
22
|
* @param {Chain} chain Chain object for the signer
|
|
24
23
|
* @param {Address} accountAddress address of the smart account using this signer
|
|
24
|
+
* @param {Hex} deferredActionData optional deferred action data to prepend to the uo signatures
|
|
25
25
|
* @returns {object} an object with methods for signing operations and managing signatures
|
|
26
26
|
*/
|
|
27
|
-
export const nativeSMASigner = (signer, chain, accountAddress) => {
|
|
27
|
+
export const nativeSMASigner = (signer, chain, accountAddress, deferredActionData) => {
|
|
28
28
|
return {
|
|
29
29
|
getDummySignature: () => {
|
|
30
|
-
const
|
|
31
|
-
return packUOSignature({
|
|
30
|
+
const sig = packUOSignature({
|
|
32
31
|
// orderedHookData: [],
|
|
33
|
-
validationSignature:
|
|
32
|
+
validationSignature: "0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c",
|
|
34
33
|
});
|
|
34
|
+
return deferredActionData ? concatHex([deferredActionData, sig]) : sig;
|
|
35
35
|
},
|
|
36
|
-
signUserOperationHash: (uoHash) => {
|
|
37
|
-
|
|
36
|
+
signUserOperationHash: async (uoHash) => {
|
|
37
|
+
const sig = await signer
|
|
38
|
+
.signMessage({ raw: uoHash })
|
|
39
|
+
.then((signature) => packUOSignature({
|
|
38
40
|
// orderedHookData: [],
|
|
39
41
|
validationSignature: signature,
|
|
40
42
|
}));
|
|
43
|
+
return deferredActionData ? concatHex([deferredActionData, sig]) : sig;
|
|
41
44
|
},
|
|
42
45
|
// we apply the expected 1271 packing here since the account contract will expect it
|
|
43
46
|
async signMessage({ message }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nativeSMASigner.js","sourceRoot":"","sources":["../../../../../src/ma-v2/account/nativeSMASigner.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,aAAa,EAOb,MAAM,
|
|
1
|
+
{"version":3,"file":"nativeSMASigner.js","sourceRoot":"","sources":["../../../../../src/ma-v2/account/nativeSMASigner.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,aAAa,EAOb,MAAM,EACN,SAAS,GACV,MAAM,MAAM,CAAC;AAEd,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,aAAa,CAA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EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;qBACpD;oBACD,OAAO,EAAE;wBACP,IAAI;qBACL;oBACD,WAAW,EAAE,gBAAgB;iBAC9B,CAAC;gBACF,QAAQ,EAAE,uBAAuB;aAClC,CAAC,CAAC;QACL,CAAC;QAED,mEAAmE;QACnE,qHAAqH;QACrH,aAAa,EAAE,KAAK,EAIlB,mBAAgE,EAClD,EAAE;YAChB,uIAAuI;YACvI,MAAM,gBAAgB,GACpB,mBAAmB,EAAE,WAAW,KAAK,gBAAgB;gBACrD,mBAAmB,EAAE,MAAM,EAAE,iBAAiB,KAAK,cAAc,CAAC;YAEpE,OAAO,gBAAgB;gBACrB,CAAC,CAAC,MAAM,CAAC;oBACL,aAAa,CAAC,GAAG;oBACjB,MAAM,MAAM,CAAC,aAAa,CAAC,mBAAmB,CAAC;iBAChD,CAAC;gBACJ,CAAC,CAAC,iBAAiB,CAAC;oBAChB,mBAAmB,EAAE,MAAM,MAAM,CAAC,aAAa,CAAC;wBAC9C,MAAM,EAAE;4BACN,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;4BACzB,iBAAiB,EAAE,cAAc;yBAClC;wBACD,KAAK,EAAE;4BACL,cAAc,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;yBACpD;wBACD,OAAO,EAAE;4BACP,IAAI,EAAE,MAAM,aAAa,CAAC,mBAAmB,CAAC;yBAC/C;wBACD,WAAW,EAAE,gBAAgB;qBAC9B,CAAC;oBACF,QAAQ,EAAE,uBAAuB;iBAClC,CAAC,CAAC;QACT,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport {\n hashMessage,\n hashTypedData,\n type Hex,\n type SignableMessage,\n type TypedData,\n type TypedDataDefinition,\n type Chain,\n type Address,\n concat,\n concatHex,\n} from \"viem\";\n\nimport {\n packUOSignature,\n pack1271Signature,\n DEFAULT_OWNER_ENTITY_ID,\n} from \"../utils.js\";\nimport { SignatureType } from \"../modules/utils.js\";\n/**\n * Creates an object with methods for generating a dummy signature, signing user operation hashes, signing messages, and signing typed data.\n *\n * @example\n * ```ts\n * import { nativeSMASigner } from \"@account-kit/smart-contracts\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n *\n * const MNEMONIC = \"...\":\n *\n * const account = createModularAccountV2({ config });\n *\n * const signer = LocalAccountSigner.mnemonicToAccountSigner(MNEMONIC);\n *\n * const messageSigner = nativeSMASigner(signer, chain, account.address);\n * ```\n *\n * @param {SmartAccountSigner} signer Signer to use for signing operations\n * @param {Chain} chain Chain object for the signer\n * @param {Address} accountAddress address of the smart account using this signer\n * @param {Hex} deferredActionData optional deferred action data to prepend to the uo signatures\n * @returns {object} an object with methods for signing operations and managing signatures\n */\nexport const nativeSMASigner = (\n signer: SmartAccountSigner,\n chain: Chain,\n accountAddress: Address,\n deferredActionData?: Hex\n) => {\n return {\n getDummySignature: (): Hex => {\n const sig = packUOSignature({\n // orderedHookData: [],\n validationSignature:\n \"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\",\n });\n\n return deferredActionData ? concatHex([deferredActionData, sig]) : sig;\n },\n\n signUserOperationHash: async (uoHash: Hex): Promise<Hex> => {\n const sig = await signer\n .signMessage({ raw: uoHash })\n .then((signature: Hex) =>\n packUOSignature({\n // orderedHookData: [],\n validationSignature: signature,\n })\n );\n\n return deferredActionData ? concatHex([deferredActionData, sig]) : sig;\n },\n\n // we apply the expected 1271 packing here since the account contract will expect it\n async signMessage({ message }: { message: SignableMessage }): Promise<Hex> {\n const hash = hashMessage(message);\n\n return pack1271Signature({\n validationSignature: await signer.signTypedData({\n domain: {\n chainId: Number(chain.id),\n verifyingContract: accountAddress,\n },\n types: {\n ReplaySafeHash: [{ name: \"hash\", type: \"bytes32\" }],\n },\n message: {\n hash,\n },\n primaryType: \"ReplaySafeHash\",\n }),\n entityId: DEFAULT_OWNER_ENTITY_ID,\n });\n },\n\n // TODO: maybe move \"sign deferred actions\" to a separate function?\n // we don't apply the expected 1271 packing since deferred sigs use typed data sigs and don't expect the 1271 packing\n signTypedData: async <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | \"EIP712Domain\" = keyof typedData\n >(\n typedDataDefinition: TypedDataDefinition<typedData, primaryType>\n ): Promise<Hex> => {\n // the accounts domain already gives replay protection across accounts for deferred actions, so we don't need to apply another wrapping\n const isDeferredAction =\n typedDataDefinition?.primaryType === \"DeferredAction\" &&\n typedDataDefinition?.domain?.verifyingContract === accountAddress;\n\n return isDeferredAction\n ? concat([\n SignatureType.EOA,\n await signer.signTypedData(typedDataDefinition),\n ])\n : pack1271Signature({\n validationSignature: await signer.signTypedData({\n domain: {\n chainId: Number(chain.id),\n verifyingContract: accountAddress,\n },\n types: {\n ReplaySafeHash: [{ name: \"hash\", type: \"bytes32\" }],\n },\n message: {\n hash: await hashTypedData(typedDataDefinition),\n },\n primaryType: \"ReplaySafeHash\",\n }),\n entityId: DEFAULT_OWNER_ENTITY_ID,\n });\n },\n };\n};\n"]}
|
|
@@ -31,32 +31,34 @@ export type DeferredActionTypedData = {
|
|
|
31
31
|
};
|
|
32
32
|
export type DeferredActionReturnData = {
|
|
33
33
|
typedData: DeferredActionTypedData;
|
|
34
|
-
nonceOverride: bigint;
|
|
35
34
|
};
|
|
36
35
|
export type CreateDeferredActionTypedDataParams = {
|
|
37
36
|
callData: Hex;
|
|
38
37
|
deadline: number;
|
|
39
|
-
|
|
40
|
-
isGlobalValidation: boolean;
|
|
41
|
-
nonceKeyOverride?: bigint;
|
|
38
|
+
nonce: bigint;
|
|
42
39
|
};
|
|
43
40
|
export type BuildDeferredActionDigestParams = {
|
|
44
|
-
|
|
41
|
+
fullPreSignatureDeferredActionDigest: Hex;
|
|
45
42
|
sig: Hex;
|
|
46
43
|
};
|
|
44
|
+
export type BuildPreSignatureDeferredActionDigestParams = {
|
|
45
|
+
typedData: DeferredActionTypedData;
|
|
46
|
+
};
|
|
47
47
|
export type BuildUserOperationWithDeferredActionParams = {
|
|
48
48
|
uo: UserOperationCallData | BatchUserOperationCallData;
|
|
49
49
|
signaturePrepend: Hex;
|
|
50
50
|
nonceOverride: bigint;
|
|
51
51
|
};
|
|
52
52
|
export type EntityIdAndNonceParams = {
|
|
53
|
-
entityId
|
|
54
|
-
nonceKey
|
|
53
|
+
entityId?: number;
|
|
54
|
+
nonceKey?: bigint;
|
|
55
55
|
isGlobalValidation: boolean;
|
|
56
|
+
isDeferredAction?: boolean;
|
|
56
57
|
};
|
|
57
58
|
export type DeferralActions = {
|
|
58
59
|
createDeferredActionTypedDataObject: (args: CreateDeferredActionTypedDataParams) => Promise<DeferredActionReturnData>;
|
|
59
60
|
buildDeferredActionDigest: (args: BuildDeferredActionDigestParams) => Hex;
|
|
61
|
+
buildPreSignatureDeferredActionDigest: (args: BuildPreSignatureDeferredActionDigestParams) => Hex;
|
|
60
62
|
buildUserOperationWithDeferredAction: (args: BuildUserOperationWithDeferredActionParams) => Promise<UserOperationRequest_v7>;
|
|
61
63
|
getEntityIdAndNonce: (args: EntityIdAndNonceParams) => Promise<{
|
|
62
64
|
nonce: bigint;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AccountNotFoundError, InvalidNonceKeyError, EntryPointNotFoundError, } from "@aa-sdk/core";
|
|
2
|
-
import { concatHex, maxUint152,
|
|
2
|
+
import { concatHex, maxUint152, encodePacked, size, toHex, encodeDeployData, hexToNumber, } from "viem";
|
|
3
3
|
import { entityIdAndNonceReaderBytecode, buildFullNonceKey } from "../utils.js";
|
|
4
4
|
import { entityIdAndNonceReaderAbi } from "../abis/entityIdAndNonceReader.js";
|
|
5
5
|
/**
|
|
@@ -9,34 +9,14 @@ import { entityIdAndNonceReaderAbi } from "../abis/entityIdAndNonceReader.js";
|
|
|
9
9
|
* @returns {object} - An object containing three methods: `createDeferredActionTypedDataObject`, `buildDeferredActionDigest`, and `buildUserOperationWithDeferredAction`.
|
|
10
10
|
*/
|
|
11
11
|
export const deferralActions = (client) => {
|
|
12
|
-
const createDeferredActionTypedDataObject = async ({ callData, deadline,
|
|
12
|
+
const createDeferredActionTypedDataObject = async ({ callData, deadline, nonce, }) => {
|
|
13
13
|
if (!client.account) {
|
|
14
14
|
throw new AccountNotFoundError();
|
|
15
15
|
}
|
|
16
|
-
if (nonceKeyOverride > maxUint152) {
|
|
17
|
-
throw new InvalidNonceKeyError(nonceKeyOverride);
|
|
18
|
-
}
|
|
19
16
|
const entryPoint = client.account.getEntryPoint();
|
|
20
17
|
if (entryPoint === undefined) {
|
|
21
18
|
throw new EntryPointNotFoundError(client.chain, "0.7.0");
|
|
22
19
|
}
|
|
23
|
-
const entryPointContract = getContract({
|
|
24
|
-
address: entryPoint.address,
|
|
25
|
-
abi: entryPoint.abi,
|
|
26
|
-
client: client,
|
|
27
|
-
});
|
|
28
|
-
// 2 = deferred action flags 0b10
|
|
29
|
-
// 1 = isGlobal validation flag 0b01
|
|
30
|
-
const fullNonceKey = buildFullNonceKey({
|
|
31
|
-
nonceKey: nonceKeyOverride,
|
|
32
|
-
entityId,
|
|
33
|
-
isGlobalValidation,
|
|
34
|
-
isDeferredAction: true,
|
|
35
|
-
});
|
|
36
|
-
const nonceOverride = (await entryPointContract.read.getNonce([
|
|
37
|
-
client.account.address,
|
|
38
|
-
fullNonceKey,
|
|
39
|
-
]));
|
|
40
20
|
return {
|
|
41
21
|
typedData: {
|
|
42
22
|
domain: {
|
|
@@ -52,12 +32,11 @@ export const deferralActions = (client) => {
|
|
|
52
32
|
},
|
|
53
33
|
primaryType: "DeferredAction",
|
|
54
34
|
message: {
|
|
55
|
-
nonce:
|
|
35
|
+
nonce: nonce,
|
|
56
36
|
deadline: deadline,
|
|
57
37
|
call: callData,
|
|
58
38
|
},
|
|
59
39
|
},
|
|
60
|
-
nonceOverride: nonceOverride,
|
|
61
40
|
};
|
|
62
41
|
};
|
|
63
42
|
/**
|
|
@@ -66,22 +45,28 @@ export const deferralActions = (client) => {
|
|
|
66
45
|
* Assumption: The client this extends is used to sign the typed data.
|
|
67
46
|
*
|
|
68
47
|
* @param {object} args The argument object containing the following:
|
|
69
|
-
* @param {
|
|
48
|
+
* @param {Hex} args.fullPreSignatureDeferredActionDigest The The data to append the signature and length to
|
|
70
49
|
* @param {Hex} args.sig The signature to include in the digest
|
|
71
50
|
* @returns {Hex} The encoded digest to be prepended to the userOp signature
|
|
72
51
|
*/
|
|
73
|
-
const buildDeferredActionDigest = ({
|
|
52
|
+
const buildDeferredActionDigest = ({ fullPreSignatureDeferredActionDigest, sig, }) => {
|
|
53
|
+
const sigLength = size(sig);
|
|
54
|
+
const encodedData = concatHex([
|
|
55
|
+
fullPreSignatureDeferredActionDigest,
|
|
56
|
+
toHex(sigLength, { size: 4 }),
|
|
57
|
+
sig,
|
|
58
|
+
]);
|
|
59
|
+
return encodedData;
|
|
60
|
+
};
|
|
61
|
+
const buildPreSignatureDeferredActionDigest = ({ typedData, }) => {
|
|
74
62
|
const signerEntity = client.account.signerEntity;
|
|
75
63
|
const validationLocator = (BigInt(signerEntity.entityId) << 8n) |
|
|
76
64
|
(signerEntity.isGlobalValidation ? 1n : 0n);
|
|
77
|
-
|
|
78
|
-
const encodedDataLength = size(
|
|
79
|
-
const
|
|
80
|
-
encodedData = concatHex([
|
|
65
|
+
const encodedCallData = encodePacked(["uint168", "uint48", "bytes"], [validationLocator, typedData.message.deadline, typedData.message.call]);
|
|
66
|
+
const encodedDataLength = size(encodedCallData);
|
|
67
|
+
const encodedData = concatHex([
|
|
81
68
|
toHex(encodedDataLength, { size: 4 }),
|
|
82
|
-
|
|
83
|
-
toHex(sigLength, { size: 4 }),
|
|
84
|
-
sig,
|
|
69
|
+
encodedCallData,
|
|
85
70
|
]);
|
|
86
71
|
return encodedData;
|
|
87
72
|
};
|
|
@@ -117,7 +102,7 @@ export const deferralActions = (client) => {
|
|
|
117
102
|
client.account.getDummySignature = previousDummySigGetter;
|
|
118
103
|
return unsignedUo;
|
|
119
104
|
};
|
|
120
|
-
const getEntityIdAndNonce = async ({ entityId, nonceKey, isGlobalValidation, }) => {
|
|
105
|
+
const getEntityIdAndNonce = async ({ entityId = 1, nonceKey = 0n, isGlobalValidation, isDeferredAction = true, }) => {
|
|
121
106
|
if (!client.account) {
|
|
122
107
|
throw new AccountNotFoundError();
|
|
123
108
|
}
|
|
@@ -138,7 +123,7 @@ export const deferralActions = (client) => {
|
|
|
138
123
|
nonceKey,
|
|
139
124
|
entityId,
|
|
140
125
|
isGlobalValidation,
|
|
141
|
-
isDeferredAction
|
|
126
|
+
isDeferredAction,
|
|
142
127
|
}),
|
|
143
128
|
],
|
|
144
129
|
});
|
|
@@ -154,6 +139,7 @@ export const deferralActions = (client) => {
|
|
|
154
139
|
return {
|
|
155
140
|
createDeferredActionTypedDataObject,
|
|
156
141
|
buildDeferredActionDigest,
|
|
142
|
+
buildPreSignatureDeferredActionDigest,
|
|
157
143
|
buildUserOperationWithDeferredAction,
|
|
158
144
|
getEntityIdAndNonce,
|
|
159
145
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deferralActions.js","sourceRoot":"","sources":["../../../../../src/ma-v2/actions/deferralActions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,GAIxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,SAAS,EACT,UAAU,EACV,WAAW,EACX,YAAY,EACZ,IAAI,EACJ,KAAK,EACL,gBAAgB,EAChB,WAAW,GACZ,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,8BAA8B,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAkE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAE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aAAa,EAAE,CAAC;QAClD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,uBAAuB,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC3D,CAAC;QAED,MAAM,QAAQ,GAAG,gBAAgB,CAAC;YAChC,GAAG,EAAE,yBAAyB;YAC9B,QAAQ,EAAE,8BAA8B;YACxC,IAAI,EAAE;gBACJ,MAAM,CAAC,OAAO,CAAC,OAAO;gBACtB,UAAU,CAAC,OAAO;gBAClB,iBAAiB,CAAC;oBAChB,QAAQ;oBACR,QAAQ;oBACR,kBAAkB;oBAClB,gBAAgB,EAAE,IAAI;iBACvB,CAAC;aACH;SACF,CAAC,CAAC;QAEH,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;QACvD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,CAAC;QAED,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC;YACnB,QAAQ,EAAE,WAAW,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;SACjD,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO;QACL,mCAAmC;QACnC,yBAAyB;QACzB,oCAAoC;QACpC,mBAAmB;KACpB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {\n AccountNotFoundError,\n InvalidNonceKeyError,\n EntryPointNotFoundError,\n type UserOperationCallData,\n type BatchUserOperationCallData,\n type UserOperationRequest_v7,\n} from \"@aa-sdk/core\";\nimport {\n type Address,\n type Hex,\n concatHex,\n maxUint152,\n getContract,\n encodePacked,\n size,\n toHex,\n encodeDeployData,\n hexToNumber,\n} from \"viem\";\nimport { entityIdAndNonceReaderBytecode, buildFullNonceKey } from \"../utils.js\";\nimport { entityIdAndNonceReaderAbi } from \"../abis/entityIdAndNonceReader.js\";\nimport type { ModularAccountV2Client } from \"../client/client.js\";\n\nexport type DeferredActionTypedData = {\n domain: {\n chainId: number;\n verifyingContract: Address;\n };\n types: {\n DeferredAction: [\n { name: \"nonce\"; type: \"uint256\" },\n { name: \"deadline\"; type: \"uint48\" },\n { name: \"call\"; type: \"bytes\" }\n ];\n };\n primaryType: \"DeferredAction\";\n message: {\n nonce: bigint;\n deadline: number;\n call: Hex;\n };\n};\n\nexport type DeferredActionReturnData = {\n typedData: DeferredActionTypedData;\n nonceOverride: bigint;\n};\n\nexport type CreateDeferredActionTypedDataParams = {\n callData: Hex;\n deadline: number;\n entityId: number;\n isGlobalValidation: boolean;\n nonceKeyOverride?: bigint;\n};\n\nexport type BuildDeferredActionDigestParams = {\n typedData: DeferredActionTypedData;\n sig: Hex;\n};\n\nexport type BuildUserOperationWithDeferredActionParams = {\n uo: UserOperationCallData | BatchUserOperationCallData;\n signaturePrepend: Hex;\n nonceOverride: bigint;\n};\n\nexport type EntityIdAndNonceParams = {\n entityId: number;\n nonceKey: bigint;\n isGlobalValidation: boolean;\n};\n\nexport type DeferralActions = {\n createDeferredActionTypedDataObject: (\n args: CreateDeferredActionTypedDataParams\n ) => Promise<DeferredActionReturnData>;\n buildDeferredActionDigest: (args: BuildDeferredActionDigestParams) => Hex;\n buildUserOperationWithDeferredAction: (\n args: BuildUserOperationWithDeferredActionParams\n ) => Promise<UserOperationRequest_v7>;\n getEntityIdAndNonce: (\n args: EntityIdAndNonceParams\n ) => Promise<{ nonce: bigint; entityId: number }>;\n};\n\n/**\n * Provides deferred action functionalities for a MA v2 client, ensuring compatibility with `SmartAccountClient`.\n *\n * @param {ModularAccountV2Client} client - The client instance which provides account and sendUserOperation functionality.\n * @returns {object} - An object containing three methods: `createDeferredActionTypedDataObject`, `buildDeferredActionDigest`, and `buildUserOperationWithDeferredAction`.\n */\nexport const deferralActions: (\n client: ModularAccountV2Client\n) => DeferralActions = (client: ModularAccountV2Client): DeferralActions => {\n const createDeferredActionTypedDataObject = async ({\n callData,\n deadline,\n entityId,\n isGlobalValidation,\n nonceKeyOverride = 0n,\n }: CreateDeferredActionTypedDataParams): Promise<DeferredActionReturnData> => {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n\n if (nonceKeyOverride > maxUint152) {\n throw new InvalidNonceKeyError(nonceKeyOverride);\n }\n\n const entryPoint = client.account.getEntryPoint();\n if (entryPoint === undefined) {\n throw new EntryPointNotFoundError(client.chain, \"0.7.0\");\n }\n\n const entryPointContract = getContract({\n address: entryPoint.address,\n abi: entryPoint.abi,\n client: client,\n });\n\n // 2 = deferred action flags 0b10\n // 1 = isGlobal validation flag 0b01\n const fullNonceKey: bigint = buildFullNonceKey({\n nonceKey: nonceKeyOverride,\n entityId,\n isGlobalValidation,\n isDeferredAction: true,\n });\n\n const nonceOverride = (await entryPointContract.read.getNonce([\n client.account.address,\n fullNonceKey,\n ])) as bigint;\n\n return {\n typedData: {\n domain: {\n chainId: await client.getChainId(),\n verifyingContract: client.account.address,\n },\n types: {\n DeferredAction: [\n { name: \"nonce\", type: \"uint256\" },\n { name: \"deadline\", type: \"uint48\" },\n { name: \"call\", type: \"bytes\" },\n ],\n },\n primaryType: \"DeferredAction\",\n message: {\n nonce: nonceOverride,\n deadline: deadline,\n call: callData,\n },\n },\n nonceOverride: nonceOverride,\n };\n };\n\n /**\n * Creates the digest which must be prepended to the userOp signature.\n *\n * Assumption: The client this extends is used to sign the typed data.\n *\n * @param {object} args The argument object containing the following:\n * @param {DeferredActionTypedData} args.typedData The typed data object for the deferred action\n * @param {Hex} args.sig The signature to include in the digest\n * @returns {Hex} The encoded digest to be prepended to the userOp signature\n */\n const buildDeferredActionDigest = ({\n typedData,\n sig,\n }: BuildDeferredActionDigestParams): Hex => {\n const signerEntity = client.account.signerEntity;\n const validationLocator =\n (BigInt(signerEntity.entityId) << 8n) |\n (signerEntity.isGlobalValidation ? 1n : 0n);\n\n let encodedData = encodePacked(\n [\"uint168\", \"uint48\", \"bytes\"],\n [validationLocator, typedData.message.deadline, typedData.message.call]\n );\n\n const encodedDataLength = size(encodedData);\n const sigLength = size(sig);\n\n encodedData = concatHex([\n toHex(encodedDataLength, { size: 4 }),\n encodedData,\n toHex(sigLength, { size: 4 }),\n sig,\n ]);\n\n return encodedData;\n };\n\n /**\n * Builds a user operation with a deferred action by wrapping buildUserOperation() with a dummy signature override.\n *\n * @param {object} args The argument object containing the following:\n * @param {UserOperationCallData | BatchUserOperationCallData} args.uo The user operation call data to build\n * @param {Hex} args.signaturePrepend The signature data to prepend to the dummy signature\n * @param {bigint} args.nonceOverride The nonce to override in the user operation, generally given from the typed data builder\n * @returns {Promise<UserOperationRequest_v7>} The unsigned user operation request with the deferred action\n */\n const buildUserOperationWithDeferredAction = async ({\n uo,\n signaturePrepend,\n nonceOverride,\n }: BuildUserOperationWithDeferredActionParams): Promise<UserOperationRequest_v7> => {\n // Check if client.account is defined\n if (client.account === undefined) {\n throw new AccountNotFoundError();\n }\n\n // Pre-fetch the dummy sig so we can override `client.account.getDummySignature()`\n const dummySig = await client.account.getDummySignature();\n\n // Cache the previous dummy signature getter\n const previousDummySigGetter = client.account.getDummySignature;\n\n // Override client.account.getDummySignature() so `client.buildUserOperation()` uses the prepended hex and the dummy signature during gas estimation\n client.account.getDummySignature = () => {\n return concatHex([signaturePrepend, dummySig as Hex]);\n };\n\n const unsignedUo = (await client.buildUserOperation({\n uo: uo,\n overrides: {\n nonce: nonceOverride,\n },\n })) as UserOperationRequest_v7;\n\n // Restore the dummy signature getter\n client.account.getDummySignature = previousDummySigGetter;\n\n return unsignedUo;\n };\n\n const getEntityIdAndNonce = async ({\n entityId,\n nonceKey,\n isGlobalValidation,\n }: EntityIdAndNonceParams) => {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n\n if (nonceKey > maxUint152) {\n throw new InvalidNonceKeyError(nonceKey);\n }\n\n const entryPoint = client.account.getEntryPoint();\n if (entryPoint === undefined) {\n throw new EntryPointNotFoundError(client.chain, \"0.7.0\");\n }\n\n const bytecode = encodeDeployData({\n abi: entityIdAndNonceReaderAbi,\n bytecode: entityIdAndNonceReaderBytecode,\n args: [\n client.account.address,\n entryPoint.address,\n buildFullNonceKey({\n nonceKey,\n entityId,\n isGlobalValidation,\n isDeferredAction: true,\n }),\n ],\n });\n\n const { data } = await client.call({ data: bytecode });\n if (!data) {\n throw new Error(\"No data returned from contract call\");\n }\n\n return {\n nonce: BigInt(data),\n entityId: hexToNumber(`0x${data.slice(40, 48)}`),\n };\n };\n\n return {\n createDeferredActionTypedDataObject,\n buildDeferredActionDigest,\n buildUserOperationWithDeferredAction,\n getEntityIdAndNonce,\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"deferralActions.js","sourceRoot":"","sources":["../../../../../src/ma-v2/actions/deferralActions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,GAIxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,SAAS,EACT,UAAU,EACV,YAAY,EACZ,IAAI,EACJ,KAAK,EACL,gBAAgB,EAChB,WAAW,GACZ,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,8BAA8B,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAuE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAEL,CAAC,MAA8B,EAAmB,EAAE;IACzE,MAAM,mCAAmC,GAAG,KAAK,EAAE,EACjD,QAAQ,EACR,QAAQ,EACR,KAAK,GAC+B,EAAqC,EAAE;QAC3E,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,IAAI,oBAAoB,EAAE,CAAC;QACnC,CAAC;QAED,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QAClD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,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,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;SACjD,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO;QACL,mCAAmC;QACnC,yBAAyB;QACzB,qCAAqC;QACrC,oCAAoC;QACpC,mBAAmB;KACpB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {\n AccountNotFoundError,\n InvalidNonceKeyError,\n EntryPointNotFoundError,\n type UserOperationCallData,\n type BatchUserOperationCallData,\n type UserOperationRequest_v7,\n} from \"@aa-sdk/core\";\nimport {\n type Address,\n type Hex,\n concatHex,\n maxUint152,\n encodePacked,\n size,\n toHex,\n encodeDeployData,\n hexToNumber,\n} from \"viem\";\nimport { entityIdAndNonceReaderBytecode, buildFullNonceKey } from \"../utils.js\";\nimport { entityIdAndNonceReaderAbi } from \"../abis/entityIdAndNonceReader.js\";\nimport type { ModularAccountV2Client } from \"../client/client.js\";\n\nexport type DeferredActionTypedData = {\n domain: {\n chainId: number;\n verifyingContract: Address;\n };\n types: {\n DeferredAction: [\n { name: \"nonce\"; type: \"uint256\" },\n { name: \"deadline\"; type: \"uint48\" },\n { name: \"call\"; type: \"bytes\" }\n ];\n };\n primaryType: \"DeferredAction\";\n message: {\n nonce: bigint;\n deadline: number;\n call: Hex;\n };\n};\n\nexport type DeferredActionReturnData = {\n typedData: DeferredActionTypedData;\n};\n\nexport type CreateDeferredActionTypedDataParams = {\n callData: Hex;\n deadline: number;\n nonce: bigint;\n};\n\nexport type BuildDeferredActionDigestParams = {\n fullPreSignatureDeferredActionDigest: Hex;\n sig: Hex;\n};\n\nexport type BuildPreSignatureDeferredActionDigestParams = {\n typedData: DeferredActionTypedData;\n};\n\nexport type BuildUserOperationWithDeferredActionParams = {\n uo: UserOperationCallData | BatchUserOperationCallData;\n signaturePrepend: Hex;\n nonceOverride: bigint;\n};\n\nexport type EntityIdAndNonceParams = {\n entityId?: number;\n nonceKey?: bigint;\n isGlobalValidation: boolean;\n isDeferredAction?: boolean;\n};\n\nexport type DeferralActions = {\n createDeferredActionTypedDataObject: (\n args: CreateDeferredActionTypedDataParams\n ) => Promise<DeferredActionReturnData>;\n buildDeferredActionDigest: (args: BuildDeferredActionDigestParams) => Hex;\n buildPreSignatureDeferredActionDigest: (\n args: BuildPreSignatureDeferredActionDigestParams\n ) => Hex;\n buildUserOperationWithDeferredAction: (\n args: BuildUserOperationWithDeferredActionParams\n ) => Promise<UserOperationRequest_v7>;\n getEntityIdAndNonce: (\n args: EntityIdAndNonceParams\n ) => Promise<{ nonce: bigint; entityId: number }>;\n};\n\n/**\n * Provides deferred action functionalities for a MA v2 client, ensuring compatibility with `SmartAccountClient`.\n *\n * @param {ModularAccountV2Client} client - The client instance which provides account and sendUserOperation functionality.\n * @returns {object} - An object containing three methods: `createDeferredActionTypedDataObject`, `buildDeferredActionDigest`, and `buildUserOperationWithDeferredAction`.\n */\nexport const deferralActions: (\n client: ModularAccountV2Client\n) => DeferralActions = (client: ModularAccountV2Client): DeferralActions => {\n const createDeferredActionTypedDataObject = async ({\n callData,\n deadline,\n nonce,\n }: CreateDeferredActionTypedDataParams): Promise<DeferredActionReturnData> => {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n\n const entryPoint = client.account.getEntryPoint();\n if (entryPoint === undefined) {\n throw new EntryPointNotFoundError(client.chain, \"0.7.0\");\n }\n\n return {\n typedData: {\n domain: {\n chainId: await client.getChainId(),\n verifyingContract: client.account.address,\n },\n types: {\n DeferredAction: [\n { name: \"nonce\", type: \"uint256\" },\n { name: \"deadline\", type: \"uint48\" },\n { name: \"call\", type: \"bytes\" },\n ],\n },\n primaryType: \"DeferredAction\",\n message: {\n nonce: nonce,\n deadline: deadline,\n call: callData,\n },\n },\n };\n };\n\n /**\n * Creates the digest which must be prepended to the userOp signature.\n *\n * Assumption: The client this extends is used to sign the typed data.\n *\n * @param {object} args The argument object containing the following:\n * @param {Hex} args.fullPreSignatureDeferredActionDigest The The data to append the signature and length to\n * @param {Hex} args.sig The signature to include in the digest\n * @returns {Hex} The encoded digest to be prepended to the userOp signature\n */\n const buildDeferredActionDigest = ({\n fullPreSignatureDeferredActionDigest,\n sig,\n }: BuildDeferredActionDigestParams): Hex => {\n const sigLength = size(sig);\n\n const encodedData = concatHex([\n fullPreSignatureDeferredActionDigest,\n toHex(sigLength, { size: 4 }),\n sig,\n ]);\n return encodedData;\n };\n\n const buildPreSignatureDeferredActionDigest = ({\n typedData,\n }: BuildPreSignatureDeferredActionDigestParams): Hex => {\n const signerEntity = client.account.signerEntity;\n const validationLocator =\n (BigInt(signerEntity.entityId) << 8n) |\n (signerEntity.isGlobalValidation ? 1n : 0n);\n\n const encodedCallData = encodePacked(\n [\"uint168\", \"uint48\", \"bytes\"],\n [validationLocator, typedData.message.deadline, typedData.message.call]\n );\n\n const encodedDataLength = size(encodedCallData);\n const encodedData = concatHex([\n toHex(encodedDataLength, { size: 4 }),\n encodedCallData,\n ]);\n return encodedData;\n };\n\n /**\n * Builds a user operation with a deferred action by wrapping buildUserOperation() with a dummy signature override.\n *\n * @param {object} args The argument object containing the following:\n * @param {UserOperationCallData | BatchUserOperationCallData} args.uo The user operation call data to build\n * @param {Hex} args.signaturePrepend The signature data to prepend to the dummy signature\n * @param {bigint} args.nonceOverride The nonce to override in the user operation, generally given from the typed data builder\n * @returns {Promise<UserOperationRequest_v7>} The unsigned user operation request with the deferred action\n */\n const buildUserOperationWithDeferredAction = async ({\n uo,\n signaturePrepend,\n nonceOverride,\n }: BuildUserOperationWithDeferredActionParams): Promise<UserOperationRequest_v7> => {\n // Check if client.account is defined\n if (client.account === undefined) {\n throw new AccountNotFoundError();\n }\n\n // Pre-fetch the dummy sig so we can override `client.account.getDummySignature()`\n const dummySig = await client.account.getDummySignature();\n\n // Cache the previous dummy signature getter\n const previousDummySigGetter = client.account.getDummySignature;\n\n // Override client.account.getDummySignature() so `client.buildUserOperation()` uses the prepended hex and the dummy signature during gas estimation\n client.account.getDummySignature = () => {\n return concatHex([signaturePrepend, dummySig as Hex]);\n };\n\n const unsignedUo = (await client.buildUserOperation({\n uo: uo,\n overrides: {\n nonce: nonceOverride,\n },\n })) as UserOperationRequest_v7;\n\n // Restore the dummy signature getter\n client.account.getDummySignature = previousDummySigGetter;\n\n return unsignedUo;\n };\n\n const getEntityIdAndNonce = async ({\n entityId = 1,\n nonceKey = 0n,\n isGlobalValidation,\n isDeferredAction = true,\n }: EntityIdAndNonceParams) => {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n\n if (nonceKey > maxUint152) {\n throw new InvalidNonceKeyError(nonceKey);\n }\n\n const entryPoint = client.account.getEntryPoint();\n if (entryPoint === undefined) {\n throw new EntryPointNotFoundError(client.chain, \"0.7.0\");\n }\n\n const bytecode = encodeDeployData({\n abi: entityIdAndNonceReaderAbi,\n bytecode: entityIdAndNonceReaderBytecode,\n args: [\n client.account.address,\n entryPoint.address,\n buildFullNonceKey({\n nonceKey,\n entityId,\n isGlobalValidation,\n isDeferredAction,\n }),\n ],\n });\n\n const { data } = await client.call({ data: bytecode });\n if (!data) {\n throw new Error(\"No data returned from contract call\");\n }\n\n return {\n nonce: BigInt(data),\n entityId: hexToNumber(`0x${data.slice(40, 48)}`),\n };\n };\n\n return {\n createDeferredActionTypedDataObject,\n buildDeferredActionDigest,\n buildPreSignatureDeferredActionDigest,\n buildUserOperationWithDeferredAction,\n getEntityIdAndNonce,\n };\n};\n"]}
|
|
@@ -8,6 +8,10 @@ export { HookType } from "./actions/common/types.js";
|
|
|
8
8
|
export { serializeValidationConfig, serializeHookConfig, serializeModuleEntity, } from "./actions/common/utils.js";
|
|
9
9
|
export type * from "./actions/install-validation/installValidation.js";
|
|
10
10
|
export { installValidationActions } from "./actions/install-validation/installValidation.js";
|
|
11
|
+
export type * from "./actions/deferralActions.js";
|
|
12
|
+
export { deferralActions } from "./actions/deferralActions.js";
|
|
13
|
+
export type * from "./permissionBuilder.js";
|
|
14
|
+
export { PermissionBuilder, PermissionType } from "./permissionBuilder.js";
|
|
11
15
|
export { getDefaultAllowlistModuleAddress, getDefaultNativeTokenLimitModuleAddress, getDefaultPaymasterGuardModuleAddress, getDefaultSingleSignerValidationModuleAddress, getDefaultTimeRangeModuleAddress, getDefaultWebauthnValidationModuleAddress, } from "./modules/utils.js";
|
|
12
16
|
export { buildFullNonceKey } from "./utils.js";
|
|
13
17
|
export { allowlistModuleAbi } from "./modules/allowlist-module/abis/allowlistModuleAbi.js";
|
|
@@ -7,6 +7,8 @@ export { nativeSMASigner } from "./account/nativeSMASigner.js";
|
|
|
7
7
|
export { HookType } from "./actions/common/types.js";
|
|
8
8
|
export { serializeValidationConfig, serializeHookConfig, serializeModuleEntity, } from "./actions/common/utils.js";
|
|
9
9
|
export { installValidationActions } from "./actions/install-validation/installValidation.js";
|
|
10
|
+
export { deferralActions } from "./actions/deferralActions.js";
|
|
11
|
+
export { PermissionBuilder, PermissionType } from "./permissionBuilder.js";
|
|
10
12
|
export { getDefaultAllowlistModuleAddress, getDefaultNativeTokenLimitModuleAddress, getDefaultPaymasterGuardModuleAddress, getDefaultSingleSignerValidationModuleAddress, getDefaultTimeRangeModuleAddress, getDefaultWebauthnValidationModuleAddress, } from "./modules/utils.js";
|
|
11
13
|
export { buildFullNonceKey } from "./utils.js";
|
|
12
14
|
export { allowlistModuleAbi } from "./modules/allowlist-module/abis/allowlistModuleAbi.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ma-v2/index.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AACxF,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AAEtF,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAQ/D,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,mDAAmD,CAAC;AAE7F,OAAO,EACL,gCAAgC,EAChC,uCAAuC,EACvC,qCAAqC,EACrC,6CAA6C,EAC7C,gCAAgC,EAChC,yCAAyC,GAC1C,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uDAAuD,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uEAAuE,CAAC;AAClH,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,kEAAkE,CAAC;AAC3G,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,+BAA+B,EAAE,MAAM,4EAA4E,CAAC;AAC7H,OAAO,EAAE,4BAA4B,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,EAAE,kBAAkB,EAAE,MAAM,wDAAwD,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,6DAA6D,CAAC","sourcesContent":["// ma v2 exports\nexport { accountFactoryAbi } from \"./abis/accountFactoryAbi.js\";\nexport { modularAccountAbi } from \"./abis/modularAccountAbi.js\";\nexport { semiModularAccountBytecodeAbi } from \"./abis/semiModularAccountBytecodeAbi.js\";\nexport { semiModularAccountStorageAbi } from \"./abis/semiModularAccountStorageAbi.js\";\n\nexport { nativeSMASigner } from \"./account/nativeSMASigner.js\";\n\nexport type {\n ModuleEntity,\n ValidationConfig,\n HookConfig,\n ValidationData,\n} from \"./actions/common/types.js\";\nexport { HookType } from \"./actions/common/types.js\";\nexport {\n serializeValidationConfig,\n serializeHookConfig,\n serializeModuleEntity,\n} from \"./actions/common/utils.js\";\nexport type * from \"./actions/install-validation/installValidation.js\";\nexport { installValidationActions } from \"./actions/install-validation/installValidation.js\";\n\nexport {\n getDefaultAllowlistModuleAddress,\n getDefaultNativeTokenLimitModuleAddress,\n getDefaultPaymasterGuardModuleAddress,\n getDefaultSingleSignerValidationModuleAddress,\n getDefaultTimeRangeModuleAddress,\n getDefaultWebauthnValidationModuleAddress,\n} from \"./modules/utils.js\";\nexport { buildFullNonceKey } from \"./utils.js\";\nexport { allowlistModuleAbi } from \"./modules/allowlist-module/abis/allowlistModuleAbi.js\";\nexport { AllowlistModule } from \"./modules/allowlist-module/module.js\";\nexport { nativeTokenLimitModuleAbi } from \"./modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.js\";\nexport { NativeTokenLimitModule } from \"./modules/native-token-limit-module/module.js\";\nexport { paymasterGuardModuleAbi } from \"./modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.js\";\nexport { PaymasterGuardModule } from \"./modules/paymaster-guard-module/module.js\";\nexport { singleSignerValidationModuleAbi } from \"./modules/single-signer-validation/abis/singleSignerValidationModuleAbi.js\";\nexport { SingleSignerValidationModule } from \"./modules/single-signer-validation/module.js\";\nexport { timeRangeModuleAbi } from \"./modules/time-range-module/abis/timeRangeModuleAbi.js\";\nexport { TimeRangeModule } from \"./modules/time-range-module/module.js\";\nexport { webauthnValidationModuleAbi } from \"./modules/webauthn-validation/abis/webauthnValidationAbi.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ma-v2/index.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;A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js\";\nexport { modularAccountAbi } from \"./abis/modularAccountAbi.js\";\nexport { semiModularAccountBytecodeAbi } from \"./abis/semiModularAccountBytecodeAbi.js\";\nexport { semiModularAccountStorageAbi } from \"./abis/semiModularAccountStorageAbi.js\";\n\nexport { nativeSMASigner } from \"./account/nativeSMASigner.js\";\n\nexport type {\n ModuleEntity,\n ValidationConfig,\n HookConfig,\n ValidationData,\n} from \"./actions/common/types.js\";\nexport { HookType } from \"./actions/common/types.js\";\nexport {\n serializeValidationConfig,\n serializeHookConfig,\n serializeModuleEntity,\n} from \"./actions/common/utils.js\";\nexport type * from \"./actions/install-validation/installValidation.js\";\nexport { installValidationActions } from \"./actions/install-validation/installValidation.js\";\nexport type * from \"./actions/deferralActions.js\";\nexport { deferralActions } from \"./actions/deferralActions.js\";\nexport type * from \"./permissionBuilder.js\";\nexport { PermissionBuilder, PermissionType } from \"./permissionBuilder.js\";\n\nexport {\n getDefaultAllowlistModuleAddress,\n getDefaultNativeTokenLimitModuleAddress,\n getDefaultPaymasterGuardModuleAddress,\n getDefaultSingleSignerValidationModuleAddress,\n getDefaultTimeRangeModuleAddress,\n getDefaultWebauthnValidationModuleAddress,\n} from \"./modules/utils.js\";\nexport { buildFullNonceKey } from \"./utils.js\";\nexport { allowlistModuleAbi } from \"./modules/allowlist-module/abis/allowlistModuleAbi.js\";\nexport { AllowlistModule } from \"./modules/allowlist-module/module.js\";\nexport { nativeTokenLimitModuleAbi } from \"./modules/native-token-limit-module/abis/nativeTokenLimitModuleAbi.js\";\nexport { NativeTokenLimitModule } from \"./modules/native-token-limit-module/module.js\";\nexport { paymasterGuardModuleAbi } from \"./modules/paymaster-guard-module/abis/paymasterGuardModuleAbi.js\";\nexport { PaymasterGuardModule } from \"./modules/paymaster-guard-module/module.js\";\nexport { singleSignerValidationModuleAbi } from \"./modules/single-signer-validation/abis/singleSignerValidationModuleAbi.js\";\nexport { SingleSignerValidationModule } from \"./modules/single-signer-validation/module.js\";\nexport { timeRangeModuleAbi } from \"./modules/time-range-module/abis/timeRangeModuleAbi.js\";\nexport { TimeRangeModule } from \"./modules/time-range-module/module.js\";\nexport { webauthnValidationModuleAbi } from \"./modules/webauthn-validation/abis/webauthnValidationAbi.js\";\n"]}
|
|
@@ -22,9 +22,10 @@ import { type Hex, type SignableMessage, type TypedDataDefinition, type Chain, t
|
|
|
22
22
|
* @param {Chain} chain Chain object for the signer
|
|
23
23
|
* @param {Address} accountAddress address of the smart account using this signer
|
|
24
24
|
* @param {number} entityId the entity id of the signing validation
|
|
25
|
+
* @param {Hex} deferredActionData optional deferred action data to prepend to the uo signatures
|
|
25
26
|
* @returns {object} an object with methods for signing operations and managing signatures
|
|
26
27
|
*/
|
|
27
|
-
export declare const singleSignerMessageSigner: (signer: SmartAccountSigner, chain: Chain, accountAddress: Address, entityId: number) => {
|
|
28
|
+
export declare const singleSignerMessageSigner: (signer: SmartAccountSigner, chain: Chain, accountAddress: Address, entityId: number, deferredActionData?: Hex) => {
|
|
28
29
|
getDummySignature: () => Hex;
|
|
29
30
|
signUserOperationHash: (uoHash: Hex) => Promise<Hex>;
|
|
30
31
|
signMessage({ message }: {
|