From 5791f3af85df462cc5aabbdf2b14d957d49c9f00 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Wed, 18 Jan 2023 12:55:49 +0100 Subject: [PATCH] fix(protocol): Add EtherTransferred event to EtherVault #12971 --- packages/protocol/.env.example | 1 + packages/protocol/contracts/bridge/EtherVault.sol | 3 +++ packages/protocol/test/etherVault/EtherVault.test.ts | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/packages/protocol/.env.example b/packages/protocol/.env.example index f01c43a636d..093b2fdede0 100644 --- a/packages/protocol/.env.example +++ b/packages/protocol/.env.example @@ -1,3 +1,4 @@ ETHERSCAN_API_KEY=ABC123ABC123ABC123ABC123ABC123ABC1 PRIVATE_KEY=0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1 LOG_LEVEL=DEBUG +REPORT_GAS=true \ No newline at end of file diff --git a/packages/protocol/contracts/bridge/EtherVault.sol b/packages/protocol/contracts/bridge/EtherVault.sol index 310b2360b2c..14715c07618 100644 --- a/packages/protocol/contracts/bridge/EtherVault.sol +++ b/packages/protocol/contracts/bridge/EtherVault.sol @@ -35,6 +35,8 @@ contract EtherVault is EssentialContract { event Authorized(address indexed addr, bool authorized); + event EtherTransferred(address indexed to, uint256 amount); + /********************* * Modifiers * *********************/ @@ -70,6 +72,7 @@ contract EtherVault is EssentialContract { */ function receiveEther(uint256 amount) public onlyAuthorized nonReentrant { msg.sender.sendEther(amount); + emit EtherTransferred(msg.sender, amount); } /** diff --git a/packages/protocol/test/etherVault/EtherVault.test.ts b/packages/protocol/test/etherVault/EtherVault.test.ts index 9d64ec18860..a3606f05c46 100644 --- a/packages/protocol/test/etherVault/EtherVault.test.ts +++ b/packages/protocol/test/etherVault/EtherVault.test.ts @@ -112,6 +112,14 @@ describe("EtherVault", function () { originalBalance.add(amount).sub(gasUsed) ); }); + + it("emits EtherTransferred event upon success", async () => { + const amount = 69; + + await expect(etherVault.connect(authorized).receiveEther(amount)) + .to.emit(etherVault, "EtherTransferred") + .withArgs(authorized.address, amount); + }); }); describe("authorize()", async function () {