@charterlabs/rhinestone-sdk 0.1.1 → 0.1.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 (194) hide show
  1. package/README.md +74 -181
  2. package/dist/src/accounts/error.d.ts +69 -0
  3. package/dist/src/accounts/error.d.ts.map +1 -0
  4. package/dist/src/accounts/error.js +109 -0
  5. package/dist/{accounts → src/accounts}/index.d.ts +14 -21
  6. package/dist/src/accounts/index.d.ts.map +1 -0
  7. package/dist/src/accounts/index.js +469 -0
  8. package/dist/src/accounts/index.test.d.ts +2 -0
  9. package/dist/src/accounts/index.test.d.ts.map +1 -0
  10. package/dist/src/accounts/index.test.js +36 -0
  11. package/dist/{accounts → src/accounts}/kernel.d.ts +7 -9
  12. package/dist/src/accounts/kernel.d.ts.map +1 -0
  13. package/dist/{accounts → src/accounts}/kernel.js +0 -8
  14. package/dist/src/accounts/kernel.test.d.ts +2 -0
  15. package/dist/src/accounts/kernel.test.d.ts.map +1 -0
  16. package/dist/src/accounts/kernel.test.js +105 -0
  17. package/dist/{accounts → src/accounts}/nexus.d.ts +14 -13
  18. package/dist/src/accounts/nexus.d.ts.map +1 -0
  19. package/dist/{accounts → src/accounts}/nexus.js +92 -88
  20. package/dist/src/accounts/nexus.test.d.ts +2 -0
  21. package/dist/src/accounts/nexus.test.d.ts.map +1 -0
  22. package/dist/src/accounts/nexus.test.js +87 -0
  23. package/dist/{accounts → src/accounts}/safe.d.ts +4 -6
  24. package/dist/src/accounts/safe.d.ts.map +1 -0
  25. package/dist/{accounts → src/accounts}/safe.js +20 -29
  26. package/dist/src/accounts/safe.test.d.ts +2 -0
  27. package/dist/src/accounts/safe.test.d.ts.map +1 -0
  28. package/dist/src/accounts/safe.test.js +87 -0
  29. package/dist/src/accounts/startale.d.ts +20 -0
  30. package/dist/src/accounts/startale.d.ts.map +1 -0
  31. package/dist/src/accounts/startale.js +100 -0
  32. package/dist/src/accounts/startale.test.d.ts +2 -0
  33. package/dist/src/accounts/startale.test.d.ts.map +1 -0
  34. package/dist/src/accounts/startale.test.js +99 -0
  35. package/dist/{accounts → src/accounts}/utils.d.ts +4 -3
  36. package/dist/src/accounts/utils.d.ts.map +1 -0
  37. package/dist/{accounts → src/accounts}/utils.js +44 -0
  38. package/dist/src/accounts/utils.test.d.ts +2 -0
  39. package/dist/src/accounts/utils.test.d.ts.map +1 -0
  40. package/dist/src/accounts/utils.test.js +49 -0
  41. package/dist/src/actions/index.d.ts +39 -0
  42. package/dist/src/actions/index.d.ts.map +1 -0
  43. package/dist/{actions → src/actions}/index.js +108 -15
  44. package/dist/src/actions/index.test.d.ts +2 -0
  45. package/dist/src/actions/index.test.d.ts.map +1 -0
  46. package/dist/src/actions/index.test.js +302 -0
  47. package/dist/{actions → src/actions}/smart-session.d.ts +2 -2
  48. package/dist/src/actions/smart-session.d.ts.map +1 -0
  49. package/dist/src/execution/compact.d.ts +8 -0
  50. package/dist/src/execution/compact.d.ts.map +1 -0
  51. package/dist/src/execution/compact.js +105 -0
  52. package/dist/src/execution/error.d.ts +54 -0
  53. package/dist/src/execution/error.d.ts.map +1 -0
  54. package/dist/src/execution/error.js +78 -0
  55. package/dist/{execution → src/execution}/index.d.ts +7 -6
  56. package/dist/src/execution/index.d.ts.map +1 -0
  57. package/dist/src/execution/index.js +150 -0
  58. package/dist/src/execution/smart-session.d.ts +15 -0
  59. package/dist/src/execution/smart-session.d.ts.map +1 -0
  60. package/dist/{execution → src/execution}/smart-session.js +16 -77
  61. package/dist/src/execution/smart-session.test.d.ts +2 -0
  62. package/dist/src/execution/smart-session.test.d.ts.map +1 -0
  63. package/dist/src/execution/smart-session.test.js +34 -0
  64. package/dist/src/execution/utils.d.ts +45 -0
  65. package/dist/src/execution/utils.d.ts.map +1 -0
  66. package/dist/src/execution/utils.js +433 -0
  67. package/dist/src/index.d.ts +41 -0
  68. package/dist/src/index.d.ts.map +1 -0
  69. package/dist/src/index.js +154 -0
  70. package/dist/src/modules/abi/smart-sessions.d.ts.map +1 -0
  71. package/dist/src/modules/common.d.ts.map +1 -0
  72. package/dist/{modules → src/modules}/index.d.ts +3 -11
  73. package/dist/src/modules/index.d.ts.map +1 -0
  74. package/dist/{modules → src/modules}/index.js +3 -45
  75. package/dist/src/modules/index.test.d.ts +2 -0
  76. package/dist/src/modules/index.test.d.ts.map +1 -0
  77. package/dist/src/modules/index.test.js +107 -0
  78. package/dist/src/modules/omni-account.d.ts +7 -0
  79. package/dist/src/modules/omni-account.d.ts.map +1 -0
  80. package/dist/src/modules/omni-account.js +11 -0
  81. package/dist/src/modules/read.d.ts +9 -0
  82. package/dist/src/modules/read.d.ts.map +1 -0
  83. package/dist/{modules → src/modules}/read.js +6 -37
  84. package/dist/{modules → src/modules}/validators/core.d.ts +6 -7
  85. package/dist/src/modules/validators/core.d.ts.map +1 -0
  86. package/dist/{modules → src/modules}/validators/core.js +83 -8
  87. package/dist/src/modules/validators/core.test.d.ts +2 -0
  88. package/dist/src/modules/validators/core.test.d.ts.map +1 -0
  89. package/dist/src/modules/validators/core.test.js +108 -0
  90. package/dist/src/modules/validators/index.d.ts +4 -0
  91. package/dist/src/modules/validators/index.d.ts.map +1 -0
  92. package/dist/{modules → src/modules}/validators/index.js +1 -3
  93. package/dist/{modules → src/modules}/validators/smart-sessions.d.ts +4 -15
  94. package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -0
  95. package/dist/{modules → src/modules}/validators/smart-sessions.js +7 -61
  96. package/dist/src/modules/validators/smart-sessions.test.d.ts +2 -0
  97. package/dist/src/modules/validators/smart-sessions.test.d.ts.map +1 -0
  98. package/dist/src/modules/validators/smart-sessions.test.js +226 -0
  99. package/dist/src/orchestrator/client.d.ts +21 -0
  100. package/dist/src/orchestrator/client.d.ts.map +1 -0
  101. package/dist/src/orchestrator/client.js +284 -0
  102. package/dist/src/orchestrator/consts.d.ts +5 -0
  103. package/dist/src/orchestrator/consts.d.ts.map +1 -0
  104. package/dist/src/orchestrator/consts.js +9 -0
  105. package/dist/src/orchestrator/error.d.ts +96 -0
  106. package/dist/src/orchestrator/error.d.ts.map +1 -0
  107. package/dist/src/orchestrator/error.js +132 -0
  108. package/dist/src/orchestrator/index.d.ts +11 -0
  109. package/dist/src/orchestrator/index.d.ts.map +1 -0
  110. package/dist/src/orchestrator/index.js +42 -0
  111. package/dist/src/orchestrator/registry.d.ts +39 -0
  112. package/dist/src/orchestrator/registry.d.ts.map +1 -0
  113. package/dist/src/orchestrator/registry.js +121 -0
  114. package/dist/src/orchestrator/registry.json +365 -0
  115. package/dist/src/orchestrator/registry.test.d.ts +2 -0
  116. package/dist/src/orchestrator/registry.test.d.ts.map +1 -0
  117. package/dist/src/orchestrator/registry.test.js +137 -0
  118. package/dist/src/orchestrator/types.d.ts +275 -0
  119. package/dist/src/orchestrator/types.d.ts.map +1 -0
  120. package/dist/src/orchestrator/types.js +19 -0
  121. package/dist/src/orchestrator/utils.d.ts +5 -0
  122. package/dist/src/orchestrator/utils.d.ts.map +1 -0
  123. package/dist/src/orchestrator/utils.js +126 -0
  124. package/dist/{types.d.ts → src/types.d.ts} +42 -21
  125. package/dist/src/types.d.ts.map +1 -0
  126. package/dist/test/consts.d.ts +10 -0
  127. package/dist/test/consts.d.ts.map +1 -0
  128. package/dist/test/consts.js +22 -0
  129. package/package.json +11 -20
  130. package/dist/accounts/index.d.ts.map +0 -1
  131. package/dist/accounts/index.js +0 -419
  132. package/dist/accounts/kernel.d.ts.map +0 -1
  133. package/dist/accounts/nexus.d.ts.map +0 -1
  134. package/dist/accounts/safe.d.ts.map +0 -1
  135. package/dist/accounts/utils.d.ts.map +0 -1
  136. package/dist/actions/index.d.ts +0 -29
  137. package/dist/actions/index.d.ts.map +0 -1
  138. package/dist/actions/registry.d.ts +0 -7
  139. package/dist/actions/registry.d.ts.map +0 -1
  140. package/dist/actions/registry.js +0 -7
  141. package/dist/actions/smart-session.d.ts.map +0 -1
  142. package/dist/execution/index.d.ts.map +0 -1
  143. package/dist/execution/index.js +0 -149
  144. package/dist/execution/smart-session.d.ts +0 -23
  145. package/dist/execution/smart-session.d.ts.map +0 -1
  146. package/dist/execution/utils.d.ts +0 -68
  147. package/dist/execution/utils.d.ts.map +0 -1
  148. package/dist/execution/utils.js +0 -482
  149. package/dist/index.d.ts +0 -38
  150. package/dist/index.d.ts.map +0 -1
  151. package/dist/index.js +0 -119
  152. package/dist/modules/abi/smart-sessions.d.ts.map +0 -1
  153. package/dist/modules/common.d.ts.map +0 -1
  154. package/dist/modules/index.d.ts.map +0 -1
  155. package/dist/modules/omni-account.d.ts +0 -9
  156. package/dist/modules/omni-account.d.ts.map +0 -1
  157. package/dist/modules/omni-account.js +0 -15
  158. package/dist/modules/read.d.ts +0 -10
  159. package/dist/modules/read.d.ts.map +0 -1
  160. package/dist/modules/registry.d.ts +0 -9
  161. package/dist/modules/registry.d.ts.map +0 -1
  162. package/dist/modules/registry.js +0 -60
  163. package/dist/modules/validators/core.d.ts.map +0 -1
  164. package/dist/modules/validators/index.d.ts +0 -4
  165. package/dist/modules/validators/index.d.ts.map +0 -1
  166. package/dist/modules/validators/smart-sessions.d.ts.map +0 -1
  167. package/dist/orchestrator/client.d.ts +0 -29
  168. package/dist/orchestrator/client.d.ts.map +0 -1
  169. package/dist/orchestrator/client.js +0 -250
  170. package/dist/orchestrator/consts.d.ts +0 -5
  171. package/dist/orchestrator/consts.d.ts.map +0 -1
  172. package/dist/orchestrator/consts.js +0 -9
  173. package/dist/orchestrator/error.d.ts +0 -18
  174. package/dist/orchestrator/error.d.ts.map +0 -1
  175. package/dist/orchestrator/error.js +0 -33
  176. package/dist/orchestrator/index.d.ts +0 -11
  177. package/dist/orchestrator/index.d.ts.map +0 -1
  178. package/dist/orchestrator/index.js +0 -40
  179. package/dist/orchestrator/registry.d.ts +0 -20
  180. package/dist/orchestrator/registry.d.ts.map +0 -1
  181. package/dist/orchestrator/registry.js +0 -444
  182. package/dist/orchestrator/types.d.ts +0 -242
  183. package/dist/orchestrator/types.d.ts.map +0 -1
  184. package/dist/orchestrator/types.js +0 -19
  185. package/dist/orchestrator/utils.d.ts +0 -29
  186. package/dist/orchestrator/utils.d.ts.map +0 -1
  187. package/dist/orchestrator/utils.js +0 -319
  188. package/dist/types.d.ts.map +0 -1
  189. /package/dist/{actions → src/actions}/smart-session.js +0 -0
  190. /package/dist/{modules → src/modules}/abi/smart-sessions.d.ts +0 -0
  191. /package/dist/{modules → src/modules}/abi/smart-sessions.js +0 -0
  192. /package/dist/{modules → src/modules}/common.d.ts +0 -0
  193. /package/dist/{modules → src/modules}/common.js +0 -0
  194. /package/dist/{types.js → src/types.js} +0 -0
