Skip to content

Commit 4f83f54

Browse files
authored
improve(SpokePool): Pass fillCompleted and relayer to acrossMessageHandler (#279)
* improve(SpokePool): Pass fillCompleted and relayer to acrossMessageHandler Signed-off-by: nicholaspai <[email protected]> * fix test Signed-off-by: nicholaspai <[email protected]> --------- Signed-off-by: nicholaspai <[email protected]>
1 parent 19d3c5a commit 4f83f54

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

contracts/SpokePool.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ interface AcrossMessageHandler {
2020
function handleAcrossMessage(
2121
address tokenSent,
2222
uint256 amount,
23+
bool fillCompleted,
24+
address relayer,
2325
bytes memory message
2426
) external;
2527
}
@@ -1244,6 +1246,8 @@ abstract contract SpokePool is
12441246
AcrossMessageHandler(relayExecution.updatedRecipient).handleAcrossMessage(
12451247
relayData.destinationToken,
12461248
amountToSend,
1249+
relayFills[relayExecution.relayHash] >= relayData.amount,
1250+
msg.sender,
12471251
relayExecution.updatedMessage
12481252
);
12491253
}

contracts/test/AcrossMessageHandlerMock.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ contract AcrossMessageHandlerMock is AcrossMessageHandler {
77
function handleAcrossMessage(
88
address tokenSent,
99
uint256 amount,
10+
bool fillCompleted,
11+
address relayer,
1012
bytes memory message
1113
) external override {}
1214
}

test/SpokePool.Relay.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,37 @@ describe("SpokePool Relayer Logic", async function () {
312312
expect(acrossMessageHandler.handleAcrossMessage).to.have.been.calledOnceWith(
313313
weth.address,
314314
consts.amountToRelay,
315+
false,
316+
relayer.address,
317+
"0x1234"
318+
);
319+
});
320+
it("Handler is called with correct params", async function () {
321+
const acrossMessageHandler = await createFake("AcrossMessageHandlerMock");
322+
const { relayData } = getRelayHash(
323+
depositor.address,
324+
acrossMessageHandler.address,
325+
consts.firstDepositId,
326+
consts.originChainId,
327+
consts.destinationChainId,
328+
weth.address,
329+
undefined,
330+
undefined,
331+
undefined,
315332
"0x1234"
316333
);
317334

318-
// The collateral should have not unwrapped to ETH and then transferred to recipient.
319-
expect(await weth.balanceOf(acrossMessageHandler.address)).to.equal(consts.amountToRelay);
335+
// Handler is called with full fill and relayer address.
336+
await spokePool
337+
.connect(depositor)
338+
.fillRelay(...getFillRelayParams(relayData, relayData.amount, consts.destinationChainId));
339+
expect(acrossMessageHandler.handleAcrossMessage).to.have.been.calledOnceWith(
340+
weth.address,
341+
relayData.amount.mul(consts.totalPostFeesPct).div(toBN(consts.oneHundredPct)),
342+
true, // True because fill completed deposit.
343+
depositor.address, // Custom relayer
344+
"0x1234"
345+
);
320346
});
321347
it("Self-relay transfers no tokens", async function () {
322348
const largeRelayAmount = consts.amountToSeedWallets.mul(100);
@@ -654,6 +680,8 @@ async function testfillRelayWithUpdatedDeposit(depositorAddress: string) {
654680
expect(acrossMessageHandler.handleAcrossMessage).to.have.been.calledOnceWith(
655681
relayData.destinationToken,
656682
amountActuallySent,
683+
false,
684+
relayer.address,
657685
updatedMessage
658686
);
659687

0 commit comments

Comments
 (0)