@rhinestone/sdk 0.7.10 → 0.8.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/{src/accounts → accounts}/index.d.ts +2 -2
- package/dist/accounts/index.d.ts.map +1 -0
- package/dist/{src/accounts → accounts}/index.js +55 -45
- package/dist/accounts/nexus.d.ts.map +1 -0
- package/dist/{src/accounts → accounts}/nexus.js +48 -42
- package/dist/accounts/safe.d.ts.map +1 -0
- package/dist/{src/accounts → accounts}/safe.js +35 -29
- package/dist/accounts/utils.d.ts.map +1 -0
- package/dist/{src/accounts → accounts}/utils.js +23 -19
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/{src/execution → execution}/index.js +66 -61
- package/dist/execution/smart-session.d.ts.map +1 -0
- package/dist/execution/smart-session.js +85 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/{src/index.js → index.js} +10 -8
- package/dist/modules/abi/smart-sessions.d.ts.map +1 -0
- package/dist/modules/common.d.ts.map +1 -0
- package/dist/modules/index.d.ts.map +1 -0
- package/dist/modules/omni-account.d.ts.map +1 -0
- package/dist/modules/validators/core.d.ts.map +1 -0
- package/dist/modules/validators/index.d.ts.map +1 -0
- package/dist/modules/validators/smart-sessions.d.ts.map +1 -0
- package/dist/orchestrator/client.d.ts.map +1 -0
- package/dist/orchestrator/consts.d.ts.map +1 -0
- package/dist/orchestrator/error.d.ts.map +1 -0
- package/dist/orchestrator/index.d.ts.map +1 -0
- package/dist/orchestrator/registry.d.ts.map +1 -0
- package/dist/orchestrator/types.d.ts.map +1 -0
- package/dist/orchestrator/utils.d.ts.map +1 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +13 -13
- package/dist/cjs/modules/abi/smart-sessions.d.ts.map +0 -1
- package/dist/cjs/modules/common.d.ts.map +0 -1
- package/dist/cjs/modules/index.d.ts.map +0 -1
- package/dist/cjs/modules/omni-account.d.ts.map +0 -1
- package/dist/cjs/modules/validators/core.d.ts.map +0 -1
- package/dist/cjs/modules/validators/index.d.ts.map +0 -1
- package/dist/cjs/modules/validators/smart-sessions.d.ts.map +0 -1
- package/dist/cjs/orchestrator/client.d.ts.map +0 -1
- package/dist/cjs/orchestrator/consts.d.ts.map +0 -1
- package/dist/cjs/orchestrator/error.d.ts.map +0 -1
- package/dist/cjs/orchestrator/index.d.ts.map +0 -1
- package/dist/cjs/orchestrator/registry.d.ts.map +0 -1
- package/dist/cjs/orchestrator/types.d.ts.map +0 -1
- package/dist/cjs/orchestrator/utils.d.ts.map +0 -1
- package/dist/cjs/types.d.ts.map +0 -1
- package/dist/src/accounts/index.d.ts.map +0 -1
- package/dist/src/accounts/nexus.d.ts.map +0 -1
- package/dist/src/accounts/safe.d.ts.map +0 -1
- package/dist/src/accounts/utils.d.ts.map +0 -1
- package/dist/src/execution/index.d.ts.map +0 -1
- package/dist/src/execution/smart-session.d.ts.map +0 -1
- package/dist/src/execution/smart-session.js +0 -81
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/modules/abi/smart-sessions.d.ts +0 -42
- package/dist/src/modules/abi/smart-sessions.d.ts.map +0 -1
- package/dist/src/modules/abi/smart-sessions.js +0 -128
- package/dist/src/modules/common.d.ts +0 -16
- package/dist/src/modules/common.d.ts.map +0 -1
- package/dist/src/modules/common.js +0 -5
- package/dist/src/modules/index.d.ts +0 -33
- package/dist/src/modules/index.d.ts.map +0 -1
- package/dist/src/modules/index.js +0 -146
- package/dist/src/modules/omni-account.d.ts +0 -9
- package/dist/src/modules/omni-account.d.ts.map +0 -1
- package/dist/src/modules/omni-account.js +0 -7
- package/dist/src/modules/validators/core.d.ts +0 -23
- package/dist/src/modules/validators/core.d.ts.map +0 -1
- package/dist/src/modules/validators/core.js +0 -112
- package/dist/src/modules/validators/index.d.ts +0 -4
- package/dist/src/modules/validators/index.d.ts.map +0 -1
- package/dist/src/modules/validators/index.js +0 -3
- package/dist/src/modules/validators/smart-sessions.d.ts +0 -29
- package/dist/src/modules/validators/smart-sessions.d.ts.map +0 -1
- package/dist/src/modules/validators/smart-sessions.js +0 -414
- package/dist/src/orchestrator/client.d.ts +0 -29
- package/dist/src/orchestrator/client.d.ts.map +0 -1
- package/dist/src/orchestrator/client.js +0 -243
- package/dist/src/orchestrator/consts.d.ts +0 -5
- package/dist/src/orchestrator/consts.d.ts.map +0 -1
- package/dist/src/orchestrator/consts.js +0 -4
- package/dist/src/orchestrator/error.d.ts +0 -18
- package/dist/src/orchestrator/error.d.ts.map +0 -1
- package/dist/src/orchestrator/error.js +0 -28
- package/dist/src/orchestrator/index.d.ts +0 -11
- package/dist/src/orchestrator/index.d.ts.map +0 -1
- package/dist/src/orchestrator/index.js +0 -10
- package/dist/src/orchestrator/registry.d.ts +0 -17
- package/dist/src/orchestrator/registry.d.ts.map +0 -1
- package/dist/src/orchestrator/registry.js +0 -344
- package/dist/src/orchestrator/types.d.ts +0 -222
- package/dist/src/orchestrator/types.d.ts.map +0 -1
- package/dist/src/orchestrator/types.js +0 -9
- package/dist/src/orchestrator/utils.d.ts +0 -29
- package/dist/src/orchestrator/utils.d.ts.map +0 -1
- package/dist/src/orchestrator/utils.js +0 -303
- package/dist/src/types.d.ts +0 -113
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -1
- package/dist/test/modules/validators/smart-sessions.test.d.ts +0 -2
- package/dist/test/modules/validators/smart-sessions.test.d.ts.map +0 -1
- package/dist/test/modules/validators/smart-sessions.test.js +0 -20
- /package/dist/{src/accounts → accounts}/nexus.d.ts +0 -0
- /package/dist/{src/accounts → accounts}/safe.d.ts +0 -0
- /package/dist/{src/accounts → accounts}/utils.d.ts +0 -0
- /package/dist/{src/execution → execution}/index.d.ts +0 -0
- /package/dist/{src/execution → execution}/smart-session.d.ts +0 -0
- /package/dist/{src/index.d.ts → index.d.ts} +0 -0
- /package/dist/{cjs/modules → modules}/abi/smart-sessions.d.ts +0 -0
- /package/dist/{cjs/modules → modules}/abi/smart-sessions.js +0 -0
- /package/dist/{cjs/modules → modules}/common.d.ts +0 -0
- /package/dist/{cjs/modules → modules}/common.js +0 -0
- /package/dist/{cjs/modules → modules}/index.d.ts +0 -0
- /package/dist/{cjs/modules → modules}/index.js +0 -0
- /package/dist/{cjs/modules → modules}/omni-account.d.ts +0 -0
- /package/dist/{cjs/modules → modules}/omni-account.js +0 -0
- /package/dist/{cjs/modules → modules}/validators/core.d.ts +0 -0
- /package/dist/{cjs/modules → modules}/validators/core.js +0 -0
- /package/dist/{cjs/modules → modules}/validators/index.d.ts +0 -0
- /package/dist/{cjs/modules → modules}/validators/index.js +0 -0
- /package/dist/{cjs/modules → modules}/validators/smart-sessions.d.ts +0 -0
- /package/dist/{cjs/modules → modules}/validators/smart-sessions.js +0 -0
- /package/dist/{cjs/orchestrator → orchestrator}/client.d.ts +0 -0
- /package/dist/{cjs/orchestrator → orchestrator}/client.js +0 -0
- /package/dist/{cjs/orchestrator → orchestrator}/consts.d.ts +0 -0
- /package/dist/{cjs/orchestrator → orchestrator}/consts.js +0 -0
- /package/dist/{cjs/orchestrator → orchestrator}/error.d.ts +0 -0
- /package/dist/{cjs/orchestrator → orchestrator}/error.js +0 -0
- /package/dist/{cjs/orchestrator → orchestrator}/index.d.ts +0 -0
- /package/dist/{cjs/orchestrator → orchestrator}/index.js +0 -0
- /package/dist/{cjs/orchestrator → orchestrator}/registry.d.ts +0 -0
- /package/dist/{cjs/orchestrator → orchestrator}/registry.js +0 -0
- /package/dist/{cjs/orchestrator → orchestrator}/types.d.ts +0 -0
- /package/dist/{cjs/orchestrator → orchestrator}/types.js +0 -0
- /package/dist/{cjs/orchestrator → orchestrator}/utils.d.ts +0 -0
- /package/dist/{cjs/orchestrator → orchestrator}/utils.js +0 -0
- /package/dist/{cjs/types.d.ts → types.d.ts} +0 -0
- /package/dist/{cjs/types.js → types.js} +0 -0
|
@@ -20,8 +20,8 @@ declare function isDeployed(chain: Chain, config: RhinestoneAccountConfig): Prom
|
|
|
20
20
|
declare function deploySource(chain: Chain, config: RhinestoneAccountConfig): Promise<void>;
|
|
21
21
|
declare function deployTarget(chain: Chain, config: RhinestoneAccountConfig, asUserOp: boolean): Promise<void>;
|
|
22
22
|
declare function getBundleInitCode(config: RhinestoneAccountConfig): `0x${string}` | undefined;
|
|
23
|
-
declare function getSmartAccount(config: RhinestoneAccountConfig, client: PublicClient, chain: Chain): Promise<import("viem/account-abstraction").SmartAccount<import("viem/account-abstraction").SmartAccountImplementation<import("
|
|
24
|
-
declare function getSmartSessionSmartAccount(config: RhinestoneAccountConfig, client: PublicClient, chain: Chain, session: Session): Promise<import("viem/account-abstraction").SmartAccount<import("viem/account-abstraction").SmartAccountImplementation<import("
|
|
23
|
+
declare function getSmartAccount(config: RhinestoneAccountConfig, client: PublicClient, chain: Chain): Promise<import("viem/account-abstraction").SmartAccount<import("viem/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">>>;
|
|
24
|
+
declare function getSmartSessionSmartAccount(config: RhinestoneAccountConfig, client: PublicClient, chain: Chain, session: Session): Promise<import("viem/account-abstraction").SmartAccount<import("viem/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">>>;
|
|
25
25
|
declare function sign(validators: OwnerSet, chain: Chain, hash: Hex): Promise<`0x${string}`>;
|
|
26
26
|
export { getDeployArgs, getBundleInitCode, getAddress, isDeployed, deploySource, deployTarget, getSmartAccount, getSmartSessionSmartAccount, sign, };
|
|
27
27
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../accounts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,KAAK,EAKV,KAAK,GAAG,EAGR,KAAK,YAAY,EAIlB,MAAM,MAAM,CAAA;AAUb,OAAO,KAAK,EAEV,QAAQ,EACR,uBAAuB,EACvB,OAAO,EACR,MAAM,UAAU,CAAA;AAiBjB,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;;;;;;;;;EAUrD;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBAgBlD;AAED,iBAAe,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,uBAAuB,oBAiBtE;AAED,iBAAe,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,uBAAuB,iBAMxE;AAED,iBAAe,YAAY,CACzB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,uBAAuB,EAC/B,QAAQ,EAAE,OAAO,iBASlB;AAUD,iBAAS,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,6BAUzD;AAgID,iBAAe,eAAe,CAC5B,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,KAAK,sJA0Bb;AAED,iBAAe,2BAA2B,CACxC,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,sJA8BjB;AAED,iBAAe,IAAI,CAAC,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,0BAYhE;AAgED,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,2BAA2B,EAC3B,IAAI,GACL,CAAA"}
|
|
@@ -1,17 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDeployArgs = getDeployArgs;
|
|
4
|
+
exports.getBundleInitCode = getBundleInitCode;
|
|
5
|
+
exports.getAddress = getAddress;
|
|
6
|
+
exports.isDeployed = isDeployed;
|
|
7
|
+
exports.deploySource = deploySource;
|
|
8
|
+
exports.deployTarget = deployTarget;
|
|
9
|
+
exports.getSmartAccount = getSmartAccount;
|
|
10
|
+
exports.getSmartSessionSmartAccount = getSmartSessionSmartAccount;
|
|
11
|
+
exports.sign = sign;
|
|
12
|
+
const viem_1 = require("viem");
|
|
13
|
+
const modules_1 = require("../modules");
|
|
14
|
+
const validators_1 = require("../modules/validators");
|
|
15
|
+
const nexus_1 = require("./nexus");
|
|
16
|
+
const safe_1 = require("./safe");
|
|
17
|
+
const utils_1 = require("./utils");
|
|
7
18
|
function getDeployArgs(config) {
|
|
8
19
|
const account = getAccount(config);
|
|
9
20
|
switch (account.type) {
|
|
10
21
|
case 'safe': {
|
|
11
|
-
return
|
|
22
|
+
return (0, safe_1.getDeployArgs)(config);
|
|
12
23
|
}
|
|
13
24
|
case 'nexus': {
|
|
14
|
-
return
|
|
25
|
+
return (0, nexus_1.getDeployArgs)(config);
|
|
15
26
|
}
|
|
16
27
|
}
|
|
17
28
|
}
|
|
@@ -23,14 +34,14 @@ function getAddress(config) {
|
|
|
23
34
|
return config.eoa.address;
|
|
24
35
|
}
|
|
25
36
|
const { factory, salt, hashedInitcode } = getDeployArgs(config);
|
|
26
|
-
const hash = keccak256(encodePacked(['bytes1', 'address', 'bytes32', 'bytes'], ['0xff', factory, salt, hashedInitcode]));
|
|
27
|
-
const address = slice(hash, 12, 32);
|
|
37
|
+
const hash = (0, viem_1.keccak256)((0, viem_1.encodePacked)(['bytes1', 'address', 'bytes32', 'bytes'], ['0xff', factory, salt, hashedInitcode]));
|
|
38
|
+
const address = (0, viem_1.slice)(hash, 12, 32);
|
|
28
39
|
return address;
|
|
29
40
|
}
|
|
30
41
|
async function isDeployed(chain, config) {
|
|
31
|
-
const publicClient = createPublicClient({
|
|
42
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
32
43
|
chain: chain,
|
|
33
|
-
transport: http(),
|
|
44
|
+
transport: (0, viem_1.http)(),
|
|
34
45
|
});
|
|
35
46
|
const address = getAddress(config);
|
|
36
47
|
const code = await publicClient.getCode({
|
|
@@ -43,7 +54,7 @@ async function isDeployed(chain, config) {
|
|
|
43
54
|
// Defensive check to ensure there's no storage conflict; can be lifted in the future
|
|
44
55
|
throw new Error('Existing EIP-7702 accounts are not yet supported');
|
|
45
56
|
}
|
|
46
|
-
return size(code) > 0;
|
|
57
|
+
return (0, viem_1.size)(code) > 0;
|
|
47
58
|
}
|
|
48
59
|
async function deploySource(chain, config) {
|
|
49
60
|
if (is7702(config)) {
|
|
@@ -78,7 +89,7 @@ function getBundleInitCode(config) {
|
|
|
78
89
|
if (!factory || !factoryData) {
|
|
79
90
|
throw new Error('Factory args not available');
|
|
80
91
|
}
|
|
81
|
-
return encodePacked(['address', 'bytes'], [factory, factoryData]);
|
|
92
|
+
return (0, viem_1.encodePacked)(['address', 'bytes'], [factory, factoryData]);
|
|
82
93
|
}
|
|
83
94
|
}
|
|
84
95
|
async function deploy7702Self(chain, config) {
|
|
@@ -90,14 +101,14 @@ async function deploy7702Self(chain, config) {
|
|
|
90
101
|
if (!initializationCallData) {
|
|
91
102
|
throw new Error(`Initialization call data not available for ${account.type}`);
|
|
92
103
|
}
|
|
93
|
-
const publicClient = createPublicClient({
|
|
104
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
94
105
|
chain,
|
|
95
|
-
transport: http(),
|
|
106
|
+
transport: (0, viem_1.http)(),
|
|
96
107
|
});
|
|
97
|
-
const accountClient = createWalletClient({
|
|
108
|
+
const accountClient = (0, viem_1.createWalletClient)({
|
|
98
109
|
account: config.eoa,
|
|
99
110
|
chain,
|
|
100
|
-
transport: http(),
|
|
111
|
+
transport: (0, viem_1.http)(),
|
|
101
112
|
});
|
|
102
113
|
const authorization = await accountClient.signAuthorization({
|
|
103
114
|
contractAddress: implementation,
|
|
@@ -113,14 +124,14 @@ async function deploy7702Self(chain, config) {
|
|
|
113
124
|
}
|
|
114
125
|
async function deployStandaloneWithEoa(chain, config, deployer) {
|
|
115
126
|
const { factory, factoryData } = getDeployArgs(config);
|
|
116
|
-
const publicClient = createPublicClient({
|
|
127
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
117
128
|
chain: chain,
|
|
118
|
-
transport: http(),
|
|
129
|
+
transport: (0, viem_1.http)(),
|
|
119
130
|
});
|
|
120
|
-
const client = createWalletClient({
|
|
131
|
+
const client = (0, viem_1.createWalletClient)({
|
|
121
132
|
account: deployer,
|
|
122
133
|
chain: chain,
|
|
123
|
-
transport: http(),
|
|
134
|
+
transport: (0, viem_1.http)(),
|
|
124
135
|
});
|
|
125
136
|
const tx = await client.sendTransaction({
|
|
126
137
|
to: factory,
|
|
@@ -129,11 +140,11 @@ async function deployStandaloneWithEoa(chain, config, deployer) {
|
|
|
129
140
|
await publicClient.waitForTransactionReceipt({ hash: tx });
|
|
130
141
|
}
|
|
131
142
|
async function deployStandaloneWithBundler(chain, config) {
|
|
132
|
-
const publicClient = createPublicClient({
|
|
143
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
133
144
|
chain,
|
|
134
|
-
transport: http(),
|
|
145
|
+
transport: (0, viem_1.http)(),
|
|
135
146
|
});
|
|
136
|
-
const bundlerClient = getBundlerClient(config, publicClient);
|
|
147
|
+
const bundlerClient = (0, utils_1.getBundlerClient)(config, publicClient);
|
|
137
148
|
const smartAccount = await getSmartAccount(config, publicClient, chain);
|
|
138
149
|
const { factory, factoryData } = getDeployArgs(config);
|
|
139
150
|
const opHash = await bundlerClient.sendUserOperation({
|
|
@@ -142,7 +153,7 @@ async function deployStandaloneWithBundler(chain, config) {
|
|
|
142
153
|
factoryData,
|
|
143
154
|
calls: [
|
|
144
155
|
{
|
|
145
|
-
to: zeroHash,
|
|
156
|
+
to: viem_1.zeroHash,
|
|
146
157
|
value: 0n,
|
|
147
158
|
data: '0x',
|
|
148
159
|
},
|
|
@@ -157,16 +168,16 @@ async function deploy7702WithBundler(chain, config) {
|
|
|
157
168
|
throw new Error('EIP-7702 accounts must have an EOA account');
|
|
158
169
|
}
|
|
159
170
|
const { implementation } = getDeployArgs(config);
|
|
160
|
-
const publicClient = createPublicClient({
|
|
171
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
161
172
|
chain,
|
|
162
|
-
transport: http(),
|
|
173
|
+
transport: (0, viem_1.http)(),
|
|
163
174
|
});
|
|
164
|
-
const accountClient = createWalletClient({
|
|
175
|
+
const accountClient = (0, viem_1.createWalletClient)({
|
|
165
176
|
account: config.eoa,
|
|
166
177
|
chain,
|
|
167
|
-
transport: http(),
|
|
178
|
+
transport: (0, viem_1.http)(),
|
|
168
179
|
});
|
|
169
|
-
const bundlerClient = getBundlerClient(config, publicClient);
|
|
180
|
+
const bundlerClient = (0, utils_1.getBundlerClient)(config, publicClient);
|
|
170
181
|
const authorization = await accountClient.signAuthorization({
|
|
171
182
|
contractAddress: implementation,
|
|
172
183
|
});
|
|
@@ -185,20 +196,20 @@ async function deploy7702WithBundler(chain, config) {
|
|
|
185
196
|
async function getSmartAccount(config, client, chain) {
|
|
186
197
|
const account = getAccount(config);
|
|
187
198
|
const address = getAddress(config);
|
|
188
|
-
const ownerValidator = getOwnerValidator(config);
|
|
199
|
+
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
189
200
|
const signFn = (hash) => sign(config.owners, chain, hash);
|
|
190
201
|
switch (account.type) {
|
|
191
202
|
case 'safe': {
|
|
192
|
-
return
|
|
203
|
+
return (0, safe_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn);
|
|
193
204
|
}
|
|
194
205
|
case 'nexus': {
|
|
195
|
-
return
|
|
206
|
+
return (0, nexus_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn);
|
|
196
207
|
}
|
|
197
208
|
}
|
|
198
209
|
}
|
|
199
210
|
async function getSmartSessionSmartAccount(config, client, chain, session) {
|
|
200
211
|
const address = getAddress(config);
|
|
201
|
-
const smartSessionValidator = getSmartSessionValidator(config);
|
|
212
|
+
const smartSessionValidator = (0, validators_1.getSmartSessionValidator)(config);
|
|
202
213
|
if (!smartSessionValidator) {
|
|
203
214
|
throw new Error('Smart sessions are not enabled for this account');
|
|
204
215
|
}
|
|
@@ -206,10 +217,10 @@ async function getSmartSessionSmartAccount(config, client, chain, session) {
|
|
|
206
217
|
const account = getAccount(config);
|
|
207
218
|
switch (account.type) {
|
|
208
219
|
case 'safe': {
|
|
209
|
-
return
|
|
220
|
+
return (0, safe_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, signFn);
|
|
210
221
|
}
|
|
211
222
|
case 'nexus': {
|
|
212
|
-
return
|
|
223
|
+
return (0, nexus_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, signFn);
|
|
213
224
|
}
|
|
214
225
|
}
|
|
215
226
|
}
|
|
@@ -217,7 +228,7 @@ async function sign(validators, chain, hash) {
|
|
|
217
228
|
switch (validators.type) {
|
|
218
229
|
case 'ecdsa': {
|
|
219
230
|
const signatures = await Promise.all(validators.accounts.map((account) => signEcdsa(account, hash)));
|
|
220
|
-
return concat(signatures);
|
|
231
|
+
return (0, viem_1.concat)(signatures);
|
|
221
232
|
}
|
|
222
233
|
case 'passkey': {
|
|
223
234
|
return await signPasskey(validators.account, chain, hash);
|
|
@@ -232,8 +243,8 @@ async function signEcdsa(account, hash) {
|
|
|
232
243
|
}
|
|
233
244
|
async function signPasskey(account, chain, hash) {
|
|
234
245
|
const { webauthn, signature } = await account.sign({ hash });
|
|
235
|
-
const usePrecompiled = isRip7212SupportedNetwork(chain);
|
|
236
|
-
const encodedSignature = getWebauthnValidatorSignature({
|
|
246
|
+
const usePrecompiled = (0, modules_1.isRip7212SupportedNetwork)(chain);
|
|
247
|
+
const encodedSignature = (0, modules_1.getWebauthnValidatorSignature)({
|
|
237
248
|
webauthn,
|
|
238
249
|
signature,
|
|
239
250
|
usePrecompiled,
|
|
@@ -247,10 +258,10 @@ async function get7702SmartAccount(config, client) {
|
|
|
247
258
|
const account = getAccount(config);
|
|
248
259
|
switch (account.type) {
|
|
249
260
|
case 'safe': {
|
|
250
|
-
return
|
|
261
|
+
return (0, safe_1.get7702SmartAccount)();
|
|
251
262
|
}
|
|
252
263
|
case 'nexus': {
|
|
253
|
-
return
|
|
264
|
+
return (0, nexus_1.get7702SmartAccount)(config.eoa, client);
|
|
254
265
|
}
|
|
255
266
|
}
|
|
256
267
|
}
|
|
@@ -258,10 +269,10 @@ async function get7702InitCalls(config) {
|
|
|
258
269
|
const account = getAccount(config);
|
|
259
270
|
switch (account.type) {
|
|
260
271
|
case 'safe': {
|
|
261
|
-
return
|
|
272
|
+
return (0, safe_1.get7702InitCalls)();
|
|
262
273
|
}
|
|
263
274
|
case 'nexus': {
|
|
264
|
-
return
|
|
275
|
+
return (0, nexus_1.get7702InitCalls)(config);
|
|
265
276
|
}
|
|
266
277
|
}
|
|
267
278
|
}
|
|
@@ -276,4 +287,3 @@ function getAccount(config) {
|
|
|
276
287
|
type: 'nexus',
|
|
277
288
|
};
|
|
278
289
|
}
|
|
279
|
-
export { getDeployArgs, getBundleInitCode, getAddress, isDeployed, deploySource, deployTarget, getSmartAccount, getSmartSessionSmartAccount, sign, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nexus.d.ts","sourceRoot":"","sources":["../../accounts/nexus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAUpE,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAA;AASjC,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAa1E,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;;EA8ErD;AAED,iBAAe,eAAe,CAC5B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,QAAQ,EAChB,gBAAgB,EAAE,OAAO,EACzB,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,iEAWlC;AAED,iBAAe,sBAAsB,CACnC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,OAAO,EACzB,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,iEAuBlC;AAED,iBAAe,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,iEAkBxE;AAgFD,iBAAS,gBAAgB,CAAC,MAAM,EAAE,uBAAuB;;;IAqDxD;AAED,OAAO,EACL,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,GACjB,CAAA"}
|
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDeployArgs = getDeployArgs;
|
|
4
|
+
exports.getSmartAccount = getSmartAccount;
|
|
5
|
+
exports.getSessionSmartAccount = getSessionSmartAccount;
|
|
6
|
+
exports.get7702SmartAccount = get7702SmartAccount;
|
|
7
|
+
exports.get7702InitCalls = get7702InitCalls;
|
|
8
|
+
const viem_1 = require("viem");
|
|
9
|
+
const account_abstraction_1 = require("viem/account-abstraction");
|
|
10
|
+
const modules_1 = require("../modules");
|
|
11
|
+
const validators_1 = require("../modules/validators");
|
|
12
|
+
const utils_1 = require("./utils");
|
|
6
13
|
const NEXUS_IMPLEMENTATION_ADDRESS = '0x000000004f43c49e93c970e84001853a70923b03';
|
|
7
14
|
const NEXUS_FACTORY_ADDRESS = '0x000000001D1D5004a02bAfAb9de2D6CE5b7B13de';
|
|
8
15
|
const NEXUS_BOOTSTRAP_ADDRESS = '0x00000000D3254452a909E4eeD47455Af7E27C289';
|
|
9
16
|
const K1_MEE_VALIDATOR_ADDRESS = '0x00000000d12897ddadc2044614a9677b191a2d95';
|
|
10
17
|
function getDeployArgs(config) {
|
|
11
|
-
const salt = keccak256('0x');
|
|
12
|
-
const moduleSetup =
|
|
13
|
-
const initData = encodeAbiParameters([{ type: 'address' }, { type: 'bytes' }], [
|
|
18
|
+
const salt = (0, viem_1.keccak256)('0x');
|
|
19
|
+
const moduleSetup = (0, modules_1.getSetup)(config);
|
|
20
|
+
const initData = (0, viem_1.encodeAbiParameters)([{ type: 'address' }, { type: 'bytes' }], [
|
|
14
21
|
NEXUS_BOOTSTRAP_ADDRESS,
|
|
15
|
-
encodeFunctionData({
|
|
16
|
-
abi: parseAbi([
|
|
22
|
+
(0, viem_1.encodeFunctionData)({
|
|
23
|
+
abi: (0, viem_1.parseAbi)([
|
|
17
24
|
'struct BootstrapConfig {address module;bytes initData;}',
|
|
18
25
|
'struct BootstrapPreValidationHookConfig {uint256 hookType;address module;bytes data;}',
|
|
19
26
|
'struct RegistryConfig {address registry;address[] attesters;uint8 threshold;}',
|
|
@@ -30,7 +37,7 @@ function getDeployArgs(config) {
|
|
|
30
37
|
initData: e.initData,
|
|
31
38
|
})),
|
|
32
39
|
{
|
|
33
|
-
module: zeroAddress,
|
|
40
|
+
module: viem_1.zeroAddress,
|
|
34
41
|
initData: '0x',
|
|
35
42
|
},
|
|
36
43
|
moduleSetup.fallbacks.map((f) => ({
|
|
@@ -46,18 +53,18 @@ function getDeployArgs(config) {
|
|
|
46
53
|
],
|
|
47
54
|
}),
|
|
48
55
|
]);
|
|
49
|
-
const factoryData = encodeFunctionData({
|
|
50
|
-
abi: parseAbi(['function createAccount(bytes,bytes32)']),
|
|
56
|
+
const factoryData = (0, viem_1.encodeFunctionData)({
|
|
57
|
+
abi: (0, viem_1.parseAbi)(['function createAccount(bytes,bytes32)']),
|
|
51
58
|
functionName: 'createAccount',
|
|
52
59
|
args: [initData, salt],
|
|
53
60
|
});
|
|
54
61
|
const creationCode = '0x60806040526102aa803803806100148161018c565b92833981016040828203126101885781516001600160a01b03811692909190838303610188576020810151906001600160401b03821161018857019281601f8501121561018857835161006e610069826101c5565b61018c565b9481865260208601936020838301011161018857815f926020809301865e8601015260017f90b772c2cb8a51aa7a8a65fc23543c6d022d5b3f8e2b92eed79fba7eef8293005d823b15610176577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b031916821790557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b5f80a282511561015e575f8091610146945190845af43d15610156573d91610137610069846101c5565b9283523d5f602085013e6101e0565b505b604051606b908161023f8239f35b6060916101e0565b50505034156101485763b398979f60e01b5f5260045ffd5b634c9c8ce360e01b5f5260045260245ffd5b5f80fd5b6040519190601f01601f191682016001600160401b038111838210176101b157604052565b634e487b7160e01b5f52604160045260245ffd5b6001600160401b0381116101b157601f01601f191660200190565b9061020457508051156101f557805190602001fd5b63d6bda27560e01b5f5260045ffd5b81511580610235575b610215575090565b639996b31560e01b5f9081526001600160a01b0391909116600452602490fd5b50803b1561020d56fe60806040523615605c575f8073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416368280378136915af43d5f803e156058573d5ff35b3d5ffd5b00fea164736f6c634300081b000a';
|
|
55
|
-
const initializationCallData = encodeFunctionData({
|
|
56
|
-
abi: parseAbi(['function initializeAccount(bytes)']),
|
|
62
|
+
const initializationCallData = (0, viem_1.encodeFunctionData)({
|
|
63
|
+
abi: (0, viem_1.parseAbi)(['function initializeAccount(bytes)']),
|
|
57
64
|
functionName: 'initializeAccount',
|
|
58
65
|
args: [initData],
|
|
59
66
|
});
|
|
60
|
-
const accountInitData = encodeAbiParameters([
|
|
67
|
+
const accountInitData = (0, viem_1.encodeAbiParameters)([
|
|
61
68
|
{
|
|
62
69
|
name: 'address',
|
|
63
70
|
type: 'address',
|
|
@@ -67,7 +74,7 @@ function getDeployArgs(config) {
|
|
|
67
74
|
type: 'bytes',
|
|
68
75
|
},
|
|
69
76
|
], [NEXUS_IMPLEMENTATION_ADDRESS, initializationCallData]);
|
|
70
|
-
const hashedInitcode = keccak256(concat([creationCode, accountInitData]));
|
|
77
|
+
const hashedInitcode = (0, viem_1.keccak256)((0, viem_1.concat)([creationCode, accountInitData]));
|
|
71
78
|
return {
|
|
72
79
|
factory: NEXUS_FACTORY_ADDRESS,
|
|
73
80
|
factoryData,
|
|
@@ -79,20 +86,20 @@ function getDeployArgs(config) {
|
|
|
79
86
|
}
|
|
80
87
|
async function getSmartAccount(client, address, owners, validatorAddress, sign) {
|
|
81
88
|
return getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
82
|
-
return getMockSignature(owners);
|
|
89
|
+
return (0, validators_1.getMockSignature)(owners);
|
|
83
90
|
}, sign);
|
|
84
91
|
}
|
|
85
92
|
async function getSessionSmartAccount(client, address, session, validatorAddress, sign) {
|
|
86
93
|
return await getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
87
|
-
const dummyOpSignature = getMockSignature(session.owners);
|
|
88
|
-
return encodeSmartSessionSignature(SMART_SESSION_MODE_USE, getPermissionId(session), dummyOpSignature);
|
|
94
|
+
const dummyOpSignature = (0, validators_1.getMockSignature)(session.owners);
|
|
95
|
+
return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_USE, (0, validators_1.getPermissionId)(session), dummyOpSignature);
|
|
89
96
|
}, async (hash) => {
|
|
90
97
|
const signature = await sign(hash);
|
|
91
|
-
return encodeSmartSessionSignature(SMART_SESSION_MODE_USE, getPermissionId(session), signature);
|
|
98
|
+
return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_USE, (0, validators_1.getPermissionId)(session), signature);
|
|
92
99
|
});
|
|
93
100
|
}
|
|
94
101
|
async function get7702SmartAccount(account, client) {
|
|
95
|
-
return await getBaseSmartAccount(account.address, client, zeroAddress, async () => {
|
|
102
|
+
return await getBaseSmartAccount(account.address, client, viem_1.zeroAddress, async () => {
|
|
96
103
|
const dynamicPart = K1_MEE_VALIDATOR_ADDRESS.substring(2).padEnd(40, '0');
|
|
97
104
|
return `0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000${dynamicPart}000000000000000000000000000000000000000000000000000000000000004181d4b4981670cb18f99f0b4a66446df1bf5b204d24cfcb659bf38ba27a4359b5711649ec2423c5e1247245eba2964679b6a1dbb85c992ae40b9b00c6935b02ff1b00000000000000000000000000000000000000000000000000000000000000`;
|
|
98
105
|
}, async (hash) => {
|
|
@@ -105,18 +112,18 @@ async function get7702SmartAccount(account, client) {
|
|
|
105
112
|
});
|
|
106
113
|
}
|
|
107
114
|
async function getBaseSmartAccount(address, client, nonceValidatorAddress, getStubSignature, signUserOperation) {
|
|
108
|
-
return await toSmartAccount({
|
|
115
|
+
return await (0, account_abstraction_1.toSmartAccount)({
|
|
109
116
|
client,
|
|
110
117
|
entryPoint: {
|
|
111
|
-
abi: entryPoint07Abi,
|
|
112
|
-
address: entryPoint07Address,
|
|
118
|
+
abi: account_abstraction_1.entryPoint07Abi,
|
|
119
|
+
address: account_abstraction_1.entryPoint07Address,
|
|
113
120
|
version: '0.7',
|
|
114
121
|
},
|
|
115
122
|
async decodeCalls() {
|
|
116
123
|
throw new Error('Not implemented');
|
|
117
124
|
},
|
|
118
125
|
async encodeCalls(calls) {
|
|
119
|
-
return encode7579Calls({
|
|
126
|
+
return (0, utils_1.encode7579Calls)({
|
|
120
127
|
mode: {
|
|
121
128
|
type: calls.length > 1 ? 'batchcall' : 'call',
|
|
122
129
|
revertOnError: false,
|
|
@@ -136,14 +143,14 @@ async function getBaseSmartAccount(address, client, nonceValidatorAddress, getSt
|
|
|
136
143
|
const TIMESTAMP_ADJUSTMENT = 16777215n; // max value for size 3
|
|
137
144
|
const defaultedKey = (args?.key ?? 0n) % TIMESTAMP_ADJUSTMENT;
|
|
138
145
|
const defaultedValidationMode = '0x00';
|
|
139
|
-
const key = concat([
|
|
140
|
-
toHex(defaultedKey, { size: 3 }),
|
|
146
|
+
const key = (0, viem_1.concat)([
|
|
147
|
+
(0, viem_1.toHex)(defaultedKey, { size: 3 }),
|
|
141
148
|
defaultedValidationMode,
|
|
142
149
|
nonceValidatorAddress,
|
|
143
150
|
]);
|
|
144
|
-
return getAccountNonce(client, {
|
|
151
|
+
return (0, utils_1.getAccountNonce)(client, {
|
|
145
152
|
address,
|
|
146
|
-
entryPointAddress: entryPoint07Address,
|
|
153
|
+
entryPointAddress: account_abstraction_1.entryPoint07Address,
|
|
147
154
|
key: BigInt(key),
|
|
148
155
|
});
|
|
149
156
|
},
|
|
@@ -160,13 +167,13 @@ async function getBaseSmartAccount(address, client, nonceValidatorAddress, getSt
|
|
|
160
167
|
const { chainId = client.chain?.id, ...userOperation } = parameters;
|
|
161
168
|
if (!chainId)
|
|
162
169
|
throw new Error('Chain id not found');
|
|
163
|
-
const hash = getUserOperationHash({
|
|
170
|
+
const hash = (0, account_abstraction_1.getUserOperationHash)({
|
|
164
171
|
userOperation: {
|
|
165
172
|
...userOperation,
|
|
166
173
|
sender: userOperation.sender ?? (await this.getAddress()),
|
|
167
174
|
signature: '0x',
|
|
168
175
|
},
|
|
169
|
-
entryPointAddress: entryPoint07Address,
|
|
176
|
+
entryPointAddress: account_abstraction_1.entryPoint07Address,
|
|
170
177
|
entryPointVersion: '0.7',
|
|
171
178
|
chainId: chainId,
|
|
172
179
|
});
|
|
@@ -179,12 +186,12 @@ function get7702InitCalls(config) {
|
|
|
179
186
|
if (!eoa) {
|
|
180
187
|
throw new Error('EIP-7702 accounts must have an EOA account');
|
|
181
188
|
}
|
|
182
|
-
const moduleSetup =
|
|
189
|
+
const moduleSetup = (0, modules_1.getSetup)(config);
|
|
183
190
|
return [
|
|
184
191
|
{
|
|
185
192
|
to: eoa.address,
|
|
186
|
-
data: encodeFunctionData({
|
|
187
|
-
abi: parseAbi([
|
|
193
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
194
|
+
abi: (0, viem_1.parseAbi)([
|
|
188
195
|
'function setRegistry(address newRegistry, address[] calldata attesters, uint8 threshold)',
|
|
189
196
|
]),
|
|
190
197
|
functionName: 'setRegistry',
|
|
@@ -197,8 +204,8 @@ function get7702InitCalls(config) {
|
|
|
197
204
|
},
|
|
198
205
|
...moduleSetup.validators.map((validator) => ({
|
|
199
206
|
to: eoa.address,
|
|
200
|
-
data: encodeFunctionData({
|
|
201
|
-
abi: parseAbi([
|
|
207
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
208
|
+
abi: (0, viem_1.parseAbi)([
|
|
202
209
|
'function installModule(uint256 moduleTypeId, address module, bytes calldata initData)',
|
|
203
210
|
]),
|
|
204
211
|
functionName: 'installModule',
|
|
@@ -207,8 +214,8 @@ function get7702InitCalls(config) {
|
|
|
207
214
|
})),
|
|
208
215
|
...moduleSetup.executors.map((executor) => ({
|
|
209
216
|
to: eoa.address,
|
|
210
|
-
data: encodeFunctionData({
|
|
211
|
-
abi: parseAbi([
|
|
217
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
218
|
+
abi: (0, viem_1.parseAbi)([
|
|
212
219
|
'function installModule(uint256 moduleTypeId, address module, bytes calldata initData)',
|
|
213
220
|
]),
|
|
214
221
|
functionName: 'installModule',
|
|
@@ -217,8 +224,8 @@ function get7702InitCalls(config) {
|
|
|
217
224
|
})),
|
|
218
225
|
...moduleSetup.fallbacks.map((fallback) => ({
|
|
219
226
|
to: eoa.address,
|
|
220
|
-
data: encodeFunctionData({
|
|
221
|
-
abi: parseAbi([
|
|
227
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
228
|
+
abi: (0, viem_1.parseAbi)([
|
|
222
229
|
'function installModule(uint256 moduleTypeId, address module, bytes calldata initData)',
|
|
223
230
|
]),
|
|
224
231
|
functionName: 'installModule',
|
|
@@ -227,4 +234,3 @@ function get7702InitCalls(config) {
|
|
|
227
234
|
})),
|
|
228
235
|
];
|
|
229
236
|
}
|
|
230
|
-
export { getDeployArgs, getSmartAccount, getSessionSmartAccount, get7702SmartAccount, get7702InitCalls, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../../accounts/safe.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EACR,KAAK,OAAO,EAIZ,KAAK,GAAG,EAER,KAAK,YAAY,EAGlB,MAAM,MAAM,CAAA;AACb,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAA;AASjC,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAgB1E,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;;EA0ErD;AAED,iBAAe,eAAe,CAC5B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,QAAQ,EAChB,gBAAgB,EAAE,OAAO,EACzB,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,iEAWlC;AAED,iBAAe,sBAAsB,CACnC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,OAAO,EACzB,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,iEAuBlC;AA0ED,iBAAS,mBAAmB,IAAI,KAAK,CAEpC;AAED,iBAAS,gBAAgB,IAAI,KAAK,CAEjC;AAsBD,OAAO,EACL,aAAa,EACb,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,GACpB,CAAA"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDeployArgs = getDeployArgs;
|
|
4
|
+
exports.getSmartAccount = getSmartAccount;
|
|
5
|
+
exports.getSessionSmartAccount = getSessionSmartAccount;
|
|
6
|
+
exports.get7702InitCalls = get7702InitCalls;
|
|
7
|
+
exports.get7702SmartAccount = get7702SmartAccount;
|
|
8
|
+
const viem_1 = require("viem");
|
|
9
|
+
const account_abstraction_1 = require("viem/account-abstraction");
|
|
10
|
+
const modules_1 = require("../modules");
|
|
11
|
+
const validators_1 = require("../modules/validators");
|
|
12
|
+
const utils_1 = require("./utils");
|
|
6
13
|
const SAFE_7579_LAUNCHPAD_ADDRESS = '0x7579011aB74c46090561ea277Ba79D510c6C00ff';
|
|
7
14
|
const SAFE_7579_ADAPTER_ADDRESS = '0x7579ee8307284f293b1927136486880611f20002';
|
|
8
15
|
const SAFE_SINGLETON_ADDRESS = '0x29fcb43b46531bca003ddc8fcb67ffe91900c762';
|
|
@@ -12,9 +19,9 @@ function getDeployArgs(config) {
|
|
|
12
19
|
{
|
|
13
20
|
const owners = getOwners(config);
|
|
14
21
|
const threshold = getThreshold(config);
|
|
15
|
-
const moduleSetup =
|
|
16
|
-
const initData = encodeFunctionData({
|
|
17
|
-
abi: parseAbi([
|
|
22
|
+
const moduleSetup = (0, modules_1.getSetup)(config);
|
|
23
|
+
const initData = (0, viem_1.encodeFunctionData)({
|
|
24
|
+
abi: (0, viem_1.parseAbi)([
|
|
18
25
|
'function setup(address[] calldata _owners,uint256 _threshold,address to,bytes calldata data,address fallbackHandler,address paymentToken,uint256 payment, address paymentReceiver) external',
|
|
19
26
|
]),
|
|
20
27
|
functionName: 'setup',
|
|
@@ -22,8 +29,8 @@ function getDeployArgs(config) {
|
|
|
22
29
|
owners,
|
|
23
30
|
threshold,
|
|
24
31
|
SAFE_7579_LAUNCHPAD_ADDRESS,
|
|
25
|
-
encodeFunctionData({
|
|
26
|
-
abi: parseAbi([
|
|
32
|
+
(0, viem_1.encodeFunctionData)({
|
|
33
|
+
abi: (0, viem_1.parseAbi)([
|
|
27
34
|
'struct ModuleInit {address module;bytes initData;}',
|
|
28
35
|
'function addSafe7579(address safe7579,ModuleInit[] calldata validators,ModuleInit[] calldata executors,ModuleInit[] calldata fallbacks, ModuleInit[] calldata hooks,address[] calldata attesters,uint8 threshold) external',
|
|
29
36
|
]),
|
|
@@ -51,20 +58,20 @@ function getDeployArgs(config) {
|
|
|
51
58
|
],
|
|
52
59
|
}),
|
|
53
60
|
SAFE_7579_ADAPTER_ADDRESS,
|
|
54
|
-
zeroAddress,
|
|
61
|
+
viem_1.zeroAddress,
|
|
55
62
|
BigInt(0),
|
|
56
|
-
zeroAddress,
|
|
63
|
+
viem_1.zeroAddress,
|
|
57
64
|
],
|
|
58
65
|
});
|
|
59
66
|
const saltNonce = 0n;
|
|
60
|
-
const factoryData = encodeFunctionData({
|
|
61
|
-
abi: parseAbi([
|
|
67
|
+
const factoryData = (0, viem_1.encodeFunctionData)({
|
|
68
|
+
abi: (0, viem_1.parseAbi)([
|
|
62
69
|
'function createProxyWithNonce(address singleton,bytes calldata initializer,uint256 saltNonce) external payable returns (address)',
|
|
63
70
|
]),
|
|
64
71
|
functionName: 'createProxyWithNonce',
|
|
65
72
|
args: [SAFE_SINGLETON_ADDRESS, initData, saltNonce],
|
|
66
73
|
});
|
|
67
|
-
const salt = keccak256(encodePacked(['bytes32', 'uint256'], [keccak256(initData), saltNonce]));
|
|
74
|
+
const salt = (0, viem_1.keccak256)((0, viem_1.encodePacked)(['bytes32', 'uint256'], [(0, viem_1.keccak256)(initData), saltNonce]));
|
|
68
75
|
const hashedInitcode = '0xe298282cefe913ab5d282047161268a8222e4bd4ed106300c547894bbefd31ee';
|
|
69
76
|
return {
|
|
70
77
|
factory: SAFE_PROXY_FACTORY_ADDRESS,
|
|
@@ -78,31 +85,31 @@ function getDeployArgs(config) {
|
|
|
78
85
|
}
|
|
79
86
|
async function getSmartAccount(client, address, owners, validatorAddress, sign) {
|
|
80
87
|
return getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
81
|
-
return getMockSignature(owners);
|
|
88
|
+
return (0, validators_1.getMockSignature)(owners);
|
|
82
89
|
}, sign);
|
|
83
90
|
}
|
|
84
91
|
async function getSessionSmartAccount(client, address, session, validatorAddress, sign) {
|
|
85
92
|
return await getBaseSmartAccount(address, client, validatorAddress, async () => {
|
|
86
|
-
const dummyOpSignature = getMockSignature(session.owners);
|
|
87
|
-
return encodeSmartSessionSignature(SMART_SESSION_MODE_USE, getPermissionId(session), dummyOpSignature);
|
|
93
|
+
const dummyOpSignature = (0, validators_1.getMockSignature)(session.owners);
|
|
94
|
+
return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_USE, (0, validators_1.getPermissionId)(session), dummyOpSignature);
|
|
88
95
|
}, async (hash) => {
|
|
89
96
|
const signature = await sign(hash);
|
|
90
|
-
return encodeSmartSessionSignature(SMART_SESSION_MODE_USE, getPermissionId(session), signature);
|
|
97
|
+
return (0, validators_1.encodeSmartSessionSignature)(validators_1.SMART_SESSION_MODE_USE, (0, validators_1.getPermissionId)(session), signature);
|
|
91
98
|
});
|
|
92
99
|
}
|
|
93
100
|
async function getBaseSmartAccount(address, client, validatorAddress, getStubSignature, signUserOperation) {
|
|
94
|
-
return await toSmartAccount({
|
|
101
|
+
return await (0, account_abstraction_1.toSmartAccount)({
|
|
95
102
|
client,
|
|
96
103
|
entryPoint: {
|
|
97
|
-
abi: entryPoint07Abi,
|
|
98
|
-
address: entryPoint07Address,
|
|
104
|
+
abi: account_abstraction_1.entryPoint07Abi,
|
|
105
|
+
address: account_abstraction_1.entryPoint07Address,
|
|
99
106
|
version: '0.7',
|
|
100
107
|
},
|
|
101
108
|
async decodeCalls() {
|
|
102
109
|
throw new Error('Not implemented');
|
|
103
110
|
},
|
|
104
111
|
async encodeCalls(calls) {
|
|
105
|
-
return encode7579Calls({
|
|
112
|
+
return (0, utils_1.encode7579Calls)({
|
|
106
113
|
mode: {
|
|
107
114
|
type: calls.length > 1 ? 'batchcall' : 'call',
|
|
108
115
|
revertOnError: false,
|
|
@@ -119,10 +126,10 @@ async function getBaseSmartAccount(address, client, validatorAddress, getStubSig
|
|
|
119
126
|
return {};
|
|
120
127
|
},
|
|
121
128
|
async getNonce() {
|
|
122
|
-
const key = concat([validatorAddress, '0x00000000']);
|
|
123
|
-
const nonce = await getAccountNonce(client, {
|
|
129
|
+
const key = (0, viem_1.concat)([validatorAddress, '0x00000000']);
|
|
130
|
+
const nonce = await (0, utils_1.getAccountNonce)(client, {
|
|
124
131
|
address,
|
|
125
|
-
entryPointAddress: entryPoint07Address,
|
|
132
|
+
entryPointAddress: account_abstraction_1.entryPoint07Address,
|
|
126
133
|
key: BigInt(key),
|
|
127
134
|
});
|
|
128
135
|
return nonce;
|
|
@@ -140,13 +147,13 @@ async function getBaseSmartAccount(address, client, validatorAddress, getStubSig
|
|
|
140
147
|
const { chainId = client.chain?.id, ...userOperation } = parameters;
|
|
141
148
|
if (!chainId)
|
|
142
149
|
throw new Error('Chain id not found');
|
|
143
|
-
const hash = getUserOperationHash({
|
|
150
|
+
const hash = (0, account_abstraction_1.getUserOperationHash)({
|
|
144
151
|
userOperation: {
|
|
145
152
|
...userOperation,
|
|
146
153
|
sender: userOperation.sender ?? (await this.getAddress()),
|
|
147
154
|
signature: '0x',
|
|
148
155
|
},
|
|
149
|
-
entryPointAddress: entryPoint07Address,
|
|
156
|
+
entryPointAddress: account_abstraction_1.entryPoint07Address,
|
|
150
157
|
entryPointVersion: '0.7',
|
|
151
158
|
chainId: chainId,
|
|
152
159
|
});
|
|
@@ -178,4 +185,3 @@ function getThreshold(config) {
|
|
|
178
185
|
return 1n;
|
|
179
186
|
}
|
|
180
187
|
}
|
|
181
|
-
export { getDeployArgs, getSmartAccount, getSessionSmartAccount, get7702InitCalls, get7702SmartAccount, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../accounts/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAchD,OAAO,KAAK,EAAiB,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAEtE,KAAK,QAAQ,GAAG,MAAM,GAAG,cAAc,GAAG,WAAW,CAAA;AAErD,UAAU,aAAa,CAAC,QAAQ,SAAS,QAAQ;IAC/C,IAAI,EAAE,QAAQ,CAAA;IACd,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,EAAE,GAAG,CAAA;IACd,OAAO,CAAC,EAAE,GAAG,CAAA;CACd;AAED,UAAU,oBAAoB,CAAC,QAAQ,SAAS,QAAQ;IACtD,IAAI,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAA;IAC7B,QAAQ,EAAE,SAAS;QACjB,EAAE,EAAE,OAAO,CAAA;QACX,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,EAAE,GAAG,GAAG,SAAS,CAAA;KACvB,EAAE,CAAA;CACJ;AAED,UAAU,qBAAqB;IAC7B,OAAO,EAAE,OAAO,CAAA;IAChB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAkDD,iBAAS,eAAe,CAAC,QAAQ,SAAS,QAAQ,EAAE,EAClD,IAAI,EACJ,QAAQ,GACT,EAAE,oBAAoB,CAAC,QAAQ,CAAC,GAAG,GAAG,CAuFtC;AAED,iBAAe,eAAe,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,qBAAqB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAmCjB;AAED,iBAAS,gBAAgB,CAAC,MAAM,EAAE,uBAAuB,EAAE,MAAM,EAAE,MAAM,6IAyBxE;AAyBD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAA"}
|