package/README.md CHANGED
@@ -1,214 +1,107 @@
1
- # Rhinestone SDK
1
+ # @charterlabs/rhinestone-sdk
2
2
 
3
- End-to-end chain abstraction and modularity toolkit
3
+ A production-ready fork of the Rhinestone SDK with enhanced WebAuthn support for Charter Labs.
4
4
 
5
- ## Usage
5
+ ## 🚀 Enhanced Features
6
6
 
7
- ### Installation
7
+ ### Superior WebAuthn Implementation
8
+ - **Multi-credential support** - Register multiple WebAuthn devices per account
9
+ - **Threshold signatures** - M-of-N security model for enterprise use
10
+ - **User verification control** - Configurable UV requirements per credential
11
+ - **WebAuthn standard compliance** - Proper credential ID handling
12
+ - **Production-ready** - Handles real-world multi-device scenarios
8
13
 
9
- ```bash
10
- npm install viem @rhinestone/sdk
11
- ```
14
+ ### Key Improvements Over Upstream
15
+ - **Multi-device support** vs single credential limitation
16
+ - ✅ **WebAuthn standard compliance** vs non-standard hashing
17
+ - ✅ **Security flexibility** vs fixed UV policies
18
+ - ✅ **Enterprise features** vs demo/MVP approach
12
19
 
