@charterlabs/rhinestone-sdk 0.0.3 → 0.0.4

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.
Files changed (61) hide show
  1. package/README.md +6 -0
  2. package/dist/src/accounts/index.d.ts +10 -6
  3. package/dist/src/accounts/index.d.ts.map +1 -1
  4. package/dist/src/accounts/index.js +100 -4
  5. package/dist/src/accounts/kernel.d.ts +22 -0
  6. package/dist/src/accounts/kernel.d.ts.map +1 -0
  7. package/dist/src/accounts/kernel.js +252 -0
  8. package/dist/src/accounts/kernel.test.d.ts +2 -0
  9. package/dist/src/accounts/kernel.test.d.ts.map +1 -0
  10. package/dist/src/accounts/kernel.test.js +103 -0
  11. package/dist/src/accounts/nexus.d.ts +7 -2
  12. package/dist/src/accounts/nexus.d.ts.map +1 -1
  13. package/dist/src/accounts/nexus.js +59 -10
  14. package/dist/src/accounts/nexus.test.js +50 -4
  15. package/dist/src/accounts/safe.d.ts +7 -2
  16. package/dist/src/accounts/safe.d.ts.map +1 -1
  17. package/dist/src/accounts/safe.js +51 -2
  18. package/dist/src/accounts/safe.test.js +50 -4
  19. package/dist/src/accounts/utils.d.ts +5 -0
  20. package/dist/src/accounts/utils.d.ts.map +1 -1
  21. package/dist/src/actions/index.d.ts +12 -0
  22. package/dist/src/actions/index.d.ts.map +1 -0
  23. package/dist/src/actions/index.js +165 -0
  24. package/dist/src/actions/index.test.d.ts +2 -0
  25. package/dist/src/actions/index.test.d.ts.map +1 -0
  26. package/dist/src/actions/index.test.js +170 -0
  27. package/dist/src/execution/index.d.ts +5 -15
  28. package/dist/src/execution/index.d.ts.map +1 -1
  29. package/dist/src/execution/index.js +30 -149
  30. package/dist/src/execution/smart-session.d.ts.map +1 -1
  31. package/dist/src/execution/smart-session.js +7 -2
  32. package/dist/src/execution/smart-session.test.js +3 -0
  33. package/dist/src/execution/utils.d.ts +68 -0
  34. package/dist/src/execution/utils.d.ts.map +1 -0
  35. package/dist/src/execution/utils.js +355 -0
  36. package/dist/src/index.d.ts +20 -24
  37. package/dist/src/index.d.ts.map +1 -1
  38. package/dist/src/index.js +24 -0
  39. package/dist/src/modules/index.d.ts +2 -1
  40. package/dist/src/modules/index.d.ts.map +1 -1
  41. package/dist/src/modules/index.js +9 -1
  42. package/dist/src/modules/registry.d.ts +9 -0
  43. package/dist/src/modules/registry.d.ts.map +1 -0
  44. package/dist/src/modules/registry.js +60 -0
  45. package/dist/src/modules/validators/core.d.ts +4 -2
  46. package/dist/src/modules/validators/core.d.ts.map +1 -1
  47. package/dist/src/modules/validators/core.js +24 -0
  48. package/dist/src/orchestrator/client.d.ts.map +1 -1
  49. package/dist/src/orchestrator/registry.d.ts +1 -1
  50. package/dist/src/orchestrator/registry.d.ts.map +1 -1
  51. package/dist/src/orchestrator/registry.js +76 -1
  52. package/dist/src/orchestrator/types.d.ts +24 -3
  53. package/dist/src/orchestrator/types.d.ts.map +1 -1
  54. package/dist/src/orchestrator/utils.d.ts.map +1 -1
  55. package/dist/src/orchestrator/utils.js +3 -0
  56. package/dist/src/types.d.ts +12 -3
  57. package/dist/src/types.d.ts.map +1 -1
  58. package/dist/test/consts.d.ts +2 -1
  59. package/dist/test/consts.d.ts.map +1 -1
  60. package/dist/test/consts.js +3 -1
  61. package/package.json +1 -1
