@rhinestone/sdk 0.2.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +4 -4
  2. package/dist/accounts/index.d.ts +15515 -4
  3. package/dist/accounts/index.d.ts.map +1 -1
  4. package/dist/accounts/index.js +69 -10
  5. package/dist/accounts/nexus.d.ts +15542 -32
  6. package/dist/accounts/nexus.d.ts.map +1 -1
  7. package/dist/accounts/nexus.js +86 -65
  8. package/dist/accounts/safe.d.ts +3 -1
  9. package/dist/accounts/safe.d.ts.map +1 -1
  10. package/dist/accounts/safe.js +8 -2
  11. package/dist/examples/abi/weth.d.ts +214 -0
  12. package/dist/examples/abi/weth.d.ts.map +1 -0
  13. package/dist/examples/abi/weth.js +279 -0
  14. package/dist/examples/cross-chain-ss.d.ts +1 -0
  15. package/dist/examples/cross-chain-ss.d.ts.map +1 -0
  16. package/dist/{example.js → examples/cross-chain-ss.js} +59 -22
  17. package/dist/examples/giza.d.ts +1 -0
  18. package/dist/examples/giza.d.ts.map +1 -0
  19. package/dist/examples/giza.js +124 -0
  20. package/dist/examples/omni-account.d.ts +1 -0
  21. package/dist/examples/omni-account.d.ts.map +1 -0
  22. package/dist/examples/omni-account.js +169 -0
  23. package/dist/examples/smart-sessions.d.ts +1 -0
  24. package/dist/examples/smart-sessions.d.ts.map +1 -0
  25. package/dist/examples/smart-sessions.js +216 -0
  26. package/dist/execution/index.d.ts +28 -3
  27. package/dist/execution/index.d.ts.map +1 -1
  28. package/dist/execution/index.js +177 -47
  29. package/dist/execution/smart-session.d.ts +14 -0
  30. package/dist/execution/smart-session.d.ts.map +1 -0
  31. package/dist/execution/smart-session.js +83 -0
  32. package/dist/index.d.ts +17 -5
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +10 -10
  35. package/dist/modules/abi/smart-sessions.d.ts +42 -0
  36. package/dist/modules/abi/smart-sessions.d.ts.map +1 -0
  37. package/dist/modules/abi/smart-sessions.js +128 -0
  38. package/dist/modules/common.d.ts +16 -0
  39. package/dist/modules/common.d.ts.map +1 -0
  40. package/dist/modules/common.js +5 -0
  41. package/dist/modules/index.d.ts +7 -18
  42. package/dist/modules/index.d.ts.map +1 -1
  43. package/dist/modules/index.js +14 -119
  44. package/dist/modules/omni-account.d.ts +9 -0
  45. package/dist/modules/omni-account.d.ts.map +1 -0
  46. package/dist/modules/omni-account.js +7 -0
  47. package/dist/modules/validators.d.ts +31 -0
  48. package/dist/modules/validators.d.ts.map +1 -0
  49. package/dist/modules/validators.js +521 -0
  50. package/dist/orchestrator/client.d.ts +2 -5
  51. package/dist/orchestrator/client.d.ts.map +1 -1
  52. package/dist/orchestrator/consts.d.ts +3 -1
  53. package/dist/orchestrator/consts.d.ts.map +1 -1
  54. package/dist/orchestrator/consts.js +3 -1
  55. package/dist/orchestrator/index.d.ts +5 -3
  56. package/dist/orchestrator/index.d.ts.map +1 -1
  57. package/dist/orchestrator/index.js +5 -4
  58. package/dist/orchestrator/registry.d.ts +5 -0
  59. package/dist/orchestrator/registry.d.ts.map +1 -0
  60. package/dist/orchestrator/registry.js +187 -0
  61. package/dist/orchestrator/types.d.ts +39 -23
  62. package/dist/orchestrator/types.d.ts.map +1 -1
  63. package/dist/orchestrator/types.js +7 -6
  64. package/dist/orchestrator/utils.d.ts +8 -4
  65. package/dist/orchestrator/utils.d.ts.map +1 -1
  66. package/dist/orchestrator/utils.js +19 -5
  67. package/dist/types.d.ts +64 -4
  68. package/dist/types.d.ts.map +1 -1
  69. package/package.json +1 -1
  70. package/dist/example.d.ts +0 -1
  71. package/dist/example.d.ts.map +0 -1
