Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add refunds #75

Merged
merged 6 commits into from
Dec 16, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions contracts/l2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ struct L2Deposit {
}

// Authorized: all tickets in this batch are authorized but not claimed
// Claimed: all tickets in this batch are claimed
// Refunded: all tickets in this batch have been refunded, due to inactivity or provable fraud.
// Withdrawn: all tickets in this batch are withdrawn (either claimed or refunded)
enum BatchStatus {
Authorized,
Claimed,
Refunded
Withdrawn
}

struct Batch {
Expand Down Expand Up @@ -131,7 +129,7 @@ contract L2 is SignatureChecker {
"safetyDelay must have passed since authorization timestamp"
);

batch.status = BatchStatus.Claimed;
batch.status = BatchStatus.Withdrawn;
batches[first] = batch;
(bool sent, ) = lpAddress.call{value: batch.total}("");
require(sent, "Failed to send Ether");
Expand Down Expand Up @@ -187,7 +185,7 @@ contract L2 is SignatureChecker {
require(sent, "Failed to send Ether");
}

batches[honestStartNonce].status = BatchStatus.Refunded;
batches[honestStartNonce].status = BatchStatus.Withdrawn;
}

function refund(uint256 index) public {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make sure I understand refund, it:

  • accepts the index of the ticket we want to refund
  • refunds all tickets whose nonce is <= index that have not yet been authorized

?

If so, it probably deserves some documentation to that effect. (And we should put a short statement in the spec.)

Copy link
Contributor Author

@kerzhner kerzhner Dec 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 3068152

Expand All @@ -202,7 +200,7 @@ contract L2 is SignatureChecker {
);
(Batch memory batch, ) = createBatch(nextNonceToAuthorize, index);
batches[nextNonceToAuthorize] = batch;
batch.status = BatchStatus.Refunded;
batch.status = BatchStatus.Withdrawn;
nextNonceToAuthorize = index + 1;

(bool sent, ) = tickets[index].l1Recipient.call{
Expand Down