@@ -0,0 +1,355 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prepareTransaction = prepareTransaction;
4
+ exports.signTransaction = signTransaction;
5
+ exports.submitTransaction = submitTransaction;
6
+ exports.getOrchestratorByChain = getOrchestratorByChain;
7
+ exports.getUserOpOrderPath = getUserOpOrderPath;
8
+ exports.getUserOp = getUserOp;
9
+ exports.signIntent = signIntent;
10
+ exports.signUserOp = signUserOp;
11
+ exports.submitUserOp = submitUserOp;
12
+ exports.prepareTransactionAsIntent = prepareTransactionAsIntent;
13
+ exports.submitIntentInternal = submitIntentInternal;
14
+ exports.getValidatorAccount = getValidatorAccount;
15
+ const viem_1 = require("viem");
16
+ const account_abstraction_1 = require("viem/account-abstraction");
17
+ const accounts_1 = require("../accounts");
18
+ const utils_1 = require("../accounts/utils");
19
+ const validators_1 = require("../modules/validators");
20
+ const core_1 = require("../modules/validators/core");
21
+ const orchestrator_1 = require("../orchestrator");
22
+ const consts_1 = require("../orchestrator/consts");
23
+ const registry_1 = require("../orchestrator/registry");
24
+ const smart_session_1 = require("./smart-session");
25
+ async function prepareTransaction(config, transaction) {
26
+ const { sourceChain, targetChain, tokenRequests, signers } = getTransactionParams(transaction);
27
+ const accountAddress = (0, accounts_1.getAddress)(config);
28
+ let bundleData;
29
+ if (signers) {
30
+ if (!sourceChain) {
31
+ throw new Error(`Specifying source chain is required when using smart sessions or guardians`);
32
+ }
33
+ // Smart sessions require a UserOp flow
34
+ bundleData = await prepareTransactionAsUserOp(config, sourceChain, targetChain, transaction.calls, transaction.gasLimit, tokenRequests, accountAddress, signers);
35
+ }
36
+ else {
37
+ bundleData = await prepareTransactionAsIntent(config, sourceChain, targetChain, transaction.calls, transaction.gasLimit, tokenRequests, accountAddress);
38
+ }
39
+ return {
40
+ bundleData,
41
+ transaction,
42
+ };
43
+ }
44
+ async function signTransaction(config, preparedTransaction) {
45
+ const { sourceChain, targetChain, signers } = getTransactionParams(preparedTransaction.transaction);
46
+ const withSession = signers?.type === 'session' ? signers.session : null;
47
+ const bundleData = preparedTransaction.bundleData;
48
+ const accountAddress = (0, accounts_1.getAddress)(config);
49
+ let signature;
50
+ if (withSession) {
51
+ if (!sourceChain) {
52
+ throw new Error(`Specifying source chain is required when using smart sessions`);
53
+ }
54
+ const userOp = bundleData.userOp;
55
+ if (!userOp) {
56
+ throw new Error(`User operation is required when using smart sessions`);
57
+ }
58
+ // Smart sessions require a UserOp flow
59
+ signature = await signUserOp(config, sourceChain, targetChain, accountAddress, signers, userOp, bundleData.orderPath);
60
+ }
61
+ else {
62
+ signature = await signIntent(config, sourceChain, targetChain, bundleData.hash);
63
+ }
64
+ return {
65
+ bundleData,
66
+ transaction: preparedTransaction.transaction,
67
+ signature,
68
+ };
69
+ }
70
+ async function submitTransaction(config, signedTransaction) {
71
+ const { bundleData, transaction, signature } = signedTransaction;
72
+ const { sourceChain, targetChain, signers } = getTransactionParams(transaction);
73
+ const withSession = signers?.type === 'session' ? signers.session : null;
74
+ if (withSession) {
75
+ if (!sourceChain) {
76
+ throw new Error(`Specifying source chain is required when using smart sessions`);
77
+ }
78
+ const userOp = bundleData.userOp;
79
+ if (!userOp) {
80
+ throw new Error(`User operation is required when using smart sessions`);
81
+ }
82
+ // Smart sessions require a UserOp flow
83
+ return await submitUserOp(config, sourceChain, targetChain, userOp, bundleData.orderPath, signature);
84
+ }
85
+ else {
86
+ return await submitIntent(config, sourceChain, targetChain, bundleData.orderPath, signature);
87
+ }
88
+ }
89
+ function getTransactionParams(transaction) {
90
+ const sourceChain = 'chain' in transaction ? transaction.chain : transaction.sourceChain;
91
+ const targetChain = 'chain' in transaction ? transaction.chain : transaction.targetChain;
92
+ const initialTokenRequests = transaction.tokenRequests;
93
+ const signers = transaction.signers;
94
+ // Across requires passing some value to repay the solvers
95
+ const tokenRequests = initialTokenRequests.length === 0
96
+ ? [
97
+ {
98
+ address: viem_1.zeroAddress,
99
+ amount: 1n,
100
+ },
101
+ ]
102
+ : initialTokenRequests;
103
+ return {
104
+ sourceChain,
105
+ targetChain,
106
+ tokenRequests,
107
+ signers,
108
+ };
109
+ }
110
+ async function prepareTransactionAsUserOp(config, sourceChain, targetChain, calls, gasLimit, tokenRequests, accountAddress, signers) {
111
+ if (sourceChain.id === targetChain.id) {
112
+ throw new Error('Source and target chains cannot be the same when using user operations');
113
+ }
114
+ const orderPath = await getUserOpOrderPath(sourceChain, targetChain, tokenRequests, accountAddress, gasLimit, config.rhinestoneApiKey);
115
+ const userOp = await getUserOp(config, targetChain, signers, orderPath, calls, tokenRequests, accountAddress);
116
+ const hash = (0, account_abstraction_1.getUserOperationHash)({
117
+ userOperation: userOp,
118
+ entryPointAddress: account_abstraction_1.entryPoint07Address,
119
+ entryPointVersion: '0.7',
120
+ chainId: targetChain.id,
121
+ });
122
+ return {
123
+ orderPath,
124
+ userOp,
125
+ hash,
126
+ };
127
+ }
128
+ async function prepareTransactionAsIntent(config, sourceChain, targetChain, calls, gasLimit, tokenRequests, accountAddress) {
129
+ const accountAccessList = sourceChain
130
+ ? {
131
+ chainIds: [sourceChain.id],
132
+ }
133
+ : (0, registry_1.getDefaultAccountAccessList)();
134
+ const metaIntent = {
135
+ targetChainId: targetChain.id,
136
+ tokenTransfers: tokenRequests.map((tokenRequest) => ({
137
+ tokenAddress: tokenRequest.address,
138
+ amount: tokenRequest.amount,
139
+ })),
140
+ targetAccount: accountAddress,
141
+ targetExecutions: calls.map((call) => ({
142
+ value: call.value ?? 0n,
143
+ to: call.to,
144
+ data: call.data ?? '0x',
145
+ })),
146
+ targetGasUnits: gasLimit,
147
+ accountAccessList,
148
+ };
149
+ const orchestrator = getOrchestratorByChain(targetChain.id, config.rhinestoneApiKey);
150
+ const orderPath = await orchestrator.getOrderPath(metaIntent, accountAddress);
151
+ orderPath[0].orderBundle.segments[0].witness.execs = [
152
+ ...orderPath[0].injectedExecutions,
153
+ ...metaIntent.targetExecutions,
154
+ ];
155
+ const orderBundleHash = (0, orchestrator_1.getOrderBundleHash)(orderPath[0].orderBundle);
156
+ return {
157
+ orderPath,
158
+ hash: orderBundleHash,
159
+ };
160
+ }
161
+ async function signIntent(config, sourceChain, targetChain, bundleHash) {
162
+ const validatorModule = (0, validators_1.getOwnerValidator)(config);
163
+ const signature = await (0, accounts_1.getPackedSignature)(config, config.owners, sourceChain || targetChain, {
164
+ address: validatorModule.address,
165
+ isRoot: true,
166
+ }, bundleHash);
167
+ return signature;
168
+ }
169
+ async function signUserOp(config, sourceChain, targetChain, accountAddress, signers, userOp, orderPath) {
170
+ const validator = getValidator(config, signers);
171
+ if (!validator) {
172
+ throw new Error('Validator not available');
173
+ }
174
+ const targetPublicClient = (0, viem_1.createPublicClient)({
175
+ chain: targetChain,
176
+ transport: (0, viem_1.http)(),
177
+ });
178
+ const targetAccount = await getValidatorAccount(config, signers, targetPublicClient, targetChain);
179
+ if (!targetAccount) {
180
+ throw new Error('No account found');
181
+ }
182
+ userOp.signature = await targetAccount.signUserOperation(userOp);
183
+ const userOpHash = (0, account_abstraction_1.getUserOperationHash)({
184
+ userOperation: userOp,
185
+ chainId: targetChain.id,
186
+ entryPointAddress: account_abstraction_1.entryPoint07Address,
187
+ entryPointVersion: '0.7',
188
+ });
189
+ orderPath[0].orderBundle.segments[0].witness.userOpHash = userOpHash;
190
+ const { hash, appDomainSeparator, contentsType, structHash } = await (0, smart_session_1.hashErc7739)(sourceChain, orderPath, accountAddress);
191
+ const owners = getOwners(signers);
192
+ if (!owners) {
193
+ throw new Error('No owners found');
194
+ }
195
+ const signature = await (0, accounts_1.getPackedSignature)(config, owners, targetChain, {
196
+ address: validator.address,
197
+ isRoot: false,
198
+ }, hash, (signature) => {
199
+ const sessionData = signers?.type === 'session' ? signers.session : null;
200
+ return sessionData
201
+ ? (0, smart_session_1.getSessionSignature)(signature, appDomainSeparator, structHash, contentsType, sessionData)
202
+ : signature;
203
+ });
204
+ return signature;
205
+ }
206
+ async function submitUserOp(config, sourceChain, targetChain, userOp, orderPath, signature) {
207
+ const signedOrderBundle = {
208
+ ...orderPath[0].orderBundle,
209
+ originSignatures: Array(orderPath[0].orderBundle.segments.length).fill(signature),
210
+ targetSignature: signature,
211
+ };
212
+ const orchestrator = getOrchestratorByChain(targetChain.id, config.rhinestoneApiKey);
213
+ const bundleResults = await orchestrator.postSignedOrderBundle([
214
+ {
215
+ signedOrderBundle,
216
+ userOp,
217
+ },
218
+ ]);
219
+ return {
220
+ type: 'bundle',
221
+ id: bundleResults[0].bundleId,
222
+ sourceChain: sourceChain.id,
223
+ targetChain: targetChain.id,
224
+ };
225
+ }
226
+ async function submitIntent(config, sourceChain, targetChain, orderPath, signature) {
227
+ return submitIntentInternal(config, sourceChain, targetChain, orderPath, signature, false);
228
+ }
229
+ function getOrchestratorByChain(chainId, apiKey) {
230
+ const orchestratorUrl = (0, registry_1.isTestnet)(chainId)
231
+ ? consts_1.DEV_ORCHESTRATOR_URL
232
+ : consts_1.PROD_ORCHESTRATOR_URL;
233
+ return (0, orchestrator_1.getOrchestrator)(apiKey, orchestratorUrl);
234
+ }
235
+ async function getUserOpOrderPath(sourceChain, targetChain, tokenRequests, accountAddress, gasLimit, rhinestoneApiKey) {
236
+ const accountAccessList = sourceChain
237
+ ? {
238
+ chainIds: [sourceChain.id],
239
+ }
240
+ : (0, registry_1.getDefaultAccountAccessList)();
241
+ const metaIntent = {
242
+ targetChainId: targetChain.id,
243
+ tokenTransfers: tokenRequests.map((tokenRequest) => ({
244
+ tokenAddress: tokenRequest.address,
245
+ amount: tokenRequest.amount,
246
+ })),
247
+ targetAccount: accountAddress,
248
+ targetGasUnits: gasLimit,
249
+ userOp: (0, orchestrator_1.getEmptyUserOp)(),
250
+ accountAccessList,
251
+ };
252
+ const orchestrator = getOrchestratorByChain(targetChain.id, rhinestoneApiKey);
253
+ const orderPath = await orchestrator.getOrderPath(metaIntent, accountAddress);
254
+ return orderPath;
255
+ }
256
+ async function getUserOp(config, targetChain, signers, orderPath, calls, tokenRequests, accountAddress) {
257
+ const targetPublicClient = (0, viem_1.createPublicClient)({
258
+ chain: targetChain,
259
+ transport: (0, viem_1.http)(),
260
+ });
261
+ const targetAccount = await getValidatorAccount(config, signers, targetPublicClient, targetChain);
262
+ if (!targetAccount) {
263
+ throw new Error('No account found');
264
+ }
265
+ const targetBundlerClient = (0, utils_1.getBundlerClient)(config, targetPublicClient);
266
+ return await targetBundlerClient.prepareUserOperation({
267
+ account: targetAccount,
268
+ calls: [...orderPath[0].injectedExecutions, ...calls],
269
+ stateOverride: [
270
+ ...tokenRequests.map((request) => {
271
+ const rootBalanceSlot = (0, registry_1.getTokenRootBalanceSlot)(targetChain, request.address);
272
+ const balanceSlot = rootBalanceSlot
273
+ ? (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: 'address' }, { type: 'uint256' }], [accountAddress, rootBalanceSlot]))
274
+ : '0x';
275
+ return {
276
+ address: request.address,
277
+ stateDiff: [
278
+ {
279
+ slot: balanceSlot,
280
+ value: (0, viem_1.pad)((0, viem_1.toHex)(request.amount)),
281
+ },
282
+ ],
283
+ };
284
+ }),
285
+ ],
286
+ });
287
+ }
288
+ async function submitIntentInternal(config, sourceChain, targetChain, orderPath, signature, deploy) {
289
+ const signedOrderBundle = {
290
+ ...orderPath[0].orderBundle,
291
+ originSignatures: Array(orderPath[0].orderBundle.segments.length).fill(signature),
292
+ targetSignature: signature,
293
+ };
294
+ if (deploy) {
295
+ await (0, accounts_1.deployTarget)(targetChain, config, false);
296
+ }
297
+ const initCode = (0, accounts_1.getBundleInitCode)(config);
298
+ const orchestrator = getOrchestratorByChain(targetChain.id, config.rhinestoneApiKey);
299
+ const bundleResults = await orchestrator.postSignedOrderBundle([
300
+ {
301
+ signedOrderBundle,
302
+ initCode,
303
+ },
304
+ ]);
305
+ return {
306
+ type: 'bundle',
307
+ id: bundleResults[0].bundleId,
308
+ sourceChain: sourceChain?.id,
309
+ targetChain: targetChain.id,
310
+ };
311
+ }
312
+ async function getValidatorAccount(config, signers, publicClient, chain) {
313
+ if (!signers) {
314
+ return undefined;
315
+ }
316
+ const withSession = signers.type === 'session' ? signers.session : null;
317
+ const withGuardians = signers.type === 'guardians' ? signers : null;
318
+ return withSession
319
+ ? await (0, accounts_1.getSmartSessionSmartAccount)(config, publicClient, chain, withSession)
320
+ : withGuardians
321
+ ? await (0, accounts_1.getGuardianSmartAccount)(config, publicClient, chain, {
322
+ type: 'ecdsa',
323
+ accounts: withGuardians.guardians,
324
+ })
325
+ : null;
326
+ }
327
+ function getValidator(config, signers) {
328
+ if (!signers) {
329
+ return undefined;
330
+ }
331
+ const withSession = signers.type === 'session' ? signers.session : null;
332
+ const withGuardians = signers.type === 'guardians' ? signers : null;
333
+ return withSession
334
+ ? (0, validators_1.getSmartSessionValidator)(config)
335
+ : withGuardians
336
+ ? (0, core_1.getSocialRecoveryValidator)(withGuardians.guardians)
337
+ : undefined;
338
+ }
339
+ function getOwners(signers) {
340
+ if (!signers) {
341
+ return undefined;
342
+ }
343
+ const withSession = signers.type === 'session' ? signers.session : null;
344
+ const withGuardians = signers.type === 'guardians' ? signers : null;
345
+ return withSession
346
+ ? withSession.owners.type === 'ecdsa'
347
+ ? withSession.owners
348
+ : undefined
349
+ : withGuardians
350
+ ? {
351
+ type: 'ecdsa',
352
+ accounts: withGuardians.guardians,
353
+ }
354
+ : undefined;
355
+ }
@@ -1,34 +1,30 @@
1
1
  import type { Address, Chain } from 'viem';
