-
Notifications
You must be signed in to change notification settings - Fork 1
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
Claim task part 1 - Solidity with minimal tests #20
Conversation
contracts/beacon/Voucher.sol
Outdated
mapping(bytes32 dealId => VoucherMatchedDeal) _voucherMatchedDeals; | ||
// Save refunded tasks to disable replay attacks. | ||
mapping(bytes32 taskId => bool) _claimedTasks; | ||
} |
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 propose to move mapping(bytes32 taskId => bool) _refundedTasks;
to VoucherHub (for example in order to protect against double refund)
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.
That way we need to move deal/task checking logic to the VoucherHub.
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.
Yes exactly!
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 tend to not prefer this option, because:
- if we do that we need to put all the claim logic in the Hub (otherwise would not work) so there is not much left in the Voucher. Also since the sponsored amount is saved in the Voucher, we will
- either be bouncing back and forth between the voucher and the hub (voucher.claim, hub.claimOnPoco, voucher.computeSponsoredAmount, hub.refund
- or duplicate things (reading PoCo state)
- I am not sure we don't risk cheating the Hub if we don't store voucher addresses.
- The top up feature would probably benefit from the voucher list to make sure the voucher exists (not a very strong argument but it goes in the same direction).
- Design wise, I find it cleaner to not include PoCo logic in the Hub.
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.
Well done
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.
Good thanks!
VoucherHub
contract needs to check that the "refund" request is legit:Option1: check that msg.sender is a voucher created by the hub and put all deal/task verification in
Voucher
contract.a. Compute voucher address and check it contains code => Not valid as users can mint vouchers themselves.
b. Store a mapping of vouchers created by
VoucherHub
.Option2: check that the deal was sponsored by a valid voucher.
a. Store a mapping of all sponsored deals of each voucher ins
VoucherHub
. => This requires duplicating voucher logic in the hub (check deal exists, check task status, ...).=> Approach 1.a is the chosen option.
Tests & coverage: