@charterlabs/rhinestone-sdk 0.2.7-dev.4 → 0.2.9
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/error.d.ts +4 -1
- package/dist/src/accounts/error.d.ts.map +1 -1
- package/dist/src/accounts/error.js +9 -1
- package/dist/src/accounts/index.d.ts +13 -3
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +62 -6
- package/dist/src/accounts/json-rpc/index.d.ts.map +1 -1
- package/dist/src/accounts/json-rpc/index.js +4 -0
- package/dist/src/accounts/json-rpc/index.test.d.ts +2 -0
- package/dist/src/accounts/json-rpc/index.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.test.js +33 -0
- package/dist/src/accounts/json-rpc/providers.d.ts +2 -1
- package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -1
- package/dist/src/accounts/json-rpc/providers.js +8 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts +2 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.test.js +43 -0
- package/dist/src/accounts/kernel.d.ts +9 -2
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +13 -0
- package/dist/src/accounts/nexus.d.ts +9 -2
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +15 -1
- 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/accounts/safe.d.ts +9 -2
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +15 -0
- package/dist/src/accounts/signing/common.d.ts.map +1 -1
- package/dist/src/accounts/signing/common.js +26 -5
- package/dist/src/accounts/signing/message.js +1 -1
- package/dist/src/accounts/startale.d.ts +9 -2
- package/dist/src/accounts/startale.d.ts.map +1 -1
- package/dist/src/accounts/startale.js +15 -0
- package/dist/src/accounts/walletClient.d.ts +27 -0
- package/dist/src/accounts/walletClient.d.ts.map +1 -1
- package/dist/src/accounts/walletClient.js +77 -0
- package/dist/src/actions/smart-sessions.d.ts +14 -0
- package/dist/src/actions/smart-sessions.d.ts.map +1 -0
- package/dist/src/actions/smart-sessions.js +16 -0
- package/dist/src/errors/index.d.ts +3 -3
- package/dist/src/errors/index.d.ts.map +1 -1
- package/dist/src/errors/index.js +18 -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 +10 -4
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +85 -12
- 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/singleChainOps.d.ts +28 -0
- package/dist/src/execution/singleChainOps.d.ts.map +1 -0
- package/dist/src/execution/singleChainOps.js +32 -0
- package/dist/src/execution/smart-session.d.ts +5 -7
- package/dist/src/execution/smart-session.d.ts.map +1 -1
- package/dist/src/execution/smart-session.js +114 -229
- 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 +16 -9
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +151 -76
- package/dist/src/index.d.ts +18 -19
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +22 -25
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +1 -1
- package/dist/src/modules/index.test.js +1 -1
- package/dist/src/modules/read.js +2 -2
- package/dist/src/modules/validators/core.d.ts +5 -3
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +39 -2
- package/dist/src/modules/validators/smart-sessions.d.ts +8 -8
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions.js +29 -80
- 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 +230 -172
- package/dist/src/orchestrator/error.d.ts +137 -1
- package/dist/src/orchestrator/error.d.ts.map +1 -1
- package/dist/src/orchestrator/error.js +137 -1
- package/dist/src/orchestrator/index.d.ts +6 -6
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +19 -3
- package/dist/src/orchestrator/registry.d.ts +6 -2
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +16 -64
- package/dist/src/orchestrator/registry.test.js +24 -24
- package/dist/src/orchestrator/types.d.ts +63 -43
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/orchestrator/types.js +9 -5
- package/dist/src/types.d.ts +42 -9
- 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 +4 -4
- package/dist/src/actions/smart-session.d.ts +0 -11
- package/dist/src/actions/smart-session.d.ts.map +0 -1
- package/dist/src/actions/smart-session.js +0 -13
- package/dist/src/execution/smart-session.test.d.ts +0 -2
- package/dist/src/execution/smart-session.test.d.ts.map +0 -1
- package/dist/src/execution/smart-session.test.js +0 -34
|
@@ -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,31 +14,34 @@ 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;
|
|
22
20
|
exports.resolveCallInputs = resolveCallInputs;
|
|
23
21
|
const viem_1 = require("viem");
|
|
24
22
|
const account_abstraction_1 = require("viem/account-abstraction");
|
|
23
|
+
const erc7739_1 = require("viem/experimental/erc7739");
|
|
25
24
|
const accounts_1 = require("../accounts");
|
|
26
25
|
const utils_1 = require("../accounts/utils");
|
|
26
|
+
const modules_1 = require("../modules");
|
|
27
27
|
const validators_1 = require("../modules/validators");
|
|
28
28
|
const core_1 = require("../modules/validators/core");
|
|
29
29
|
const orchestrator_1 = require("../orchestrator");
|
|
30
30
|
const consts_1 = require("../orchestrator/consts");
|
|
31
31
|
const registry_1 = require("../orchestrator/registry");
|
|
32
|
+
const types_1 = require("../orchestrator/types");
|
|
32
33
|
const compact_1 = require("./compact");
|
|
33
34
|
const error_1 = require("./error");
|
|
34
35
|
const permit2_1 = require("./permit2");
|
|
36
|
+
const singleChainOps_1 = require("./singleChainOps");
|
|
35
37
|
async function prepareTransaction(config, transaction) {
|
|
36
|
-
const { sourceChains, targetChain, tokenRequests, signers, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, } = getTransactionParams(transaction);
|
|
38
|
+
const { sourceChains, targetChain, tokenRequests, signers, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, account, recipient, } = getTransactionParams(transaction);
|
|
37
39
|
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
38
40
|
const isUserOpSigner = signers?.type === 'guardians' || signers?.type === 'session';
|
|
39
41
|
if (isUserOpSigner) {
|
|
40
42
|
throw new error_1.SignerNotSupportedError();
|
|
41
43
|
}
|
|
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);
|
|
44
|
+
const intentRoute = await prepareTransactionAsIntent(config, sourceChains, targetChain, await resolveCallInputs(transaction.calls, config, targetChain, accountAddress), transaction.gasLimit, tokenRequests, recipient, accountAddress, sponsored ?? false, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, account);
|
|
43
45
|
return {
|
|
44
46
|
intentRoute,
|
|
45
47
|
transaction,
|
|
@@ -77,11 +79,12 @@ async function resolveCallInputs(inputs, config, chain, accountAddress) {
|
|
|
77
79
|
async function signTransaction(config, preparedTransaction) {
|
|
78
80
|
const { targetChain, signers } = getTransactionParams(preparedTransaction.transaction);
|
|
79
81
|
const intentRoute = preparedTransaction.intentRoute;
|
|
80
|
-
const
|
|
82
|
+
const { originSignatures, destinationSignature } = await signIntent(config, targetChain, intentRoute.intentOp, signers);
|
|
81
83
|
return {
|
|
82
84
|
intentRoute,
|
|
83
85
|
transaction: preparedTransaction.transaction,
|
|
84
|
-
|
|
86
|
+
originSignatures,
|
|
87
|
+
destinationSignature,
|
|
85
88
|
};
|
|
86
89
|
}
|
|
87
90
|
async function signUserOperation(config, preparedUserOperation) {
|
|
@@ -121,12 +124,54 @@ async function signTypedData(config, parameters, chain, signers) {
|
|
|
121
124
|
}
|
|
122
125
|
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
123
126
|
const isRoot = validator.address === ownerValidator.address;
|
|
127
|
+
if (signers?.type === 'session') {
|
|
128
|
+
return await signTypedDataWithSession(config, chain, {
|
|
129
|
+
address: validator.address,
|
|
130
|
+
isRoot,
|
|
131
|
+
}, signers, parameters);
|
|
132
|
+
}
|
|
124
133
|
const signature = await (0, accounts_1.getTypedDataPackedSignature)(config, signers, chain, {
|
|
125
134
|
address: validator.address,
|
|
126
135
|
isRoot,
|
|
127
136
|
}, parameters);
|
|
128
137
|
return await (0, accounts_1.toErc6492Signature)(config, signature, chain);
|
|
129
138
|
}
|
|
139
|
+
async function signTypedDataWithSession(config, chain, validator, signers, parameters) {
|
|
140
|
+
const { name, version, chainId, verifyingContract, salt } = (0, accounts_1.getEip712Domain)(config, chain);
|
|
141
|
+
const signature = await (0, accounts_1.getTypedDataPackedSignature)(config, signers, chain, validator, {
|
|
142
|
+
domain: parameters.domain,
|
|
143
|
+
primaryType: 'TypedDataSign',
|
|
144
|
+
types: {
|
|
145
|
+
...parameters.types,
|
|
146
|
+
TypedDataSign: [
|
|
147
|
+
{ name: 'contents', type: parameters.primaryType },
|
|
148
|
+
{ name: 'name', type: 'string' },
|
|
149
|
+
{ name: 'version', type: 'string' },
|
|
150
|
+
{ name: 'chainId', type: 'uint256' },
|
|
151
|
+
{ name: 'verifyingContract', type: 'address' },
|
|
152
|
+
{ name: 'salt', type: 'bytes32' },
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
message: {
|
|
156
|
+
contents: parameters.message,
|
|
157
|
+
name,
|
|
158
|
+
version,
|
|
159
|
+
chainId,
|
|
160
|
+
verifyingContract,
|
|
161
|
+
salt,
|
|
162
|
+
},
|
|
163
|
+
}, (signature) => {
|
|
164
|
+
const erc7739Signature = (0, erc7739_1.wrapTypedDataSignature)({
|
|
165
|
+
domain: parameters.domain,
|
|
166
|
+
primaryType: parameters.primaryType,
|
|
167
|
+
types: parameters.types,
|
|
168
|
+
message: parameters.message,
|
|
169
|
+
signature,
|
|
170
|
+
});
|
|
171
|
+
return (0, viem_1.encodePacked)(['bytes32', 'bytes'], [(0, validators_1.getPermissionId)(signers.session), erc7739Signature]);
|
|
172
|
+
});
|
|
173
|
+
return await (0, accounts_1.toErc6492Signature)(config, signature, chain);
|
|
174
|
+
}
|
|
130
175
|
async function signAuthorizationsInternal(config, data) {
|
|
131
176
|
const eoa = config.eoa;
|
|
132
177
|
if (!eoa) {
|
|
@@ -163,11 +208,11 @@ async function signAuthorizationsInternal(config, data) {
|
|
|
163
208
|
}
|
|
164
209
|
return authorizations;
|
|
165
210
|
}
|
|
166
|
-
async function submitTransaction(config, signedTransaction, authorizations) {
|
|
167
|
-
const { intentRoute, transaction,
|
|
211
|
+
async function submitTransaction(config, signedTransaction, authorizations, dryRun = false) {
|
|
212
|
+
const { intentRoute, transaction, originSignatures, destinationSignature } = signedTransaction;
|
|
168
213
|
const { sourceChains, targetChain } = getTransactionParams(transaction);
|
|
169
214
|
const intentOp = intentRoute.intentOp;
|
|
170
|
-
return await submitIntent(config, sourceChains, targetChain, intentOp,
|
|
215
|
+
return await submitIntent(config, sourceChains, targetChain, intentOp, originSignatures, destinationSignature, authorizations, dryRun);
|
|
171
216
|
}
|
|
172
217
|
async function submitUserOperation(config, signedUserOperation) {
|
|
173
218
|
const chain = signedUserOperation.transaction.chain;
|
|
@@ -176,15 +221,6 @@ async function submitUserOperation(config, signedUserOperation) {
|
|
|
176
221
|
// Smart sessions require a UserOp flow
|
|
177
222
|
return await submitUserOp(config, chain, userOp, signature);
|
|
178
223
|
}
|
|
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
224
|
function getTransactionParams(transaction) {
|
|
189
225
|
const sourceChains = 'chain' in transaction ? [transaction.chain] : transaction.sourceChains;
|
|
190
226
|
const targetChain = 'chain' in transaction ? transaction.chain : transaction.targetChain;
|
|
@@ -197,6 +233,8 @@ function getTransactionParams(transaction) {
|
|
|
197
233
|
const sourceAssets = transaction.sourceAssets;
|
|
198
234
|
const feeAsset = transaction.feeAsset;
|
|
199
235
|
const lockFunds = transaction.lockFunds;
|
|
236
|
+
const account = transaction.experimental_accountOverride;
|
|
237
|
+
const recipient = transaction.recipient;
|
|
200
238
|
const tokenRequests = getTokenRequests(sourceChains || [], targetChain, initialTokenRequests, settlementLayers);
|
|
201
239
|
return {
|
|
202
240
|
sourceChains,
|
|
@@ -210,6 +248,8 @@ function getTransactionParams(transaction) {
|
|
|
210
248
|
sourceAssets,
|
|
211
249
|
feeAsset,
|
|
212
250
|
lockFunds,
|
|
251
|
+
account,
|
|
252
|
+
recipient,
|
|
213
253
|
};
|
|
214
254
|
}
|
|
215
255
|
function getTokenRequests(sourceChains, targetChain, initialTokenRequests, settlementLayers) {
|
|
@@ -256,10 +296,10 @@ async function prepareTransactionAsUserOp(config, chain, callInputs, signers, ga
|
|
|
256
296
|
}),
|
|
257
297
|
};
|
|
258
298
|
}
|
|
259
|
-
async function prepareTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, isSponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds) {
|
|
299
|
+
async function prepareTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, recipient, accountAddress, isSponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, account) {
|
|
260
300
|
const calls = parseCalls(callInputs, targetChain.id);
|
|
261
301
|
const accountAccessList = createAccountAccessList(sourceChains, sourceAssets);
|
|
262
|
-
const { setupOps, delegations } = await getSetupOperationsAndDelegations(config,
|
|
302
|
+
const { setupOps, delegations } = await getSetupOperationsAndDelegations(config, accountAddress, eip7702InitSignature);
|
|
263
303
|
const getAccountType = (config) => {
|
|
264
304
|
if (config.account?.type === 'eoa') {
|
|
265
305
|
return 'EOA';
|
|
@@ -271,17 +311,22 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
271
311
|
const accountType = getAccountType(config);
|
|
272
312
|
const metaIntent = {
|
|
273
313
|
destinationChainId: targetChain.id,
|
|
274
|
-
|
|
314
|
+
tokenRequests: tokenRequests.map((tokenRequest) => ({
|
|
275
315
|
tokenAddress: (0, registry_1.resolveTokenAddress)(tokenRequest.address, targetChain.id),
|
|
276
316
|
amount: tokenRequest.amount,
|
|
277
317
|
})),
|
|
318
|
+
recipient,
|
|
278
319
|
account: {
|
|
279
320
|
address: accountAddress,
|
|
280
321
|
accountType: accountType,
|
|
281
|
-
setupOps,
|
|
322
|
+
setupOps: account?.setupOps ?? setupOps,
|
|
282
323
|
delegations,
|
|
283
324
|
},
|
|
284
|
-
destinationExecutions: calls
|
|
325
|
+
destinationExecutions: calls.map((call) => ({
|
|
326
|
+
to: call.to,
|
|
327
|
+
value: call.value.toString(),
|
|
328
|
+
data: call.data,
|
|
329
|
+
})),
|
|
285
330
|
destinationGasUnits: gasLimit,
|
|
286
331
|
accountAccessList,
|
|
287
332
|
options: {
|
|
@@ -301,26 +346,32 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
301
346
|
}
|
|
302
347
|
async function signIntent(config, targetChain, intentOp, signers) {
|
|
303
348
|
if (config.account?.type === 'eoa') {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
349
|
+
const originSignatures = [];
|
|
350
|
+
for (const element of intentOp.elements) {
|
|
351
|
+
let digest;
|
|
352
|
+
if (config.eoa?.signTypedData) {
|
|
353
|
+
const typedData = (0, permit2_1.getTypedData)(element, BigInt(intentOp.nonce), BigInt(intentOp.expires));
|
|
354
|
+
originSignatures.push(await config.eoa.signTypedData(typedData));
|
|
355
|
+
}
|
|
356
|
+
else if (config.eoa?.sign) {
|
|
357
|
+
digest = (0, compact_1.getPermit2Digest)(element, BigInt(intentOp.nonce), BigInt(intentOp.expires));
|
|
358
|
+
originSignatures.push(await config.eoa.sign({ hash: digest }));
|
|
359
|
+
}
|
|
360
|
+
else if (config.eoa?.signMessage) {
|
|
361
|
+
digest = (0, compact_1.getPermit2Digest)(element, BigInt(intentOp.nonce), BigInt(intentOp.expires));
|
|
362
|
+
originSignatures.push(await config.eoa.signMessage({
|
|
363
|
+
message: { raw: digest },
|
|
364
|
+
}));
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
throw new accounts_1.EoaSigningMethodNotConfiguredError('signTypedData, sign, or signMessage');
|
|
368
|
+
}
|
|
322
369
|
}
|
|
323
|
-
|
|
370
|
+
const destinationSignature = originSignatures.at(-1);
|
|
371
|
+
return {
|
|
372
|
+
originSignatures,
|
|
373
|
+
destinationSignature,
|
|
374
|
+
};
|
|
324
375
|
}
|
|
325
376
|
const validator = getValidator(config, signers);
|
|
326
377
|
if (!validator) {
|
|
@@ -328,19 +379,57 @@ async function signIntent(config, targetChain, intentOp, signers) {
|
|
|
328
379
|
}
|
|
329
380
|
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
330
381
|
const isRoot = validator.address === ownerValidator.address;
|
|
331
|
-
const
|
|
332
|
-
return
|
|
382
|
+
const signatures = await getIntentSignature(config, intentOp, signers, targetChain, validator, isRoot);
|
|
383
|
+
return {
|
|
384
|
+
originSignatures: signatures.originSignatures,
|
|
385
|
+
destinationSignature: signatures.destinationSignature,
|
|
386
|
+
};
|
|
333
387
|
}
|
|
334
388
|
async function getIntentSignature(config, intentOp, signers, targetChain, validator, isRoot) {
|
|
335
|
-
const
|
|
336
|
-
|
|
337
|
-
|
|
389
|
+
const withPermit2 = intentOp.elements.some((element) => element.mandate.qualifier.settlementContext?.fundingMethod ===
|
|
390
|
+
types_1.FundingMethod.PERMIT2);
|
|
391
|
+
const withIntentExecutorOps = intentOp.elements.some((element) => element.mandate.qualifier.settlementContext.settlementLayer ===
|
|
392
|
+
'INTENT_EXECUTOR');
|
|
393
|
+
if (withIntentExecutorOps) {
|
|
394
|
+
const signature = await getSingleChainOpsSignature(config, intentOp, signers, targetChain, validator, isRoot);
|
|
395
|
+
return signature;
|
|
396
|
+
}
|
|
397
|
+
if (withPermit2) {
|
|
398
|
+
return await getPermit2Signatures(config, intentOp, signers, targetChain, validator, isRoot);
|
|
338
399
|
}
|
|
339
|
-
|
|
400
|
+
const signature = await getCompactSignature(config, intentOp, signers, targetChain, validator, isRoot);
|
|
401
|
+
return {
|
|
402
|
+
originSignatures: Array(intentOp.elements.length).fill(signature),
|
|
403
|
+
destinationSignature: signature,
|
|
404
|
+
};
|
|
340
405
|
}
|
|
341
|
-
async function
|
|
342
|
-
const
|
|
343
|
-
|
|
406
|
+
async function getSingleChainOpsSignature(config, intentOp, signers, targetChain, validator, isRoot) {
|
|
407
|
+
const address = (0, accounts_1.getAddress)(config);
|
|
408
|
+
const intentExecutor = (0, modules_1.getIntentExecutor)(config);
|
|
409
|
+
const originSignatures = [];
|
|
410
|
+
for (const element of intentOp.elements) {
|
|
411
|
+
const typedData = (0, singleChainOps_1.getTypedData)(address, intentExecutor.address, element, BigInt(intentOp.nonce));
|
|
412
|
+
const signature = await signIntentTypedData(config, signers, targetChain, validator, isRoot, typedData);
|
|
413
|
+
originSignatures.push(signature);
|
|
414
|
+
}
|
|
415
|
+
const destinationSignature = originSignatures.at(-1);
|
|
416
|
+
return {
|
|
417
|
+
originSignatures,
|
|
418
|
+
destinationSignature,
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
async function getPermit2Signatures(config, intentOp, signers, targetChain, validator, isRoot) {
|
|
422
|
+
const originSignatures = [];
|
|
423
|
+
for (const element of intentOp.elements) {
|
|
424
|
+
const typedData = (0, permit2_1.getTypedData)(element, BigInt(intentOp.nonce), BigInt(intentOp.expires));
|
|
425
|
+
const signature = await signIntentTypedData(config, signers, targetChain, validator, isRoot, typedData);
|
|
426
|
+
originSignatures.push(signature);
|
|
427
|
+
}
|
|
428
|
+
const destinationSignature = originSignatures.at(-1);
|
|
429
|
+
return {
|
|
430
|
+
originSignatures,
|
|
431
|
+
destinationSignature,
|
|
432
|
+
};
|
|
344
433
|
}
|
|
345
434
|
async function getCompactSignature(config, intentOp, signers, targetChain, validator, isRoot) {
|
|
346
435
|
const typedData = (0, compact_1.getCompactTypedData)(intentOp);
|
|
@@ -413,8 +502,8 @@ async function submitUserOp(config, chain, userOp, signature) {
|
|
|
413
502
|
chain: chain.id,
|
|
414
503
|
};
|
|
415
504
|
}
|
|
416
|
-
async function submitIntent(config, sourceChains, targetChain, intentOp,
|
|
417
|
-
return submitIntentInternal(config, sourceChains, targetChain, intentOp,
|
|
505
|
+
async function submitIntent(config, sourceChains, targetChain, intentOp, originSignatures, destinationSignature, authorizations, dryRun) {
|
|
506
|
+
return submitIntentInternal(config, sourceChains, targetChain, intentOp, originSignatures, destinationSignature, authorizations, dryRun);
|
|
418
507
|
}
|
|
419
508
|
function getOrchestratorByChain(chainId, apiKey, orchestratorUrl) {
|
|
420
509
|
if (orchestratorUrl) {
|
|
@@ -425,14 +514,11 @@ function getOrchestratorByChain(chainId, apiKey, orchestratorUrl) {
|
|
|
425
514
|
: consts_1.PROD_ORCHESTRATOR_URL;
|
|
426
515
|
return (0, orchestrator_1.getOrchestrator)(apiKey, defaultOrchestratorUrl);
|
|
427
516
|
}
|
|
428
|
-
|
|
429
|
-
return simulateIntentInternal(config, sourceChains, targetChain, intentOp, signature, authorizations);
|
|
430
|
-
}
|
|
431
|
-
function createSignedIntentOp(intentOp, signature, authorizations) {
|
|
517
|
+
function createSignedIntentOp(intentOp, originSignatures, destinationSignature, authorizations) {
|
|
432
518
|
return {
|
|
433
519
|
...intentOp,
|
|
434
|
-
originSignatures
|
|
435
|
-
destinationSignature
|
|
520
|
+
originSignatures,
|
|
521
|
+
destinationSignature,
|
|
436
522
|
signedAuthorizations: authorizations.length > 0
|
|
437
523
|
? authorizations.map((authorization) => ({
|
|
438
524
|
chainId: authorization.chainId,
|
|
@@ -445,10 +531,10 @@ function createSignedIntentOp(intentOp, signature, authorizations) {
|
|
|
445
531
|
: undefined,
|
|
446
532
|
};
|
|
447
533
|
}
|
|
448
|
-
async function submitIntentInternal(config, sourceChains, targetChain, intentOp,
|
|
449
|
-
const signedIntentOp = createSignedIntentOp(intentOp,
|
|
534
|
+
async function submitIntentInternal(config, sourceChains, targetChain, intentOp, originSignatures, destinationSignature, authorizations, dryRun) {
|
|
535
|
+
const signedIntentOp = createSignedIntentOp(intentOp, originSignatures, destinationSignature, authorizations);
|
|
450
536
|
const orchestrator = getOrchestratorByChain(targetChain.id, config.apiKey, config.endpointUrl);
|
|
451
|
-
const intentResults = await orchestrator.submitIntent(signedIntentOp);
|
|
537
|
+
const intentResults = await orchestrator.submitIntent(signedIntentOp, dryRun);
|
|
452
538
|
return {
|
|
453
539
|
type: 'intent',
|
|
454
540
|
id: BigInt(intentResults.result.id),
|
|
@@ -456,12 +542,6 @@ async function submitIntentInternal(config, sourceChains, targetChain, intentOp,
|
|
|
456
542
|
targetChain: targetChain.id,
|
|
457
543
|
};
|
|
458
544
|
}
|
|
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
545
|
async function getValidatorAccount(config, signers, publicClient, chain) {
|
|
466
546
|
if (!signers) {
|
|
467
547
|
return (0, accounts_1.getSmartAccount)(config, publicClient, chain);
|
|
@@ -491,7 +571,8 @@ function getValidator(config, signers) {
|
|
|
491
571
|
if (withOwner) {
|
|
492
572
|
// ECDSA
|
|
493
573
|
if (withOwner.kind === 'ecdsa') {
|
|
494
|
-
|
|
574
|
+
// Use the configured owner validator (e.g., ENS) rather than forcing Ownable
|
|
575
|
+
return (0, validators_1.getOwnerValidator)(config);
|
|
495
576
|
}
|
|
496
577
|
// Passkeys (WebAuthn)
|
|
497
578
|
if (withOwner.kind === 'passkey') {
|
|
@@ -539,7 +620,7 @@ function createAccountAccessList(sourceChains, sourceAssets) {
|
|
|
539
620
|
}
|
|
540
621
|
return { chainTokens: sourceAssets };
|
|
541
622
|
}
|
|
542
|
-
async function getSetupOperationsAndDelegations(config,
|
|
623
|
+
async function getSetupOperationsAndDelegations(config, accountAddress, eip7702InitSignature) {
|
|
543
624
|
const initCode = (0, accounts_1.getInitCode)(config);
|
|
544
625
|
if (config.account?.type === 'eoa') {
|
|
545
626
|
return {
|
|
@@ -567,12 +648,6 @@ async function getSetupOperationsAndDelegations(config, chain, accountAddress, e
|
|
|
567
648
|
};
|
|
568
649
|
}
|
|
569
650
|
else if (initCode) {
|
|
570
|
-
const isAccountDeployed = await (0, accounts_1.isDeployed)(config, chain);
|
|
571
|
-
if (isAccountDeployed) {
|
|
572
|
-
return {
|
|
573
|
-
setupOps: [],
|
|
574
|
-
};
|
|
575
|
-
}
|
|
576
651
|
// Contract account with init code
|
|
577
652
|
return {
|
|
578
653
|
setupOps: [
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import type { Address, Chain, HashTypedDataParameters, Hex, SignableMessage, SignedAuthorizationList, TypedData, Account } from 'viem';
|
|
2
2
|
import type { UserOperationReceipt } from 'viem/account-abstraction';
|
|
3
|
-
import { deployStandaloneWithEoa as deployStandaloneWithEoaInternal } from './accounts';
|
|
4
|
-
import { walletClientToAccount } from './accounts/walletClient';
|
|
5
|
-
import { encodeSmartSessionSignature } from './actions/smart-session';
|
|
3
|
+
import { getInitCode, deployStandaloneWithEoa as deployStandaloneWithEoaInternal } from './accounts';
|
|
4
|
+
import { walletClientToAccount, wrapParaAccount } from './accounts/walletClient';
|
|
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
|
|
11
|
-
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';
|
|
9
|
+
import { type ApprovalRequired, getAllSupportedChainsAndTokens, getSupportedTokens, getTokenAddress, type IntentCost, type IntentInput, type IntentOp, type IntentOpStatus, type Portfolio, type SettlementLayer, type SignedIntentOp, type TokenRequirements, type WrapRequired } from './orchestrator';
|
|
10
|
+
import type { AccountProviderConfig, AccountType, BundlerConfig, Call, CallInput, MultiFactorValidatorConfig, OwnableValidatorConfig, OwnerSet, PaymasterConfig, Policy, ProviderConfig, Recovery, RhinestoneAccountConfig, RhinestoneSDKConfig, 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>;
|
|
@@ -21,8 +23,7 @@ interface RhinestoneAccount {
|
|
|
21
23
|
signAuthorizations: (preparedTransaction: PreparedTransactionData) => Promise<SignedAuthorizationList>;
|
|
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
|
-
submitTransaction: (signedTransaction: SignedTransactionData, authorizations?: SignedAuthorizationList) => Promise<TransactionResult>;
|
|
25
|
-
simulateTransaction: (signedTransaction: SignedTransactionData, authorizations?: SignedAuthorizationList) => Promise<IntentResult>;
|
|
26
|
+
submitTransaction: (signedTransaction: SignedTransactionData, authorizations?: SignedAuthorizationList, dryRun?: boolean) => Promise<TransactionResult>;
|
|
26
27
|
sendTransaction: (transaction: Transaction) => Promise<TransactionResult>;
|
|
27
28
|
prepareUserOperation: (transaction: UserOperationTransaction) => Promise<PreparedUserOperationData>;
|
|
28
29
|
signUserOperation: (preparedUserOperation: PreparedUserOperationData) => Promise<SignedUserOperationData>;
|
|
@@ -32,8 +33,8 @@ interface RhinestoneAccount {
|
|
|
32
33
|
waitForExecution(result: UserOperationResult, acceptsPreconfirmations?: boolean): Promise<UserOperationReceipt>;
|
|
33
34
|
getAddress: () => Address;
|
|
34
35
|
getPortfolio: (onTestnets?: boolean) => Promise<Portfolio>;
|
|
35
|
-
getMaxSpendableAmount: (chain: Chain, tokenAddress: Address, gasUnits: bigint, sponsored?: boolean) => Promise<bigint>;
|
|
36
|
-
getSessionDetails: (sessions: Session[], sessionIndex: number, signature?: Hex) => Promise<SessionDetails>;
|
|
36
|
+
getMaxSpendableAmount: (chain: Chain, tokenAddress: Address | TokenSymbol, gasUnits: bigint, sponsored?: boolean) => Promise<bigint>;
|
|
37
|
+
getSessionDetails: (sessions: Session[], sessionIndex: number, initialNonces?: bigint[], signature?: Hex) => Promise<SessionDetails>;
|
|
37
38
|
getOwners: (chain: Chain) => Promise<{
|
|
38
39
|
accounts: Address[];
|
|
39
40
|
threshold: number;
|
|
@@ -47,17 +48,15 @@ declare class RhinestoneSDK {
|
|
|
47
48
|
private provider?;
|
|
48
49
|
private bundler?;
|
|
49
50
|
private paymaster?;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
endpointUrl?: string;
|
|
53
|
-
provider?: ProviderConfig;
|
|
54
|
-
bundler?: BundlerConfig;
|
|
55
|
-
paymaster?: PaymasterConfig;
|
|
56
|
-
});
|
|
51
|
+
private useDevContracts?;
|
|
52
|
+
constructor(options?: RhinestoneSDKConfig);
|
|
57
53
|
createAccount(config: RhinestoneAccountConfig): Promise<RhinestoneAccount>;
|
|
54
|
+
getIntentStatus(intentId: bigint): Promise<TransactionStatus & {
|
|
55
|
+
status: IntentOpStatus["status"];
|
|
56
|
+
}>;
|
|
58
57
|
}
|
|
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,
|
|
58
|
+
export { RhinestoneSDK, walletClientToAccount, wrapParaAccount, getInitCode, getSupportedTokens, getTokenAddress, getAllSupportedChainsAndTokens, deployStandaloneWithEoaInternal as deployStandaloneWithEoa, checkERC20AllowanceDirect, getPermit2Address, signPermit2Batch, signPermit2Sequential, };
|
|
59
|
+
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, TokenRequirements, WrapRequired, ApprovalRequired, MultiChainPermit2Config, MultiChainPermit2Result, BatchPermit2Result, };
|
|
61
60
|
export { generateCredentialId, getCredentialIds, hasCredentialById, hasCredential, addCredential, removeCredential, setThreshold, getCredentialInfo, getThreshold, getCredentials, WEBAUTHN_VALIDATOR_ABI, } from './modules/validators/webauthn-contract';
|
|
62
61
|
export { getOrchestrator } from './orchestrator';
|
|
63
62
|
//# 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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b,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,EACT,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAEhB,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,22 +1,23 @@
|
|
|
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.getAllSupportedChainsAndTokens = exports.getTokenAddress = exports.getSupportedTokens = exports.getInitCode = exports.wrapParaAccount = exports.walletClientToAccount = exports.RhinestoneSDK = void 0;
|
|
4
4
|
const accounts_1 = require("./accounts");
|
|
5
|
+
Object.defineProperty(exports, "getInitCode", { enumerable: true, get: function () { return accounts_1.getInitCode; } });
|
|
5
6
|
Object.defineProperty(exports, "deployStandaloneWithEoa", { enumerable: true, get: function () { return accounts_1.deployStandaloneWithEoa; } });
|
|
6
7
|
const walletClient_1 = require("./accounts/walletClient");
|
|
7
8
|
Object.defineProperty(exports, "walletClientToAccount", { enumerable: true, get: function () { return walletClient_1.walletClientToAccount; } });
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(exports, "encodeSmartSessionSignature", { enumerable: true, get: function () { return smart_session_1.encodeSmartSessionSignature; } });
|
|
9
|
+
Object.defineProperty(exports, "wrapParaAccount", { enumerable: true, get: function () { return walletClient_1.wrapParaAccount; } });
|
|
10
10
|
const execution_1 = require("./execution");
|
|
11
11
|
const permit2_1 = require("./execution/permit2");
|
|
12
12
|
Object.defineProperty(exports, "checkERC20AllowanceDirect", { enumerable: true, get: function () { return permit2_1.checkERC20AllowanceDirect; } });
|
|
13
13
|
Object.defineProperty(exports, "getPermit2Address", { enumerable: true, get: function () { return permit2_1.getPermit2Address; } });
|
|
14
14
|
Object.defineProperty(exports, "signPermit2Batch", { enumerable: true, get: function () { return permit2_1.signPermit2Batch; } });
|
|
15
15
|
Object.defineProperty(exports, "signPermit2Sequential", { enumerable: true, get: function () { return permit2_1.signPermit2Sequential; } });
|
|
16
|
-
const
|
|
16
|
+
const smart_session_1 = require("./execution/smart-session");
|
|
17
17
|
const utils_1 = require("./execution/utils");
|
|
18
18
|
const modules_1 = require("./modules");
|
|
19
19
|
const orchestrator_1 = require("./orchestrator");
|
|
20
|
+
Object.defineProperty(exports, "getAllSupportedChainsAndTokens", { enumerable: true, get: function () { return orchestrator_1.getAllSupportedChainsAndTokens; } });
|
|
20
21
|
Object.defineProperty(exports, "getSupportedTokens", { enumerable: true, get: function () { return orchestrator_1.getSupportedTokens; } });
|
|
21
22
|
Object.defineProperty(exports, "getTokenAddress", { enumerable: true, get: function () { return orchestrator_1.getTokenAddress; } });
|
|
22
23
|
/**
|
|
@@ -38,8 +39,8 @@ async function createRhinestoneAccount(config) {
|
|
|
38
39
|
* @param chain Chain to deploy the account on
|
|
39
40
|
* @param session Session to deploy the account on (optional)
|
|
40
41
|
*/
|
|
41
|
-
function deploy(chain,
|
|
42
|
-
return (0, accounts_1.deploy)(config, chain,
|
|
42
|
+
function deploy(chain, params) {
|
|
43
|
+
return (0, accounts_1.deploy)(config, chain, params);
|
|
43
44
|
}
|
|
44
45
|
/**
|
|
45
46
|
* Checks if the account is deployed on a given chain
|
|
@@ -120,9 +121,10 @@ async function createRhinestoneAccount(config) {
|
|
|
120
121
|
* @returns transaction result object (a UserOp hash)
|
|
121
122
|
* @see {@link signTransaction} to sign the transaction data
|
|
122
123
|
* @see {@link signAuthorizations} to sign the required EIP-7702 authorizations
|
|
124
|
+
* @see {@link dryRun} true when intent is not executed onchain (internal use only)
|
|
123
125
|
*/
|
|
124
|
-
function submitTransaction(signedTransaction, authorizations) {
|
|
125
|
-
return (0, utils_1.submitTransaction)(config, signedTransaction, authorizations ?? []);
|
|
126
|
+
function submitTransaction(signedTransaction, authorizations, dryRun) {
|
|
127
|
+
return (0, utils_1.submitTransaction)(config, signedTransaction, authorizations ?? [], dryRun);
|
|
126
128
|
}
|
|
127
129
|
/**
|
|
128
130
|
* Prepare a user operation data
|
|
@@ -150,16 +152,6 @@ async function createRhinestoneAccount(config) {
|
|
|
150
152
|
function submitUserOperation(signedUserOperation) {
|
|
151
153
|
return (0, utils_1.submitUserOperation)(config, signedUserOperation);
|
|
152
154
|
}
|
|
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
155
|
/**
|
|
164
156
|
* Sign and send a transaction
|
|
165
157
|
* @param transaction Transaction to send
|
|
@@ -197,12 +189,12 @@ async function createRhinestoneAccount(config) {
|
|
|
197
189
|
/**
|
|
198
190
|
* Get the maximum spendable token amount on the target chain
|
|
199
191
|
* @param chain Target chain
|
|
200
|
-
* @param
|
|
192
|
+
* @param token Token address (on the target chain)
|
|
201
193
|
* @param gasUnits Gas cost estimate for the transaction execution
|
|
202
194
|
* @returns Maximum spendable amount in absolute units
|
|
203
195
|
*/
|
|
204
|
-
function getMaxSpendableAmount(chain,
|
|
205
|
-
return (0, execution_1.getMaxSpendableAmount)(config, chain,
|
|
196
|
+
function getMaxSpendableAmount(chain, token, gasUnits, sponsored = false) {
|
|
197
|
+
return (0, execution_1.getMaxSpendableAmount)(config, chain, token, gasUnits, sponsored);
|
|
206
198
|
}
|
|
207
199
|
/**
|
|
208
200
|
* Get account owners (ECDSA)
|
|
@@ -219,12 +211,12 @@ async function createRhinestoneAccount(config) {
|
|
|
219
211
|
* @returns List of account validators
|
|
220
212
|
*/
|
|
221
213
|
function getValidators(chain) {
|
|
222
|
-
const accountType = config.
|
|
214
|
+
const accountType = (0, accounts_1.getAccountProvider)(config).type;
|
|
223
215
|
const account = getAddress();
|
|
224
216
|
return (0, modules_1.getValidators)(accountType, account, chain, config.provider);
|
|
225
217
|
}
|
|
226
|
-
function getSessionDetails(sessions, sessionIndex, signature) {
|
|
227
|
-
return (0,
|
|
218
|
+
function getSessionDetails(sessions, sessionIndex, initialNonces, signature) {
|
|
219
|
+
return (0, smart_session_1.getSessionDetails)(config, sessions, sessionIndex, initialNonces, signature);
|
|
228
220
|
}
|
|
229
221
|
/**
|
|
230
222
|
* Check ERC20 allowance for the account owner and token (using Permit2 as spender)
|
|
@@ -251,7 +243,6 @@ async function createRhinestoneAccount(config) {
|
|
|
251
243
|
signMessage,
|
|
252
244
|
signTypedData,
|
|
253
245
|
submitTransaction,
|
|
254
|
-
simulateTransaction,
|
|
255
246
|
prepareUserOperation,
|
|
256
247
|
signUserOperation,
|
|
257
248
|
submitUserOperation,
|
|
@@ -273,12 +264,14 @@ class RhinestoneSDK {
|
|
|
273
264
|
provider;
|
|
274
265
|
bundler;
|
|
275
266
|
paymaster;
|
|
267
|
+
useDevContracts;
|
|
276
268
|
constructor(options) {
|
|
277
269
|
this.apiKey = options?.apiKey;
|
|
278
270
|
this.endpointUrl = options?.endpointUrl;
|
|
279
271
|
this.provider = options?.provider;
|
|
280
272
|
this.bundler = options?.bundler;
|
|
281
273
|
this.paymaster = options?.paymaster;
|
|
274
|
+
this.useDevContracts = options?.useDevContracts;
|
|
282
275
|
}
|
|
283
276
|
createAccount(config) {
|
|
284
277
|
const rhinestoneConfig = {
|
|
@@ -288,9 +281,13 @@ class RhinestoneSDK {
|
|
|
288
281
|
provider: this.provider,
|
|
289
282
|
bundler: this.bundler,
|
|
290
283
|
paymaster: this.paymaster,
|
|
284
|
+
useDevContracts: this.useDevContracts,
|
|
291
285
|
};
|
|
292
286
|
return createRhinestoneAccount(rhinestoneConfig);
|
|
293
287
|
}
|
|
288
|
+
getIntentStatus(intentId) {
|
|
289
|
+
return (0, execution_1.getIntentStatus)(this.apiKey, this.endpointUrl, intentId);
|
|
290
|
+
}
|
|
294
291
|
}
|
|
295
292
|
exports.RhinestoneSDK = RhinestoneSDK;
|
|
296
293
|
// WebAuthn Validator contract helpers (keep Charter API stable)
|