2
+ import { UserOperationReceipt } from 'viem/account-abstraction';
3
+ import { addOwner, recover, removeOwner, setThreshold, setUpRecovery } from './actions';
2
4
  import type { TransactionResult } from './execution';
3
- import type { BundleStatus, MetaIntent, MultiChainCompact, PostOrderBundleResult, SignedMultiChainCompact } from './orchestrator';
5
+ import { BundleData, PreparedTransactionData, SignedTransactionData } from './execution/utils';
6
+ import type { BundleResult, BundleStatus, MetaIntent, MultiChainCompact, PostOrderBundleResult, SignedMultiChainCompact, UserTokenBalance } from './orchestrator';
4
7
  import type { Call, Execution, RhinestoneAccountConfig, Session, Transaction } from './types';
8
+ interface RhinestoneAccount {
9
+ config: RhinestoneAccountConfig;
10
+ deploy: (chain: Chain, session?: Session) => Promise<void>;
11
+ prepareTransaction: (transaction: Transaction) => Promise<PreparedTransactionData>;
12
+ signTransaction: (preparedTransaction: PreparedTransactionData) => Promise<SignedTransactionData>;
13
+ submitTransaction: (signedTransaction: SignedTransactionData) => Promise<TransactionResult>;
14
+ sendTransaction: (transaction: Transaction) => Promise<TransactionResult>;
15
+ waitForExecution: (result: TransactionResult, acceptsPreconfirmations?: boolean) => Promise<BundleResult | UserOperationReceipt>;
16
+ getAddress: () => Address;
17
+ getPortfolio: (onTestnets?: boolean) => Promise<UserTokenBalance[]>;
18
+ getMaxSpendableAmount: (chain: Chain, tokenAddress: Address, gasUnits: bigint) => Promise<bigint>;
19
+ deploySource: (chain: Chain) => Promise<void>;
20
+ }
5
21
  /**
6
22
  * Initialize a Rhinestone account
7
23
  * Note: accounts are deployed onchain only when the first transaction is sent.
8
24
  * @param config Account config (e.g. implementation vendor, owner signers, smart sessions)
9
25
  * @returns account
10
26
  */
