@rhinestone/sdk 0.11.0 → 0.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/src/accounts/index.d.ts +5 -2
  2. package/dist/src/accounts/index.d.ts.map +1 -1
  3. package/dist/src/accounts/index.js +46 -0
  4. package/dist/src/accounts/kernel.d.ts +4 -1
  5. package/dist/src/accounts/kernel.d.ts.map +1 -1
  6. package/dist/src/accounts/kernel.js +73 -42
  7. package/dist/src/accounts/kernel.test.js +17 -0
  8. package/dist/src/accounts/nexus.d.ts +4 -1
  9. package/dist/src/accounts/nexus.d.ts.map +1 -1
  10. package/dist/src/accounts/nexus.js +37 -0
  11. package/dist/src/accounts/nexus.test.js +14 -0
  12. package/dist/src/accounts/safe.d.ts +4 -1
  13. package/dist/src/accounts/safe.d.ts.map +1 -1
  14. package/dist/src/accounts/safe.js +37 -0
  15. package/dist/src/accounts/safe.test.js +14 -0
  16. package/dist/src/actions/index.d.ts +12 -0
  17. package/dist/src/actions/index.d.ts.map +1 -0
  18. package/dist/src/actions/index.js +165 -0
  19. package/dist/src/actions/index.test.d.ts +2 -0
  20. package/dist/src/actions/index.test.d.ts.map +1 -0
  21. package/dist/src/actions/index.test.js +170 -0
  22. package/dist/src/execution/index.d.ts.map +1 -1
  23. package/dist/src/execution/index.js +22 -12
  24. package/dist/src/execution/utils.d.ts +5 -4
  25. package/dist/src/execution/utils.d.ts.map +1 -1
  26. package/dist/src/execution/utils.js +84 -23
  27. package/dist/src/index.d.ts +15 -25
  28. package/dist/src/index.d.ts.map +1 -1
  29. package/dist/src/modules/index.d.ts.map +1 -1
  30. package/dist/src/modules/index.js +5 -0
  31. package/dist/src/modules/validators/core.d.ts +4 -2
  32. package/dist/src/modules/validators/core.d.ts.map +1 -1
  33. package/dist/src/modules/validators/core.js +24 -0
  34. package/dist/src/orchestrator/registry.d.ts.map +1 -1
  35. package/dist/src/orchestrator/registry.js +1 -0
  36. package/dist/src/types.d.ts +11 -2
  37. package/dist/src/types.d.ts.map +1 -1
  38. package/dist/test/consts.d.ts +2 -1
  39. package/dist/test/consts.d.ts.map +1 -1
  40. package/dist/test/consts.js +3 -1
  41. package/package.json +1 -1
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addOwner = addOwner;
4
+ exports.removeOwner = removeOwner;
5
+ exports.setThreshold = setThreshold;
6
+ exports.recover = recover;
7
+ exports.setUpRecovery = setUpRecovery;
8
+ const viem_1 = require("viem");
9
+ const accounts_1 = require("../accounts");
10
+ const core_1 = require("../modules/validators/core");
11
+ function setUpRecovery({ rhinestoneAccount, guardians, threshold = 1, }) {
12
+ const module = (0, core_1.getSocialRecoveryValidator)(guardians, threshold);
13
+ const calls = (0, accounts_1.getModuleInstallationCalls)(rhinestoneAccount.config, module);
14
+ return calls;
15
+ }
16
+ async function recover(address, newOwners, chain) {
17
+ switch (newOwners.type) {
18
+ case 'ecdsa': {
19
+ return recoverEcdsaOwnership(address, newOwners, chain);
20
+ }
21
+ case 'passkey': {
22
+ throw new Error('Passkey ownership recovery is not yet supported');
23
+ }
24
+ }
25
+ }
26
+ function addOwner(owner) {
27
+ return {
28
+ to: core_1.OWNABLE_VALIDATOR_ADDRESS,
29
+ data: (0, viem_1.encodeFunctionData)({
30
+ abi: [
31
+ {
32
+ inputs: [{ internalType: 'address', name: 'owner', type: 'address' }],
33
+ name: 'addOwner',
34
+ outputs: [],
35
+ stateMutability: 'nonpayable',
36
+ type: 'function',
37
+ },
38
+ ],
39
+ functionName: 'addOwner',
40
+ args: [owner],
41
+ }),
42
+ };
43
+ }
44
+ function removeOwner(prevOwner, ownerToRemove) {
45
+ return {
46
+ to: core_1.OWNABLE_VALIDATOR_ADDRESS,
47
+ data: (0, viem_1.encodeFunctionData)({
48
+ abi: [
49
+ {
50
+ inputs: [
51
+ { internalType: 'address', name: 'prevOwner', type: 'address' },
52
+ { internalType: 'address', name: 'owner', type: 'address' },
53
+ ],
54
+ name: 'removeOwner',
55
+ outputs: [],
56
+ stateMutability: 'nonpayable',
57
+ type: 'function',
58
+ },
59
+ ],
60
+ functionName: 'removeOwner',
61
+ args: [prevOwner, ownerToRemove],
62
+ }),
63
+ };
64
+ }
65
+ function setThreshold(newThreshold) {
66
+ return {
67
+ to: core_1.OWNABLE_VALIDATOR_ADDRESS,
68
+ data: (0, viem_1.encodeFunctionData)({
69
+ abi: [
70
+ {
71
+ inputs: [
72
+ { internalType: 'uint256', name: '_threshold', type: 'uint256' },
73
+ ],
74
+ name: 'setThreshold',
75
+ outputs: [],
76
+ stateMutability: 'nonpayable',
77
+ type: 'function',
78
+ },
79
+ ],
80
+ functionName: 'setThreshold',
81
+ args: [newThreshold],
82
+ }),
83
+ };
84
+ }
85
+ async function recoverEcdsaOwnership(address, newOwners, chain) {
86
+ const publicClient = (0, viem_1.createPublicClient)({
87
+ chain,
88
+ transport: (0, viem_1.http)(),
89
+ });
90
+ // Read the existing config
91
+ const [existingOwners, existingThreshold] = await Promise.all([
92
+ publicClient.readContract({
93
+ address: core_1.OWNABLE_VALIDATOR_ADDRESS,
94
+ abi: [
95
+ {
96
+ inputs: [
97
+ { internalType: 'address', name: 'account', type: 'address' },
98
+ ],
99
+ name: 'getOwners',
100
+ outputs: [
101
+ {
102
+ internalType: 'address[]',
103
+ name: 'ownersArray',
104
+ type: 'address[]',
105
+ },
106
+ ],
107
+ stateMutability: 'view',
108
+ type: 'function',
109
+ },
110
+ ],
111
+ functionName: 'getOwners',
112
+ args: [address],
113
+ }),
114
+ publicClient.readContract({
115
+ address: core_1.OWNABLE_VALIDATOR_ADDRESS,
116
+ abi: [
117
+ {
118
+ inputs: [
119
+ { internalType: 'address', name: 'account', type: 'address' },
120
+ ],
121
+ name: 'threshold',
122
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
123
+ stateMutability: 'view',
124
+ type: 'function',
125
+ },
126
+ ],
127
+ functionName: 'threshold',
128
+ args: [address],
129
+ }),
130
+ ]);
131
+ const normalizedExistingOwners = existingOwners.map((owner) => owner.toLowerCase());
132
+ const calls = [];
133
+ // Convert new owners config to addresses and threshold
134
+ const newOwnerAddresses = newOwners.accounts
135
+ .map((account) => account.address.toLowerCase())
136
+ .sort();
137
+ const newThreshold = BigInt(newOwners.threshold ?? 1);
138
+ // Check if threshold needs to be updated
139
+ if (existingThreshold !== newThreshold) {
140
+ calls.push(setThreshold(newThreshold));
141
+ }
142
+ const ownersToAdd = newOwnerAddresses.filter((owner) => !normalizedExistingOwners.includes(owner));
143
+ const ownersToRemove = normalizedExistingOwners.filter((owner) => !newOwnerAddresses.includes(owner));
144
+ // Maintain the list as making changes to keep track of the previous owner for removals
145
+ // Note: new owners are added to the START of the linked list
146
+ let currentOwners = [...normalizedExistingOwners];
147
+ for (const owner of ownersToAdd) {
148
+ calls.push(addOwner(owner));
149
+ currentOwners.unshift(owner);
150
+ }
151
+ for (const ownerToRemove of ownersToRemove) {
152
+ const ownerIndex = currentOwners.indexOf(ownerToRemove);
153
+ let prevOwner;
154
+ if (ownerIndex === 0) {
155
+ // If it's the first owner, use the sentinel address
156
+ prevOwner = '0x0000000000000000000000000000000000000001';
157
+ }
158
+ else {
159
+ prevOwner = currentOwners[ownerIndex - 1];
160
+ }
161
+ calls.push(removeOwner(prevOwner, ownerToRemove));
162
+ currentOwners = currentOwners.filter((owner) => owner !== ownerToRemove);
163
+ }
164
+ return calls;
165
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../actions/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const viem_1 = require("viem");
4
+ const chains_1 = require("viem/chains");
5
+ const vitest_1 = require("vitest");
6
+ const consts_1 = require("../../test/consts");
7
+ const __1 = require("..");
8
+ const _1 = require(".");
9
+ const MOCK_OWNER_A = '0xd1aefebdceefc094f1805b241fa5e6db63a9181a';
10
+ const MOCK_OWNER_B = '0xeddfcb50d18f6d3d51c4f7cbca5ed6bdebc59817';
11
+ const MOCK_ACCOUNT_ADDRESS = '0x1234567890123456789012345678901234567890';
12
+ // Mock viem
13
+ vitest_1.vi.mock('viem', async (importOriginal) => {
14
+ const actual = await importOriginal();
15
+ return {
16
+ // @ts-ignore
17
+ ...actual,
18
+ createPublicClient: vitest_1.vi.fn(),
19
+ };
20
+ });
21
+ (0, vitest_1.describe)('Actions', () => {
22
+ (0, vitest_1.describe)('Add Owner', () => {
23
+ (0, vitest_1.test)('', () => {
24
+ (0, vitest_1.expect)((0, _1.addOwner)(MOCK_OWNER_A)).toEqual({
25
+ to: '0x2483DA3A338895199E5e538530213157e931Bf06',
26
+ data: '0x7065cb48000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a',
27
+ });
28
+ });
29
+ });
30
+ (0, vitest_1.describe)('Remove Owner', () => {
31
+ (0, vitest_1.test)('', () => {
32
+ (0, vitest_1.expect)((0, _1.removeOwner)(MOCK_OWNER_A, MOCK_OWNER_B)).toEqual({
33
+ to: '0x2483DA3A338895199E5e538530213157e931Bf06',
34
+ data: '0xfbe5ce0a000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a000000000000000000000000eddfcb50d18f6d3d51c4f7cbca5ed6bdebc59817',
35
+ });
36
+ });
37
+ });
38
+ (0, vitest_1.describe)('Set Threshold', () => {
39
+ (0, vitest_1.test)('', () => {
40
+ (0, vitest_1.expect)((0, _1.setThreshold)(1n)).toEqual({
41
+ to: '0x2483DA3A338895199E5e538530213157e931Bf06',
42
+ data: '0x960bfe040000000000000000000000000000000000000000000000000000000000000001',
43
+ });
44
+ });
45
+ });
46
+ (0, vitest_1.describe)('Set Up Recovery', async () => {
47
+ const rhinestoneAccount = await (0, __1.createRhinestoneAccount)({
48
+ owners: {
49
+ type: 'ecdsa',
50
+ accounts: [consts_1.accountA],
51
+ },
52
+ rhinestoneApiKey: consts_1.MOCK_API_KEY,
53
+ });
54
+ (0, vitest_1.test)('Single Guardian', () => {
55
+ (0, vitest_1.expect)((0, _1.setUpRecovery)({
56
+ rhinestoneAccount,
57
+ guardians: [consts_1.accountB],
58
+ threshold: 1,
59
+ })).toEqual([
60
+ {
61
+ to: '0x27d66c2e6b33579ee108206c4bc8f66bb655e69f',
62
+ data: '0x9517e29f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000a04d053b3c8021e8d5bf641816c42daa75d8b597000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7',
63
+ },
64
+ ]);
65
+ });
66
+ (0, vitest_1.test)('Guardian Multi-Sig', () => {
67
+ (0, vitest_1.expect)((0, _1.setUpRecovery)({
68
+ rhinestoneAccount,
69
+ guardians: [consts_1.accountB, consts_1.accountC, consts_1.accountD],
70
+ threshold: 2,
71
+ })).toEqual([
72
+ {
73
+ to: '0x27d66c2e6b33579ee108206c4bc8f66bb655e69f',
74
+ data: '0x9517e29f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000a04d053b3c8021e8d5bf641816c42daa75d8b597000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000030000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000c27b7578151c5ef713c62c65db09763d57ac3596000000000000000000000000c5587d912c862252599b61926adaef316ba06da0',
75
+ },
76
+ ]);
77
+ });
78
+ });
79
+ (0, vitest_1.describe)('Recover', () => {
80
+ const mockPublicClient = {
81
+ readContract: vitest_1.vi.fn(),
82
+ };
83
+ (0, vitest_1.beforeEach)(() => {
84
+ const createPublicClientMock = viem_1.createPublicClient;
85
+ createPublicClientMock.mockReturnValue(mockPublicClient);
86
+ vitest_1.vi.clearAllMocks();
87
+ });
88
+ (0, vitest_1.test)('1/1 Owners - Single owner to different single owner', async () => {
89
+ // Initial state
90
+ mockPublicClient.readContract
91
+ .mockResolvedValueOnce([consts_1.accountA.address.toLowerCase()])
92
+ .mockResolvedValueOnce(1n);
93
+ const newOwners = {
94
+ type: 'ecdsa',
95
+ accounts: [consts_1.accountB],
96
+ threshold: 1,
97
+ };
98
+ const result = await (0, _1.recover)(MOCK_ACCOUNT_ADDRESS, newOwners, chains_1.base);
99
+ (0, vitest_1.expect)(mockPublicClient.readContract).toHaveBeenCalledTimes(2);
100
+ (0, vitest_1.expect)(result).toEqual([
101
+ {
102
+ to: '0x2483DA3A338895199E5e538530213157e931Bf06',
103
+ data: '0x7065cb480000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7',
104
+ },
105
+ {
106
+ to: '0x2483DA3A338895199E5e538530213157e931Bf06',
107
+ data: '0xfbe5ce0a0000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936',
108
+ },
109
+ ]);
110
+ });
111
+ (0, vitest_1.test)('1/N Owners - Single owner to multiple owners', async () => {
112
+ // Initial state
113
+ mockPublicClient.readContract
114
+ .mockResolvedValueOnce([
115
+ consts_1.accountA.address.toLowerCase(),
116
+ consts_1.accountB.address.toLowerCase(),
117
+ consts_1.accountC.address.toLowerCase(),
118
+ ])
119
+ .mockResolvedValueOnce(1n);
120
+ const newOwners = {
121
+ type: 'ecdsa',
122
+ accounts: [consts_1.accountB, consts_1.accountC, consts_1.accountD],
123
+ threshold: 1,
124
+ };
125
+ const result = await (0, _1.recover)(MOCK_ACCOUNT_ADDRESS, newOwners, chains_1.base);
126
+ (0, vitest_1.expect)(mockPublicClient.readContract).toHaveBeenCalledTimes(2);
127
+ (0, vitest_1.expect)(result).toEqual([
128
+ {
129
+ to: '0x2483DA3A338895199E5e538530213157e931Bf06',
130
+ data: '0x7065cb48000000000000000000000000c5587d912c862252599b61926adaef316ba06da0',
131
+ },
132
+ {
133
+ to: '0x2483DA3A338895199E5e538530213157e931Bf06',
134
+ data: '0xfbe5ce0a000000000000000000000000c5587d912c862252599b61926adaef316ba06da0000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936',
135
+ },
136
+ ]);
137
+ });
138
+ (0, vitest_1.test)('M/N Owners - Multiple owners to different multiple owners', async () => {
139
+ // Initial state
140
+ mockPublicClient.readContract
141
+ .mockResolvedValueOnce([
142
+ consts_1.accountA.address.toLowerCase(),
143
+ consts_1.accountB.address.toLowerCase(),
144
+ consts_1.accountC.address.toLowerCase(),
145
+ ])
146
+ .mockResolvedValueOnce(2n);
147
+ const newOwners = {
148
+ type: 'ecdsa',
149
+ accounts: [consts_1.accountB, consts_1.accountD],
150
+ threshold: 2,
151
+ };
152
+ const result = await (0, _1.recover)(MOCK_ACCOUNT_ADDRESS, newOwners, chains_1.base);
153
+ (0, vitest_1.expect)(mockPublicClient.readContract).toHaveBeenCalledTimes(2);
154
+ (0, vitest_1.expect)(result).toEqual([
155
+ {
156
+ to: '0x2483DA3A338895199E5e538530213157e931Bf06',
157
+ data: '0x7065cb48000000000000000000000000c5587d912c862252599b61926adaef316ba06da0',
158
+ },
159
+ {
160
+ to: '0x2483DA3A338895199E5e538530213157e931Bf06',
161
+ data: '0xfbe5ce0a000000000000000000000000c5587d912c862252599b61926adaef316ba06da0000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936',
162
+ },
163
+ {
164
+ to: '0x2483DA3A338895199E5e538530213157e931Bf06',
165
+ data: '0xfbe5ce0a0000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000c27b7578151c5ef713c62c65db09763d57ac3596',
166
+ },
167
+ ]);
168
+ });
169
+ });
170
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../execution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAIX,MAAM,MAAM,CAAA;AAWb,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAYnD,OAAO,KAAK,EAEV,uBAAuB,EAIvB,WAAW,EACZ,MAAM,UAAU,CAAA;AAEjB,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAc5D,iBAAe,eAAe,CAC5B,MAAM,EAAE,uBAAuB,EAC/B,WAAW,EAAE,WAAW,8BAyBzB;AA2KD,iBAAe,gBAAgB,CAC7B,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,iBAAiB,EACzB,uBAAuB,EAAE,OAAO;;;;;;;;;;;;kBAwCjC;AAED,iBAAe,qBAAqB,CAClC,MAAM,EAAE,uBAAuB,EAC/B,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,OAAO,EACrB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CASjB;AAED,iBAAe,YAAY,CACzB,MAAM,EAAE,uBAAuB,EAC/B,UAAU,EAAE,OAAO,yDAMpB;AAED,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,GACb,CAAA;AACD,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../execution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAIX,MAAM,MAAM,CAAA;AAYb,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAYnD,OAAO,KAAK,EAEV,uBAAuB,EAIvB,WAAW,EACZ,MAAM,UAAU,CAAA;AAEjB,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAe5D,iBAAe,eAAe,CAC5B,MAAM,EAAE,uBAAuB,EAC/B,WAAW,EAAE,WAAW,8BAyBzB;AAsLD,iBAAe,gBAAgB,CAC7B,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,iBAAiB,EACzB,uBAAuB,EAAE,OAAO;;;;;;;;;;;;kBAwCjC;AAED,iBAAe,qBAAqB,CAClC,MAAM,EAAE,uBAAuB,EAC/B,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,OAAO,EACrB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CASjB;AAED,iBAAe,YAAY,CACzB,MAAM,EAAE,uBAAuB,EAC/B,UAAU,EAAE,OAAO,yDAMpB;AAED,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,GACb,CAAA;AACD,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAA"}
@@ -31,7 +31,6 @@ async function sendTransactionInternal(config, sourceChain, targetChain, calls,
31
31
  }
32
32
  }
33
33
  const accountAddress = (0, accounts_1.getAddress)(config);
34
- const withSession = signers?.type === 'session' ? signers.session : null;
35
34
  // Across requires passing some value to repay the solvers
36
35
  const tokenRequests = initialTokenRequests.length === 0
37
36
  ? [
@@ -41,29 +40,38 @@ async function sendTransactionInternal(config, sourceChain, targetChain, calls,
41
40
  },
42
41
  ]
43
42
  : initialTokenRequests;
44
- if (withSession) {
43
+ if (signers) {
45
44
  if (!sourceChain) {
46
- throw new Error(`Specifying source chain is required when using smart sessions`);
45
+ throw new Error(`Specifying source chain is required when using smart sessions or guardians`);
46
+ }
47
+ const withSession = signers?.type === 'session' ? signers.session : null;
48
+ if (withSession) {
49
+ await (0, smart_session_1.enableSmartSession)(sourceChain, config, withSession);
47
50
  }
48
- await (0, smart_session_1.enableSmartSession)(sourceChain, config, withSession);
49
51
  // Smart sessions require a UserOp flow
50
- return await sendTransactionAsUserOp(config, sourceChain, targetChain, calls, gasLimit, tokenRequests, accountAddress, withSession);
52
+ return await sendTransactionAsUserOp(config, sourceChain, targetChain, calls, gasLimit, tokenRequests, accountAddress, signers);
51
53
  }
52
54
  else {
53
55
  return await sendTransactionAsIntent(config, sourceChain, targetChain, calls, gasLimit, tokenRequests, accountAddress);
54
56
  }
55
57
  }
56
- async function sendTransactionAsUserOp(config, sourceChain, targetChain, calls, gasLimit, tokenRequests, accountAddress, withSession) {
58
+ async function sendTransactionAsUserOp(config, sourceChain, targetChain, calls, gasLimit, tokenRequests, accountAddress, signers) {
59
+ const withSession = signers?.type === 'session' ? signers.session : null;
57
60
  const publicClient = (0, viem_1.createPublicClient)({
58
61
  chain: sourceChain,
59
62
  transport: (0, viem_1.http)(),
60
63
  });
61
- const sessionAccount = await (0, accounts_1.getSmartSessionSmartAccount)(config, publicClient, sourceChain, withSession);
64
+ const validatorAccount = await (0, utils_2.getValidatorAccount)(config, signers, publicClient, sourceChain);
65
+ if (!validatorAccount) {
66
+ throw new Error('No validator account found');
67
+ }
62
68
  const bundlerClient = (0, utils_1.getBundlerClient)(config, publicClient);
63
69
  if (sourceChain.id === targetChain.id) {
64
- await (0, smart_session_1.enableSmartSession)(targetChain, config, withSession);
70
+ if (withSession) {
71
+ await (0, smart_session_1.enableSmartSession)(targetChain, config, withSession);
72
+ }
65
73
  const hash = await bundlerClient.sendUserOperation({
66
- account: sessionAccount,
74
+ account: validatorAccount,
67
75
  calls,
68
76
  });
69
77
  return {
@@ -76,9 +84,11 @@ async function sendTransactionAsUserOp(config, sourceChain, targetChain, calls,
76
84
  const orderPath = await (0, utils_2.getUserOpOrderPath)(sourceChain, targetChain, tokenRequests, accountAddress, gasLimit, config.rhinestoneApiKey);
77
85
  // Deploy the account on the target chain
78
86
  await (0, accounts_1.deployTarget)(targetChain, config, true);
79
- await (0, smart_session_1.enableSmartSession)(targetChain, config, withSession);
80
- const userOp = await (0, utils_2.getUserOp)(config, targetChain, withSession, orderPath, calls, tokenRequests, accountAddress);
81
- const signature = await (0, utils_2.signUserOp)(config, sourceChain, targetChain, accountAddress, withSession, userOp, orderPath);
87
+ if (withSession) {
88
+ await (0, smart_session_1.enableSmartSession)(targetChain, config, withSession);
89
+ }
90
+ const userOp = await (0, utils_2.getUserOp)(config, targetChain, signers, orderPath, calls, tokenRequests, accountAddress);
91
+ const signature = await (0, utils_2.signUserOp)(config, sourceChain, targetChain, accountAddress, signers, userOp, orderPath);
82
92
  return await (0, utils_2.submitUserOp)(config, sourceChain, targetChain, userOp, orderPath, signature);
83
93
  }
84
94
  async function sendTransactionAsIntent(config, sourceChain, targetChain, calls, gasLimit, tokenRequests, accountAddress) {
@@ -1,7 +1,7 @@
1
1
  import { Address, Chain, Hex } from 'viem';
2
2
  import { UserOperation } from 'viem/account-abstraction';
3
3
  import { OrderPath } from '../orchestrator/types';
4
- import { Call, RhinestoneAccountConfig, Session, TokenRequest, Transaction } from '../types';
4
+ import { Call, RhinestoneAccountConfig, SignerSet, TokenRequest, Transaction } from '../types';
5
5
  type TransactionResult = {
6
6
  type: 'userop';
7
7
  hash: Hex;
@@ -30,11 +30,11 @@ declare function signTransaction(config: RhinestoneAccountConfig, preparedTransa
30
30
  declare function submitTransaction(config: RhinestoneAccountConfig, signedTransaction: SignedTransactionData): Promise<TransactionResult>;
31
31
  declare function prepareTransactionAsIntent(config: RhinestoneAccountConfig, sourceChain: Chain | undefined, targetChain: Chain, calls: Call[], gasLimit: bigint | undefined, tokenRequests: TokenRequest[], accountAddress: Address): Promise<BundleData>;
32
32
  declare function signIntent(config: RhinestoneAccountConfig, sourceChain: Chain | undefined, targetChain: Chain, bundleHash: Hex): Promise<`0x${string}`>;
33
- declare function signUserOp(config: RhinestoneAccountConfig, sourceChain: Chain, targetChain: Chain, accountAddress: Address, withSession: Session, userOp: UserOperation, orderPath: OrderPath): Promise<`0x${string}`>;
33
+ declare function signUserOp(config: RhinestoneAccountConfig, sourceChain: Chain, targetChain: Chain, accountAddress: Address, signers: SignerSet | undefined, userOp: UserOperation, orderPath: OrderPath): Promise<`0x${string}`>;
34
34
  declare function submitUserOp(config: RhinestoneAccountConfig, sourceChain: Chain, targetChain: Chain, userOp: UserOperation, orderPath: OrderPath, signature: Hex): Promise<TransactionResult>;
35
35
  declare function getOrchestratorByChain(chainId: number, apiKey: string): import("../orchestrator").Orchestrator;
36
36
  declare function getUserOpOrderPath(sourceChain: Chain, targetChain: Chain, tokenRequests: TokenRequest[], accountAddress: Address, gasLimit: bigint | undefined, rhinestoneApiKey: string): Promise<OrderPath>;
37
- declare function getUserOp(config: RhinestoneAccountConfig, targetChain: Chain, withSession: Session, orderPath: OrderPath, calls: Call[], tokenRequests: TokenRequest[], accountAddress: Address): Promise<{
37
+ declare function getUserOp(config: RhinestoneAccountConfig, targetChain: Chain, signers: SignerSet | undefined, orderPath: OrderPath, calls: Call[], tokenRequests: TokenRequest[], accountAddress: Address): Promise<{
38
38
  readonly account: import("viem/account-abstraction").SmartAccount<import("viem/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">>;
39
39
  readonly stateOverride: {
40
40
  address: `0x${string}`;
@@ -62,6 +62,7 @@ declare function getUserOp(config: RhinestoneAccountConfig, targetChain: Chain,
62
62
  signature: UserOperation["signature"];
63
63
  }>;
64
64
  declare function submitIntentInternal(config: RhinestoneAccountConfig, sourceChain: Chain | undefined, targetChain: Chain, orderPath: OrderPath, signature: Hex, deploy: boolean): Promise<TransactionResult>;
65
- export { prepareTransaction, signTransaction, submitTransaction, getOrchestratorByChain, getUserOpOrderPath, getUserOp, signIntent, signUserOp, submitUserOp, prepareTransactionAsIntent, submitIntentInternal, };
65
+ declare function getValidatorAccount(config: RhinestoneAccountConfig, signers: SignerSet | undefined, publicClient: any, chain: Chain): Promise<import("viem/account-abstraction").SmartAccount<import("viem/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">> | null | undefined>;
66
+ export { prepareTransaction, signTransaction, submitTransaction, getOrchestratorByChain, getUserOpOrderPath, getUserOp, signIntent, signUserOp, submitUserOp, prepareTransactionAsIntent, submitIntentInternal, getValidatorAccount, };
66
67
  export type { BundleData, TransactionResult, PreparedTransactionData, SignedTransactionData, };
67
68
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../execution/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,KAAK,EAGL,GAAG,EAMJ,MAAM,MAAM,CAAA;AACb,OAAO,EAGL,aAAa,EACd,MAAM,0BAA0B,CAAA;AA2BjC,OAAO,EAEL,SAAS,EAGV,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,IAAI,EACJ,uBAAuB,EACvB,OAAO,EACP,YAAY,EACZ,WAAW,EACZ,MAAM,UAAU,CAAA;AAIjB,KAAK,iBAAiB,GAClB;IACE,IAAI,EAAE,QAAQ,CAAA;IACd,IAAI,EAAE,GAAG,CAAA;IACT,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;CACpB,GACD;IACE,IAAI,EAAE,QAAQ,CAAA;IACd,EAAE,EAAE,MAAM,CAAA;IACV,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAEL,UAAU,UAAU;IAClB,IAAI,EAAE,GAAG,CAAA;IACT,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,CAAC,EAAE,aAAa,CAAA;CACvB;AAED,UAAU,uBAAuB;IAC/B,UAAU,EAAE,UAAU,CAAA;IACtB,WAAW,EAAE,WAAW,CAAA;CACzB;AAED,UAAU,qBAAsB,SAAQ,uBAAuB;IAC7D,SAAS,EAAE,GAAG,CAAA;CACf;AAED,iBAAe,kBAAkB,CAC/B,MAAM,EAAE,uBAAuB,EAC/B,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,uBAAuB,CAAC,CAwClC;AAED,iBAAe,eAAe,CAC5B,MAAM,EAAE,uBAAuB,EAC/B,mBAAmB,EAAE,uBAAuB,GAC3C,OAAO,CAAC,qBAAqB,CAAC,CA2ChC;AAED,iBAAe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