Skip to content

Commit

Permalink
feat(spokePoolClient): add getter for slow fill requests
Browse files Browse the repository at this point in the history
  • Loading branch information
melisaguevara committed Feb 14, 2025
1 parent f885c0f commit 35dcdd7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/clients/SpokePoolClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,18 @@ export class SpokePoolClient extends BaseAbstractClient {
return Object.values(this.depositHashes).find(({ depositId: _depositId }) => _depositId.eq(depositId));
}

/**
* Retrieves a list of slow fill requests from the SpokePool contract.
* @returns A list of slow fill requests.
*/
public getSlowFillRequests(): SlowFillRequestWithBlock[] {
return sortEventsAscendingInPlace(Object.values(this.slowFillRequests));
}

/**
* Find a SlowFillRequested event based on its deposit RelayData.
* @param relayData RelayData field for the SlowFill request.
* @returns The corresponding SlowFIllRequest event if found, otherwise undefined.
* @returns The corresponding SlowFillRequest event if found, otherwise undefined.
*/
public getSlowFillRequest(relayData: RelayData): SlowFillRequestWithBlock | undefined {
const messageHash = getMessageHash(relayData.message);
Expand Down
9 changes: 6 additions & 3 deletions test/SpokePoolClient.v3Events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,10 @@ describe("SpokePoolClient: Event Filtering", function () {
}
await destinationSpokePoolClient.update(slowFillRequestedEvents);

// Should receive _all_ fills submitted on the destination chain.
// Should receive _all_ slow fills submitted on the destination chain.
const slowFillRequests = destinationSpokePoolClient.getSlowFillRequests();
expect(slowFillRequests.length).to.equal(requests.length);

requests.forEach((event) => {
let { args } = event;
expect(args).to.not.be.undefined;
Expand Down Expand Up @@ -363,7 +366,7 @@ describe("SpokePoolClient: Event Filtering", function () {
expect(deposit.depositId).to.equal(depositEvent.args!.depositId);

const v3Fill = fillFromDeposit(deposit, relayer);
fillEvents.push(destinationSpokePoolClient.fillV3Relay(v3Fill as FillWithBlock));
fillEvents.push(destinationSpokePoolClient.fillV3Relay(v3Fill as FillWithBlock & { message: string }));
}
await destinationSpokePoolClient.update(filledRelayEvents);

Expand Down Expand Up @@ -447,7 +450,7 @@ describe("SpokePoolClient: Event Filtering", function () {
exclusiveRelayer,
relayer,
depositId: toBN(i),
} as FillWithBlock);
} as FillWithBlock & { message: string });
await originSpokePoolClient.update(["FilledV3Relay"]);
let relay = originSpokePoolClient.getFills().at(-1);
expect(relay).to.exist;
Expand Down

0 comments on commit 35dcdd7

Please sign in to comment.