@rhinestone/sdk 2.0.0-beta.28 → 2.0.0-beta.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/actions/smart-sessions.d.ts +3 -2
- package/dist/src/actions/smart-sessions.d.ts.map +1 -1
- package/dist/src/actions/smart-sessions.js +3 -2
- package/dist/src/index.d.ts +226 -25
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +38 -123
- package/dist/src/jwt-server/jcs.d.ts +1 -1
- package/dist/src/jwt-server/jcs.js +4 -2
- package/dist/src/orchestrator/consts.d.ts +1 -1
- package/dist/src/orchestrator/consts.js +1 -1
- package/dist/src/utils/index.d.ts +59 -0
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/index.js +59 -0
- package/package.json +1 -1
|
@@ -80,8 +80,9 @@ interface CreateCrossChainPermissionInput {
|
|
|
80
80
|
settlementLayers?: CrossChainSettlementLayer[];
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
|
-
* Build a {@link CrossChainPermit} from an ergonomic input shape
|
|
84
|
-
*
|
|
83
|
+
* Build a {@link CrossChainPermit} from an ergonomic input shape.
|
|
84
|
+
*
|
|
85
|
+
* Accepts:
|
|
85
86
|
* - a single `from`/`to` leg or arrays of legs
|
|
86
87
|
* - `TokenSymbol` ("USDC", "USDT", ...) which is resolved to the
|
|
87
88
|
* per-chain ERC-20 address via the shared token registry
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smart-sessions.d.ts","sourceRoot":"","sources":["../../../actions/smart-sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,GAAG,EAAa,MAAM,MAAM,CAAA;AAUpE,OAAO,KAAK,EACV,gBAAgB,EAChB,yBAAyB,EACzB,aAAa,EACb,OAAO,EACP,WAAW,EACZ,MAAM,UAAU,CAAA;AAEjB;;;GAGG;AACH,iBAAS,mB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C,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAC7D;;;;;;OAMG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,yBAAyB,EAAE,CAAA;CAC/C;AAiBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,iBAAS,0BAA0B,CACjC,KAAK,EAAE,+BAA+B,GACrC,gBAAgB,CA6DlB;AAED,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,0BAA0B,EAC1B,0BAA0B,GAC3B,CAAA"}
|
|
@@ -64,8 +64,9 @@ function resolveTokenForChain(token, chainId) {
|
|
|
64
64
|
return isAddress(token) ? token : getTokenAddress(token, chainId);
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
|
-
* Build a {@link CrossChainPermit} from an ergonomic input shape
|
|
68
|
-
*
|
|
67
|
+
* Build a {@link CrossChainPermit} from an ergonomic input shape.
|
|
68
|
+
*
|
|
69
|
+
* Accepts:
|
|
69
70
|
* - a single `from`/`to` leg or arrays of legs
|
|
70
71
|
* - `TokenSymbol` ("USDC", "USDT", ...) which is resolved to the
|
|
71
72
|
* per-chain ERC-20 address via the shared token registry
|
package/dist/src/index.d.ts
CHANGED
|
@@ -18,47 +18,210 @@ interface SubmitTransactionOptions {
|
|
|
18
18
|
internal_dryRun?: boolean;
|
|
19
19
|
}
|
|
20
20
|
interface RhinestoneAccount {
|
|
21
|
+
/** The resolved account configuration. */
|
|
21
22
|
config: RhinestoneAccountConfig;
|
|
22
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Deploy the account on a given chain.
|
|
25
|
+
* @param chain Chain to deploy the account on
|
|
26
|
+
* @param params Optional deployment parameters (session, sponsorship)
|
|
27
|
+
* @returns `true` once the deployment is submitted
|
|
28
|
+
*/
|
|
29
|
+
deploy(chain: Chain, params?: {
|
|
23
30
|
session?: Session;
|
|
24
31
|
sponsored?: boolean;
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
}): Promise<boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* Check whether the account is deployed on a given chain.
|
|
35
|
+
* @param chain Chain to check
|
|
36
|
+
* @returns `true` if the account is deployed, `false` otherwise
|
|
37
|
+
*/
|
|
38
|
+
isDeployed(chain: Chain): Promise<boolean>;
|
|
39
|
+
/**
|
|
40
|
+
* Set up an existing account on a given chain by installing any missing modules.
|
|
41
|
+
* @param chain Chain to set the account up on
|
|
42
|
+
* @returns `true` once setup is submitted
|
|
43
|
+
*/
|
|
44
|
+
setup(chain: Chain): Promise<boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* Get the account initialization data, used to deploy the account onchain.
|
|
47
|
+
* @returns The factory address and factory data
|
|
48
|
+
*/
|
|
28
49
|
getInitData(): {
|
|
29
50
|
factory: Address;
|
|
30
51
|
factoryData: Hex;
|
|
31
52
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Prepare and sign the EIP-7702 account initialization data.
|
|
55
|
+
* @returns The init data signature
|
|
56
|
+
*/
|
|
57
|
+
signEip7702InitData(): Promise<Hex>;
|
|
58
|
+
/**
|
|
59
|
+
* Prepare a transaction for signing.
|
|
60
|
+
* @param transaction Transaction to prepare
|
|
61
|
+
* @returns The prepared transaction data
|
|
62
|
+
* @see {@link signTransaction} to sign the prepared transaction
|
|
63
|
+
* @see {@link submitTransaction} to submit the signed transaction
|
|
64
|
+
*/
|
|
65
|
+
prepareTransaction(transaction: Transaction): Promise<PreparedTransactionData>;
|
|
66
|
+
/**
|
|
67
|
+
* Get the typed-data messages to sign for a prepared transaction.
|
|
68
|
+
* @param preparedTransaction Prepared transaction data
|
|
69
|
+
* @param options Optional override; pass `{ intentId }` to inspect a specific quote from `preparedTransaction.quotes.all`
|
|
70
|
+
* @returns The origin, destination, and (when required) target-execution typed-data messages
|
|
71
|
+
* @see {@link prepareTransaction} to prepare the transaction data for signing
|
|
72
|
+
*/
|
|
73
|
+
getTransactionMessages(preparedTransaction: PreparedTransactionData, options?: QuoteSelection): {
|
|
35
74
|
origin: TypedDataDefinition[];
|
|
36
75
|
destination: TypedDataDefinition;
|
|
37
76
|
targetExecution?: TypedDataDefinition;
|
|
38
77
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Sign a prepared transaction.
|
|
80
|
+
* @param preparedTransaction Prepared transaction data
|
|
81
|
+
* @param options Optional override; pass `{ intentId }` to sign a specific quote from `preparedTransaction.quotes.all`
|
|
82
|
+
* @returns The signed transaction data
|
|
83
|
+
* @see {@link prepareTransaction} to prepare the transaction data for signing
|
|
84
|
+
* @see {@link submitTransaction} to submit the signed transaction
|
|
85
|
+
*/
|
|
86
|
+
signTransaction(preparedTransaction: PreparedTransactionData, options?: QuoteSelection): Promise<SignedTransactionData>;
|
|
87
|
+
/**
|
|
88
|
+
* Sign the EIP-7702 authorizations required for a transaction.
|
|
89
|
+
* @param preparedTransaction Prepared transaction data
|
|
90
|
+
* @returns The signed authorization list
|
|
91
|
+
* @see {@link prepareTransaction} to prepare the transaction data for signing
|
|
92
|
+
*/
|
|
93
|
+
signAuthorizations(preparedTransaction: PreparedTransactionData): Promise<SignedAuthorizationList>;
|
|
94
|
+
/**
|
|
95
|
+
* Sign a message (EIP-191).
|
|
96
|
+
* @param message Message to sign
|
|
97
|
+
* @param chain Chain to sign the message for
|
|
98
|
+
* @param signers Signers to use, or `undefined` for the account default
|
|
99
|
+
* @returns The signature
|
|
100
|
+
* @see {@link signTypedData} to sign EIP-712 typed data
|
|
101
|
+
*/
|
|
102
|
+
signMessage(message: SignableMessage, chain: Chain, signers: SignerSet | undefined): Promise<Hex>;
|
|
103
|
+
/**
|
|
104
|
+
* Sign typed data (EIP-712).
|
|
105
|
+
* @param parameters Typed-data parameters
|
|
106
|
+
* @param chain Chain to sign the typed data for
|
|
107
|
+
* @param signers Signers to use, or `undefined` for the account default
|
|
108
|
+
* @returns The signature
|
|
109
|
+
* @see {@link signMessage} to sign an EIP-191 message
|
|
110
|
+
*/
|
|
111
|
+
signTypedData<typedData extends TypedData | Record<string, unknown> = TypedData, primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData>(parameters: HashTypedDataParameters<typedData, primaryType>, chain: Chain, signers: SignerSet | undefined): Promise<Hex>;
|
|
112
|
+
/**
|
|
113
|
+
* Sign an orchestrator intent operation. Used by headless flows that prepare
|
|
114
|
+
* the intent outside the SDK but still need the SDK-owned smart-session
|
|
115
|
+
* signature packing and target-execution signature routing.
|
|
116
|
+
* @param signData Sign data returned by the orchestrator (origin/destination/targetExecution typed data)
|
|
117
|
+
* @param targetChain Chain where the destination execution runs
|
|
118
|
+
* @param signers Signers to use, or `undefined` for the account default
|
|
119
|
+
* @returns The intent signatures, ready for submission
|
|
120
|
+
* @see {@link signTransaction} for the canonical signing path
|
|
121
|
+
*/
|
|
122
|
+
signIntent(signData: SignData, targetChain: DestinationChain, signers?: SignerSet): Promise<SignedIntentData>;
|
|
123
|
+
/**
|
|
124
|
+
* Submit a signed transaction.
|
|
125
|
+
* @param signedTransaction Signed transaction data
|
|
126
|
+
* @param options Optional submission options (e.g. EIP-7702 `authorizations`)
|
|
127
|
+
* @returns The transaction result (an intent ID)
|
|
128
|
+
* @see {@link signTransaction} to sign the transaction data
|
|
129
|
+
* @see {@link signAuthorizations} to sign the required EIP-7702 authorizations
|
|
130
|
+
* @see {@link waitForExecution} to wait for the transaction to execute onchain
|
|
131
|
+
*/
|
|
132
|
+
submitTransaction(signedTransaction: SignedTransactionData, options?: SubmitTransactionOptions): Promise<TransactionResult>;
|
|
133
|
+
/**
|
|
134
|
+
* Prepare a user operation for signing.
|
|
135
|
+
* @param transaction User operation to prepare
|
|
136
|
+
* @returns The prepared user operation data
|
|
137
|
+
* @see {@link signUserOperation} to sign the prepared user operation
|
|
138
|
+
* @see {@link submitUserOperation} to submit the signed user operation
|
|
139
|
+
* @see {@link sendUserOperation} to prepare, sign, and submit in one call
|
|
140
|
+
*/
|
|
141
|
+
prepareUserOperation(transaction: UserOperationTransaction): Promise<PreparedUserOperationData>;
|
|
142
|
+
/**
|
|
143
|
+
* Sign a prepared user operation.
|
|
144
|
+
* @param preparedUserOperation Prepared user operation data
|
|
145
|
+
* @returns The signed user operation data
|
|
146
|
+
* @see {@link prepareUserOperation} to prepare the user operation data for signing
|
|
147
|
+
* @see {@link submitUserOperation} to submit the signed user operation
|
|
148
|
+
*/
|
|
149
|
+
signUserOperation(preparedUserOperation: PreparedUserOperationData): Promise<SignedUserOperationData>;
|
|
150
|
+
/**
|
|
151
|
+
* Submit a signed user operation.
|
|
152
|
+
* @param signedUserOperation Signed user operation data
|
|
153
|
+
* @returns The user operation result (a UserOp hash)
|
|
154
|
+
* @see {@link signUserOperation} to sign the user operation data
|
|
155
|
+
* @see {@link waitForExecution} to wait for the user operation to execute onchain
|
|
156
|
+
*/
|
|
157
|
+
submitUserOperation(signedUserOperation: SignedUserOperationData): Promise<UserOperationResult>;
|
|
158
|
+
/**
|
|
159
|
+
* Prepare, sign, and submit a user operation in a single call.
|
|
160
|
+
* @param transaction User operation to send
|
|
161
|
+
* @returns The user operation result (a UserOp hash)
|
|
162
|
+
* @see {@link waitForExecution} to wait for the user operation to execute onchain
|
|
163
|
+
*/
|
|
164
|
+
sendUserOperation(transaction: UserOperationTransaction): Promise<UserOperationResult>;
|
|
165
|
+
/**
|
|
166
|
+
* Wait for a submitted transaction or user operation to execute onchain.
|
|
167
|
+
* Polls the orchestrator until the intent reaches a terminal state; on failure
|
|
168
|
+
* an `IntentFailedError` is thrown.
|
|
169
|
+
* @param result The result returned by a submit/send call
|
|
170
|
+
* @returns The per-chain operation status (for intents) or a UserOp receipt
|
|
171
|
+
*/
|
|
49
172
|
waitForExecution(result: TransactionResult): Promise<TransactionStatus>;
|
|
50
173
|
waitForExecution(result: UserOperationResult): Promise<UserOperationReceipt>;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
174
|
+
/**
|
|
175
|
+
* Get the account address.
|
|
176
|
+
* @returns The smart account address
|
|
177
|
+
*/
|
|
178
|
+
getAddress(): Address;
|
|
179
|
+
/**
|
|
180
|
+
* Get the account portfolio (token balances across chains).
|
|
181
|
+
* @param onTestnets Whether to query testnet balances (default is `false`)
|
|
182
|
+
* @returns The account balances
|
|
183
|
+
*/
|
|
184
|
+
getPortfolio(onTestnets?: boolean): Promise<Portfolio>;
|
|
185
|
+
/**
|
|
186
|
+
* Resolve the smart-session details for a set of sessions.
|
|
187
|
+
* @param sessions Sessions to resolve
|
|
188
|
+
* @returns The resolved session details
|
|
189
|
+
*/
|
|
190
|
+
experimental_getSessionDetails(sessions: Session[]): Promise<SessionDetails>;
|
|
191
|
+
/**
|
|
192
|
+
* Check whether a smart session is enabled on the account.
|
|
193
|
+
* @param session Session to check
|
|
194
|
+
* @returns `true` if the session is enabled
|
|
195
|
+
*/
|
|
196
|
+
experimental_isSessionEnabled(session: Session): Promise<boolean>;
|
|
197
|
+
/**
|
|
198
|
+
* Sign the data required to enable a smart session.
|
|
199
|
+
* @param details Session details to enable
|
|
200
|
+
* @returns The enable-session signature
|
|
201
|
+
*/
|
|
202
|
+
experimental_signEnableSession(details: SessionDetails): Promise<Hex>;
|
|
203
|
+
/**
|
|
204
|
+
* Get the account owners.
|
|
205
|
+
* @remarks Only returns ECDSA owners; owners managed by other validator types are not included.
|
|
206
|
+
* @param chain Chain to read the owners from
|
|
207
|
+
* @returns The owner addresses and threshold, or `null` if unavailable
|
|
208
|
+
*/
|
|
209
|
+
getOwners(chain: Chain): Promise<{
|
|
57
210
|
accounts: Address[];
|
|
58
211
|
threshold: number;
|
|
59
212
|
} | null>;
|
|
60
|
-
|
|
61
|
-
|
|
213
|
+
/**
|
|
214
|
+
* Get the account validator modules.
|
|
215
|
+
* @param chain Chain to read the validators from
|
|
216
|
+
* @returns The validator module addresses
|
|
217
|
+
*/
|
|
218
|
+
getValidators(chain: Chain): Promise<Address[]>;
|
|
219
|
+
/**
|
|
220
|
+
* Get the account executor modules.
|
|
221
|
+
* @param chain Chain to read the executors from
|
|
222
|
+
* @returns The executor module addresses
|
|
223
|
+
*/
|
|
224
|
+
getExecutors(chain: Chain): Promise<Address[]>;
|
|
62
225
|
}
|
|
63
226
|
interface SignedIntentData {
|
|
64
227
|
originSignatures: OriginSignature[];
|
|
@@ -72,6 +235,10 @@ interface SignedIntentData {
|
|
|
72
235
|
* @returns account
|
|
73
236
|
*/
|
|
74
237
|
declare function createRhinestoneAccount(config: RhinestoneConfig): Promise<RhinestoneAccount>;
|
|
238
|
+
/**
|
|
239
|
+
* Stateful entry point that holds shared configuration (auth, provider, bundler,
|
|
240
|
+
* paymaster) and creates accounts from it.
|
|
241
|
+
*/
|
|
75
242
|
declare class RhinestoneSDK {
|
|
76
243
|
private authProvider;
|
|
77
244
|
private endpointUrl?;
|
|
@@ -80,9 +247,43 @@ declare class RhinestoneSDK {
|
|
|
80
247
|
private paymaster?;
|
|
81
248
|
private useDevContracts?;
|
|
82
249
|
private headers?;
|
|
250
|
+
/**
|
|
251
|
+
* Create a Rhinestone SDK instance.
|
|
252
|
+
* @param options Shared configuration applied to every account created by this instance
|
|
253
|
+
*/
|
|
83
254
|
constructor(options: RhinestoneSDKConfig);
|
|
255
|
+
/**
|
|
256
|
+
* Create an account using this instance's shared configuration.
|
|
257
|
+
* @param config Per-account configuration (owners, account type, modules, sessions)
|
|
258
|
+
* @returns The account instance
|
|
259
|
+
* @example
|
|
260
|
+
* ```ts
|
|
261
|
+
* import { RhinestoneSDK } from '@rhinestone/sdk'
|
|
262
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
263
|
+
*
|
|
264
|
+
* const owner = privateKeyToAccount('0x...')
|
|
265
|
+
*
|
|
266
|
+
* const sdk = new RhinestoneSDK({
|
|
267
|
+
* auth: { mode: 'apiKey', apiKey: process.env.RHINESTONE_API_KEY! },
|
|
268
|
+
* })
|
|
269
|
+
*
|
|
270
|
+
* const account = await sdk.createAccount({
|
|
271
|
+
* owners: { type: 'ecdsa', accounts: [owner] },
|
|
272
|
+
* })
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
84
275
|
createAccount(config: RhinestoneAccountConfig): Promise<RhinestoneAccount>;
|
|
276
|
+
/**
|
|
277
|
+
* Get the current status of a submitted intent.
|
|
278
|
+
* @param intentId The intent ID returned when the transaction was submitted
|
|
279
|
+
* @returns The intent status
|
|
280
|
+
*/
|
|
85
281
|
getIntentStatus(intentId: string): Promise<TransactionStatus>;
|
|
282
|
+
/**
|
|
283
|
+
* Split a transaction into multiple intents across chains.
|
|
284
|
+
* @param input The intents to split
|
|
285
|
+
* @returns The split-intents result
|
|
286
|
+
*/
|
|
86
287
|
splitIntents(input: SplitIntentsInput): Promise<SplitIntentsResult>;
|
|
87
288
|
}
|
|
88
289
|
export { RhinestoneSDK, createRhinestoneAccount, hyperCoreMainnet, solanaMainnet, tronMainnet, OWNABLE_VALIDATOR_ADDRESS, WEBAUTHN_VALIDATOR_ADDRESS, MULTI_FACTOR_VALIDATOR_ADDRESS, SMART_SESSION_EMISSARY_ADDRESS, createCrossChainPermission, };
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,KAAK,EACL,uBAAuB,EACvB,GAAG,EACH,eAAe,EACf,uBAAuB,EACvB,SAAS,EACT,mBAAmB,EACpB,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAapE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAA;AAErE,OAAO,EAKL,KAAK,iBAAiB,EACtB,KA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e,EACf,WAAW,EACX,WAAW,EACX,SAAS,EACT,IAAI,EACJ,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,QAAQ,EACR,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,EAC1B,SAAS,EACT,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAClB,OAAO,EACP,iBAAiB,EACjB,QAAQ,EACR,UAAU,EACV,wBAAwB,EACxB,eAAe,EACf,MAAM,EACN,kBAAkB,EAClB,gBAAgB,EAChB,yBAAyB,EACzB,mCAAmC,EACnC,cAAc,EACd,uBAAuB,EACvB,KAAK,EACL,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,yBAAyB,EACzB,uBAAuB,EACvB,mBAAmB,EACnB,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAEhB,eAAe,EACf,QAAQ,EACR,gBAAgB,EAEhB,eAAe,EACf,aAAa,EACb,cAAc,GACf,CAAA"}
|
package/dist/src/index.js
CHANGED
|
@@ -20,34 +20,15 @@ async function createRhinestoneAccount(config) {
|
|
|
20
20
|
if (config.account?.type !== 'eoa' && !config.owners) {
|
|
21
21
|
throw new OwnersFieldRequiredError();
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Deploys the account on a given chain
|
|
25
|
-
* @param chain Chain to deploy the account on
|
|
26
|
-
* @param session Session to deploy the account on (optional)
|
|
27
|
-
*/
|
|
28
23
|
function deploy(chain, params) {
|
|
29
24
|
return deployInternal(config, chain, params);
|
|
30
25
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Checks if the account is deployed on a given chain
|
|
33
|
-
* @param chain Chain to check if the account is deployed on
|
|
34
|
-
* @returns true if the account is deployed, false otherwise
|
|
35
|
-
*/
|
|
36
26
|
function isDeployed(chain) {
|
|
37
27
|
return isDeployedInternal(config, chain);
|
|
38
28
|
}
|
|
39
|
-
/**
|
|
40
|
-
* Sets up the existing account on a given chain
|
|
41
|
-
* by installing the missing modules (if any).
|
|
42
|
-
* @param chain Chain to set up the account on
|
|
43
|
-
*/
|
|
44
29
|
function setup(chain) {
|
|
45
30
|
return setupInternal(config, chain);
|
|
46
31
|
}
|
|
47
|
-
/**
|
|
48
|
-
* Get the account initialization data. Used for deploying the account onchain.
|
|
49
|
-
* @returns factory address and factory data
|
|
50
|
-
*/
|
|
51
32
|
function getInitData() {
|
|
52
33
|
const initData = getInitCode(config);
|
|
53
34
|
if (!initData) {
|
|
@@ -61,81 +42,27 @@ async function createRhinestoneAccount(config) {
|
|
|
61
42
|
factoryData: initData.factoryData,
|
|
62
43
|
};
|
|
63
44
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Prepare and sign the EIP-7702 account initialization data
|
|
66
|
-
* @returns init data signature
|
|
67
|
-
*/
|
|
68
45
|
function signEip7702InitData() {
|
|
69
46
|
return signEip7702InitDataInternal(config);
|
|
70
47
|
}
|
|
71
|
-
/**
|
|
72
|
-
* Prepare a transaction data
|
|
73
|
-
* @param transaction Transaction to prepare
|
|
74
|
-
* @returns prepared transaction data
|
|
75
|
-
*/
|
|
76
48
|
function prepareTransaction(transaction) {
|
|
77
49
|
return prepareTransactionInternal(config, transaction);
|
|
78
50
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Get the transaction typed data message to sign
|
|
81
|
-
* @param preparedTransaction Prepared transaction data
|
|
82
|
-
* @param options Optional override; pass `{ intentId }` to inspect a specific quote from `preparedTransaction.quotes.all`
|
|
83
|
-
* @see {@link prepareTransaction} to prepare the transaction data for signing
|
|
84
|
-
*/
|
|
85
51
|
function getTransactionMessages(preparedTransaction, options) {
|
|
86
52
|
return getTransactionMessagesInternal(config, preparedTransaction, options);
|
|
87
53
|
}
|
|
88
|
-
/**
|
|
89
|
-
* Sign a transaction
|
|
90
|
-
* @param preparedTransaction Prepared transaction data
|
|
91
|
-
* @param options Optional override; pass `{ intentId }` to sign a specific quote from `preparedTransaction.quotes.all`
|
|
92
|
-
* @returns signed transaction data
|
|
93
|
-
* @see {@link prepareTransaction} to prepare the transaction data for signing
|
|
94
|
-
*/
|
|
95
54
|
function signTransaction(preparedTransaction, options) {
|
|
96
55
|
return signTransactionInternal(config, preparedTransaction, options);
|
|
97
56
|
}
|
|
98
|
-
/**
|
|
99
|
-
* Sign the required EIP-7702 authorizations for a transaction
|
|
100
|
-
* @param preparedTransaction Prepared transaction data
|
|
101
|
-
* @returns signed authorizations
|
|
102
|
-
* @see {@link prepareTransaction} to prepare the transaction data for signing
|
|
103
|
-
*/
|
|
104
57
|
function signAuthorizations(preparedTransaction) {
|
|
105
58
|
return signAuthorizationsInternal(config, preparedTransaction);
|
|
106
59
|
}
|
|
107
|
-
/**
|
|
108
|
-
* Sign a message (EIP-191)
|
|
109
|
-
* @param message Message to sign
|
|
110
|
-
* @param chain Chain to sign the message on
|
|
111
|
-
* @param signers Signers to use for signing
|
|
112
|
-
* @returns signature
|
|
113
|
-
*/
|
|
114
60
|
function signMessage(message, chain, signers) {
|
|
115
61
|
return signMessageInternal(config, message, chain, signers);
|
|
116
62
|
}
|
|
117
|
-
/**
|
|
118
|
-
* Sign a typed data (EIP-712)
|
|
119
|
-
* @param parameters Typed data parameters
|
|
120
|
-
* @param chain Chain to sign the typed data on
|
|
121
|
-
* @param signers Signers to use for signing
|
|
122
|
-
* @returns signature
|
|
123
|
-
*/
|
|
124
63
|
function signTypedData(parameters, chain, signers) {
|
|
125
64
|
return signTypedDataInternal(config, parameters, chain, signers);
|
|
126
65
|
}
|
|
127
|
-
/**
|
|
128
|
-
* Sign an orchestrator intent operation.
|
|
129
|
-
* This is used by headless flows that prepare the intent outside the SDK but
|
|
130
|
-
* still need the SDK-owned SmartSession signature packing and target-execution
|
|
131
|
-
* signature routing. Mirrors the canonical {@link signTransaction} path: origin
|
|
132
|
-
* and destination are always signed in claim mode, and the target-execution
|
|
133
|
-
* signature is derived separately (returned only when the intent requires it).
|
|
134
|
-
* @param signData Sign data returned by the orchestrator (origin/destination/targetExecution typed data)
|
|
135
|
-
* @param targetChain Chain where the destination execution runs
|
|
136
|
-
* @param signers Signers to use for signing
|
|
137
|
-
* @returns Intent signatures ready for submission
|
|
138
|
-
*/
|
|
139
66
|
async function signIntent(signData, targetChain, signers) {
|
|
140
67
|
const { originSignatures, destinationSignature } = await signIntentInternal(config, signData, targetChain, signers, false);
|
|
141
68
|
const targetExecutionSignature = await getTargetExecutionSignatureInternal(config, signData, targetChain, signers);
|
|
@@ -145,85 +72,35 @@ async function createRhinestoneAccount(config) {
|
|
|
145
72
|
targetExecutionSignature,
|
|
146
73
|
};
|
|
147
74
|
}
|
|
148
|
-
/**
|
|
149
|
-
* Submit a transaction
|
|
150
|
-
* @param signedTransaction Signed transaction data
|
|
151
|
-
* @param options Optional submission options
|
|
152
|
-
* @param options.authorizations EIP-7702 authorizations to submit
|
|
153
|
-
* @returns transaction result object (a UserOp hash)
|
|
154
|
-
* @see {@link signTransaction} to sign the transaction data
|
|
155
|
-
* @see {@link signAuthorizations} to sign the required EIP-7702 authorizations
|
|
156
|
-
*/
|
|
157
75
|
function submitTransaction(signedTransaction, options) {
|
|
158
76
|
return submitTransactionInternal(config, signedTransaction, options?.authorizations ?? [], options?.internal_dryRun ?? false);
|
|
159
77
|
}
|
|
160
|
-
/**
|
|
161
|
-
* Prepare a user operation data
|
|
162
|
-
* @param transaction User operation to prepare
|
|
163
|
-
* @returns prepared user operation data
|
|
164
|
-
*/
|
|
165
78
|
function prepareUserOperation(transaction) {
|
|
166
79
|
return prepareUserOperationInternal(config, transaction);
|
|
167
80
|
}
|
|
168
|
-
/**
|
|
169
|
-
* Sign a user operation
|
|
170
|
-
* @param preparedUserOperation Prepared user operation data
|
|
171
|
-
* @returns signed user operation data
|
|
172
|
-
* @see {@link prepareUserOperation} to prepare the user operation data for signing
|
|
173
|
-
*/
|
|
174
81
|
function signUserOperation(preparedUserOperation) {
|
|
175
82
|
return signUserOperationInternal(config, preparedUserOperation);
|
|
176
83
|
}
|
|
177
|
-
/**
|
|
178
|
-
* Submit a transaction
|
|
179
|
-
* @param signedTransaction Signed transaction data
|
|
180
|
-
* @returns transaction result object (a UserOp hash)
|
|
181
|
-
* @see {@link signUserOperation} to sign the user operation data
|
|
182
|
-
*/
|
|
183
84
|
function submitUserOperation(signedUserOperation) {
|
|
184
85
|
return submitUserOperationInternal(config, signedUserOperation);
|
|
185
86
|
}
|
|
186
|
-
/**
|
|
187
|
-
* Sign and send a user operation
|
|
188
|
-
* @param transaction User operation to send
|
|
189
|
-
* @returns user operation result object (a UserOp hash)
|
|
190
|
-
*/
|
|
191
87
|
function sendUserOperation(transaction) {
|
|
192
88
|
return sendUserOperationInternal(config, transaction);
|
|
193
89
|
}
|
|
194
90
|
function waitForExecution(result) {
|
|
195
91
|
return waitForExecutionInternal(config, result);
|
|
196
92
|
}
|
|
197
|
-
/**
|
|
198
|
-
* Get account address
|
|
199
|
-
* @returns Address of the smart account
|
|
200
|
-
*/
|
|
201
93
|
function getAddress() {
|
|
202
94
|
return getAddressInternal(config);
|
|
203
95
|
}
|
|
204
|
-
/**
|
|
205
|
-
* Get account portfolio
|
|
206
|
-
* @param onTestnets Whether to query the testnet balances (default is `false`)
|
|
207
|
-
* @returns Account balances
|
|
208
|
-
*/
|
|
209
96
|
function getPortfolio(onTestnets = false) {
|
|
210
97
|
return getPortfolioInternal(config, onTestnets);
|
|
211
98
|
}
|
|
212
|
-
/**
|
|
213
|
-
* Get account owners (ECDSA)
|
|
214
|
-
* @param chain Chain to get the owners on
|
|
215
|
-
* @returns Account owners
|
|
216
|
-
*/
|
|
217
99
|
function getOwners(chain) {
|
|
218
100
|
const accountType = getAccountProvider(config).type;
|
|
219
101
|
const account = getAddress();
|
|
220
102
|
return getOwnersInternal(accountType, account, chain, config.provider);
|
|
221
103
|
}
|
|
222
|
-
/**
|
|
223
|
-
* Get account validator modules
|
|
224
|
-
* @param chain Chain to get the validators on
|
|
225
|
-
* @returns List of account validators
|
|
226
|
-
*/
|
|
227
104
|
function getValidators(chain) {
|
|
228
105
|
const accountType = getAccountProvider(config).type;
|
|
229
106
|
const account = getAddress();
|
|
@@ -275,6 +152,10 @@ async function createRhinestoneAccount(config) {
|
|
|
275
152
|
getInitData,
|
|
276
153
|
};
|
|
277
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Stateful entry point that holds shared configuration (auth, provider, bundler,
|
|
157
|
+
* paymaster) and creates accounts from it.
|
|
158
|
+
*/
|
|
278
159
|
class RhinestoneSDK {
|
|
279
160
|
authProvider;
|
|
280
161
|
endpointUrl;
|
|
@@ -283,6 +164,10 @@ class RhinestoneSDK {
|
|
|
283
164
|
paymaster;
|
|
284
165
|
useDevContracts;
|
|
285
166
|
headers;
|
|
167
|
+
/**
|
|
168
|
+
* Create a Rhinestone SDK instance.
|
|
169
|
+
* @param options Shared configuration applied to every account created by this instance
|
|
170
|
+
*/
|
|
286
171
|
constructor(options) {
|
|
287
172
|
this.authProvider = createAuthProvider(options);
|
|
288
173
|
this.endpointUrl = options.endpointUrl;
|
|
@@ -292,6 +177,26 @@ class RhinestoneSDK {
|
|
|
292
177
|
this.useDevContracts = options.useDevContracts;
|
|
293
178
|
this.headers = options.headers;
|
|
294
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Create an account using this instance's shared configuration.
|
|
182
|
+
* @param config Per-account configuration (owners, account type, modules, sessions)
|
|
183
|
+
* @returns The account instance
|
|
184
|
+
* @example
|
|
185
|
+
* ```ts
|
|
186
|
+
* import { RhinestoneSDK } from '@rhinestone/sdk'
|
|
187
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
188
|
+
*
|
|
189
|
+
* const owner = privateKeyToAccount('0x...')
|
|
190
|
+
*
|
|
191
|
+
* const sdk = new RhinestoneSDK({
|
|
192
|
+
* auth: { mode: 'apiKey', apiKey: process.env.RHINESTONE_API_KEY! },
|
|
193
|
+
* })
|
|
194
|
+
*
|
|
195
|
+
* const account = await sdk.createAccount({
|
|
196
|
+
* owners: { type: 'ecdsa', accounts: [owner] },
|
|
197
|
+
* })
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
295
200
|
createAccount(config) {
|
|
296
201
|
const rhinestoneConfig = {
|
|
297
202
|
...config,
|
|
@@ -305,9 +210,19 @@ class RhinestoneSDK {
|
|
|
305
210
|
};
|
|
306
211
|
return createRhinestoneAccount(rhinestoneConfig);
|
|
307
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Get the current status of a submitted intent.
|
|
215
|
+
* @param intentId The intent ID returned when the transaction was submitted
|
|
216
|
+
* @returns The intent status
|
|
217
|
+
*/
|
|
308
218
|
getIntentStatus(intentId) {
|
|
309
219
|
return getIntentStatusInternal(this.authProvider, this.endpointUrl, intentId, this.headers);
|
|
310
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Split a transaction into multiple intents across chains.
|
|
223
|
+
* @param input The intents to split
|
|
224
|
+
* @returns The split-intents result
|
|
225
|
+
*/
|
|
311
226
|
splitIntents(input) {
|
|
312
227
|
return splitIntentsInternal(this.authProvider, this.endpointUrl, input, this.headers);
|
|
313
228
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* RFC 8785 JSON Canonicalization Scheme (JCS).
|
|
3
3
|
*
|
|
4
4
|
* Produces a deterministic JSON serialization by:
|
|
5
|
-
* 1. Sorting object keys lexicographically (
|
|
5
|
+
* 1. Sorting object keys lexicographically (UTF-16 code-unit order, per RFC 8785 §3.2.3)
|
|
6
6
|
* 2. Using ES2015+ `JSON.stringify` number serialization (IEEE 754 → shortest round-trip)
|
|
7
7
|
* 3. No whitespace
|
|
8
8
|
*
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* RFC 8785 JSON Canonicalization Scheme (JCS).
|
|
3
3
|
*
|
|
4
4
|
* Produces a deterministic JSON serialization by:
|
|
5
|
-
* 1. Sorting object keys lexicographically (
|
|
5
|
+
* 1. Sorting object keys lexicographically (UTF-16 code-unit order, per RFC 8785 §3.2.3)
|
|
6
6
|
* 2. Using ES2015+ `JSON.stringify` number serialization (IEEE 754 → shortest round-trip)
|
|
7
7
|
* 3. No whitespace
|
|
8
8
|
*
|
|
@@ -43,7 +43,9 @@ function serialize(value) {
|
|
|
43
43
|
const items = value.map((item) => serialize(item));
|
|
44
44
|
return `[${items.join(',')}]`;
|
|
45
45
|
}
|
|
46
|
-
// Object — sort keys by
|
|
46
|
+
// Object — sort keys by UTF-16 code-unit order (RFC 8785 §3.2.3).
|
|
47
|
+
// Native String comparison already orders by UTF-16 code unit, which is
|
|
48
|
+
// exactly what JCS mandates — do not replace with a code-point comparator.
|
|
47
49
|
const obj = value;
|
|
48
50
|
const keys = Object.keys(obj).sort();
|
|
49
51
|
const members = [];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare const PROD_ORCHESTRATOR_URL = "https://v1.orchestrator.rhinestone.dev";
|
|
2
2
|
declare const RHINESTONE_SPOKE_POOL_ADDRESS = "0x000000000060f6e853447881951574cdd0663530";
|
|
3
|
-
declare const SDK_VERSION = "2.0.0-beta.
|
|
3
|
+
declare const SDK_VERSION = "2.0.0-beta.29";
|
|
4
4
|
declare const API_VERSION = "2026-04.blanc";
|
|
5
5
|
export { PROD_ORCHESTRATOR_URL, RHINESTONE_SPOKE_POOL_ADDRESS, SDK_VERSION, API_VERSION, };
|
|
6
6
|
//# sourceMappingURL=consts.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const PROD_ORCHESTRATOR_URL = 'https://v1.orchestrator.rhinestone.dev';
|
|
2
2
|
const RHINESTONE_SPOKE_POOL_ADDRESS = '0x000000000060f6e853447881951574cdd0663530';
|
|
3
|
-
const SDK_VERSION = '2.0.0-beta.
|
|
3
|
+
const SDK_VERSION = '2.0.0-beta.29';
|
|
4
4
|
const API_VERSION = '2026-04.blanc';
|
|
5
5
|
export { PROD_ORCHESTRATOR_URL, RHINESTONE_SPOKE_POOL_ADDRESS, SDK_VERSION, API_VERSION, };
|
|
@@ -2,12 +2,55 @@ import type { Account, Address, Hex } from 'viem';
|
|
|
2
2
|
import { getSetup as experimental_getModuleSetup } from '../modules/index.js';
|
|
3
3
|
import type { RhinestoneAccountConfig } from '../types.js';
|
|
4
4
|
import { walletClientToAccount, wrapParaAccount } from './walletClient.js';
|
|
5
|
+
/**
|
|
6
|
+
* Compute the v0 (legacy) initialization data for an account configuration.
|
|
7
|
+
*
|
|
8
|
+
* Use this to reconstruct the `initData` for an account originally created with
|
|
9
|
+
* the Rhinestone SDK v0, then pass it back into `createAccount`.
|
|
10
|
+
* @param config Account configuration
|
|
11
|
+
* @returns The account address, factory, factory data, and whether the intent executor is installed
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { experimental_getV0InitData } from '@rhinestone/sdk/utils'
|
|
15
|
+
*
|
|
16
|
+
* const initData = experimental_getV0InitData({
|
|
17
|
+
* owners: { type: 'ecdsa', accounts: [owner] },
|
|
18
|
+
* })
|
|
19
|
+
*
|
|
20
|
+
* const account = await sdk.createAccount({
|
|
21
|
+
* owners: { type: 'ecdsa', accounts: [owner] },
|
|
22
|
+
* initData,
|
|
23
|
+
* })
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
5
26
|
declare function experimental_getV0InitData(config: RhinestoneAccountConfig): {
|
|
6
27
|
address: Address;
|
|
7
28
|
factory: Address;
|
|
8
29
|
factoryData: Hex;
|
|
9
30
|
intentExecutorInstalled: boolean;
|
|
10
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Compute the Rhinestone initialization data for an account configuration.
|
|
34
|
+
*
|
|
35
|
+
* Use this to reconstruct the `initData` for an account originally created with
|
|
36
|
+
* the Rhinestone SDK, then pass it back into `createAccount` instead of
|
|
37
|
+
* providing the factory and factory data manually.
|
|
38
|
+
* @param config Account configuration
|
|
39
|
+
* @returns The account address, plus factory data when the account is not yet deployed
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { experimental_getRhinestoneInitData } from '@rhinestone/sdk/utils'
|
|
43
|
+
*
|
|
44
|
+
* const initData = experimental_getRhinestoneInitData({
|
|
45
|
+
* owners: { type: 'ecdsa', accounts: [owner] },
|
|
46
|
+
* })
|
|
47
|
+
*
|
|
48
|
+
* const account = await sdk.createAccount({
|
|
49
|
+
* owners: { type: 'ecdsa', accounts: [owner] },
|
|
50
|
+
* initData,
|
|
51
|
+
* })
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
11
54
|
declare function experimental_getRhinestoneInitData(config: RhinestoneAccountConfig): {
|
|
12
55
|
address: Address;
|
|
13
56
|
factory: Address;
|
|
@@ -16,6 +59,22 @@ declare function experimental_getRhinestoneInitData(config: RhinestoneAccountCon
|
|
|
16
59
|
} | {
|
|
17
60
|
address: Address;
|
|
18
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* Create a view-only viem `Account` for an address. Any signing operation throws.
|
|
64
|
+
*
|
|
65
|
+
* Useful as an account owner when signing happens elsewhere (e.g. a server-held
|
|
66
|
+
* session signer), so the SDK can read from the account without holding a key.
|
|
67
|
+
* @param address Address to wrap
|
|
68
|
+
* @returns A viem account that can be read from but not signed with
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* import { toViewOnlyAccount } from '@rhinestone/sdk/utils'
|
|
72
|
+
*
|
|
73
|
+
* const account = await sdk.createAccount({
|
|
74
|
+
* owners: { type: 'ecdsa', accounts: [toViewOnlyAccount(userAddress)] },
|
|
75
|
+
* })
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
19
78
|
declare function toViewOnlyAccount(address: Address): Account;
|
|
20
79
|
export { experimental_getV0InitData, experimental_getModuleSetup, experimental_getRhinestoneInitData, toViewOnlyAccount, walletClientToAccount, wrapParaAccount, };
|
|
21
80
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAGjD,OAAO,EAAE,QAAQ,IAAI,2BAA2B,EAAE,MAAM,YAAY,CAAA;AACpE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AACvD,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAEvE,iBAAS,0BAA0B,CAAC,MAAM,EAAE,uBAAuB,GAAG;IACpE,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,GAAG,CAAA;IAChB,uBAAuB,EAAE,OAAO,CAAA;CACjC,CAgBA;AAED,iBAAS,kCAAkC,CAAC,MAAM,EAAE,uBAAuB,GACvE;IACE,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,GAAG,CAAA;IAChB,uBAAuB,EAAE,OAAO,CAAA;CACjC,GACD;IACE,OAAO,EAAE,OAAO,CAAA;CACjB,CAmBJ;AAED,iBAAS,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAcpD;AAED,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,kCAAkC,EAClC,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,GAChB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAGjD,OAAO,EAAE,QAAQ,IAAI,2BAA2B,EAAE,MAAM,YAAY,CAAA;AACpE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AACvD,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAEvE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,iBAAS,0BAA0B,CAAC,MAAM,EAAE,uBAAuB,GAAG;IACpE,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,GAAG,CAAA;IAChB,uBAAuB,EAAE,OAAO,CAAA;CACjC,CAgBA;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,iBAAS,kCAAkC,CAAC,MAAM,EAAE,uBAAuB,GACvE;IACE,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,GAAG,CAAA;IAChB,uBAAuB,EAAE,OAAO,CAAA;CACjC,GACD;IACE,OAAO,EAAE,OAAO,CAAA;CACjB,CAmBJ;AAED;;;;;;;;;;;;;;;GAeG;AACH,iBAAS,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAcpD;AAED,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,kCAAkC,EAClC,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,GAChB,CAAA"}
|
package/dist/src/utils/index.js
CHANGED
|
@@ -2,6 +2,27 @@ import { toAccount } from 'viem/accounts';
|
|
|
2
2
|
import { getAddress, getInitCode, getV0InitCode } from '../accounts/index.js';
|
|
3
3
|
import { getSetup as experimental_getModuleSetup } from '../modules/index.js';
|
|
4
4
|
import { walletClientToAccount, wrapParaAccount } from './walletClient.js';
|
|
5
|
+
/**
|
|
6
|
+
* Compute the v0 (legacy) initialization data for an account configuration.
|
|
7
|
+
*
|
|
8
|
+
* Use this to reconstruct the `initData` for an account originally created with
|
|
9
|
+
* the Rhinestone SDK v0, then pass it back into `createAccount`.
|
|
10
|
+
* @param config Account configuration
|
|
11
|
+
* @returns The account address, factory, factory data, and whether the intent executor is installed
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { experimental_getV0InitData } from '@rhinestone/sdk/utils'
|
|
15
|
+
*
|
|
16
|
+
* const initData = experimental_getV0InitData({
|
|
17
|
+
* owners: { type: 'ecdsa', accounts: [owner] },
|
|
18
|
+
* })
|
|
19
|
+
*
|
|
20
|
+
* const account = await sdk.createAccount({
|
|
21
|
+
* owners: { type: 'ecdsa', accounts: [owner] },
|
|
22
|
+
* initData,
|
|
23
|
+
* })
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
5
26
|
function experimental_getV0InitData(config) {
|
|
6
27
|
const initCode = getV0InitCode(config);
|
|
7
28
|
if (!initCode) {
|
|
@@ -19,6 +40,28 @@ function experimental_getV0InitData(config) {
|
|
|
19
40
|
intentExecutorInstalled: true,
|
|
20
41
|
};
|
|
21
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Compute the Rhinestone initialization data for an account configuration.
|
|
45
|
+
*
|
|
46
|
+
* Use this to reconstruct the `initData` for an account originally created with
|
|
47
|
+
* the Rhinestone SDK, then pass it back into `createAccount` instead of
|
|
48
|
+
* providing the factory and factory data manually.
|
|
49
|
+
* @param config Account configuration
|
|
50
|
+
* @returns The account address, plus factory data when the account is not yet deployed
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* import { experimental_getRhinestoneInitData } from '@rhinestone/sdk/utils'
|
|
54
|
+
*
|
|
55
|
+
* const initData = experimental_getRhinestoneInitData({
|
|
56
|
+
* owners: { type: 'ecdsa', accounts: [owner] },
|
|
57
|
+
* })
|
|
58
|
+
*
|
|
59
|
+
* const account = await sdk.createAccount({
|
|
60
|
+
* owners: { type: 'ecdsa', accounts: [owner] },
|
|
61
|
+
* initData,
|
|
62
|
+
* })
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
22
65
|
function experimental_getRhinestoneInitData(config) {
|
|
23
66
|
const initCode = getInitCode(config);
|
|
24
67
|
if (!initCode) {
|
|
@@ -40,6 +83,22 @@ function experimental_getRhinestoneInitData(config) {
|
|
|
40
83
|
};
|
|
41
84
|
}
|
|
42
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Create a view-only viem `Account` for an address. Any signing operation throws.
|
|
88
|
+
*
|
|
89
|
+
* Useful as an account owner when signing happens elsewhere (e.g. a server-held
|
|
90
|
+
* session signer), so the SDK can read from the account without holding a key.
|
|
91
|
+
* @param address Address to wrap
|
|
92
|
+
* @returns A viem account that can be read from but not signed with
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* import { toViewOnlyAccount } from '@rhinestone/sdk/utils'
|
|
96
|
+
*
|
|
97
|
+
* const account = await sdk.createAccount({
|
|
98
|
+
* owners: { type: 'ecdsa', accounts: [toViewOnlyAccount(userAddress)] },
|
|
99
|
+
* })
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
43
102
|
function toViewOnlyAccount(address) {
|
|
44
103
|
const errorMessage = 'Signing is not supported for view-only accounts';
|
|
45
104
|
return toAccount({
|