11
- declare function createRhinestoneAccount(config: RhinestoneAccountConfig): Promise<{
12
- config: RhinestoneAccountConfig;
13
- sendTransaction: (transaction: Transaction) => Promise<TransactionResult>;
14
- waitForExecution: (result: TransactionResult, acceptsPreconfirmations?: boolean) => Promise<import("./orchestrator").BundleResult | {
15
- actualGasCost: bigint;
16
- actualGasUsed: bigint;
17
- entryPoint: Address;
18
- logs: import("viem").Log<bigint, number, false>[];
19
- nonce: bigint;
20
- paymaster?: `0x${string}` | undefined;
21
- reason?: string | undefined | undefined;
22
- receipt: import("viem").TransactionReceipt<bigint, number, "success" | "reverted">;
23
- sender: Address;
24
- success: boolean;
25
- userOpHash: import("viem").Hash;
26
- }>;
27
- getAddress: () => `0x${string}`;
28
- getPortfolio: (onTestnets?: boolean) => Promise<import("./orchestrator").UserTokenBalance[]>;
29
- getMaxSpendableAmount: (chain: Chain, tokenAddress: Address, gasUnits: bigint) => Promise<bigint>;
30
- deploySource: (chain: Chain) => Promise<void>;
31
- }>;
32
- export { createRhinestoneAccount };
33
- export type { BundleStatus, Session, Call, Execution, MetaIntent, MultiChainCompact, PostOrderBundleResult, SignedMultiChainCompact, };
27
+ declare function createRhinestoneAccount(config: RhinestoneAccountConfig): Promise<RhinestoneAccount>;
28
+ export { createRhinestoneAccount, addOwner, recover, removeOwner, setThreshold, setUpRecovery, };
29
+ export type { RhinestoneAccount, BundleStatus, Session, Call, Execution, MetaIntent, MultiChainCompact, PostOrderBundleResult, SignedMultiChainCompact, BundleData, PreparedTransactionData, SignedTransactionData, TransactionResult, };
34
30
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AAE1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAOpD,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EACV,IAAI,EACJ,SAAS,EACT,uBAAuB,EACvB,OAAO,EACP,WAAW,EACZ,MAAM,SAAS,CAAA;AAEhB;;;;;GAKG;AACH,iBAAe,uBAAuB,CAAC,MAAM,EAAE,uBAAuB;;mCAM9B,WAAW;+BAWvC,iBAAiB;;;;;;;;;;;;;;;mCA+BlB,KAAK,gBACE,OAAO,YACX,MAAM;0BAKW,KAAK;GAanC;AAED,OAAO,EAAE,uBAAuB,EAAE,CAAA;AAClC,YAAY,EACV,YAAY,EACZ,OAAO,EACP,IAAI,EACJ,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,GACxB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAM/D,OAAO,EACL,QAAQ,EACR,OAAO,EACP,WAAW,EACX,YAAY,EACZ,aAAa,EACd,MAAM,WAAW,CAAA;AAClB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAOpD,OAAO,EACL,UAAU,EACV,uBAAuB,EAEvB,qBAAqB,EAGtB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,gBA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AuB,EACvB,QAAQ,EACR,OAAO,EACP,WAAW,EACX,YAAY,EACZ,aAAa,GACd,CAAA;AACD,YAAY,EACV,iBAAiB,EACjB,YAAY,EACZ,OAAO,EACP,IAAI,EACJ,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,UAAU,EACV,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,GAClB,CAAA"}
package/dist/src/index.js CHANGED
@@ -1,8 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setUpRecovery = exports.setThreshold = exports.removeOwner = exports.recover = exports.addOwner = void 0;
3
4
  exports.createRhinestoneAccount = createRhinestoneAccount;
