Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaspai committed Feb 7, 2024
1 parent 3e68234 commit 3e3e5ed
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/utils/DepositUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { validateFillForDeposit } from "./FlowUtils";
import { getCurrentTime } from "./TimeUtils";
import { isDefined } from "./TypeGuards";
import { isDepositFormedCorrectly } from "./ValidatorUtils";
import { isSlowFillRequest, isV2Deposit, isV3Deposit, isV3Fill } from "./V3Utils";
import { isV2Deposit, isV2Fill, isV3Deposit } from "./V3Utils";

// Load a deposit for a fill if the fill's deposit ID is outside this client's search range.
// This can be used by the Dataworker to determine whether to give a relayer a refund for a fill
Expand Down Expand Up @@ -98,10 +98,10 @@ export async function queryHistoricalDepositForFill(
if (isDefined(cachedDeposit)) {
deposit = cachedDeposit as DepositWithBlock;
} else {
if (isSlowFillRequest(fill) || isV3Fill(fill)) {
deposit = await spokePoolClient.findDepositV3(fill.depositId, fill.destinationChainId, fill.depositor);
} else {
if (isV2Fill(fill)) {
deposit = await spokePoolClient.findDeposit(fill.depositId, fill.destinationChainId, fill.depositor);
} else {
deposit = await spokePoolClient.findDepositV3(fill.depositId, fill.destinationChainId, fill.depositor);
}
if (cache) {
await setDepositInCache(deposit, getCurrentTime(), cache, DEFAULT_CACHING_TTL);
Expand Down
6 changes: 2 additions & 4 deletions src/utils/FlowUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,16 @@ export function validateFillForDeposit(
}

// If fill is a slow fill request, then deposit must be a v3 deposit or return false.
if (isSlowFillRequest(fill)) {
if (isV3Deposit(deposit)) {
if (isSlowFillRequest(fill) && !isV2Fill(fill) && isV3Deposit(deposit)) {
return V3_DEPOSIT_COMPARISON_KEYS.every((key) => {

Check warning on line 75 in src/utils/FlowUtils.ts

View workflow job for this annotation

GitHub Actions / Lint

Delete `··`
if (fillFieldsToIgnore.includes(key)) {

Check warning on line 76 in src/utils/FlowUtils.ts

View workflow job for this annotation

GitHub Actions / Lint

Delete `··`
return true;

Check warning on line 77 in src/utils/FlowUtils.ts

View workflow job for this annotation

GitHub Actions / Lint

Delete `··`
}

Check warning on line 78 in src/utils/FlowUtils.ts

View workflow job for this annotation

GitHub Actions / Lint

Delete `··`
return fill[key] !== undefined && fill[key].toString() === deposit[key]?.toString();

Check warning on line 79 in src/utils/FlowUtils.ts

View workflow job for this annotation

GitHub Actions / Lint

Delete `··`
});

Check warning on line 80 in src/utils/FlowUtils.ts

View workflow job for this annotation

GitHub Actions / Lint

Delete `··`
}
} else {
// If fill is a fill, then compare the fill to the correct V2 or V3 type of deposit.
if (isV2Deposit(deposit) && isV2Fill(fill as Fill)) {
if (isV2Deposit(deposit) && isV2Fill(fill)) {
return V2_DEPOSIT_COMPARISON_KEYS.every((key) => {
if (fillFieldsToIgnore.includes(key)) {
return true;
Expand Down
1 change: 1 addition & 0 deletions src/utils/V3Utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
Fill,
FillType,
SlowFillRequest,
V2Deposit,
V2Fill,
V2RelayData,
Expand Down

0 comments on commit 3e3e5ed

Please sign in to comment.