@charterlabs/rhinestone-sdk 0.2.7-dev.4 → 0.2.8
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/README.md +46 -8
- package/dist/src/accounts/index.d.ts +4 -1
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +36 -5
- package/dist/src/accounts/passport.d.ts +12 -0
- package/dist/src/accounts/passport.d.ts.map +1 -0
- package/dist/src/accounts/passport.js +173 -0
- package/dist/src/actions/smart-sessions.d.ts +23 -0
- package/dist/src/actions/smart-sessions.d.ts.map +1 -0
- package/dist/src/actions/{smart-session.js → smart-sessions.js} +13 -0
- package/dist/src/errors/index.d.ts +2 -2
- package/dist/src/errors/index.d.ts.map +1 -1
- package/dist/src/errors/index.js +16 -1
- package/dist/src/execution/compact.d.ts +3 -3
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +3 -3
- package/dist/src/execution/error.d.ts +8 -1
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +10 -1
- package/dist/src/execution/index.d.ts +3 -2
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +62 -9
- package/dist/src/execution/multiChainOps.d.ts +40 -0
- package/dist/src/execution/multiChainOps.d.ts.map +1 -0
- package/dist/src/execution/multiChainOps.js +39 -0
- package/dist/src/execution/permit2.d.ts +2 -2
- package/dist/src/execution/permit2.d.ts.map +1 -1
- package/dist/src/execution/permit2.js +28 -19
- package/dist/src/execution/smart-session.d.ts.map +1 -1
- package/dist/src/execution/smart-session.js +3 -3
- package/dist/src/execution/types.d.ts +2 -1
- package/dist/src/execution/types.d.ts.map +1 -1
- package/dist/src/execution/utils.d.ts +15 -8
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +88 -72
- package/dist/src/index.d.ts +7 -6
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +9 -21
- package/dist/src/modules/index.test.js +1 -1
- package/dist/src/modules/read.js +2 -2
- package/dist/src/modules/validators/smart-sessions.d.ts +4 -4
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions.js +10 -72
- package/dist/src/modules/validators/smart-sessions.test.js +4 -5
- package/dist/src/orchestrator/client.d.ts +3 -2
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +217 -171
- package/dist/src/orchestrator/error.d.ts +111 -1
- package/dist/src/orchestrator/error.d.ts.map +1 -1
- package/dist/src/orchestrator/error.js +128 -1
- package/dist/src/orchestrator/index.d.ts +4 -4
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +16 -1
- package/dist/src/orchestrator/types.d.ts +30 -24
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/types.d.ts +12 -2
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/index.d.ts +3 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/index.js +5 -0
- package/package.json +1 -1
- package/dist/src/actions/smart-session.d.ts +0 -11
- package/dist/src/actions/smart-session.d.ts.map +0 -1
|
@@ -7,7 +7,6 @@ exports.signAuthorizationsInternal = signAuthorizationsInternal;
|
|
|
7
7
|
exports.signMessage = signMessage;
|
|
8
8
|
exports.signTypedData = signTypedData;
|
|
9
9
|
exports.submitTransaction = submitTransaction;
|
|
10
|
-
exports.simulateTransaction = simulateTransaction;
|
|
11
10
|
exports.prepareUserOperation = prepareUserOperation;
|
|
12
11
|
exports.signUserOperation = signUserOperation;
|
|
13
12
|
exports.submitUserOperation = submitUserOperation;
|
|
@@ -15,7 +14,6 @@ exports.getOrchestratorByChain = getOrchestratorByChain;
|
|
|
15
14
|
exports.signIntent = signIntent;
|
|
16
15
|
exports.prepareTransactionAsIntent = prepareTransactionAsIntent;
|
|
17
16
|
exports.submitIntentInternal = submitIntentInternal;
|
|
18
|
-
exports.simulateIntentInternal = simulateIntentInternal;
|
|
19
17
|
exports.getValidatorAccount = getValidatorAccount;
|
|
20
18
|
exports.parseCalls = parseCalls;
|
|
21
19
|
exports.getTokenRequests = getTokenRequests;
|
|
@@ -24,6 +22,7 @@ const viem_1 = require("viem");
|
|
|
24
22
|
const account_abstraction_1 = require("viem/account-abstraction");
|
|
25
23
|
const accounts_1 = require("../accounts");
|
|
26
24
|
const utils_1 = require("../accounts/utils");
|
|
25
|
+
const modules_1 = require("../modules");
|
|
27
26
|
const validators_1 = require("../modules/validators");
|
|
28
27
|
const core_1 = require("../modules/validators/core");
|
|
29
28
|
const orchestrator_1 = require("../orchestrator");
|
|
@@ -31,15 +30,16 @@ const consts_1 = require("../orchestrator/consts");
|
|
|
31
30
|
const registry_1 = require("../orchestrator/registry");
|
|
32
31
|
const compact_1 = require("./compact");
|
|
33
32
|
const error_1 = require("./error");
|
|
33
|
+
const multiChainOps_1 = require("./multiChainOps");
|
|
34
34
|
const permit2_1 = require("./permit2");
|
|
35
35
|
async function prepareTransaction(config, transaction) {
|
|
36
|
-
const { sourceChains, targetChain, tokenRequests, signers, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, } = getTransactionParams(transaction);
|
|
36
|
+
const { sourceChains, targetChain, tokenRequests, signers, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, account, } = getTransactionParams(transaction);
|
|
37
37
|
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
38
38
|
const isUserOpSigner = signers?.type === 'guardians' || signers?.type === 'session';
|
|
39
39
|
if (isUserOpSigner) {
|
|
40
40
|
throw new error_1.SignerNotSupportedError();
|
|
41
41
|
}
|
|
42
|
-
const intentRoute = await prepareTransactionAsIntent(config, sourceChains, targetChain, await resolveCallInputs(transaction.calls, config, targetChain, accountAddress), transaction.gasLimit, tokenRequests, accountAddress, sponsored ?? false, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds);
|
|
42
|
+
const intentRoute = await prepareTransactionAsIntent(config, sourceChains, targetChain, await resolveCallInputs(transaction.calls, config, targetChain, accountAddress), transaction.gasLimit, tokenRequests, accountAddress, sponsored ?? false, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, account);
|
|
43
43
|
return {
|
|
44
44
|
intentRoute,
|
|
45
45
|
transaction,
|
|
@@ -77,11 +77,12 @@ async function resolveCallInputs(inputs, config, chain, accountAddress) {
|
|
|
77
77
|
async function signTransaction(config, preparedTransaction) {
|
|
78
78
|
const { targetChain, signers } = getTransactionParams(preparedTransaction.transaction);
|
|
79
79
|
const intentRoute = preparedTransaction.intentRoute;
|
|
80
|
-
const
|
|
80
|
+
const { originSignatures, destinationSignature } = await signIntent(config, targetChain, intentRoute.intentOp, signers);
|
|
81
81
|
return {
|
|
82
82
|
intentRoute,
|
|
83
83
|
transaction: preparedTransaction.transaction,
|
|
84
|
-
|
|
84
|
+
originSignatures,
|
|
85
|
+
destinationSignature,
|
|
85
86
|
};
|
|
86
87
|
}
|
|
87
88
|
async function signUserOperation(config, preparedUserOperation) {
|
|
@@ -163,11 +164,11 @@ async function signAuthorizationsInternal(config, data) {
|
|
|
163
164
|
}
|
|
164
165
|
return authorizations;
|
|
165
166
|
}
|
|
166
|
-
async function submitTransaction(config, signedTransaction, authorizations) {
|
|
167
|
-
const { intentRoute, transaction,
|
|
167
|
+
async function submitTransaction(config, signedTransaction, authorizations, dryRun = false) {
|
|
168
|
+
const { intentRoute, transaction, originSignatures, destinationSignature } = signedTransaction;
|
|
168
169
|
const { sourceChains, targetChain } = getTransactionParams(transaction);
|
|
169
170
|
const intentOp = intentRoute.intentOp;
|
|
170
|
-
return await submitIntent(config, sourceChains, targetChain, intentOp,
|
|
171
|
+
return await submitIntent(config, sourceChains, targetChain, intentOp, originSignatures, destinationSignature, authorizations, dryRun);
|
|
171
172
|
}
|
|
172
173
|
async function submitUserOperation(config, signedUserOperation) {
|
|
173
174
|
const chain = signedUserOperation.transaction.chain;
|
|
@@ -176,15 +177,6 @@ async function submitUserOperation(config, signedUserOperation) {
|
|
|
176
177
|
// Smart sessions require a UserOp flow
|
|
177
178
|
return await submitUserOp(config, chain, userOp, signature);
|
|
178
179
|
}
|
|
179
|
-
async function simulateTransaction(config, signedTransaction, authorizations) {
|
|
180
|
-
const { intentRoute, transaction, signature } = signedTransaction;
|
|
181
|
-
const { sourceChains, targetChain } = getTransactionParams(transaction);
|
|
182
|
-
const intentOp = intentRoute.intentOp;
|
|
183
|
-
if (!intentOp) {
|
|
184
|
-
throw new error_1.OrderPathRequiredForIntentsError();
|
|
185
|
-
}
|
|
186
|
-
return await simulateIntent(config, sourceChains, targetChain, intentOp, signature, authorizations);
|
|
187
|
-
}
|
|
188
180
|
function getTransactionParams(transaction) {
|
|
189
181
|
const sourceChains = 'chain' in transaction ? [transaction.chain] : transaction.sourceChains;
|
|
190
182
|
const targetChain = 'chain' in transaction ? transaction.chain : transaction.targetChain;
|
|
@@ -197,6 +189,7 @@ function getTransactionParams(transaction) {
|
|
|
197
189
|
const sourceAssets = transaction.sourceAssets;
|
|
198
190
|
const feeAsset = transaction.feeAsset;
|
|
199
191
|
const lockFunds = transaction.lockFunds;
|
|
192
|
+
const account = transaction.experimental_accountOverride;
|
|
200
193
|
const tokenRequests = getTokenRequests(sourceChains || [], targetChain, initialTokenRequests, settlementLayers);
|
|
201
194
|
return {
|
|
202
195
|
sourceChains,
|
|
@@ -210,6 +203,7 @@ function getTransactionParams(transaction) {
|
|
|
210
203
|
sourceAssets,
|
|
211
204
|
feeAsset,
|
|
212
205
|
lockFunds,
|
|
206
|
+
account,
|
|
213
207
|
};
|
|
214
208
|
}
|
|
215
209
|
function getTokenRequests(sourceChains, targetChain, initialTokenRequests, settlementLayers) {
|
|
@@ -256,10 +250,10 @@ async function prepareTransactionAsUserOp(config, chain, callInputs, signers, ga
|
|
|
256
250
|
}),
|
|
257
251
|
};
|
|
258
252
|
}
|
|
259
|
-
async function prepareTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, isSponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds) {
|
|
253
|
+
async function prepareTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, isSponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, account) {
|
|
260
254
|
const calls = parseCalls(callInputs, targetChain.id);
|
|
261
255
|
const accountAccessList = createAccountAccessList(sourceChains, sourceAssets);
|
|
262
|
-
const { setupOps, delegations } = await getSetupOperationsAndDelegations(config,
|
|
256
|
+
const { setupOps, delegations } = await getSetupOperationsAndDelegations(config, accountAddress, eip7702InitSignature);
|
|
263
257
|
const getAccountType = (config) => {
|
|
264
258
|
if (config.account?.type === 'eoa') {
|
|
265
259
|
return 'EOA';
|
|
@@ -278,10 +272,14 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
278
272
|
account: {
|
|
279
273
|
address: accountAddress,
|
|
280
274
|
accountType: accountType,
|
|
281
|
-
setupOps,
|
|
275
|
+
setupOps: account?.setupOps ?? setupOps,
|
|
282
276
|
delegations,
|
|
283
277
|
},
|
|
284
|
-
destinationExecutions: calls
|
|
278
|
+
destinationExecutions: calls.map((call) => ({
|
|
279
|
+
to: call.to,
|
|
280
|
+
value: call.value.toString(),
|
|
281
|
+
data: call.data,
|
|
282
|
+
})),
|
|
285
283
|
destinationGasUnits: gasLimit,
|
|
286
284
|
accountAccessList,
|
|
287
285
|
options: {
|
|
@@ -301,26 +299,31 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
301
299
|
}
|
|
302
300
|
async function signIntent(config, targetChain, intentOp, signers) {
|
|
303
301
|
if (config.account?.type === 'eoa') {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
302
|
+
const originSignatures = [];
|
|
303
|
+
for (const element of intentOp.elements) {
|
|
304
|
+
let digest;
|
|
305
|
+
if (config.eoa?.signTypedData) {
|
|
306
|
+
const typedData = (0, permit2_1.getTypedData)(element, BigInt(intentOp.nonce), BigInt(intentOp.expires));
|
|
307
|
+
originSignatures.push(await config.eoa.signTypedData(typedData));
|
|
308
|
+
}
|
|
309
|
+
else if (config.eoa?.sign) {
|
|
310
|
+
digest = (0, compact_1.getPermit2Digest)(element, BigInt(intentOp.nonce), BigInt(intentOp.expires));
|
|
311
|
+
originSignatures.push(await config.eoa.sign({ hash: digest }));
|
|
312
|
+
}
|
|
313
|
+
else if (config.eoa?.signMessage) {
|
|
314
|
+
digest = (0, compact_1.getPermit2Digest)(element, BigInt(intentOp.nonce), BigInt(intentOp.expires));
|
|
315
|
+
originSignatures.push(await config.eoa.signMessage({
|
|
316
|
+
message: { raw: digest },
|
|
317
|
+
}));
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
throw new accounts_1.EoaSigningMethodNotConfiguredError('signTypedData, sign, or signMessage');
|
|
321
|
+
}
|
|
322
322
|
}
|
|
323
|
-
return
|
|
323
|
+
return {
|
|
324
|
+
originSignatures,
|
|
325
|
+
destinationSignature: originSignatures[0],
|
|
326
|
+
};
|
|
324
327
|
}
|
|
325
328
|
const validator = getValidator(config, signers);
|
|
326
329
|
if (!validator) {
|
|
@@ -328,19 +331,47 @@ async function signIntent(config, targetChain, intentOp, signers) {
|
|
|
328
331
|
}
|
|
329
332
|
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
330
333
|
const isRoot = validator.address === ownerValidator.address;
|
|
331
|
-
const
|
|
332
|
-
return
|
|
334
|
+
const signatures = await getIntentSignature(config, intentOp, signers, targetChain, validator, isRoot);
|
|
335
|
+
return signatures;
|
|
333
336
|
}
|
|
334
337
|
async function getIntentSignature(config, intentOp, signers, targetChain, validator, isRoot) {
|
|
335
338
|
const withJitFlow = intentOp.elements.some((element) => element.mandate.qualifier.settlementContext?.usingJIT);
|
|
339
|
+
const withMultiChainOps = intentOp.elements.some((element) => element.mandate.qualifier.settlementContext.settlementLayer ===
|
|
340
|
+
'INTENT_EXECUTOR');
|
|
341
|
+
if (withMultiChainOps) {
|
|
342
|
+
const signature = await getMultiChainOpsSignature(config, intentOp, signers, targetChain, validator, isRoot);
|
|
343
|
+
return {
|
|
344
|
+
originSignatures: Array(intentOp.elements.length).fill(signature),
|
|
345
|
+
destinationSignature: signature,
|
|
346
|
+
};
|
|
347
|
+
}
|
|
336
348
|
if (withJitFlow) {
|
|
337
|
-
return await
|
|
349
|
+
return await getPermit2Signatures(config, intentOp, signers, targetChain, validator, isRoot);
|
|
338
350
|
}
|
|
339
|
-
|
|
351
|
+
const signature = await getCompactSignature(config, intentOp, signers, targetChain, validator, isRoot);
|
|
352
|
+
return {
|
|
353
|
+
originSignatures: Array(intentOp.elements.length).fill(signature),
|
|
354
|
+
destinationSignature: signature,
|
|
355
|
+
};
|
|
340
356
|
}
|
|
341
|
-
async function
|
|
342
|
-
const
|
|
343
|
-
|
|
357
|
+
async function getMultiChainOpsSignature(config, intentOp, signers, targetChain, validator, isRoot) {
|
|
358
|
+
const address = (0, accounts_1.getAddress)(config);
|
|
359
|
+
const intentExecutor = (0, modules_1.getIntentExecutor)(config);
|
|
360
|
+
const typedData = (0, multiChainOps_1.getTypedData)(address, intentExecutor.address, intentOp);
|
|
361
|
+
const signature = await signIntentTypedData(config, signers, targetChain, validator, isRoot, typedData);
|
|
362
|
+
return signature;
|
|
363
|
+
}
|
|
364
|
+
async function getPermit2Signatures(config, intentOp, signers, targetChain, validator, isRoot) {
|
|
365
|
+
const originSignatures = [];
|
|
366
|
+
for (const element of intentOp.elements) {
|
|
367
|
+
const typedData = (0, permit2_1.getTypedData)(element, BigInt(intentOp.nonce), BigInt(intentOp.expires));
|
|
368
|
+
const signature = await signIntentTypedData(config, signers, targetChain, validator, isRoot, typedData);
|
|
369
|
+
originSignatures.push(signature);
|
|
370
|
+
}
|
|
371
|
+
return {
|
|
372
|
+
originSignatures,
|
|
373
|
+
destinationSignature: originSignatures[0],
|
|
374
|
+
};
|
|
344
375
|
}
|
|
345
376
|
async function getCompactSignature(config, intentOp, signers, targetChain, validator, isRoot) {
|
|
346
377
|
const typedData = (0, compact_1.getCompactTypedData)(intentOp);
|
|
@@ -413,8 +444,8 @@ async function submitUserOp(config, chain, userOp, signature) {
|
|
|
413
444
|
chain: chain.id,
|
|
414
445
|
};
|
|
415
446
|
}
|
|
416
|
-
async function submitIntent(config, sourceChains, targetChain, intentOp,
|
|
417
|
-
return submitIntentInternal(config, sourceChains, targetChain, intentOp,
|
|
447
|
+
async function submitIntent(config, sourceChains, targetChain, intentOp, originSignatures, destinationSignature, authorizations, dryRun) {
|
|
448
|
+
return submitIntentInternal(config, sourceChains, targetChain, intentOp, originSignatures, destinationSignature, authorizations, dryRun);
|
|
418
449
|
}
|
|
419
450
|
function getOrchestratorByChain(chainId, apiKey, orchestratorUrl) {
|
|
420
451
|
if (orchestratorUrl) {
|
|
@@ -425,14 +456,11 @@ function getOrchestratorByChain(chainId, apiKey, orchestratorUrl) {
|
|
|
425
456
|
: consts_1.PROD_ORCHESTRATOR_URL;
|
|
426
457
|
return (0, orchestrator_1.getOrchestrator)(apiKey, defaultOrchestratorUrl);
|
|
427
458
|
}
|
|
428
|
-
|
|
429
|
-
return simulateIntentInternal(config, sourceChains, targetChain, intentOp, signature, authorizations);
|
|
430
|
-
}
|
|
431
|
-
function createSignedIntentOp(intentOp, signature, authorizations) {
|
|
459
|
+
function createSignedIntentOp(intentOp, originSignatures, destinationSignature, authorizations) {
|
|
432
460
|
return {
|
|
433
461
|
...intentOp,
|
|
434
|
-
originSignatures
|
|
435
|
-
destinationSignature
|
|
462
|
+
originSignatures,
|
|
463
|
+
destinationSignature,
|
|
436
464
|
signedAuthorizations: authorizations.length > 0
|
|
437
465
|
? authorizations.map((authorization) => ({
|
|
438
466
|
chainId: authorization.chainId,
|
|
@@ -445,10 +473,10 @@ function createSignedIntentOp(intentOp, signature, authorizations) {
|
|
|
445
473
|
: undefined,
|
|
446
474
|
};
|
|
447
475
|
}
|
|
448
|
-
async function submitIntentInternal(config, sourceChains, targetChain, intentOp,
|
|
449
|
-
const signedIntentOp = createSignedIntentOp(intentOp,
|
|
476
|
+
async function submitIntentInternal(config, sourceChains, targetChain, intentOp, originSignatures, destinationSignature, authorizations, dryRun) {
|
|
477
|
+
const signedIntentOp = createSignedIntentOp(intentOp, originSignatures, destinationSignature, authorizations);
|
|
450
478
|
const orchestrator = getOrchestratorByChain(targetChain.id, config.apiKey, config.endpointUrl);
|
|
451
|
-
const intentResults = await orchestrator.submitIntent(signedIntentOp);
|
|
479
|
+
const intentResults = await orchestrator.submitIntent(signedIntentOp, dryRun);
|
|
452
480
|
return {
|
|
453
481
|
type: 'intent',
|
|
454
482
|
id: BigInt(intentResults.result.id),
|
|
@@ -456,12 +484,6 @@ async function submitIntentInternal(config, sourceChains, targetChain, intentOp,
|
|
|
456
484
|
targetChain: targetChain.id,
|
|
457
485
|
};
|
|
458
486
|
}
|
|
459
|
-
async function simulateIntentInternal(config, _sourceChains, targetChain, intentOp, signature, authorizations) {
|
|
460
|
-
const signedIntentOp = createSignedIntentOp(intentOp, signature, authorizations);
|
|
461
|
-
const orchestrator = getOrchestratorByChain(targetChain.id, config.apiKey, config.endpointUrl);
|
|
462
|
-
const simulationResults = await orchestrator.simulateIntent(signedIntentOp);
|
|
463
|
-
return simulationResults;
|
|
464
|
-
}
|
|
465
487
|
async function getValidatorAccount(config, signers, publicClient, chain) {
|
|
466
488
|
if (!signers) {
|
|
467
489
|
return (0, accounts_1.getSmartAccount)(config, publicClient, chain);
|
|
@@ -539,7 +561,7 @@ function createAccountAccessList(sourceChains, sourceAssets) {
|
|
|
539
561
|
}
|
|
540
562
|
return { chainTokens: sourceAssets };
|
|
541
563
|
}
|
|
542
|
-
async function getSetupOperationsAndDelegations(config,
|
|
564
|
+
async function getSetupOperationsAndDelegations(config, accountAddress, eip7702InitSignature) {
|
|
543
565
|
const initCode = (0, accounts_1.getInitCode)(config);
|
|
544
566
|
if (config.account?.type === 'eoa') {
|
|
545
567
|
return {
|
|
@@ -567,12 +589,6 @@ async function getSetupOperationsAndDelegations(config, chain, accountAddress, e
|
|
|
567
589
|
};
|
|
568
590
|
}
|
|
569
591
|
else if (initCode) {
|
|
570
|
-
const isAccountDeployed = await (0, accounts_1.isDeployed)(config, chain);
|
|
571
|
-
if (isAccountDeployed) {
|
|
572
|
-
return {
|
|
573
|
-
setupOps: [],
|
|
574
|
-
};
|
|
575
|
-
}
|
|
576
592
|
// Contract account with init code
|
|
577
593
|
return {
|
|
578
594
|
setupOps: [
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,16 +2,18 @@ import type { Address, Chain, HashTypedDataParameters, Hex, SignableMessage, Sig
|
|
|
2
2
|
import type { UserOperationReceipt } from 'viem/account-abstraction';
|
|
3
3
|
import { deployStandaloneWithEoa as deployStandaloneWithEoaInternal } from './accounts';
|
|
4
4
|
import { walletClientToAccount } from './accounts/walletClient';
|
|
5
|
-
import { encodeSmartSessionSignature } from './actions/smart-session';
|
|
6
5
|
import { type TransactionResult, type TransactionStatus, type UserOperationResult } from './execution';
|
|
7
6
|
import { type BatchPermit2Result, checkERC20AllowanceDirect, getPermit2Address, type MultiChainPermit2Config, type MultiChainPermit2Result, signPermit2Batch, signPermit2Sequential } from './execution/permit2';
|
|
8
7
|
import { type SessionDetails } from './execution/smart-session';
|
|
9
8
|
import { type IntentRoute, type PreparedTransactionData, type PreparedUserOperationData, type SignedTransactionData, type SignedUserOperationData } from './execution/utils';
|
|
10
|
-
import { getSupportedTokens, getTokenAddress, type IntentCost, type IntentInput, type IntentOp, type IntentOpStatus, type
|
|
9
|
+
import { getSupportedTokens, getTokenAddress, type IntentCost, type IntentInput, type IntentOp, type IntentOpStatus, type Portfolio, type SettlementLayer, type SignedIntentOp } from './orchestrator';
|
|
11
10
|
import type { AccountProviderConfig, AccountType, BundlerConfig, Call, CallInput, MultiFactorValidatorConfig, OwnableValidatorConfig, OwnerSet, PaymasterConfig, Policy, ProviderConfig, Recovery, RhinestoneAccountConfig, Session, SignerSet, TokenRequest, TokenSymbol, Transaction, UniversalActionPolicyParamCondition, UserOperationTransaction, WebauthnValidatorConfig } from './types';
|
|
12
11
|
interface RhinestoneAccount {
|
|
13
12
|
config: RhinestoneAccountConfig;
|
|
14
|
-
deploy: (chain: Chain,
|
|
13
|
+
deploy: (chain: Chain, params?: {
|
|
14
|
+
session?: Session;
|
|
15
|
+
sponsored?: boolean;
|
|
16
|
+
}) => Promise<boolean>;
|
|
15
17
|
isDeployed: (chain: Chain) => Promise<boolean>;
|
|
16
18
|
setup: (chain: Chain) => Promise<boolean>;
|
|
17
19
|
deployStandaloneWithEoa: (chain: Chain, config: RhinestoneAccountConfig, deployer: Account) => Promise<void>;
|
|
@@ -22,7 +24,6 @@ interface RhinestoneAccount {
|
|
|
22
24
|
signMessage: (message: SignableMessage, chain: Chain, signers: SignerSet | undefined) => Promise<Hex>;
|
|
23
25
|
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>;
|
|
24
26
|
submitTransaction: (signedTransaction: SignedTransactionData, authorizations?: SignedAuthorizationList) => Promise<TransactionResult>;
|
|
25
|
-
simulateTransaction: (signedTransaction: SignedTransactionData, authorizations?: SignedAuthorizationList) => Promise<IntentResult>;
|
|
26
27
|
sendTransaction: (transaction: Transaction) => Promise<TransactionResult>;
|
|
27
28
|
prepareUserOperation: (transaction: UserOperationTransaction) => Promise<PreparedUserOperationData>;
|
|
28
29
|
signUserOperation: (preparedUserOperation: PreparedUserOperationData) => Promise<SignedUserOperationData>;
|
|
@@ -56,8 +57,8 @@ declare class RhinestoneSDK {
|
|
|
56
57
|
});
|
|
57
58
|
createAccount(config: RhinestoneAccountConfig): Promise<RhinestoneAccount>;
|
|
58
59
|
}
|
|
59
|
-
export { RhinestoneSDK, walletClientToAccount,
|
|
60
|
-
export type { RhinestoneAccount, AccountType, RhinestoneAccountConfig, AccountProviderConfig, ProviderConfig, BundlerConfig, PaymasterConfig, Transaction, TokenSymbol, CallInput, Call, TokenRequest, OwnerSet, OwnableValidatorConfig, WebauthnValidatorConfig, MultiFactorValidatorConfig, SignerSet, Session, Recovery, Policy, UniversalActionPolicyParamCondition, PreparedTransactionData, SignedTransactionData, TransactionResult, PreparedUserOperationData, SignedUserOperationData, UserOperationResult, IntentCost, IntentInput, IntentOp, IntentOpStatus, IntentRoute,
|
|
60
|
+
export { RhinestoneSDK, walletClientToAccount, getSupportedTokens, getTokenAddress, deployStandaloneWithEoaInternal as deployStandaloneWithEoa, checkERC20AllowanceDirect, getPermit2Address, signPermit2Batch, signPermit2Sequential, };
|
|
61
|
+
export type { RhinestoneAccount, AccountType, RhinestoneAccountConfig, AccountProviderConfig, ProviderConfig, BundlerConfig, PaymasterConfig, Transaction, TokenSymbol, CallInput, Call, TokenRequest, OwnerSet, OwnableValidatorConfig, WebauthnValidatorConfig, MultiFactorValidatorConfig, SignerSet, Session, Recovery, Policy, UniversalActionPolicyParamCondition, PreparedTransactionData, SignedTransactionData, TransactionResult, PreparedUserOperationData, SignedUserOperationData, UserOperationResult, IntentCost, IntentInput, IntentOp, IntentOpStatus, IntentRoute, SettlementLayer, SignedIntentOp, Portfolio, MultiChainPermit2Config, MultiChainPermit2Result, BatchPermit2Result, };
|
|
61
62
|
export { generateCredentialId, getCredentialIds, hasCredentialById, hasCredential, addCredential, removeCredential, setThreshold, getCredentialInfo, getThreshold, getCredentials, WEBAUTHN_VALIDATOR_ABI, } from './modules/validators/webauthn-contract';
|
|
62
63
|
export { getOrchestrator } from './orchestrator';
|
|
63
64
|
//# sourceMappingURL=index.d.ts.map
|
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,OAAO,EACR,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,
|
|
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,OAAO,EACR,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,EASL,uBAAuB,IAAI,+BAA+B,EAC3D,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAKL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EAEzB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,KAAK,kBAAkB,EACvB,yBAAyB,EAEzB,iBAAiB,EACjB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,uBAAuB,EAC5B,KAAK,yBAAyB,EAG9B,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAQ7B,MAAM,mBAAmB,CAAA;AAK1B,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,KAAK,UAAU,EACf,KAAK,WAAW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AAM,EAAE,uBAAuB;CAW9C;AAED,OAAO,EACL,aAAa,EACb,qBAAqB,EAErB,kBAAkB,EAClB,eAAe,EAEf,+BAA+B,IAAI,uBAAuB,EAE1D,yBAAyB,EACzB,iBAAiB,EAEjB,gBAAgB,EAChB,qBAAqB,GACtB,CAAA;AACD,YAAY,EACV,iBAAiB,EACjB,WAAW,EACX,uBAAuB,EACvB,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,eAAe,EACf,WAAW,EACX,WAAW,EACX,SAAS,EACT,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,sBAAsB,EACtB,uBAAuB,EACvB,0BAA0B,EAC1B,SAAS,EACT,OAAO,EACP,QAAQ,EACR,MAAM,EACN,mCAAmC,EACnC,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,EACjB,yBAAyB,EACzB,uBAAuB,EACvB,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,QAAQ,EACR,cAAc,EACd,WAAW,EACX,eAAe,EACf,cAAc,EACd,SAAS,EAET,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,GACnB,CAAA;AAGD,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,sBAAsB,GACvB,MAAM,wCAAwC,CAAA;AAG/C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOrchestrator = exports.WEBAUTHN_VALIDATOR_ABI = exports.getCredentials = exports.getThreshold = exports.getCredentialInfo = exports.setThreshold = exports.removeCredential = exports.addCredential = exports.hasCredential = exports.hasCredentialById = exports.getCredentialIds = exports.generateCredentialId = exports.signPermit2Sequential = exports.signPermit2Batch = exports.getPermit2Address = exports.checkERC20AllowanceDirect = exports.deployStandaloneWithEoa = exports.getTokenAddress = exports.getSupportedTokens = exports.
|
|
3
|
+
exports.getOrchestrator = exports.WEBAUTHN_VALIDATOR_ABI = exports.getCredentials = exports.getThreshold = exports.getCredentialInfo = exports.setThreshold = exports.removeCredential = exports.addCredential = exports.hasCredential = exports.hasCredentialById = exports.getCredentialIds = exports.generateCredentialId = exports.signPermit2Sequential = exports.signPermit2Batch = exports.getPermit2Address = exports.checkERC20AllowanceDirect = exports.deployStandaloneWithEoa = exports.getTokenAddress = exports.getSupportedTokens = exports.walletClientToAccount = exports.RhinestoneSDK = void 0;
|
|
4
4
|
const accounts_1 = require("./accounts");
|
|
5
5
|
Object.defineProperty(exports, "deployStandaloneWithEoa", { enumerable: true, get: function () { return accounts_1.deployStandaloneWithEoa; } });
|
|
6
6
|
const walletClient_1 = require("./accounts/walletClient");
|
|
7
7
|
Object.defineProperty(exports, "walletClientToAccount", { enumerable: true, get: function () { return walletClient_1.walletClientToAccount; } });
|
|
8
|
-
const smart_session_1 = require("./actions/smart-session");
|
|
9
|
-
Object.defineProperty(exports, "encodeSmartSessionSignature", { enumerable: true, get: function () { return smart_session_1.encodeSmartSessionSignature; } });
|
|
10
8
|
const execution_1 = require("./execution");
|
|
11
9
|
const permit2_1 = require("./execution/permit2");
|
|
12
10
|
Object.defineProperty(exports, "checkERC20AllowanceDirect", { enumerable: true, get: function () { return permit2_1.checkERC20AllowanceDirect; } });
|
|
13
11
|
Object.defineProperty(exports, "getPermit2Address", { enumerable: true, get: function () { return permit2_1.getPermit2Address; } });
|
|
14
12
|
Object.defineProperty(exports, "signPermit2Batch", { enumerable: true, get: function () { return permit2_1.signPermit2Batch; } });
|
|
15
13
|
Object.defineProperty(exports, "signPermit2Sequential", { enumerable: true, get: function () { return permit2_1.signPermit2Sequential; } });
|
|
16
|
-
const
|
|
14
|
+
const smart_session_1 = require("./execution/smart-session");
|
|
17
15
|
const utils_1 = require("./execution/utils");
|
|
18
16
|
const modules_1 = require("./modules");
|
|
19
17
|
const orchestrator_1 = require("./orchestrator");
|
|
@@ -38,8 +36,8 @@ async function createRhinestoneAccount(config) {
|
|
|
38
36
|
* @param chain Chain to deploy the account on
|
|
39
37
|
* @param session Session to deploy the account on (optional)
|
|
40
38
|
*/
|
|
41
|
-
function deploy(chain,
|
|
42
|
-
return (0, accounts_1.deploy)(config, chain,
|
|
39
|
+
function deploy(chain, params) {
|
|
40
|
+
return (0, accounts_1.deploy)(config, chain, params);
|
|
43
41
|
}
|
|
44
42
|
/**
|
|
45
43
|
* Checks if the account is deployed on a given chain
|
|
@@ -120,9 +118,10 @@ async function createRhinestoneAccount(config) {
|
|
|
120
118
|
* @returns transaction result object (a UserOp hash)
|
|
121
119
|
* @see {@link signTransaction} to sign the transaction data
|
|
122
120
|
* @see {@link signAuthorizations} to sign the required EIP-7702 authorizations
|
|
121
|
+
* @see {@link dryRun} true when intent is not executed onchain (internal use only)
|
|
123
122
|
*/
|
|
124
|
-
function submitTransaction(signedTransaction, authorizations) {
|
|
125
|
-
return (0, utils_1.submitTransaction)(config, signedTransaction, authorizations ?? []);
|
|
123
|
+
function submitTransaction(signedTransaction, authorizations, dryRun) {
|
|
124
|
+
return (0, utils_1.submitTransaction)(config, signedTransaction, authorizations ?? [], dryRun);
|
|
126
125
|
}
|
|
127
126
|
/**
|
|
128
127
|
* Prepare a user operation data
|
|
@@ -150,16 +149,6 @@ async function createRhinestoneAccount(config) {
|
|
|
150
149
|
function submitUserOperation(signedUserOperation) {
|
|
151
150
|
return (0, utils_1.submitUserOperation)(config, signedUserOperation);
|
|
152
151
|
}
|
|
153
|
-
/**
|
|
154
|
-
* Simulate a transaction
|
|
155
|
-
* @param signedTransaction Signed transaction data
|
|
156
|
-
* @param authorizations EIP-7702 authorizations to simulate (optional)
|
|
157
|
-
* @returns simulation result
|
|
158
|
-
* @see {@link sendTransaction} to send the transaction
|
|
159
|
-
*/
|
|
160
|
-
function simulateTransaction(signedTransaction, authorizations) {
|
|
161
|
-
return (0, utils_1.simulateTransaction)(config, signedTransaction, authorizations ?? []);
|
|
162
|
-
}
|
|
163
152
|
/**
|
|
164
153
|
* Sign and send a transaction
|
|
165
154
|
* @param transaction Transaction to send
|
|
@@ -219,12 +208,12 @@ async function createRhinestoneAccount(config) {
|
|
|
219
208
|
* @returns List of account validators
|
|
220
209
|
*/
|
|
221
210
|
function getValidators(chain) {
|
|
222
|
-
const accountType = config.
|
|
211
|
+
const accountType = (0, accounts_1.getAccountProvider)(config).type;
|
|
223
212
|
const account = getAddress();
|
|
224
213
|
return (0, modules_1.getValidators)(accountType, account, chain, config.provider);
|
|
225
214
|
}
|
|
226
215
|
function getSessionDetails(sessions, sessionIndex, signature) {
|
|
227
|
-
return (0,
|
|
216
|
+
return (0, smart_session_1.getSessionDetails)(config, sessions, sessionIndex, signature);
|
|
228
217
|
}
|
|
229
218
|
/**
|
|
230
219
|
* Check ERC20 allowance for the account owner and token (using Permit2 as spender)
|
|
@@ -251,7 +240,6 @@ async function createRhinestoneAccount(config) {
|
|
|
251
240
|
signMessage,
|
|
252
241
|
signTypedData,
|
|
253
242
|
submitTransaction,
|
|
254
|
-
simulateTransaction,
|
|
255
243
|
prepareUserOperation,
|
|
256
244
|
signUserOperation,
|
|
257
245
|
submitUserOperation,
|
|
@@ -48,7 +48,7 @@ const index_1 = require("./index");
|
|
|
48
48
|
],
|
|
49
49
|
};
|
|
50
50
|
const setup = (0, index_1.getSetup)(config);
|
|
51
|
-
const smartSessionValidator = setup.validators.find((validator) => validator.address === '
|
|
51
|
+
const smartSessionValidator = setup.validators.find((validator) => validator.address === '0x00000000008bdaba73cd9815d79069c247eb4bda');
|
|
52
52
|
if (!smartSessionValidator) {
|
|
53
53
|
return;
|
|
54
54
|
}
|
package/dist/src/modules/read.js
CHANGED
|
@@ -11,10 +11,10 @@ async function getValidators(accountType, account, chain, provider) {
|
|
|
11
11
|
transport: (0, utils_1.createTransport)(chain, provider),
|
|
12
12
|
});
|
|
13
13
|
switch (accountType) {
|
|
14
|
-
case 'custom':
|
|
15
14
|
case 'safe':
|
|
16
15
|
case 'startale':
|
|
17
|
-
case 'nexus':
|
|
16
|
+
case 'nexus':
|
|
17
|
+
case 'passport': {
|
|
18
18
|
const validators = await publicClient.readContract({
|
|
19
19
|
abi: [
|
|
20
20
|
{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Address, type
|
|
2
|
-
import type { AccountType,
|
|
1
|
+
import { type Address, type Hex, type PublicClient } from 'viem';
|
|
2
|
+
import type { AccountType, RhinestoneAccountConfig, Session } from '../../types';
|
|
3
3
|
import { type Module } from '../common';
|
|
4
4
|
interface SessionData {
|
|
5
5
|
sessionValidator: Address;
|
|
@@ -82,8 +82,8 @@ declare const SMART_SESSIONS_VALIDATOR_ADDRESS: Address;
|
|
|
82
82
|
declare const SMART_SESSION_MODE_USE = "0x00";
|
|
83
83
|
declare const SMART_SESSION_MODE_ENABLE = "0x01";
|
|
84
84
|
declare const SMART_SESSION_MODE_UNSAFE_ENABLE = "0x02";
|
|
85
|
-
declare function getSessionData(
|
|
86
|
-
declare function getEnableSessionCall(
|
|
85
|
+
declare function getSessionData(session: Session): Promise<SessionData>;
|
|
86
|
+
declare function getEnableSessionCall(session: Session): Promise<{
|
|
87
87
|
to: `0x${string}`;
|
|
88
88
|
data: `0x${string}`;
|
|
89
89
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smart-sessions.d.ts","sourceRoot":"","sources":["../../../../modules/validators/smart-sessions.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,OAAO,
|
|
1
|
+
{"version":3,"file":"smart-sessions.d.ts","sourceRoot":"","sources":["../../../../modules/validators/smart-sessions.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,OAAO,EAMZ,KAAK,GAAG,EAGR,KAAK,YAAY,EAKlB,MAAM,MAAM,CAAA;AAMb,OAAO,KAAK,EACV,WAAW,EAGX,uBAAuB,EACvB,O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