@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
|
@@ -3,17 +3,17 @@ import { encodeFunctionData, concatHex, zeroAddress, } from "viem";
|
|
|
3
3
|
import { semiModularAccountBytecodeAbi } from "../../abis/semiModularAccountBytecodeAbi.js";
|
|
4
4
|
import { serializeValidationConfig, serializeHookConfig, serializeModuleEntity, } from "../common/utils.js";
|
|
5
5
|
import {} from "../../client/client.js";
|
|
6
|
-
import {} from "../../account/
|
|
6
|
+
import {} from "../../account/common/modularAccountV2Base.js";
|
|
7
7
|
import { DEFAULT_OWNER_ENTITY_ID } from "../../utils.js";
|
|
8
8
|
/**
|
|
9
9
|
* Provides validation installation and uninstallation functionalities for a MA v2 client, ensuring compatibility with `SmartAccountClient`.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```ts
|
|
13
|
-
* import {
|
|
13
|
+
* import { createModularAccountV2Client, installValidationActions, getDefaultSingleSignerValidationModuleAddress, SingleSignerValidationModule } from "@account-kit/smart-contracts";
|
|
14
14
|
* import { Address } from "viem";
|
|
15
15
|
*
|
|
16
|
-
* const client = (await
|
|
16
|
+
* const client = (await createModularAccountV2Client({ ... })).extend(installValidationActions);
|
|
17
17
|
* const sessionKeyAddress: Address = "0x1234";
|
|
18
18
|
* const sessionKeyEntityId: number = 1;
|
|
19
19
|
*
|
|
@@ -49,8 +49,8 @@ import { DEFAULT_OWNER_ENTITY_ID } from "../../utils.js";
|
|
|
49
49
|
* @param {object} client - The client instance which provides account and sendUserOperation functionality.
|
|
50
50
|
* @returns {object} - An object containing two methods, `installValidation` and `uninstallValidation`.
|
|
51
51
|
*/
|
|
52
|
-
export const installValidationActions = (client) =>
|
|
53
|
-
|
|
52
|
+
export const installValidationActions = (client) => {
|
|
53
|
+
const encodeInstallValidation = async ({ validationConfig, selectors, installData, hooks, account = client.account, }) => {
|
|
54
54
|
if (!account) {
|
|
55
55
|
throw new AccountNotFoundError();
|
|
56
56
|
}
|
|
@@ -62,8 +62,7 @@ export const installValidationActions = (client) => ({
|
|
|
62
62
|
validationConfig.moduleAddress !== zeroAddress) {
|
|
63
63
|
throw new EntityIdOverrideError();
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
const callData = await encodeCallData(encodeFunctionData({
|
|
65
|
+
return account.encodeCallData(encodeFunctionData({
|
|
67
66
|
abi: semiModularAccountBytecodeAbi,
|
|
68
67
|
functionName: "installValidation",
|
|
69
68
|
args: [
|
|
@@ -73,21 +72,15 @@ export const installValidationActions = (client) => ({
|
|
|
73
72
|
hooks.map((hook) => concatHex([serializeHookConfig(hook.hookConfig), hook.initData])),
|
|
74
73
|
],
|
|
75
74
|
}));
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
account,
|
|
79
|
-
overrides,
|
|
80
|
-
});
|
|
81
|
-
},
|
|
82
|
-
uninstallValidation: async ({ moduleAddress, entityId, uninstallData, hookUninstallDatas, account = client.account, overrides, }) => {
|
|
75
|
+
};
|
|
76
|
+
const encodeUninstallValidation = async ({ moduleAddress, entityId, uninstallData, hookUninstallDatas, account = client.account, }) => {
|
|
83
77
|
if (!account) {
|
|
84
78
|
throw new AccountNotFoundError();
|
|
85
79
|
}
|
|
86
80
|
if (!isSmartAccountClient(client)) {
|
|
87
81
|
throw new IncompatibleClientError("SmartAccountClient", "uninstallValidation", client);
|
|
88
82
|
}
|
|
89
|
-
|
|
90
|
-
const callData = await encodeCallData(encodeFunctionData({
|
|
83
|
+
return account.encodeCallData(encodeFunctionData({
|
|
91
84
|
abi: semiModularAccountBytecodeAbi,
|
|
92
85
|
functionName: "uninstallValidation",
|
|
93
86
|
args: [
|
|
@@ -99,11 +92,38 @@ export const installValidationActions = (client) => ({
|
|
|
99
92
|
hookUninstallDatas,
|
|
100
93
|
],
|
|
101
94
|
}));
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
|
|
95
|
+
};
|
|
96
|
+
return {
|
|
97
|
+
encodeInstallValidation,
|
|
98
|
+
encodeUninstallValidation,
|
|
99
|
+
installValidation: async ({ validationConfig, selectors, installData, hooks, account = client.account, overrides, }) => {
|
|
100
|
+
const callData = await encodeInstallValidation({
|
|
101
|
+
validationConfig,
|
|
102
|
+
selectors,
|
|
103
|
+
installData,
|
|
104
|
+
hooks,
|
|
105
|
+
account,
|
|
106
|
+
});
|
|
107
|
+
return client.sendUserOperation({
|
|
108
|
+
uo: callData,
|
|
109
|
+
account,
|
|
110
|
+
overrides,
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
uninstallValidation: async ({ moduleAddress, entityId, uninstallData, hookUninstallDatas, account = client.account, overrides, }) => {
|
|
114
|
+
const callData = await encodeUninstallValidation({
|
|
115
|
+
moduleAddress,
|
|
116
|
+
entityId,
|
|
117
|
+
uninstallData,
|
|
118
|
+
hookUninstallDatas,
|
|
119
|
+
account,
|
|
120
|
+
});
|
|
121
|
+
return client.sendUserOperation({
|
|
122
|
+
uo: callData,
|
|
123
|
+
account,
|
|
124
|
+
overrides,
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
};
|
|
109
129
|
//# sourceMappingURL=installValidation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installValidation.js","sourceRoot":"","sources":["../../../../../../src/ma-v2/actions/install-validation/installValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,GAKtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,kBAAkB,EAClB,SAAS,EACT,WAAW,GACZ,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAE5F,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,
|
|
1
|
+
{"version":3,"file":"installValidation.js","sourceRoot":"","sources":["../../../../../../src/ma-v2/actions/install-validation/installValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,GAKtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,kBAAkB,EAClB,SAAS,EACT,WAAW,GACZ,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAE5F,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAA+B,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAyB,MAAM,8CAA8C,CAAC;AACrF,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AA+CzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAII,CAAC,MAAM,EAAE,EAAE;IAClD,MAAM,uBAAuB,GAAG,KAAK,EAAE,EACrC,gBAAgB,EAChB,SAAS,EACT,WAAW,EACX,KAAK,EACL,OAAO,GAAG,MAAM,CAAC,OAAO,GACA,EAAE,EAAE;QAC5B,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;QACnC,CAAC;QAED,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,uBAAuB,CAC/B,oBAAoB,EACpB,mBAAmB,EACnB,MAAM,CACP,CAAC;QACJ,CAAC;QAED,2GAA2G;QAC3G,IACE,gBAAgB,CAAC,QAAQ,KAAK,uBAAuB;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,KAAK,EACL,OAAO,GAAG,MAAM,CAAC,OAAO,EACxB,SAAS,GACV,EAAE,EAAE;YACH,MAAM,QAAQ,GAAG,MAAM,uBAAuB,CAAC;gBAC7C,gBAAgB;gBAChB,SAAS;gBACT,WAAW;gBACX,KAAK;gBACL,OAAO;aACR,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC,iBAAiB,CAAC;gBAC9B,EAAE,EAAE,QAAQ;gBACZ,OAAO;gBACP,SAAS;aACV,CAAC,CAAC;QACL,CAAC;QAED,mBAAmB,EAAE,KAAK,EAAE,EAC1B,aAAa,EACb,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,OAAO,GAAG,MAAM,CAAC,OAAO,EACxB,SAAS,GACV,EAAE,EAAE;YACH,MAAM,QAAQ,GAAG,MAAM,yBAAyB,CAAC;gBAC/C,aAAa;gBACb,QAAQ;gBACR,aAAa;gBACb,kBAAkB;gBAClB,OAAO;aACR,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC,iBAAiB,CAAC;gBAC9B,EAAE,EAAE,QAAQ;gBACZ,OAAO;gBACP,SAAS;aACV,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {\n AccountNotFoundError,\n IncompatibleClientError,\n isSmartAccountClient,\n EntityIdOverrideError,\n type GetEntryPointFromAccount,\n type SendUserOperationResult,\n type UserOperationOverridesParameter,\n type SmartAccountSigner,\n} from \"@aa-sdk/core\";\nimport {\n type Address,\n type Hex,\n encodeFunctionData,\n concatHex,\n zeroAddress,\n} from \"viem\";\n\nimport { semiModularAccountBytecodeAbi } from \"../../abis/semiModularAccountBytecodeAbi.js\";\nimport type { HookConfig, ValidationConfig } from \"../common/types.js\";\nimport {\n serializeValidationConfig,\n serializeHookConfig,\n serializeModuleEntity,\n} from \"../common/utils.js\";\n\nimport { type ModularAccountV2Client } from \"../../client/client.js\";\nimport { type ModularAccountV2 } from \"../../account/common/modularAccountV2Base.js\";\nimport { DEFAULT_OWNER_ENTITY_ID } from \"../../utils.js\";\n\nexport type InstallValidationParams<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = {\n validationConfig: ValidationConfig;\n selectors: Hex[];\n installData: Hex;\n hooks: {\n hookConfig: HookConfig;\n initData: Hex;\n }[];\n account?: ModularAccountV2<TSigner> | undefined;\n} & UserOperationOverridesParameter<\n GetEntryPointFromAccount<ModularAccountV2<TSigner>>\n>;\n\nexport type UninstallValidationParams<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = {\n moduleAddress: Address;\n entityId: number;\n uninstallData: Hex;\n hookUninstallDatas: Hex[];\n account?: ModularAccountV2<TSigner> | undefined;\n} & UserOperationOverridesParameter<\n GetEntryPointFromAccount<ModularAccountV2<TSigner>>\n>;\n\nexport type InstallValidationActions<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = {\n installValidation: (\n args: InstallValidationParams<TSigner>\n ) => Promise<SendUserOperationResult>;\n encodeInstallValidation: (\n // TODO: omit the user op sending related parameters from this type\n args: InstallValidationParams<TSigner>\n ) => Promise<Hex>;\n uninstallValidation: (\n args: UninstallValidationParams<TSigner>\n ) => Promise<SendUserOperationResult>;\n encodeUninstallValidation: (\n args: UninstallValidationParams<TSigner>\n ) => Promise<Hex>;\n};\n\n/**\n * Provides validation installation and uninstallation functionalities for a MA v2 client, ensuring compatibility with `SmartAccountClient`.\n *\n * @example\n * ```ts\n * import { createModularAccountV2Client, installValidationActions, getDefaultSingleSignerValidationModuleAddress, SingleSignerValidationModule } from \"@account-kit/smart-contracts\";\n * import { Address } from \"viem\";\n *\n * const client = (await createModularAccountV2Client({ ... })).extend(installValidationActions);\n * const sessionKeyAddress: Address = \"0x1234\";\n * const sessionKeyEntityId: number = 1;\n *\n * await client.installValidation({\n * validationConfig: {\n * moduleAddress: getDefaultSingleSignerValidationModuleAddress(\n * client.chain\n * ),\n * entityId: sessionKeyEntityId,\n * isGlobal: true,\n * isSignatureValidation: false,\n * isUserOpValidation: true,\n * },\n * selectors: [],\n * installData: SingleSignerValidationModule.encodeOnInstallData({\n * entityId: sessionKeyEntityId,\n * signer: sessionKeyAddress,\n * }),\n * hooks: [],\n * });\n *\n * await client.uninstallValidation({\n * moduleAddress: sessionKeyAddress,\n * entityId: sessionKeyEntityId,\n * uninstallData: SingleSignerValidationModule.encodeOnUninstallData({\n * entityId: sessionKeyEntityId,\n * }),\n * hookUninstallDatas: [],\n * });\n *\n * ```\n *\n * @param {object} client - The client instance which provides account and sendUserOperation functionality.\n * @returns {object} - An object containing two methods, `installValidation` and `uninstallValidation`.\n */\nexport const installValidationActions: <\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>(\n client: ModularAccountV2Client<TSigner>\n) => InstallValidationActions<TSigner> = (client) => {\n const encodeInstallValidation = async ({\n validationConfig,\n selectors,\n installData,\n hooks,\n account = client.account,\n }: InstallValidationParams) => {\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"SmartAccountClient\",\n \"installValidation\",\n client\n );\n }\n\n // an entityId of zero is only allowed if we're installing or uninstalling hooks on the fallback validation\n if (\n validationConfig.entityId === DEFAULT_OWNER_ENTITY_ID &&\n validationConfig.moduleAddress !== zeroAddress\n ) {\n throw new EntityIdOverrideError();\n }\n\n return account.encodeCallData(\n encodeFunctionData({\n abi: semiModularAccountBytecodeAbi,\n functionName: \"installValidation\",\n args: [\n serializeValidationConfig(validationConfig),\n selectors,\n installData,\n hooks.map((hook: { hookConfig: HookConfig; initData: Hex }) =>\n concatHex([serializeHookConfig(hook.hookConfig), hook.initData])\n ),\n ],\n })\n );\n };\n\n const encodeUninstallValidation = async ({\n moduleAddress,\n entityId,\n uninstallData,\n hookUninstallDatas,\n account = client.account,\n }: UninstallValidationParams) => {\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"SmartAccountClient\",\n \"uninstallValidation\",\n client\n );\n }\n\n return account.encodeCallData(\n encodeFunctionData({\n abi: semiModularAccountBytecodeAbi,\n functionName: \"uninstallValidation\",\n args: [\n serializeModuleEntity({\n moduleAddress,\n entityId,\n }),\n uninstallData,\n hookUninstallDatas,\n ],\n })\n );\n };\n\n return {\n encodeInstallValidation,\n encodeUninstallValidation,\n installValidation: async ({\n validationConfig,\n selectors,\n installData,\n hooks,\n account = client.account,\n overrides,\n }) => {\n const callData = await encodeInstallValidation({\n validationConfig,\n selectors,\n installData,\n hooks,\n account,\n });\n\n return client.sendUserOperation({\n uo: callData,\n account,\n overrides,\n });\n },\n\n uninstallValidation: async ({\n moduleAddress,\n entityId,\n uninstallData,\n hookUninstallDatas,\n account = client.account,\n overrides,\n }) => {\n const callData = await encodeUninstallValidation({\n moduleAddress,\n entityId,\n uninstallData,\n hookUninstallDatas,\n account,\n });\n\n return client.sendUserOperation({\n uo: callData,\n account,\n overrides,\n });\n },\n };\n};\n"]}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { type SmartAccountClient, type SmartAccountSigner, type SmartAccountClientConfig, type NotType } from "@aa-sdk/core";
|
|
2
2
|
import { type Chain, type Transport } from "viem";
|
|
3
|
-
import { type
|
|
3
|
+
import { type CreateModularAccountV2Params } from "../account/modularAccountV2.js";
|
|
4
4
|
import { type AlchemySmartAccountClientConfig, type AlchemyTransport } from "@account-kit/infra";
|
|
5
5
|
import type { LightAccount } from "../../light-account/accounts/account.js";
|
|
6
|
-
|
|
7
|
-
export type
|
|
8
|
-
export type
|
|
6
|
+
import type { ModularAccountV2 } from "../account/common/modularAccountV2Base.js";
|
|
7
|
+
export type ModularAccountV2Client<TSigner extends SmartAccountSigner = SmartAccountSigner, TChain extends Chain = Chain, TTransport extends Transport | AlchemyTransport = Transport> = SmartAccountClient<TTransport, TChain, ModularAccountV2<TSigner>>;
|
|
8
|
+
export type CreateModularAccountV2ClientParams<TTransport extends Transport = Transport, TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner> = CreateModularAccountV2Params<TTransport, TSigner> & Omit<SmartAccountClientConfig<TTransport, TChain>, "transport" | "account" | "chain">;
|
|
9
|
+
export type CreateModularAccountV2AlchemyClientParams<TTransport extends Transport = Transport, TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner> = Omit<CreateModularAccountV2ClientParams<TTransport, TChain, TSigner>, "transport"> & Omit<AlchemySmartAccountClientConfig<TChain, LightAccount<TSigner>>, "account"> & {
|
|
9
10
|
paymasterAndData?: never;
|
|
10
11
|
dummyPaymasterAndData?: never;
|
|
11
12
|
};
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
13
|
+
export declare function createModularAccountV2Client<TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner>(args: CreateModularAccountV2AlchemyClientParams<AlchemyTransport, TChain, TSigner>): Promise<ModularAccountV2Client<TSigner, TChain, AlchemyTransport>>;
|
|
14
|
+
export declare function createModularAccountV2Client<TTransport extends Transport = Transport, TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner>(args: CreateModularAccountV2ClientParams<TTransport, TChain, TSigner> & NotType<TTransport, AlchemyTransport>): Promise<ModularAccountV2Client<TSigner, TChain>>;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { createSmartAccountClient, } from "@aa-sdk/core";
|
|
1
|
+
import { createSmartAccountClient, default7702GasEstimator, default7702UserOpSigner, } from "@aa-sdk/core";
|
|
2
2
|
import {} from "viem";
|
|
3
|
-
import {
|
|
3
|
+
import { createModularAccountV2, } from "../account/modularAccountV2.js";
|
|
4
4
|
import { createAlchemySmartAccountClient, isAlchemyTransport, } from "@account-kit/infra";
|
|
5
5
|
/**
|
|
6
|
-
* Creates a
|
|
6
|
+
* Creates a Modular Account V2 client using the provided configuration parameters.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* import {
|
|
11
|
-
* import { createSMAV2AccountClient } from "@account-kit/smart-contracts";
|
|
9
|
+
* ```ts twoslash
|
|
10
|
+
* import { createModularAccountV2Client } from "@account-kit/smart-contracts";
|
|
12
11
|
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
13
|
-
* import { sepolia } from "@account-kit/infra";
|
|
12
|
+
* import { alchemy, sepolia } from "@account-kit/infra";
|
|
14
13
|
*
|
|
15
14
|
* const MNEMONIC = "...";
|
|
16
15
|
* const RPC_URL = "...";
|
|
@@ -19,11 +18,11 @@ import { createAlchemySmartAccountClient, isAlchemyTransport, } from "@account-k
|
|
|
19
18
|
*
|
|
20
19
|
* const chain = sepolia;
|
|
21
20
|
*
|
|
22
|
-
* const transport =
|
|
21
|
+
* const transport = alchemy({ rpcUrl: RPC_URL });
|
|
23
22
|
*
|
|
24
23
|
* const policyId = "...";
|
|
25
24
|
*
|
|
26
|
-
* const
|
|
25
|
+
* const modularAccountV2Client = await createModularAccountV2Client({
|
|
27
26
|
* chain,
|
|
28
27
|
* signer,
|
|
29
28
|
* transport,
|
|
@@ -31,27 +30,31 @@ import { createAlchemySmartAccountClient, isAlchemyTransport, } from "@account-k
|
|
|
31
30
|
* });
|
|
32
31
|
* ```
|
|
33
32
|
*
|
|
34
|
-
* @param {
|
|
33
|
+
* @param {CreateModularAccountV2ClientParams} config The configuration parameters required to create the Modular Account v2 account client
|
|
35
34
|
* @returns {Promise<SmartAccountClient>} A promise that resolves to a `SmartAccountClient` instance
|
|
36
35
|
*/
|
|
37
|
-
export async function
|
|
36
|
+
export async function createModularAccountV2Client(config) {
|
|
38
37
|
const { transport, chain } = config;
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
const account = await createModularAccountV2(config);
|
|
39
|
+
const middlewareToAppend = config.mode === "7702"
|
|
40
|
+
? {
|
|
41
|
+
gasEstimator: default7702GasEstimator(config.gasEstimator),
|
|
42
|
+
signUserOperation: default7702UserOpSigner(config.signUserOperation),
|
|
43
|
+
}
|
|
44
|
+
: {};
|
|
44
45
|
if (isAlchemyTransport(transport, chain)) {
|
|
45
46
|
return createAlchemySmartAccountClient({
|
|
46
47
|
...config,
|
|
47
48
|
transport,
|
|
48
49
|
chain,
|
|
49
|
-
account
|
|
50
|
+
account,
|
|
51
|
+
...middlewareToAppend,
|
|
50
52
|
});
|
|
51
53
|
}
|
|
52
54
|
return createSmartAccountClient({
|
|
53
55
|
...config,
|
|
54
|
-
account
|
|
56
|
+
account,
|
|
57
|
+
...middlewareToAppend,
|
|
55
58
|
});
|
|
56
59
|
}
|
|
57
60
|
//# sourceMappingURL=client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../src/ma-v2/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,wBAAwB,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../src/ma-v2/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAA8B,MAAM,MAAM,CAAC;AAElD,OAAO,EACL,sBAAsB,GAEvB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,+BAA+B,EAC/B,kBAAkB,GAInB,MAAM,oBAAoB,CAAC;AAsD5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,MAE6C;IAE7C,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IAEpC,MAAM,OAAO,GAAG,MAAM,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAErD,MAAM,kBAAkB,GACtB,MAAM,CAAC,IAAI,KAAK,MAAM;QACpB,CAAC,CAAC;YACE,YAAY,EAAE,uBAAuB,CAAC,MAAM,CAAC,YAAY,CAAC;YAC1D,iBAAiB,EAAE,uBAAuB,CAAC,MAAM,CAAC,iBAAiB,CAAC;SACrE;QACH,CAAC,CAAC,EAAE,CAAC;IAET,IAAI,kBAAkB,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;QACzC,OAAO,+BAA+B,CAAC;YACrC,GAAG,MAAM;YACT,SAAS;YACT,KAAK;YACL,OAAO;YACP,GAAG,kBAAkB;SACtB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,wBAAwB,CAAC;QAC9B,GAAG,MAAM;QACT,OAAO;QACP,GAAG,kBAAkB;KACtB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n type SmartAccountClient,\n type SmartAccountSigner,\n type SmartAccountClientConfig,\n type NotType,\n createSmartAccountClient,\n default7702GasEstimator,\n default7702UserOpSigner,\n} from \"@aa-sdk/core\";\nimport { type Chain, type Transport } from \"viem\";\n\nimport {\n createModularAccountV2,\n type CreateModularAccountV2Params,\n} from \"../account/modularAccountV2.js\";\n\nimport {\n createAlchemySmartAccountClient,\n isAlchemyTransport,\n type AlchemySmartAccountClient,\n type AlchemySmartAccountClientConfig,\n type AlchemyTransport,\n} from \"@account-kit/infra\";\nimport type { LightAccount } from \"../../light-account/accounts/account.js\";\n\nimport type { ModularAccountV2 } from \"../account/common/modularAccountV2Base.js\";\n\nexport type ModularAccountV2Client<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TChain extends Chain = Chain,\n TTransport extends Transport | AlchemyTransport = Transport\n> = SmartAccountClient<TTransport, TChain, ModularAccountV2<TSigner>>;\n\nexport type CreateModularAccountV2ClientParams<\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = CreateModularAccountV2Params<TTransport, TSigner> &\n Omit<\n SmartAccountClientConfig<TTransport, TChain>,\n \"transport\" | \"account\" | \"chain\"\n >;\n\nexport type CreateModularAccountV2AlchemyClientParams<\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = Omit<\n CreateModularAccountV2ClientParams<TTransport, TChain, TSigner>,\n \"transport\"\n> &\n Omit<\n AlchemySmartAccountClientConfig<TChain, LightAccount<TSigner>>,\n \"account\"\n > & { paymasterAndData?: never; dummyPaymasterAndData?: never };\n\nexport function createModularAccountV2Client<\n TChain extends Chain = Chain,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>(\n args: CreateModularAccountV2AlchemyClientParams<\n AlchemyTransport,\n TChain,\n TSigner\n >\n): Promise<ModularAccountV2Client<TSigner, TChain, AlchemyTransport>>;\n\nexport function createModularAccountV2Client<\n TTransport extends Transport = Transport,\n TChain extends Chain = Chain,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>(\n args: CreateModularAccountV2ClientParams<TTransport, TChain, TSigner> &\n NotType<TTransport, AlchemyTransport>\n): Promise<ModularAccountV2Client<TSigner, TChain>>;\n\n/**\n * Creates a Modular Account V2 client using the provided configuration parameters.\n *\n * @example\n * ```ts twoslash\n * import { createModularAccountV2Client } 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 * const policyId = \"...\";\n *\n * const modularAccountV2Client = await createModularAccountV2Client({\n * chain,\n * signer,\n * transport,\n * policyId, // NOTE: you may only pass in a gas policy ID if you provide an Alchemy transport!\n * });\n * ```\n *\n * @param {CreateModularAccountV2ClientParams} config The configuration parameters required to create the Modular Account v2 account client\n * @returns {Promise<SmartAccountClient>} A promise that resolves to a `SmartAccountClient` instance\n */\nexport async function createModularAccountV2Client(\n config:\n | CreateModularAccountV2ClientParams\n | CreateModularAccountV2AlchemyClientParams\n): Promise<SmartAccountClient | AlchemySmartAccountClient> {\n const { transport, chain } = config;\n\n const account = await createModularAccountV2(config);\n\n const middlewareToAppend =\n config.mode === \"7702\"\n ? {\n gasEstimator: default7702GasEstimator(config.gasEstimator),\n signUserOperation: default7702UserOpSigner(config.signUserOperation),\n }\n : {};\n\n if (isAlchemyTransport(transport, chain)) {\n return createAlchemySmartAccountClient({\n ...config,\n transport,\n chain,\n account,\n ...middlewareToAppend,\n });\n }\n\n return createSmartAccountClient({\n ...config,\n account,\n ...middlewareToAppend,\n });\n}\n"]}
|
|
@@ -3,15 +3,11 @@ export { modularAccountAbi } from "./abis/modularAccountAbi.js";
|
|
|
3
3
|
export { semiModularAccountBytecodeAbi } from "./abis/semiModularAccountBytecodeAbi.js";
|
|
4
4
|
export { semiModularAccountStorageAbi } from "./abis/semiModularAccountStorageAbi.js";
|
|
5
5
|
export { nativeSMASigner } from "./account/nativeSMASigner.js";
|
|
6
|
-
export type * from "./account/semiModularAccountV2.js";
|
|
7
|
-
export { createSMAV2Account } from "./account/semiModularAccountV2.js";
|
|
8
6
|
export type { ModuleEntity, ValidationConfig, HookConfig, ValidationData, } from "./actions/common/types.js";
|
|
9
7
|
export { HookType } from "./actions/common/types.js";
|
|
10
8
|
export { serializeValidationConfig, serializeHookConfig, serializeModuleEntity, } from "./actions/common/utils.js";
|
|
11
9
|
export type * from "./actions/install-validation/installValidation.js";
|
|
12
10
|
export { installValidationActions } from "./actions/install-validation/installValidation.js";
|
|
13
|
-
export type * from "./client/client.js";
|
|
14
|
-
export { createSMAV2AccountClient } from "./client/client.js";
|
|
15
11
|
export { getDefaultAllowlistModuleAddress, getDefaultNativeTokenLimitModuleAddress, getDefaultPaymasterGuardModuleAddress, getDefaultSingleSignerValidationModuleAddress, getDefaultTimeRangeModuleAddress, getDefaultWebauthnValidationModuleAddress, } from "./modules/utils.js";
|
|
16
12
|
export { allowlistModuleAbi } from "./modules/allowlist-module/abis/allowlistModuleAbi.js";
|
|
17
13
|
export { AllowlistModule } from "./modules/allowlist-module/module.js";
|
|
@@ -4,11 +4,9 @@ export { modularAccountAbi } from "./abis/modularAccountAbi.js";
|
|
|
4
4
|
export { semiModularAccountBytecodeAbi } from "./abis/semiModularAccountBytecodeAbi.js";
|
|
5
5
|
export { semiModularAccountStorageAbi } from "./abis/semiModularAccountStorageAbi.js";
|
|
6
6
|
export { nativeSMASigner } from "./account/nativeSMASigner.js";
|
|
7
|
-
export { createSMAV2Account } from "./account/semiModularAccountV2.js";
|
|
8
7
|
export { HookType } from "./actions/common/types.js";
|
|
9
8
|
export { serializeValidationConfig, serializeHookConfig, serializeModuleEntity, } from "./actions/common/utils.js";
|
|
10
9
|
export { installValidationActions } from "./actions/install-validation/installValidation.js";
|
|
11
|
-
export { createSMAV2AccountClient } from "./client/client.js";
|
|
12
10
|
export { getDefaultAllowlistModuleAddress, getDefaultNativeTokenLimitModuleAddress, getDefaultPaymasterGuardModuleAddress, getDefaultSingleSignerValidationModuleAddress, getDefaultTimeRangeModuleAddress, getDefaultWebauthnValidationModuleAddress, } from "./modules/utils.js";
|
|
13
11
|
export { allowlistModuleAbi } from "./modules/allowlist-module/abis/allowlistModuleAbi.js";
|
|
14
12
|
export { AllowlistModule } from "./modules/allowlist-module/module.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;
|
|
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,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 { 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,4 +1,5 @@
|
|
|
1
1
|
import { type Address, type Hex } from "viem";
|
|
2
|
+
import { type HookConfig } from "../../actions/common/types.js";
|
|
2
3
|
export declare const AllowlistModule: {
|
|
3
4
|
abi: readonly [{
|
|
4
5
|
readonly type: "function";
|
|
@@ -556,6 +557,19 @@ export declare const AllowlistModule: {
|
|
|
556
557
|
readonly name: "UnexpectedDataPassed";
|
|
557
558
|
readonly inputs: readonly [];
|
|
558
559
|
}];
|
|
560
|
+
buildHook: (installArgs: {
|
|
561
|
+
entityId: number;
|
|
562
|
+
inputs: Array<{
|
|
563
|
+
target: Address;
|
|
564
|
+
hasSelectorAllowlist: boolean;
|
|
565
|
+
hasERC20SpendLimit: boolean;
|
|
566
|
+
erc20SpendLimit: bigint;
|
|
567
|
+
selectors: Array<Hex>;
|
|
568
|
+
}>;
|
|
569
|
+
}, address: Address) => {
|
|
570
|
+
hookConfig: HookConfig;
|
|
571
|
+
initData: Hex;
|
|
572
|
+
};
|
|
559
573
|
encodeOnInstallData: (args: {
|
|
560
574
|
entityId: number;
|
|
561
575
|
inputs: Array<{
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import { encodeAbiParameters } from "viem";
|
|
2
2
|
import { allowlistModuleAbi } from "./abis/allowlistModuleAbi.js";
|
|
3
|
+
import { HookType } from "../../actions/common/types.js";
|
|
3
4
|
export const AllowlistModule = {
|
|
4
5
|
abi: allowlistModuleAbi,
|
|
6
|
+
buildHook: (installArgs, address) => {
|
|
7
|
+
const installData = AllowlistModule.encodeOnInstallData(installArgs);
|
|
8
|
+
return {
|
|
9
|
+
hookConfig: {
|
|
10
|
+
address: address,
|
|
11
|
+
entityId: installArgs.entityId,
|
|
12
|
+
hookType: HookType.VALIDATION,
|
|
13
|
+
hasPreHooks: true,
|
|
14
|
+
hasPostHooks: false,
|
|
15
|
+
},
|
|
16
|
+
initData: installData,
|
|
17
|
+
};
|
|
18
|
+
},
|
|
5
19
|
encodeOnInstallData: (args) => {
|
|
6
20
|
const { entityId, inputs } = args;
|
|
7
21
|
return encodeAbiParameters([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../../../../../src/ma-v2/modules/allowlist-module/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAA0B,MAAM,MAAM,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../../../../../src/ma-v2/modules/allowlist-module/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAA0B,MAAM,MAAM,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAmB,MAAM,+BAA+B,CAAC;AAE1E,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,GAAG,EAAE,kBAAkB;IACvB,SAAS,EAAE,CACT,WASC,EACD,OAAgB,EAIhB,EAAE;QACF,MAAM,WAAW,GAAG,eAAe,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;QACrE,OAAO;YACL,UAAU,EAAE;gBACV,OAAO,EAAE,OAAO;gBAChB,QAAQ,EAAE,WAAW,CAAC,QAAQ;gBAC9B,QAAQ,EAAE,QAAQ,CAAC,UAAU;gBAC7B,WAAW,EAAE,IAAI;gBACjB,YAAY,EAAE,KAAK;aACpB;YACD,QAAQ,EAAE,WAAW;SACtB,CAAC;IACJ,CAAC;IACD,mBAAmB,EAAE,CAAC,IASrB,EAAO,EAAE;QACR,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAClC,OAAO,mBAAmB,CACxB;YACE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAClB;gBACE,IAAI,EAAE,SAAS;gBACf,UAAU,EAAE;oBACV,EAAE,IAAI,EAAE,SAAS,EAAE;oBACnB,EAAE,IAAI,EAAE,MAAM,EAAE;oBAChB,EAAE,IAAI,EAAE,MAAM,EAAE;oBAChB,EAAE,IAAI,EAAE,SAAS,EAAE;oBACnB,EAAE,IAAI,EAAE,UAAU,EAAE;iBACrB;aACF;SACF,EACD;YACE,QAAQ;YACR,MAAM,CAAC,GAAG,CACR,CAAC,KAAK,EAAE,EAAE,CACR;gBACE,KAAK,CAAC,MAAM;gBACZ,KAAK,CAAC,oBAAoB;gBAC1B,KAAK,CAAC,kBAAkB;gBACxB,KAAK,CAAC,eAAe;gBACrB,KAAK,CAAC,SAAS;aACP,CACb;SACF,CACF,CAAC;IACJ,CAAC;IAED,qBAAqB,EAAE,CAAC,IASvB,EAAO,EAAE;QACR,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAClC,OAAO,mBAAmB,CACxB;YACE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAClB;gBACE,IAAI,EAAE,SAAS;gBACf,UAAU,EAAE;oBACV,EAAE,IAAI,EAAE,SAAS,EAAE;oBACnB,EAAE,IAAI,EAAE,MAAM,EAAE;oBAChB,EAAE,IAAI,EAAE,MAAM,EAAE;oBAChB,EAAE,IAAI,EAAE,SAAS,EAAE;oBACnB,EAAE,IAAI,EAAE,UAAU,EAAE;iBACrB;aACF;SACF,EACD;YACE,QAAQ;YACR,MAAM,CAAC,GAAG,CACR,CAAC,KAAK,EAAE,EAAE,CACR;gBACE,KAAK,CAAC,MAAM;gBACZ,KAAK,CAAC,oBAAoB;gBAC1B,KAAK,CAAC,kBAAkB;gBACxB,KAAK,CAAC,eAAe;gBACrB,KAAK,CAAC,SAAS;aACP,CACb;SACF,CACF,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { encodeAbiParameters, type Address, type Hex } from \"viem\";\nimport { allowlistModuleAbi } from \"./abis/allowlistModuleAbi.js\";\nimport { HookType, type HookConfig } from \"../../actions/common/types.js\";\n\nexport const AllowlistModule = {\n abi: allowlistModuleAbi,\n buildHook: (\n installArgs: {\n entityId: number;\n inputs: Array<{\n target: Address;\n hasSelectorAllowlist: boolean;\n hasERC20SpendLimit: boolean;\n erc20SpendLimit: bigint;\n selectors: Array<Hex>;\n }>;\n },\n address: Address\n ): {\n hookConfig: HookConfig;\n initData: Hex;\n } => {\n const installData = AllowlistModule.encodeOnInstallData(installArgs);\n return {\n hookConfig: {\n address: address,\n entityId: installArgs.entityId,\n hookType: HookType.VALIDATION,\n hasPreHooks: true,\n hasPostHooks: false,\n },\n initData: installData,\n };\n },\n encodeOnInstallData: (args: {\n entityId: number;\n inputs: Array<{\n target: Address;\n hasSelectorAllowlist: boolean;\n hasERC20SpendLimit: boolean;\n erc20SpendLimit: bigint;\n selectors: Array<Hex>;\n }>;\n }): Hex => {\n const { entityId, inputs } = args;\n return encodeAbiParameters(\n [\n { type: \"uint32\" },\n {\n type: \"tuple[]\",\n components: [\n { type: \"address\" },\n { type: \"bool\" },\n { type: \"bool\" },\n { type: \"uint256\" },\n { type: \"bytes4[]\" },\n ],\n },\n ],\n [\n entityId,\n inputs.map(\n (input) =>\n [\n input.target,\n input.hasSelectorAllowlist,\n input.hasERC20SpendLimit,\n input.erc20SpendLimit,\n input.selectors,\n ] as const\n ),\n ]\n );\n },\n\n encodeOnUninstallData: (args: {\n entityId: number;\n inputs: Array<{\n target: Address;\n hasSelectorAllowlist: boolean;\n hasERC20SpendLimit: boolean;\n erc20SpendLimit: bigint;\n selectors: Array<Hex>;\n }>;\n }): Hex => {\n const { entityId, inputs } = args;\n return encodeAbiParameters(\n [\n { type: \"uint32\" },\n {\n type: \"tuple[]\",\n components: [\n { type: \"address\" },\n { type: \"bool\" },\n { type: \"bool\" },\n { type: \"uint256\" },\n { type: \"bytes4[]\" },\n ],\n },\n ],\n [\n entityId,\n inputs.map(\n (input) =>\n [\n input.target,\n input.hasSelectorAllowlist,\n input.hasERC20SpendLimit,\n input.erc20SpendLimit,\n input.selectors,\n ] as const\n ),\n ]\n );\n },\n};\n"]}
|
|
@@ -11,7 +11,7 @@ import { type Hex, type SignableMessage, type TypedDataDefinition, type Chain, t
|
|
|
11
11
|
*
|
|
12
12
|
* const MNEMONIC = "...":
|
|
13
13
|
*
|
|
14
|
-
* const account =
|
|
14
|
+
* const account = createModularAccountV2({ config });
|
|
15
15
|
*
|
|
16
16
|
* const signer = LocalAccountSigner.mnemonicToAccountSigner(MNEMONIC);
|
|
17
17
|
*
|
|
@@ -12,7 +12,7 @@ import { packUOSignature, pack1271Signature } from "../../utils.js";
|
|
|
12
12
|
*
|
|
13
13
|
* const MNEMONIC = "...":
|
|
14
14
|
*
|
|
15
|
-
* const account =
|
|
15
|
+
* const account = createModularAccountV2({ config });
|
|
16
16
|
*
|
|
17
17
|
* const signer = LocalAccountSigner.mnemonicToAccountSigner(MNEMONIC);
|
|
18
18
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../../../../../../src/ma-v2/modules/single-signer-validation/signer.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,aAAa,EACb,SAAS,GAOV,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,6CAA6C,EAAE,MAAM,aAAa,CAAC;AAE5E,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACpE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,MAA0B,EAC1B,KAAY,EACZ,cAAuB,EACvB,QAAgB,EAChB,EAAE;IACF,OAAO;QACL,iBAAiB,EAAE,GAAQ,EAAE;YAC3B,MAAM,mBAAmB,GACvB,sIAAsI,CAAC;YAEzI,OAAO,eAAe,CAAC;gBACrB,uBAAuB;gBACvB,mBAAmB,EAAE,mBAAmB;aACzC,CAAC,CAAC;QACL,CAAC;QAED,qBAAqB,EAAE,CAAC,MAAW,EAAgB,EAAE;YACnD,OAAO,MAAM,CAAC,WAAW,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAc,EAAE,EAAE,CACjE,eAAe,CAAC;gBACd,uBAAuB;gBACvB,mBAAmB,EAAE,SAAS;aAC/B,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cAAc,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;iBACpD;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,MAAM,aAAa,CAAC,mBAAmB,CAAC;iBAC/C;gBACD,WAAW,EAAE,gBAAgB;aAC9B,CAAC,CAAC;YAEH,OAAO,gBAAgB;gBACrB,CAAC,CAAC,mBAAmB;gBACrB,CAAC,CAAC,iBAAiB,CAAC;oBAChB,mBAAmB;oBACnB,QAAQ;iBACT,CAAC,CAAC;QACT,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport {\n hashMessage,\n hashTypedData,\n concatHex,\n type Hex,\n type SignableMessage,\n type TypedData,\n type TypedDataDefinition,\n type Chain,\n type Address,\n} from \"viem\";\nimport { getDefaultSingleSignerValidationModuleAddress } from \"../utils.js\";\n\nimport { packUOSignature, pack1271Signature } from \"../../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 \n * ```ts\n * import { singleSignerMessageSigner } from \"@account-kit/smart-contracts\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n *\n * const MNEMONIC = \"...\":\n * \n * const account =
|
|
1
|
+
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../../../../../../src/ma-v2/modules/single-signer-validation/signer.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,aAAa,EACb,SAAS,GAOV,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,6CAA6C,EAAE,MAAM,aAAa,CAAC;AAE5E,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACpE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,MAA0B,EAC1B,KAAY,EACZ,cAAuB,EACvB,QAAgB,EAChB,EAAE;IACF,OAAO;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WAAW,KAAK,gBAAgB;gBACrD,mBAAmB,EAAE,MAAM,EAAE,iBAAiB,KAAK,cAAc,CAAC;YAEpE,MAAM,mBAAmB,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC;gBACrD,MAAM,EAAE;oBACN,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;oBACzB,iBAAiB,EACf,6CAA6C,CAAC,KAAK,CAAC;oBACtD,IAAI,EAAE,SAAS,CAAC,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;iBAC1D;gBACD,KAAK,EAAE;oBACL,cAAc,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;iBACpD;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,MAAM,aAAa,CAAC,mBAAmB,CAAC;iBAC/C;gBACD,WAAW,EAAE,gBAAgB;aAC9B,CAAC,CAAC;YAEH,OAAO,gBAAgB;gBACrB,CAAC,CAAC,mBAAmB;gBACrB,CAAC,CAAC,iBAAiB,CAAC;oBAChB,mBAAmB;oBACnB,QAAQ;iBACT,CAAC,CAAC;QACT,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport {\n hashMessage,\n hashTypedData,\n concatHex,\n type Hex,\n type SignableMessage,\n type TypedData,\n type TypedDataDefinition,\n type Chain,\n type Address,\n} from \"viem\";\nimport { getDefaultSingleSignerValidationModuleAddress } from \"../utils.js\";\n\nimport { packUOSignature, pack1271Signature } from \"../../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 \n * ```ts\n * import { singleSignerMessageSigner } 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 = singleSignerMessageSigner(signer, chain, account.address, account.signerEntity.entityId);\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 {number} entityId the entity id of the signing validation\n * @returns {object} an object with methods for signing operations and managing signatures\n */\nexport const singleSignerMessageSigner = (\n signer: SmartAccountSigner,\n chain: Chain,\n accountAddress: Address,\n entityId: number\n) => {\n return {\n getDummySignature: (): Hex => {\n const dummyEcdsaSignature =\n \"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\";\n\n return packUOSignature({\n // orderedHookData: [],\n validationSignature: dummyEcdsaSignature,\n });\n },\n\n signUserOperationHash: (uoHash: Hex): Promise<Hex> => {\n return signer.signMessage({ raw: uoHash }).then((signature: Hex) =>\n packUOSignature({\n // orderedHookData: [],\n validationSignature: signature,\n })\n );\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 = await hashMessage(message);\n\n return pack1271Signature({\n validationSignature: await signer.signTypedData({\n domain: {\n chainId: Number(chain.id),\n verifyingContract:\n getDefaultSingleSignerValidationModuleAddress(chain),\n salt: concatHex([`0x${\"00\".repeat(12)}`, accountAddress]),\n },\n types: {\n ReplaySafeHash: [{ name: \"hash\", type: \"bytes32\" }],\n },\n message: {\n hash,\n },\n primaryType: \"ReplaySafeHash\",\n }),\n entityId,\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 const validationSignature = await signer.signTypedData({\n domain: {\n chainId: Number(chain.id),\n verifyingContract:\n getDefaultSingleSignerValidationModuleAddress(chain),\n salt: concatHex([`0x${\"00\".repeat(12)}`, accountAddress]),\n },\n types: {\n ReplaySafeHash: [{ name: \"hash\", type: \"bytes32\" }],\n },\n message: {\n hash: await hashTypedData(typedDataDefinition),\n },\n primaryType: \"ReplaySafeHash\",\n });\n\n return isDeferredAction\n ? validationSignature\n : pack1271Signature({\n validationSignature,\n entityId,\n });\n },\n };\n};\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type Hex } from "viem";
|
|
1
|
+
import { type Address, type Hex } from "viem";
|
|
2
|
+
import { type HookConfig } from "../../actions/common/types.js";
|
|
2
3
|
export declare const TimeRangeModule: {
|
|
3
4
|
abi: readonly [{
|
|
4
5
|
readonly type: "function";
|
|
@@ -229,6 +230,14 @@ export declare const TimeRangeModule: {
|
|
|
229
230
|
readonly name: "UnexpectedDataPassed";
|
|
230
231
|
readonly inputs: readonly [];
|
|
231
232
|
}];
|
|
233
|
+
buildHook: (installArgs: {
|
|
234
|
+
entityId: number;
|
|
235
|
+
validUntil: number;
|
|
236
|
+
validAfter: number;
|
|
237
|
+
}, address: Address) => {
|
|
238
|
+
hookConfig: HookConfig;
|
|
239
|
+
initData: Hex;
|
|
240
|
+
};
|
|
232
241
|
encodeOnInstallData: (args: {
|
|
233
242
|
entityId: number;
|
|
234
243
|
validUntil: number;
|
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
import { encodeAbiParameters } from "viem";
|
|
2
2
|
import { timeRangeModuleAbi } from "./abis/timeRangeModuleAbi.js";
|
|
3
|
+
import { HookType } from "../../actions/common/types.js";
|
|
3
4
|
export const TimeRangeModule = {
|
|
4
5
|
abi: timeRangeModuleAbi,
|
|
6
|
+
buildHook: (installArgs, address) => {
|
|
7
|
+
if (installArgs.validUntil > 2 ** 48 - 1) {
|
|
8
|
+
throw new Error("TimeRangeModule.buildHook: validUntil > type(uint48).max");
|
|
9
|
+
}
|
|
10
|
+
if (installArgs.validAfter > 2 ** 48 - 1) {
|
|
11
|
+
throw new Error("TimeRangeModule.buildHook: validAfter > type(uint48).max");
|
|
12
|
+
}
|
|
13
|
+
const installData = TimeRangeModule.encodeOnInstallData(installArgs);
|
|
14
|
+
return {
|
|
15
|
+
hookConfig: {
|
|
16
|
+
address: address,
|
|
17
|
+
entityId: installArgs.entityId,
|
|
18
|
+
hookType: HookType.VALIDATION,
|
|
19
|
+
hasPreHooks: false,
|
|
20
|
+
hasPostHooks: false,
|
|
21
|
+
},
|
|
22
|
+
initData: installData,
|
|
23
|
+
};
|
|
24
|
+
},
|
|
5
25
|
encodeOnInstallData: (args) => {
|
|
6
26
|
const { entityId, validUntil, validAfter } = args;
|
|
7
27
|
return encodeAbiParameters([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../../../../../src/ma-v2/modules/time-range-module/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../../../../../src/ma-v2/modules/time-range-module/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAA0B,MAAM,MAAM,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAmB,MAAM,+BAA+B,CAAC;AAE1E,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,GAAG,EAAE,kBAAkB;IACvB,SAAS,EAAE,CACT,WAIC,EACD,OAAgB,EAC2B,EAAE;QAC7C,IAAI,WAAW,CAAC,UAAU,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,E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ACD;gBACE,IAAI,EAAE,QAAQ;aACf;YACD;gBACE,IAAI,EAAE,QAAQ;aACf;SACF,EACD,CAAC,QAAQ,EAAE,UAAU,EAAE,UAAU,CAAC,CACnC,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { encodeAbiParameters, type Address, type Hex } from \"viem\";\n\nimport { timeRangeModuleAbi } from \"./abis/timeRangeModuleAbi.js\";\nimport { HookType, type HookConfig } from \"../../actions/common/types.js\";\n\nexport const TimeRangeModule = {\n abi: timeRangeModuleAbi,\n buildHook: (\n installArgs: {\n entityId: number;\n validUntil: number;\n validAfter: number;\n },\n address: Address\n ): { hookConfig: HookConfig; initData: Hex } => {\n if (installArgs.validUntil > 2 ** 48 - 1) {\n throw new Error(\n \"TimeRangeModule.buildHook: validUntil > type(uint48).max\"\n );\n }\n\n if (installArgs.validAfter > 2 ** 48 - 1) {\n throw new Error(\n \"TimeRangeModule.buildHook: validAfter > type(uint48).max\"\n );\n }\n\n const installData = TimeRangeModule.encodeOnInstallData(installArgs);\n return {\n hookConfig: {\n address: address,\n entityId: installArgs.entityId,\n hookType: HookType.VALIDATION,\n hasPreHooks: false,\n hasPostHooks: false,\n },\n initData: installData,\n };\n },\n encodeOnInstallData: (args: {\n entityId: number;\n validUntil: number;\n validAfter: number;\n }): Hex => {\n const { entityId, validUntil, validAfter } = args;\n\n return encodeAbiParameters(\n [\n {\n type: \"uint32\",\n },\n {\n type: \"uint48\",\n },\n {\n type: \"uint48\",\n },\n ],\n [entityId, validUntil, validAfter]\n );\n },\n encodeOnUninstallData: (args: { entityId: number }): Hex => {\n const { entityId } = args;\n\n return encodeAbiParameters(\n [\n {\n type: \"uint32\",\n },\n ],\n [entityId]\n );\n },\n encodeSetTimeRange: (args: {\n entityId: number;\n validUntil: number;\n validAfter: number;\n }): Hex => {\n const { entityId, validUntil, validAfter } = args;\n\n return encodeAbiParameters(\n [\n {\n type: \"uint32\",\n },\n {\n type: \"uint48\",\n },\n {\n type: \"uint48\",\n },\n ],\n [entityId, validUntil, validAfter]\n );\n },\n};\n"]}
|
|
@@ -51,4 +51,9 @@ export { SessionKeySigner } from "./msca/plugins/session-key/signer.js";
|
|
|
51
51
|
export { buildSessionKeysToRemoveStruct } from "./msca/plugins/session-key/utils.js";
|
|
52
52
|
export type * from "./msca/plugins/types.js";
|
|
53
53
|
export { getDefaultMultiOwnerModularAccountFactoryAddress, getDefaultMultisigModularAccountFactoryAddress, getMAInitializationData, getMSCAUpgradeToData, } from "./msca/utils.js";
|
|
54
|
+
export type * from "./ma-v2/account/modularAccountV2.js";
|
|
55
|
+
export type * from "./ma-v2/account/common/modularAccountV2Base.js";
|
|
56
|
+
export { createModularAccountV2 } from "./ma-v2/account/modularAccountV2.js";
|
|
57
|
+
export type * from "./ma-v2/client/client.js";
|
|
58
|
+
export { createModularAccountV2Client } from "./ma-v2/client/client.js";
|
|
54
59
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,mBAAmB,qCAAqC,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,iBAAiB,IAAI,6BAA6B,EAAE,MAAM,8CAA8C,CAAC;AAClH,OAAO,EACL,+BAA+B,EAC/B,KAAK,+BAA+B,GACrC,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EACL,yCAAyC,EACzC,KAAK,yCAAyC,GAC/C,MAAM,oDAAoD,CAAC;AAC5D,mBAAmB,4CAA4C,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AACvF,mBAAmB,0BAA0B,CAAC;AAE9C,OAAO,EACL,sBAAsB,EACtB,oCAAoC,EACpC,gCAAgC,EAChC,0BAA0B,EAC1B,oCAAoC,EACpC,8CAA8C,EA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