@rhinestone/sdk 1.5.0 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/accounts/error.d.ts +1 -1
- package/dist/src/accounts/error.js +1 -19
- package/dist/src/accounts/index.d.ts +5 -5
- package/dist/src/accounts/index.js +121 -157
- package/dist/src/accounts/json-rpc/index.d.ts +1 -1
- package/dist/src/accounts/json-rpc/index.js +8 -10
- package/dist/src/accounts/json-rpc/providers.d.ts +1 -1
- package/dist/src/accounts/json-rpc/providers.js +4 -7
- package/dist/src/accounts/kernel.d.ts +3 -3
- package/dist/src/accounts/kernel.js +66 -75
- package/dist/src/accounts/nexus.d.ts +3 -3
- package/dist/src/accounts/nexus.js +62 -73
- package/dist/src/accounts/passport.d.ts +3 -3
- package/dist/src/accounts/passport.js +9 -13
- package/dist/src/accounts/safe.d.ts +3 -3
- package/dist/src/accounts/safe.js +54 -63
- package/dist/src/accounts/signing/common.d.ts +2 -2
- package/dist/src/accounts/signing/common.js +30 -36
- package/dist/src/accounts/signing/message.d.ts +2 -2
- package/dist/src/accounts/signing/message.js +10 -12
- package/dist/src/accounts/signing/passkeys.js +11 -17
- package/dist/src/accounts/signing/typedData.d.ts +1 -1
- package/dist/src/accounts/signing/typedData.js +6 -8
- package/dist/src/accounts/startale.d.ts +3 -3
- package/dist/src/accounts/startale.js +37 -47
- package/dist/src/accounts/utils.d.ts +2 -2
- package/dist/src/accounts/utils.js +22 -28
- package/dist/src/accounts/walletClient.js +4 -8
- package/dist/src/actions/compact.d.ts +1 -1
- package/dist/src/actions/compact.js +22 -35
- package/dist/src/actions/deployment.d.ts +1 -1
- package/dist/src/actions/deployment.js +11 -13
- package/dist/src/actions/ecdsa.d.ts +1 -1
- package/dist/src/actions/ecdsa.js +14 -20
- package/dist/src/actions/index.d.ts +2 -2
- package/dist/src/actions/index.js +6 -10
- package/dist/src/actions/mfa.d.ts +1 -1
- package/dist/src/actions/mfa.js +18 -24
- package/dist/src/actions/passkeys.d.ts +2 -2
- package/dist/src/actions/passkeys.js +14 -20
- package/dist/src/actions/recovery.d.ts +1 -1
- package/dist/src/actions/recovery.js +25 -29
- package/dist/src/actions/smart-sessions.d.ts +1 -1
- package/dist/src/actions/smart-sessions.js +8 -12
- package/dist/src/auth/provider.d.ts +1 -1
- package/dist/src/auth/provider.js +1 -4
- package/dist/src/errors/index.d.ts +3 -3
- package/dist/src/errors/index.js +10 -54
- package/dist/src/execution/compact.d.ts +3 -3
- package/dist/src/execution/compact.js +10 -18
- package/dist/src/execution/error.js +1 -11
- package/dist/src/execution/index.d.ts +8 -8
- package/dist/src/execution/index.js +50 -65
- package/dist/src/execution/permit2.d.ts +5 -5
- package/dist/src/execution/permit2.js +8 -13
- package/dist/src/execution/singleChainOps.d.ts +2 -2
- package/dist/src/execution/singleChainOps.js +1 -3
- package/dist/src/execution/types.d.ts +1 -1
- package/dist/src/execution/types.js +1 -2
- package/dist/src/execution/utils.d.ts +4 -4
- package/dist/src/execution/utils.js +133 -156
- package/dist/src/index.d.ts +9 -9
- package/dist/src/index.js +55 -66
- package/dist/src/jwt-server/digest.js +3 -6
- package/dist/src/jwt-server/express.d.ts +1 -1
- package/dist/src/jwt-server/express.d.ts.map +1 -1
- package/dist/src/jwt-server/express.js +6 -7
- package/dist/src/jwt-server/handlers.d.ts +1 -1
- package/dist/src/jwt-server/handlers.js +7 -11
- package/dist/src/jwt-server/index.d.ts +7 -7
- package/dist/src/jwt-server/index.js +6 -17
- package/dist/src/jwt-server/jcs.js +1 -4
- package/dist/src/jwt-server/signer.d.ts +1 -1
- package/dist/src/jwt-server/signer.js +10 -13
- package/dist/src/jwt-server/sponsorship.js +2 -7
- package/dist/src/jwt-server/web.d.ts +1 -1
- package/dist/src/jwt-server/web.js +5 -9
- package/dist/src/modules/abi/smart-session-emissary.js +1 -3
- package/dist/src/modules/abi/smart-sessions.js +1 -4
- package/dist/src/modules/chain-abstraction.js +1 -5
- package/dist/src/modules/common.d.ts +1 -1
- package/dist/src/modules/common.js +1 -13
- package/dist/src/modules/index.d.ts +5 -5
- package/dist/src/modules/index.js +35 -50
- package/dist/src/modules/legacy.d.ts +2 -2
- package/dist/src/modules/legacy.js +11 -14
- package/dist/src/modules/read.d.ts +1 -1
- package/dist/src/modules/read.js +11 -15
- package/dist/src/modules/validators/core.d.ts +2 -2
- package/dist/src/modules/validators/core.js +26 -44
- package/dist/src/modules/validators/index.d.ts +2 -2
- package/dist/src/modules/validators/index.js +3 -19
- package/dist/src/modules/validators/policies/claim/permit2.d.ts +1 -1
- package/dist/src/modules/validators/policies/claim/permit2.js +39 -44
- package/dist/src/modules/validators/policies/claim/types.js +11 -14
- package/dist/src/modules/validators/smart-sessions.d.ts +3 -3
- package/dist/src/modules/validators/smart-sessions.js +65 -94
- package/dist/src/orchestrator/client.d.ts +2 -2
- package/dist/src/orchestrator/client.js +46 -50
- package/dist/src/orchestrator/consts.d.ts +1 -1
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +2 -8
- package/dist/src/orchestrator/error.js +1 -33
- package/dist/src/orchestrator/index.d.ts +7 -7
- package/dist/src/orchestrator/index.js +7 -56
- package/dist/src/orchestrator/registry.d.ts +2 -2
- package/dist/src/orchestrator/registry.js +19 -33
- package/dist/src/orchestrator/types.js +1 -17
- package/dist/src/orchestrator/utils.js +1 -3
- package/dist/src/types.d.ts +3 -3
- package/dist/src/types.js +1 -2
- package/dist/src/utils/index.d.ts +2 -2
- package/dist/src/utils/index.js +9 -15
- package/package.json +15 -98
|
@@ -1,47 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
exports.getIntentAccount = getIntentAccount;
|
|
22
|
-
exports.getTargetExecutionSignature = getTargetExecutionSignature;
|
|
23
|
-
exports.hashErc7739TypedDataForSolady = hashErc7739TypedDataForSolady;
|
|
24
|
-
exports.resolveSessionForChain = resolveSessionForChain;
|
|
25
|
-
const viem_1 = require("viem");
|
|
26
|
-
const account_abstraction_1 = require("viem/account-abstraction");
|
|
27
|
-
const erc7739_1 = require("viem/experimental/erc7739");
|
|
28
|
-
const accounts_1 = require("../accounts");
|
|
29
|
-
const common_1 = require("../accounts/signing/common");
|
|
30
|
-
const startale_1 = require("../accounts/startale");
|
|
31
|
-
const utils_1 = require("../accounts/utils");
|
|
32
|
-
const provider_1 = require("../auth/provider");
|
|
33
|
-
const modules_1 = require("../modules");
|
|
34
|
-
const validators_1 = require("../modules/validators");
|
|
35
|
-
const core_1 = require("../modules/validators/core");
|
|
36
|
-
const permit2_1 = require("../modules/validators/policies/claim/permit2");
|
|
37
|
-
const orchestrator_1 = require("../orchestrator");
|
|
38
|
-
const registry_1 = require("../orchestrator/registry");
|
|
39
|
-
const types_1 = require("../orchestrator/types");
|
|
40
|
-
const utils_2 = require("../orchestrator/utils");
|
|
41
|
-
const compact_1 = require("./compact");
|
|
42
|
-
const error_1 = require("./error");
|
|
43
|
-
const permit2_2 = require("./permit2");
|
|
44
|
-
const singleChainOps_1 = require("./singleChainOps");
|
|
1
|
+
import { concat, createPublicClient, createWalletClient, encodeAbiParameters, encodePacked, hashDomain, hashMessage, hashStruct, hashTypedData, isAddress, keccak256, publicActions, toHex, } from 'viem';
|
|
2
|
+
import { entryPoint07Address, getUserOperationHash, } from 'viem/account-abstraction';
|
|
3
|
+
import { wrapTypedDataSignature } from 'viem/experimental/erc7739';
|
|
4
|
+
import { EoaAccountMustHaveAccountError, EoaSigningMethodNotConfiguredError, FactoryArgsNotAvailableError, getAccountProvider, getAddress, getEip712Domain, getEip1271Signature, getEip7702InitCall, getEmissarySignature, getGuardianSmartAccount, getInitCode, getSmartAccount, getTypedDataPackedSignature, is7702, toErc6492Signature, } from '../accounts/index.js';
|
|
5
|
+
import { convertOwnerSetToSignerSet } from '../accounts/signing/common.js';
|
|
6
|
+
import { K1_DEFAULT_VALIDATOR_ADDRESS } from '../accounts/startale.js';
|
|
7
|
+
import { createTransport, getBundlerClient, } from '../accounts/utils.js';
|
|
8
|
+
import { createAuthProvider } from '../auth/provider.js';
|
|
9
|
+
import { getIntentExecutor } from '../modules/index.js';
|
|
10
|
+
import { buildMockSignature, DUMMY_PRECLAIMOP_SELECTOR, DUMMY_PRECLAIMOP_TARGET, getOwnerValidator, getPermissionId, getSmartSessionValidator, isSessionEnabled, } from '../modules/validators/index.js';
|
|
11
|
+
import { getMultiFactorValidator, getSocialRecoveryValidator, getWebAuthnValidator, supportsEip712, } from '../modules/validators/core.js';
|
|
12
|
+
import { buildPermit2ClaimPolicyCalldata } from '../modules/validators/policies/claim/permit2.js';
|
|
13
|
+
import { getOrchestrator, } from '../orchestrator/index.js';
|
|
14
|
+
import { getChainById, getTokenAddress, resolveTokenAddress, } from '../orchestrator/registry.js';
|
|
15
|
+
import { SIG_MODE_EMISSARY_EXECUTION_ERC1271, SIG_MODE_ERC1271_EMISSARY, } from '../orchestrator/types.js';
|
|
16
|
+
import { convertBigIntFields } from '../orchestrator/utils.js';
|
|
17
|
+
import { getCompactTypedData } from './compact.js';
|
|
18
|
+
import { Eip7702InitSignatureRequiredError, SignerNotSupportedError, } from './error.js';
|
|
19
|
+
import { getTypedData as getPermit2TypedData } from './permit2.js';
|
|
20
|
+
import { getTypedData as getSingleChainOpsTypedData } from './singleChainOps.js';
|
|
45
21
|
function isResolvedSessionSignerSet(signers) {
|
|
46
22
|
return (signers?.type === 'experimental_session' && 'verifyExecutions' in signers);
|
|
47
23
|
}
|
|
@@ -50,7 +26,7 @@ async function resolveSignersForChain(config, signers, chainId) {
|
|
|
50
26
|
return signers;
|
|
51
27
|
}
|
|
52
28
|
const resolved = resolveSessionForChain(signers, chainId);
|
|
53
|
-
const enabled = await
|
|
29
|
+
const enabled = await isSessionEnabled(getAddress(config), config.provider, resolved.session, config.useDevContracts);
|
|
54
30
|
const enableData = enabled ? undefined : resolved.enableData;
|
|
55
31
|
const hasExplicitActions = !!resolved.session.actions?.length;
|
|
56
32
|
const verifyExecutions = resolved.verifyExecutions ?? signers.verifyExecutions ?? hasExplicitActions;
|
|
@@ -73,10 +49,10 @@ function resolveSessionForChain(signers, chainId) {
|
|
|
73
49
|
}
|
|
74
50
|
async function prepareTransaction(config, transaction) {
|
|
75
51
|
const { sourceChains, targetChain, tokenRequests, signers, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, auxiliaryFunds, account, recipient, } = getTransactionParams(transaction);
|
|
76
|
-
const accountAddress =
|
|
52
|
+
const accountAddress = getAddress(config);
|
|
77
53
|
const isUserOpSigner = signers?.type === 'guardians';
|
|
78
54
|
if (isUserOpSigner) {
|
|
79
|
-
throw new
|
|
55
|
+
throw new SignerNotSupportedError();
|
|
80
56
|
}
|
|
81
57
|
const prepared = await prepareTransactionAsIntent(config, sourceChains, targetChain, await resolveCallInputs(transaction.calls, config, targetChain, accountAddress), transaction.gasLimit, tokenRequests, recipient, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, auxiliaryFunds, account, signers);
|
|
82
58
|
return {
|
|
@@ -88,7 +64,7 @@ async function prepareTransaction(config, transaction) {
|
|
|
88
64
|
async function prepareUserOperation(config, transaction) {
|
|
89
65
|
const chain = transaction.chain;
|
|
90
66
|
const signers = transaction.signers;
|
|
91
|
-
const accountAddress =
|
|
67
|
+
const accountAddress = getAddress(config);
|
|
92
68
|
const data = await prepareTransactionAsUserOp(config, chain, await resolveCallInputs(transaction.calls, config, chain, accountAddress), signers, transaction.gasLimit);
|
|
93
69
|
return {
|
|
94
70
|
userOperation: data.userOp,
|
|
@@ -156,7 +132,7 @@ async function getTargetExecutionSignature(config, intentOp, targetChain, signer
|
|
|
156
132
|
if (!validator) {
|
|
157
133
|
throw new Error('Validator not available');
|
|
158
134
|
}
|
|
159
|
-
const ownerValidator =
|
|
135
|
+
const ownerValidator = getOwnerValidator(config);
|
|
160
136
|
const isRoot = validator.address === ownerValidator.address;
|
|
161
137
|
const signature = await getDestinationSignature(config, resolvedSigners, validator, isRoot, targetChain, destination, [], true);
|
|
162
138
|
return signature;
|
|
@@ -182,21 +158,21 @@ async function signMessage(config, message, chain, signers) {
|
|
|
182
158
|
if (!validator) {
|
|
183
159
|
throw new Error('Validator not available');
|
|
184
160
|
}
|
|
185
|
-
const ownerValidator =
|
|
161
|
+
const ownerValidator = getOwnerValidator(config);
|
|
186
162
|
const isRoot = validator.address === ownerValidator.address;
|
|
187
|
-
const hash =
|
|
188
|
-
const signature = await
|
|
163
|
+
const hash = hashMessage(message);
|
|
164
|
+
const signature = await getEip1271Signature(config, signers, chain, {
|
|
189
165
|
address: validator.address,
|
|
190
166
|
isRoot,
|
|
191
167
|
}, hash);
|
|
192
|
-
return await
|
|
168
|
+
return await toErc6492Signature(config, signature, chain);
|
|
193
169
|
}
|
|
194
170
|
async function signTypedData(config, parameters, chain, signers, options) {
|
|
195
171
|
const validator = getValidator(config, signers);
|
|
196
172
|
if (!validator) {
|
|
197
173
|
throw new Error('Validator not available');
|
|
198
174
|
}
|
|
199
|
-
const ownerValidator =
|
|
175
|
+
const ownerValidator = getOwnerValidator(config);
|
|
200
176
|
const isRoot = validator.address === ownerValidator.address;
|
|
201
177
|
if (signers?.type === 'experimental_session') {
|
|
202
178
|
const resolved = resolveSessionForChain(signers, chain.id);
|
|
@@ -205,31 +181,31 @@ async function signTypedData(config, parameters, chain, signers, options) {
|
|
|
205
181
|
isRoot,
|
|
206
182
|
}, resolved.session, parameters);
|
|
207
183
|
}
|
|
208
|
-
const account =
|
|
209
|
-
if (account.type === 'startale' &&
|
|
184
|
+
const account = getAccountProvider(config);
|
|
185
|
+
if (account.type === 'startale' && supportsEip712(validator)) {
|
|
210
186
|
const isK1 = validator.address.toLowerCase() ===
|
|
211
|
-
|
|
187
|
+
K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase();
|
|
212
188
|
if (isK1) {
|
|
213
189
|
const sig = await signErc7739TypedData(config, signers, validator, isRoot, parameters, chain);
|
|
214
190
|
if (!options?.skipErc6492) {
|
|
215
|
-
return await
|
|
191
|
+
return await toErc6492Signature(config, sig, chain);
|
|
216
192
|
}
|
|
217
193
|
return sig;
|
|
218
194
|
}
|
|
219
195
|
}
|
|
220
|
-
const signature = await
|
|
196
|
+
const signature = await getTypedDataPackedSignature(config, signers, chain, {
|
|
221
197
|
address: validator.address,
|
|
222
198
|
isRoot,
|
|
223
199
|
}, parameters);
|
|
224
200
|
if (!options?.skipErc6492) {
|
|
225
|
-
return await
|
|
201
|
+
return await toErc6492Signature(config, signature, chain);
|
|
226
202
|
}
|
|
227
203
|
return signature;
|
|
228
204
|
}
|
|
229
205
|
async function signTypedDataWithSession(config, chain, validator, session, parameters) {
|
|
230
|
-
const { name, version, chainId, verifyingContract, salt } =
|
|
231
|
-
const signers =
|
|
232
|
-
const signature = await
|
|
206
|
+
const { name, version, chainId, verifyingContract, salt } = getEip712Domain(config, chain);
|
|
207
|
+
const signers = convertOwnerSetToSignerSet(session.owners);
|
|
208
|
+
const signature = await getTypedDataPackedSignature(config, signers, chain, validator, {
|
|
233
209
|
domain: parameters.domain,
|
|
234
210
|
primaryType: 'TypedDataSign',
|
|
235
211
|
types: {
|
|
@@ -252,39 +228,39 @@ async function signTypedDataWithSession(config, chain, validator, session, param
|
|
|
252
228
|
salt,
|
|
253
229
|
},
|
|
254
230
|
}, (signature) => {
|
|
255
|
-
const erc7739Signature =
|
|
231
|
+
const erc7739Signature = wrapTypedDataSignature({
|
|
256
232
|
domain: parameters.domain,
|
|
257
233
|
primaryType: parameters.primaryType,
|
|
258
234
|
types: parameters.types,
|
|
259
235
|
message: parameters.message,
|
|
260
236
|
signature,
|
|
261
237
|
});
|
|
262
|
-
return
|
|
238
|
+
return encodePacked(['bytes32', 'bytes'], [getPermissionId(session), erc7739Signature]);
|
|
263
239
|
});
|
|
264
|
-
return await
|
|
240
|
+
return await toErc6492Signature(config, signature, chain);
|
|
265
241
|
}
|
|
266
242
|
async function signAuthorizationsInternal(config, data) {
|
|
267
243
|
const eoa = config.eoa;
|
|
268
244
|
if (!eoa) {
|
|
269
245
|
throw new Error('EIP-7702 initialization is required for EOA accounts');
|
|
270
246
|
}
|
|
271
|
-
const accountAddress =
|
|
247
|
+
const accountAddress = getAddress(config);
|
|
272
248
|
const requiredDelegations = 'intentOp' in data
|
|
273
249
|
? data.intentOp.signedMetadata.account.requiredDelegations || {}
|
|
274
250
|
: {};
|
|
275
251
|
const authorizations = [];
|
|
276
252
|
for (const chainId in requiredDelegations) {
|
|
277
253
|
const delegation = requiredDelegations[chainId];
|
|
278
|
-
const chain =
|
|
279
|
-
const walletClient =
|
|
254
|
+
const chain = getChainById(Number(chainId));
|
|
255
|
+
const walletClient = createWalletClient({
|
|
280
256
|
chain,
|
|
281
257
|
account: eoa,
|
|
282
|
-
transport:
|
|
283
|
-
}).extend(
|
|
258
|
+
transport: createTransport(chain, config.provider),
|
|
259
|
+
}).extend(publicActions);
|
|
284
260
|
const code = await walletClient.getCode({
|
|
285
261
|
address: accountAddress,
|
|
286
262
|
});
|
|
287
|
-
const isDelegated = code ===
|
|
263
|
+
const isDelegated = code === concat(['0xef0100', delegation.contract.toLowerCase()]);
|
|
288
264
|
if (isDelegated) {
|
|
289
265
|
continue;
|
|
290
266
|
}
|
|
@@ -349,15 +325,15 @@ function getTokenRequests(targetChain, initialTokenRequests) {
|
|
|
349
325
|
return initialTokenRequests ?? [];
|
|
350
326
|
}
|
|
351
327
|
async function prepareTransactionAsUserOp(config, chain, callInputs, signers, gasLimit) {
|
|
352
|
-
const publicClient =
|
|
328
|
+
const publicClient = createPublicClient({
|
|
353
329
|
chain,
|
|
354
|
-
transport:
|
|
330
|
+
transport: createTransport(chain, config.provider),
|
|
355
331
|
});
|
|
356
332
|
const validatorAccount = await getValidatorAccount(config, signers, publicClient, chain);
|
|
357
333
|
if (!validatorAccount) {
|
|
358
334
|
throw new Error('No validator account found');
|
|
359
335
|
}
|
|
360
|
-
const bundlerClient =
|
|
336
|
+
const bundlerClient = getBundlerClient(config, publicClient);
|
|
361
337
|
const calls = parseCalls(callInputs, chain.id);
|
|
362
338
|
const userOp = await bundlerClient.prepareUserOperation({
|
|
363
339
|
account: validatorAccount,
|
|
@@ -366,10 +342,10 @@ async function prepareTransactionAsUserOp(config, chain, callInputs, signers, ga
|
|
|
366
342
|
});
|
|
367
343
|
return {
|
|
368
344
|
userOp,
|
|
369
|
-
hash:
|
|
345
|
+
hash: getUserOperationHash({
|
|
370
346
|
userOperation: userOp,
|
|
371
347
|
chainId: chain.id,
|
|
372
|
-
entryPointAddress:
|
|
348
|
+
entryPointAddress: entryPoint07Address,
|
|
373
349
|
entryPointVersion: '0.7',
|
|
374
350
|
}),
|
|
375
351
|
};
|
|
@@ -383,7 +359,7 @@ function getAccountType(accountConfig) {
|
|
|
383
359
|
}
|
|
384
360
|
}
|
|
385
361
|
function getIntentAccount(config, eip7702InitSignature, account) {
|
|
386
|
-
const accountAddress =
|
|
362
|
+
const accountAddress = getAddress(config);
|
|
387
363
|
const accountType = getAccountType(config.account);
|
|
388
364
|
const { setupOps, delegations } = getSetupOperationsAndDelegations(config, accountAddress, eip7702InitSignature);
|
|
389
365
|
return {
|
|
@@ -415,7 +391,7 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
415
391
|
...getIntentAccount(config, eip7702InitSignature, account),
|
|
416
392
|
...(signers?.type === 'experimental_session' && {
|
|
417
393
|
// Global fallback: target-chain sig for backward-compat with older orchestrators
|
|
418
|
-
mockSignature:
|
|
394
|
+
mockSignature: buildMockSignature(resolveSessionForChain(signers, targetChain.id).session, config.useDevContracts, sourceChains?.length ?? 1),
|
|
419
395
|
// Per-chain map: enables accurate per-chain session validation gas simulation
|
|
420
396
|
mockSignatures: Object.fromEntries([
|
|
421
397
|
...new Set([
|
|
@@ -424,14 +400,14 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
424
400
|
]),
|
|
425
401
|
].map((chainId) => [
|
|
426
402
|
String(chainId),
|
|
427
|
-
|
|
403
|
+
buildMockSignature(resolveSessionForChain(signers, chainId).session, config.useDevContracts, sourceChains?.length ?? 1, chainId),
|
|
428
404
|
])),
|
|
429
405
|
}),
|
|
430
406
|
};
|
|
431
407
|
const recipient = getRecipient(recipientInput);
|
|
432
408
|
const signatureMode = signers?.type === 'experimental_session'
|
|
433
|
-
?
|
|
434
|
-
:
|
|
409
|
+
? SIG_MODE_EMISSARY_EXECUTION_ERC1271
|
|
410
|
+
: SIG_MODE_ERC1271_EMISSARY;
|
|
435
411
|
// For session signers that need enabling, pass a dummy preclaimop per source chain
|
|
436
412
|
// so the orchestrator bakes it into the bundle before computing its HMAC. The filler
|
|
437
413
|
// executes the op via verifyExecution in ENABLE mode, enabling the session on-chain
|
|
@@ -451,9 +427,9 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
451
427
|
continue;
|
|
452
428
|
preClaimExecutions[chainId] = [
|
|
453
429
|
{
|
|
454
|
-
to:
|
|
430
|
+
to: DUMMY_PRECLAIMOP_TARGET,
|
|
455
431
|
value: 0n,
|
|
456
|
-
data:
|
|
432
|
+
data: DUMMY_PRECLAIMOP_SELECTOR,
|
|
457
433
|
},
|
|
458
434
|
];
|
|
459
435
|
}
|
|
@@ -461,7 +437,7 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
461
437
|
const metaIntent = {
|
|
462
438
|
destinationChainId: targetChain.id,
|
|
463
439
|
tokenRequests: tokenRequests.map((tokenRequest) => ({
|
|
464
|
-
tokenAddress:
|
|
440
|
+
tokenAddress: resolveTokenAddress(tokenRequest.address, targetChain.id),
|
|
465
441
|
amount: tokenRequest.amount,
|
|
466
442
|
})),
|
|
467
443
|
recipient,
|
|
@@ -491,8 +467,8 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
491
467
|
},
|
|
492
468
|
...(Object.keys(preClaimExecutions).length > 0 && { preClaimExecutions }),
|
|
493
469
|
};
|
|
494
|
-
const serializedIntent =
|
|
495
|
-
const orchestrator =
|
|
470
|
+
const serializedIntent = convertBigIntFields(metaIntent);
|
|
471
|
+
const orchestrator = getOrchestrator(config._authProvider ?? createAuthProvider(config), config.endpointUrl, config.headers);
|
|
496
472
|
const intentRoute = await orchestrator.getIntentRoute(metaIntent);
|
|
497
473
|
return { intentRoute, intentInput: serializedIntent };
|
|
498
474
|
}
|
|
@@ -501,7 +477,7 @@ async function signIntent(config, intentOp, targetChain, signers, targetExecutio
|
|
|
501
477
|
if (config.account?.type === 'eoa') {
|
|
502
478
|
const eoa = config.eoa;
|
|
503
479
|
if (!eoa) {
|
|
504
|
-
throw new
|
|
480
|
+
throw new EoaAccountMustHaveAccountError();
|
|
505
481
|
}
|
|
506
482
|
const originSignatures = [];
|
|
507
483
|
for (const typedData of origin) {
|
|
@@ -510,7 +486,7 @@ async function signIntent(config, intentOp, targetChain, signers, targetExecutio
|
|
|
510
486
|
originSignatures.push(signature);
|
|
511
487
|
}
|
|
512
488
|
else {
|
|
513
|
-
throw new
|
|
489
|
+
throw new EoaSigningMethodNotConfiguredError('signTypedData');
|
|
514
490
|
}
|
|
515
491
|
}
|
|
516
492
|
const destinationSignature = originSignatures.at(-1);
|
|
@@ -523,11 +499,11 @@ async function signIntent(config, intentOp, targetChain, signers, targetExecutio
|
|
|
523
499
|
if (!validator) {
|
|
524
500
|
throw new Error('Validator not available');
|
|
525
501
|
}
|
|
526
|
-
const ownerValidator =
|
|
502
|
+
const ownerValidator = getOwnerValidator(config);
|
|
527
503
|
const isRoot = validator.address === ownerValidator.address;
|
|
528
504
|
const originSignatures = [];
|
|
529
505
|
for (const typedData of origin) {
|
|
530
|
-
const chain =
|
|
506
|
+
const chain = getChainById(typedData.domain?.chainId);
|
|
531
507
|
const originSigners = await resolveSignersForChain(config, signers, chain.id);
|
|
532
508
|
const signature = await signIntentTypedData(config, originSigners, validator, isRoot, typedData, chain, targetExecution ?? false);
|
|
533
509
|
originSignatures.push(signature);
|
|
@@ -549,8 +525,8 @@ async function getDestinationSignature(config, signers, validator, isRoot, targe
|
|
|
549
525
|
// the account's eip712Domain() returns the target chain's chainId, which differs
|
|
550
526
|
// from the origin chain used for the last origin signature
|
|
551
527
|
const isK1Validator = validator.address.toLowerCase() ===
|
|
552
|
-
|
|
553
|
-
if (isK1Validator &&
|
|
528
|
+
K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase();
|
|
529
|
+
if (isK1Validator && supportsEip712(validator)) {
|
|
554
530
|
return await signDestinationSeparately(config, signers, validator, isRoot, targetChain, destination, targetExecution);
|
|
555
531
|
}
|
|
556
532
|
const lastOriginSignature = originSignatures.at(-1);
|
|
@@ -559,30 +535,30 @@ async function getDestinationSignature(config, signers, validator, isRoot, targe
|
|
|
559
535
|
: (lastOriginSignature ?? '0x');
|
|
560
536
|
}
|
|
561
537
|
async function signDestinationSeparately(config, signers, validator, isRoot, targetChain, destination, targetExecution) {
|
|
562
|
-
const destinationChain =
|
|
538
|
+
const destinationChain = getChainById(targetChain.id);
|
|
563
539
|
const destinationSignatures = await signIntentTypedData(config, signers, validator, isRoot, destination, destinationChain, targetExecution);
|
|
564
540
|
return typeof destinationSignatures === 'object'
|
|
565
541
|
? destinationSignatures.preClaimSig
|
|
566
542
|
: (destinationSignatures ?? '0x');
|
|
567
543
|
}
|
|
568
544
|
function getIntentMessages(config, intentOp) {
|
|
569
|
-
const address =
|
|
570
|
-
const intentExecutor =
|
|
545
|
+
const address = getAddress(config);
|
|
546
|
+
const intentExecutor = getIntentExecutor(config);
|
|
571
547
|
const withPermit2 = intentOp.elements.some((element) => element.mandate.qualifier.settlementContext.fundingMethod === 'PERMIT2');
|
|
572
548
|
const withIntentExecutorOps = intentOp.elements.some((element) => element.mandate.qualifier.settlementContext.settlementLayer ===
|
|
573
549
|
'INTENT_EXECUTOR');
|
|
574
550
|
const origin = [];
|
|
575
551
|
for (const element of intentOp.elements) {
|
|
576
552
|
if (withIntentExecutorOps) {
|
|
577
|
-
const typedData = (
|
|
553
|
+
const typedData = getSingleChainOpsTypedData(address, intentExecutor.address, element, BigInt(intentOp.nonce));
|
|
578
554
|
origin.push(typedData);
|
|
579
555
|
}
|
|
580
556
|
else if (withPermit2) {
|
|
581
|
-
const typedData = (
|
|
557
|
+
const typedData = getPermit2TypedData(element, BigInt(intentOp.nonce), BigInt(intentOp.expires));
|
|
582
558
|
origin.push(typedData);
|
|
583
559
|
}
|
|
584
560
|
else {
|
|
585
|
-
const typedData =
|
|
561
|
+
const typedData = getCompactTypedData(intentOp);
|
|
586
562
|
origin.push(typedData);
|
|
587
563
|
}
|
|
588
564
|
}
|
|
@@ -593,10 +569,10 @@ function getIntentMessages(config, intentOp) {
|
|
|
593
569
|
};
|
|
594
570
|
}
|
|
595
571
|
function getTargetExecutionMessage(config, intentOp) {
|
|
596
|
-
const address =
|
|
597
|
-
const intentExecutor =
|
|
572
|
+
const address = getAddress(config);
|
|
573
|
+
const intentExecutor = getIntentExecutor(config);
|
|
598
574
|
const lastElement = intentOp.elements.at(-1);
|
|
599
|
-
const typedData = (
|
|
575
|
+
const typedData = getSingleChainOpsTypedData(address, intentExecutor.address, lastElement, BigInt(intentOp.targetExecutionNonce));
|
|
600
576
|
typedData.message.gasRefund = typedData.message.gasRefund ?? {
|
|
601
577
|
token: '0x0000000000000000000000000000000000000000',
|
|
602
578
|
exchangeRate: 0n,
|
|
@@ -618,21 +594,21 @@ function resolveClaimPolicyData(signers, parameters) {
|
|
|
618
594
|
typeof msg.deadline !== 'bigint') {
|
|
619
595
|
return undefined;
|
|
620
596
|
}
|
|
621
|
-
return
|
|
597
|
+
return buildPermit2ClaimPolicyCalldata(signers.session.claimPolicies[0], parameters.message);
|
|
622
598
|
}
|
|
623
599
|
async function signIntentTypedData(config, signers, validator, isRoot, parameters, chain, targetExecution) {
|
|
624
|
-
if (
|
|
600
|
+
if (supportsEip712(validator)) {
|
|
625
601
|
const isK1Validator = validator.address.toLowerCase() ===
|
|
626
|
-
|
|
602
|
+
K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase();
|
|
627
603
|
if (isK1Validator) {
|
|
628
604
|
return await signErc7739TypedData(config, signers, validator, isRoot, parameters, chain);
|
|
629
605
|
}
|
|
630
|
-
return await
|
|
606
|
+
return await getTypedDataPackedSignature(config, signers, chain, {
|
|
631
607
|
address: validator.address,
|
|
632
608
|
isRoot,
|
|
633
609
|
}, parameters);
|
|
634
610
|
}
|
|
635
|
-
const hash =
|
|
611
|
+
const hash = hashTypedData(parameters);
|
|
636
612
|
if (isResolvedSessionSignerSet(signers) && signers.verifyExecutions) {
|
|
637
613
|
if (targetExecution) {
|
|
638
614
|
const targetSigners = {
|
|
@@ -643,7 +619,7 @@ async function signIntentTypedData(config, signers, validator, isRoot, parameter
|
|
|
643
619
|
};
|
|
644
620
|
// signWithSession (called inside getEmissarySignature) already calls packSignature
|
|
645
621
|
// internally, so no transform is needed here
|
|
646
|
-
return await
|
|
622
|
+
return await getEmissarySignature(config, targetSigners, chain, hash);
|
|
647
623
|
}
|
|
648
624
|
const claimPolicyData = resolveClaimPolicyData(signers, parameters);
|
|
649
625
|
const sessionSignersForEip1271 = {
|
|
@@ -653,11 +629,11 @@ async function signIntentTypedData(config, signers, validator, isRoot, parameter
|
|
|
653
629
|
enableData: signers.enableData,
|
|
654
630
|
claimPolicyData,
|
|
655
631
|
};
|
|
656
|
-
const eip1271Signature = await
|
|
632
|
+
const eip1271Signature = await getEip1271Signature(config, sessionSignersForEip1271, chain, {
|
|
657
633
|
address: validator.address,
|
|
658
634
|
isRoot,
|
|
659
635
|
}, hash);
|
|
660
|
-
const emissarySignature = await
|
|
636
|
+
const emissarySignature = await getEmissarySignature(config, {
|
|
661
637
|
type: 'experimental_session',
|
|
662
638
|
session: signers.session,
|
|
663
639
|
verifyExecutions: true,
|
|
@@ -670,12 +646,12 @@ async function signIntentTypedData(config, signers, validator, isRoot, parameter
|
|
|
670
646
|
}
|
|
671
647
|
if (isResolvedSessionSignerSet(signers)) {
|
|
672
648
|
const claimPolicyData = resolveClaimPolicyData(signers, parameters);
|
|
673
|
-
return await
|
|
649
|
+
return await getEip1271Signature(config, claimPolicyData !== undefined ? { ...signers, claimPolicyData } : signers, chain, {
|
|
674
650
|
address: validator.address,
|
|
675
651
|
isRoot,
|
|
676
652
|
}, hash);
|
|
677
653
|
}
|
|
678
|
-
return await
|
|
654
|
+
return await getEip1271Signature(config, signers, chain, {
|
|
679
655
|
address: validator.address,
|
|
680
656
|
isRoot,
|
|
681
657
|
}, hash);
|
|
@@ -685,9 +661,9 @@ async function signUserOp(config, chain, signers, userOp) {
|
|
|
685
661
|
if (!validator) {
|
|
686
662
|
throw new Error('Validator not available');
|
|
687
663
|
}
|
|
688
|
-
const publicClient =
|
|
664
|
+
const publicClient = createPublicClient({
|
|
689
665
|
chain,
|
|
690
|
-
transport:
|
|
666
|
+
transport: createTransport(chain, config.provider),
|
|
691
667
|
});
|
|
692
668
|
const account = await getValidatorAccount(config, signers, publicClient, chain);
|
|
693
669
|
if (!account) {
|
|
@@ -696,36 +672,36 @@ async function signUserOp(config, chain, signers, userOp) {
|
|
|
696
672
|
return await account.signUserOperation(userOp);
|
|
697
673
|
}
|
|
698
674
|
async function submitUserOp(config, chain, userOp, signature) {
|
|
699
|
-
const publicClient =
|
|
675
|
+
const publicClient = createPublicClient({
|
|
700
676
|
chain,
|
|
701
|
-
transport:
|
|
677
|
+
transport: createTransport(chain, config.provider),
|
|
702
678
|
});
|
|
703
|
-
const bundlerClient =
|
|
679
|
+
const bundlerClient = getBundlerClient(config, publicClient);
|
|
704
680
|
const hash = await bundlerClient.request({
|
|
705
681
|
method: 'eth_sendUserOperation',
|
|
706
682
|
params: [
|
|
707
683
|
{
|
|
708
684
|
sender: userOp.sender,
|
|
709
|
-
nonce:
|
|
685
|
+
nonce: toHex(userOp.nonce),
|
|
710
686
|
factory: userOp.factory,
|
|
711
687
|
factoryData: userOp.factoryData,
|
|
712
688
|
callData: userOp.callData,
|
|
713
|
-
callGasLimit:
|
|
714
|
-
verificationGasLimit:
|
|
715
|
-
preVerificationGas:
|
|
716
|
-
maxPriorityFeePerGas:
|
|
717
|
-
maxFeePerGas:
|
|
689
|
+
callGasLimit: toHex(userOp.callGasLimit),
|
|
690
|
+
verificationGasLimit: toHex(userOp.verificationGasLimit),
|
|
691
|
+
preVerificationGas: toHex(userOp.preVerificationGas),
|
|
692
|
+
maxPriorityFeePerGas: toHex(userOp.maxPriorityFeePerGas),
|
|
693
|
+
maxFeePerGas: toHex(userOp.maxFeePerGas),
|
|
718
694
|
paymaster: userOp.paymaster,
|
|
719
695
|
paymasterVerificationGasLimit: userOp.paymasterVerificationGasLimit
|
|
720
|
-
?
|
|
696
|
+
? toHex(userOp.paymasterVerificationGasLimit)
|
|
721
697
|
: undefined,
|
|
722
698
|
paymasterPostOpGasLimit: userOp.paymasterPostOpGasLimit
|
|
723
|
-
?
|
|
699
|
+
? toHex(userOp.paymasterPostOpGasLimit)
|
|
724
700
|
: undefined,
|
|
725
701
|
paymasterData: userOp.paymasterData,
|
|
726
702
|
signature,
|
|
727
703
|
},
|
|
728
|
-
|
|
704
|
+
entryPoint07Address,
|
|
729
705
|
],
|
|
730
706
|
});
|
|
731
707
|
return {
|
|
@@ -758,7 +734,7 @@ function createSignedIntentOp(intentOp, originSignatures, destinationSignature,
|
|
|
758
734
|
async function submitIntentInternal(config, sourceChains, targetChain, intentOp, originSignatures, destinationSignature, targetExecutionSignature, authorizations, dryRun, intentInput) {
|
|
759
735
|
const signedIntentOp = createSignedIntentOp(intentOp, originSignatures, destinationSignature, targetExecutionSignature, authorizations);
|
|
760
736
|
const isSponsored = !!intentInput?.options?.sponsorSettings;
|
|
761
|
-
const orchestrator =
|
|
737
|
+
const orchestrator = getOrchestrator(config._authProvider ?? createAuthProvider(config), config.endpointUrl, config.headers);
|
|
762
738
|
const intentResults = await orchestrator.submitIntent(signedIntentOp, dryRun, intentInput ? { intentInput, isSponsored } : undefined);
|
|
763
739
|
// Some settlement paths (e.g. SAME_CHAIN) may not return a result.id — fall
|
|
764
740
|
// back to the nonce which the orchestrator also accepts as an intent identifier.
|
|
@@ -772,16 +748,16 @@ async function submitIntentInternal(config, sourceChains, targetChain, intentOp,
|
|
|
772
748
|
}
|
|
773
749
|
async function getValidatorAccount(config, signers, publicClient, chain) {
|
|
774
750
|
if (!signers) {
|
|
775
|
-
return
|
|
751
|
+
return getSmartAccount(config, publicClient, chain);
|
|
776
752
|
}
|
|
777
753
|
// Owners
|
|
778
754
|
const withOwner = signers.type === 'owner' ? signers : null;
|
|
779
755
|
if (withOwner) {
|
|
780
|
-
return
|
|
756
|
+
return getSmartAccount(config, publicClient, chain);
|
|
781
757
|
}
|
|
782
758
|
const withGuardians = signers.type === 'guardians' ? signers : null;
|
|
783
759
|
return withGuardians
|
|
784
|
-
? await
|
|
760
|
+
? await getGuardianSmartAccount(config, publicClient, chain, {
|
|
785
761
|
type: 'ecdsa',
|
|
786
762
|
accounts: withGuardians.guardians,
|
|
787
763
|
})
|
|
@@ -789,7 +765,7 @@ async function getValidatorAccount(config, signers, publicClient, chain) {
|
|
|
789
765
|
}
|
|
790
766
|
function getValidator(config, signers) {
|
|
791
767
|
if (!signers) {
|
|
792
|
-
return
|
|
768
|
+
return getOwnerValidator(config);
|
|
793
769
|
}
|
|
794
770
|
// Owners
|
|
795
771
|
const withOwner = signers.type === 'owner' ? signers : null;
|
|
@@ -797,29 +773,29 @@ function getValidator(config, signers) {
|
|
|
797
773
|
// ECDSA
|
|
798
774
|
if (withOwner.kind === 'ecdsa') {
|
|
799
775
|
// Use the configured owner validator (e.g., ENS) rather than forcing Ownable
|
|
800
|
-
return
|
|
776
|
+
return getOwnerValidator(config);
|
|
801
777
|
}
|
|
802
778
|
// Passkeys (WebAuthn)
|
|
803
779
|
if (withOwner.kind === 'passkey') {
|
|
804
|
-
return
|
|
780
|
+
return getWebAuthnValidator(1, withOwner.accounts.map((account) => ({
|
|
805
781
|
pubKey: account.publicKey,
|
|
806
782
|
authenticatorId: account.id,
|
|
807
783
|
})));
|
|
808
784
|
}
|
|
809
785
|
// Multi-factor
|
|
810
786
|
if (withOwner.kind === 'multi-factor') {
|
|
811
|
-
return
|
|
787
|
+
return getMultiFactorValidator(1, withOwner.validators);
|
|
812
788
|
}
|
|
813
789
|
}
|
|
814
790
|
// Smart sessions
|
|
815
791
|
const withSession = signers.type === 'experimental_session';
|
|
816
792
|
if (withSession) {
|
|
817
|
-
return
|
|
793
|
+
return getSmartSessionValidator(config);
|
|
818
794
|
}
|
|
819
795
|
// Guardians (social recovery)
|
|
820
796
|
const withGuardians = signers.type === 'guardians' ? signers : null;
|
|
821
797
|
if (withGuardians) {
|
|
822
|
-
return
|
|
798
|
+
return getSocialRecoveryValidator(withGuardians.guardians);
|
|
823
799
|
}
|
|
824
800
|
// Fallback
|
|
825
801
|
return undefined;
|
|
@@ -828,7 +804,7 @@ function parseCalls(calls, chainId) {
|
|
|
828
804
|
return calls.map((call) => ({
|
|
829
805
|
data: call.data ?? '0x',
|
|
830
806
|
value: call.value ?? 0n,
|
|
831
|
-
to:
|
|
807
|
+
to: resolveTokenAddress(call.to, chainId),
|
|
832
808
|
}));
|
|
833
809
|
}
|
|
834
810
|
function createAccountAccessList(sourceChains, sourceAssets) {
|
|
@@ -842,7 +818,7 @@ function createAccountAccessList(sourceChains, sourceAssets) {
|
|
|
842
818
|
if (isExactConfig) {
|
|
843
819
|
const resolvedConfigs = sourceAssets.map((config) => ({
|
|
844
820
|
chainId: config.chain.id,
|
|
845
|
-
tokenAddress:
|
|
821
|
+
tokenAddress: resolveTokenAddress(config.address, config.chain.id),
|
|
846
822
|
amount: config.amount,
|
|
847
823
|
}));
|
|
848
824
|
return resolvedConfigs;
|
|
@@ -854,18 +830,18 @@ function createAccountAccessList(sourceChains, sourceAssets) {
|
|
|
854
830
|
return { chainTokens: sourceAssets };
|
|
855
831
|
}
|
|
856
832
|
function getSetupOperationsAndDelegations(config, accountAddress, eip7702InitSignature) {
|
|
857
|
-
const initCode =
|
|
833
|
+
const initCode = getInitCode(config);
|
|
858
834
|
if (config.account?.type === 'eoa') {
|
|
859
835
|
return {
|
|
860
836
|
setupOps: [],
|
|
861
837
|
};
|
|
862
838
|
}
|
|
863
|
-
else if (
|
|
839
|
+
else if (is7702(config)) {
|
|
864
840
|
// EIP-7702 initialization is only needed for EOA accounts
|
|
865
841
|
if (!eip7702InitSignature || eip7702InitSignature === '0x') {
|
|
866
|
-
throw new
|
|
842
|
+
throw new Eip7702InitSignatureRequiredError();
|
|
867
843
|
}
|
|
868
|
-
const { initData: eip7702InitData, contract: eip7702Contract } =
|
|
844
|
+
const { initData: eip7702InitData, contract: eip7702Contract } = getEip7702InitCall(config, eip7702InitSignature);
|
|
869
845
|
return {
|
|
870
846
|
setupOps: [
|
|
871
847
|
{
|
|
@@ -891,7 +867,7 @@ function getSetupOperationsAndDelegations(config, accountAddress, eip7702InitSig
|
|
|
891
867
|
setupOps: [],
|
|
892
868
|
};
|
|
893
869
|
}
|
|
894
|
-
throw new
|
|
870
|
+
throw new FactoryArgsNotAvailableError();
|
|
895
871
|
}
|
|
896
872
|
// Contract account with init code
|
|
897
873
|
return {
|
|
@@ -913,12 +889,12 @@ function getSetupOperationsAndDelegations(config, accountAddress, eip7702InitSig
|
|
|
913
889
|
function validateTokenSymbols(chain, tokenAddressOrSymbols) {
|
|
914
890
|
function validateTokenSymbol(chain, addressOrSymbol) {
|
|
915
891
|
// Address
|
|
916
|
-
if (
|
|
892
|
+
if (isAddress(addressOrSymbol, { strict: false })) {
|
|
917
893
|
return true;
|
|
918
894
|
}
|
|
919
895
|
// Token symbol
|
|
920
|
-
const address =
|
|
921
|
-
return
|
|
896
|
+
const address = getTokenAddress(addressOrSymbol, chain.id);
|
|
897
|
+
return isAddress(address, { strict: false });
|
|
922
898
|
}
|
|
923
899
|
for (const addressOrSymbol of tokenAddressOrSymbols) {
|
|
924
900
|
if (!validateTokenSymbol(chain, addressOrSymbol)) {
|
|
@@ -930,7 +906,7 @@ function validateTokenSymbols(chain, tokenAddressOrSymbols) {
|
|
|
930
906
|
// Uses a Solady-compatible TypedDataSign hash and wraps the signature with
|
|
931
907
|
// the app domain separator and contents hash for on-chain verification.
|
|
932
908
|
async function signErc7739TypedData(config, signers, validator, isRoot, parameters, chain) {
|
|
933
|
-
const verifierDomain =
|
|
909
|
+
const verifierDomain = getEip712Domain(config, chain);
|
|
934
910
|
const hash = hashErc7739TypedDataForSolady({
|
|
935
911
|
domain: parameters.domain,
|
|
936
912
|
types: parameters.types,
|
|
@@ -938,10 +914,10 @@ async function signErc7739TypedData(config, signers, validator, isRoot, paramete
|
|
|
938
914
|
message: parameters.message,
|
|
939
915
|
verifierDomain,
|
|
940
916
|
});
|
|
941
|
-
return await
|
|
917
|
+
return await getEip1271Signature(config, signers, chain, {
|
|
942
918
|
address: validator.address,
|
|
943
919
|
isRoot,
|
|
944
|
-
}, hash, (signature) =>
|
|
920
|
+
}, hash, (signature) => wrapTypedDataSignature({
|
|
945
921
|
domain: parameters.domain,
|
|
946
922
|
primaryType: parameters.primaryType,
|
|
947
923
|
types: parameters.types,
|
|
@@ -979,15 +955,15 @@ function hashErc7739TypedDataForSolady({ domain, types, primaryType, message, ve
|
|
|
979
955
|
// Construct TypedDataSign type string matching Solady's on-chain encoding:
|
|
980
956
|
// TypedDataSign(<contentsName> contents,...salt) + contentsType
|
|
981
957
|
const typedDataSignTypeString = `TypedDataSign(${contentsName} contents,string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)${contentsType}`;
|
|
982
|
-
const typedDataSignTypeHash =
|
|
958
|
+
const typedDataSignTypeHash = keccak256(toHex(typedDataSignTypeString));
|
|
983
959
|
// Hash the original content struct
|
|
984
|
-
const contentsHash =
|
|
960
|
+
const contentsHash = hashStruct({
|
|
985
961
|
data: message,
|
|
986
962
|
primaryType,
|
|
987
963
|
types: types,
|
|
988
964
|
});
|
|
989
965
|
// Compute the TypedDataSign struct hash
|
|
990
|
-
const structHash =
|
|
966
|
+
const structHash = keccak256(encodeAbiParameters([
|
|
991
967
|
{ type: 'bytes32' },
|
|
992
968
|
{ type: 'bytes32' },
|
|
993
969
|
{ type: 'bytes32' },
|
|
@@ -998,8 +974,8 @@ function hashErc7739TypedDataForSolady({ domain, types, primaryType, message, ve
|
|
|
998
974
|
], [
|
|
999
975
|
typedDataSignTypeHash,
|
|
1000
976
|
contentsHash,
|
|
1001
|
-
|
|
1002
|
-
|
|
977
|
+
keccak256(toHex(verifierDomain.name)),
|
|
978
|
+
keccak256(toHex(verifierDomain.version)),
|
|
1003
979
|
BigInt(verifierDomain.chainId),
|
|
1004
980
|
verifierDomain.verifyingContract,
|
|
1005
981
|
verifierDomain.salt,
|
|
@@ -1016,10 +992,11 @@ function hashErc7739TypedDataForSolady({ domain, types, primaryType, message, ve
|
|
|
1016
992
|
domainTypes.push({ name: 'verifyingContract', type: 'address' });
|
|
1017
993
|
if (domain.salt)
|
|
1018
994
|
domainTypes.push({ name: 'salt', type: 'bytes32' });
|
|
1019
|
-
const appDomainSeparator =
|
|
995
|
+
const appDomainSeparator = hashDomain({
|
|
1020
996
|
domain,
|
|
1021
997
|
types: { EIP712Domain: domainTypes },
|
|
1022
998
|
});
|
|
1023
999
|
// Final hash: keccak256("\x19\x01" || appDomainSep || structHash)
|
|
1024
|
-
return
|
|
1000
|
+
return keccak256(concat(['0x1901', appDomainSeparator, structHash]));
|
|
1025
1001
|
}
|
|
1002
|
+
export { prepareTransaction, getTransactionMessages, signTransaction, signAuthorizations, signAuthorizationsInternal, signMessage, signTypedData, submitTransaction, prepareUserOperation, signUserOperation, submitUserOperation, signIntent, prepareTransactionAsIntent, submitIntentInternal, getValidatorAccount, parseCalls, getTokenRequests, resolveCallInputs, getIntentAccount, getTargetExecutionSignature, hashErc7739TypedDataForSolady, resolveSessionForChain, };
|