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