@eulerxyz/euler-v2-sdk 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/plugins/pyth/pythPlugin.d.ts +13 -3
- package/dist/src/plugins/pyth/pythPlugin.d.ts.map +1 -1
- package/dist/src/plugins/pyth/pythPlugin.js +114 -46
- package/dist/src/plugins/pyth/pythPlugin.js.map +1 -1
- package/dist/src/plugins/types.d.ts +4 -2
- package/dist/src/plugins/types.d.ts.map +1 -1
- package/dist/src/plugins/types.js +2 -2
- package/dist/src/plugins/types.js.map +1 -1
- package/dist/src/sdk/sdk.d.ts +5 -5
- package/dist/src/sdk/sdk.d.ts.map +1 -1
- package/dist/src/sdk/sdk.js +7 -28
- package/dist/src/sdk/sdk.js.map +1 -1
- package/dist/src/services/executionService/executionService.d.ts +66 -5
- package/dist/src/services/executionService/executionService.d.ts.map +1 -1
- package/dist/src/services/executionService/executionService.js +48 -4
- package/dist/src/services/executionService/executionService.js.map +1 -1
- package/dist/src/services/executionService/executionServiceTypes.d.ts +13 -0
- package/dist/src/services/executionService/executionServiceTypes.d.ts.map +1 -1
- package/dist/src/services/executionService/executionServiceTypes.js.map +1 -1
- package/dist/src/services/executionService/index.d.ts +2 -1
- package/dist/src/services/executionService/index.d.ts.map +1 -1
- package/dist/src/services/executionService/index.js +1 -0
- package/dist/src/services/executionService/index.js.map +1 -1
- package/dist/src/services/executionService/materializedExecution.d.ts +153 -0
- package/dist/src/services/executionService/materializedExecution.d.ts.map +1 -0
- package/dist/src/services/executionService/materializedExecution.js +475 -0
- package/dist/src/services/executionService/materializedExecution.js.map +1 -0
- package/dist/src/services/executionService/migrationAuthorization.d.ts +10 -0
- package/dist/src/services/executionService/migrationAuthorization.d.ts.map +1 -0
- package/dist/src/services/executionService/migrationAuthorization.js +142 -0
- package/dist/src/services/executionService/migrationAuthorization.js.map +1 -0
- package/dist/src/services/positionMigrationService/connectors/aave/aaveConnectorTypes.d.ts +2 -0
- package/dist/src/services/positionMigrationService/connectors/aave/aaveConnectorTypes.d.ts.map +1 -1
- package/dist/src/services/positionMigrationService/connectors/metamorpho/metamorphoConnectorTypes.d.ts +1 -0
- package/dist/src/services/positionMigrationService/connectors/metamorpho/metamorphoConnectorTypes.d.ts.map +1 -1
- package/dist/src/services/positionMigrationService/connectors/morpho/morphoConnector.d.ts +4 -4
- package/dist/src/services/positionMigrationService/connectors/morpho/morphoConnector.d.ts.map +1 -1
- package/dist/src/services/positionMigrationService/connectors/morpho/morphoConnector.js +7 -10
- package/dist/src/services/positionMigrationService/connectors/morpho/morphoConnector.js.map +1 -1
- package/dist/src/services/positionMigrationService/connectors/morpho/morphoConnectorTypes.d.ts +5 -1
- package/dist/src/services/positionMigrationService/connectors/morpho/morphoConnectorTypes.d.ts.map +1 -1
- package/dist/src/services/positionMigrationService/index.d.ts +1 -1
- package/dist/src/services/positionMigrationService/index.d.ts.map +1 -1
- package/dist/src/services/positionMigrationService/index.js.map +1 -1
- package/dist/src/services/positionMigrationService/positionMigrationService.d.ts +7 -1
- package/dist/src/services/positionMigrationService/positionMigrationService.d.ts.map +1 -1
- package/dist/src/services/positionMigrationService/positionMigrationService.js +188 -3
- package/dist/src/services/positionMigrationService/positionMigrationService.js.map +1 -1
- package/dist/src/services/positionMigrationService/positionMigrationServiceTypes.d.ts +49 -15
- package/dist/src/services/positionMigrationService/positionMigrationServiceTypes.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { type Address, type Hash, type Hex, type TransactionReceipt } from "viem";
|
|
2
|
+
import { type DecodedSmartContractError } from "../../utils/decodeSmartContractErrors.js";
|
|
3
|
+
import type { ProviderService } from "../providerService/index.js";
|
|
4
|
+
import type { EVCBatchItem, PermitSingleTypedData, TransactionPlanPrepared } from "./executionServiceTypes.js";
|
|
5
|
+
export type Permit2MaterializationInput = {
|
|
6
|
+
planItemIndex: number;
|
|
7
|
+
resolvedIndex: number;
|
|
8
|
+
nonce: number;
|
|
9
|
+
sigDeadline: bigint;
|
|
10
|
+
expiration: number;
|
|
11
|
+
};
|
|
12
|
+
export type MaterializeExecutionArgs = {
|
|
13
|
+
prepared: TransactionPlanPrepared;
|
|
14
|
+
inputs: {
|
|
15
|
+
evcAddress: Address;
|
|
16
|
+
permit2: readonly Permit2MaterializationInput[];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export type MaterializedExecutionRequestKind = "approval" | "evcBatch" | "contractCall";
|
|
20
|
+
/** Exact transaction template sealed before dynamic signatures are collected. */
|
|
21
|
+
export type MaterializedExecutionRequest = {
|
|
22
|
+
requestIndex: number;
|
|
23
|
+
sourcePlanItemIndex: number;
|
|
24
|
+
kind: MaterializedExecutionRequestKind;
|
|
25
|
+
chainId: number;
|
|
26
|
+
from: Address;
|
|
27
|
+
to: Address;
|
|
28
|
+
data: Hex;
|
|
29
|
+
value: bigint;
|
|
30
|
+
};
|
|
31
|
+
export type MaterializedSafeCall = Pick<MaterializedExecutionRequest, "to" | "data" | "value">;
|
|
32
|
+
export type MaterializedPermit2SignatureSlot = {
|
|
33
|
+
slotId: Hash;
|
|
34
|
+
kind: "permit2";
|
|
35
|
+
signer: Address;
|
|
36
|
+
chainId: number;
|
|
37
|
+
planItemIndex: number;
|
|
38
|
+
resolvedIndex: number;
|
|
39
|
+
nonce: number;
|
|
40
|
+
validUntil: bigint;
|
|
41
|
+
typedDataHash: Hash;
|
|
42
|
+
typedData: PermitSingleTypedData;
|
|
43
|
+
insertion: {
|
|
44
|
+
requestIndex: number;
|
|
45
|
+
batchItemIndex: number;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export type MaterializedExecution = {
|
|
49
|
+
readonly __materialized: true;
|
|
50
|
+
readonly chainId: number;
|
|
51
|
+
readonly from: Address;
|
|
52
|
+
readonly evcAddress: Address;
|
|
53
|
+
readonly requests: readonly MaterializedExecutionRequest[];
|
|
54
|
+
readonly signatureSlots: readonly MaterializedPermit2SignatureSlot[];
|
|
55
|
+
readonly safeCalls: readonly MaterializedSafeCall[];
|
|
56
|
+
};
|
|
57
|
+
export type MaterializedSignatureValue = {
|
|
58
|
+
slotId: Hash;
|
|
59
|
+
signature: Hex;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* A finalized request vector supplied as trusted application input. The SDK
|
|
63
|
+
* does not authenticate this artifact. The application must cover the complete
|
|
64
|
+
* artifact with its accepted review digest before passing it to
|
|
65
|
+
* `executeMaterialized`.
|
|
66
|
+
*/
|
|
67
|
+
export type FinalizedMaterializedExecution = {
|
|
68
|
+
readonly __materialized: true;
|
|
69
|
+
/** Structural discriminator only; this is not a security seal. */
|
|
70
|
+
readonly __finalized: true;
|
|
71
|
+
readonly chainId: number;
|
|
72
|
+
readonly from: Address;
|
|
73
|
+
readonly evcAddress: Address;
|
|
74
|
+
readonly requests: readonly MaterializedExecutionRequest[];
|
|
75
|
+
readonly signatureSlots: readonly MaterializedPermit2SignatureSlot[];
|
|
76
|
+
readonly signatureValues: readonly MaterializedSignatureValue[];
|
|
77
|
+
readonly safeCalls: readonly MaterializedSafeCall[];
|
|
78
|
+
};
|
|
79
|
+
export type MaterializedExecutionProgress = {
|
|
80
|
+
completed: number;
|
|
81
|
+
total: number;
|
|
82
|
+
request?: MaterializedExecutionRequest;
|
|
83
|
+
status: "signature" | "transaction" | "completed";
|
|
84
|
+
hash?: Hash;
|
|
85
|
+
};
|
|
86
|
+
export type ExecuteMaterializedOptions = {
|
|
87
|
+
sendTransaction: (request: MaterializedExecutionRequest) => Promise<Hash>;
|
|
88
|
+
signTypedData?: (typedData: PermitSingleTypedData) => Promise<Hex>;
|
|
89
|
+
revalidate?: {
|
|
90
|
+
permit2NonceMustEqualPinned?: boolean;
|
|
91
|
+
};
|
|
92
|
+
/** Awaited immediately before every signature wallet prompt. */
|
|
93
|
+
onBeforeSignature?: (slot: MaterializedPermit2SignatureSlot, index: number) => Promise<void> | void;
|
|
94
|
+
/** Awaited after all signatures are inserted and before the first signed batch. */
|
|
95
|
+
onFinalized?: (execution: FinalizedMaterializedExecution) => Promise<void> | void;
|
|
96
|
+
/** Awaited immediately before every transaction wallet prompt. */
|
|
97
|
+
onBeforeStep?: (request: MaterializedExecutionRequest, index: number) => Promise<void> | void;
|
|
98
|
+
/** Awaited after broadcast and before receipt polling. */
|
|
99
|
+
onTransactionHash?: (request: MaterializedExecutionRequest, index: number, hash: Hash) => Promise<void> | void;
|
|
100
|
+
/** Awaited after a successful receipt and before the next wallet prompt. */
|
|
101
|
+
onAfterStep?: (request: MaterializedExecutionRequest, index: number, hash: Hash, receipt: TransactionReceipt) => Promise<void> | void;
|
|
102
|
+
onProgress?: (progress: MaterializedExecutionProgress) => void;
|
|
103
|
+
};
|
|
104
|
+
export type MaterializedExecutionResult = {
|
|
105
|
+
execution: FinalizedMaterializedExecution;
|
|
106
|
+
hashes: Hash[];
|
|
107
|
+
receipts: TransactionReceipt[];
|
|
108
|
+
};
|
|
109
|
+
export interface MaterializedExecutionEncoder {
|
|
110
|
+
getPermit2TypedData(args: {
|
|
111
|
+
chainId: number;
|
|
112
|
+
token: Address;
|
|
113
|
+
amount: bigint;
|
|
114
|
+
spender: Address;
|
|
115
|
+
nonce: number;
|
|
116
|
+
sigDeadline: bigint;
|
|
117
|
+
expiration: number;
|
|
118
|
+
}): PermitSingleTypedData;
|
|
119
|
+
encodePermit2Call(args: {
|
|
120
|
+
chainId: number;
|
|
121
|
+
owner: Address;
|
|
122
|
+
message: PermitSingleTypedData["message"];
|
|
123
|
+
signature: Hex;
|
|
124
|
+
}): EVCBatchItem;
|
|
125
|
+
encodeBatch(items: EVCBatchItem[]): Hex;
|
|
126
|
+
}
|
|
127
|
+
export declare class MaterializedExecutionError extends Error {
|
|
128
|
+
readonly decodedErrors: DecodedSmartContractError[];
|
|
129
|
+
readonly originalError: unknown;
|
|
130
|
+
constructor(message: string, originalError: unknown, decodedErrors: DecodedSmartContractError[]);
|
|
131
|
+
}
|
|
132
|
+
export declare class MaterializedTransactionRevertedError extends Error {
|
|
133
|
+
readonly hash: Hash;
|
|
134
|
+
constructor(hash: Hash);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Purely compose a prepared plan into deterministic transaction templates.
|
|
138
|
+
* All live values used by composition are explicit inputs. Permit2 signatures
|
|
139
|
+
* are represented by typed signature slots and a fixed placeholder.
|
|
140
|
+
*/
|
|
141
|
+
export declare function materializeExecution(encoder: MaterializedExecutionEncoder, args: MaterializeExecutionArgs): MaterializedExecution;
|
|
142
|
+
/** Purely insert the exact provided signatures without changing any other byte. */
|
|
143
|
+
export declare function finalizeMaterializedExecution(encoder: MaterializedExecutionEncoder, materialized: MaterializedExecution, signatures: readonly MaterializedSignatureValue[]): FinalizedMaterializedExecution;
|
|
144
|
+
/**
|
|
145
|
+
* Dispatch static prerequisites that precede the first signed batch, collect
|
|
146
|
+
* the declared signatures, finalize a new immutable request vector, then
|
|
147
|
+
* dispatch its remaining exact requests. No transaction is recomposed during
|
|
148
|
+
* dispatch. A supplied FinalizedMaterializedExecution is not authenticated by
|
|
149
|
+
* the SDK; this function assumes the application already authenticated the
|
|
150
|
+
* complete finalized input against its accepted review digest.
|
|
151
|
+
*/
|
|
152
|
+
export declare function executeMaterialized(encoder: MaterializedExecutionEncoder, providerService: ProviderService, materialized: MaterializedExecution | FinalizedMaterializedExecution, options: ExecuteMaterializedOptions): Promise<MaterializedExecutionResult>;
|
|
153
|
+
//# sourceMappingURL=materializedExecution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"materializedExecution.d.ts","sourceRoot":"","sources":["../../../../src/services/executionService/materializedExecution.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,OAAO,EAOZ,KAAK,IAAI,EACT,KAAK,GAAG,EACR,KAAK,kBAAkB,EACvB,MAAM,MAAM,CAAC;AAEd,OAAO,EACN,KAAK,yBAAyB,EAE9B,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAA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AmF;AACnF,wBAAgB,6BAA6B,CAC5C,OAAO,EAAE,4BAA4B,EACrC,YAAY,EAAE,qBAAqB,EACnC,UAAU,EAAE,SAAS,0BAA0B,EAAE,GAC/C,8BAA8B,CAwEhC;AA+CD;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACxC,OAAO,EAAE,4BAA4B,EACrC,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,qBAAqB,GAAG,8BAA8B,EACpE,OAAO,EAAE,0BAA0B,GACjC,OAAO,CAAC,2BAA2B,CAAC,CA8GtC"}
|
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
import { decodeFunctionData, encodeFunctionData, encodePacked, getAddress, hashTypedData, keccak256, } from "viem";
|
|
2
|
+
import { decodeSmartContractErrors, } from "../../utils/decodeSmartContractErrors.js";
|
|
3
|
+
import { ethereumVaultConnectorAbi } from "./abis/ethereumVaultConnectorAbi.js";
|
|
4
|
+
import { assertNoCowSwapPlanItems, flattenBatchEntries, } from "./executionServiceTypes.js";
|
|
5
|
+
const PLACEHOLDER_SIGNATURE = `0x${"00".repeat(65)}`;
|
|
6
|
+
const PERMIT2_ALLOWANCE_ABI = [
|
|
7
|
+
{
|
|
8
|
+
name: "allowance",
|
|
9
|
+
type: "function",
|
|
10
|
+
stateMutability: "view",
|
|
11
|
+
inputs: [
|
|
12
|
+
{ name: "owner", type: "address" },
|
|
13
|
+
{ name: "token", type: "address" },
|
|
14
|
+
{ name: "spender", type: "address" },
|
|
15
|
+
],
|
|
16
|
+
outputs: [
|
|
17
|
+
{ name: "amount", type: "uint160" },
|
|
18
|
+
{ name: "expiration", type: "uint48" },
|
|
19
|
+
{ name: "nonce", type: "uint48" },
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
export class MaterializedExecutionError extends Error {
|
|
24
|
+
decodedErrors;
|
|
25
|
+
originalError;
|
|
26
|
+
constructor(message, originalError, decodedErrors) {
|
|
27
|
+
super(message);
|
|
28
|
+
this.name = "MaterializedExecutionError";
|
|
29
|
+
this.originalError = originalError;
|
|
30
|
+
this.decodedErrors = decodedErrors;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export class MaterializedTransactionRevertedError extends Error {
|
|
34
|
+
hash;
|
|
35
|
+
constructor(hash) {
|
|
36
|
+
super(`Transaction ${hash} reverted`);
|
|
37
|
+
this.name = "MaterializedTransactionRevertedError";
|
|
38
|
+
this.hash = hash;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function ownerOf(account) {
|
|
42
|
+
return getAddress(typeof account === "string" ? account : account.owner);
|
|
43
|
+
}
|
|
44
|
+
function deepFreeze(value) {
|
|
45
|
+
if (value && typeof value === "object" && !Object.isFrozen(value)) {
|
|
46
|
+
for (const child of Object.values(value))
|
|
47
|
+
deepFreeze(child);
|
|
48
|
+
Object.freeze(value);
|
|
49
|
+
}
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
function cloneTypedData(typedData) {
|
|
53
|
+
return {
|
|
54
|
+
domain: { ...typedData.domain },
|
|
55
|
+
types: {
|
|
56
|
+
PermitDetails: [
|
|
57
|
+
{ ...typedData.types.PermitDetails[0] },
|
|
58
|
+
{ ...typedData.types.PermitDetails[1] },
|
|
59
|
+
{ ...typedData.types.PermitDetails[2] },
|
|
60
|
+
{ ...typedData.types.PermitDetails[3] },
|
|
61
|
+
],
|
|
62
|
+
PermitSingle: [
|
|
63
|
+
{ ...typedData.types.PermitSingle[0] },
|
|
64
|
+
{ ...typedData.types.PermitSingle[1] },
|
|
65
|
+
{ ...typedData.types.PermitSingle[2] },
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
primaryType: "PermitSingle",
|
|
69
|
+
message: {
|
|
70
|
+
details: { ...typedData.message.details },
|
|
71
|
+
spender: typedData.message.spender,
|
|
72
|
+
sigDeadline: typedData.message.sigDeadline,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function inputKey(planItemIndex, resolvedIndex) {
|
|
77
|
+
return `${planItemIndex}:${resolvedIndex}`;
|
|
78
|
+
}
|
|
79
|
+
function assertMaterializationInput(input) {
|
|
80
|
+
if (!Number.isSafeInteger(input.planItemIndex) ||
|
|
81
|
+
input.planItemIndex < 0 ||
|
|
82
|
+
!Number.isSafeInteger(input.resolvedIndex) ||
|
|
83
|
+
input.resolvedIndex < 0) {
|
|
84
|
+
throw new Error("Permit2 materialization coordinates are invalid");
|
|
85
|
+
}
|
|
86
|
+
if (!Number.isSafeInteger(input.nonce) || input.nonce < 0) {
|
|
87
|
+
throw new Error("Permit2 materialization nonce is invalid");
|
|
88
|
+
}
|
|
89
|
+
if (input.sigDeadline <= 0n) {
|
|
90
|
+
throw new Error("Permit2 materialization signature deadline is invalid");
|
|
91
|
+
}
|
|
92
|
+
if (!Number.isSafeInteger(input.expiration) || input.expiration <= 0) {
|
|
93
|
+
throw new Error("Permit2 materialization expiration is invalid");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function decodeBatchItems(data) {
|
|
97
|
+
const decoded = decodeFunctionData({
|
|
98
|
+
abi: ethereumVaultConnectorAbi,
|
|
99
|
+
data,
|
|
100
|
+
});
|
|
101
|
+
if (decoded.functionName !== "batch") {
|
|
102
|
+
throw new Error("Materialized EVC request does not encode batch()");
|
|
103
|
+
}
|
|
104
|
+
return decoded.args[0].map((item) => ({
|
|
105
|
+
targetContract: getAddress(item.targetContract),
|
|
106
|
+
onBehalfOfAccount: getAddress(item.onBehalfOfAccount),
|
|
107
|
+
value: item.value,
|
|
108
|
+
data: item.data,
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
function makeSafeCalls(requests) {
|
|
112
|
+
return requests.map(({ to, data, value }) => ({ to, data, value }));
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Purely compose a prepared plan into deterministic transaction templates.
|
|
116
|
+
* All live values used by composition are explicit inputs. Permit2 signatures
|
|
117
|
+
* are represented by typed signature slots and a fixed placeholder.
|
|
118
|
+
*/
|
|
119
|
+
export function materializeExecution(encoder, args) {
|
|
120
|
+
const { prepared, inputs } = args;
|
|
121
|
+
assertNoCowSwapPlanItems(prepared.plan, "materializeExecution");
|
|
122
|
+
const from = ownerOf(prepared.account);
|
|
123
|
+
const evcAddress = getAddress(inputs.evcAddress);
|
|
124
|
+
const permitInputs = new Map();
|
|
125
|
+
for (const input of inputs.permit2) {
|
|
126
|
+
assertMaterializationInput(input);
|
|
127
|
+
const key = inputKey(input.planItemIndex, input.resolvedIndex);
|
|
128
|
+
if (permitInputs.has(key)) {
|
|
129
|
+
throw new Error(`Duplicate Permit2 materialization input ${key}`);
|
|
130
|
+
}
|
|
131
|
+
permitInputs.set(key, input);
|
|
132
|
+
}
|
|
133
|
+
const requests = [];
|
|
134
|
+
const signatureSlots = [];
|
|
135
|
+
const pendingPermitItems = [];
|
|
136
|
+
const consumedPermitInputs = new Set();
|
|
137
|
+
for (const [planItemIndex, item] of prepared.plan.entries()) {
|
|
138
|
+
if (item.type === "cowSwap") {
|
|
139
|
+
throw new Error("ExecutionService.materializeExecution does not support CoW swap plans");
|
|
140
|
+
}
|
|
141
|
+
if (item.type === "requiredApproval") {
|
|
142
|
+
if (!item.resolved) {
|
|
143
|
+
throw new Error(`Approval at plan item ${planItemIndex} is unresolved`);
|
|
144
|
+
}
|
|
145
|
+
for (const [resolvedIndex, resolved] of item.resolved.entries()) {
|
|
146
|
+
if (resolved.type === "approve") {
|
|
147
|
+
requests.push({
|
|
148
|
+
requestIndex: requests.length,
|
|
149
|
+
sourcePlanItemIndex: planItemIndex,
|
|
150
|
+
kind: "approval",
|
|
151
|
+
chainId: prepared.chainId,
|
|
152
|
+
from,
|
|
153
|
+
to: getAddress(resolved.token),
|
|
154
|
+
data: resolved.data,
|
|
155
|
+
value: 0n,
|
|
156
|
+
});
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
const key = inputKey(planItemIndex, resolvedIndex);
|
|
160
|
+
const input = permitInputs.get(key);
|
|
161
|
+
if (!input) {
|
|
162
|
+
throw new Error(`Permit2 materialization input ${key} is missing`);
|
|
163
|
+
}
|
|
164
|
+
consumedPermitInputs.add(key);
|
|
165
|
+
const typedData = cloneTypedData(encoder.getPermit2TypedData({
|
|
166
|
+
chainId: prepared.chainId,
|
|
167
|
+
token: getAddress(resolved.token),
|
|
168
|
+
amount: resolved.amount,
|
|
169
|
+
spender: getAddress(resolved.spender),
|
|
170
|
+
nonce: input.nonce,
|
|
171
|
+
sigDeadline: input.sigDeadline,
|
|
172
|
+
expiration: input.expiration,
|
|
173
|
+
}));
|
|
174
|
+
const typedDataHash = hashTypedData(typedData);
|
|
175
|
+
pendingPermitItems.push({
|
|
176
|
+
planItemIndex,
|
|
177
|
+
resolvedIndex,
|
|
178
|
+
item: encoder.encodePermit2Call({
|
|
179
|
+
chainId: prepared.chainId,
|
|
180
|
+
owner: getAddress(resolved.owner),
|
|
181
|
+
message: typedData.message,
|
|
182
|
+
signature: PLACEHOLDER_SIGNATURE,
|
|
183
|
+
}),
|
|
184
|
+
slot: {
|
|
185
|
+
kind: "permit2",
|
|
186
|
+
signer: getAddress(resolved.owner),
|
|
187
|
+
chainId: prepared.chainId,
|
|
188
|
+
planItemIndex,
|
|
189
|
+
resolvedIndex,
|
|
190
|
+
nonce: input.nonce,
|
|
191
|
+
validUntil: input.sigDeadline,
|
|
192
|
+
typedDataHash,
|
|
193
|
+
typedData,
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
if (item.type === "evcBatch") {
|
|
200
|
+
const batchItems = [
|
|
201
|
+
...pendingPermitItems.map((pending) => pending.item),
|
|
202
|
+
...flattenBatchEntries(item.items),
|
|
203
|
+
];
|
|
204
|
+
const requestIndex = requests.length;
|
|
205
|
+
requests.push({
|
|
206
|
+
requestIndex,
|
|
207
|
+
sourcePlanItemIndex: planItemIndex,
|
|
208
|
+
kind: "evcBatch",
|
|
209
|
+
chainId: prepared.chainId,
|
|
210
|
+
from,
|
|
211
|
+
to: evcAddress,
|
|
212
|
+
data: encoder.encodeBatch(batchItems),
|
|
213
|
+
value: batchItems.reduce((sum, batchItem) => sum + batchItem.value, 0n),
|
|
214
|
+
});
|
|
215
|
+
for (const [batchItemIndex, pending] of pendingPermitItems.entries()) {
|
|
216
|
+
const slotId = keccak256(encodePacked(["bytes32", "uint256", "uint256", "uint256", "uint256"], [
|
|
217
|
+
pending.slot.typedDataHash,
|
|
218
|
+
BigInt(pending.planItemIndex),
|
|
219
|
+
BigInt(pending.resolvedIndex),
|
|
220
|
+
BigInt(requestIndex),
|
|
221
|
+
BigInt(batchItemIndex),
|
|
222
|
+
]));
|
|
223
|
+
signatureSlots.push({
|
|
224
|
+
...pending.slot,
|
|
225
|
+
slotId,
|
|
226
|
+
insertion: { requestIndex, batchItemIndex },
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
pendingPermitItems.length = 0;
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
if (pendingPermitItems.length > 0) {
|
|
233
|
+
throw new Error("Permit2 signature has no following EVC batch insertion point");
|
|
234
|
+
}
|
|
235
|
+
if (item.chainId !== prepared.chainId) {
|
|
236
|
+
throw new Error(`Plan item targets chain ${item.chainId}, but materialization targets chain ${prepared.chainId}`);
|
|
237
|
+
}
|
|
238
|
+
requests.push({
|
|
239
|
+
requestIndex: requests.length,
|
|
240
|
+
sourcePlanItemIndex: planItemIndex,
|
|
241
|
+
kind: "contractCall",
|
|
242
|
+
chainId: prepared.chainId,
|
|
243
|
+
from,
|
|
244
|
+
to: getAddress(item.to),
|
|
245
|
+
data: encodeFunctionData({
|
|
246
|
+
abi: item.abi,
|
|
247
|
+
functionName: item.functionName,
|
|
248
|
+
args: item.args,
|
|
249
|
+
}),
|
|
250
|
+
value: item.value,
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
if (pendingPermitItems.length > 0) {
|
|
254
|
+
throw new Error("Permit2 signature has no following EVC batch insertion point");
|
|
255
|
+
}
|
|
256
|
+
if (consumedPermitInputs.size !== permitInputs.size) {
|
|
257
|
+
const unused = [...permitInputs.keys()].filter((key) => !consumedPermitInputs.has(key));
|
|
258
|
+
throw new Error(`Unused Permit2 materialization inputs: ${unused.join(", ")}`);
|
|
259
|
+
}
|
|
260
|
+
return deepFreeze({
|
|
261
|
+
__materialized: true,
|
|
262
|
+
chainId: prepared.chainId,
|
|
263
|
+
from,
|
|
264
|
+
evcAddress,
|
|
265
|
+
requests,
|
|
266
|
+
signatureSlots,
|
|
267
|
+
safeCalls: makeSafeCalls(requests),
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
/** Purely insert the exact provided signatures without changing any other byte. */
|
|
271
|
+
export function finalizeMaterializedExecution(encoder, materialized, signatures) {
|
|
272
|
+
if (signatures.length !== materialized.signatureSlots.length) {
|
|
273
|
+
throw new Error("Signature values do not exactly match materialized slots");
|
|
274
|
+
}
|
|
275
|
+
const signatureById = new Map(signatures.map((value) => [value.slotId, value]));
|
|
276
|
+
if (signatureById.size !== signatures.length) {
|
|
277
|
+
throw new Error("Duplicate materialized signature value");
|
|
278
|
+
}
|
|
279
|
+
for (const slot of materialized.signatureSlots) {
|
|
280
|
+
if (!signatureById.has(slot.slotId)) {
|
|
281
|
+
throw new Error(`Materialized signature ${slot.slotId} is missing`);
|
|
282
|
+
}
|
|
283
|
+
if (hashTypedData(slot.typedData) !== slot.typedDataHash) {
|
|
284
|
+
throw new Error(`Materialized signature slot ${slot.slotId} was mutated`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
const requests = materialized.requests.map((request) => ({ ...request }));
|
|
288
|
+
for (const [requestIndex, request] of requests.entries()) {
|
|
289
|
+
const slots = materialized.signatureSlots.filter((slot) => slot.insertion.requestIndex === requestIndex);
|
|
290
|
+
if (slots.length === 0)
|
|
291
|
+
continue;
|
|
292
|
+
if (request.kind !== "evcBatch") {
|
|
293
|
+
throw new Error("Materialized signature points outside an EVC batch");
|
|
294
|
+
}
|
|
295
|
+
const batchItems = decodeBatchItems(request.data);
|
|
296
|
+
if (encoder.encodeBatch(batchItems) !== request.data) {
|
|
297
|
+
throw new Error("Materialized EVC request is not canonically encoded");
|
|
298
|
+
}
|
|
299
|
+
for (const slot of slots) {
|
|
300
|
+
const signature = signatureById.get(slot.slotId);
|
|
301
|
+
const reviewedItem = batchItems[slot.insertion.batchItemIndex];
|
|
302
|
+
if (!signature || !reviewedItem) {
|
|
303
|
+
throw new Error("Materialized signature insertion point is invalid");
|
|
304
|
+
}
|
|
305
|
+
const expectedPlaceholder = encoder.encodePermit2Call({
|
|
306
|
+
chainId: slot.chainId,
|
|
307
|
+
owner: slot.signer,
|
|
308
|
+
message: slot.typedData.message,
|
|
309
|
+
signature: PLACEHOLDER_SIGNATURE,
|
|
310
|
+
});
|
|
311
|
+
if (reviewedItem.targetContract !== expectedPlaceholder.targetContract ||
|
|
312
|
+
reviewedItem.onBehalfOfAccount !== expectedPlaceholder.onBehalfOfAccount ||
|
|
313
|
+
reviewedItem.value !== expectedPlaceholder.value ||
|
|
314
|
+
reviewedItem.data !== expectedPlaceholder.data) {
|
|
315
|
+
throw new Error("Materialized Permit2 placeholder was mutated");
|
|
316
|
+
}
|
|
317
|
+
batchItems[slot.insertion.batchItemIndex] = encoder.encodePermit2Call({
|
|
318
|
+
chainId: slot.chainId,
|
|
319
|
+
owner: slot.signer,
|
|
320
|
+
message: slot.typedData.message,
|
|
321
|
+
signature: signature.signature,
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
request.data = encoder.encodeBatch(batchItems);
|
|
325
|
+
request.value = batchItems.reduce((sum, item) => sum + item.value, 0n);
|
|
326
|
+
}
|
|
327
|
+
return deepFreeze({
|
|
328
|
+
__materialized: true,
|
|
329
|
+
__finalized: true,
|
|
330
|
+
chainId: materialized.chainId,
|
|
331
|
+
from: materialized.from,
|
|
332
|
+
evcAddress: materialized.evcAddress,
|
|
333
|
+
requests,
|
|
334
|
+
signatureSlots: materialized.signatureSlots.map((slot) => ({ ...slot })),
|
|
335
|
+
signatureValues: signatures.map((value) => ({ ...value })),
|
|
336
|
+
safeCalls: makeSafeCalls(requests),
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
async function executeWithDecodedErrors(fn) {
|
|
340
|
+
try {
|
|
341
|
+
return await fn();
|
|
342
|
+
}
|
|
343
|
+
catch (error) {
|
|
344
|
+
if (error instanceof MaterializedTransactionRevertedError)
|
|
345
|
+
throw error;
|
|
346
|
+
const decoded = await decodeSmartContractErrors(error);
|
|
347
|
+
if (decoded.length > 0) {
|
|
348
|
+
throw new MaterializedExecutionError("Materialized execution failed", error, decoded);
|
|
349
|
+
}
|
|
350
|
+
throw error;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
function permit2Address(slot) {
|
|
354
|
+
const verifyingContract = slot.typedData.domain.verifyingContract;
|
|
355
|
+
if (typeof verifyingContract !== "string") {
|
|
356
|
+
throw new Error("Materialized Permit2 domain has no verifying contract");
|
|
357
|
+
}
|
|
358
|
+
return getAddress(verifyingContract);
|
|
359
|
+
}
|
|
360
|
+
async function assertPinnedPermit2Nonce(providerService, slot) {
|
|
361
|
+
const publicClient = providerService.getProvider(slot.chainId);
|
|
362
|
+
const allowance = (await publicClient.readContract({
|
|
363
|
+
address: permit2Address(slot),
|
|
364
|
+
abi: PERMIT2_ALLOWANCE_ABI,
|
|
365
|
+
functionName: "allowance",
|
|
366
|
+
args: [
|
|
367
|
+
slot.signer,
|
|
368
|
+
slot.typedData.message.details.token,
|
|
369
|
+
slot.typedData.message.spender,
|
|
370
|
+
],
|
|
371
|
+
}));
|
|
372
|
+
if (Number(allowance[2]) !== slot.nonce) {
|
|
373
|
+
throw new Error("Permit2 nonce changed after materialization");
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Dispatch static prerequisites that precede the first signed batch, collect
|
|
378
|
+
* the declared signatures, finalize a new immutable request vector, then
|
|
379
|
+
* dispatch its remaining exact requests. No transaction is recomposed during
|
|
380
|
+
* dispatch. A supplied FinalizedMaterializedExecution is not authenticated by
|
|
381
|
+
* the SDK; this function assumes the application already authenticated the
|
|
382
|
+
* complete finalized input against its accepted review digest.
|
|
383
|
+
*/
|
|
384
|
+
export async function executeMaterialized(encoder, providerService, materialized, options) {
|
|
385
|
+
const publicClient = providerService.getProvider(materialized.chainId);
|
|
386
|
+
const alreadyFinalized = "__finalized" in materialized && materialized.__finalized === true;
|
|
387
|
+
const firstSignedRequestIndex = materialized.signatureSlots.length
|
|
388
|
+
? Math.min(...materialized.signatureSlots.map((slot) => slot.insertion.requestIndex))
|
|
389
|
+
: 0;
|
|
390
|
+
let execution = alreadyFinalized
|
|
391
|
+
? materialized
|
|
392
|
+
: undefined;
|
|
393
|
+
const hashes = [];
|
|
394
|
+
const receipts = [];
|
|
395
|
+
const dispatchRequest = async (request, index) => {
|
|
396
|
+
if (options.revalidate?.permit2NonceMustEqualPinned) {
|
|
397
|
+
for (const slot of materialized.signatureSlots) {
|
|
398
|
+
if (slot.insertion.requestIndex === index) {
|
|
399
|
+
await assertPinnedPermit2Nonce(providerService, slot);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
await options.onBeforeStep?.(request, index);
|
|
404
|
+
options.onProgress?.({
|
|
405
|
+
completed: hashes.length,
|
|
406
|
+
total: materialized.requests.length,
|
|
407
|
+
request,
|
|
408
|
+
status: "transaction",
|
|
409
|
+
});
|
|
410
|
+
const hash = await options.sendTransaction(request);
|
|
411
|
+
hashes.push(hash);
|
|
412
|
+
await options.onTransactionHash?.(request, index, hash);
|
|
413
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
414
|
+
if (receipt.status !== "success") {
|
|
415
|
+
throw new MaterializedTransactionRevertedError(hash);
|
|
416
|
+
}
|
|
417
|
+
receipts.push(receipt);
|
|
418
|
+
await options.onAfterStep?.(request, index, hash, receipt);
|
|
419
|
+
options.onProgress?.({
|
|
420
|
+
completed: hashes.length,
|
|
421
|
+
total: materialized.requests.length,
|
|
422
|
+
request,
|
|
423
|
+
status: "transaction",
|
|
424
|
+
hash,
|
|
425
|
+
});
|
|
426
|
+
};
|
|
427
|
+
await executeWithDecodedErrors(async () => {
|
|
428
|
+
let nextRequestIndex = 0;
|
|
429
|
+
if (options.revalidate?.permit2NonceMustEqualPinned &&
|
|
430
|
+
materialized.signatureSlots.length > 0 &&
|
|
431
|
+
(alreadyFinalized || firstSignedRequestIndex > 0)) {
|
|
432
|
+
for (const slot of materialized.signatureSlots) {
|
|
433
|
+
await assertPinnedPermit2Nonce(providerService, slot);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
if (!alreadyFinalized) {
|
|
437
|
+
for (; nextRequestIndex < firstSignedRequestIndex; nextRequestIndex++) {
|
|
438
|
+
await dispatchRequest(materialized.requests[nextRequestIndex], nextRequestIndex);
|
|
439
|
+
}
|
|
440
|
+
const signatures = [];
|
|
441
|
+
options.onProgress?.({
|
|
442
|
+
completed: hashes.length,
|
|
443
|
+
total: materialized.requests.length,
|
|
444
|
+
status: "signature",
|
|
445
|
+
});
|
|
446
|
+
for (const [index, slot] of materialized.signatureSlots.entries()) {
|
|
447
|
+
if (!options.signTypedData) {
|
|
448
|
+
throw new Error("ExecutionService.executeMaterialized requires signTypedData when Permit2 approval is needed");
|
|
449
|
+
}
|
|
450
|
+
if (options.revalidate?.permit2NonceMustEqualPinned) {
|
|
451
|
+
await assertPinnedPermit2Nonce(providerService, slot);
|
|
452
|
+
}
|
|
453
|
+
await options.onBeforeSignature?.(slot, index);
|
|
454
|
+
const signature = await options.signTypedData(slot.typedData);
|
|
455
|
+
signatures.push({ slotId: slot.slotId, signature });
|
|
456
|
+
}
|
|
457
|
+
execution = finalizeMaterializedExecution(encoder, materialized, signatures);
|
|
458
|
+
}
|
|
459
|
+
if (!execution)
|
|
460
|
+
throw new Error("Materialized execution was not finalized");
|
|
461
|
+
await options.onFinalized?.(execution);
|
|
462
|
+
for (; nextRequestIndex < execution.requests.length; nextRequestIndex++) {
|
|
463
|
+
await dispatchRequest(execution.requests[nextRequestIndex], nextRequestIndex);
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
if (!execution)
|
|
467
|
+
throw new Error("Materialized execution was not finalized");
|
|
468
|
+
options.onProgress?.({
|
|
469
|
+
completed: execution.requests.length,
|
|
470
|
+
total: execution.requests.length,
|
|
471
|
+
status: "completed",
|
|
472
|
+
});
|
|
473
|
+
return { execution, hashes, receipts };
|
|
474
|
+
}
|
|
475
|
+
//# sourceMappingURL=materializedExecution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"materializedExecution.js","sourceRoot":"","sources":["../../../../src/services/executionService/materializedExecution.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,aAAa,EACb,SAAS,GAIT,MAAM,MAAM,CAAC;AAEd,OAAO,EAEN,yBAAyB,GACzB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAMhF,OAAO,EACN,wBAAwB,EACxB,mBAAmB,GACnB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,qBAAqB,GAAG,KAAK,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAS,CAAC;AAE5D,MAAM,qBAAqB,GAAG;IAC7B;QACC,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,MAAM;QACvB,MAAM,EAAE;YACP,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YAClC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YAClC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;SACpC;QACD,OAAO,EAAE;YACR,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,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