Skip to content

Commit

Permalink
fix(protocol): Add EtherTransferred event to EtherVault #12971
Browse files Browse the repository at this point in the history
  • Loading branch information
bxmmm1 authored Jan 18, 2023
1 parent e3c8243 commit 5791f3a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/protocol/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ETHERSCAN_API_KEY=ABC123ABC123ABC123ABC123ABC123ABC1
PRIVATE_KEY=0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1
LOG_LEVEL=DEBUG
REPORT_GAS=true
3 changes: 3 additions & 0 deletions packages/protocol/contracts/bridge/EtherVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ contract EtherVault is EssentialContract {

event Authorized(address indexed addr, bool authorized);

event EtherTransferred(address indexed to, uint256 amount);

/*********************
* Modifiers *
*********************/
Expand Down Expand Up @@ -70,6 +72,7 @@ contract EtherVault is EssentialContract {
*/
function receiveEther(uint256 amount) public onlyAuthorized nonReentrant {
msg.sender.sendEther(amount);
emit EtherTransferred(msg.sender, amount);
}

/**
Expand Down
8 changes: 8 additions & 0 deletions packages/protocol/test/etherVault/EtherVault.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit 5791f3a

Please sign in to comment.