@rhinestone/sdk 2.0.0-beta.2 → 2.0.0-beta.20
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/index.d.ts +5 -5
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +46 -2
- package/dist/src/actions/ecdsa.js +2 -2
- package/dist/src/actions/index.js +2 -2
- package/dist/src/actions/mfa.js +2 -2
- package/dist/src/actions/passkeys.js +2 -2
- package/dist/src/actions/smart-sessions.d.ts +11 -3
- package/dist/src/actions/smart-sessions.d.ts.map +1 -1
- package/dist/src/actions/smart-sessions.js +14 -9
- package/dist/src/errors/index.d.ts +3 -3
- package/dist/src/errors/index.d.ts.map +1 -1
- package/dist/src/errors/index.js +4 -4
- package/dist/src/execution/error.d.ts +8 -7
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +7 -5
- package/dist/src/execution/index.d.ts +16 -17
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +18 -34
- package/dist/src/execution/utils.d.ts +15 -11
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +259 -56
- package/dist/src/index.d.ts +6 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -0
- package/dist/src/modules/validators/permissions.d.ts.map +1 -1
- package/dist/src/modules/validators/permissions.js +161 -17
- package/dist/src/modules/validators/smart-sessions.d.ts +24 -8
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions.js +227 -83
- package/dist/src/orchestrator/caip2.d.ts +9 -3
- package/dist/src/orchestrator/caip2.d.ts.map +1 -1
- package/dist/src/orchestrator/caip2.js +40 -5
- package/dist/src/orchestrator/client.d.ts +2 -1
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +56 -30
- 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 +1 -1
- package/dist/src/orchestrator/destinations.d.ts +23 -0
- package/dist/src/orchestrator/destinations.d.ts.map +1 -0
- package/dist/src/orchestrator/destinations.js +36 -0
- package/dist/src/orchestrator/error.d.ts +22 -3
- package/dist/src/orchestrator/error.d.ts.map +1 -1
- package/dist/src/orchestrator/error.js +32 -2
- package/dist/src/orchestrator/index.d.ts +6 -5
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +4 -3
- package/dist/src/orchestrator/registry.d.ts +2 -1
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +10 -0
- package/dist/src/orchestrator/types.d.ts +103 -35
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/orchestrator/types.js +1 -5
- package/dist/src/types.d.ts +148 -15
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -2,13 +2,14 @@ import { type Address, type Chain, type HashTypedDataParameters, type Hex, type
|
|
|
2
2
|
import { type UserOperation } from 'viem/account-abstraction';
|
|
3
3
|
import { type ResolvedSessionSignerSet } from '../modules/validators/smart-sessions.js';
|
|
4
4
|
import { type Quote, type SignData } from '../orchestrator/index.js';
|
|
5
|
-
import { type
|
|
6
|
-
import
|
|
5
|
+
import { type DestinationChain, type NonEvmAddress } from '../orchestrator/destinations.js';
|
|
6
|
+
import { type AuxiliaryFunds, type OriginSignature, type SettlementLayerFilter, type SignatureMode } from '../orchestrator/types.js';
|
|
7
|
+
import type { Call, CalldataInput, CallInput, NonEvmTokenRequest, RhinestoneAccountConfig, RhinestoneConfig, Session, SessionEnableData, SessionSignerSet, SignerSet, SourceAssetInput, SourceCallInput, Sponsorship, TokenRequest, TokenSymbol, Transaction, UserOperationTransaction } from '../types.js';
|
|
7
8
|
type InternalSignerSet = Exclude<SignerSet, SessionSignerSet> | ResolvedSessionSignerSet;
|
|
9
|
+
declare function resolveSignatureMode(config: RhinestoneConfig, signers: SignerSet | undefined, sourceChains: Chain[] | undefined, targetChainId: number, preResolved?: Map<number, InternalSignerSet | undefined>): Promise<SignatureMode>;
|
|
8
10
|
declare function resolveSessionForChain(signers: SessionSignerSet, chainId: number): {
|
|
9
11
|
session: Session;
|
|
10
12
|
enableData?: SessionEnableData;
|
|
11
|
-
verifyExecutions?: boolean;
|
|
12
13
|
};
|
|
13
14
|
interface UserOperationResult {
|
|
14
15
|
type: 'userop';
|
|
@@ -18,10 +19,12 @@ interface UserOperationResult {
|
|
|
18
19
|
interface TransactionResult {
|
|
19
20
|
type: 'intent';
|
|
20
21
|
id: string;
|
|
22
|
+
traceId: string;
|
|
21
23
|
sourceChains?: number[];
|
|
22
24
|
targetChain: number;
|
|
23
25
|
}
|
|
24
26
|
interface PreparedQuotes {
|
|
27
|
+
traceId: string;
|
|
25
28
|
best: Quote;
|
|
26
29
|
all: Quote[];
|
|
27
30
|
}
|
|
@@ -56,7 +59,7 @@ declare function getTransactionMessages(_config: RhinestoneConfig, preparedTrans
|
|
|
56
59
|
targetExecution?: TypedDataDefinition;
|
|
57
60
|
};
|
|
58
61
|
declare function signTransaction(config: RhinestoneConfig, preparedTransaction: PreparedTransactionData, options?: QuoteSelection): Promise<SignedTransactionData>;
|
|
59
|
-
declare function getTargetExecutionSignature(config: RhinestoneConfig, signData: SignData, targetChain:
|
|
62
|
+
declare function getTargetExecutionSignature(config: RhinestoneConfig, signData: SignData, targetChain: DestinationChain, signers: SignerSet | undefined): Promise<`0x${string}` | undefined>;
|
|
60
63
|
declare function signUserOperation(config: RhinestoneConfig, preparedUserOperation: PreparedUserOperationData): Promise<SignedUserOperationData>;
|
|
61
64
|
declare function signAuthorizations(config: RhinestoneConfig, preparedTransaction: PreparedTransactionData): Promise<SignedAuthorization[]>;
|
|
62
65
|
declare function signMessage(config: RhinestoneConfig, message: SignableMessage, chain: Chain, signers: SignerSet | undefined): Promise<`0x${string}`>;
|
|
@@ -65,12 +68,12 @@ declare function signTypedData<typedData extends TypedData | Record<string, unkn
|
|
|
65
68
|
}): Promise<`0x${string}`>;
|
|
66
69
|
declare function signAuthorizationsInternal(config: RhinestoneConfig, context: {
|
|
67
70
|
sourceChains: Chain[] | undefined;
|
|
68
|
-
targetChain:
|
|
71
|
+
targetChain: DestinationChain;
|
|
69
72
|
eip7702InitSignature: Hex | undefined;
|
|
70
73
|
}): Promise<SignedAuthorization[]>;
|
|
71
74
|
declare function submitTransaction(config: RhinestoneConfig, signedTransaction: SignedTransactionData, authorizations: SignedAuthorizationList, dryRun?: boolean): Promise<TransactionResult>;
|
|
72
75
|
declare function submitUserOperation(config: RhinestoneConfig, signedUserOperation: SignedUserOperationData): Promise<UserOperationResult>;
|
|
73
|
-
declare function getTokenRequests(targetChain:
|
|
76
|
+
declare function getTokenRequests(targetChain: DestinationChain, initialTokenRequests: (TokenRequest | NonEvmTokenRequest)[] | undefined): (TokenRequest | NonEvmTokenRequest)[];
|
|
74
77
|
declare function getIntentAccount(config: RhinestoneConfig, eip7702InitSignature: Hex | undefined, account: {
|
|
75
78
|
setupOps?: {
|
|
76
79
|
to: Address;
|
|
@@ -89,23 +92,24 @@ declare function getIntentAccount(config: RhinestoneConfig, eip7702InitSignature
|
|
|
89
92
|
};
|
|
90
93
|
} | undefined;
|
|
91
94
|
};
|
|
92
|
-
declare function prepareTransactionAsIntent(config: RhinestoneConfig, sourceChains: Chain[] | undefined, targetChain:
|
|
95
|
+
declare function prepareTransactionAsIntent(config: RhinestoneConfig, sourceChains: Chain[] | undefined, targetChain: DestinationChain, callInputs: CalldataInput[], gasLimit: bigint | undefined, tokenRequests: (TokenRequest | NonEvmTokenRequest)[], recipientInput: RhinestoneAccountConfig | Address | NonEvmAddress | undefined, sponsored: Sponsorship | undefined, eip7702InitSignature: Hex | undefined, settlementLayers: SettlementLayerFilter | undefined, sourceAssets: SourceAssetInput | undefined, feeAsset: Address | TokenSymbol | undefined, auxiliaryFunds: AuxiliaryFunds | undefined, account: {
|
|
93
96
|
setupOps?: {
|
|
94
97
|
to: Address;
|
|
95
98
|
data: Hex;
|
|
96
99
|
}[];
|
|
97
|
-
} | undefined, signers: SignerSet | undefined): Promise<{
|
|
100
|
+
} | undefined, signers: SignerSet | undefined, sourceCalls?: Record<number, SourceCallInput[]>): Promise<{
|
|
98
101
|
quotes: {
|
|
102
|
+
traceId: string;
|
|
99
103
|
best: Quote;
|
|
100
104
|
all: Quote[];
|
|
101
105
|
};
|
|
102
106
|
intentInput: any;
|
|
103
107
|
}>;
|
|
104
|
-
declare function signIntent(config: RhinestoneConfig, signData: SignData, targetChain:
|
|
108
|
+
declare function signIntent(config: RhinestoneConfig, signData: SignData, targetChain: DestinationChain, signers?: SignerSet, targetExecution?: boolean): Promise<{
|
|
105
109
|
originSignatures: OriginSignature[];
|
|
106
110
|
destinationSignature: `0x${string}`;
|
|
107
111
|
}>;
|
|
108
|
-
declare function submitIntentInternal(config: RhinestoneConfig, sourceChains: Chain[] | undefined, targetChain:
|
|
112
|
+
declare function submitIntentInternal(config: RhinestoneConfig, sourceChains: Chain[] | undefined, targetChain: DestinationChain, quote: Quote, originSignatures: OriginSignature[], destinationSignature: Hex, targetExecutionSignature: Hex | undefined, authorizations: SignedAuthorizationList, dryRun: boolean, intentInput?: unknown): Promise<TransactionResult>;
|
|
109
113
|
declare function getValidatorAccount(config: RhinestoneConfig, signers: SignerSet | undefined, publicClient: PublicClient, chain: Chain): Promise<import("viem/account-abstraction").SmartAccount<import("viem/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">> | null | undefined>;
|
|
110
114
|
declare function parseCalls(calls: CalldataInput[], chainId: number): Call[];
|
|
111
115
|
declare function hashErc7739TypedDataForSolady({ domain, types, primaryType, message, verifierDomain, }: {
|
|
@@ -121,6 +125,6 @@ declare function hashErc7739TypedDataForSolady({ domain, types, primaryType, mes
|
|
|
121
125
|
salt: Hex;
|
|
122
126
|
};
|
|
123
127
|
}): Hex;
|
|
124
|
-
export { prepareTransaction, getTransactionMessages, signTransaction, signAuthorizations, signAuthorizationsInternal, signMessage, signTypedData, submitTransaction, prepareUserOperation, signUserOperation, submitUserOperation, signIntent, prepareTransactionAsIntent, submitIntentInternal, getValidatorAccount, parseCalls, getTokenRequests, resolveCallInputs, getIntentAccount, getTargetExecutionSignature, hashErc7739TypedDataForSolady, resolveSessionForChain, };
|
|
128
|
+
export { prepareTransaction, getTransactionMessages, signTransaction, signAuthorizations, signAuthorizationsInternal, signMessage, signTypedData, submitTransaction, prepareUserOperation, signUserOperation, submitUserOperation, signIntent, prepareTransactionAsIntent, submitIntentInternal, getValidatorAccount, parseCalls, getTokenRequests, resolveCallInputs, getIntentAccount, getTargetExecutionSignature, hashErc7739TypedDataForSolady, resolveSessionForChain, resolveSignatureMode, };
|
|
125
129
|
export type { InternalSignerSet, TransactionResult, PreparedQuotes, PreparedTransactionData, PreparedUserOperationData, QuoteSelection, SignedTransactionData, SignedUserOperationData, UserOperationResult, };
|
|
126
130
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../execution/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAMV,KAAK,uBAAuB,EAC5B,KAAK,GAAG,EAOR,KAAK,YAAY,EAEjB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,SAAS,EACd,KAAK,mBAAmB,EACxB,KAAK,eAAe,EAGrB,MAAM,MAAM,CAAA;AACb,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAA;AA+CjC,OAAO,EACL,KAAK,wBAAwB,EAE9B,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EAIL,KAAK,KAAK,EACV,KAAK,QAAQ,EACd,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../execution/utils.ts"],"names":[],"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
|
@@ -11,10 +11,12 @@ import { getMultiFactorValidator, getSocialRecoveryValidator, getWebAuthnValidat
|
|
|
11
11
|
import { buildPermit2ClaimPolicyCalldata, } from '../modules/validators/policies/claim/permit2.js';
|
|
12
12
|
import { resolvePermit2ClaimPolicy, } from '../modules/validators/smart-sessions.js';
|
|
13
13
|
import { getOrchestrator, } from '../orchestrator/index.js';
|
|
14
|
+
import { toCaip2 } from '../orchestrator/caip2.js';
|
|
15
|
+
import { getChainId, isNonEvmChain, } from '../orchestrator/destinations.js';
|
|
14
16
|
import { getChainById, getTokenAddress, resolveTokenAddress, } from '../orchestrator/registry.js';
|
|
15
|
-
import { SIG_MODE_EMISSARY_EXECUTION_ERC1271,
|
|
17
|
+
import { SIG_MODE_EMISSARY_EXECUTION_ERC1271, SIG_MODE_ERC1271, } from '../orchestrator/types.js';
|
|
16
18
|
import { convertBigIntFields } from '../orchestrator/utils.js';
|
|
17
|
-
import { Eip7702InitSignatureRequiredError, QuoteNotInPreparedTransactionError, SignerNotSupportedError, } from './error.js';
|
|
19
|
+
import { Eip7702InitSignatureRequiredError, InvalidSourceCallsError, QuoteNotInPreparedTransactionError, SignerNotSupportedError, } from './error.js';
|
|
18
20
|
function isResolvedSessionSignerSet(signers) {
|
|
19
21
|
return (signers?.type === 'experimental_session' && 'verifyExecutions' in signers);
|
|
20
22
|
}
|
|
@@ -25,16 +27,61 @@ async function resolveSignersForChain(config, signers, chainId) {
|
|
|
25
27
|
const resolved = resolveSessionForChain(signers, chainId);
|
|
26
28
|
const enabled = await isSessionEnabled(getAddress(config), config.provider, resolved.session, config.useDevContracts);
|
|
27
29
|
const enableData = enabled ? undefined : resolved.enableData;
|
|
28
|
-
const verifyExecutions = resolved.verifyExecutions ??
|
|
29
|
-
signers.verifyExecutions ??
|
|
30
|
-
resolved.session.hasExplicitPermissions;
|
|
31
30
|
return {
|
|
32
31
|
type: 'experimental_session',
|
|
33
32
|
session: resolved.session,
|
|
34
33
|
enableData,
|
|
35
|
-
|
|
34
|
+
// First use of any session must go through the emissary's verifyExecution
|
|
35
|
+
// path: that's the only mechanism that consumes enableData + calls setConfig
|
|
36
|
+
// to install the session on-chain. Once installed, steady-state signing can
|
|
37
|
+
// drop to mode 1 unless the session has explicit permissions to enforce.
|
|
38
|
+
verifyExecutions: !enabled || resolved.session.hasExplicitPermissions,
|
|
36
39
|
};
|
|
37
40
|
}
|
|
41
|
+
// Picks the single signature mode that matches the bytes shape the SDK will
|
|
42
|
+
// actually sign, so the on-chain dispatcher hits the right validator on the
|
|
43
|
+
// first try instead of falling through a hybrid.
|
|
44
|
+
async function resolveSignatureMode(config, signers, sourceChains, targetChainId,
|
|
45
|
+
// Optional pre-resolved per-chain signer sets. When supplied, reuse them
|
|
46
|
+
// instead of resolving again — each resolveSignersForChain does an
|
|
47
|
+
// isSessionEnabled RPC, so sharing one map across mockSignatures, sigMode, and
|
|
48
|
+
// preClaim avoids duplicate calls per intent. The map also defines *which*
|
|
49
|
+
// chains carry a session: the caller omits a non-EVM target (it has no session
|
|
50
|
+
// validator), so deriving the chain set from the map's keys keeps us from
|
|
51
|
+
// resolving — and throwing on — a target with no configured session.
|
|
52
|
+
preResolved) {
|
|
53
|
+
if (config.account?.type === 'eoa') {
|
|
54
|
+
return SIG_MODE_ERC1271;
|
|
55
|
+
}
|
|
56
|
+
if (signers?.type !== 'experimental_session') {
|
|
57
|
+
return SIG_MODE_ERC1271;
|
|
58
|
+
}
|
|
59
|
+
const chainIds = preResolved
|
|
60
|
+
? [...preResolved.keys()]
|
|
61
|
+
: [...new Set([...(sourceChains ?? []).map((c) => c.id), targetChainId])];
|
|
62
|
+
const resolvedSet = await Promise.all(chainIds.map((chainId) =>
|
|
63
|
+
// Use has() not `?? resolve` so a cached `undefined` entry is still reused
|
|
64
|
+
// (get() can't distinguish "missing key" from "present but undefined").
|
|
65
|
+
preResolved?.has(chainId)
|
|
66
|
+
? preResolved.get(chainId)
|
|
67
|
+
: resolveSignersForChain(config, signers, chainId)));
|
|
68
|
+
let anyVerifyExecutions = false;
|
|
69
|
+
for (const resolved of resolvedSet) {
|
|
70
|
+
if (!isResolvedSessionSignerSet(resolved)) {
|
|
71
|
+
return SIG_MODE_ERC1271;
|
|
72
|
+
}
|
|
73
|
+
// Conservative: one chain with verifyExecutions=true forces mode 5 across
|
|
74
|
+
// all origin signatures — a single mode field can't describe divergence.
|
|
75
|
+
if (resolved.verifyExecutions)
|
|
76
|
+
anyVerifyExecutions = true;
|
|
77
|
+
}
|
|
78
|
+
// Mode 4 (pure emissary-execution) is unused: signIntentTypedData always
|
|
79
|
+
// emits a dual sig for the intent's origin/destination signatures when
|
|
80
|
+
// verifyExecutions=true, so mode 5 is the right hybrid.
|
|
81
|
+
return anyVerifyExecutions
|
|
82
|
+
? SIG_MODE_EMISSARY_EXECUTION_ERC1271
|
|
83
|
+
: SIG_MODE_ERC1271;
|
|
84
|
+
}
|
|
38
85
|
function resolveSessionForChain(signers, chainId) {
|
|
39
86
|
if ('sessions' in signers) {
|
|
40
87
|
const config = signers.sessions[chainId];
|
|
@@ -46,13 +93,27 @@ function resolveSessionForChain(signers, chainId) {
|
|
|
46
93
|
return { session: signers.session, enableData: signers.enableData };
|
|
47
94
|
}
|
|
48
95
|
async function prepareTransaction(config, transaction) {
|
|
49
|
-
const { sourceChains, targetChain, tokenRequests, signers, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, auxiliaryFunds, account, recipient, } = getTransactionParams(transaction);
|
|
96
|
+
const { sourceChains, targetChain, tokenRequests, signers, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, auxiliaryFunds, account, recipient, sourceCalls, } = getTransactionParams(transaction);
|
|
50
97
|
const accountAddress = getAddress(config);
|
|
51
98
|
const isUserOpSigner = signers?.type === 'guardians';
|
|
52
99
|
if (isUserOpSigner) {
|
|
53
100
|
throw new SignerNotSupportedError();
|
|
54
101
|
}
|
|
55
|
-
|
|
102
|
+
// Destination calls (transaction.calls on a cross-chain transaction) are
|
|
103
|
+
// executed on the destination chain by the solver/account. For non-EVM
|
|
104
|
+
// destinations we can't resolve arbitrary EVM calls; assert there are
|
|
105
|
+
// none and route an empty list through.
|
|
106
|
+
let resolvedCalls;
|
|
107
|
+
if (isNonEvmChain(targetChain)) {
|
|
108
|
+
if (transaction.calls && transaction.calls.length > 0) {
|
|
109
|
+
throw new Error(`Destination calls are not supported for non-EVM target chain ${targetChain.name} (${targetChain.caip2})`);
|
|
110
|
+
}
|
|
111
|
+
resolvedCalls = [];
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
resolvedCalls = await resolveCallInputs(transaction.calls, config, targetChain, accountAddress);
|
|
115
|
+
}
|
|
116
|
+
const prepared = await prepareTransactionAsIntent(config, sourceChains, targetChain, resolvedCalls, transaction.gasLimit, tokenRequests, recipient, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, auxiliaryFunds, account, signers, sourceCalls);
|
|
56
117
|
return {
|
|
57
118
|
quotes: prepared.quotes,
|
|
58
119
|
intentInput: prepared.intentInput,
|
|
@@ -131,6 +192,11 @@ async function getTargetExecutionSignature(config, signData, targetChain, signer
|
|
|
131
192
|
if (!signData.targetExecution) {
|
|
132
193
|
return undefined;
|
|
133
194
|
}
|
|
195
|
+
// Target executions are EVM-only (smart-session validator on destination).
|
|
196
|
+
// Non-EVM destinations don't have a validator there to verify the sig.
|
|
197
|
+
if (isNonEvmChain(targetChain)) {
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
134
200
|
const resolvedSigners = await resolveSignersForChain(config, signers, targetChain.id);
|
|
135
201
|
if (!isResolvedSessionSignerSet(resolvedSigners) ||
|
|
136
202
|
!resolvedSigners.verifyExecutions) {
|
|
@@ -266,10 +332,16 @@ async function signAuthorizationsInternal(config, context) {
|
|
|
266
332
|
}
|
|
267
333
|
const accountAddress = getAddress(config);
|
|
268
334
|
const { contract: eip7702Contract } = getEip7702InitCall(config, eip7702InitSignature);
|
|
335
|
+
// EIP-7702 authorization is EVM-only — there's no contract to delegate
|
|
336
|
+
// to on Solana / Tron. Skip the destination chain entirely when it's
|
|
337
|
+
// non-EVM; source chains are always EVM by construction.
|
|
269
338
|
const chains = new Map();
|
|
270
|
-
for (const chain of
|
|
339
|
+
for (const chain of context.sourceChains ?? []) {
|
|
271
340
|
chains.set(chain.id, chain);
|
|
272
341
|
}
|
|
342
|
+
if (!isNonEvmChain(context.targetChain)) {
|
|
343
|
+
chains.set(context.targetChain.id, context.targetChain);
|
|
344
|
+
}
|
|
273
345
|
const authorizations = [];
|
|
274
346
|
for (const chain of chains.values()) {
|
|
275
347
|
const walletClient = createWalletClient({
|
|
@@ -318,6 +390,7 @@ function getTransactionParams(transaction) {
|
|
|
318
390
|
const auxiliaryFunds = transaction.auxiliaryFunds;
|
|
319
391
|
const account = transaction.experimental_accountOverride;
|
|
320
392
|
const recipient = transaction.recipient;
|
|
393
|
+
const sourceCalls = transaction.sourceCalls;
|
|
321
394
|
const tokenRequests = getTokenRequests(targetChain, initialTokenRequests);
|
|
322
395
|
return {
|
|
323
396
|
sourceChains,
|
|
@@ -333,11 +406,19 @@ function getTransactionParams(transaction) {
|
|
|
333
406
|
auxiliaryFunds,
|
|
334
407
|
account,
|
|
335
408
|
recipient,
|
|
409
|
+
sourceCalls,
|
|
336
410
|
};
|
|
337
411
|
}
|
|
338
412
|
function getTokenRequests(targetChain, initialTokenRequests) {
|
|
339
|
-
|
|
340
|
-
|
|
413
|
+
// Non-EVM destinations carry SPL mint / Tron T-prefixed addresses that
|
|
414
|
+
// aren't valid 0x-hex; skip symbol/EVM-address validation here and let
|
|
415
|
+
// the orchestrator validate per its own schema. EVM destinations keep
|
|
416
|
+
// the existing strict check so a typo on Optimism still fails fast.
|
|
417
|
+
if (initialTokenRequests && !isNonEvmChain(targetChain)) {
|
|
418
|
+
// Inside this branch targetChain is a viem `Chain`, which excludes the
|
|
419
|
+
// non-EVM transaction variant — token requests are EVM-typed here.
|
|
420
|
+
const evmRequests = initialTokenRequests;
|
|
421
|
+
validateTokenSymbols(targetChain, evmRequests.map((tokenRequest) => tokenRequest.address));
|
|
341
422
|
}
|
|
342
423
|
return initialTokenRequests ?? [];
|
|
343
424
|
}
|
|
@@ -386,12 +467,43 @@ function getIntentAccount(config, eip7702InitSignature, account) {
|
|
|
386
467
|
delegations,
|
|
387
468
|
};
|
|
388
469
|
}
|
|
389
|
-
|
|
390
|
-
|
|
470
|
+
function cloneAuxiliaryFunds(auxiliaryFunds) {
|
|
471
|
+
if (!auxiliaryFunds)
|
|
472
|
+
return undefined;
|
|
473
|
+
return Object.fromEntries(Object.entries(auxiliaryFunds).map(([chainId, funds]) => [
|
|
474
|
+
Number(chainId),
|
|
475
|
+
{ ...funds },
|
|
476
|
+
]));
|
|
477
|
+
}
|
|
478
|
+
function toCallInput(sourceCall) {
|
|
479
|
+
const { provides: _provides, ...call } = sourceCall;
|
|
480
|
+
return call;
|
|
481
|
+
}
|
|
482
|
+
function addProvidedFunds(auxiliaryFunds, chainId, calls) {
|
|
483
|
+
let next = auxiliaryFunds;
|
|
484
|
+
for (const call of calls) {
|
|
485
|
+
for (const provided of call.provides ?? []) {
|
|
486
|
+
next ??= {};
|
|
487
|
+
next[chainId] ??= {};
|
|
488
|
+
const token = provided.token;
|
|
489
|
+
next[chainId][token] = (next[chainId][token] ?? 0n) + provided.amount;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
return next;
|
|
493
|
+
}
|
|
494
|
+
async function prepareTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, recipientInput, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, auxiliaryFunds, account, signers, sourceCalls) {
|
|
495
|
+
const targetChainId = getChainId(targetChain);
|
|
496
|
+
const calls = parseCalls(callInputs, targetChainId);
|
|
391
497
|
const accountAccessList = createAccountAccessList(sourceChains, sourceAssets);
|
|
392
498
|
function getRecipient(recipient) {
|
|
393
499
|
if (typeof recipient === 'string') {
|
|
394
|
-
//
|
|
500
|
+
// Non-EVM recipients (Solana base58 / Tron T-prefix) carry no
|
|
501
|
+
// EVM smart-account semantics; orchestrator schema requires
|
|
502
|
+
// accountType / setupOps to be unset. Emit just the address.
|
|
503
|
+
if (isNonEvmChain(targetChain)) {
|
|
504
|
+
return { address: recipient };
|
|
505
|
+
}
|
|
506
|
+
// EVM passthrough — assume EOA.
|
|
395
507
|
return {
|
|
396
508
|
address: recipient,
|
|
397
509
|
accountType: 'EOA',
|
|
@@ -404,25 +516,65 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
404
516
|
}
|
|
405
517
|
return getIntentAccount(recipient, eip7702InitSignature, account);
|
|
406
518
|
}
|
|
519
|
+
// Resolve per-chain signer state once (each resolveSignersForChain does an
|
|
520
|
+
// isSessionEnabled RPC) and reuse it for mock signatures, the signature mode,
|
|
521
|
+
// and preClaim ops. Exclude a non-EVM destination — it has no session
|
|
522
|
+
// validator, so resolving it would waste an RPC (or throw for per-chain
|
|
523
|
+
// session signers). resolveSignatureMode derives its chain set from this map's
|
|
524
|
+
// keys, so the excluded non-EVM target is never resolved there either.
|
|
525
|
+
const sessionChainIds = [
|
|
526
|
+
...new Set([
|
|
527
|
+
...(sourceChains ?? []).map((c) => c.id),
|
|
528
|
+
...(isNonEvmChain(targetChain) ? [] : [targetChainId]),
|
|
529
|
+
]),
|
|
530
|
+
];
|
|
531
|
+
const resolvedByChain = signers?.type === 'experimental_session'
|
|
532
|
+
? new Map(await Promise.all(sessionChainIds.map(async (chainId) => [
|
|
533
|
+
chainId,
|
|
534
|
+
await resolveSignersForChain(config, signers, chainId),
|
|
535
|
+
])))
|
|
536
|
+
: undefined;
|
|
537
|
+
// Per-chain mock signatures: enables accurate per-chain session validation gas
|
|
538
|
+
// simulation. Non-EVM destinations are excluded — they have no destination-side
|
|
539
|
+
// session validator. Each chain's mock sig carries that chain's own resolved
|
|
540
|
+
// shape (ENABLE / USE / ERC-1271). Note these are per-chain and may differ in
|
|
541
|
+
// shape, whereas `signatureMode` (below) is a single global value resolved
|
|
542
|
+
// conservatively (anyVerifyExecutions across chains → mode 5) — so in mixed
|
|
543
|
+
// states a chain's mock shape need not match the global signatureMode.
|
|
544
|
+
let mockSignatures;
|
|
545
|
+
if (resolvedByChain) {
|
|
546
|
+
const entries = [...resolvedByChain.entries()].flatMap(([chainId, resolved]) => {
|
|
547
|
+
// resolvedByChain is keyed by sessionChainIds, which already excludes a
|
|
548
|
+
// non-EVM target — so no per-entry target guard is needed here.
|
|
549
|
+
if (!isResolvedSessionSignerSet(resolved))
|
|
550
|
+
return [];
|
|
551
|
+
// Match the mock shape to what the real sig will be: ERC-1271 when not
|
|
552
|
+
// verifying executions; otherwise ENABLE if the session still needs
|
|
553
|
+
// installing (enableData present), else USE (already enabled, e.g.
|
|
554
|
+
// explicit permissions — its real sig is MODE_USE with no enableData).
|
|
555
|
+
const shape = !resolved.verifyExecutions
|
|
556
|
+
? 'erc1271'
|
|
557
|
+
: resolved.enableData !== undefined
|
|
558
|
+
? 'enable'
|
|
559
|
+
: 'use';
|
|
560
|
+
return [
|
|
561
|
+
[
|
|
562
|
+
String(chainId),
|
|
563
|
+
buildMockSignature(resolved.session, config.useDevContracts, sourceChains?.length ?? 1, chainId, shape),
|
|
564
|
+
],
|
|
565
|
+
];
|
|
566
|
+
});
|
|
567
|
+
// Leave mockSignatures undefined (not {}) when there are no eligible chains,
|
|
568
|
+
// so downstream consumers can treat presence as "per-chain sigs provided".
|
|
569
|
+
if (entries.length > 0)
|
|
570
|
+
mockSignatures = Object.fromEntries(entries);
|
|
571
|
+
}
|
|
407
572
|
const intentAccount = {
|
|
408
573
|
...getIntentAccount(config, eip7702InitSignature, account),
|
|
409
|
-
...(
|
|
410
|
-
// Per-chain map: enables accurate per-chain session validation gas simulation
|
|
411
|
-
mockSignatures: Object.fromEntries([
|
|
412
|
-
...new Set([
|
|
413
|
-
...(sourceChains ?? []).map((c) => c.id),
|
|
414
|
-
targetChain.id,
|
|
415
|
-
]),
|
|
416
|
-
].map((chainId) => [
|
|
417
|
-
String(chainId),
|
|
418
|
-
buildMockSignature(resolveSessionForChain(signers, chainId).session, config.useDevContracts, sourceChains?.length ?? 1, chainId),
|
|
419
|
-
])),
|
|
420
|
-
}),
|
|
574
|
+
...(mockSignatures && { mockSignatures }),
|
|
421
575
|
};
|
|
422
576
|
const recipient = getRecipient(recipientInput);
|
|
423
|
-
const signatureMode = signers
|
|
424
|
-
? SIG_MODE_EMISSARY_EXECUTION_ERC1271
|
|
425
|
-
: SIG_MODE_ERC1271_EMISSARY;
|
|
577
|
+
const signatureMode = await resolveSignatureMode(config, signers, sourceChains, targetChainId, resolvedByChain);
|
|
426
578
|
// For session signers that need enabling, pass a dummy preclaimop per source chain
|
|
427
579
|
// so the orchestrator bakes it into the bundle before computing its HMAC. The filler
|
|
428
580
|
// executes the op via verifyExecution in ENABLE mode, enabling the session on-chain
|
|
@@ -430,11 +582,11 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
430
582
|
// post-facto — because the orchestrator HMAC covers preClaimOps.
|
|
431
583
|
const preClaimExecutions = {};
|
|
432
584
|
if (signers?.type === 'experimental_session' && sourceChains) {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
585
|
+
// Reuse the shared per-chain resolution (source chains are a subset of
|
|
586
|
+
// sessionChainIds) instead of resolving — and re-doing isSessionEnabled — again.
|
|
587
|
+
for (const chain of sourceChains) {
|
|
588
|
+
const chainId = chain.id;
|
|
589
|
+
const resolved = resolvedByChain?.get(chainId);
|
|
438
590
|
if (!isResolvedSessionSignerSet(resolved))
|
|
439
591
|
continue;
|
|
440
592
|
const { enableData, verifyExecutions } = resolved;
|
|
@@ -449,10 +601,40 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
449
601
|
];
|
|
450
602
|
}
|
|
451
603
|
}
|
|
604
|
+
let combinedAuxiliaryFunds = cloneAuxiliaryFunds(auxiliaryFunds);
|
|
605
|
+
if (sourceCalls) {
|
|
606
|
+
const accountAddress = getAddress(config);
|
|
607
|
+
const allowedChainIds = new Set([
|
|
608
|
+
...(sourceChains ?? []).map((c) => c.id),
|
|
609
|
+
...(!isNonEvmChain(targetChain) ? [targetChainId] : []),
|
|
610
|
+
]);
|
|
611
|
+
for (const [chainIdStr, calls] of Object.entries(sourceCalls)) {
|
|
612
|
+
const chainId = Number(chainIdStr);
|
|
613
|
+
if (!allowedChainIds.has(chainId)) {
|
|
614
|
+
throw new InvalidSourceCallsError({ chainId });
|
|
615
|
+
}
|
|
616
|
+
const chain = sourceChains?.find((c) => c.id === chainId) ??
|
|
617
|
+
(!isNonEvmChain(targetChain) && targetChainId === chainId
|
|
618
|
+
? targetChain
|
|
619
|
+
: undefined);
|
|
620
|
+
if (!chain) {
|
|
621
|
+
throw new InvalidSourceCallsError({ chainId });
|
|
622
|
+
}
|
|
623
|
+
combinedAuxiliaryFunds = addProvidedFunds(combinedAuxiliaryFunds, chainId, calls);
|
|
624
|
+
const resolved = await resolveCallInputs(calls.map(toCallInput), config, chain, accountAddress);
|
|
625
|
+
const userExecutions = parseCalls(resolved, chainId);
|
|
626
|
+
if (userExecutions.length === 0)
|
|
627
|
+
continue;
|
|
628
|
+
preClaimExecutions[chainId] = [
|
|
629
|
+
...(preClaimExecutions[chainId] ?? []),
|
|
630
|
+
...userExecutions,
|
|
631
|
+
];
|
|
632
|
+
}
|
|
633
|
+
}
|
|
452
634
|
const metaIntent = {
|
|
453
|
-
destinationChainId:
|
|
635
|
+
destinationChainId: targetChainId,
|
|
454
636
|
tokenRequests: tokenRequests.map((tokenRequest) => ({
|
|
455
|
-
tokenAddress: resolveTokenAddress(tokenRequest.address,
|
|
637
|
+
tokenAddress: resolveTokenAddress(tokenRequest.address, targetChainId),
|
|
456
638
|
amount: tokenRequest.amount,
|
|
457
639
|
})),
|
|
458
640
|
recipient,
|
|
@@ -477,19 +659,19 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
477
659
|
: undefined,
|
|
478
660
|
settlementLayers,
|
|
479
661
|
signatureMode,
|
|
480
|
-
auxiliaryFunds,
|
|
662
|
+
auxiliaryFunds: combinedAuxiliaryFunds,
|
|
481
663
|
},
|
|
482
664
|
...(Object.keys(preClaimExecutions).length > 0 && { preClaimExecutions }),
|
|
483
665
|
};
|
|
484
666
|
const serializedIntent = convertBigIntFields(metaIntent);
|
|
485
667
|
const orchestrator = getOrchestrator(config._authProvider ?? createAuthProvider(config), config.endpointUrl, config.headers);
|
|
486
|
-
const { routes } = await orchestrator.createQuote(metaIntent);
|
|
668
|
+
const { routes, traceId } = await orchestrator.createQuote(metaIntent);
|
|
487
669
|
const best = routes[0];
|
|
488
670
|
if (!best) {
|
|
489
671
|
throw new Error('Orchestrator returned no quote');
|
|
490
672
|
}
|
|
491
673
|
return {
|
|
492
|
-
quotes: { best, all: routes },
|
|
674
|
+
quotes: { traceId, best, all: routes },
|
|
493
675
|
intentInput: serializedIntent,
|
|
494
676
|
};
|
|
495
677
|
}
|
|
@@ -529,7 +711,14 @@ async function signIntent(config, signData, targetChain, signers, targetExecutio
|
|
|
529
711
|
const signature = await signIntentTypedData(config, originSigners, validator, isRoot, typedData, chain, targetExecution ?? false);
|
|
530
712
|
originSignatures.push(signature);
|
|
531
713
|
}
|
|
532
|
-
|
|
714
|
+
// Non-EVM destinations have no destination-side validator, so there's no
|
|
715
|
+
// session to resolve and no signer to derive. Skipping here matters for
|
|
716
|
+
// per-chain experimental sessions: `resolveSessionForChain` would throw
|
|
717
|
+
// `No session configured for chain {synthetic-id}` since users never
|
|
718
|
+
// configure a session keyed by the synthetic Solana/Tron chain id.
|
|
719
|
+
const destinationSigners = isNonEvmChain(targetChain)
|
|
720
|
+
? undefined
|
|
721
|
+
: await resolveSignersForChain(config, signers, targetChain.id);
|
|
533
722
|
const destinationSignature = await getDestinationSignature(config, destinationSigners, validator, isRoot, targetChain, destination, originSignatures, targetExecution ?? false);
|
|
534
723
|
return {
|
|
535
724
|
originSignatures,
|
|
@@ -537,18 +726,25 @@ async function signIntent(config, signData, targetChain, signers, targetExecutio
|
|
|
537
726
|
};
|
|
538
727
|
}
|
|
539
728
|
async function getDestinationSignature(config, signers, validator, isRoot, targetChain, destination, originSignatures, targetExecution) {
|
|
540
|
-
//
|
|
541
|
-
// session enable data
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
729
|
+
// Non-EVM destinations have no destination-side validator, no
|
|
730
|
+
// eip712Domain(), no smart session enable data. Settlement is solver-
|
|
731
|
+
// mediated on the orchestrator side and the origin signatures alone
|
|
732
|
+
// authorize the bundle. Fall through to the "reuse last origin sig"
|
|
733
|
+
// branch instead of trying to sign on Solana / Tron.
|
|
734
|
+
if (!isNonEvmChain(targetChain)) {
|
|
735
|
+
// Smart sessions require a separate destination signature because the
|
|
736
|
+
// session enable data differs per chain
|
|
737
|
+
if (signers?.type === 'experimental_session') {
|
|
738
|
+
return await signDestinationSeparately(config, signers, validator, isRoot, targetChain, destination, targetExecution);
|
|
739
|
+
}
|
|
740
|
+
// ERC-7739 with K1 validator requires a separate destination signature because
|
|
741
|
+
// the account's eip712Domain() returns the target chain's chainId, which differs
|
|
742
|
+
// from the origin chain used for the last origin signature
|
|
743
|
+
const isK1Validator = validator.address.toLowerCase() ===
|
|
744
|
+
K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase();
|
|
745
|
+
if (isK1Validator && supportsEip712(validator)) {
|
|
746
|
+
return await signDestinationSeparately(config, signers, validator, isRoot, targetChain, destination, targetExecution);
|
|
747
|
+
}
|
|
552
748
|
}
|
|
553
749
|
const lastOriginSignature = originSignatures.at(-1);
|
|
554
750
|
return typeof lastOriginSignature === 'object'
|
|
@@ -757,7 +953,7 @@ async function submitIntentInternal(config, sourceChains, targetChain, quote, or
|
|
|
757
953
|
...(authorizations.length > 0 && {
|
|
758
954
|
authorizations: {
|
|
759
955
|
sponsor: authorizations.map((authorization) => ({
|
|
760
|
-
chainId: authorization.chainId,
|
|
956
|
+
chainId: toCaip2(authorization.chainId),
|
|
761
957
|
address: authorization.address,
|
|
762
958
|
nonce: authorization.nonce,
|
|
763
959
|
yParity: authorization.yParity ?? 0,
|
|
@@ -774,8 +970,9 @@ async function submitIntentInternal(config, sourceChains, targetChain, quote, or
|
|
|
774
970
|
return {
|
|
775
971
|
type: 'intent',
|
|
776
972
|
id: response.intentId,
|
|
973
|
+
traceId: response.traceId,
|
|
777
974
|
sourceChains: sourceChains?.map((chain) => chain.id),
|
|
778
|
-
targetChain: targetChain
|
|
975
|
+
targetChain: getChainId(targetChain),
|
|
779
976
|
};
|
|
780
977
|
}
|
|
781
978
|
async function getValidatorAccount(config, signers, publicClient, chain) {
|
|
@@ -833,6 +1030,8 @@ function getValidator(config, signers) {
|
|
|
833
1030
|
return undefined;
|
|
834
1031
|
}
|
|
835
1032
|
function parseCalls(calls, chainId) {
|
|
1033
|
+
// Destination calls only run on EVM chains (non-EVM destinations reject
|
|
1034
|
+
// calls upstream), so the resolved `to` is always a viem `Address` here.
|
|
836
1035
|
return calls.map((call) => ({
|
|
837
1036
|
data: call.data ?? '0x',
|
|
838
1037
|
value: call.value ?? 0n,
|
|
@@ -852,6 +1051,8 @@ function createAccountAccessList(sourceChains, sourceAssets) {
|
|
|
852
1051
|
const chainTokenAmounts = {};
|
|
853
1052
|
for (const config of sourceAssets) {
|
|
854
1053
|
const chainId = config.chain.id;
|
|
1054
|
+
// Source assets live on viem `Chain`s, which are always EVM, so the
|
|
1055
|
+
// resolved value is a viem `Address`.
|
|
855
1056
|
const tokenAddress = resolveTokenAddress(config.address, config.chain.id);
|
|
856
1057
|
if (config.amount !== undefined) {
|
|
857
1058
|
if (!chainTokenAmounts[chainId])
|
|
@@ -999,7 +1200,9 @@ function hashErc7739TypedDataForSolady({ domain, types, primaryType, message, ve
|
|
|
999
1200
|
deps.delete(primary);
|
|
1000
1201
|
const sorted = [primary, ...Array.from(deps).sort()];
|
|
1001
1202
|
return sorted
|
|
1002
|
-
.map((t) => `${t}(${allTypes[t]
|
|
1203
|
+
.map((t) => `${t}(${allTypes[t]
|
|
1204
|
+
.map((f) => `${f.type} ${f.name}`)
|
|
1205
|
+
.join(',')})`)
|
|
1003
1206
|
.join('');
|
|
1004
1207
|
}
|
|
1005
1208
|
const contentsType = encodeTypeString(primaryType, types);
|
|
@@ -1051,4 +1254,4 @@ function hashErc7739TypedDataForSolady({ domain, types, primaryType, message, ve
|
|
|
1051
1254
|
// Final hash: keccak256("\x19\x01" || appDomainSep || structHash)
|
|
1052
1255
|
return keccak256(concat(['0x1901', appDomainSeparator, structHash]));
|
|
1053
1256
|
}
|
|
1054
|
-
export { prepareTransaction, getTransactionMessages, signTransaction, signAuthorizations, signAuthorizationsInternal, signMessage, signTypedData, submitTransaction, prepareUserOperation, signUserOperation, submitUserOperation, signIntent, prepareTransactionAsIntent, submitIntentInternal, getValidatorAccount, parseCalls, getTokenRequests, resolveCallInputs, getIntentAccount, getTargetExecutionSignature, hashErc7739TypedDataForSolady, resolveSessionForChain, };
|
|
1257
|
+
export { prepareTransaction, getTransactionMessages, signTransaction, signAuthorizations, signAuthorizationsInternal, signMessage, signTypedData, submitTransaction, prepareUserOperation, signUserOperation, submitUserOperation, signIntent, prepareTransactionAsIntent, submitIntentInternal, getValidatorAccount, parseCalls, getTokenRequests, resolveCallInputs, getIntentAccount, getTargetExecutionSignature, hashErc7739TypedDataForSolady, resolveSessionForChain, resolveSignatureMode, };
|