@across-protocol/sdk 4.0.0-beta.4 → 4.0.0-beta.6
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.js +22 -5
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +0 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/cjs/utils/AddressUtils.d.ts +1 -0
- package/dist/cjs/utils/AddressUtils.js +14 -1
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/DepositUtils.d.ts +2 -1
- package/dist/cjs/utils/DepositUtils.js +9 -0
- package/dist/cjs/utils/DepositUtils.js.map +1 -1
- package/dist/cjs/utils/NetworkUtils.d.ts +1 -0
- package/dist/cjs/utils/NetworkUtils.js +6 -1
- package/dist/cjs/utils/NetworkUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +27 -6
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +0 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/esm/utils/AddressUtils.d.ts +1 -0
- package/dist/esm/utils/AddressUtils.js +16 -0
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/DepositUtils.d.ts +2 -1
- package/dist/esm/utils/DepositUtils.js +9 -0
- package/dist/esm/utils/DepositUtils.js.map +1 -1
- package/dist/esm/utils/NetworkUtils.d.ts +6 -0
- package/dist/esm/utils/NetworkUtils.js +10 -0
- package/dist/esm/utils/NetworkUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.js +1 -1
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSpokePoolClient.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 +2 -1
- package/dist/types/utils/DepositUtils.d.ts.map +1 -1
- package/dist/types/utils/NetworkUtils.d.ts +6 -0
- package/dist/types/utils/NetworkUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/clients/BundleDataClient/BundleDataClient.ts +22 -0
- package/src/clients/mocks/MockSpokePoolClient.ts +0 -1
- package/src/utils/AddressUtils.ts +16 -0
- package/src/utils/DepositUtils.ts +9 -0
- package/src/utils/NetworkUtils.ts +11 -0
- package/src/utils/SpokeUtils.ts +1 -1
|
@@ -38,3 +38,19 @@ export function compareAddressesSimple(addressA?: string, addressB?: string): bo
|
|
|
38
38
|
}
|
|
39
39
|
return addressA.toLowerCase() === addressB.toLowerCase();
|
|
40
40
|
}
|
|
41
|
+
|
|
42
|
+
export function isValidEvmAddress(address: string): boolean {
|
|
43
|
+
if (utils.isAddress(address)) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
// We may throw an error here if hexZeroPadFails. This will happen if the address to pad is greater than 20 bytes long, indicating
|
|
47
|
+
// that the address had less than 12 leading zero bytes.
|
|
48
|
+
// We may also throw at getAddress if the input cannot be converted into a checksummed EVM address for some reason.
|
|
49
|
+
// For both cases, this indicates that the address cannot be casted as a bytes20 EVM address, so we should return false.
|
|
50
|
+
try {
|
|
51
|
+
const evmAddress = utils.hexZeroPad(utils.hexStripZeros(address), 20);
|
|
52
|
+
return utils.isAddress(utils.getAddress(evmAddress));
|
|
53
|
+
} catch (_e) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -5,6 +5,7 @@ import { CachingMechanismInterface, Deposit, DepositWithBlock, Fill, SlowFillReq
|
|
|
5
5
|
import { getNetworkName } from "./NetworkUtils";
|
|
6
6
|
import { getDepositInCache, getDepositKey, setDepositInCache } from "./CachingUtils";
|
|
7
7
|
import { validateFillForDeposit } from "./FlowUtils";
|
|
8
|
+
import { isUnsafeDepositId } from "./SpokeUtils";
|
|
8
9
|
import { getCurrentTime } from "./TimeUtils";
|
|
9
10
|
import { isDefined } from "./TypeGuards";
|
|
10
11
|
import { isDepositFormedCorrectly } from "./ValidatorUtils";
|
|
@@ -17,6 +18,7 @@ export enum InvalidFill {
|
|
|
17
18
|
DepositIdInvalid = 0, // Deposit ID seems invalid for origin SpokePool
|
|
18
19
|
DepositIdNotFound, // Deposit ID not found (bad RPC data?)
|
|
19
20
|
FillMismatch, // Fill does not match deposit parameters for deposit ID.
|
|
21
|
+
DepositIdOutOfRange, // Fill is for a deterministic deposit.
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
export type DepositSearchResult =
|
|
@@ -40,6 +42,13 @@ export async function queryHistoricalDepositForFill(
|
|
|
40
42
|
fill: Fill | SlowFillRequest,
|
|
41
43
|
cache?: CachingMechanismInterface
|
|
42
44
|
): Promise<DepositSearchResult> {
|
|
45
|
+
if (isUnsafeDepositId(fill.depositId)) {
|
|
46
|
+
return {
|
|
47
|
+
found: false,
|
|
48
|
+
code: InvalidFill.DepositIdOutOfRange,
|
|
49
|
+
reason: `Cannot find historical deposit for fill with unsafe deposit ID ${fill.depositId}.`,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
43
52
|
if (fill.originChainId !== spokePoolClient.chainId) {
|
|
44
53
|
throw new Error(`OriginChainId mismatch (${fill.originChainId} != ${spokePoolClient.chainId})`);
|
|
45
54
|
}
|
|
@@ -123,6 +123,17 @@ export function chainIsL1(chainId: number): boolean {
|
|
|
123
123
|
return [CHAIN_IDs.MAINNET, CHAIN_IDs.SEPOLIA].includes(chainId);
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Determines whether a chain ID runs on an EVM-like execution layer.
|
|
128
|
+
* @param chainId Chain ID to evaluate.
|
|
129
|
+
* @returns True if chain corresponding to chainId has an EVM-like execution layer.
|
|
130
|
+
*/
|
|
131
|
+
export function chainIsEvm(chainId: number): boolean {
|
|
132
|
+
chainId;
|
|
133
|
+
// TODO: Fix when we support non-EVM chains.
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
|
|
126
137
|
/**
|
|
127
138
|
* Determines whether a chain ID has the capacity for having its USDC bridged via CCTP.
|
|
128
139
|
* @param chainId Chain ID to evaluate.
|
package/src/utils/SpokeUtils.ts
CHANGED
|
@@ -209,7 +209,7 @@ export async function getBlockRangeForDepositId(
|
|
|
209
209
|
export async function getDepositIdAtBlock(contract: Contract, blockTag: number): Promise<BigNumber> {
|
|
210
210
|
const _depositIdAtBlock = await contract.numberOfDeposits({ blockTag });
|
|
211
211
|
const depositIdAtBlock = toBN(_depositIdAtBlock);
|
|
212
|
-
// Sanity check to ensure that the deposit ID is
|
|
212
|
+
// Sanity check to ensure that the deposit ID is greater than or equal to zero.
|
|
213
213
|
if (depositIdAtBlock.lt(bnZero)) {
|
|
214
214
|
throw new Error("Invalid deposit count");
|
|
215
215
|
}
|