@across-protocol/sdk 4.1.31 → 4.1.32-hotfix.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/cjs/clients/BundleDataClient/BundleDataClient.js +2 -2
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient.d.ts +1 -0
- package/dist/cjs/clients/SpokePoolClient.js +4 -1
- package/dist/cjs/clients/SpokePoolClient.js.map +1 -1
- package/dist/cjs/utils/BundleUtils.js +9 -9
- package/dist/cjs/utils/BundleUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.d.ts +2 -1
- package/dist/cjs/utils/SpokeUtils.js +18 -3
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +2 -2
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient.d.ts +2 -1
- package/dist/esm/clients/SpokePoolClient.js +6 -3
- package/dist/esm/clients/SpokePoolClient.js.map +1 -1
- package/dist/esm/utils/BundleUtils.js +9 -9
- package/dist/esm/utils/BundleUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.d.ts +8 -2
- package/dist/esm/utils/SpokeUtils.js +22 -3
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/types/clients/SpokePoolClient.d.ts +2 -1
- package/dist/types/clients/SpokePoolClient.d.ts.map +1 -1
- package/dist/types/utils/SpokeUtils.d.ts +8 -2
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/clients/BundleDataClient/BundleDataClient.ts +2 -2
- package/src/clients/SpokePoolClient.ts +7 -2
- package/src/utils/BundleUtils.ts +8 -8
- package/src/utils/SpokeUtils.ts +14 -3
package/package.json
CHANGED
|
@@ -1551,8 +1551,8 @@ export class BundleDataClient {
|
|
|
1551
1551
|
// there are no gaps in block timestamps between bundles.
|
|
1552
1552
|
const endBlockForChain = Math.min(_endBlockForChain + 1, spokePoolClient.latestBlockSearched);
|
|
1553
1553
|
const [startTime, _endTime] = [
|
|
1554
|
-
await spokePoolClient.
|
|
1555
|
-
await spokePoolClient.
|
|
1554
|
+
await spokePoolClient.getTimestampForBlock(startBlockForChain),
|
|
1555
|
+
await spokePoolClient.getTimestampForBlock(endBlockForChain),
|
|
1556
1556
|
];
|
|
1557
1557
|
// @dev similar to reasoning above to ensure no gaps between bundle block range timestamps and also
|
|
1558
1558
|
// no overlap, subtract 1 from the end time.
|
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
findDepositBlock,
|
|
49
49
|
getMaxFillDeadlineInRange as getMaxFillDeadline,
|
|
50
50
|
getTimeAt as _getTimeAt,
|
|
51
|
+
getTimestampForBlock as _getTimestampForBlock,
|
|
51
52
|
relayFillStatus,
|
|
52
53
|
} from "../utils/SpokeUtils";
|
|
53
54
|
import { BaseAbstractClient, isUpdateFailureReason, UpdateFailureReason } from "./BaseAbstractClient";
|
|
@@ -844,11 +845,11 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
844
845
|
}
|
|
845
846
|
|
|
846
847
|
/**
|
|
847
|
-
* Retrieves the SpokePool
|
|
848
|
+
* Retrieves the time from the SpokePool contract at a particular block.
|
|
848
849
|
* @returns The time at the specified block tag.
|
|
849
850
|
*/
|
|
850
851
|
public getTimeAt(blockNumber: number): Promise<number> {
|
|
851
|
-
return _getTimeAt(this.spokePool
|
|
852
|
+
return _getTimeAt(this.spokePool, blockNumber);
|
|
852
853
|
}
|
|
853
854
|
|
|
854
855
|
/**
|
|
@@ -949,6 +950,10 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
949
950
|
);
|
|
950
951
|
}
|
|
951
952
|
|
|
953
|
+
public getTimestampForBlock(blockTag: number): Promise<number> {
|
|
954
|
+
return _getTimestampForBlock(this.spokePool.provider, blockTag);
|
|
955
|
+
}
|
|
956
|
+
|
|
952
957
|
/**
|
|
953
958
|
* Find the amount filled for a deposit at a particular block.
|
|
954
959
|
* @param relayData Deposit information that is used to complete a fill.
|
package/src/utils/BundleUtils.ts
CHANGED
|
@@ -74,15 +74,15 @@ export function getImpliedBundleBlockRanges(
|
|
|
74
74
|
|
|
75
75
|
// Load all chain indices in order to map bundle evaluation block numbers to enabled chains list.
|
|
76
76
|
const chainIdIndices = configStoreClient.getChainIdIndicesForBlock(rootBundle.blockNumber);
|
|
77
|
-
const result = rootBundle.bundleEvaluationBlockNumbers.map((
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
const result = rootBundle.bundleEvaluationBlockNumbers.map((_endBlock, i) => {
|
|
78
|
+
const endBlock = _endBlock.toNumber();
|
|
79
|
+
const bundleEndBlock = prevRootBundle?.bundleEvaluationBlockNumbers?.[i]?.toNumber() ?? 0;
|
|
80
|
+
const fromBlock = bundleEndBlock === endBlock ? endBlock : bundleEndBlock + 1;
|
|
81
81
|
const chainId = chainIdIndices[i];
|
|
82
82
|
if (!enabledChainsAtMainnetStartBlock.includes(chainId)) {
|
|
83
|
-
return [endBlock
|
|
83
|
+
return [endBlock, endBlock];
|
|
84
84
|
}
|
|
85
|
-
return [fromBlock, endBlock
|
|
85
|
+
return [fromBlock, endBlock];
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
// Lastly, sanity check the results to catch errors early:
|
|
@@ -91,9 +91,9 @@ export function getImpliedBundleBlockRanges(
|
|
|
91
91
|
result.forEach(([start, end], i) => {
|
|
92
92
|
const chainId = chainIdIndices[i];
|
|
93
93
|
if (enabledChainsAtMainnetStartBlock.includes(chainId)) {
|
|
94
|
-
if (start
|
|
94
|
+
if (start > end) {
|
|
95
95
|
throw new Error(
|
|
96
|
-
`Invalid block range for enabled chain ${chainId}: start block ${start} is greater than
|
|
96
|
+
`Invalid block range for enabled chain ${chainId}: start block ${start} is greater than end block ${end}`
|
|
97
97
|
);
|
|
98
98
|
}
|
|
99
99
|
} else {
|
package/src/utils/SpokeUtils.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { BytesLike, Contract, PopulatedTransaction, providers, utils as ethersUt
|
|
|
3
3
|
import { CHAIN_IDs, MAX_SAFE_DEPOSIT_ID, ZERO_ADDRESS, ZERO_BYTES } from "../constants";
|
|
4
4
|
import { Deposit, FillStatus, FillWithBlock, RelayData } from "../interfaces";
|
|
5
5
|
import { chunk } from "./ArrayUtils";
|
|
6
|
-
import { BigNumber, toBN, bnZero } from "./BigNumberUtils";
|
|
6
|
+
import { bnUint32Max, BigNumber, toBN, bnZero } from "./BigNumberUtils";
|
|
7
7
|
import { keccak256 } from "./common";
|
|
8
8
|
import { isMessageEmpty } from "./DepositUtils";
|
|
9
9
|
import { isDefined } from "./TypeGuards";
|
|
@@ -59,10 +59,21 @@ export function populateV3Relay(
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
* Retrieves the
|
|
62
|
+
* Retrieves the time from the SpokePool contract at a particular block.
|
|
63
63
|
* @returns The time at the specified block tag.
|
|
64
64
|
*/
|
|
65
|
-
export async function getTimeAt(
|
|
65
|
+
export async function getTimeAt(spokePool: Contract, blockNumber: number): Promise<number> {
|
|
66
|
+
const currentTime = await spokePool.getCurrentTime({ blockTag: blockNumber });
|
|
67
|
+
assert(BigNumber.isBigNumber(currentTime) && currentTime.lt(bnUint32Max));
|
|
68
|
+
return currentTime.toNumber();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Retrieves the chain time at a particular block.
|
|
73
|
+
* @note This should be the same as getTimeAt() but can differ in test. These two functions should be consolidated.
|
|
74
|
+
* @returns The chain time at the specified block tag.
|
|
75
|
+
*/
|
|
76
|
+
export async function getTimestampForBlock(provider: providers.Provider, blockNumber: number): Promise<number> {
|
|
66
77
|
const block = await provider.getBlock(blockNumber);
|
|
67
78
|
return block.timestamp;
|
|
68
79
|
}
|