@alchemy/smart-accounts 0.0.0-alpha.9 → 5.0.0-beta.2
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/LICENSE +1 -1
- package/README.md +36 -0
- package/dist/esm/index.d.ts +2 -4
- package/dist/esm/index.js +2 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/light-account/accounts/account.d.ts +7 -3
- package/dist/esm/light-account/accounts/account.js +20 -10
- package/dist/esm/light-account/accounts/account.js.map +1 -1
- package/dist/esm/light-account/accounts/base.js +50 -23
- package/dist/esm/light-account/accounts/base.js.map +1 -1
- package/dist/esm/light-account/accounts/calldataCodec.js +3 -2
- package/dist/esm/light-account/accounts/calldataCodec.js.map +1 -1
- package/dist/esm/light-account/accounts/multi-owner-account.d.ts +6 -2
- package/dist/esm/light-account/accounts/multi-owner-account.js +14 -6
- package/dist/esm/light-account/accounts/multi-owner-account.js.map +1 -1
- package/dist/esm/light-account/lightAccountStaticImpl.d.ts +3 -1
- package/dist/esm/light-account/lightAccountStaticImpl.js +57 -7
- package/dist/esm/light-account/lightAccountStaticImpl.js.map +1 -1
- package/dist/esm/light-account/predictAddress.d.ts +40 -2
- package/dist/esm/light-account/predictAddress.js +83 -3
- package/dist/esm/light-account/predictAddress.js.map +1 -1
- package/dist/esm/light-account/registry.d.ts +3410 -0
- package/dist/esm/light-account/registry.js +33 -1
- package/dist/esm/light-account/registry.js.map +1 -1
- package/dist/esm/logger.d.ts +1 -1
- package/dist/esm/logger.js +1 -1
- package/dist/esm/logger.js.map +1 -1
- package/dist/esm/ma-v1/accounts/multi-owner-account.d.ts +6 -2
- package/dist/esm/ma-v1/accounts/multi-owner-account.js +18 -7
- package/dist/esm/ma-v1/accounts/multi-owner-account.js.map +1 -1
- package/dist/esm/ma-v1/predictAddress.d.ts +20 -1
- package/dist/esm/ma-v1/predictAddress.js +38 -2
- package/dist/esm/ma-v1/predictAddress.js.map +1 -1
- package/dist/esm/ma-v2/accounts/account.d.ts +8 -5
- package/dist/esm/ma-v2/accounts/account.js +23 -42
- package/dist/esm/ma-v2/accounts/account.js.map +1 -1
- package/dist/esm/ma-v2/accounts/base.d.ts +2 -2
- package/dist/esm/ma-v2/accounts/base.js +12 -59
- package/dist/esm/ma-v2/accounts/base.js.map +1 -1
- package/dist/esm/ma-v2/mav2StaticImpl.d.ts +1 -15
- package/dist/esm/ma-v2/mav2StaticImpl.js +0 -33
- package/dist/esm/ma-v2/mav2StaticImpl.js.map +1 -1
- package/dist/esm/ma-v2/modules/time-range-module/module.js +3 -2
- package/dist/esm/ma-v2/modules/time-range-module/module.js.map +1 -1
- package/dist/esm/ma-v2/predictAddress.d.ts +22 -6
- package/dist/esm/ma-v2/predictAddress.js +46 -12
- package/dist/esm/ma-v2/predictAddress.js.map +1 -1
- package/dist/esm/ma-v2/utils/account.d.ts +0 -3
- package/dist/esm/ma-v2/utils/account.js +0 -3
- package/dist/esm/ma-v2/utils/account.js.map +1 -1
- package/dist/esm/ma-v2/utils/signature.d.ts +1 -16
- package/dist/esm/ma-v2/utils/signature.js +1 -38
- package/dist/esm/ma-v2/utils/signature.js.map +1 -1
- package/dist/esm/utils.d.ts +24 -11
- package/dist/esm/utils.js +67 -21
- package/dist/esm/utils.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/index.d.ts +2 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/light-account/accounts/account.d.ts +7 -3
- package/dist/types/light-account/accounts/account.d.ts.map +1 -1
- package/dist/types/light-account/accounts/base.d.ts.map +1 -1
- package/dist/types/light-account/accounts/calldataCodec.d.ts.map +1 -1
- package/dist/types/light-account/accounts/multi-owner-account.d.ts +6 -2
- package/dist/types/light-account/accounts/multi-owner-account.d.ts.map +1 -1
- package/dist/types/light-account/lightAccountStaticImpl.d.ts +3 -1
- package/dist/types/light-account/lightAccountStaticImpl.d.ts.map +1 -1
- package/dist/types/light-account/predictAddress.d.ts +40 -2
- package/dist/types/light-account/predictAddress.d.ts.map +1 -1
- package/dist/types/light-account/registry.d.ts +3410 -0
- package/dist/types/light-account/registry.d.ts.map +1 -1
- package/dist/types/logger.d.ts +1 -1
- package/dist/types/logger.d.ts.map +1 -1
- package/dist/types/ma-v1/accounts/multi-owner-account.d.ts +6 -2
- package/dist/types/ma-v1/accounts/multi-owner-account.d.ts.map +1 -1
- package/dist/types/ma-v1/predictAddress.d.ts +20 -1
- package/dist/types/ma-v1/predictAddress.d.ts.map +1 -1
- package/dist/types/ma-v2/accounts/account.d.ts +8 -5
- package/dist/types/ma-v2/accounts/account.d.ts.map +1 -1
- package/dist/types/ma-v2/accounts/base.d.ts +2 -2
- package/dist/types/ma-v2/accounts/base.d.ts.map +1 -1
- package/dist/types/ma-v2/mav2StaticImpl.d.ts +1 -15
- package/dist/types/ma-v2/mav2StaticImpl.d.ts.map +1 -1
- package/dist/types/ma-v2/modules/time-range-module/module.d.ts.map +1 -1
- package/dist/types/ma-v2/predictAddress.d.ts +22 -6
- package/dist/types/ma-v2/predictAddress.d.ts.map +1 -1
- package/dist/types/ma-v2/utils/account.d.ts +0 -3
- package/dist/types/ma-v2/utils/account.d.ts.map +1 -1
- package/dist/types/ma-v2/utils/signature.d.ts +1 -16
- package/dist/types/ma-v2/utils/signature.d.ts.map +1 -1
- package/dist/types/utils.d.ts +24 -11
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +9 -8
- package/src/index.ts +0 -6
- package/src/light-account/accounts/account.ts +30 -16
- package/src/light-account/accounts/base.ts +62 -23
- package/src/light-account/accounts/calldataCodec.ts +3 -2
- package/src/light-account/accounts/multi-owner-account.ts +22 -9
- package/src/light-account/lightAccountStaticImpl.ts +84 -11
- package/src/light-account/predictAddress.ts +124 -3
- package/src/light-account/registry.ts +44 -0
- package/src/logger.ts +2 -2
- package/src/ma-v1/accounts/multi-owner-account.ts +26 -11
- package/src/ma-v1/predictAddress.ts +60 -3
- package/src/ma-v2/accounts/account.ts +39 -52
- package/src/ma-v2/accounts/base.ts +11 -84
- package/src/ma-v2/mav2StaticImpl.ts +1 -52
- package/src/ma-v2/modules/time-range-module/module.ts +3 -2
- package/src/ma-v2/predictAddress.ts +68 -30
- package/src/ma-v2/utils/account.ts +0 -3
- package/src/ma-v2/utils/signature.ts +2 -57
- package/src/utils.ts +111 -27
- package/src/version.ts +1 -1
- package/dist/esm/ma-v2/abis/webAuthnFactoryAbi.d.ts +0 -330
- package/dist/esm/ma-v2/abis/webAuthnFactoryAbi.js +0 -260
- package/dist/esm/ma-v2/abis/webAuthnFactoryAbi.js.map +0 -1
- package/dist/esm/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.d.ts +0 -287
- package/dist/esm/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.js +0 -374
- package/dist/esm/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.js.map +0 -1
- package/dist/esm/ma-v2/modules/webauthn-validation/module.d.ts +0 -11
- package/dist/esm/ma-v2/modules/webauthn-validation/module.js +0 -16
- package/dist/esm/ma-v2/modules/webauthn-validation/module.js.map +0 -1
- package/dist/types/ma-v2/abis/webAuthnFactoryAbi.d.ts +0 -331
- package/dist/types/ma-v2/abis/webAuthnFactoryAbi.d.ts.map +0 -1
- package/dist/types/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.d.ts +0 -288
- package/dist/types/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.d.ts.map +0 -1
- package/dist/types/ma-v2/modules/webauthn-validation/module.d.ts +0 -12
- package/dist/types/ma-v2/modules/webauthn-validation/module.d.ts.map +0 -1
- package/src/ma-v2/abis/webAuthnFactoryAbi.ts +0 -259
- package/src/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.ts +0 -373
- package/src/ma-v2/modules/webauthn-validation/module.ts +0 -28
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Address } from "viem";
|
|
2
|
-
import { entryPoint06Abi, entryPoint07Abi } from "viem/account-abstraction";
|
|
2
|
+
import { entryPoint06Abi, entryPoint07Abi, entryPoint08Abi, entryPoint09Abi } from "viem/account-abstraction";
|
|
3
3
|
import { LightAccountAbi_v1 } from "./abis/LightAccountAbi_v1.js";
|
|
4
4
|
import { LightAccountFactoryAbi_v1 } from "./abis/LightAccountFactoryAbi_v1.js";
|
|
5
5
|
import type { StaticSmartAccountImplementation } from "../types.js";
|
|
@@ -21,4 +21,6 @@ export type MultiOwnerLightAccountFactoryArgs = {
|
|
|
21
21
|
salt: bigint;
|
|
22
22
|
};
|
|
23
23
|
export declare const multiOwnerLightAccountStaticImplV2_0_0: StaticSmartAccountImplementation<false, "0.7", MultiOwnerLightAccountFactoryArgs, typeof entryPoint07Abi, typeof MultiOwnerLightAccountAbi, typeof MultiOwnerLightAccountFactoryAbi>;
|
|
24
|
+
export declare const lightAccountStaticImplV2_1_0: StaticSmartAccountImplementation<false, "0.8", LightAccountFactoryArgs, typeof entryPoint08Abi, typeof LightAccountAbi_v2, typeof LightAccountFactoryAbi_v2>;
|
|
25
|
+
export declare const lightAccountStaticImplV2_2_0: StaticSmartAccountImplementation<false, "0.9", LightAccountFactoryArgs, typeof entryPoint09Abi, typeof LightAccountAbi_v2, typeof LightAccountFactoryAbi_v2>;
|
|
24
26
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { encodeFunctionData } from "viem";
|
|
2
|
-
import { entryPoint06Abi, entryPoint07Abi, entryPoint06Address, entryPoint07Address, } from "viem/account-abstraction";
|
|
2
|
+
import { entryPoint06Abi, entryPoint07Abi, entryPoint06Address, entryPoint07Address, entryPoint08Abi, entryPoint08Address, entryPoint09Abi, entryPoint09Address, } from "viem/account-abstraction";
|
|
3
3
|
import { LightAccountAbi_v1 } from "./abis/LightAccountAbi_v1.js";
|
|
4
4
|
import { LightAccountFactoryAbi_v1 } from "./abis/LightAccountFactoryAbi_v1.js";
|
|
5
5
|
import { predictLightAccountAddress, predictMultiOwnerLightAccountAddress, } from "./predictAddress.js";
|
|
@@ -60,16 +60,12 @@ export const lightAccountStaticImplV1_1_0 = {
|
|
|
60
60
|
});
|
|
61
61
|
},
|
|
62
62
|
};
|
|
63
|
-
|
|
64
|
-
const lightAccountV2Base = {
|
|
63
|
+
export const lightAccountStaticImplV2_0_0 = {
|
|
65
64
|
entryPoint: {
|
|
66
65
|
abi: entryPoint07Abi,
|
|
67
66
|
address: entryPoint07Address,
|
|
68
67
|
version: "0.7",
|
|
69
68
|
},
|
|
70
|
-
};
|
|
71
|
-
export const lightAccountStaticImplV2_0_0 = {
|
|
72
|
-
...lightAccountV2Base,
|
|
73
69
|
accountAbi: LightAccountAbi_v2,
|
|
74
70
|
accountImplementation: lowerAddress("0x8E8e658E22B12ada97B402fF0b044D6A325013C7"),
|
|
75
71
|
factoryAbi: LightAccountFactoryAbi_v2,
|
|
@@ -90,7 +86,11 @@ export const lightAccountStaticImplV2_0_0 = {
|
|
|
90
86
|
},
|
|
91
87
|
};
|
|
92
88
|
export const multiOwnerLightAccountStaticImplV2_0_0 = {
|
|
93
|
-
|
|
89
|
+
entryPoint: {
|
|
90
|
+
abi: entryPoint07Abi,
|
|
91
|
+
address: entryPoint07Address,
|
|
92
|
+
version: "0.7",
|
|
93
|
+
},
|
|
94
94
|
accountAbi: MultiOwnerLightAccountAbi,
|
|
95
95
|
accountImplementation: lowerAddress("0xd2c27F9eE8E4355f71915ffD5568cB3433b6823D"),
|
|
96
96
|
factoryAbi: MultiOwnerLightAccountFactoryAbi,
|
|
@@ -109,4 +109,54 @@ export const multiOwnerLightAccountStaticImplV2_0_0 = {
|
|
|
109
109
|
});
|
|
110
110
|
},
|
|
111
111
|
};
|
|
112
|
+
export const lightAccountStaticImplV2_1_0 = {
|
|
113
|
+
entryPoint: {
|
|
114
|
+
abi: entryPoint08Abi,
|
|
115
|
+
address: entryPoint08Address,
|
|
116
|
+
version: "0.8",
|
|
117
|
+
},
|
|
118
|
+
accountAbi: LightAccountAbi_v2,
|
|
119
|
+
accountImplementation: lowerAddress("0x2c53D0bD33A60db8881c7b049Df6fd762A1f059C"),
|
|
120
|
+
factoryAbi: LightAccountFactoryAbi_v2,
|
|
121
|
+
factoryAddress: lowerAddress("0x000000000000B1c70Df4DC2CcF86372714e14154"),
|
|
122
|
+
getFactoryData: (factoryArgs) => {
|
|
123
|
+
return encodeFunctionData({
|
|
124
|
+
abi: LightAccountFactoryAbi_v2,
|
|
125
|
+
functionName: "createAccount",
|
|
126
|
+
args: [factoryArgs.owner, factoryArgs.salt],
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
predictAccountAddress: (factoryArgs) => {
|
|
130
|
+
return predictLightAccountAddress({
|
|
131
|
+
salt: factoryArgs.salt,
|
|
132
|
+
ownerAddress: factoryArgs.owner,
|
|
133
|
+
version: "v2.1.0",
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
export const lightAccountStaticImplV2_2_0 = {
|
|
138
|
+
entryPoint: {
|
|
139
|
+
abi: entryPoint09Abi,
|
|
140
|
+
address: entryPoint09Address,
|
|
141
|
+
version: "0.9",
|
|
142
|
+
},
|
|
143
|
+
accountAbi: LightAccountAbi_v2,
|
|
144
|
+
accountImplementation: lowerAddress("0x05FF1bF6Ac15d4990Ea77Ae60394629bcB16640d"),
|
|
145
|
+
factoryAbi: LightAccountFactoryAbi_v2,
|
|
146
|
+
factoryAddress: lowerAddress("0x0000000000003805C662f84E42E446C96a446e82"),
|
|
147
|
+
getFactoryData: (factoryArgs) => {
|
|
148
|
+
return encodeFunctionData({
|
|
149
|
+
abi: LightAccountFactoryAbi_v2,
|
|
150
|
+
functionName: "createAccount",
|
|
151
|
+
args: [factoryArgs.owner, factoryArgs.salt],
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
predictAccountAddress: (factoryArgs) => {
|
|
155
|
+
return predictLightAccountAddress({
|
|
156
|
+
salt: factoryArgs.salt,
|
|
157
|
+
ownerAddress: factoryArgs.owner,
|
|
158
|
+
version: "v2.2.0",
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
};
|
|
112
162
|
//# sourceMappingURL=lightAccountStaticImpl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lightAccountStaticImpl.js","sourceRoot":"","sources":["../../../src/light-account/lightAccountStaticImpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAgB,MAAM,MAAM,CAAC;AACxD,OAAO,EACL,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAGhF,OAAO,EACL,0BAA0B,EAC1B,oCAAoC,GACrC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAE,gCAAgC,EAAE,MAAM,4CAA4C,CAAC;AAC9F,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAiB/C,MAAM,kBAAkB,GAAG;IACzB,UAAU,EAAE;QACV,GAAG,EAAE,eAAe;QACpB,OAAO,EAAE,mBAAmB;QAC5B,OAAO,EAAE,KAAK;KACf;IACD,UAAU,EAAE,kBAAkB;IAC9B,UAAU,EAAE,yBAAyB;IACrC,cAAc,EAAE,CAAC,WAAoC,EAAE,EAAE;QACvD,OAAO,kBAAkB,CAAC;YACxB,GAAG,EAAE,yBAAyB;YAC9B,YAAY,EAAE,eAAe;YAC7B,IAAI,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC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,cAAc,EAAE,WAAW,CAAC,MAAM;SACnC,CAAC,CAAC;IACL,CAAC;CACF,CAAC","sourcesContent":["import { encodeFunctionData, type Address } from \"viem\";\nimport {\n entryPoint06Abi,\n entryPoint07Abi,\n entryPoint06Address,\n entryPoint07Address,\n} from \"viem/account-abstraction\";\nimport { LightAccountAbi_v1 } from \"./abis/LightAccountAbi_v1.js\";\nimport { LightAccountFactoryAbi_v1 } from \"./abis/LightAccountFactoryAbi_v1.js\";\n\nimport type { StaticSmartAccountImplementation } from \"../types.js\";\nimport {\n predictLightAccountAddress,\n predictMultiOwnerLightAccountAddress,\n} from \"./predictAddress.js\";\nimport { LightAccountAbi_v2 } from \"./abis/LightAccountAbi_v2.js\";\nimport { LightAccountFactoryAbi_v2 } from \"./abis/LightAccountFactoryAbi_v2.js\";\nimport { MultiOwnerLightAccountAbi } from \"./abis/MultiOwnerLightAccountAbi.js\";\nimport { MultiOwnerLightAccountFactoryAbi } from \"./abis/MultiOwnerLightAccountFactoryAbi.js\";\nimport { lowerAddress } from \"@alchemy/common\";\n\nexport type LightAccountFactoryArgs = {\n owner: Address;\n salt: bigint;\n};\n\n// Shared type and fields for all light account v1 implementations\ntype LightAccountV1StaticImpl = StaticSmartAccountImplementation<\n false,\n \"0.6\",\n LightAccountFactoryArgs,\n typeof entryPoint06Abi,\n typeof LightAccountAbi_v1,\n typeof LightAccountFactoryAbi_v1\n>;\n\nconst lightAccountV1Base = {\n entryPoint: {\n abi: entryPoint06Abi,\n address: entryPoint06Address,\n version: \"0.6\",\n },\n accountAbi: LightAccountAbi_v1,\n factoryAbi: LightAccountFactoryAbi_v1,\n getFactoryData: (factoryArgs: LightAccountFactoryArgs) => {\n return encodeFunctionData({\n abi: LightAccountFactoryAbi_v1,\n functionName: \"createAccount\",\n args: [factoryArgs.owner, factoryArgs.salt],\n });\n },\n} satisfies Partial<LightAccountV1StaticImpl>;\n\nexport const lightAccountStaticImplV1_0_1: LightAccountV1StaticImpl = {\n ...lightAccountV1Base,\n factoryAddress: lowerAddress(\"0x000000893A26168158fbeaDD9335Be5bC96592E2\"),\n accountImplementation: lowerAddress(\n \"0xc1b2fc4197c9187853243e6e4eb5a4af8879a1c0\",\n ),\n predictAccountAddress: (factoryArgs) => {\n return predictLightAccountAddress({\n salt: factoryArgs.salt,\n ownerAddress: factoryArgs.owner,\n version: \"v1.0.1\",\n });\n },\n};\n\nexport const lightAccountStaticImplV1_0_2: LightAccountV1StaticImpl = {\n ...lightAccountV1Base,\n accountImplementation: lowerAddress(\n \"0x5467b1947F47d0646704EB801E075e72aeAe8113\",\n ),\n factoryAddress: lowerAddress(\"0x00000055C0b4fA41dde26A74435ff03692292FBD\"),\n predictAccountAddress: (factoryArgs) => {\n return predictLightAccountAddress({\n salt: factoryArgs.salt,\n ownerAddress: factoryArgs.owner,\n version: \"v1.0.2\",\n });\n },\n};\n\nexport const lightAccountStaticImplV1_1_0: LightAccountV1StaticImpl = {\n ...lightAccountV1Base,\n accountImplementation: lowerAddress(\n \"0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba\",\n ),\n factoryAddress: lowerAddress(\"0x00004EC70002a32400f8ae005A26081065620D20\"),\n predictAccountAddress: (factoryArgs) => {\n return predictLightAccountAddress({\n salt: factoryArgs.salt,\n ownerAddress: factoryArgs.owner,\n version: \"v1.1.0\",\n });\n },\n};\n\n// Shared type and fields for all light account v2 implementations\nconst lightAccountV2Base = {\n entryPoint: {\n abi: entryPoint07Abi,\n address: entryPoint07Address,\n version: \"0.7\",\n },\n} satisfies Partial<StaticSmartAccountImplementation<false, \"0.7\">>;\n\nexport const lightAccountStaticImplV2_0_0: StaticSmartAccountImplementation<\n false,\n \"0.7\",\n LightAccountFactoryArgs,\n typeof entryPoint07Abi,\n typeof LightAccountAbi_v2,\n typeof LightAccountFactoryAbi_v2\n> = {\n ...lightAccountV2Base,\n accountAbi: LightAccountAbi_v2,\n accountImplementation: lowerAddress(\n \"0x8E8e658E22B12ada97B402fF0b044D6A325013C7\",\n ),\n factoryAbi: LightAccountFactoryAbi_v2,\n factoryAddress: lowerAddress(\"0x0000000000400CdFef5E2714E63d8040b700BC24\"),\n getFactoryData: (factoryArgs) => {\n return encodeFunctionData({\n abi: LightAccountFactoryAbi_v2,\n functionName: \"createAccount\",\n args: [factoryArgs.owner, factoryArgs.salt],\n });\n },\n predictAccountAddress: (factoryArgs) => {\n return predictLightAccountAddress({\n salt: factoryArgs.salt,\n ownerAddress: factoryArgs.owner,\n version: \"v2.0.0\",\n });\n },\n};\n\nexport type MultiOwnerLightAccountFactoryArgs = {\n owners: Address[];\n salt: bigint;\n};\n\nexport const multiOwnerLightAccountStaticImplV2_0_0: StaticSmartAccountImplementation<\n false,\n \"0.7\",\n MultiOwnerLightAccountFactoryArgs,\n typeof entryPoint07Abi,\n typeof MultiOwnerLightAccountAbi,\n typeof MultiOwnerLightAccountFactoryAbi\n> = {\n ...lightAccountV2Base,\n accountAbi: MultiOwnerLightAccountAbi,\n accountImplementation: lowerAddress(\n \"0xd2c27F9eE8E4355f71915ffD5568cB3433b6823D\",\n ),\n factoryAbi: MultiOwnerLightAccountFactoryAbi,\n factoryAddress: lowerAddress(\"0x000000000019d2Ee9F2729A65AfE20bb0020AefC\"),\n getFactoryData: (factoryArgs) => {\n return encodeFunctionData({\n abi: MultiOwnerLightAccountFactoryAbi,\n functionName: \"createAccount\",\n args: [factoryArgs.owners, factoryArgs.salt],\n });\n },\n predictAccountAddress: (factoryArgs) => {\n return predictMultiOwnerLightAccountAddress({\n salt: factoryArgs.salt,\n ownerAddresses: factoryArgs.owners,\n });\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"lightAccountStaticImpl.js","sourceRoot":"","sources":["../../../src/light-account/lightAccountStaticImpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAgB,MAAM,MAAM,CAAC;AACxD,OAAO,EACL,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,eAAe,E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,EAAE,EAAE;QAC9B,OAAO,kBAAkB,CAAC;YACxB,GAAG,EAAE,yBAAyB;YAC9B,YAAY,EAAE,eAAe;YAC7B,IAAI,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC;SAC5C,CAAC,CAAC;IACL,CAAC;IACD,qBAAqB,EAAE,CAAC,WAAW,EAAE,EAAE;QACrC,OAAO,0BAA0B,CAAC;YAChC,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,YAAY,EAAE,WAAW,CAAC,KAAK;YAC/B,OAAO,EAAE,QAAQ;SAClB,CAAC,CAAC;IACL,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAOrC;IACF,UAAU,EAAE;QACV,GAAG,EAAE,eAAe;QACpB,OAAO,EAAE,mBAAmB;QAC5B,OAAO,EAAE,KAAK;KACf;IACD,UAAU,EAAE,kBAAkB;IAC9B,qBAAqB,EAAE,YAAY,CACjC,4CAA4C,CAC7C;IACD,UAAU,EAAE,yBAAyB;IACrC,cAAc,EAAE,YAAY,CAAC,4CAA4C,CAAC;IAC1E,cAAc,EAAE,CAAC,WAAW,EAAE,EAAE;QAC9B,OAAO,kBAAkB,CAAC;YACxB,GAAG,EAAE,yBAAyB;YAC9B,YAAY,EAAE,eAAe;YAC7B,IAAI,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC;SAC5C,CAAC,CAAC;IACL,CAAC;IACD,qBAAqB,EAAE,CAAC,WAAW,EAAE,EAAE;QACrC,OAAO,0BAA0B,CAAC;YAChC,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,YAAY,EAAE,WAAW,CAAC,KAAK;YAC/B,OAAO,EAAE,QAAQ;SAClB,CAAC,CAAC;IACL,CAAC;CACF,CAAC","sourcesContent":["import { encodeFunctionData, type Address } from \"viem\";\nimport {\n entryPoint06Abi,\n entryPoint07Abi,\n entryPoint06Address,\n entryPoint07Address,\n entryPoint08Abi,\n entryPoint08Address,\n entryPoint09Abi,\n entryPoint09Address,\n} from \"viem/account-abstraction\";\nimport { LightAccountAbi_v1 } from \"./abis/LightAccountAbi_v1.js\";\nimport { LightAccountFactoryAbi_v1 } from \"./abis/LightAccountFactoryAbi_v1.js\";\n\nimport type { StaticSmartAccountImplementation } from \"../types.js\";\nimport {\n predictLightAccountAddress,\n predictMultiOwnerLightAccountAddress,\n} from \"./predictAddress.js\";\nimport { LightAccountAbi_v2 } from \"./abis/LightAccountAbi_v2.js\";\nimport { LightAccountFactoryAbi_v2 } from \"./abis/LightAccountFactoryAbi_v2.js\";\nimport { MultiOwnerLightAccountAbi } from \"./abis/MultiOwnerLightAccountAbi.js\";\nimport { MultiOwnerLightAccountFactoryAbi } from \"./abis/MultiOwnerLightAccountFactoryAbi.js\";\nimport { lowerAddress } from \"@alchemy/common\";\n\nexport type LightAccountFactoryArgs = {\n owner: Address;\n salt: bigint;\n};\n\n// Shared type and fields for all light account v1 implementations\ntype LightAccountV1StaticImpl = StaticSmartAccountImplementation<\n false,\n \"0.6\",\n LightAccountFactoryArgs,\n typeof entryPoint06Abi,\n typeof LightAccountAbi_v1,\n typeof LightAccountFactoryAbi_v1\n>;\n\nconst lightAccountV1Base = {\n entryPoint: {\n abi: entryPoint06Abi,\n address: entryPoint06Address,\n version: \"0.6\",\n },\n accountAbi: LightAccountAbi_v1,\n factoryAbi: LightAccountFactoryAbi_v1,\n getFactoryData: (factoryArgs: LightAccountFactoryArgs) => {\n return encodeFunctionData({\n abi: LightAccountFactoryAbi_v1,\n functionName: \"createAccount\",\n args: [factoryArgs.owner, factoryArgs.salt],\n });\n },\n} satisfies Partial<LightAccountV1StaticImpl>;\n\nexport const lightAccountStaticImplV1_0_1: LightAccountV1StaticImpl = {\n ...lightAccountV1Base,\n factoryAddress: lowerAddress(\"0x000000893A26168158fbeaDD9335Be5bC96592E2\"),\n accountImplementation: lowerAddress(\n \"0xc1b2fc4197c9187853243e6e4eb5a4af8879a1c0\",\n ),\n predictAccountAddress: (factoryArgs) => {\n return predictLightAccountAddress({\n salt: factoryArgs.salt,\n ownerAddress: factoryArgs.owner,\n version: \"v1.0.1\",\n });\n },\n};\n\nexport const lightAccountStaticImplV1_0_2: LightAccountV1StaticImpl = {\n ...lightAccountV1Base,\n accountImplementation: lowerAddress(\n \"0x5467b1947F47d0646704EB801E075e72aeAe8113\",\n ),\n factoryAddress: lowerAddress(\"0x00000055C0b4fA41dde26A74435ff03692292FBD\"),\n predictAccountAddress: (factoryArgs) => {\n return predictLightAccountAddress({\n salt: factoryArgs.salt,\n ownerAddress: factoryArgs.owner,\n version: \"v1.0.2\",\n });\n },\n};\n\nexport const lightAccountStaticImplV1_1_0: LightAccountV1StaticImpl = {\n ...lightAccountV1Base,\n accountImplementation: lowerAddress(\n \"0xae8c656ad28F2B59a196AB61815C16A0AE1c3cba\",\n ),\n factoryAddress: lowerAddress(\"0x00004EC70002a32400f8ae005A26081065620D20\"),\n predictAccountAddress: (factoryArgs) => {\n return predictLightAccountAddress({\n salt: factoryArgs.salt,\n ownerAddress: factoryArgs.owner,\n version: \"v1.1.0\",\n });\n },\n};\n\nexport const lightAccountStaticImplV2_0_0: StaticSmartAccountImplementation<\n false,\n \"0.7\",\n LightAccountFactoryArgs,\n typeof entryPoint07Abi,\n typeof LightAccountAbi_v2,\n typeof LightAccountFactoryAbi_v2\n> = {\n entryPoint: {\n abi: entryPoint07Abi,\n address: entryPoint07Address,\n version: \"0.7\",\n },\n accountAbi: LightAccountAbi_v2,\n accountImplementation: lowerAddress(\n \"0x8E8e658E22B12ada97B402fF0b044D6A325013C7\",\n ),\n factoryAbi: LightAccountFactoryAbi_v2,\n factoryAddress: lowerAddress(\"0x0000000000400CdFef5E2714E63d8040b700BC24\"),\n getFactoryData: (factoryArgs) => {\n return encodeFunctionData({\n abi: LightAccountFactoryAbi_v2,\n functionName: \"createAccount\",\n args: [factoryArgs.owner, factoryArgs.salt],\n });\n },\n predictAccountAddress: (factoryArgs) => {\n return predictLightAccountAddress({\n salt: factoryArgs.salt,\n ownerAddress: factoryArgs.owner,\n version: \"v2.0.0\",\n });\n },\n};\n\nexport type MultiOwnerLightAccountFactoryArgs = {\n owners: Address[];\n salt: bigint;\n};\n\nexport const multiOwnerLightAccountStaticImplV2_0_0: StaticSmartAccountImplementation<\n false,\n \"0.7\",\n MultiOwnerLightAccountFactoryArgs,\n typeof entryPoint07Abi,\n typeof MultiOwnerLightAccountAbi,\n typeof MultiOwnerLightAccountFactoryAbi\n> = {\n entryPoint: {\n abi: entryPoint07Abi,\n address: entryPoint07Address,\n version: \"0.7\",\n },\n accountAbi: MultiOwnerLightAccountAbi,\n accountImplementation: lowerAddress(\n \"0xd2c27F9eE8E4355f71915ffD5568cB3433b6823D\",\n ),\n factoryAbi: MultiOwnerLightAccountFactoryAbi,\n factoryAddress: lowerAddress(\"0x000000000019d2Ee9F2729A65AfE20bb0020AefC\"),\n getFactoryData: (factoryArgs) => {\n return encodeFunctionData({\n abi: MultiOwnerLightAccountFactoryAbi,\n functionName: \"createAccount\",\n args: [factoryArgs.owners, factoryArgs.salt],\n });\n },\n predictAccountAddress: (factoryArgs) => {\n return predictMultiOwnerLightAccountAddress({\n salt: factoryArgs.salt,\n ownerAddresses: factoryArgs.owners,\n });\n },\n};\n\nexport const lightAccountStaticImplV2_1_0: StaticSmartAccountImplementation<\n false,\n \"0.8\",\n LightAccountFactoryArgs,\n typeof entryPoint08Abi,\n typeof LightAccountAbi_v2,\n typeof LightAccountFactoryAbi_v2\n> = {\n entryPoint: {\n abi: entryPoint08Abi,\n address: entryPoint08Address,\n version: \"0.8\",\n },\n accountAbi: LightAccountAbi_v2,\n accountImplementation: lowerAddress(\n \"0x2c53D0bD33A60db8881c7b049Df6fd762A1f059C\",\n ),\n factoryAbi: LightAccountFactoryAbi_v2,\n factoryAddress: lowerAddress(\"0x000000000000B1c70Df4DC2CcF86372714e14154\"),\n getFactoryData: (factoryArgs) => {\n return encodeFunctionData({\n abi: LightAccountFactoryAbi_v2,\n functionName: \"createAccount\",\n args: [factoryArgs.owner, factoryArgs.salt],\n });\n },\n predictAccountAddress: (factoryArgs) => {\n return predictLightAccountAddress({\n salt: factoryArgs.salt,\n ownerAddress: factoryArgs.owner,\n version: \"v2.1.0\",\n });\n },\n};\n\nexport const lightAccountStaticImplV2_2_0: StaticSmartAccountImplementation<\n false,\n \"0.9\",\n LightAccountFactoryArgs,\n typeof entryPoint09Abi,\n typeof LightAccountAbi_v2,\n typeof LightAccountFactoryAbi_v2\n> = {\n entryPoint: {\n abi: entryPoint09Abi,\n address: entryPoint09Address,\n version: \"0.9\",\n },\n accountAbi: LightAccountAbi_v2,\n accountImplementation: lowerAddress(\n \"0x05FF1bF6Ac15d4990Ea77Ae60394629bcB16640d\",\n ),\n factoryAbi: LightAccountFactoryAbi_v2,\n factoryAddress: lowerAddress(\"0x0000000000003805C662f84E42E446C96a446e82\"),\n getFactoryData: (factoryArgs) => {\n return encodeFunctionData({\n abi: LightAccountFactoryAbi_v2,\n functionName: \"createAccount\",\n args: [factoryArgs.owner, factoryArgs.salt],\n });\n },\n predictAccountAddress: (factoryArgs) => {\n return predictLightAccountAddress({\n salt: factoryArgs.salt,\n ownerAddress: factoryArgs.owner,\n version: \"v2.2.0\",\n });\n },\n};\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type Address } from "viem";
|
|
2
|
-
import {
|
|
1
|
+
import { type Address, type Client, type Hex } from "viem";
|
|
2
|
+
import type { EntryPointVersion } from "viem/account-abstraction";
|
|
3
|
+
import { AccountVersionRegistry, type LightAccountVersion } from "./registry.js";
|
|
3
4
|
export type PredictLightAccountAddressParams = {
|
|
4
5
|
version: keyof typeof AccountVersionRegistry.LightAccount;
|
|
5
6
|
salt: bigint;
|
|
@@ -33,3 +34,40 @@ export type PredictMultiOwnerLightAccountAddressParams = {
|
|
|
33
34
|
* @returns {Address} Predicted account address for the multi-owner light account.
|
|
34
35
|
*/
|
|
35
36
|
export declare function predictMultiOwnerLightAccountAddress({ salt, ownerAddresses, factoryAddress, }: PredictMultiOwnerLightAccountAddressParams): Address;
|
|
37
|
+
export type GetLightAccountAddressFromFactoryDataParams = {
|
|
38
|
+
client: Client;
|
|
39
|
+
factoryAddress: Address;
|
|
40
|
+
factoryData: Hex;
|
|
41
|
+
entryPoint: {
|
|
42
|
+
version: EntryPointVersion;
|
|
43
|
+
address: Address;
|
|
44
|
+
};
|
|
45
|
+
version: LightAccountVersion<"LightAccount">;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Gets the light account address from factory data.
|
|
49
|
+
* If the factory is a known default, decodes the args and predicts without RPC.
|
|
50
|
+
* Otherwise falls back to calling the entry point's getSenderAddress.
|
|
51
|
+
*
|
|
52
|
+
* @param {GetLightAccountAddressFromFactoryDataParams} params - The parameters
|
|
53
|
+
* @returns {Promise<Address>} The account address
|
|
54
|
+
*/
|
|
55
|
+
export declare function getLightAccountAddressFromFactoryData({ client, factoryAddress, factoryData, entryPoint, version, }: GetLightAccountAddressFromFactoryDataParams): Promise<Address>;
|
|
56
|
+
export type GetMultiOwnerLightAccountAddressFromFactoryDataParams = {
|
|
57
|
+
client: Client;
|
|
58
|
+
factoryAddress: Address;
|
|
59
|
+
factoryData: Hex;
|
|
60
|
+
entryPoint: {
|
|
61
|
+
version: EntryPointVersion;
|
|
62
|
+
address: Address;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Gets the multi-owner light account address from factory data.
|
|
67
|
+
* If the factory is a known default, decodes the args and predicts without RPC.
|
|
68
|
+
* Otherwise falls back to calling the entry point's getSenderAddress.
|
|
69
|
+
*
|
|
70
|
+
* @param {GetMultiOwnerLightAccountAddressFromFactoryDataParams} params - The parameters
|
|
71
|
+
* @returns {Promise<Address>} The account address
|
|
72
|
+
*/
|
|
73
|
+
export declare function getMultiOwnerLightAccountAddressFromFactoryData({ client, factoryAddress, factoryData, entryPoint, }: GetMultiOwnerLightAccountAddressFromFactoryDataParams): Promise<Address>;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { concatHex, encodeAbiParameters, encodeDeployData, encodeFunctionData, getContractAddress, keccak256, toHex, } from "viem";
|
|
1
|
+
import { concatHex, decodeFunctionData, encodeAbiParameters, encodeDeployData, encodeFunctionData, getContractAddress, isAddressEqual, keccak256, toHex, } from "viem";
|
|
2
2
|
import { LightAccountAbi_v1 } from "./abis/LightAccountAbi_v1.js";
|
|
3
|
+
import { LightAccountFactoryAbi_v1 } from "./abis/LightAccountFactoryAbi_v1.js";
|
|
4
|
+
import { LightAccountFactoryAbi_v2 } from "./abis/LightAccountFactoryAbi_v2.js";
|
|
5
|
+
import { MultiOwnerLightAccountFactoryAbi } from "./abis/MultiOwnerLightAccountFactoryAbi.js";
|
|
3
6
|
import { OZ_ERC1967Proxy_ConstructorAbi } from "./abis/OZ_ERC1967Proxy.js";
|
|
4
|
-
import { AccountVersionRegistry } from "./registry.js";
|
|
7
|
+
import { AccountVersionRegistry, } from "./registry.js";
|
|
5
8
|
import { BaseError, lowerAddress } from "@alchemy/common";
|
|
9
|
+
import { getSenderFromFactoryData } from "../utils.js";
|
|
6
10
|
/**
|
|
7
11
|
* Predicts the address of a light account based on provided parameters such as factory address, salt, owner address, and version.
|
|
8
12
|
*
|
|
@@ -46,7 +50,9 @@ export function predictLightAccountAddress({ factoryAddress, salt, ownerAddress,
|
|
|
46
50
|
}),
|
|
47
51
|
});
|
|
48
52
|
case "v2.0.0":
|
|
49
|
-
|
|
53
|
+
case "v2.1.0":
|
|
54
|
+
case "v2.2.0":
|
|
55
|
+
// Logic ported from LA factory v2
|
|
50
56
|
const combinedSalt = keccak256(encodeAbiParameters([{ type: "address" }, { type: "uint256" }], [ownerAddress, salt]));
|
|
51
57
|
const initCode = getLAv2ProxyBytecode(implementationAddress);
|
|
52
58
|
return getContractAddress({
|
|
@@ -110,4 +116,78 @@ function getLAv2ProxyBytecode(implementationAddress) {
|
|
|
110
116
|
function assertNeverLightAccountVersion(version) {
|
|
111
117
|
throw new BaseError(`Unknown light account version: ${version}`);
|
|
112
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Gets the light account address from factory data.
|
|
121
|
+
* If the factory is a known default, decodes the args and predicts without RPC.
|
|
122
|
+
* Otherwise falls back to calling the entry point's getSenderAddress.
|
|
123
|
+
*
|
|
124
|
+
* @param {GetLightAccountAddressFromFactoryDataParams} params - The parameters
|
|
125
|
+
* @returns {Promise<Address>} The account address
|
|
126
|
+
*/
|
|
127
|
+
export async function getLightAccountAddressFromFactoryData({ client, factoryAddress, factoryData, entryPoint, version, }) {
|
|
128
|
+
const defaultFactory = AccountVersionRegistry["LightAccount"][version].factoryAddress;
|
|
129
|
+
if (isAddressEqual(factoryAddress, defaultFactory)) {
|
|
130
|
+
const factoryAbi = version === "v2.0.0"
|
|
131
|
+
? LightAccountFactoryAbi_v2
|
|
132
|
+
: LightAccountFactoryAbi_v1;
|
|
133
|
+
try {
|
|
134
|
+
const decoded = decodeFunctionData({
|
|
135
|
+
abi: factoryAbi,
|
|
136
|
+
data: factoryData,
|
|
137
|
+
});
|
|
138
|
+
if (decoded.functionName === "createAccount") {
|
|
139
|
+
const [decodedOwner, decodedSalt] = decoded.args;
|
|
140
|
+
return predictLightAccountAddress({
|
|
141
|
+
factoryAddress,
|
|
142
|
+
salt: decodedSalt,
|
|
143
|
+
ownerAddress: decodedOwner,
|
|
144
|
+
version,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
// Decode failed, fall through to RPC
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return getSenderFromFactoryData(client, {
|
|
153
|
+
factory: factoryAddress,
|
|
154
|
+
factoryData,
|
|
155
|
+
entryPoint,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Gets the multi-owner light account address from factory data.
|
|
160
|
+
* If the factory is a known default, decodes the args and predicts without RPC.
|
|
161
|
+
* Otherwise falls back to calling the entry point's getSenderAddress.
|
|
162
|
+
*
|
|
163
|
+
* @param {GetMultiOwnerLightAccountAddressFromFactoryDataParams} params - The parameters
|
|
164
|
+
* @returns {Promise<Address>} The account address
|
|
165
|
+
*/
|
|
166
|
+
export async function getMultiOwnerLightAccountAddressFromFactoryData({ client, factoryAddress, factoryData, entryPoint, }) {
|
|
167
|
+
const defaultFactory = AccountVersionRegistry["MultiOwnerLightAccount"]["v2.0.0"].factoryAddress;
|
|
168
|
+
if (isAddressEqual(factoryAddress, defaultFactory)) {
|
|
169
|
+
try {
|
|
170
|
+
const decoded = decodeFunctionData({
|
|
171
|
+
abi: MultiOwnerLightAccountFactoryAbi,
|
|
172
|
+
data: factoryData,
|
|
173
|
+
});
|
|
174
|
+
if (decoded.functionName === "createAccount") {
|
|
175
|
+
const [decodedOwners, decodedSalt] = decoded.args;
|
|
176
|
+
return predictMultiOwnerLightAccountAddress({
|
|
177
|
+
factoryAddress,
|
|
178
|
+
salt: decodedSalt,
|
|
179
|
+
ownerAddresses: [...decodedOwners],
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
// Decode failed, fall through to RPC
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return getSenderFromFactoryData(client, {
|
|
188
|
+
factory: factoryAddress,
|
|
189
|
+
factoryData,
|
|
190
|
+
entryPoint,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
113
193
|
//# sourceMappingURL=predictAddress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predictAddress.js","sourceRoot":"","sources":["../../../src/light-account/predictAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,SAAS,EACT,KAAK,GAGN,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,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5C,CAAC,cAAc,EAAE,IAAI,CAAC,CACvB,CACF,CAAC;IAEF,MAAM,QAAQ,GAAQ,oBAAoB,CAAC,qBAAqB,CAAC,CAAC;IAElE,OAAO,kBAAkB,CAAC;QACxB,IAAI,EAAE,eAAe;QACrB,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE,QAAQ;KACnB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,mBAAmB,GACvB,4lEAA0mE,CAAC;AAE7mE,+HAA+H;AAE/H,SAAS,oBAAoB,CAAC,qBAA8B;IAC1D,OAAO,SAAS,CAAC;QACf,sBAAsB;QACtB,qBAAqB;QACrB,wIAAwI;KACzI,CAAC,CAAC;AACL,CAAC;AAED,SAAS,8BAA8B,CAAC,OAAc;IACpD,MAAM,IAAI,SAAS,CAAC,kCAAkC,OAAO,EAAE,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import {\n concatHex,\n encodeAbiParameters,\n encodeDeployData,\n encodeFunctionData,\n getContractAddress,\n keccak256,\n toHex,\n type Address,\n type Hex,\n} from \"viem\";\nimport { LightAccountAbi_v1 } from \"./abis/LightAccountAbi_v1.js\";\nimport { OZ_ERC1967Proxy_ConstructorAbi } from \"./abis/OZ_ERC1967Proxy.js\";\nimport { AccountVersionRegistry } from \"./registry.js\";\nimport { BaseError, lowerAddress } from \"@alchemy/common\";\n\nexport type PredictLightAccountAddressParams = {\n version: keyof typeof AccountVersionRegistry.LightAccount;\n salt: bigint;\n ownerAddress: Address;\n factoryAddress?: Address;\n};\n\n/**\n * Predicts the address of a light account based on provided parameters such as factory address, salt, owner address, and version.\n *\n * @param {PredictLightAccountAddressParams} params The parameters required to predict the light account address, including factory address, salt, owner address, and version\n * @returns {Address} The predicted address of the light account calculated based on the provided parameters\n */\nexport function predictLightAccountAddress({\n factoryAddress,\n salt,\n ownerAddress,\n version,\n}: PredictLightAccountAddressParams): Address {\n const factoryAddress_ =\n factoryAddress != null\n ? lowerAddress(factoryAddress)\n : AccountVersionRegistry.LightAccount[version].factoryAddress;\n\n const implementationAddress =\n // If we aren't using the default factory address, we compute the implementation address from the factory's `create` deployment.\n // This is accurate for both LA v1 and v2 factories. If we are using the default factory address, we use the implementation address from the registry.\n factoryAddress_ !==\n AccountVersionRegistry.LightAccount[version].factoryAddress\n ? getContractAddress({\n from: factoryAddress_,\n nonce: 1n,\n })\n : AccountVersionRegistry.LightAccount[version].accountImplementation;\n\n switch (version) {\n case \"v1.0.1\":\n case \"v1.0.2\":\n case \"v1.1.0\":\n // Same proxy initcode for all LA v1 factories\n return getContractAddress({\n from: factoryAddress_,\n opcode: \"CREATE2\",\n salt: toHex(salt, { size: 32 }),\n bytecode: encodeDeployData({\n bytecode: LAv1_PROXY_BYTECODE,\n abi: OZ_ERC1967Proxy_ConstructorAbi,\n args: [\n implementationAddress,\n encodeFunctionData({\n abi: LightAccountAbi_v1,\n functionName: \"initialize\",\n args: [ownerAddress],\n }),\n ],\n }),\n });\n\n case \"v2.0.0\":\n // Logic ported from LA factory v2.0.0\n const combinedSalt = keccak256(\n encodeAbiParameters(\n [{ type: \"address\" }, { type: \"uint256\" }],\n [ownerAddress, salt],\n ),\n );\n\n const initCode = getLAv2ProxyBytecode(implementationAddress);\n\n return getContractAddress({\n from: factoryAddress_,\n opcode: \"CREATE2\",\n salt: combinedSalt,\n bytecode: initCode,\n });\n\n default:\n assertNeverLightAccountVersion(version);\n }\n}\n\nexport type PredictMultiOwnerLightAccountAddressParams = {\n salt: bigint;\n ownerAddresses: Address[];\n factoryAddress?: Address;\n // There's just one version of the MultiOwnerLightAccount for now, so skip requiring the version as a parameter.\n};\n\n// Note: assumes the owner addresses are already deduped, sorted in ascending order, and have the signer address included.\n/**\n * Predicts the address of a **Multi-Owner Light Account** given the factory, salt\n * and the set of owner addresses.\n *\n * Internally replicates the CREATE2 calculation performed by the factory so\n * you can obtain the counter-factual account address before deployment (useful\n * for funding or displaying to users).\n *\n * @param {PredictMultiOwnerLightAccountAddressParams} params Object containing:\n * – `factoryAddress` Factory contract that will deploy the account.\n * – `salt` Arbitrary salt used when calling the factory.\n * – `ownerAddresses` Array of owner EOAs (must be deduped & sorted).\n * @returns {Address} Predicted account address for the multi-owner light account.\n */\nexport function predictMultiOwnerLightAccountAddress({\n salt,\n ownerAddresses,\n factoryAddress,\n}: PredictMultiOwnerLightAccountAddressParams): Address {\n const factoryAddress_ =\n factoryAddress != null\n ? lowerAddress(factoryAddress)\n : AccountVersionRegistry.MultiOwnerLightAccount[\"v2.0.0\"].factoryAddress;\n\n const implementationAddress =\n // If we aren't using the default factory address, we compute the implementation address from the factory's `create` deployment.\n // This is accurate for both LA v1 and v2 factories. If we are using the default factory address, we use the implementation address from the registry.\n factoryAddress_ !==\n AccountVersionRegistry.MultiOwnerLightAccount[\"v2.0.0\"].factoryAddress\n ? getContractAddress({\n from: factoryAddress_,\n nonce: 1n,\n })\n : AccountVersionRegistry.MultiOwnerLightAccount[\"v2.0.0\"]\n .accountImplementation;\n\n const combinedSalt = keccak256(\n encodeAbiParameters(\n [{ type: \"address[]\" }, { type: \"uint256\" }],\n [ownerAddresses, salt],\n ),\n );\n\n const initCode: Hex = getLAv2ProxyBytecode(implementationAddress);\n\n return getContractAddress({\n from: factoryAddress_,\n opcode: \"CREATE2\",\n salt: combinedSalt,\n bytecode: initCode,\n });\n}\n\nconst LAv1_PROXY_BYTECODE =\n \"0x60406080815261042c908138038061001681610218565b93843982019181818403126102135780516001600160a01b038116808203610213576020838101516001600160401b0394919391858211610213570186601f820112156102135780519061007161006c83610253565b610218565b918083528583019886828401011161021357888661008f930161026e565b813b156101b9577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b031916841790556000927fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8480a28051158015906101b2575b61010b575b855160e790816103458239f35b855194606086019081118682101761019e578697849283926101889952602788527f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c87890152660819985a5b195960ca1b8a8901525190845af4913d15610194573d9061017a61006c83610253565b91825281943d92013e610291565b508038808080806100fe565b5060609250610291565b634e487b7160e01b84526041600452602484fd5b50826100f9565b855162461bcd60e51b815260048101859052602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608490fd5b600080fd5b6040519190601f01601f191682016001600160401b0381118382101761023d57604052565b634e487b7160e01b600052604160045260246000fd5b6001600160401b03811161023d57601f01601f191660200190565b60005b8381106102815750506000910152565b8181015183820152602001610271565b919290156102f357508151156102a5575090565b3b156102ae5790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156103065750805190602001fd5b6044604051809262461bcd60e51b825260206004830152610336815180928160248601526020868601910161026e565b601f01601f19168101030190fdfe60806040523615605f5773ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc54166000808092368280378136915af43d82803e15605b573d90f35b3d90fd5b73ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc54166000808092368280378136915af43d82803e15605b573d90f3fea26469706673582212205da2750cd2b0cadfd354d8a1ca4752ed7f22214c8069d852f7dc6b8e9e5ee66964736f6c63430008150033\" satisfies Hex;\n\n// Bytecode from https://github.com/Vectorized/solady/blob/c6e5238e5f3b621789c59e1a443f43b6606394b2/src/utils/LibClone.sol#L721\n\nfunction getLAv2ProxyBytecode(implementationAddress: Address): Hex {\n return concatHex([\n \"0x603d3d8160223d3973\",\n implementationAddress,\n \"0x60095155f3363d3d373d3d363d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc545af43d6000803e6038573d6000fd5b3d6000f3\",\n ]);\n}\n\nfunction assertNeverLightAccountVersion(version: never): never {\n throw new BaseError(`Unknown light account version: ${version}`);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"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AK,eAAe,EAAE,CAAC;gBAC7C,MAAM,CAAC,aAAa,EAAE,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;gBAClD,OAAO,oCAAoC,CAAC;oBAC1C,cAAc;oBACd,IAAI,EAAE,WAAW;oBACjB,cAAc,EAAE,CAAC,GAAG,aAAa,CAAC;iBACnC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,qCAAqC;QACvC,CAAC;IACH,CAAC;IACD,OAAO,wBAAwB,CAAC,MAAM,EAAE;QACtC,OAAO,EAAE,cAAc;QACvB,WAAW;QACX,UAAU;KACX,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n concatHex,\n decodeFunctionData,\n encodeAbiParameters,\n encodeDeployData,\n encodeFunctionData,\n getContractAddress,\n isAddressEqual,\n keccak256,\n toHex,\n type Address,\n type Client,\n type Hex,\n} from \"viem\";\nimport type { EntryPointVersion } from \"viem/account-abstraction\";\nimport { LightAccountAbi_v1 } from \"./abis/LightAccountAbi_v1.js\";\nimport { LightAccountFactoryAbi_v1 } from \"./abis/LightAccountFactoryAbi_v1.js\";\nimport { LightAccountFactoryAbi_v2 } from \"./abis/LightAccountFactoryAbi_v2.js\";\nimport { MultiOwnerLightAccountFactoryAbi } from \"./abis/MultiOwnerLightAccountFactoryAbi.js\";\nimport { OZ_ERC1967Proxy_ConstructorAbi } from \"./abis/OZ_ERC1967Proxy.js\";\nimport {\n AccountVersionRegistry,\n type LightAccountVersion,\n} from \"./registry.js\";\nimport { BaseError, lowerAddress } from \"@alchemy/common\";\nimport { getSenderFromFactoryData } from \"../utils.js\";\n\nexport type PredictLightAccountAddressParams = {\n version: keyof typeof AccountVersionRegistry.LightAccount;\n salt: bigint;\n ownerAddress: Address;\n factoryAddress?: Address;\n};\n\n/**\n * Predicts the address of a light account based on provided parameters such as factory address, salt, owner address, and version.\n *\n * @param {PredictLightAccountAddressParams} params The parameters required to predict the light account address, including factory address, salt, owner address, and version\n * @returns {Address} The predicted address of the light account calculated based on the provided parameters\n */\nexport function predictLightAccountAddress({\n factoryAddress,\n salt,\n ownerAddress,\n version,\n}: PredictLightAccountAddressParams): Address {\n const factoryAddress_ =\n factoryAddress != null\n ? lowerAddress(factoryAddress)\n : AccountVersionRegistry.LightAccount[version].factoryAddress;\n\n const implementationAddress =\n // If we aren't using the default factory address, we compute the implementation address from the factory's `create` deployment.\n // This is accurate for both LA v1 and v2 factories. If we are using the default factory address, we use the implementation address from the registry.\n factoryAddress_ !==\n AccountVersionRegistry.LightAccount[version].factoryAddress\n ? getContractAddress({\n from: factoryAddress_,\n nonce: 1n,\n })\n : AccountVersionRegistry.LightAccount[version].accountImplementation;\n\n switch (version) {\n case \"v1.0.1\":\n case \"v1.0.2\":\n case \"v1.1.0\":\n // Same proxy initcode for all LA v1 factories\n return getContractAddress({\n from: factoryAddress_,\n opcode: \"CREATE2\",\n salt: toHex(salt, { size: 32 }),\n bytecode: encodeDeployData({\n bytecode: LAv1_PROXY_BYTECODE,\n abi: OZ_ERC1967Proxy_ConstructorAbi,\n args: [\n implementationAddress,\n encodeFunctionData({\n abi: LightAccountAbi_v1,\n functionName: \"initialize\",\n args: [ownerAddress],\n }),\n ],\n }),\n });\n\n case \"v2.0.0\":\n case \"v2.1.0\":\n case \"v2.2.0\":\n // Logic ported from LA factory v2\n const combinedSalt = keccak256(\n encodeAbiParameters(\n [{ type: \"address\" }, { type: \"uint256\" }],\n [ownerAddress, salt],\n ),\n );\n\n const initCode = getLAv2ProxyBytecode(implementationAddress);\n\n return getContractAddress({\n from: factoryAddress_,\n opcode: \"CREATE2\",\n salt: combinedSalt,\n bytecode: initCode,\n });\n default:\n assertNeverLightAccountVersion(version);\n }\n}\n\nexport type PredictMultiOwnerLightAccountAddressParams = {\n salt: bigint;\n ownerAddresses: Address[];\n factoryAddress?: Address;\n // There's just one version of the MultiOwnerLightAccount for now, so skip requiring the version as a parameter.\n};\n\n// Note: assumes the owner addresses are already deduped, sorted in ascending order, and have the signer address included.\n/**\n * Predicts the address of a **Multi-Owner Light Account** given the factory, salt\n * and the set of owner addresses.\n *\n * Internally replicates the CREATE2 calculation performed by the factory so\n * you can obtain the counter-factual account address before deployment (useful\n * for funding or displaying to users).\n *\n * @param {PredictMultiOwnerLightAccountAddressParams} params Object containing:\n * – `factoryAddress` Factory contract that will deploy the account.\n * – `salt` Arbitrary salt used when calling the factory.\n * – `ownerAddresses` Array of owner EOAs (must be deduped & sorted).\n * @returns {Address} Predicted account address for the multi-owner light account.\n */\nexport function predictMultiOwnerLightAccountAddress({\n salt,\n ownerAddresses,\n factoryAddress,\n}: PredictMultiOwnerLightAccountAddressParams): Address {\n const factoryAddress_ =\n factoryAddress != null\n ? lowerAddress(factoryAddress)\n : AccountVersionRegistry.MultiOwnerLightAccount[\"v2.0.0\"].factoryAddress;\n\n const implementationAddress =\n // If we aren't using the default factory address, we compute the implementation address from the factory's `create` deployment.\n // This is accurate for both LA v1 and v2 factories. If we are using the default factory address, we use the implementation address from the registry.\n factoryAddress_ !==\n AccountVersionRegistry.MultiOwnerLightAccount[\"v2.0.0\"].factoryAddress\n ? getContractAddress({\n from: factoryAddress_,\n nonce: 1n,\n })\n : AccountVersionRegistry.MultiOwnerLightAccount[\"v2.0.0\"]\n .accountImplementation;\n\n const combinedSalt = keccak256(\n encodeAbiParameters(\n [{ type: \"address[]\" }, { type: \"uint256\" }],\n [ownerAddresses, salt],\n ),\n );\n\n const initCode: Hex = getLAv2ProxyBytecode(implementationAddress);\n\n return getContractAddress({\n from: factoryAddress_,\n opcode: \"CREATE2\",\n salt: combinedSalt,\n bytecode: initCode,\n });\n}\n\nconst LAv1_PROXY_BYTECODE =\n \"0x60406080815261042c908138038061001681610218565b93843982019181818403126102135780516001600160a01b038116808203610213576020838101516001600160401b0394919391858211610213570186601f820112156102135780519061007161006c83610253565b610218565b918083528583019886828401011161021357888661008f930161026e565b813b156101b9577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b031916841790556000927fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8480a28051158015906101b2575b61010b575b855160e790816103458239f35b855194606086019081118682101761019e578697849283926101889952602788527f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c87890152660819985a5b195960ca1b8a8901525190845af4913d15610194573d9061017a61006c83610253565b91825281943d92013e610291565b508038808080806100fe565b5060609250610291565b634e487b7160e01b84526041600452602484fd5b50826100f9565b855162461bcd60e51b815260048101859052602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608490fd5b600080fd5b6040519190601f01601f191682016001600160401b0381118382101761023d57604052565b634e487b7160e01b600052604160045260246000fd5b6001600160401b03811161023d57601f01601f191660200190565b60005b8381106102815750506000910152565b8181015183820152602001610271565b919290156102f357508151156102a5575090565b3b156102ae5790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156103065750805190602001fd5b6044604051809262461bcd60e51b825260206004830152610336815180928160248601526020868601910161026e565b601f01601f19168101030190fdfe60806040523615605f5773ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc54166000808092368280378136915af43d82803e15605b573d90f35b3d90fd5b73ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc54166000808092368280378136915af43d82803e15605b573d90f3fea26469706673582212205da2750cd2b0cadfd354d8a1ca4752ed7f22214c8069d852f7dc6b8e9e5ee66964736f6c63430008150033\" satisfies Hex;\n\n// Bytecode from https://github.com/Vectorized/solady/blob/c6e5238e5f3b621789c59e1a443f43b6606394b2/src/utils/LibClone.sol#L721\n\nfunction getLAv2ProxyBytecode(implementationAddress: Address): Hex {\n return concatHex([\n \"0x603d3d8160223d3973\",\n implementationAddress,\n \"0x60095155f3363d3d373d3d363d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc545af43d6000803e6038573d6000fd5b3d6000f3\",\n ]);\n}\n\nfunction assertNeverLightAccountVersion(version: never): never {\n throw new BaseError(`Unknown light account version: ${version}`);\n}\n\nexport type GetLightAccountAddressFromFactoryDataParams = {\n client: Client;\n factoryAddress: Address;\n factoryData: Hex;\n entryPoint: {\n version: EntryPointVersion;\n address: Address;\n };\n version: LightAccountVersion<\"LightAccount\">;\n};\n\n/**\n * Gets the light account address from factory data.\n * If the factory is a known default, decodes the args and predicts without RPC.\n * Otherwise falls back to calling the entry point's getSenderAddress.\n *\n * @param {GetLightAccountAddressFromFactoryDataParams} params - The parameters\n * @returns {Promise<Address>} The account address\n */\nexport async function getLightAccountAddressFromFactoryData({\n client,\n factoryAddress,\n factoryData,\n entryPoint,\n version,\n}: GetLightAccountAddressFromFactoryDataParams): Promise<Address> {\n const defaultFactory =\n AccountVersionRegistry[\"LightAccount\"][version].factoryAddress;\n if (isAddressEqual(factoryAddress, defaultFactory)) {\n const factoryAbi =\n version === \"v2.0.0\"\n ? LightAccountFactoryAbi_v2\n : LightAccountFactoryAbi_v1;\n try {\n const decoded = decodeFunctionData({\n abi: factoryAbi,\n data: factoryData,\n });\n if (decoded.functionName === \"createAccount\") {\n const [decodedOwner, decodedSalt] = decoded.args;\n return predictLightAccountAddress({\n factoryAddress,\n salt: decodedSalt,\n ownerAddress: decodedOwner,\n version,\n });\n }\n } catch {\n // Decode failed, fall through to RPC\n }\n }\n return getSenderFromFactoryData(client, {\n factory: factoryAddress,\n factoryData,\n entryPoint,\n });\n}\n\nexport type GetMultiOwnerLightAccountAddressFromFactoryDataParams = {\n client: Client;\n factoryAddress: Address;\n factoryData: Hex;\n entryPoint: {\n version: EntryPointVersion;\n address: Address;\n };\n};\n\n/**\n * Gets the multi-owner light account address from factory data.\n * If the factory is a known default, decodes the args and predicts without RPC.\n * Otherwise falls back to calling the entry point's getSenderAddress.\n *\n * @param {GetMultiOwnerLightAccountAddressFromFactoryDataParams} params - The parameters\n * @returns {Promise<Address>} The account address\n */\nexport async function getMultiOwnerLightAccountAddressFromFactoryData({\n client,\n factoryAddress,\n factoryData,\n entryPoint,\n}: GetMultiOwnerLightAccountAddressFromFactoryDataParams): Promise<Address> {\n const defaultFactory =\n AccountVersionRegistry[\"MultiOwnerLightAccount\"][\"v2.0.0\"].factoryAddress;\n if (isAddressEqual(factoryAddress, defaultFactory)) {\n try {\n const decoded = decodeFunctionData({\n abi: MultiOwnerLightAccountFactoryAbi,\n data: factoryData,\n });\n if (decoded.functionName === \"createAccount\") {\n const [decodedOwners, decodedSalt] = decoded.args;\n return predictMultiOwnerLightAccountAddress({\n factoryAddress,\n salt: decodedSalt,\n ownerAddresses: [...decodedOwners],\n });\n }\n } catch {\n // Decode failed, fall through to RPC\n }\n }\n return getSenderFromFactoryData(client, {\n factory: factoryAddress,\n factoryData,\n entryPoint,\n });\n}\n"]}
|