Skip to content

Commit 2028d51

Browse files
authored
BM-226: Add Deposit and Withdrawal events (github#53)
1 parent 2d861db commit 2028d51

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

contracts/src/IProofMarket.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ interface IProofMarket {
101101
event RequestFulfilled(uint192 indexed requestId, bytes journal, bytes seal);
102102
/// Event when prover stake is burned for failing to fulfill a request by the deadline.
103103
event LockinStakeBurned(uint192 indexed requestId, uint96 stake);
104+
/// Event when a deposit is made to the proof market.
105+
event Deposit(address indexed account, uint256 value);
106+
/// Event when a withdrawal is made from the proof market.
107+
event Withdrawal(address indexed account, uint256 value);
104108

105109
/// Request is locked when it was not expected to be.
106110
error RequestIsLocked(uint192 requestId);

contracts/src/ProofMarket.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,15 @@ contract ProofMarket is IProofMarket, EIP712 {
149149
// Deposit Ether into the market.
150150
function deposit() public payable {
151151
accounts[msg.sender].balance += msg.value.toUint96();
152+
emit Deposit(msg.sender, msg.value);
152153
}
153154

154155
// Withdraw Ether from the market.
155156
function withdraw(uint256 value) public {
156157
accounts[msg.sender].balance -= value.toUint96();
157158
(bool sent,) = msg.sender.call{value: value}("");
158159
require(sent, "failed to send Ether");
160+
emit Withdrawal(msg.sender, value);
159161
}
160162

161163
// Get the current balance of an account.

contracts/test/ProofMarket.t.sol

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,29 @@ contract ProofMarketTest is Test {
194194
return (fills, assessorSeal);
195195
}
196196

197+
function testDeposit() public {
198+
vm.deal(PROVER_WALLET.addr, 1 ether);
199+
// Deposit funds into the market
200+
vm.expectEmit(true, true, false, true);
201+
emit IProofMarket.Deposit(PROVER_WALLET.addr, 1 ether);
202+
vm.prank(PROVER_WALLET.addr);
203+
proofMarket.deposit{value: 1 ether}();
204+
}
205+
206+
function testWithdraw() public {
207+
// Deposit funds into the market
208+
vm.deal(PROVER_WALLET.addr, 1 ether);
209+
vm.prank(PROVER_WALLET.addr);
210+
proofMarket.deposit{value: 1 ether}();
211+
212+
// Withdraw funds from the market
213+
vm.expectEmit(true, true, false, true);
214+
emit IProofMarket.Withdrawal(PROVER_WALLET.addr, 1 ether);
215+
vm.prank(PROVER_WALLET.addr);
216+
proofMarket.withdraw(1 ether);
217+
checkProofMarketBalance();
218+
}
219+
197220
function testSubmitRequest() public {
198221
// Submit request
199222
Vm.Wallet memory client = createClient(1);

docs/src/market/rfc.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ interface IProofMarket {
160160
event RequestFulfilled(uint192 indexed requestId, bytes journal, bytes seal);
161161
/// Event when prover stake is burned for failing to fulfill a request by the deadline.
162162
event LockinStakeBurned(uint192 indexed requestId, uint96 stake);
163+
/// Event when a deposit is made to the proof market.
164+
event Deposit(address indexed account, uint256 value);
165+
/// Event when a withdrawal is made from the proof market.
166+
event Withdrawal(address indexed account, uint256 value);
163167
164168
/// Request is locked when it was not expected to be.
165169
error RequestIsLocked(uint192 requestId);

0 commit comments

Comments
 (0)