@@ -0,0 +1,279 @@
1
+ export const abi = [
2
+ {
3
+ constant: true,
4
+ inputs: [],
5
+ name: 'name',
6
+ outputs: [
7
+ {
8
+ name: '',
9
+ type: 'string',
10
+ },
11
+ ],
12
+ payable: false,
13
+ stateMutability: 'view',
14
+ type: 'function',
15
+ },
16
+ {
17
+ constant: false,
18
+ inputs: [
19
+ {
20
+ name: 'guy',
21
+ type: 'address',
22
+ },
23
+ {
24
+ name: 'wad',
25
+ type: 'uint256',
26
+ },
27
+ ],
28
+ name: 'approve',
29
+ outputs: [
30
+ {
31
+ name: '',
32
+ type: 'bool',
33
+ },
34
+ ],
35
+ payable: false,
36
+ stateMutability: 'nonpayable',
37
+ type: 'function',
38
+ },
39
+ {
40
+ constant: true,
41
+ inputs: [],
42
+ name: 'totalSupply',
43
+ outputs: [
44
+ {
45
+ name: '',
46
+ type: 'uint256',
47
+ },
48
+ ],
49
+ payable: false,
50
+ stateMutability: 'view',
51
+ type: 'function',
52
+ },
53
+ {
54
+ constant: false,
55
+ inputs: [
56
+ {
57
+ name: 'src',
58
+ type: 'address',
59
+ },
60
+ {
61
+ name: 'dst',
62
+ type: 'address',
63
+ },
64
+ {
65
+ name: 'wad',
66
+ type: 'uint256',
67
+ },
68
+ ],
69
+ name: 'transferFrom',
70
+ outputs: [
71
+ {
72
+ name: '',
73
+ type: 'bool',
74
+ },
75
+ ],
76
+ payable: false,
77
+ stateMutability: 'nonpayable',
78
+ type: 'function',
79
+ },
80
+ {
81
+ constant: false,
82
+ inputs: [
83
+ {
84
+ name: 'wad',
85
+ type: 'uint256',
86
+ },
87
+ ],
88
+ name: 'withdraw',
89
+ outputs: [],
90
+ payable: false,
91
+ stateMutability: 'nonpayable',
92
+ type: 'function',
93
+ },
94
+ {
95
+ constant: true,
96
+ inputs: [],
97
+ name: 'decimals',
98
+ outputs: [
99
+ {
100
+ name: '',
101
+ type: 'uint8',
102
+ },
103
+ ],
104
+ payable: false,
105
+ stateMutability: 'view',
106
+ type: 'function',
107
+ },
108
+ {
109
+ constant: true,
110
+ inputs: [
111
+ {
112
+ name: '',
113
+ type: 'address',
114
+ },
115
+ ],
116
+ name: 'balanceOf',
117
+ outputs: [
118
+ {
119
+ name: '',
120
+ type: 'uint256',
121
+ },
122
+ ],
123
+ payable: false,
124
+ stateMutability: 'view',
125
+ type: 'function',
126
+ },
127
+ {
128
+ constant: true,
129
+ inputs: [],
130
+ name: 'symbol',
131
+ outputs: [
132
+ {
133
+ name: '',
134
+ type: 'string',
135
+ },
136
+ ],
137
+ payable: false,
138
+ stateMutability: 'view',
139
+ type: 'function',
140
+ },
141
+ {
142
+ constant: false,
143
+ inputs: [
144
+ {
145
+ name: 'dst',
146
+ type: 'address',
147
+ },
148
+ {
149
+ name: 'wad',
150
+ type: 'uint256',
151
+ },
152
+ ],
153
+ name: 'transfer',
154
+ outputs: [
155
+ {
156
+ name: '',
157
+ type: 'bool',
158
+ },
159
+ ],
160
+ payable: false,
161
+ stateMutability: 'nonpayable',
162
+ type: 'function',
163
+ },
164
+ {
165
+ constant: false,
166
+ inputs: [],
167
+ name: 'deposit',
168
+ outputs: [],
169
+ payable: true,
170
+ stateMutability: 'payable',
171
+ type: 'function',
172
+ },
173
+ {
174
+ constant: true,
175
+ inputs: [
176
+ {
177
+ name: '',
178
+ type: 'address',
179
+ },
180
+ {
181
+ name: '',
182
+ type: 'address',
183
+ },
184
+ ],
185
+ name: 'allowance',
186
+ outputs: [
187
+ {
188
+ name: '',
189
+ type: 'uint256',
190
+ },
191
+ ],
192
+ payable: false,
193
+ stateMutability: 'view',
194
+ type: 'function',
195
+ },
196
+ {
197
+ payable: true,
198
+ stateMutability: 'payable',
199
+ type: 'fallback',
200
+ },
201
+ {
202
+ anonymous: false,
203
+ inputs: [
204
+ {
205
+ indexed: true,
206
+ name: 'src',
207
+ type: 'address',
208
+ },
209
+ {
210
+ indexed: true,
211
+ name: 'guy',
212
+ type: 'address',
213
+ },
214
+ {
215
+ indexed: false,
216
+ name: 'wad',
217
+ type: 'uint256',
218
+ },
219
+ ],
220
+ name: 'Approval',
221
+ type: 'event',
222
+ },
223
+ {
224
+ anonymous: false,
225
+ inputs: [
226
+ {
227
+ indexed: true,
228
+ name: 'src',
229
+ type: 'address',
230
+ },
231
+ {
232
+ indexed: true,
233
+ name: 'dst',
234
+ type: 'address',
235
+ },
236
+ {
237
+ indexed: false,
238
+ name: 'wad',
239
+ type: 'uint256',
240
+ },
241
+ ],
242
+ name: 'Transfer',
243
+ type: 'event',
244
+ },
245
+ {
246
+ anonymous: false,
247
+ inputs: [
248
+ {
249
+ indexed: true,
250
+ name: 'dst',
251
+ type: 'address',
252
+ },
253
+ {
254
+ indexed: false,
255
+ name: 'wad',
256
+ type: 'uint256',
257
+ },
258
+ ],
259
+ name: 'Deposit',
260
+ type: 'event',
261
+ },
262
+ {
263
+ anonymous: false,
264
+ inputs: [
265
+ {
266
+ indexed: true,
267
+ name: 'src',
268
+ type: 'address',
269
+ },
270
+ {
271
+ indexed: false,
272
+ name: 'wad',
273
+ type: 'uint256',
274
+ },
275
+ ],
276
+ name: 'Withdrawal',
277
+ type: 'event',
278
+ },
279
+ ];
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=cross-chain-ss.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cross-chain-ss.d.ts","sourceRoot":"","sources":["../../examples/cross-chain-ss.ts"],"names":[],"mappings":""}
@@ -4,10 +4,10 @@
4
4
  // baseSepolia,
