@across-protocol/sdk 4.0.3-beta.0 → 4.0.3
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/cjs/clients/BundleDataClient/BundleDataClient.d.ts +2 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +25 -9
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.d.ts +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +4 -4
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +6 -3
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +5 -4
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient.js +127 -80
- package/dist/cjs/clients/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +16 -2
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +77 -35
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/cjs/constants.d.ts +2 -1
- package/dist/cjs/constants.js +3 -2
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/interfaces/SpokePool.d.ts +4 -2
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/utils/AddressUtils.d.ts +1 -0
- package/dist/cjs/utils/AddressUtils.js +5 -1
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/CachingUtils.js +1 -1
- package/dist/cjs/utils/CachingUtils.js.map +1 -1
- package/dist/cjs/utils/DepositUtils.d.ts +1 -1
- package/dist/cjs/utils/DepositUtils.js +11 -8
- package/dist/cjs/utils/DepositUtils.js.map +1 -1
- package/dist/cjs/utils/FlowUtils.d.ts +4 -3
- package/dist/cjs/utils/FlowUtils.js +5 -1
- package/dist/cjs/utils/FlowUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.d.ts +6 -3
- package/dist/cjs/utils/SpokeUtils.js +2 -2
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +2 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +29 -13
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +2 -2
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +6 -3
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +3 -2
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient.js +135 -85
- package/dist/esm/clients/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +16 -2
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +79 -37
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/esm/constants.d.ts +2 -1
- package/dist/esm/constants.js +6 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/interfaces/SpokePool.d.ts +4 -2
- package/dist/esm/package.json +1 -0
- package/dist/esm/utils/AddressUtils.d.ts +1 -0
- package/dist/esm/utils/AddressUtils.js +7 -4
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/CachingUtils.js +2 -2
- package/dist/esm/utils/CachingUtils.js.map +1 -1
- package/dist/esm/utils/DepositUtils.d.ts +1 -1
- package/dist/esm/utils/DepositUtils.js +12 -9
- package/dist/esm/utils/DepositUtils.js.map +1 -1
- package/dist/esm/utils/FlowUtils.d.ts +4 -3
- package/dist/esm/utils/FlowUtils.js +6 -1
- package/dist/esm/utils/FlowUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.d.ts +6 -3
- package/dist/esm/utils/SpokeUtils.js +2 -2
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/abi/typechain/Multicall3.d.ts +4 -1
- package/dist/esm/utils/abi/typechain/factories/Multicall3__factory.js.map +1 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +2 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts +1 -1
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +6 -3
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +16 -2
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
- package/dist/types/constants.d.ts +2 -1
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/interfaces/SpokePool.d.ts +4 -2
- package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
- package/dist/types/utils/AddressUtils.d.ts +1 -0
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/DepositUtils.d.ts +1 -1
- package/dist/types/utils/DepositUtils.d.ts.map +1 -1
- package/dist/types/utils/FlowUtils.d.ts +4 -3
- package/dist/types/utils/FlowUtils.d.ts.map +1 -1
- package/dist/types/utils/SpokeUtils.d.ts +6 -3
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/dist/types/utils/abi/typechain/Multicall3.d.ts +4 -1
- package/dist/types/utils/abi/typechain/Multicall3.d.ts.map +1 -1
- package/dist/types/utils/abi/typechain/common.d.ts.map +1 -1
- package/dist/types/utils/abi/typechain/factories/Multicall3__factory.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/clients/BundleDataClient/BundleDataClient.ts +30 -13
- package/src/clients/BundleDataClient/utils/FillUtils.ts +2 -2
- package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +6 -3
- package/src/clients/SpokePoolClient.ts +67 -23
- package/src/clients/mocks/MockSpokePoolClient.ts +125 -29
- package/src/constants.ts +6 -1
- package/src/interfaces/SpokePool.ts +4 -2
- package/src/utils/AddressUtils.ts +8 -4
- package/src/utils/CachingUtils.ts +2 -2
- package/src/utils/DepositUtils.ts +8 -3
- package/src/utils/FlowUtils.ts +10 -4
- package/src/utils/SpokeUtils.ts +7 -4
|
@@ -3,9 +3,10 @@ import { SpokePoolClient } from "../clients";
|
|
|
3
3
|
import { DEFAULT_CACHING_TTL, EMPTY_MESSAGE, ZERO_BYTES } from "../constants";
|
|
4
4
|
import { CachingMechanismInterface, Deposit, DepositWithBlock, Fill, SlowFillRequest } from "../interfaces";
|
|
5
5
|
import { getNetworkName } from "./NetworkUtils";
|
|
6
|
+
import { bnZero } from "./BigNumberUtils";
|
|
6
7
|
import { getDepositInCache, getDepositKey, setDepositInCache } from "./CachingUtils";
|
|
7
8
|
import { validateFillForDeposit } from "./FlowUtils";
|
|
8
|
-
import { isUnsafeDepositId } from "./SpokeUtils";
|
|
9
|
+
import { getMessageHash, isUnsafeDepositId } from "./SpokeUtils";
|
|
9
10
|
import { getCurrentTime } from "./TimeUtils";
|
|
10
11
|
import { isDefined } from "./TypeGuards";
|
|
11
12
|
import { isDepositFormedCorrectly } from "./ValidatorUtils";
|
|
@@ -122,6 +123,8 @@ export async function queryHistoricalDepositForFill(
|
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
|
|
126
|
+
deposit.messageHash ??= getMessageHash(deposit.message);
|
|
127
|
+
|
|
125
128
|
const match = validateFillForDeposit(fill, deposit);
|
|
126
129
|
if (match.valid) {
|
|
127
130
|
return { found: true, deposit };
|
|
@@ -146,8 +149,10 @@ export function isZeroValueDeposit(deposit: Pick<Deposit, "inputAmount" | "messa
|
|
|
146
149
|
return deposit.inputAmount.eq(0) && isMessageEmpty(deposit.message);
|
|
147
150
|
}
|
|
148
151
|
|
|
149
|
-
export function isZeroValueFillOrSlowFillRequest(
|
|
150
|
-
|
|
152
|
+
export function isZeroValueFillOrSlowFillRequest(
|
|
153
|
+
e: Pick<Fill | SlowFillRequest, "inputAmount" | "messageHash">
|
|
154
|
+
): boolean {
|
|
155
|
+
return e.inputAmount.eq(bnZero) && e.messageHash === ZERO_BYTES;
|
|
151
156
|
}
|
|
152
157
|
|
|
153
158
|
/**
|
package/src/utils/FlowUtils.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isDefined } from "../utils";
|
|
2
2
|
import { Deposit, RelayData } from "../interfaces";
|
|
3
|
+
import { UNDEFINED_MESSAGE_HASH } from "../constants";
|
|
3
4
|
|
|
4
5
|
export const RELAYDATA_KEYS = [
|
|
5
6
|
"depositId",
|
|
@@ -14,14 +15,14 @@ export const RELAYDATA_KEYS = [
|
|
|
14
15
|
"fillDeadline",
|
|
15
16
|
"exclusivityDeadline",
|
|
16
17
|
"exclusiveRelayer",
|
|
17
|
-
"
|
|
18
|
+
"messageHash",
|
|
18
19
|
] as const;
|
|
19
20
|
|
|
20
21
|
// Ensure that each deposit element is included with the same value in the fill. This includes all elements defined
|
|
21
22
|
// by the depositor as well as destinationToken, which are pulled from other clients.
|
|
22
23
|
export function validateFillForDeposit(
|
|
23
|
-
relayData: RelayData & { destinationChainId: number },
|
|
24
|
-
deposit?: Deposit
|
|
24
|
+
relayData: Omit<RelayData, "message"> & { messageHash: string; destinationChainId: number },
|
|
25
|
+
deposit?: Omit<Deposit, "quoteTimestamp" | "fromLiteChain" | "toLiteChain">
|
|
25
26
|
): { valid: true } | { valid: false; reason: string } {
|
|
26
27
|
if (deposit === undefined) {
|
|
27
28
|
return { valid: false, reason: "Deposit is undefined" };
|
|
@@ -30,7 +31,12 @@ export function validateFillForDeposit(
|
|
|
30
31
|
// Note: this short circuits when a key is found where the comparison doesn't match.
|
|
31
32
|
// TODO: if we turn on "strict" in the tsconfig, the elements of FILL_DEPOSIT_COMPARISON_KEYS will be automatically
|
|
32
33
|
// validated against the fields in Fill and Deposit, generating an error if there is a discrepency.
|
|
33
|
-
|
|
34
|
+
let invalidKey = RELAYDATA_KEYS.find((key) => relayData[key].toString() !== deposit[key].toString());
|
|
35
|
+
|
|
36
|
+
// There should be no paths for `messageHash` to be unset, but mask it off anyway.
|
|
37
|
+
if (!isDefined(invalidKey) && [relayData.messageHash, deposit.messageHash].includes(UNDEFINED_MESSAGE_HASH)) {
|
|
38
|
+
invalidKey = "messageHash";
|
|
39
|
+
}
|
|
34
40
|
|
|
35
41
|
return isDefined(invalidKey)
|
|
36
42
|
? { valid: false, reason: `${invalidKey} mismatch (${relayData[invalidKey]} != ${deposit[invalidKey]})` }
|
package/src/utils/SpokeUtils.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from "assert";
|
|
2
2
|
import { BytesLike, Contract, PopulatedTransaction, providers, utils as ethersUtils } from "ethers";
|
|
3
3
|
import { CHAIN_IDs, MAX_SAFE_DEPOSIT_ID, ZERO_ADDRESS, ZERO_BYTES } from "../constants";
|
|
4
|
-
import { Deposit,
|
|
4
|
+
import { Deposit, FillStatus, FillWithBlock, RelayData } from "../interfaces";
|
|
5
5
|
import { SpokePoolClient } from "../clients";
|
|
6
6
|
import { chunk } from "./ArrayUtils";
|
|
7
7
|
import { BigNumber, toBN, bnOne, bnZero } from "./BigNumberUtils";
|
|
@@ -64,7 +64,9 @@ export function populateV3Relay(
|
|
|
64
64
|
* is required to compute a complete RelayData hash.
|
|
65
65
|
* note: This function should _not_ be used to query the SpokePool.fillStatuses mapping.
|
|
66
66
|
*/
|
|
67
|
-
export function getRelayEventKey(
|
|
67
|
+
export function getRelayEventKey(
|
|
68
|
+
data: Omit<RelayData, "message"> & { messageHash: string; destinationChainId: number }
|
|
69
|
+
): string {
|
|
68
70
|
return [
|
|
69
71
|
data.depositor,
|
|
70
72
|
data.recipient,
|
|
@@ -78,7 +80,7 @@ export function getRelayEventKey(data: RelayData & { destinationChainId: number
|
|
|
78
80
|
data.depositId,
|
|
79
81
|
data.fillDeadline,
|
|
80
82
|
data.exclusivityDeadline,
|
|
81
|
-
data.
|
|
83
|
+
data.messageHash,
|
|
82
84
|
]
|
|
83
85
|
.map(String)
|
|
84
86
|
.join("-");
|
|
@@ -284,7 +286,7 @@ export function getRelayDataHash(relayData: RelayData, destinationChainId: numbe
|
|
|
284
286
|
);
|
|
285
287
|
}
|
|
286
288
|
|
|
287
|
-
export function getRelayHashFromEvent(e:
|
|
289
|
+
export function getRelayHashFromEvent(e: RelayData & { destinationChainId: number }): string {
|
|
288
290
|
return getRelayDataHash(e, e.destinationChainId);
|
|
289
291
|
}
|
|
290
292
|
|
|
@@ -455,6 +457,7 @@ export async function findFillEvent(
|
|
|
455
457
|
const fill = {
|
|
456
458
|
...spreadEventWithBlockNumber(event),
|
|
457
459
|
destinationChainId,
|
|
460
|
+
messageHash: getMessageHash(event.args.message),
|
|
458
461
|
} as FillWithBlock;
|
|
459
462
|
return fill;
|
|
460
463
|
}
|