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

[fast_exits] Pay exit bond to exit initiator #638

Merged
merged 7 commits into from
Jun 10, 2020

Conversation

souradeep-das
Copy link
Contributor

Closes #629

pik694
pik694 previously approved these changes Jun 3, 2020
Copy link
Contributor

@pik694 pik694 left a comment

Choose a reason for hiding this comment

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

Minor remarks 🙂

@@ -21,6 +21,8 @@ contract Liquidity is ERC721Full {

struct ExitData {
uint256 exitBondSize;
address exitInitiator;
bool bondReturned;
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of having such a flag we could set exitInitiator to address(0)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes @pik694, but in that case we wouldn't be able to differentiate between a wrong/invalid exitId provided and an already claimed bond in case we wan't to throw distinct messages for the users? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

but should we need that? it is just an invalid claim

Copy link
Contributor Author

@souradeep-das souradeep-das Jun 3, 2020

Choose a reason for hiding this comment

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

Lets remove it if we dont need to give out the specific reason(error message). Your call 😄

*/
function getExitBond(uint160 exitId) public {
require(exitData[exitId].bondReturned == false, "Exit Bond Already returned");
require(exitData[exitId].exitInitiator != address(0), "ExitId is invalid");
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe that this check is not necessary as the check blow is essential

PaymentExitDataModel.StandardExit[] memory exits = paymentExitGame.standardExits(
exitIdList
);
if (exits[0].utxoPos == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe assert here. this would eliminate need to use if else structure

Copy link
Contributor Author

@souradeep-das souradeep-das Jun 3, 2020

Choose a reason for hiding this comment

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

ohh if we use assert here, we cant return back an error message? Do we want that? also require in the middle might not be a good idea?

Copy link
Contributor

Choose a reason for hiding this comment

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

require in the middle might not be a good idea?

I don't think it matters. And if-else + revert is really just the same thing.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah...I know we are still handling the exit processed check in another issue.
However, can we put exit.utxoPos == 0 into a function now (and the part in getWithdraw too) with naming like: (eg.) checkExitProcessed so make this a bit easier to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And if-else + revert is really just the same thing

Thats true! I'll change to require for better readability then
Also having a function here to checkExitProcessed will make it simpler to make changes later

boolafish
boolafish previously approved these changes Jun 5, 2020
PaymentExitDataModel.StandardExit[] memory exits = paymentExitGame.standardExits(
exitIdList
);
if (exits[0].utxoPos == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

require in the middle might not be a good idea?

I don't think it matters. And if-else + revert is really just the same thing.

PaymentExitDataModel.StandardExit[] memory exits = paymentExitGame.standardExits(
exitIdList
);
if (exits[0].utxoPos == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

ah...I know we are still handling the exit processed check in another issue.
However, can we put exit.utxoPos == 0 into a function now (and the part in getWithdraw too) with naming like: (eg.) checkExitProcessed so make this a bit easier to read.

@souradeep-das souradeep-das dismissed stale reviews from boolafish and pik694 via 5a4aa7e June 5, 2020 16:33
@souradeep-das souradeep-das requested review from pik694 and boolafish June 5, 2020 16:41
boolafish
boolafish previously approved these changes Jun 9, 2020
Copy link
Contributor

@boolafish boolafish left a comment

Choose a reason for hiding this comment

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

lol bad timing for this comment and not give this earlier, would suggest we rename getWithdrawal and getExitbond to be sth not start with get. It would be confused as a getter function potentially.

Probably getWithdrawal -> withdrawExit or retreiveProcessedExit and getExitBond -> withdrawExitBond, retreiveExitBond ?

Anyway approval given, if you'd like to make the change just ping me and I will approve again.

boolafish
boolafish previously approved these changes Jun 9, 2020
@souradeep-das souradeep-das dismissed stale reviews from pik694 and boolafish via c5d4e11 June 9, 2020 16:06
@souradeep-das souradeep-das requested a review from pik694 June 9, 2020 16:25
Copy link
Contributor

@pik694 pik694 left a comment

Choose a reason for hiding this comment

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

Just minor typos. Can be merged in some next PR, or now, or never - up to you.

}

/**
* @dev Get Amount from contract after exit is processed - (to be updated)
* @param exitId The exit id
*/
function getWithdrawal(uint160 exitId) public {
function withdrawExit(uint160 exitId) public {
require(
super.ownerOf(exitId) == msg.sender,
"Only the NFT owner of the respective exit can get the withdrawal"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"Only the NFT owner of the respective exit can get the withdrawal"
"Only the NFT owner of the respective exit can withdraw"

* @param exitId The exit id
*/
function withdrawExitBond(uint160 exitId) public {
require(exitData[exitId].exitInitiator != address(0), "Exit Bond does not exist or is already claimed");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
require(exitData[exitId].exitInitiator != address(0), "Exit Bond does not exist or is already claimed");
require(exitData[exitId].exitInitiator != address(0), "Exit Bond does not exist or has already been claimed");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @pik694, doing it on the next one.

@souradeep-das souradeep-das merged commit fef1f7a into master Jun 10, 2020
@souradeep-das souradeep-das deleted the souradeep/fast_exits_bond branch June 10, 2020 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[fast exits] Pay back exit bond
3 participants