5
5
  // arbitrumSepolia,
6
6
  // optimismSepolia,
7
- // arbitrum,
8
- // base,
9
- // optimism,
10
7
  // sepolia,
8
+ // optimism,
9
+ // base,
10
+ // arbitrum,
11
11
  // } from 'viem/chains'
12
12
  // import {
13
13
  // Chain,
@@ -15,11 +15,14 @@
15
15
  // createWalletClient,
16
16
  // encodeFunctionData,
17
17
  // erc20Abi,
18
+ // getAbiItem,
18
19
  // Hex,
19
20
  // http,
20
21
  // parseEther,
22
+ // toFunctionSelector,
21
23
  // } from 'viem'
22
- // import { createRhinestoneAccount } from './index'
24
+ // import { createRhinestoneAccount } from '../index'
25
+ // import { Session } from '../types'
23
26
  // const fundingPrivateKey = process.env.FUNDING_PRIVATE_KEY
24
27
  // if (!fundingPrivateKey) {
25
28
  // throw new Error('FUNDING_PRIVATE_KEY is not set')
@@ -28,8 +31,12 @@
28
31
  // if (!rhinestoneApiKey) {
29
32
  // throw new Error('RHINESTONE_API_KEY is not set')
30
33
  // }
34
+ // const pimlicoApiKey = process.env.PIMLICO_API_KEY
35
+ // if (!pimlicoApiKey) {
36
+ // throw new Error('PIMLICO_API_KEY is not set')
37
+ // }
31
38
  // const sourceChain = baseSepolia
32
- // const targetChain = arbitrumSepolia
39
+ // const targetChain = optimismSepolia
33
40
  // const usdcTarget = getTokenAddress(targetChain)
34
41
  // const usdcAmount = 1n
35
42
  // const fundingAccount = privateKeyToAccount(fundingPrivateKey as Hex)
@@ -42,20 +49,44 @@
42
49
  // chain: sourceChain,
43
50
  // transport: getTransport(sourceChain),
44
51
  // })
