@rhinestone/sdk 1.0.0-alpha.2 → 1.0.0-alpha.21
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/custom.d.ts +18 -0
- package/dist/src/accounts/custom.d.ts.map +1 -0
- package/dist/src/accounts/custom.js +121 -0
- package/dist/src/accounts/custom.test.d.ts +2 -0
- package/dist/src/accounts/custom.test.d.ts.map +1 -0
- package/dist/src/accounts/custom.test.js +64 -0
- package/dist/src/accounts/error.d.ts.map +1 -1
- package/dist/src/accounts/error.js +2 -0
- package/dist/src/accounts/index.d.ts +22 -13
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +192 -186
- package/dist/src/accounts/index.test.js +3 -3
- package/dist/src/accounts/json-rpc/index.d.ts +5 -0
- package/dist/src/accounts/json-rpc/index.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.js +16 -0
- package/dist/src/accounts/json-rpc/index.test.d.ts +2 -0
- package/dist/src/accounts/json-rpc/index.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.test.js +16 -0
- package/dist/src/accounts/json-rpc/providers.d.ts +4 -0
- package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.js +14 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts +2 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.test.js +15 -0
- package/dist/src/accounts/kernel.d.ts +9 -10
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +3 -14
- package/dist/src/accounts/kernel.test.js +10 -15
- package/dist/src/accounts/nexus.d.ts +14 -13
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +121 -93
- package/dist/src/accounts/nexus.test.js +13 -14
- package/dist/src/accounts/safe.d.ts +5 -7
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +25 -35
- package/dist/src/accounts/safe.test.js +9 -10
- package/dist/src/accounts/signing/common.d.ts +27 -0
- package/dist/src/accounts/signing/common.d.ts.map +1 -0
- package/dist/src/accounts/signing/common.js +142 -0
- package/dist/src/accounts/signing/message.d.ts +5 -0
- package/dist/src/accounts/signing/message.d.ts.map +1 -0
- package/dist/src/accounts/signing/message.js +47 -0
- package/dist/src/accounts/signing/passkeys.d.ts +29 -0
- package/dist/src/accounts/signing/passkeys.d.ts.map +1 -0
- package/dist/src/accounts/signing/passkeys.js +90 -0
- package/dist/src/accounts/signing/passkeys.test.d.ts +2 -0
- package/dist/src/accounts/signing/passkeys.test.d.ts.map +1 -0
- package/dist/src/accounts/signing/passkeys.test.js +73 -0
- package/dist/src/accounts/signing/typedData.d.ts +5 -0
- package/dist/src/accounts/signing/typedData.d.ts.map +1 -0
- package/dist/src/accounts/signing/typedData.js +35 -0
- package/dist/src/accounts/startale.d.ts +20 -0
- package/dist/src/accounts/startale.d.ts.map +1 -0
- package/dist/src/accounts/startale.js +100 -0
- package/dist/src/accounts/startale.test.d.ts +2 -0
- package/dist/src/accounts/startale.test.d.ts.map +1 -0
- package/dist/src/accounts/startale.test.js +96 -0
- package/dist/src/accounts/utils.d.ts +2 -1
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/accounts/utils.js +7 -0
- package/dist/src/actions/index.d.ts +145 -7
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +373 -23
- package/dist/src/actions/index.test.js +35 -17
- package/dist/src/actions/smart-session.d.ts +8 -2
- package/dist/src/actions/smart-session.d.ts.map +1 -1
- package/dist/src/actions/smart-session.js +6 -0
- package/dist/src/execution/compact.d.ts +130 -3
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +94 -1
- package/dist/src/execution/error.d.ts +2 -9
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +4 -13
- package/dist/src/execution/index.d.ts +3 -4
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +35 -80
- package/dist/src/execution/smart-session.d.ts +1 -1
- package/dist/src/execution/smart-session.d.ts.map +1 -1
- package/dist/src/execution/smart-session.js +12 -17
- package/dist/src/execution/utils.d.ts +19 -14
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +222 -97
- package/dist/src/index.d.ts +17 -15
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +108 -21
- package/dist/src/modules/index.d.ts +3 -22
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +5 -65
- package/dist/src/modules/index.test.js +3 -17
- package/dist/src/modules/omni-account.d.ts +2 -4
- package/dist/src/modules/omni-account.d.ts.map +1 -1
- package/dist/src/modules/omni-account.js +4 -8
- package/dist/src/modules/read.d.ts +5 -6
- package/dist/src/modules/read.d.ts.map +1 -1
- package/dist/src/modules/read.js +7 -37
- package/dist/src/modules/validators/core.d.ts +8 -8
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +126 -42
- package/dist/src/modules/validators/core.test.js +7 -7
- package/dist/src/modules/validators/smart-sessions.d.ts +3 -3
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions.js +10 -9
- package/dist/src/modules/validators/smart-sessions.test.js +4 -4
- package/dist/src/orchestrator/client.d.ts +5 -3
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +159 -95
- package/dist/src/orchestrator/consts.d.ts +3 -2
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +4 -2
- package/dist/src/orchestrator/index.d.ts +3 -4
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +1 -9
- package/dist/src/orchestrator/registry.d.ts +10 -13
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +75 -395
- package/dist/src/orchestrator/registry.test.d.ts.map +1 -0
- package/dist/src/orchestrator/registry.test.js +137 -0
- package/dist/src/orchestrator/types.d.ts +78 -16
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.d.ts +1 -3
- package/dist/src/orchestrator/utils.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.js +0 -102
- package/dist/src/types.d.ts +69 -26
- package/dist/src/types.d.ts.map +1 -1
- package/dist/test/consts.d.ts +2 -2
- package/dist/test/consts.d.ts.map +1 -1
- package/package.json +2 -1
- package/dist/src/actions/registry.d.ts +0 -7
- package/dist/src/actions/registry.d.ts.map +0 -1
- package/dist/src/actions/registry.js +0 -7
- package/dist/src/actions/registry.test.d.ts.map +0 -1
- package/dist/src/actions/registry.test.js +0 -25
- package/dist/src/modules/registry.d.ts +0 -13
- package/dist/src/modules/registry.d.ts.map +0 -1
- package/dist/src/modules/registry.js +0 -67
- /package/dist/src/{actions → orchestrator}/registry.test.d.ts +0 -0
|
@@ -5,19 +5,23 @@ exports.getModuleInstallationCalls = getModuleInstallationCalls;
|
|
|
5
5
|
exports.getModuleUninstallationCalls = getModuleUninstallationCalls;
|
|
6
6
|
exports.getAddress = getAddress;
|
|
7
7
|
exports.getAccountProvider = getAccountProvider;
|
|
8
|
+
exports.getInitCode = getInitCode;
|
|
9
|
+
exports.signEip7702InitData = signEip7702InitData;
|
|
10
|
+
exports.getEip7702InitCall = getEip7702InitCall;
|
|
8
11
|
exports.isDeployed = isDeployed;
|
|
9
12
|
exports.deploy = deploy;
|
|
10
|
-
exports.
|
|
11
|
-
exports.deployTarget = deployTarget;
|
|
13
|
+
exports.toErc6492Signature = toErc6492Signature;
|
|
12
14
|
exports.getSmartAccount = getSmartAccount;
|
|
13
15
|
exports.getSmartSessionSmartAccount = getSmartSessionSmartAccount;
|
|
14
16
|
exports.getGuardianSmartAccount = getGuardianSmartAccount;
|
|
15
17
|
exports.getPackedSignature = getPackedSignature;
|
|
18
|
+
exports.getTypedDataPackedSignature = getTypedDataPackedSignature;
|
|
16
19
|
const viem_1 = require("viem");
|
|
20
|
+
const execution_1 = require("../execution");
|
|
17
21
|
const smart_session_1 = require("../execution/smart-session");
|
|
18
|
-
const modules_1 = require("../modules");
|
|
19
22
|
const validators_1 = require("../modules/validators");
|
|
20
23
|
const core_1 = require("../modules/validators/core");
|
|
24
|
+
const custom_1 = require("./custom");
|
|
21
25
|
const error_1 = require("./error");
|
|
22
26
|
Object.defineProperty(exports, "AccountError", { enumerable: true, get: function () { return error_1.AccountError; } });
|
|
23
27
|
Object.defineProperty(exports, "Eip7702AccountMustHaveEoaError", { enumerable: true, get: function () { return error_1.Eip7702AccountMustHaveEoaError; } });
|
|
@@ -31,6 +35,10 @@ Object.defineProperty(exports, "SmartSessionsNotEnabledError", { enumerable: tru
|
|
|
31
35
|
const kernel_1 = require("./kernel");
|
|
32
36
|
const nexus_1 = require("./nexus");
|
|
33
37
|
const safe_1 = require("./safe");
|
|
38
|
+
const common_1 = require("./signing/common");
|
|
39
|
+
const message_1 = require("./signing/message");
|
|
40
|
+
const typedData_1 = require("./signing/typedData");
|
|
41
|
+
const startale_1 = require("./startale");
|
|
34
42
|
const utils_1 = require("./utils");
|
|
35
43
|
function getDeployArgs(config) {
|
|
36
44
|
const account = getAccountProvider(config);
|
|
@@ -44,6 +52,63 @@ function getDeployArgs(config) {
|
|
|
44
52
|
case 'kernel': {
|
|
45
53
|
return (0, kernel_1.getDeployArgs)(config);
|
|
46
54
|
}
|
|
55
|
+
case 'startale': {
|
|
56
|
+
return (0, startale_1.getDeployArgs)(config);
|
|
57
|
+
}
|
|
58
|
+
case 'custom': {
|
|
59
|
+
return (0, custom_1.getDeployArgs)(config);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function getInitCode(config) {
|
|
64
|
+
if (is7702(config)) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
const { factory, factoryData } = getDeployArgs(config);
|
|
69
|
+
if (!factory || !factoryData) {
|
|
70
|
+
throw new error_1.FactoryArgsNotAvailableError();
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
factory,
|
|
74
|
+
factoryData,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async function signEip7702InitData(config) {
|
|
79
|
+
const eoa = config.eoa;
|
|
80
|
+
if (!eoa) {
|
|
81
|
+
throw new error_1.Eip7702AccountMustHaveEoaError();
|
|
82
|
+
}
|
|
83
|
+
const account = getAccountProvider(config);
|
|
84
|
+
switch (account.type) {
|
|
85
|
+
case 'nexus': {
|
|
86
|
+
return await (0, nexus_1.signEip7702InitData)(config, eoa);
|
|
87
|
+
}
|
|
88
|
+
case 'safe':
|
|
89
|
+
case 'kernel':
|
|
90
|
+
case 'startale': {
|
|
91
|
+
throw new Error(`7702 is not supported for account type ${account.type}`);
|
|
92
|
+
}
|
|
93
|
+
case 'custom': {
|
|
94
|
+
throw new Error('7702 is not supported for custom account');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async function getEip7702InitCall(config, signature) {
|
|
99
|
+
const account = getAccountProvider(config);
|
|
100
|
+
switch (account.type) {
|
|
101
|
+
case 'nexus': {
|
|
102
|
+
return await (0, nexus_1.getEip7702InitCall)(config, signature);
|
|
103
|
+
}
|
|
104
|
+
case 'safe':
|
|
105
|
+
case 'kernel':
|
|
106
|
+
case 'startale': {
|
|
107
|
+
throw new Error(`7702 is not supported for account type ${account.type}`);
|
|
108
|
+
}
|
|
109
|
+
case 'custom': {
|
|
110
|
+
throw new Error('7702 is not supported for custom account');
|
|
111
|
+
}
|
|
47
112
|
}
|
|
48
113
|
}
|
|
49
114
|
function getModuleInstallationCalls(config, module) {
|
|
@@ -60,11 +125,18 @@ function getModuleInstallationCalls(config, module) {
|
|
|
60
125
|
case 'kernel': {
|
|
61
126
|
return (0, kernel_1.getInstallData)(module);
|
|
62
127
|
}
|
|
128
|
+
case 'startale': {
|
|
129
|
+
return [(0, startale_1.getInstallData)(module)];
|
|
130
|
+
}
|
|
131
|
+
case 'custom': {
|
|
132
|
+
return (0, custom_1.getInstallData)(config, module);
|
|
133
|
+
}
|
|
63
134
|
}
|
|
64
135
|
}
|
|
65
136
|
const installData = getInstallData();
|
|
66
137
|
return installData.map((data) => ({
|
|
67
138
|
to: address,
|
|
139
|
+
value: 0n,
|
|
68
140
|
data,
|
|
69
141
|
}));
|
|
70
142
|
}
|
|
@@ -96,7 +168,7 @@ function getModuleUninstallationCalls(config, module) {
|
|
|
96
168
|
functionName: 'uninstallModule',
|
|
97
169
|
args: [module.type, module.address, module.deInitData],
|
|
98
170
|
});
|
|
99
|
-
return [{ to: address, data }];
|
|
171
|
+
return [{ to: address, data, value: 0n }];
|
|
100
172
|
}
|
|
101
173
|
function getAddress(config) {
|
|
102
174
|
if (is7702(config)) {
|
|
@@ -116,29 +188,78 @@ function getAddress(config) {
|
|
|
116
188
|
case 'kernel': {
|
|
117
189
|
return (0, kernel_1.getAddress)(config);
|
|
118
190
|
}
|
|
191
|
+
case 'startale': {
|
|
192
|
+
return (0, startale_1.getAddress)(config);
|
|
193
|
+
}
|
|
194
|
+
case 'custom': {
|
|
195
|
+
return (0, custom_1.getAddress)(config);
|
|
196
|
+
}
|
|
119
197
|
}
|
|
120
198
|
}
|
|
121
|
-
// Signs and packs a signature to be EIP-1271
|
|
122
|
-
async function getPackedSignature(config,
|
|
123
|
-
|
|
199
|
+
// Signs and packs a signature to be EIP-1271 compatible
|
|
200
|
+
async function getPackedSignature(config, signers, chain, validator, hash, transformSignature = (signature) => signature) {
|
|
201
|
+
signers = signers ?? (0, common_1.convertOwnerSetToSignerSet)(config.owners);
|
|
202
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash);
|
|
124
203
|
const account = getAccountProvider(config);
|
|
125
204
|
const address = getAddress(config);
|
|
126
205
|
switch (account.type) {
|
|
127
206
|
case 'safe': {
|
|
128
|
-
|
|
207
|
+
const signature = await signFn(hash);
|
|
208
|
+
return (0, safe_1.packSignature)(signature, validator, transformSignature);
|
|
209
|
+
}
|
|
210
|
+
case 'nexus': {
|
|
211
|
+
const signature = await signFn(hash);
|
|
212
|
+
return (0, nexus_1.packSignature)(signature, validator, transformSignature);
|
|
213
|
+
}
|
|
214
|
+
case 'kernel': {
|
|
215
|
+
const signature = await signFn((0, kernel_1.wrapMessageHash)(hash, address));
|
|
216
|
+
return (0, kernel_1.packSignature)(signature, validator, transformSignature);
|
|
217
|
+
}
|
|
218
|
+
case 'startale': {
|
|
219
|
+
const signature = await signFn(hash);
|
|
220
|
+
return (0, startale_1.packSignature)(signature, validator, transformSignature);
|
|
221
|
+
}
|
|
222
|
+
case 'custom': {
|
|
223
|
+
const signature = await signFn(hash);
|
|
224
|
+
return (0, custom_1.getPackedSignature)(config, signature, validator, transformSignature);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
// Signs and packs a signature to be EIP-1271 compatible
|
|
229
|
+
async function getTypedDataPackedSignature(config, signers, chain, validator, parameters, transformSignature = (signature) => signature) {
|
|
230
|
+
const address = getAddress(config);
|
|
231
|
+
signers = signers ?? (0, common_1.convertOwnerSetToSignerSet)(config.owners);
|
|
232
|
+
const signFn = (parameters) => (0, typedData_1.sign)(signers, chain, address, parameters);
|
|
233
|
+
const account = getAccountProvider(config);
|
|
234
|
+
switch (account.type) {
|
|
235
|
+
case 'safe': {
|
|
236
|
+
const signature = await signFn(parameters);
|
|
237
|
+
return (0, safe_1.packSignature)(signature, validator, transformSignature);
|
|
238
|
+
}
|
|
239
|
+
case 'custom': {
|
|
240
|
+
const signature = await signFn(parameters);
|
|
241
|
+
return (0, custom_1.getPackedSignature)(config, signature, validator, transformSignature);
|
|
129
242
|
}
|
|
130
243
|
case 'nexus': {
|
|
131
|
-
|
|
244
|
+
const signature = await signFn(parameters);
|
|
245
|
+
return (0, nexus_1.packSignature)(signature, validator, transformSignature);
|
|
132
246
|
}
|
|
133
247
|
case 'kernel': {
|
|
134
|
-
|
|
248
|
+
const address = getAddress(config);
|
|
249
|
+
const signMessageFn = (hash) => (0, message_1.sign)(signers, chain, address, hash);
|
|
250
|
+
const signature = await signMessageFn((0, kernel_1.wrapMessageHash)((0, viem_1.hashTypedData)(parameters), address));
|
|
251
|
+
return (0, kernel_1.packSignature)(signature, validator, transformSignature);
|
|
252
|
+
}
|
|
253
|
+
case 'startale': {
|
|
254
|
+
const signature = await signFn(parameters);
|
|
255
|
+
return (0, startale_1.packSignature)(signature, validator, transformSignature);
|
|
135
256
|
}
|
|
136
257
|
}
|
|
137
258
|
}
|
|
138
|
-
async function isDeployed(
|
|
259
|
+
async function isDeployed(config, chain) {
|
|
139
260
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
140
261
|
chain: chain,
|
|
141
|
-
transport: (0,
|
|
262
|
+
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
142
263
|
});
|
|
143
264
|
const address = getAddress(config);
|
|
144
265
|
const code = await publicClient.getCode({
|
|
@@ -154,141 +275,60 @@ async function isDeployed(chain, config) {
|
|
|
154
275
|
return (0, viem_1.size)(code) > 0;
|
|
155
276
|
}
|
|
156
277
|
async function deploy(config, chain, session) {
|
|
157
|
-
await
|
|
278
|
+
await deployWithIntent(chain, config);
|
|
158
279
|
if (session) {
|
|
159
280
|
await (0, smart_session_1.enableSmartSession)(chain, config, session);
|
|
160
281
|
}
|
|
161
282
|
}
|
|
162
|
-
async function
|
|
163
|
-
if (is7702(config)) {
|
|
164
|
-
return deploy7702Self(chain, config);
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
return deployStandalone(chain, config);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
async function deployTarget(chain, config, asUserOp) {
|
|
171
|
-
if (is7702(config)) {
|
|
172
|
-
return deploy7702WithBundler(chain, config);
|
|
173
|
-
}
|
|
174
|
-
if (asUserOp) {
|
|
175
|
-
return deployStandalone(chain, config);
|
|
176
|
-
}
|
|
177
|
-
// No need to deploy manually for the intent flow
|
|
178
|
-
}
|
|
179
|
-
async function deployStandalone(chain, config) {
|
|
180
|
-
const deployer = config.deployerAccount;
|
|
181
|
-
if (deployer) {
|
|
182
|
-
return deployStandaloneWithEoa(chain, config, deployer);
|
|
183
|
-
}
|
|
184
|
-
return deployStandaloneWithBundler(chain, config);
|
|
185
|
-
}
|
|
186
|
-
async function deploy7702Self(chain, config) {
|
|
187
|
-
if (!config.eoa) {
|
|
188
|
-
throw new error_1.Eip7702AccountMustHaveEoaError();
|
|
189
|
-
}
|
|
190
|
-
const account = getAccountProvider(config);
|
|
191
|
-
const { implementation, initializationCallData } = getDeployArgs(config);
|
|
192
|
-
if (!initializationCallData) {
|
|
193
|
-
throw new Error(`Initialization call data not available for ${account.type}`);
|
|
194
|
-
}
|
|
195
|
-
const publicClient = (0, viem_1.createPublicClient)({
|
|
196
|
-
chain,
|
|
197
|
-
transport: (0, viem_1.http)(),
|
|
198
|
-
});
|
|
199
|
-
const accountClient = (0, viem_1.createWalletClient)({
|
|
200
|
-
account: config.eoa,
|
|
201
|
-
chain,
|
|
202
|
-
transport: (0, viem_1.http)(),
|
|
203
|
-
});
|
|
204
|
-
const authorization = await accountClient.signAuthorization({
|
|
205
|
-
contractAddress: implementation,
|
|
206
|
-
executor: 'self',
|
|
207
|
-
});
|
|
208
|
-
const hash = await accountClient.sendTransaction({
|
|
209
|
-
chain,
|
|
210
|
-
authorizationList: [authorization],
|
|
211
|
-
to: config.eoa.address,
|
|
212
|
-
data: initializationCallData,
|
|
213
|
-
});
|
|
214
|
-
await publicClient.waitForTransactionReceipt({ hash });
|
|
215
|
-
}
|
|
216
|
-
async function deployStandaloneWithEoa(chain, config, deployer) {
|
|
217
|
-
const { factory, factoryData } = getDeployArgs(config);
|
|
218
|
-
const publicClient = (0, viem_1.createPublicClient)({
|
|
219
|
-
chain: chain,
|
|
220
|
-
transport: (0, viem_1.http)(),
|
|
221
|
-
});
|
|
222
|
-
const client = (0, viem_1.createWalletClient)({
|
|
223
|
-
account: deployer,
|
|
224
|
-
chain: chain,
|
|
225
|
-
transport: (0, viem_1.http)(),
|
|
226
|
-
});
|
|
227
|
-
const tx = await client.sendTransaction({
|
|
228
|
-
to: factory,
|
|
229
|
-
data: factoryData,
|
|
230
|
-
});
|
|
231
|
-
await publicClient.waitForTransactionReceipt({ hash: tx });
|
|
232
|
-
}
|
|
233
|
-
async function deployStandaloneWithBundler(chain, config) {
|
|
283
|
+
async function deployWithIntent(chain, config) {
|
|
234
284
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
235
285
|
chain,
|
|
236
|
-
transport: (0,
|
|
286
|
+
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
237
287
|
});
|
|
238
|
-
const
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
288
|
+
const address = getAddress(config);
|
|
289
|
+
const code = await publicClient.getCode({ address });
|
|
290
|
+
if (code) {
|
|
291
|
+
// Already deployed
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
const result = await (0, execution_1.sendTransaction)(config, {
|
|
295
|
+
targetChain: chain,
|
|
245
296
|
calls: [
|
|
246
297
|
{
|
|
247
|
-
to: viem_1.
|
|
248
|
-
value: 0n,
|
|
298
|
+
to: viem_1.zeroAddress,
|
|
249
299
|
data: '0x',
|
|
250
300
|
},
|
|
251
301
|
],
|
|
252
302
|
});
|
|
253
|
-
await
|
|
254
|
-
hash: opHash,
|
|
255
|
-
});
|
|
303
|
+
await (0, execution_1.waitForExecution)(config, result, true);
|
|
256
304
|
}
|
|
257
|
-
async function
|
|
258
|
-
|
|
259
|
-
|
|
305
|
+
async function toErc6492Signature(config, signature, chain) {
|
|
306
|
+
const deployed = await isDeployed(config, chain);
|
|
307
|
+
if (deployed) {
|
|
308
|
+
return signature;
|
|
260
309
|
}
|
|
261
|
-
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
const smartAccount = await get7702SmartAccount(config, publicClient);
|
|
277
|
-
const initCalls = await get7702InitCalls(config);
|
|
278
|
-
const opHash = await bundlerClient.sendUserOperation({
|
|
279
|
-
account: smartAccount,
|
|
280
|
-
calls: initCalls,
|
|
281
|
-
authorization,
|
|
282
|
-
});
|
|
283
|
-
await bundlerClient.waitForUserOperationReceipt({
|
|
284
|
-
hash: opHash,
|
|
285
|
-
});
|
|
310
|
+
// Account is not deployed, use ERC-6492
|
|
311
|
+
const initCode = getInitCode(config);
|
|
312
|
+
if (!initCode) {
|
|
313
|
+
throw new error_1.FactoryArgsNotAvailableError();
|
|
314
|
+
}
|
|
315
|
+
const { factory, factoryData } = initCode;
|
|
316
|
+
const magicBytes = '0x6492649264926492649264926492649264926492649264926492649264926492';
|
|
317
|
+
return (0, viem_1.concat)([
|
|
318
|
+
(0, viem_1.encodeAbiParameters)([
|
|
319
|
+
{ name: 'create2Factory', type: 'address' },
|
|
320
|
+
{ name: 'factoryCalldata', type: 'bytes' },
|
|
321
|
+
{ name: 'originalERC1271Signature', type: 'bytes' },
|
|
322
|
+
], [factory, factoryData, signature]),
|
|
323
|
+
magicBytes,
|
|
324
|
+
]);
|
|
286
325
|
}
|
|
287
326
|
async function getSmartAccount(config, client, chain) {
|
|
288
327
|
const account = getAccountProvider(config);
|
|
289
328
|
const address = getAddress(config);
|
|
290
329
|
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
291
|
-
const
|
|
330
|
+
const signers = (0, common_1.convertOwnerSetToSignerSet)(config.owners);
|
|
331
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash);
|
|
292
332
|
switch (account.type) {
|
|
293
333
|
case 'safe': {
|
|
294
334
|
return (0, safe_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn);
|
|
@@ -299,6 +339,12 @@ async function getSmartAccount(config, client, chain) {
|
|
|
299
339
|
case 'kernel': {
|
|
300
340
|
return (0, kernel_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn);
|
|
301
341
|
}
|
|
342
|
+
case 'startale': {
|
|
343
|
+
return (0, startale_1.getSmartAccount)(client, address, config.owners, ownerValidator.address, signFn);
|
|
344
|
+
}
|
|
345
|
+
case 'custom': {
|
|
346
|
+
return (0, custom_1.getSmartAccount)(config, client, address, ownerValidator.address, signFn);
|
|
347
|
+
}
|
|
302
348
|
}
|
|
303
349
|
}
|
|
304
350
|
async function getSmartSessionSmartAccount(config, client, chain, session, enableData) {
|
|
@@ -307,7 +353,12 @@ async function getSmartSessionSmartAccount(config, client, chain, session, enabl
|
|
|
307
353
|
if (!smartSessionValidator) {
|
|
308
354
|
throw new error_1.SmartSessionsNotEnabledError();
|
|
309
355
|
}
|
|
310
|
-
const
|
|
356
|
+
const signers = {
|
|
357
|
+
type: 'session',
|
|
358
|
+
session,
|
|
359
|
+
enableData: enableData || undefined,
|
|
360
|
+
};
|
|
361
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash);
|
|
311
362
|
const account = getAccountProvider(config);
|
|
312
363
|
switch (account.type) {
|
|
313
364
|
case 'safe': {
|
|
@@ -319,6 +370,12 @@ async function getSmartSessionSmartAccount(config, client, chain, session, enabl
|
|
|
319
370
|
case 'kernel': {
|
|
320
371
|
return (0, kernel_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, enableData, signFn);
|
|
321
372
|
}
|
|
373
|
+
case 'startale': {
|
|
374
|
+
return (0, startale_1.getSessionSmartAccount)(client, address, session, smartSessionValidator.address, enableData, signFn);
|
|
375
|
+
}
|
|
376
|
+
case 'custom': {
|
|
377
|
+
return (0, custom_1.getSessionSmartAccount)(config, client, address, session, smartSessionValidator.address, enableData);
|
|
378
|
+
}
|
|
322
379
|
}
|
|
323
380
|
}
|
|
324
381
|
async function getGuardianSmartAccount(config, client, chain, guardians) {
|
|
@@ -328,7 +385,11 @@ async function getGuardianSmartAccount(config, client, chain, guardians) {
|
|
|
328
385
|
if (!socialRecoveryValidator) {
|
|
329
386
|
throw new Error('Social recovery is not available');
|
|
330
387
|
}
|
|
331
|
-
const
|
|
388
|
+
const signers = {
|
|
389
|
+
type: 'guardians',
|
|
390
|
+
guardians: accounts,
|
|
391
|
+
};
|
|
392
|
+
const signFn = (hash) => (0, message_1.sign)(signers, chain, address, hash);
|
|
332
393
|
const account = getAccountProvider(config);
|
|
333
394
|
switch (account.type) {
|
|
334
395
|
case 'safe': {
|
|
@@ -340,63 +401,8 @@ async function getGuardianSmartAccount(config, client, chain, guardians) {
|
|
|
340
401
|
case 'kernel': {
|
|
341
402
|
return (0, kernel_1.getGuardianSmartAccount)(client, address, guardians, socialRecoveryValidator.address, signFn);
|
|
342
403
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
async function sign(validators, chain, hash) {
|
|
346
|
-
switch (validators.type) {
|
|
347
|
-
case 'ecdsa': {
|
|
348
|
-
const signatures = await Promise.all(validators.accounts.map((account) => signEcdsa(account, hash)));
|
|
349
|
-
return (0, viem_1.concat)(signatures);
|
|
350
|
-
}
|
|
351
|
-
case 'passkey': {
|
|
352
|
-
return await signPasskey(validators.account, chain, hash);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
async function signEcdsa(account, hash) {
|
|
357
|
-
if (!account.signMessage) {
|
|
358
|
-
throw new error_1.SigningNotSupportedForAccountError();
|
|
359
|
-
}
|
|
360
|
-
return await account.signMessage({ message: { raw: hash } });
|
|
361
|
-
}
|
|
362
|
-
async function signPasskey(account, chain, hash) {
|
|
363
|
-
const { webauthn, signature } = await account.sign({ hash });
|
|
364
|
-
const usePrecompiled = (0, modules_1.isRip7212SupportedNetwork)(chain);
|
|
365
|
-
const encodedSignature = (0, modules_1.getWebauthnValidatorSignature)({
|
|
366
|
-
webauthn,
|
|
367
|
-
signature,
|
|
368
|
-
usePrecompiled,
|
|
369
|
-
});
|
|
370
|
-
return encodedSignature;
|
|
371
|
-
}
|
|
372
|
-
async function get7702SmartAccount(config, client) {
|
|
373
|
-
if (!config.eoa) {
|
|
374
|
-
throw new error_1.Eip7702AccountMustHaveEoaError();
|
|
375
|
-
}
|
|
376
|
-
const account = getAccountProvider(config);
|
|
377
|
-
switch (account.type) {
|
|
378
|
-
case 'safe': {
|
|
379
|
-
return (0, safe_1.get7702SmartAccount)();
|
|
380
|
-
}
|
|
381
|
-
case 'nexus': {
|
|
382
|
-
return (0, nexus_1.get7702SmartAccount)(config.eoa, client);
|
|
383
|
-
}
|
|
384
|
-
case 'kernel': {
|
|
385
|
-
return (0, kernel_1.get7702SmartAccount)();
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
async function get7702InitCalls(config) {
|
|
390
|
-
const account = getAccountProvider(config);
|
|
391
|
-
switch (account.type) {
|
|
392
|
-
case 'safe': {
|
|
393
|
-
return (0, safe_1.get7702InitCalls)();
|
|
394
|
-
}
|
|
395
|
-
case 'nexus': {
|
|
396
|
-
return (0, nexus_1.get7702InitCalls)(config);
|
|
397
|
-
}
|
|
398
|
-
case 'kernel': {
|
|
399
|
-
return (0, kernel_1.get7702InitCalls)();
|
|
404
|
+
case 'startale': {
|
|
405
|
+
return (0, startale_1.getGuardianSmartAccount)(client, address, guardians, socialRecoveryValidator.address, signFn);
|
|
400
406
|
}
|
|
401
407
|
}
|
|
402
408
|
}
|
|
@@ -14,17 +14,17 @@ const _1 = require(".");
|
|
|
14
14
|
},
|
|
15
15
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
16
16
|
});
|
|
17
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
17
|
+
(0, vitest_1.expect)(address).toEqual('0x0681de31e060b384f0b08a3bac99e9bdff302474');
|
|
18
18
|
});
|
|
19
19
|
(0, vitest_1.test)('Safe, passkey owner with a session', () => {
|
|
20
20
|
const address = (0, _1.getAddress)({
|
|
21
21
|
owners: {
|
|
22
22
|
type: 'passkey',
|
|
23
|
-
|
|
23
|
+
accounts: [consts_1.passkeyAccount],
|
|
24
24
|
},
|
|
25
25
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
26
26
|
});
|
|
27
|
-
(0, vitest_1.expect)(address).toEqual('
|
|
27
|
+
(0, vitest_1.expect)(address).toEqual('0x894b88c04b4de6abddce81e8bdc91927e37d6ced');
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
30
|
(0, vitest_1.describe)('Sign', () => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../accounts/json-rpc/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAQ,KAAK,SAAS,EAAE,MAAM,MAAM,CAAA;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGjD,iBAAS,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,SAAS,CAc3E;AAED,OAAO,EAAE,eAAe,EAAE,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTransport = createTransport;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const providers_1 = require("./providers");
|
|
6
|
+
function createTransport(chain, provider) {
|
|
7
|
+
if (!provider) {
|
|
8
|
+
return (0, viem_1.http)();
|
|
9
|
+
}
|
|
10
|
+
switch (provider.type) {
|
|
11
|
+
case 'alchemy': {
|
|
12
|
+
const alchemyUrl = (0, providers_1.getAlchemyUrl)(chain.id, provider.apiKey);
|
|
13
|
+
return (0, viem_1.http)(alchemyUrl);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../../accounts/json-rpc/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chains_1 = require("viem/chains");
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
const index_1 = require("./index");
|
|
6
|
+
(0, vitest_1.describe)('JSON-RPC', () => {
|
|
7
|
+
(0, vitest_1.describe)('createTransport', () => {
|
|
8
|
+
(0, vitest_1.test)('Alchemy', () => {
|
|
9
|
+
const transport = (0, index_1.createTransport)(chains_1.base, {
|
|
10
|
+
type: 'alchemy',
|
|
11
|
+
apiKey: '123',
|
|
12
|
+
});
|
|
13
|
+
(0, vitest_1.expect)(transport).toBeDefined();
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../../../accounts/json-rpc/providers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAExD,iBAAS,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAStE;AAED,OAAO,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAlchemyUrl = getAlchemyUrl;
|
|
4
|
+
const shared_configs_1 = require("@rhinestone/shared-configs");
|
|
5
|
+
function getAlchemyUrl(chainId, apiKey) {
|
|
6
|
+
const urlTemplate = shared_configs_1.providerRegistry.Alchemy.url_template;
|
|
7
|
+
const chainParam = shared_configs_1.providerRegistry.Alchemy.chain_mapping[chainId];
|
|
8
|
+
if (!chainParam) {
|
|
9
|
+
throw new Error(`Unsupported chain: ${chainId}`);
|
|
10
|
+
}
|
|
11
|
+
return urlTemplate
|
|
12
|
+
.replace('{{chain_param}}', chainParam)
|
|
13
|
+
.replace('\$\{ALCHEMY_API_KEY\}', apiKey);
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.test.d.ts","sourceRoot":"","sources":["../../../../accounts/json-rpc/providers.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chains_1 = require("viem/chains");
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
const providers_1 = require("./providers");
|
|
6
|
+
(0, vitest_1.describe)('Providers', () => {
|
|
7
|
+
(0, vitest_1.describe)('Alchemy', () => {
|
|
8
|
+
(0, vitest_1.test)('Network', () => {
|
|
9
|
+
const mockApiKey = '123';
|
|
10
|
+
(0, vitest_1.expect)((0, providers_1.getAlchemyUrl)(chains_1.mainnet.id, mockApiKey)).toBe('https://eth-mainnet.g.alchemy.com/v2/123');
|
|
11
|
+
(0, vitest_1.expect)((0, providers_1.getAlchemyUrl)(chains_1.sepolia.id, mockApiKey)).toBe('https://eth-sepolia.g.alchemy.com/v2/123');
|
|
12
|
+
(0, vitest_1.expect)((0, providers_1.getAlchemyUrl)(chains_1.polygon.id, mockApiKey)).toBe('https://polygon-mainnet.g.alchemy.com/v2/123');
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Abi, Address, Hex, PublicClient } from 'viem';
|
|
2
|
-
import { SmartAccount, SmartAccountImplementation } from 'viem/account-abstraction';
|
|
3
|
-
import { Module } from '../modules/common';
|
|
4
|
-
import { EnableSessionData } from '../modules/validators/smart-sessions';
|
|
5
|
-
import { OwnerSet, RhinestoneAccountConfig, Session } from '../types';
|
|
6
|
-
import { ValidatorConfig } from './utils';
|
|
1
|
+
import { type Abi, type Address, type Hex, type PublicClient } from 'viem';
|
|
2
|
+
import { type SmartAccount, type SmartAccountImplementation } from 'viem/account-abstraction';
|
|
3
|
+
import { type Module } from '../modules/common';
|
|
4
|
+
import type { EnableSessionData } from '../modules/validators/smart-sessions';
|
|
5
|
+
import type { OwnerSet, RhinestoneAccountConfig, Session } from '../types';
|
|
6
|
+
import { type ValidatorConfig } from './utils';
|
|
7
7
|
declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
8
8
|
factory: `0x${string}`;
|
|
9
9
|
factoryData: `0x${string}`;
|
|
@@ -13,11 +13,10 @@ declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
|
13
13
|
};
|
|
14
14
|
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
15
15
|
declare function getInstallData(module: Module): Hex[];
|
|
16
|
-
declare function
|
|
17
|
-
declare function
|
|
18
|
-
declare function getPackedSignature(signFn: (message: Hex) => Promise<Hex>, hash: Hex, validator: ValidatorConfig, accountAddress: Address, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
|
|
16
|
+
declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
|
|
17
|
+
declare function wrapMessageHash(messageHash: Hex, accountAddress: Hex): Hex;
|
|
19
18
|
declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
20
19
|
declare function getSessionSmartAccount(client: PublicClient, address: Address, session: Session, validatorAddress: Address, enableData: EnableSessionData | null, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
21
20
|
declare function getGuardianSmartAccount(client: PublicClient, address: Address, guardians: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<SmartAccount<SmartAccountImplementation<Abi, "0.7">>>;
|
|
22
|
-
export { getInstallData, getAddress, getDeployArgs, getSmartAccount, getSessionSmartAccount, getGuardianSmartAccount,
|
|
21
|
+
export { getInstallData, getAddress, getDeployArgs, getSmartAccount, getSessionSmartAccount, getGuardianSmartAccount, packSignature, wrapMessageHash, };
|
|
23
22
|
//# sourceMappingURL=kernel.d.ts.map
|