4
5
  const accounts_1 = require("./accounts");
6
+ const actions_1 = require("./actions");
7
+ Object.defineProperty(exports, "addOwner", { enumerable: true, get: function () { return actions_1.addOwner; } });
8
+ Object.defineProperty(exports, "recover", { enumerable: true, get: function () { return actions_1.recover; } });
9
+ Object.defineProperty(exports, "removeOwner", { enumerable: true, get: function () { return actions_1.removeOwner; } });
10
+ Object.defineProperty(exports, "setThreshold", { enumerable: true, get: function () { return actions_1.setThreshold; } });
11
+ Object.defineProperty(exports, "setUpRecovery", { enumerable: true, get: function () { return actions_1.setUpRecovery; } });
5
12
  const execution_1 = require("./execution");
13
+ const utils_1 = require("./execution/utils");
6
14
  /**
7
15
  * Initialize a Rhinestone account
8
16
  * Note: accounts are deployed onchain only when the first transaction is sent.
@@ -10,6 +18,18 @@ const execution_1 = require("./execution");
10
18
  * @returns account
11
19
  */
12
20
  async function createRhinestoneAccount(config) {
21
+ function deploy(chain, session) {
22
+ return (0, accounts_1.deploy)(config, chain, session);
23
+ }
24
+ function prepareTransaction(transaction) {
25
+ return (0, utils_1.prepareTransaction)(config, transaction);
26
+ }
27
+ function signTransaction(preparedTransaction) {
28
+ return (0, utils_1.signTransaction)(config, preparedTransaction);
29
+ }
30
+ function submitTransaction(signedTransaction) {
31
+ return (0, utils_1.submitTransaction)(config, signedTransaction);
32
+ }
13
33
  /**
14
34
  * Sign and send a transaction
15
35
  * @param transaction Transaction to send
@@ -57,6 +77,10 @@ async function createRhinestoneAccount(config) {
57
77
  }
58
78
  return {
59
79
  config,
80
+ deploy,
81
+ prepareTransaction,
82
+ signTransaction,
83
+ submitTransaction,
60
84
  sendTransaction,
61
85
  waitForExecution,
62
86
  getAddress,
@@ -2,6 +2,7 @@ import { type Address, type Chain, type Hex } from 'viem';
2
2
  import type { RhinestoneAccountConfig } from '../types';
3
3
  import { type Module } from './common';
4
4
  import { HOOK_ADDRESS } from './omni-account';
5
+ import { getTrustAttesterCall, getTrustedAttesters } from './registry';
5
6
  import { getOwnerValidator } from './validators';
6
7
  interface WebAuthnData {
7
8
  authenticatorData: Hex;
@@ -29,5 +30,5 @@ interface ModeleSetup {
29
30
  declare function getSetup(config: RhinestoneAccountConfig): ModeleSetup;
30
31
  declare function getWebauthnValidatorSignature({ webauthn, signature, usePrecompiled, }: WebauthnValidatorSignature): `0x${string}`;
31
32
  declare function isRip7212SupportedNetwork(chain: Chain): boolean;
32
- export { HOOK_ADDRESS, getSetup, getOwnerValidator, getWebauthnValidatorSignature, isRip7212SupportedNetwork, };
33
+ export { HOOK_ADDRESS, getSetup, getTrustAttesterCall, getTrustedAttesters, getOwnerValidator, getWebauthnValidatorSignature, isRip7212SupportedNetwork, };
33
34
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../modules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EAEZ,KAAK,KAAK,EAEV,KAAK,GAAG,EAET,MAAM,MAAM,CAAA;AAYb,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAEvD,OAAO,EAGL,KAAK,MAAM,EACZ,MAAM,UAAU,CAAA;AACjB,OAAO,EACL,YAAY,EAMb,MAAM,gBAAgB,CAAA;AACvB,OAAO,EA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ADDRESS = void 0;
3
+ exports.getOwnerValidator = exports.getTrustedAttesters = exports.getTrustAttesterCall = exports.HOOK_ADDRESS = void 0;
4
4
  exports.getSetup = getSetup;
5
5
  exports.getWebauthnValidatorSignature = getWebauthnValidatorSignature;
6
6
  exports.isRip7212SupportedNetwork = isRip7212SupportedNetwork;
@@ -9,8 +9,12 @@ const chains_1 = require("viem/chains");
9
9
  const common_1 = require("./common");
10
10
  const omni_account_1 = require("./omni-account");
11
11
  Object.defineProperty(exports, "HOOK_ADDRESS", { enumerable: true, get: function () { return omni_account_1.HOOK_ADDRESS; } });
12
+ const registry_1 = require("./registry");
13
+ Object.defineProperty(exports, "getTrustAttesterCall", { enumerable: true, get: function () { return registry_1.getTrustAttesterCall; } });
14
+ Object.defineProperty(exports, "getTrustedAttesters", { enumerable: true, get: function () { return registry_1.getTrustedAttesters; } });
12
15
  const validators_1 = require("./validators");
13
16
  Object.defineProperty(exports, "getOwnerValidator", { enumerable: true, get: function () { return validators_1.getOwnerValidator; } });
17
+ const core_1 = require("./validators/core");
14
18
  const SMART_SESSION_COMPATIBILITY_FALLBACK_ADDRESS = '0x12cae64c42f362e7d5a847c2d33388373f629177';
15
19
  function getSetup(config) {
16
20
  const ownerValidator = (0, validators_1.getOwnerValidator)(config);
@@ -19,6 +23,10 @@ function getSetup(config) {
19
23
  if (smartSessionValidator) {
20
24
  validators.push(smartSessionValidator);
21
25
  }
26
+ if (config.recovery) {
27
+ const socialRecoveryValidator = (0, core_1.getSocialRecoveryValidator)(config.recovery.guardians, config.recovery.threshold);
28
+ validators.push(socialRecoveryValidator);
29
+ }
22
30
  const executors = [
23
31
  {
24
32
  address: omni_account_1.SAME_CHAIN_MODULE_ADDRESS,
@@ -0,0 +1,9 @@
1
+ import { Address, PublicClient } from 'viem';
2
+ import { RhinestoneAccountConfig } from '../types';
3
+ declare function getTrustAttesterCall(config: RhinestoneAccountConfig): {
4
+ to: `0x${string}`;
5
+ data: `0x${string}`;
6
+ };
7
+ declare function getTrustedAttesters(client: PublicClient, account: Address): Promise<readonly Address[]>;
8
+ export { getTrustAttesterCall, getTrustedAttesters };
9
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../modules/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAsB,YAAY,EAAE,MAAM,MAAM,CAAA;AAEhE,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAIlD,iBAAS,oBAAoB,CAAC,MAAM,EAAE,uBAAuB;;;EA0B5D;AAED,iBAAe,mBAAmB,CAChC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,SAAS,OAAO,EAAE,CAAC,CAyB7B;AAED,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,CAAA"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTrustAttesterCall = getTrustAttesterCall;
4
+ exports.getTrustedAttesters = getTrustedAttesters;
5
+ const viem_1 = require("viem");
6
+ const _1 = require(".");
7
+ const omni_account_1 = require("./omni-account");
8
+ function getTrustAttesterCall(config) {
9
+ const moduleSetup = (0, _1.getSetup)(config);
10
+ return {
11
+ to: omni_account_1.RHINESTONE_MODULE_REGISTRY_ADDRESS,
12
+ data: (0, viem_1.encodeFunctionData)({
13
+ abi: [
14
+ {
15
+ name: 'trustAttesters',
16
+ type: 'function',
17
+ inputs: [
18
+ {
19
+ name: 'threshold',
20
+ type: 'uint8',
21
+ },
22
+ {
23
+ name: 'attesters',
24
+ type: 'address[]',
25
+ },
26
+ ],
27
+ outputs: [],
28
+ },
29
+ ],
30
+ functionName: 'trustAttesters',
31
+ args: [moduleSetup.threshold, moduleSetup.attesters],
32
+ }),
33
+ };
34
+ }
35
+ async function getTrustedAttesters(client, account) {
36
+ return await client.readContract({
37
+ address: omni_account_1.RHINESTONE_MODULE_REGISTRY_ADDRESS,
38
+ abi: [
39
+ {
40
+ type: 'function',
41
+ stateMutability: 'view',
42
+ name: 'findTrustedAttesters',
43
+ inputs: [
44
+ {
45
+ type: 'address',
46
+ name: 'smartAccount',
47
+ },
48
+ ],
49
+ outputs: [
50
+ {
51
+ type: 'address[]',
52
+ name: 'attesters',
53
+ },
54
+ ],
55
+ },
56
+ ],
57
+ functionName: 'findTrustedAttesters',
58
+ args: [account],
59
+ });
60
+ }
@@ -1,8 +1,10 @@
1
- import { type Hex } from 'viem';
1
+ import { Account, type Address, type Hex } from 'viem';
2
2
  import type { OwnerSet, RhinestoneAccountConfig } from '../../types';
3
3
  import { type Module } from '../common';
4
+ declare const OWNABLE_VALIDATOR_ADDRESS: Address;
4
5
  declare function getOwnerValidator(config: RhinestoneAccountConfig): Module;
5
6
  declare function getMockSignature(ownerSet: OwnerSet): Hex;
6
7
  declare function getValidator(owners: OwnerSet): Module;
7
- export { getOwnerValidator, getValidator, getMockSignature };
8
+ declare function getSocialRecoveryValidator(guardians: Account[], threshold?: number): Module;
9
+ export { OWNABLE_VALIDATOR_ADDRESS, getOwnerValidator, getSocialRecoveryValidator, getValidator, getMockSignature, };
8
10
  //# sourceMappingURL=core.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../modules/validators/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,GAAG,EAIT,MAAM,MAAM,CAAA;AAEb,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAEpE,OAAO,EAA4B,KAAK,MAAM,EAAE,MAAM,WAAW,CAAA;AAwBjE,iBAAS,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,UAEzD;AAED,iBAAS,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,GAAG,CAUjD;AAED,iBAAS,YAAY,CAAC,MAAM,EAAE,QAAQ,UAarC;AAkGD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAA"}
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../modules/validators/core.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,KAAK,OAAO,EAIZ,KAAK,GAAG,EAIT,MAAM,MAAM,CAAA;AAEb,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAEpE,OAAO,EAA4B,KAAK,MAAM,EAAE,MAAM,WAAW,CAAA;AAcjE,QAAA,MAAM,yBAAyB,EAAE,OACa,CAAA;AAY9C,iBAAS,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,UAEzD;AAED,iBAAS,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,GAAG,CAUjD;AAED,iBAAS,YAAY,CAAC,MAAM,EAAE,QAAQ,UAarC;AAqFD,iBAAS,0BAA0B,CACjC,SAAS,EAAE,OAAO,EAAE,EACpB,SAAS,SAAI,GACZ,MAAM,CAsBR;AAeD,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EACjB,0BAA0B,EAC1B,YAAY,EACZ,gBAAgB,GACjB,CAAA"}
@@ -1,12 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OWNABLE_VALIDATOR_ADDRESS = void 0;
3
4
  exports.getOwnerValidator = getOwnerValidator;
5
+ exports.getSocialRecoveryValidator = getSocialRecoveryValidator;
4
6
  exports.getValidator = getValidator;
5
7
  exports.getMockSignature = getMockSignature;
6
8
  const viem_1 = require("viem");
7
9
  const common_1 = require("../common");
8
10
  const OWNABLE_VALIDATOR_ADDRESS = '0x2483DA3A338895199E5e538530213157e931Bf06';
11
+ exports.OWNABLE_VALIDATOR_ADDRESS = OWNABLE_VALIDATOR_ADDRESS;
9
12
  const WEBAUTHN_VALIDATOR_ADDRESS = '0xb9E9CcF81464482897c687Dc876606961C547A77';
13
+ const SOCIAL_RECOVERY_VALIDATOR_ADDRESS = '0xA04D053b3C8021e8D5bF641816c42dAA75D8b597';
10
14
  const ECDSA_MOCK_SIGNATURE = '0x81d4b4981670cb18f99f0b4a66446df1bf5b204d24cfcb659bf38ba27a4359b5711649ec2423c5e1247245eba2964679b6a1dbb85c992ae40b9b00c6935b02ff1b';
11
15
  const WEBAUTHN_MOCK_SIGNATURE = '0x00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000001635bc6d0f68ff895cae8a288ecf7542a6a9cd555df784b73e1e2ea7e9104b1db15e9015d280cb19527881c625fee43fd3a405d5b0d199a8c8e6589a7381209e40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97631d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f47b2274797065223a22776562617574686e2e676574222c226368616c6c656e6765223a22746278584e465339585f3442797231634d77714b724947422d5f3330613051685a36793775634d30424f45222c226f726967696e223a22687474703a2f2f6c6f63616c686f73743a33303030222c2263726f73734f726967696e223a66616c73652c20226f746865725f6b6579735f63616e5f62655f61646465645f68657265223a22646f206e6f7420636f6d7061726520636c69656e74446174614a534f4e20616761696e737420612074656d706c6174652e205365652068747470733a2f2f676f6f2e676c2f796162506578227d000000000000000000000000';
12
16
  function getOwnerValidator(config) {
@@ -103,6 +107,26 @@ function getWebAuthnValidator(webAuthnCredential) {
103
107
  type: common_1.MODULE_TYPE_ID_VALIDATOR,
104
108
  };
105
109
  }
110
+ function getSocialRecoveryValidator(guardians, threshold = 1) {
111
+ const guardianAddresses = guardians.map((guardian) => guardian.address);
112
+ guardianAddresses.sort();
113
+ return {
114
+ type: common_1.MODULE_TYPE_ID_VALIDATOR,
115
+ address: SOCIAL_RECOVERY_VALIDATOR_ADDRESS,
116
+ initData: (0, viem_1.encodeAbiParameters)([
117
+ {
118
+ type: 'uint256',
119
+ name: 'threshold',
120
+ },
121
+ {
122
+ type: 'address[]',
123
+ name: 'guardians',
124
+ },
125
+ ], [BigInt(threshold), guardianAddresses]),
126
+ deInitData: '0x',
127
+ additionalContext: '0x',
128
+ };
129
+ }
106
130
  function parsePublicKey(publicKey) {
107
131
  const bytes = typeof publicKey === 'string' ? (0, viem_1.hexToBytes)(publicKey) : publicKey;
108
132
  const offset = bytes.length === 65 ? 1 : 0;