45
- // console.log('new pks', [
46
- // generatePrivateKey(),
47
- // generatePrivateKey(),
48
- // generatePrivateKey(),
49
- // ])
50
- // const privateKeyA =
51
- // '0xc1d2bc5a55f47783735daad366cefa85a7fbd2619a2639c1f0bef7aafe6217b0'
52
+ // const useNewKeys = true
53
+ // if (!useNewKeys) {
54
+ // console.log('new pks', [
55
+ // generatePrivateKey(),
56
+ // generatePrivateKey(),
57
+ // generatePrivateKey(),
58
+ // ])
59
+ // }
60
+ // const privateKeyA = useNewKeys
61
+ // ? generatePrivateKey()
62
+ // : '0x2abb7571751edee246e21179db22388dda1fd623e1aad66552f4a3838920eb3d'
52
63
  // const accountA = privateKeyToAccount(privateKeyA)
53
- // const privateKeyB =
54
- // '0xe076077b3c53583d0eefcad6b30929cc0dfd58e9a2566cf6a059e327ec62fdbe'
64
+ // const privateKeyB = useNewKeys
65
+ // ? generatePrivateKey()
66
+ // : '0xd30440894e60fbc1d17d5967c476ab9128c19e186077c042c6d1de592075a0d9'
55
67
  // const accountB = privateKeyToAccount(privateKeyB)
56
- // const privateKeyC =
57
- // '0x34afca21087883dba533ecf1d9d705dd2ab8a1933e98db704bb7d9ff83edcaa8'
68
+ // const privateKeyC = useNewKeys
69
+ // ? generatePrivateKey()
70
+ // : '0xb63c74af219a3949cf95f5e3a3d20b0137425de053bb03e5cc0f46fe0d19f22f'
58
71
  // const accountC = privateKeyToAccount(privateKeyC)
72
+ // const session: Session = {
73
+ // owners: {
74
+ // type: 'ecdsa',
75
+ // accounts: [accountA],
76
+ // },
77
+ // // actions: [],
78
+ // actions: [
79
+ // {
80
+ // target: usdcTarget,
81
+ // selector: toFunctionSelector(
82
+ // getAbiItem({
83
+ // abi: erc20Abi,
84
+ // name: 'transfer',
85
+ // }),
86
+ // ),
87
+ // },
88
+ // ],
89
+ // }
59
90
  // const rhinestoneAccount = await createRhinestoneAccount({
60
91
  // account: {
61
92
  // type: 'nexus',
@@ -65,9 +96,13 @@
65
96
  // accounts: [accountA, accountB, accountC],
66
97
  // threshold: 2,
67
98
  // },
68
- // sessions: [],
99
+ // sessions: [session],
69
100
  // rhinestoneApiKey,
70
101
  // deployerAccount: fundingAccount,
102
+ // bundler: {
103
+ // type: 'pimlico',
104
+ // apiKey: pimlicoApiKey,
105
+ // },
71
106
  // })
72
107
  // const address = await rhinestoneAccount.getAddress()
73
108
  // console.log(address)
@@ -82,13 +117,12 @@
82
117
  // })
83
118
  // await publicClient.waitForTransactionReceipt({ hash: txHash })
84
119
  // }
85
- // const bundleId = await rhinestoneAccount.sendTransactions({
120
+ // const transactionResult = await rhinestoneAccount.sendTransactions({
86
121
  // sourceChain,
87
122
  // targetChain,
88
123
  // calls: [
89
124
  // {
90
125
  // to: usdcTarget,
91
- // value: 0n,
92
126
  // data: encodeFunctionData({
93
127
  // abi: erc20Abi,
94
128
  // functionName: 'transfer',
@@ -102,10 +136,13 @@
102
136
  // amount: usdcAmount,
103
137
  // },
104
138
  // ],
139
+ // signers: {
140
+ // type: 'session',
141
+ // session,
142
+ // },
105
143
  // })
106
- // console.log('id', bundleId)
107
- // const bundleResult = await rhinestoneAccount.waitForExecution({ id: bundleId })
108
- // console.log('status', bundleResult.status)
144
+ // const result = await rhinestoneAccount.waitForExecution(transactionResult)
145
+ // console.log('status', result)
109
146
  // function getTokenAddress(chain: Chain) {
110
147
  // switch (chain.id) {