13
- ```bash
14
- pnpm install viem @rhinestone/sdk
15
- ```
20
+ ## Installation
16
21
 
17
22
  ```bash
18
- yarn add viem @rhinestone/sdk
23
+ npm install @charterlabs/rhinestone-sdk viem
24
+ # or
25
+ bun add @charterlabs/rhinestone-sdk viem
19
26
  ```
20
27
 
21
- ```bash
22
- bun install viem @rhinestone/sdk
23
- ```
24
-
25
- ## Quickstart
26
-
27
- You'll need a Rhinestone API key, as well as an existing account with some testnet ETH on the source chain.
28
-
29
- ### Creating a Wallet
28
+ ## Quick Start
30
29
 
31
- Let's create a smart account with a single owner:
32
-
33
- ```ts
34
- import { createRhinestoneAccount } from '@rhinestone/sdk'
30
+ ```typescript
31
+ import { createRhinestoneAccount } from '@charterlabs/rhinestone-sdk'
35
32
  import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'
36
- import { baseSepolia, arbitrumSepolia, optimismSepolia } from 'viem/chains'
37
- import {
38
- Chain,
39
- createPublicClient,
40
- createWalletClient,
41
- encodeFunctionData,
42
- erc20Abi,
43
- Hex,
44
- http,
45
- parseEther,
46
- } from 'viem'
47
-
48
- const fundingPrivateKey = process.env.FUNDING_PRIVATE_KEY
49
- if (!fundingPrivateKey) {
50
- throw new Error('FUNDING_PRIVATE_KEY is not set')
51
- }
52
-
53
- const rhinestoneApiKey = process.env.RHINESTONE_API_KEY
54
- if (!rhinestoneApiKey) {
55
- throw new Error('RHINESTONE_API_KEY is not set')
56
- }
57
-
58
- const sourceChain = baseSepolia
59
- const targetChain = arbitrumSepolia
60
-
61
- // You can use an existing PK here
62
- const privateKey = generatePrivateKey()
63
- console.info(`Owner private key: ${privateKey}`)
64
- const account = privateKeyToAccount(privateKey)
65
33
 
