-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add refunds #75
Conversation
8d55c1f
to
13643ae
Compare
At the moment, L2 contract is not concerned with WHY a batch has been withdrawn
A batch can be created to: - Authorize tickets - Refund tickets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except for the vulnerability, this looks great!
contracts/l2.sol
Outdated
@@ -189,4 +189,25 @@ contract L2 is SignatureChecker { | |||
|
|||
batches[honestStartNonce].status = BatchStatus.Refunded; | |||
} | |||
|
|||
function refund(uint256 index) public { |
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 3068152
contracts/l2.sol
Outdated
|
||
function refund(uint256 index) public { | ||
require( | ||
block.timestamp > tickets[index].timestamp + maxAuthDelay, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this logic makes me think that tickets[index].timestamp
would be more clear if it was renamed to tickets[index].createdAt
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it: 1b63880
Also add documentation for the refund function
A customer can refund a ticket after the authorization window expires. When refund is called for a ticket:
This PR also reduces
BatchStatus
to 2 types: Authorized and Withdrawn.Fixes #74