@charterlabs/rhinestone-sdk 0.2.9 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/accounts/error.d.ts +8 -1
- package/dist/src/accounts/error.d.ts.map +1 -1
- package/dist/src/accounts/error.js +10 -1
- package/dist/src/accounts/index.d.ts +11 -11
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +71 -53
- package/dist/src/accounts/kernel.d.ts +3 -5
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +10 -18
- package/dist/src/accounts/kernel.test.js +10 -3
- package/dist/src/accounts/nexus.d.ts +5 -7
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +112 -59
- package/dist/src/accounts/nexus.test.js +10 -3
- package/dist/src/accounts/passport.d.ts +4 -7
- package/dist/src/accounts/passport.d.ts.map +1 -1
- package/dist/src/accounts/passport.js +0 -91
- package/dist/src/accounts/safe.d.ts +9 -4
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +110 -39
- package/dist/src/accounts/safe.test.js +10 -3
- package/dist/src/accounts/signing/common.d.ts +3 -3
- package/dist/src/accounts/signing/common.d.ts.map +1 -1
- package/dist/src/accounts/signing/common.js +36 -3
- package/dist/src/accounts/signing/message.js +2 -2
- package/dist/src/accounts/signing/typedData.d.ts.map +1 -1
- package/dist/src/accounts/signing/typedData.js +3 -3
- package/dist/src/accounts/startale.d.ts +2 -4
- package/dist/src/accounts/startale.d.ts.map +1 -1
- package/dist/src/accounts/startale.js +2 -5
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/accounts/utils.js +10 -3
- package/dist/src/accounts/walletClient.d.ts.map +1 -1
- package/dist/src/accounts/walletClient.js +6 -0
- package/dist/src/actions/compact.d.ts +3 -2
- package/dist/src/actions/compact.d.ts.map +1 -1
- package/dist/src/actions/compact.js +1 -0
- package/dist/src/actions/deployment.d.ts +19 -0
- package/dist/src/actions/deployment.d.ts.map +1 -0
- package/dist/src/actions/deployment.js +78 -0
- package/dist/src/actions/index.d.ts +4 -11
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +12 -0
- package/dist/src/actions/smart-sessions.d.ts +7 -8
- package/dist/src/actions/smart-sessions.d.ts.map +1 -1
- package/dist/src/actions/smart-sessions.js +7 -4
- package/dist/src/errors/index.d.ts +2 -2
- package/dist/src/errors/index.d.ts.map +1 -1
- package/dist/src/errors/index.js +2 -1
- package/dist/src/execution/compact.d.ts +12 -17
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +10 -16
- package/dist/src/execution/index.d.ts +6 -6
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +16 -27
- package/dist/src/execution/permit2.d.ts +12 -17
- package/dist/src/execution/permit2.d.ts.map +1 -1
- package/dist/src/execution/permit2.js +10 -16
- package/dist/src/execution/singleChainOps.d.ts +15 -3
- package/dist/src/execution/singleChainOps.d.ts.map +1 -1
- package/dist/src/execution/singleChainOps.js +17 -3
- package/dist/src/execution/utils.d.ts +32 -10
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +121 -108
- package/dist/src/index.d.ts +23 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +36 -6
- package/dist/src/modules/abi/smart-session-emissary.d.ts +696 -0
- package/dist/src/modules/abi/smart-session-emissary.d.ts.map +1 -0
- package/dist/src/modules/abi/smart-session-emissary.js +565 -0
- package/dist/src/modules/chain-abstraction.d.ts +5 -0
- package/dist/src/modules/chain-abstraction.d.ts.map +1 -0
- package/dist/src/modules/chain-abstraction.js +7 -0
- package/dist/src/modules/common.d.ts +10 -2
- package/dist/src/modules/common.d.ts.map +1 -1
- package/dist/src/modules/common.js +10 -0
- package/dist/src/modules/index.d.ts +3 -9
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +24 -8
- package/dist/src/modules/index.test.js +3 -9
- package/dist/src/modules/legacy.d.ts +10 -0
- package/dist/src/modules/legacy.d.ts.map +1 -0
- package/dist/src/modules/legacy.js +65 -0
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +2 -0
- package/dist/src/modules/validators/index.d.ts +2 -2
- package/dist/src/modules/validators/index.d.ts.map +1 -1
- package/dist/src/modules/validators/index.js +1 -6
- package/dist/src/modules/validators/smart-sessions.d.ts +105 -20
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions.js +199 -435
- package/dist/src/orchestrator/client.d.ts +7 -3
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +3 -13
- package/dist/src/orchestrator/index.d.ts +2 -2
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +2 -1
- 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 +28 -8
- package/dist/src/orchestrator/registry.test.js +13 -0
- package/dist/src/orchestrator/types.d.ts +11 -12
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/orchestrator/types.js +1 -7
- package/dist/src/types.d.ts +47 -25
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/index.d.ts +24 -1
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/index.js +58 -0
- package/dist/test/utils/utils.d.ts +5 -0
- package/dist/test/utils/utils.d.ts.map +1 -0
- package/dist/test/utils/utils.js +20 -0
- package/package.json +33 -3
- package/dist/src/execution/smart-session.d.ts +0 -13
- package/dist/src/execution/smart-session.d.ts.map +0 -1
- package/dist/src/execution/smart-session.js +0 -178
- package/dist/src/modules/omni-account.d.ts +0 -8
- package/dist/src/modules/omni-account.d.ts.map +0 -1
- package/dist/src/modules/omni-account.js +0 -13
- 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 -222
|
@@ -47,17 +47,20 @@ function getTypedData(element, nonce, expires) {
|
|
|
47
47
|
{ name: 'targetChain', type: 'uint256' },
|
|
48
48
|
{ name: 'fillExpiry', type: 'uint256' },
|
|
49
49
|
],
|
|
50
|
-
|
|
50
|
+
Ops: [
|
|
51
51
|
{ name: 'to', type: 'address' },
|
|
52
52
|
{ name: 'value', type: 'uint256' },
|
|
53
53
|
{ name: 'data', type: 'bytes' },
|
|
54
54
|
],
|
|
55
|
+
Op: [
|
|
56
|
+
{ name: 'vt', type: 'bytes32' },
|
|
57
|
+
{ name: 'ops', type: 'Ops[]' },
|
|
58
|
+
],
|
|
55
59
|
Mandate: [
|
|
56
60
|
{ name: 'target', type: 'Target' },
|
|
57
|
-
{ name: 'v', type: 'uint8' },
|
|
58
61
|
{ name: 'minGas', type: 'uint128' },
|
|
59
|
-
{ name: 'originOps', type: 'Op
|
|
60
|
-
{ name: 'destOps', type: 'Op
|
|
62
|
+
{ name: 'originOps', type: 'Op' },
|
|
63
|
+
{ name: 'destOps', type: 'Op' },
|
|
61
64
|
{ name: 'q', type: 'bytes32' },
|
|
62
65
|
],
|
|
63
66
|
PermitBatchWitnessTransferFrom: [
|
|
@@ -84,18 +87,9 @@ function getTypedData(element, nonce, expires) {
|
|
|
84
87
|
targetChain: BigInt(mandate.destinationChainId),
|
|
85
88
|
fillExpiry: BigInt(mandate.fillDeadline),
|
|
86
89
|
},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
to: op.to,
|
|
91
|
-
value: BigInt(op.value),
|
|
92
|
-
data: op.data,
|
|
93
|
-
})),
|
|
94
|
-
destOps: mandate.destinationOps.map((op) => ({
|
|
95
|
-
to: op.to,
|
|
96
|
-
value: BigInt(op.value),
|
|
97
|
-
data: op.data,
|
|
98
|
-
})),
|
|
90
|
+
minGas: BigInt(mandate.minGas),
|
|
91
|
+
originOps: mandate.preClaimOps,
|
|
92
|
+
destOps: mandate.destinationOps,
|
|
99
93
|
q: (0, viem_1.keccak256)(mandate.qualifier.encodedVal),
|
|
100
94
|
},
|
|
101
95
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type {
|
|
1
|
+
import { type Address } from 'viem';
|
|
2
|
+
import type { IntentOpElement } from '../orchestrator/types';
|
|
3
3
|
declare function getTypedData(account: Address, intentExecutorAddress: Address, element: IntentOpElement, nonce: bigint): {
|
|
4
4
|
domain: {
|
|
5
5
|
name: string;
|
|
@@ -16,12 +16,24 @@ declare function getTypedData(account: Address, intentExecutorAddress: Address,
|
|
|
16
16
|
name: string;
|
|
17
17
|
type: string;
|
|
18
18
|
}[];
|
|
19
|
+
GasRefund: {
|
|
20
|
+
name: string;
|
|
21
|
+
type: string;
|
|
22
|
+
}[];
|
|
23
|
+
Ops: {
|
|
24
|
+
name: string;
|
|
25
|
+
type: string;
|
|
26
|
+
}[];
|
|
19
27
|
};
|
|
20
28
|
primaryType: "SingleChainOps";
|
|
21
29
|
message: {
|
|
22
30
|
account: `0x${string}`;
|
|
23
31
|
nonce: bigint;
|
|
24
|
-
|
|
32
|
+
op: import("../orchestrator/types").Op;
|
|
33
|
+
gasRefund: {
|
|
34
|
+
token: "0x0000000000000000000000000000000000000000";
|
|
35
|
+
exchangeRate: bigint;
|
|
36
|
+
};
|
|
25
37
|
};
|
|
26
38
|
};
|
|
27
39
|
export { getTypedData };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"singleChainOps.d.ts","sourceRoot":"","sources":["../../../execution/singleChainOps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"singleChainOps.d.ts","sourceRoot":"","sources":["../../../execution/singleChainOps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAe,MAAM,MAAM,CAAA;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5D,iBAAS,YAAY,CACnB,OAAO,EAAE,OAAO,EAChB,qBAAqB,EAAE,OAAO,EAC9B,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0Cd;AACD,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTypedData = getTypedData;
|
|
4
|
+
const viem_1 = require("viem");
|
|
4
5
|
function getTypedData(account, intentExecutorAddress, element, nonce) {
|
|
5
|
-
const ops = element.mandate.destinationOps;
|
|
6
6
|
return {
|
|
7
7
|
domain: {
|
|
8
8
|
name: 'IntentExecutor',
|
|
@@ -14,9 +14,18 @@ function getTypedData(account, intentExecutorAddress, element, nonce) {
|
|
|
14
14
|
SingleChainOps: [
|
|
15
15
|
{ name: 'account', type: 'address' },
|
|
16
16
|
{ name: 'nonce', type: 'uint256' },
|
|
17
|
-
{ name: '
|
|
17
|
+
{ name: 'op', type: 'Op' },
|
|
18
|
+
{ name: 'gasRefund', type: 'GasRefund' },
|
|
18
19
|
],
|
|
19
20
|
Op: [
|
|
21
|
+
{ name: 'vt', type: 'bytes32' },
|
|
22
|
+
{ name: 'ops', type: 'Ops[]' },
|
|
23
|
+
],
|
|
24
|
+
GasRefund: [
|
|
25
|
+
{ name: 'token', type: 'address' },
|
|
26
|
+
{ name: 'exchangeRate', type: 'uint256' },
|
|
27
|
+
],
|
|
28
|
+
Ops: [
|
|
20
29
|
{ name: 'to', type: 'address' },
|
|
21
30
|
{ name: 'value', type: 'uint256' },
|
|
22
31
|
{ name: 'data', type: 'bytes' },
|
|
@@ -26,7 +35,12 @@ function getTypedData(account, intentExecutorAddress, element, nonce) {
|
|
|
26
35
|
message: {
|
|
27
36
|
account,
|
|
28
37
|
nonce,
|
|
29
|
-
|
|
38
|
+
op: element.mandate.destinationOps,
|
|
39
|
+
// todo
|
|
40
|
+
gasRefund: {
|
|
41
|
+
token: viem_1.zeroAddress,
|
|
42
|
+
exchangeRate: 0n,
|
|
43
|
+
},
|
|
30
44
|
},
|
|
31
45
|
};
|
|
32
46
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type Address, type Chain, type HashTypedDataParameters, type Hex, type PublicClient, type SignableMessage, type SignedAuthorization, type SignedAuthorizationList, type TypedData } from 'viem';
|
|
1
|
+
import { type Address, type Chain, type HashTypedDataParameters, type Hex, type PublicClient, type SignableMessage, type SignedAuthorization, type SignedAuthorizationList, type TypedData, type TypedDataDefinition } from 'viem';
|
|
2
2
|
import { type UserOperation } from 'viem/account-abstraction';
|
|
3
3
|
import { type IntentOp, type IntentRoute } from '../orchestrator';
|
|
4
|
-
import
|
|
5
|
-
import type { Call, CalldataInput, CallInput, RhinestoneConfig, SignerSet, SourceAssetInput, TokenRequest, TokenSymbol, Transaction, UserOperationTransaction } from '../types';
|
|
4
|
+
import type { SettlementLayer } from '../orchestrator/types';
|
|
5
|
+
import type { Call, CalldataInput, CallInput, RhinestoneAccountConfig, RhinestoneConfig, SignerSet, SourceAssetInput, Sponsorship, TokenRequest, TokenSymbol, Transaction, UserOperationTransaction } from '../types';
|
|
6
6
|
interface UserOperationResult {
|
|
7
7
|
type: 'userop';
|
|
8
8
|
hash: Hex;
|
|
@@ -32,7 +32,11 @@ interface SignedUserOperationData extends PreparedUserOperationData {
|
|
|
32
32
|
}
|
|
33
33
|
declare function prepareTransaction(config: RhinestoneConfig, transaction: Transaction): Promise<PreparedTransactionData>;
|
|
34
34
|
declare function prepareUserOperation(config: RhinestoneConfig, transaction: UserOperationTransaction): Promise<PreparedUserOperationData>;
|
|
35
|
-
declare function resolveCallInputs(inputs: CallInput[], config: RhinestoneConfig, chain: Chain, accountAddress: Address): Promise<CalldataInput[]>;
|
|
35
|
+
declare function resolveCallInputs(inputs: CallInput[] | undefined, config: RhinestoneConfig, chain: Chain, accountAddress: Address): Promise<CalldataInput[]>;
|
|
36
|
+
declare function getTransactionMessages(config: RhinestoneConfig, preparedTransaction: PreparedTransactionData): {
|
|
37
|
+
origin: TypedDataDefinition[];
|
|
38
|
+
destination: TypedDataDefinition;
|
|
39
|
+
};
|
|
36
40
|
declare function signTransaction(config: RhinestoneConfig, preparedTransaction: PreparedTransactionData): Promise<SignedTransactionData>;
|
|
37
41
|
declare function signUserOperation(config: RhinestoneConfig, preparedUserOperation: PreparedUserOperationData): Promise<SignedUserOperationData>;
|
|
38
42
|
declare function signAuthorizations(config: RhinestoneConfig, preparedTransaction: PreparedTransactionData): Promise<SignedAuthorization[]>;
|
|
@@ -41,21 +45,39 @@ declare function signTypedData<typedData extends TypedData | Record<string, unkn
|
|
|
41
45
|
declare function signAuthorizationsInternal(config: RhinestoneConfig, data: IntentRoute | UserOperation): Promise<SignedAuthorization[]>;
|
|
42
46
|
declare function submitTransaction(config: RhinestoneConfig, signedTransaction: SignedTransactionData, authorizations: SignedAuthorizationList, dryRun?: boolean): Promise<TransactionResult>;
|
|
43
47
|
declare function submitUserOperation(config: RhinestoneConfig, signedUserOperation: SignedUserOperationData): Promise<UserOperationResult>;
|
|
44
|
-
declare function getTokenRequests(sourceChains: Chain[], targetChain: Chain, initialTokenRequests: TokenRequest[] | undefined, settlementLayers: SettlementLayer[] | undefined): TokenRequest[];
|
|
45
|
-
declare function
|
|
48
|
+
declare function getTokenRequests(sourceChains: Chain[] | undefined, targetChain: Chain, initialTokenRequests: TokenRequest[] | undefined, settlementLayers: SettlementLayer[] | undefined): TokenRequest[];
|
|
49
|
+
declare function getIntentAccount(config: RhinestoneConfig, eip7702InitSignature: Hex | undefined, account: {
|
|
46
50
|
setupOps?: {
|
|
47
51
|
to: Address;
|
|
48
52
|
data: Hex;
|
|
49
53
|
}[];
|
|
50
|
-
}):
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
} | undefined): {
|
|
55
|
+
address: `0x${string}`;
|
|
56
|
+
accountType: "ERC7579" | "EOA";
|
|
57
|
+
setupOps: {
|
|
58
|
+
to: Address;
|
|
59
|
+
data: Hex;
|
|
60
|
+
}[];
|
|
61
|
+
delegations: {
|
|
62
|
+
0: {
|
|
63
|
+
contract: `0x${string}`;
|
|
64
|
+
};
|
|
65
|
+
} | undefined;
|
|
66
|
+
};
|
|
67
|
+
declare function prepareTransactionAsIntent(config: RhinestoneConfig, sourceChains: Chain[] | undefined, targetChain: Chain, callInputs: CalldataInput[], gasLimit: bigint | undefined, tokenRequests: TokenRequest[], recipientInput: RhinestoneAccountConfig | Address | undefined, sponsored: Sponsorship | undefined, eip7702InitSignature: Hex | undefined, settlementLayers: SettlementLayer[] | undefined, sourceAssets: SourceAssetInput | undefined, feeAsset: Address | TokenSymbol | undefined, lockFunds: boolean | undefined, account: {
|
|
68
|
+
setupOps?: {
|
|
69
|
+
to: Address;
|
|
70
|
+
data: Hex;
|
|
71
|
+
}[];
|
|
72
|
+
} | undefined): Promise<IntentRoute>;
|
|
73
|
+
declare function signIntent(config: RhinestoneConfig, intentOp: IntentOp, signers?: SignerSet): Promise<{
|
|
74
|
+
originSignatures: `0x${string}`[];
|
|
53
75
|
destinationSignature: `0x${string}`;
|
|
54
76
|
}>;
|
|
55
77
|
declare function getOrchestratorByChain(chainId: number, apiKey: string | undefined, orchestratorUrl?: string): import("../orchestrator").Orchestrator;
|
|
56
78
|
declare function submitIntentInternal(config: RhinestoneConfig, sourceChains: Chain[] | undefined, targetChain: Chain, intentOp: IntentOp, originSignatures: Hex[], destinationSignature: Hex, authorizations: SignedAuthorizationList, dryRun: boolean): Promise<TransactionResult>;
|
|
57
79
|
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>;
|
|
58
80
|
declare function parseCalls(calls: CalldataInput[], chainId: number): Call[];
|
|
59
|
-
export { prepareTransaction, signTransaction, signAuthorizations, signAuthorizationsInternal, signMessage, signTypedData, submitTransaction, prepareUserOperation, signUserOperation, submitUserOperation, getOrchestratorByChain, signIntent, prepareTransactionAsIntent, submitIntentInternal, getValidatorAccount, parseCalls, getTokenRequests, resolveCallInputs, };
|
|
81
|
+
export { prepareTransaction, getTransactionMessages, signTransaction, signAuthorizations, signAuthorizationsInternal, signMessage, signTypedData, submitTransaction, prepareUserOperation, signUserOperation, submitUserOperation, getOrchestratorByChain, signIntent, prepareTransactionAsIntent, submitIntentInternal, getValidatorAccount, parseCalls, getTokenRequests, resolveCallInputs, getIntentAccount, };
|
|
60
82
|
export type { IntentRoute, TransactionResult, PreparedTransactionData, PreparedUserOperationData, SignedTransactionData, SignedUserOperationData, UserOperationResult, };
|
|
61
83
|
//# 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,EAKV,KAAK,uBAAuB,EAC5B,KAAK,GAAG,EAIR,KAAK,YAAY,EAEjB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../execution/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAKV,KAAK,uBAAuB,EAC5B,KAAK,GAAG,EAIR,KAAK,YAAY,EAEjB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,SAAS,EACd,KAAK,mBAAmB,EAIzB,MAAM,MAAM,CAAA;AACb,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAA;AAmCjC,OAAO,EAGL,KA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-1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.prepareTransaction = prepareTransaction;
|
|
4
|
+
exports.getTransactionMessages = getTransactionMessages;
|
|
4
5
|
exports.signTransaction = signTransaction;
|
|
5
6
|
exports.signAuthorizations = signAuthorizations;
|
|
6
7
|
exports.signAuthorizationsInternal = signAuthorizationsInternal;
|
|
@@ -18,6 +19,7 @@ exports.getValidatorAccount = getValidatorAccount;
|
|
|
18
19
|
exports.parseCalls = parseCalls;
|
|
19
20
|
exports.getTokenRequests = getTokenRequests;
|
|
20
21
|
exports.resolveCallInputs = resolveCallInputs;
|
|
22
|
+
exports.getIntentAccount = getIntentAccount;
|
|
21
23
|
const viem_1 = require("viem");
|
|
22
24
|
const account_abstraction_1 = require("viem/account-abstraction");
|
|
23
25
|
const erc7739_1 = require("viem/experimental/erc7739");
|
|
@@ -29,7 +31,6 @@ const core_1 = require("../modules/validators/core");
|
|
|
29
31
|
const orchestrator_1 = require("../orchestrator");
|
|
30
32
|
const consts_1 = require("../orchestrator/consts");
|
|
31
33
|
const registry_1 = require("../orchestrator/registry");
|
|
32
|
-
const types_1 = require("../orchestrator/types");
|
|
33
34
|
const compact_1 = require("./compact");
|
|
34
35
|
const error_1 = require("./error");
|
|
35
36
|
const permit2_1 = require("./permit2");
|
|
@@ -37,11 +38,11 @@ const singleChainOps_1 = require("./singleChainOps");
|
|
|
37
38
|
async function prepareTransaction(config, transaction) {
|
|
38
39
|
const { sourceChains, targetChain, tokenRequests, signers, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, account, recipient, } = getTransactionParams(transaction);
|
|
39
40
|
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
40
|
-
const isUserOpSigner = signers?.type === 'guardians'
|
|
41
|
+
const isUserOpSigner = signers?.type === 'guardians';
|
|
41
42
|
if (isUserOpSigner) {
|
|
42
43
|
throw new error_1.SignerNotSupportedError();
|
|
43
44
|
}
|
|
44
|
-
const intentRoute = await prepareTransactionAsIntent(config, sourceChains, targetChain, await resolveCallInputs(transaction.calls, config, targetChain, accountAddress), transaction.gasLimit, tokenRequests, recipient,
|
|
45
|
+
const intentRoute = await prepareTransactionAsIntent(config, sourceChains, targetChain, await resolveCallInputs(transaction.calls, config, targetChain, accountAddress), transaction.gasLimit, tokenRequests, recipient, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, account);
|
|
45
46
|
return {
|
|
46
47
|
intentRoute,
|
|
47
48
|
transaction,
|
|
@@ -60,6 +61,9 @@ async function prepareUserOperation(config, transaction) {
|
|
|
60
61
|
}
|
|
61
62
|
async function resolveCallInputs(inputs, config, chain, accountAddress) {
|
|
62
63
|
const resolved = [];
|
|
64
|
+
if (!inputs) {
|
|
65
|
+
return resolved;
|
|
66
|
+
}
|
|
63
67
|
for (const intent of inputs) {
|
|
64
68
|
if ('resolve' in intent) {
|
|
65
69
|
const result = await intent.resolve({ config, chain, accountAddress });
|
|
@@ -76,10 +80,13 @@ async function resolveCallInputs(inputs, config, chain, accountAddress) {
|
|
|
76
80
|
}
|
|
77
81
|
return resolved;
|
|
78
82
|
}
|
|
83
|
+
function getTransactionMessages(config, preparedTransaction) {
|
|
84
|
+
return getIntentMessages(config, preparedTransaction.intentRoute.intentOp);
|
|
85
|
+
}
|
|
79
86
|
async function signTransaction(config, preparedTransaction) {
|
|
80
|
-
const {
|
|
87
|
+
const { signers } = getTransactionParams(preparedTransaction.transaction);
|
|
81
88
|
const intentRoute = preparedTransaction.intentRoute;
|
|
82
|
-
const { originSignatures, destinationSignature } = await signIntent(config,
|
|
89
|
+
const { originSignatures, destinationSignature } = await signIntent(config, intentRoute.intentOp, signers);
|
|
83
90
|
return {
|
|
84
91
|
intentRoute,
|
|
85
92
|
transaction: preparedTransaction.transaction,
|
|
@@ -124,7 +131,7 @@ async function signTypedData(config, parameters, chain, signers) {
|
|
|
124
131
|
}
|
|
125
132
|
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
126
133
|
const isRoot = validator.address === ownerValidator.address;
|
|
127
|
-
if (signers?.type === '
|
|
134
|
+
if (signers?.type === 'experimental_session') {
|
|
128
135
|
return await signTypedDataWithSession(config, chain, {
|
|
129
136
|
address: validator.address,
|
|
130
137
|
isRoot,
|
|
@@ -262,7 +269,9 @@ function getTokenRequests(sourceChains, targetChain, initialTokenRequests, settl
|
|
|
262
269
|
amount: 1n,
|
|
263
270
|
};
|
|
264
271
|
const isSameChain = (settlementLayers?.length === 1 && settlementLayers[0] === 'SAME_CHAIN') ||
|
|
265
|
-
(sourceChains
|
|
272
|
+
(sourceChains &&
|
|
273
|
+
sourceChains.length === 1 &&
|
|
274
|
+
sourceChains[0].id === targetChain.id);
|
|
266
275
|
const tokenRequests = !initialTokenRequests || initialTokenRequests.length === 0
|
|
267
276
|
? isSameChain
|
|
268
277
|
? []
|
|
@@ -296,19 +305,45 @@ async function prepareTransactionAsUserOp(config, chain, callInputs, signers, ga
|
|
|
296
305
|
}),
|
|
297
306
|
};
|
|
298
307
|
}
|
|
299
|
-
|
|
308
|
+
function getAccountType(accountConfig) {
|
|
309
|
+
if (accountConfig?.type === 'eoa') {
|
|
310
|
+
return 'EOA';
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
return 'ERC7579';
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
function getIntentAccount(config, eip7702InitSignature, account) {
|
|
317
|
+
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
318
|
+
const accountType = getAccountType(config.account);
|
|
319
|
+
const { setupOps, delegations } = getSetupOperationsAndDelegations(config, accountAddress, eip7702InitSignature);
|
|
320
|
+
return {
|
|
321
|
+
address: accountAddress,
|
|
322
|
+
accountType: accountType,
|
|
323
|
+
setupOps: account?.setupOps ?? setupOps,
|
|
324
|
+
delegations,
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
async function prepareTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, recipientInput, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, account) {
|
|
300
328
|
const calls = parseCalls(callInputs, targetChain.id);
|
|
301
329
|
const accountAccessList = createAccountAccessList(sourceChains, sourceAssets);
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
return
|
|
330
|
+
function getRecipient(recipient) {
|
|
331
|
+
if (typeof recipient === 'string') {
|
|
332
|
+
// Passed as an address, assume it's an EOA
|
|
333
|
+
return {
|
|
334
|
+
address: recipient,
|
|
335
|
+
accountType: 'EOA',
|
|
336
|
+
setupOps: [],
|
|
337
|
+
delegations: undefined,
|
|
338
|
+
};
|
|
306
339
|
}
|
|
307
|
-
|
|
308
|
-
return
|
|
340
|
+
if (!recipient) {
|
|
341
|
+
return undefined;
|
|
309
342
|
}
|
|
310
|
-
|
|
311
|
-
|
|
343
|
+
return getIntentAccount(recipient, eip7702InitSignature, account);
|
|
344
|
+
}
|
|
345
|
+
const intentAccount = getIntentAccount(config, eip7702InitSignature, account);
|
|
346
|
+
const recipient = getRecipient(recipientInput);
|
|
312
347
|
const metaIntent = {
|
|
313
348
|
destinationChainId: targetChain.id,
|
|
314
349
|
tokenRequests: tokenRequests.map((tokenRequest) => ({
|
|
@@ -316,27 +351,26 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
316
351
|
amount: tokenRequest.amount,
|
|
317
352
|
})),
|
|
318
353
|
recipient,
|
|
319
|
-
account:
|
|
320
|
-
|
|
321
|
-
accountType: accountType,
|
|
322
|
-
setupOps: account?.setupOps ?? setupOps,
|
|
323
|
-
delegations,
|
|
324
|
-
},
|
|
325
|
-
destinationExecutions: calls.map((call) => ({
|
|
326
|
-
to: call.to,
|
|
327
|
-
value: call.value.toString(),
|
|
328
|
-
data: call.data,
|
|
329
|
-
})),
|
|
354
|
+
account: intentAccount,
|
|
355
|
+
destinationExecutions: calls,
|
|
330
356
|
destinationGasUnits: gasLimit,
|
|
331
357
|
accountAccessList,
|
|
332
358
|
options: {
|
|
333
359
|
topupCompact: lockFunds ?? false,
|
|
334
360
|
feeToken: feeAsset,
|
|
335
|
-
sponsorSettings:
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
361
|
+
sponsorSettings: sponsored
|
|
362
|
+
? typeof sponsored === 'object'
|
|
363
|
+
? {
|
|
364
|
+
gasSponsored: sponsored.gas,
|
|
365
|
+
bridgeFeesSponsored: sponsored.bridging,
|
|
366
|
+
swapFeesSponsored: sponsored.swaps,
|
|
367
|
+
}
|
|
368
|
+
: {
|
|
369
|
+
gasSponsored: sponsored,
|
|
370
|
+
bridgeFeesSponsored: sponsored,
|
|
371
|
+
swapFeesSponsored: sponsored,
|
|
372
|
+
}
|
|
373
|
+
: undefined,
|
|
340
374
|
settlementLayers,
|
|
341
375
|
},
|
|
342
376
|
};
|
|
@@ -344,27 +378,21 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
344
378
|
const intentRoute = await orchestrator.getIntentRoute(metaIntent);
|
|
345
379
|
return intentRoute;
|
|
346
380
|
}
|
|
347
|
-
async function signIntent(config,
|
|
381
|
+
async function signIntent(config, intentOp, signers) {
|
|
382
|
+
const { origin } = getIntentMessages(config, intentOp);
|
|
348
383
|
if (config.account?.type === 'eoa') {
|
|
384
|
+
const eoa = config.eoa;
|
|
385
|
+
if (!eoa) {
|
|
386
|
+
throw new accounts_1.EoaAccountMustHaveAccountError();
|
|
387
|
+
}
|
|
349
388
|
const originSignatures = [];
|
|
350
|
-
for (const
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
originSignatures.push(await config.eoa.signTypedData(typedData));
|
|
355
|
-
}
|
|
356
|
-
else if (config.eoa?.sign) {
|
|
357
|
-
digest = (0, compact_1.getPermit2Digest)(element, BigInt(intentOp.nonce), BigInt(intentOp.expires));
|
|
358
|
-
originSignatures.push(await config.eoa.sign({ hash: digest }));
|
|
359
|
-
}
|
|
360
|
-
else if (config.eoa?.signMessage) {
|
|
361
|
-
digest = (0, compact_1.getPermit2Digest)(element, BigInt(intentOp.nonce), BigInt(intentOp.expires));
|
|
362
|
-
originSignatures.push(await config.eoa.signMessage({
|
|
363
|
-
message: { raw: digest },
|
|
364
|
-
}));
|
|
389
|
+
for (const typedData of origin) {
|
|
390
|
+
if (eoa.signTypedData) {
|
|
391
|
+
const signature = await eoa.signTypedData(typedData);
|
|
392
|
+
originSignatures.push(signature);
|
|
365
393
|
}
|
|
366
394
|
else {
|
|
367
|
-
throw new accounts_1.EoaSigningMethodNotConfiguredError('signTypedData
|
|
395
|
+
throw new accounts_1.EoaSigningMethodNotConfiguredError('signTypedData');
|
|
368
396
|
}
|
|
369
397
|
}
|
|
370
398
|
const destinationSignature = originSignatures.at(-1);
|
|
@@ -379,37 +407,10 @@ async function signIntent(config, targetChain, intentOp, signers) {
|
|
|
379
407
|
}
|
|
380
408
|
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
381
409
|
const isRoot = validator.address === ownerValidator.address;
|
|
382
|
-
const signatures = await getIntentSignature(config, intentOp, signers, targetChain, validator, isRoot);
|
|
383
|
-
return {
|
|
384
|
-
originSignatures: signatures.originSignatures,
|
|
385
|
-
destinationSignature: signatures.destinationSignature,
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
async function getIntentSignature(config, intentOp, signers, targetChain, validator, isRoot) {
|
|
389
|
-
const withPermit2 = intentOp.elements.some((element) => element.mandate.qualifier.settlementContext?.fundingMethod ===
|
|
390
|
-
types_1.FundingMethod.PERMIT2);
|
|
391
|
-
const withIntentExecutorOps = intentOp.elements.some((element) => element.mandate.qualifier.settlementContext.settlementLayer ===
|
|
392
|
-
'INTENT_EXECUTOR');
|
|
393
|
-
if (withIntentExecutorOps) {
|
|
394
|
-
const signature = await getSingleChainOpsSignature(config, intentOp, signers, targetChain, validator, isRoot);
|
|
395
|
-
return signature;
|
|
396
|
-
}
|
|
397
|
-
if (withPermit2) {
|
|
398
|
-
return await getPermit2Signatures(config, intentOp, signers, targetChain, validator, isRoot);
|
|
399
|
-
}
|
|
400
|
-
const signature = await getCompactSignature(config, intentOp, signers, targetChain, validator, isRoot);
|
|
401
|
-
return {
|
|
402
|
-
originSignatures: Array(intentOp.elements.length).fill(signature),
|
|
403
|
-
destinationSignature: signature,
|
|
404
|
-
};
|
|
405
|
-
}
|
|
406
|
-
async function getSingleChainOpsSignature(config, intentOp, signers, targetChain, validator, isRoot) {
|
|
407
|
-
const address = (0, accounts_1.getAddress)(config);
|
|
408
|
-
const intentExecutor = (0, modules_1.getIntentExecutor)(config);
|
|
409
410
|
const originSignatures = [];
|
|
410
|
-
for (const
|
|
411
|
-
const
|
|
412
|
-
const signature = await signIntentTypedData(config, signers,
|
|
411
|
+
for (const typedData of origin) {
|
|
412
|
+
const chain = (0, registry_1.getChainById)(typedData.domain?.chainId);
|
|
413
|
+
const signature = await signIntentTypedData(config, signers, validator, isRoot, typedData, chain);
|
|
413
414
|
originSignatures.push(signature);
|
|
414
415
|
}
|
|
415
416
|
const destinationSignature = originSignatures.at(-1);
|
|
@@ -418,32 +419,42 @@ async function getSingleChainOpsSignature(config, intentOp, signers, targetChain
|
|
|
418
419
|
destinationSignature,
|
|
419
420
|
};
|
|
420
421
|
}
|
|
421
|
-
|
|
422
|
-
const
|
|
422
|
+
function getIntentMessages(config, intentOp) {
|
|
423
|
+
const address = (0, accounts_1.getAddress)(config);
|
|
424
|
+
const intentExecutor = (0, modules_1.getIntentExecutor)(config);
|
|
425
|
+
const withPermit2 = intentOp.elements.some((element) => element.mandate.qualifier.settlementContext.fundingMethod === 'PERMIT2');
|
|
426
|
+
const withIntentExecutorOps = intentOp.elements.some((element) => element.mandate.qualifier.settlementContext.settlementLayer ===
|
|
427
|
+
'INTENT_EXECUTOR');
|
|
428
|
+
const origin = [];
|
|
423
429
|
for (const element of intentOp.elements) {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
430
|
+
if (withIntentExecutorOps) {
|
|
431
|
+
const typedData = (0, singleChainOps_1.getTypedData)(address, intentExecutor.address, element, BigInt(intentOp.nonce));
|
|
432
|
+
origin.push(typedData);
|
|
433
|
+
}
|
|
434
|
+
else if (withPermit2) {
|
|
435
|
+
const typedData = (0, permit2_1.getTypedData)(element, BigInt(intentOp.nonce), BigInt(intentOp.expires));
|
|
436
|
+
origin.push(typedData);
|
|
437
|
+
}
|
|
438
|
+
else {
|
|
439
|
+
const typedData = (0, compact_1.getCompactTypedData)(intentOp);
|
|
440
|
+
origin.push(typedData);
|
|
441
|
+
}
|
|
427
442
|
}
|
|
428
|
-
const
|
|
443
|
+
const destination = origin.at(-1);
|
|
429
444
|
return {
|
|
430
|
-
|
|
431
|
-
|
|
445
|
+
origin,
|
|
446
|
+
destination,
|
|
432
447
|
};
|
|
433
448
|
}
|
|
434
|
-
async function
|
|
435
|
-
const typedData = (0, compact_1.getCompactTypedData)(intentOp);
|
|
436
|
-
return await signIntentTypedData(config, signers, targetChain, validator, isRoot, typedData);
|
|
437
|
-
}
|
|
438
|
-
async function signIntentTypedData(config, signers, targetChain, validator, isRoot, parameters) {
|
|
449
|
+
async function signIntentTypedData(config, signers, validator, isRoot, parameters, chain) {
|
|
439
450
|
if ((0, core_1.supportsEip712)(validator)) {
|
|
440
|
-
return await (0, accounts_1.getTypedDataPackedSignature)(config, signers,
|
|
451
|
+
return await (0, accounts_1.getTypedDataPackedSignature)(config, signers, chain, {
|
|
441
452
|
address: validator.address,
|
|
442
453
|
isRoot,
|
|
443
454
|
}, parameters);
|
|
444
455
|
}
|
|
445
456
|
const hash = (0, viem_1.hashTypedData)(parameters);
|
|
446
|
-
return await (0, accounts_1.getPackedSignature)(config, signers,
|
|
457
|
+
return await (0, accounts_1.getPackedSignature)(config, signers, chain, {
|
|
447
458
|
address: validator.address,
|
|
448
459
|
isRoot,
|
|
449
460
|
}, hash);
|
|
@@ -551,16 +562,13 @@ async function getValidatorAccount(config, signers, publicClient, chain) {
|
|
|
551
562
|
if (withOwner) {
|
|
552
563
|
return (0, accounts_1.getSmartAccount)(config, publicClient, chain);
|
|
553
564
|
}
|
|
554
|
-
const withSession = signers.type === 'session' ? signers : null;
|
|
555
565
|
const withGuardians = signers.type === 'guardians' ? signers : null;
|
|
556
|
-
return
|
|
557
|
-
? await (0, accounts_1.
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
})
|
|
563
|
-
: null;
|
|
566
|
+
return withGuardians
|
|
567
|
+
? await (0, accounts_1.getGuardianSmartAccount)(config, publicClient, chain, {
|
|
568
|
+
type: 'ecdsa',
|
|
569
|
+
accounts: withGuardians.guardians,
|
|
570
|
+
})
|
|
571
|
+
: null;
|
|
564
572
|
}
|
|
565
573
|
function getValidator(config, signers) {
|
|
566
574
|
if (!signers) {
|
|
@@ -587,7 +595,7 @@ function getValidator(config, signers) {
|
|
|
587
595
|
}
|
|
588
596
|
}
|
|
589
597
|
// Smart sessions
|
|
590
|
-
const withSession = signers.type === '
|
|
598
|
+
const withSession = signers.type === 'experimental_session' ? signers.session : null;
|
|
591
599
|
if (withSession) {
|
|
592
600
|
return (0, validators_1.getSmartSessionValidator)(config);
|
|
593
601
|
}
|
|
@@ -620,7 +628,7 @@ function createAccountAccessList(sourceChains, sourceAssets) {
|
|
|
620
628
|
}
|
|
621
629
|
return { chainTokens: sourceAssets };
|
|
622
630
|
}
|
|
623
|
-
|
|
631
|
+
function getSetupOperationsAndDelegations(config, accountAddress, eip7702InitSignature) {
|
|
624
632
|
const initCode = (0, accounts_1.getInitCode)(config);
|
|
625
633
|
if (config.account?.type === 'eoa') {
|
|
626
634
|
return {
|
|
@@ -632,7 +640,7 @@ async function getSetupOperationsAndDelegations(config, accountAddress, eip7702I
|
|
|
632
640
|
if (!eip7702InitSignature || eip7702InitSignature === '0x') {
|
|
633
641
|
throw new Error('EIP-7702 initialization signature is required for EOA accounts');
|
|
634
642
|
}
|
|
635
|
-
const { initData: eip7702InitData, contract: eip7702Contract } =
|
|
643
|
+
const { initData: eip7702InitData, contract: eip7702Contract } = (0, accounts_1.getEip7702InitCall)(config, eip7702InitSignature);
|
|
636
644
|
return {
|
|
637
645
|
setupOps: [
|
|
638
646
|
{
|
|
@@ -648,12 +656,17 @@ async function getSetupOperationsAndDelegations(config, accountAddress, eip7702I
|
|
|
648
656
|
};
|
|
649
657
|
}
|
|
650
658
|
else if (initCode) {
|
|
659
|
+
const to = 'factory' in initCode ? initCode.factory : undefined;
|
|
660
|
+
const data = 'factory' in initCode ? initCode.factoryData : undefined;
|
|
661
|
+
if (!to || !data) {
|
|
662
|
+
throw new accounts_1.FactoryArgsNotAvailableError();
|
|
663
|
+
}
|
|
651
664
|
// Contract account with init code
|
|
652
665
|
return {
|
|
653
666
|
setupOps: [
|
|
654
667
|
{
|
|
655
|
-
to
|
|
656
|
-
data
|
|
668
|
+
to,
|
|
669
|
+
data,
|
|
657
670
|
},
|
|
658
671
|
],
|
|
659
672
|
};
|