34
+ // Create account with WebAuthn support
66
35
  const rhinestoneAccount = await createRhinestoneAccount({
67
36
  owners: {
68
- type: 'ecdsa',
69
- accounts: [account],
70
- }
71
- rhinestoneApiKey,
37
+ type: 'passkey',
38
+ account: webAuthnAccount, // Your WebAuthn account
39
+ credentialIds: ['0x...', '0x...'] // Multiple credential IDs
40
+ },
41
+ rhinestoneApiKey: 'your-api-key'
72
42
  })
73
- const address = await rhinestoneAccount.getAddress()
74
- console.info(`Smart account address: ${address}`)
75
43
  ```
76
44
 
77
- ### Funding the Account
78
-
79
- We will send some ETH from the funding account to the created smart account. The Orchestrator will use some of that ETH to deploy the account on the target chain, as well as to convert it to USDC for a transfer transaction.
80
-
81
- ```ts
82
- const publicClient = createPublicClient({
83
- chain: sourceChain,
84
- transport: http(),
85
- });
86
- const fundingAccount = privateKeyToAccount(fundingPrivateKey as Hex);
87
- const fundingClient = createWalletClient({
88
- account: fundingAccount,
89
- chain: sourceChain,
90
- transport: http(),
91
- });
92
-
93
- const txHash = await fundingClient.sendTransaction({
94
- to: address,
95
- value: parseEther('0.001'),
96
- });
97
- await publicClient.waitForTransactionReceipt({ hash: txHash });
98
- ```
45
+ ## WebAuthn Features
99
46
 
100
- ### Sending a Cross-chain Transaction
101
-
102
- Finally, let's make a cross-chain token transfer:
103
-
104
- ```ts
105
- const usdcTarget = '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d';
106
- const usdcAmount = 1n;
107
-
108
- const transaction = await rhinestoneAccount.sendTransaction({
109
- sourceChain,
110
- targetChain,
111
- calls: [
112
- {
113
- to: usdcTarget,
114
- value: 0n,
115
- data: encodeFunctionData({
116
- abi: erc20Abi,
117
- functionName: 'transfer',
118
- args: ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', usdcAmount],
119
- }),
120
- },
121
- ],
122
- tokenRequests: [
123
- {
124
- address: usdcTarget,
125
- amount: usdcAmount,
126
- },
127
- ],
128
- });
129
- console.info('Transaction', transaction);
130
-
131
- const transactionResult = await rhinestoneAccount.waitForExecution(transaction);
132
- console.info('Result', transactionResult);
47
+ ### Multi-Credential Support
48
+ ```typescript
49
+ // Register multiple devices
50
+ const config = {
51
+ owners: {
52
+ type: 'passkey',
53
+ account: webAuthnAccount,
54
+ credentialIds: [
55
+ '0x1234...', // Phone
56
+ '0x5678...', // Laptop
57
+ '0x9abc...' // Security key
58
+ ]
59
+ }
60
+ }
133
61
  ```
134
62
 
