-
Notifications
You must be signed in to change notification settings - Fork 66
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
Conversation
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.
Minor remarks 🙂
@@ -21,6 +21,8 @@ contract Liquidity is ERC721Full { | |||
|
|||
struct ExitData { | |||
uint256 exitBondSize; | |||
address exitInitiator; | |||
bool bondReturned; |
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.
instead of having such a flag we could set exitInitiator
to address(0)
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 @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? 🤔
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.
but should we need that? it is just an invalid claim
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.
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"); |
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 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) { |
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.
maybe assert
here. this would eliminate need to use if else
structure
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.
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?
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.
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.
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.
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.
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.
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
PaymentExitDataModel.StandardExit[] memory exits = paymentExitGame.standardExits( | ||
exitIdList | ||
); | ||
if (exits[0].utxoPos == 0) { |
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.
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) { |
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.
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.
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.
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.
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.
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" |
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.
"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"); |
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.
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"); |
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.
Thanks @pik694, doing it on the next one.
Closes #629