111
148
  // case sepolia.id:
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=giza.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"giza.d.ts","sourceRoot":"","sources":["../../examples/giza.ts"],"names":[],"mappings":""}
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ // import { baseSepolia } from 'viem/chains'
3
+ // import { createRhinestoneAccount } from '../index'
4
+ // import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'
5
+ // import {
6
+ // createPublicClient,
7
+ // createWalletClient,
8
+ // encodeFunctionData,
9
+ // erc20Abi,
10
+ // http,
11
+ // parseEther,
12
+ // zeroAddress,
13
+ // } from 'viem'
14
+ // import { Session } from '../types'
15
+ // const rhinestoneApiKey = 'YOUR_RHINESTONE_API_KEY'
16
+ // const chain = baseSepolia
17
+ // const weth = '0x4200000000000000000000000000000000000006'
18
+ // const wethAmount = 1n
19
+ // const publicClient = createPublicClient({
20
+ // chain,
21
+ // transport: http(),
22
+ // })
23
+ // const fundingAccount = privateKeyToAccount('0x_YOUR_PRIVATE_KEY')
24
+ // const fundingClient = createWalletClient({
25
+ // account: fundingAccount,
26
+ // chain,
27
+ // transport: http(),
28
+ // })
29
+ // const fundingAccountBalance = await publicClient.getBalance({
30
+ // address: fundingAccount.address,
31
+ // })
32
+ // if (fundingAccountBalance === 0n) {
33
+ // throw new Error(
34
+ // `Please fund the account ${fundingAccount.address} with base sepolia ETH`,
35
+ // )
36
+ // }
37
+ // const ownerAccount = privateKeyToAccount(generatePrivateKey())
38
+ // const sessionSignerAccount = privateKeyToAccount(generatePrivateKey())
39
+ // const session: Session = {
40
+ // owners: {
41
+ // type: 'ecdsa',
42
+ // accounts: [sessionSignerAccount],
43
+ // },
44
+ // policies: [
45
+ // {
46
+ // type: 'time-frame',
47
+ // validAfter: Date.now() - 60, // 1 minute
48
+ // validUntil: Date.now() + 60 * 60 * 24, // 1 day
49
+ // },
50
+ // ],
51
+ // }
52
+ // const rhinestoneAccount = await createRhinestoneAccount({
53
+ // account: {
54
+ // type: 'nexus',
55
+ // },
56
+ // owners: {
57
+ // type: 'ecdsa',
58
+ // accounts: [ownerAccount],
59
+ // },
60
+ // sessions: [session],
61
+ // rhinestoneApiKey,
62
+ // deployerAccount: fundingAccount,
63
+ // bundler: {
64
+ // type: 'pimlico',
65
+ // apiKey: 'YOUR_PIMLICO_API_KEY',
66
+ // },
67
+ // })
68
+ // const address = await rhinestoneAccount.getAddress()
69
+ // console.log(`Smart account address: ${address}`)
70
+ // // Prefunding the smart account
71
+ // const ethBalance = await publicClient.getBalance({
72
+ // address,
73
+ // })
74
+ // if (ethBalance < parseEther('0.001')) {
75
+ // const txHash = await fundingClient.sendTransaction({
76
+ // to: address,
77
+ // value: parseEther('0.001'),
78
+ // })
79
+ // await publicClient.waitForTransactionReceipt({ hash: txHash })
80
+ // }
81
+ // const transactionResult = await rhinestoneAccount.sendTransactions({
82
+ // chain,
83
+ // calls: [
84
+ // {
85
+ // to: weth,
86
+ // data: encodeFunctionData({
87
+ // abi: [
88
+ // {
89
+ // constant: false,
90
+ // inputs: [],
91
+ // name: 'deposit',
92
+ // outputs: [],
93
+ // payable: true,
94
+ // stateMutability: 'payable',
95
+ // type: 'function',
96
+ // },
97
+ // ],
98
+ // functionName: 'deposit',
99
+ // args: [],
100
+ // }),
101
+ // value: wethAmount,
102
+ // },
103
+ // {
104
+ // to: weth,
105
+ // data: encodeFunctionData({
106
+ // abi: erc20Abi,
107
+ // functionName: 'transfer',
108
+ // args: ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', wethAmount],
109
+ // }),
110
+ // },
111
+ // ],
112
+ // tokenRequests: [
113
+ // {
114
+ // address: zeroAddress,
115
+ // amount: wethAmount,
116
+ // },
117
+ // ],
118
+ // signers: {
119
+ // type: 'session',
120
+ // session,
121
+ // },
122
+ // })
123
+ // const result = await rhinestoneAccount.waitForExecution(transactionResult)
124
+ // console.log('status', result)
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=omni-account.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"omni-account.d.ts","sourceRoot":"","sources":["../../examples/omni-account.ts"],"names":[],"mappings":""}