135
- After running that, you will get a smart account deployed on both Base Sepolia and Arbitrum Sepolia, and make a cross-chain USDC transfer.
136
-
137
- ### Using Smart Sessions
138
-
139
- First, define a session you want to use:
140
-
141
- ```ts
142
- const session: Session = {
63
+ ### Threshold Signatures
64
+ ```typescript
65
+ // Require 2-of-3 signatures
66
+ const config = {
143
67
  owners: {
144
- type: 'ecdsa',
145
- accounts: [sessionOwner],
146
- },
147
- actions: [
148
- {
149
- target: wethAddress,
150
- selector: toFunctionSelector(
151
- getAbiItem({
152
- abi: wethAbi,
153
- name: 'deposit',
154
- }),
155
- ),
156
- },
157
- {
158
- target: wethAddress,
159
- selector: toFunctionSelector(
160
- getAbiItem({
161
- abi: wethAbi,
162
- name: 'transfer',
163
- }),
164
- ),
165
- policies: [
166
- {
167
- type: 'universal-action',
168
- rules: [
169
- {
170
- condition: 'equal',
171
- calldataOffset: 0n,
172
- referenceValue: '0xd8da6bf26964af9d7eed9e03e53415d37aa96045',
173
- },
174
- ],
175
- },
176
- ],
177
- },
178
- ],
68
+ type: 'multi-factor',
69
+ validators: [phoneValidator, laptopValidator, securityKeyValidator],
70
+ threshold: 2
71
+ }
179
72
  }
180
73
  ```
181
74
 
182
- During account initialization, provide the session you've just created. Make sure to also provide a bundler configuration.
183
-
184
- ```ts
185
- const rhinestoneAccount = await createRhinestoneAccount({
186
- //
187
- sessions: [session],
188
- bundler: {
189
- // …
190
- },
75
+ ### User Verification Control
76
+ ```typescript
77
+ // Configure UV requirements per credential
78
+ const validator = getWebAuthnValidator({
79
+ pubKey: publicKey,
80
+ authenticatorId: 'device-id',
81
+ requireUV: true // Require user verification
191
82
  })
192
83
  ```
193
84
 
194
- When making a transaction, specify the `signers` object to sign it with the session key:
85
+ ## Development
195
86
 
196
- ```ts
197
- const transactionResult = await rhinestoneAccount.sendTransaction({
198
- //
199
- signers: {
200
- type: 'session',
201
- session: session,
202
- },
203
- })
204
- ```
87
+ ```bash
88
+ # Install dependencies
89
+ bun install
205
90
 
206
- ## Migrating from Orchestrator SDK
91
+ # Build
92
+ bun run build
207
93
 
208
- To migrate from the [Orchestrator SDK](https://github.com/rhinestonewtf/orchestrator-sdk), replace all imports of `@rhinestone/orchestrator-sdk` with `@rhinestone/sdk/orchestrator`.
94
+ # Test
95
+ bun run test
209
96
 
210
- Let us know if you encounter any issues!
97
+ # Create changeset
98
+ bun run changeset
99
+
100
+ # Version and publish
101
+ bun run changeset:version
102
+ bun run changeset:release
103
+ ```
211
104
 
212
- ## Contributing
105
+ ## License
213
106
 
214
- For feature or change requests, feel free to open a PR, start a discussion or get in touch with us.
107
+ MIT - Charter Labs
@@ -0,0 +1,69 @@
1
+ import type { AccountType } from '../types';
2
+ declare class AccountError extends Error {
3
+ private readonly _message;
4
+ private readonly _context;
5
+ private readonly _errorType;
6
+ private readonly _traceId;
7
+ constructor(params?: {
8
+ message?: string;
9
+ context?: any;
10
+ errorType?: string;
11
+ traceId?: string;
12
+ });
13
+ get message(): string;
14
+ get context(): any;
15
+ get errorType(): string;
16
+ get traceId(): string;
17
+ }
18
+ declare class Eip7702AccountMustHaveEoaError extends AccountError {
19
+ constructor(params?: {
20
+ context?: any;
21
+ errorType?: string;
22
+ traceId?: string;
23
+ });
24
+ }
25
+ declare class ExistingEip7702AccountsNotSupportedError extends AccountError {
26
+ constructor(params?: {
27
+ context?: any;
28
+ errorType?: string;
29
+ traceId?: string;
30
+ });
31
+ }
32
+ declare class FactoryArgsNotAvailableError extends AccountError {
33
+ constructor(params?: {
34
+ context?: any;
35
+ errorType?: string;
36
+ traceId?: string;
37
+ });
38
+ }
39
+ declare class SmartSessionsNotEnabledError extends AccountError {
40
+ constructor(params?: {
41
+ context?: any;
42
+ errorType?: string;
43
+ traceId?: string;
44
+ });
45
+ }
46
+ declare class SigningNotSupportedForAccountError extends AccountError {
47
+ constructor(params?: {
48
+ context?: any;
49
+ errorType?: string;
50
+ traceId?: string;
51
+ });
52
+ }
53
+ declare class SignMessageNotSupportedByAccountError extends AccountError {
54
+ constructor(params?: {
55
+ context?: any;
56
+ errorType?: string;
57
+ traceId?: string;
58
+ });
59
+ }
60
+ declare class Eip7702NotSupportedForAccountError extends AccountError {
61
+ constructor(account: AccountType, params?: {
62
+ context?: any;
63
+ errorType?: string;
64
+ traceId?: string;
65
+ });
66
+ }
67
+ declare function isAccountError(error: Error): error is AccountError;
68
+ export { isAccountError, AccountError, Eip7702AccountMustHaveEoaError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, SmartSessionsNotEnabledError, SigningNotSupportedForAccountError, SignMessageNotSupportedByAccountError, Eip7702NotSupportedForAccountError, };
69
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../accounts/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,cAAM,YAAa,SAAQ,KAAK;IAC9B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAQ;IACjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAK;IAC9B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;IACnC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAQ;gBAErB,MAAM,CAAC,EAAE;QACnB,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,OAAO,CAAC,EAAE,GAAG,CAAA;QACb,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB;IAQD,IAAI,OAAO,WAEV;IAED,IAAI,OAAO,QAEV;IAED,IAAI,SAAS,WAEZ;IAED,IAAI,OAAO,WAEV;CACF;AAED,cAAM,8BAA+B,SAAQ,YAAY;gBAC3C,MAAM,CAAC,EAAE;QACnB,OAAO,CAAC,EAAE,GAAG,CAAA;QACb,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB;CAMF;AAED,cAAM,wCAAyC,SAAQ,YAAY;gBACrD,MAAM,CAAC,EAAE;QACnB,OAAO,CAAC,EAAE,GAAG,CAAA;QACb,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB;CAMF;AAED,cAAM,4BAA6B,SAAQ,YAAY;gBACzC,MAAM,CAAC,EAAE;QACnB,OAAO,CAAC,EAAE,GAAG,CAAA;QACb,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB;CAMF;AAED,cAAM,4BAA6B,SAAQ,YAAY;gBACzC,MAAM,CAAC,EAAE;QACnB,OAAO,CAAC,EAAE,GAAG,CAAA;QACb,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB;CAMF;AAED,cAAM,kCAAmC,SAAQ,YAAY;gBAC/C,MAAM,CAAC,EAAE;QACnB,OAAO,CAAC,EAAE,GAAG,CAAA;QACb,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB;CAMF;AAED,cAAM,qCAAsC,SAAQ,YAAY;gBAClD,MAAM,CAAC,EAAE;QACnB,OAAO,CAAC,EAAE,GAAG,CAAA;QACb,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB;CAMF;AAED,cAAM,kCAAmC,SAAQ,YAAY;gBAEzD,OAAO,EAAE,WAAW,EACpB,MAAM,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,GAAG,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;CAQnE;AAED,iBAAS,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,YAAY,CAE3D;AAeD,OAAO,EACL,cAAc,EACd,YAAY,EACZ,8BAA8B,EAC9B,wCAAwC,EACxC,4BAA4B,EAC5B,4BAA4B,EAC5B,kCAAkC,EAClC,qCAAqC,EACrC,kCAAkC,GACnC,CAAA"}
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Eip7702NotSupportedForAccountError = exports.SignMessageNotSupportedByAccountError = exports.SigningNotSupportedForAccountError = exports.SmartSessionsNotEnabledError = exports.FactoryArgsNotAvailableError = exports.ExistingEip7702AccountsNotSupportedError = exports.Eip7702AccountMustHaveEoaError = exports.AccountError = void 0;
4
+ exports.isAccountError = isAccountError;
5
+ class AccountError extends Error {
6
+ _message;
7
+ _context;
8
+ _errorType;
9
+ _traceId;
10
+ constructor(params) {
11
+ super();
12
+ this._message = params?.message || 'AccountError';
13
+ this._context = params?.context || {};
14
+ this._errorType = params?.errorType || 'Unknown';
15
+ this._traceId = params?.traceId || '';
16
+ }
17
+ get message() {
18
+ return this._message;
19
+ }
20
+ get context() {
21
+ return this._context;
22
+ }
23
+ get errorType() {
24
+ return this._errorType;
25
+ }
26
+ get traceId() {
27
+ return this._traceId;
28
+ }
29
+ }
30
+ exports.AccountError = AccountError;
31
+ class Eip7702AccountMustHaveEoaError extends AccountError {
32
+ constructor(params) {
33
+ super({
34
+ message: 'EIP-7702 accounts must have an EOA account',
35
+ ...params,
36
+ });
37
+ }
38
+ }
39
+ exports.Eip7702AccountMustHaveEoaError = Eip7702AccountMustHaveEoaError;
40
+ class ExistingEip7702AccountsNotSupportedError extends AccountError {
41
+ constructor(params) {
42
+ super({
43
+ message: 'Existing EIP-7702 accounts are not yet supported',
44
+ ...params,
45
+ });
46
+ }
47
+ }
48
+ exports.ExistingEip7702AccountsNotSupportedError = ExistingEip7702AccountsNotSupportedError;
49
+ class FactoryArgsNotAvailableError extends AccountError {
50
+ constructor(params) {
51
+ super({
52
+ message: 'Factory args not available',
53
+ ...params,
54
+ });
55
+ }
56
+ }
57
+ exports.FactoryArgsNotAvailableError = FactoryArgsNotAvailableError;
58
+ class SmartSessionsNotEnabledError extends AccountError {
59
+ constructor(params) {
60
+ super({
61
+ message: 'Smart sessions are not enabled for this account',
62
+ ...params,
63
+ });
64
+ }
65
+ }
66
+ exports.SmartSessionsNotEnabledError = SmartSessionsNotEnabledError;
67
+ class SigningNotSupportedForAccountError extends AccountError {
68
+ constructor(params) {
69
+ super({
70
+ message: 'Signing not supported for the account',
71
+ ...params,
72
+ });
73
+ }
74
+ }
75
+ exports.SigningNotSupportedForAccountError = SigningNotSupportedForAccountError;
76
+ class SignMessageNotSupportedByAccountError extends AccountError {
77
+ constructor(params) {
78
+ super({
79
+ message: 'Sign message not supported by account',
80
+ ...params,
81
+ });
82
+ }
83
+ }
84
+ exports.SignMessageNotSupportedByAccountError = SignMessageNotSupportedByAccountError;
85
+ class Eip7702NotSupportedForAccountError extends AccountError {
86
+ constructor(account, params) {
87
+ const accountName = getAccountName(account);
88
+ super({
89
+ message: `EIP-7702 is not supported for ${accountName} accounts`,
90
+ ...params,
91
+ });
92
+ }
93
+ }
94
+ exports.Eip7702NotSupportedForAccountError = Eip7702NotSupportedForAccountError;
95
+ function isAccountError(error) {
96
+ return error instanceof AccountError;
97
+ }
98
+ function getAccountName(account) {
99
+ switch (account) {
100
+ case 'safe':
101
+ return 'Safe';
102
+ case 'kernel':
103
+ return 'Kernel';
104
+ case 'nexus':
105
+ return 'Nexus';
106
+ case 'startale':
107
+ return 'Startale';
108
+ }
109
+ }
@@ -1,34 +1,27 @@
1
1
  import { type Chain, type Hex, type PublicClient } from 'viem';
2
- import { Module } from '../modules/common';
3
- import { EnableSessionData } from '../modules/validators/smart-sessions';
4
- import type { AccountProviderConfig, Call, OwnerSet, RhinestoneAccountConfig, Session } from '../types';
5
- import { ValidatorConfig } from './utils';
6
- declare function getDeployArgs(config: RhinestoneAccountConfig): {
2
+ import type { Module } from '../modules/common';
3
+ import type { EnableSessionData } from '../modules/validators/smart-sessions';
4
+ import type { AccountProviderConfig, Call, OwnerSet, RhinestoneAccountConfig, Session, SignerSet } from '../types';
5
+ import { AccountError, Eip7702AccountMustHaveEoaError, Eip7702NotSupportedForAccountError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, isAccountError, SigningNotSupportedForAccountError, SignMessageNotSupportedByAccountError, SmartSessionsNotEnabledError } from './error';
6
+ import { type ValidatorConfig } from './utils';
7
+ declare function getInitCode(config: RhinestoneAccountConfig): {
7
8
  factory: `0x${string}`;
8
9
  factoryData: `0x${string}`;
9
- salt: `0x${string}`;
10
- implementation: `0x${string}`;
11
- initializationCallData: null;
12
- } | {
13
- factory: `0x${string}`;
14
- factoryData: `0x${string}`;
15
- salt: `0x${string}`;
16
- implementation: `0x${string}`;
17
- initializationCallData: `0x${string}`;
18
- };
10
+ } | undefined;
11
+ declare function signEip7702InitData(config: RhinestoneAccountConfig): Promise<`0x${string}`>;
12
+ declare function getEip7702InitCall(config: RhinestoneAccountConfig, signature: Hex): Promise<{
13
+ initData: `0x${string}`;
14
+ contract: `0x${string}`;
15
+ }>;
19
16
  declare function getModuleInstallationCalls(config: RhinestoneAccountConfig, module: Module): Call[];
20
17
  declare function getModuleUninstallationCalls(config: RhinestoneAccountConfig, module: Module): Call[];
21
18
  declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
22
- declare function getPackedSignature(config: RhinestoneAccountConfig, owners: OwnerSet, chain: Chain, validator: ValidatorConfig, hash: Hex, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
19
+ declare function getPackedSignature(config: RhinestoneAccountConfig, signers: SignerSet | undefined, chain: Chain, validator: ValidatorConfig, hash: Hex, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
23
20
  declare function isDeployed(chain: Chain, config: RhinestoneAccountConfig): Promise<boolean>;
24
21
  declare function deploy(config: RhinestoneAccountConfig, chain: Chain, session?: Session): Promise<void>;
25
- declare function deploySource(chain: Chain, config: RhinestoneAccountConfig): Promise<void>;
26
- declare function deployTarget(chain: Chain, config: RhinestoneAccountConfig, asUserOp: boolean): Promise<void>;
27
- declare function getBundleInitCode(config: RhinestoneAccountConfig): `0x${string}` | undefined;
28
22
  declare function getSmartAccount(config: RhinestoneAccountConfig, client: PublicClient, chain: Chain): Promise<import("viem/account-abstraction").SmartAccount<import("viem/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">>>;
29
23
  declare function getSmartSessionSmartAccount(config: RhinestoneAccountConfig, client: PublicClient, chain: Chain, session: Session, enableData: EnableSessionData | null): Promise<import("viem/account-abstraction").SmartAccount<import("viem/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">>>;
30
24
  declare function getGuardianSmartAccount(config: RhinestoneAccountConfig, client: PublicClient, chain: Chain, guardians: OwnerSet): Promise<import("viem/account-abstraction").SmartAccount<import("viem/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">>>;
31
- declare function sign(validators: OwnerSet, chain: Chain, hash: Hex): Promise<`0x${string}`>;
32
25
  declare function getAccountProvider(config: RhinestoneAccountConfig): AccountProviderConfig;
33
- export { getModuleInstallationCalls, getModuleUninstallationCalls, getDeployArgs, getBundleInitCode, getAddress, getAccountProvider, isDeployed, deploy, deploySource, deployTarget, getSmartAccount, getSmartSessionSmartAccount, getGuardianSmartAccount, getPackedSignature, sign, };
26
+ export { getModuleInstallationCalls, getModuleUninstallationCalls, getAddress, getAccountProvider, getInitCode, signEip7702InitData, getEip7702InitCall, isDeployed, deploy, getSmartAccount, getSmartSessionSmartAccount, getGuardianSmartAccount, getPackedSignature, isAccountError, AccountError, Eip7702AccountMustHaveEoaError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, SmartSessionsNotEnabledError, SigningNotSupportedForAccountError, SignMessageNotSupportedByAccountError, Eip7702NotSupportedForAccountError, };
34
27
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../accounts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,KAAK,EAKV,KAAK,GAAG,EACR,KAAK,YAAY,EAKlB,MAAM,MAAM,CAAA;AAQb,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAS/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAC7E,OAAO,KAAK,EACV,qBAAqB,EACrB,IAAI,EACJ,QAAQ,EAER,uBAAuB,EACvB,OAAO,EACP,SAAS,EACV,MAAM,UAAU,CAAA;AACjB,OAAO,EACL,YAAY,EACZ,8BAA8B,EAC9B,kCAAkC,EAClC,wCAAwC,EACxC,4BAA4B,EAC5B,cAAc,EACd,kCAAkC,EAClC,qCAAqC,EACrC,4BAA4B,EAC7B,MAAM,SAAS,CAAA;AAuChB,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAoB/D,iBAAS,WAAW,CAAC,MAAM,EAAE,uBAAuB;;;cAanD;AAED,iBAAe,mBAAmB,CAAC,MAAM,EAAE,uBAAuB,0BAgBjE;AAED,iBAAe,kBAAkB,CAC/B,MAAM,EAAE,uBAAuB,EAC/B,SAAS,EAAE,GAAG;;;GAaf;AAED,iBAAS,0BAA0B,CACjC,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,MAAM,GACb,IAAI,EAAE,CA2BR;AAED,iBAAS,4BAA4B,CACnC,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,MAAM,GACb,IAAI,EAAE,CA6BR;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,iBAsBlD;AAGD,iBAAe,kBAAkB,CAC/B,MAAM,EAAE,uBAAuB,EAC/B,OAAO,EAAE,SAAS,GAAG,SAAS,EAC9B,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,eAAe,EAC1B,IAAI,EAAE,GAAG,EACT,kBAAkB,GAAE,CAAC,SAAS,EAAE,GAAG,KAAK,GAA8B,0BAoCvE;AAED,iBAAe,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,uBAAuB,oBAiBtE;AAED,iBAAe,MAAM,CACnB,MAAM,EAAE,uBAAuB,EAC/B,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE,OAAO,iBAMlB;AAwBD,iBAAe,eAAe,CAC5B,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,KAAK,sJA6Cb;AAED,iBAAe,2BAA2B,CACxC,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,iBAAiB,GAAG,IAAI,sJAyDrC;AAED,iBAAe,uBAAuB,CACpC,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,QAAQ,sJAqDpB;AAwHD,iBAAS,kBAAkB,CACzB,MAAM,EAAE,uBAAuB,GAC9B,qBAAqB,CAOvB;AA6CD,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,UAAU,EACV,kBAAkB,EAClB,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,UAAU,EACV,MAAM,EACN,eAAe,EACf,2BAA2B,EAC3B,uBAAuB,EACvB,kBAAkB,EAElB,cAAc,EACd,YAAY,EACZ,8BAA8B,EAC9B,wCAAwC,EACxC,4BAA4B,EAC5B,4BAA4B,EAC5B,kCAAkC,EAClC,qCAAqC,EACrC,kCAAkC,GACnC,CAAA"}