-
Notifications
You must be signed in to change notification settings - Fork 41
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
Added approveAndCall
to TBTC token
#5
Conversation
approveAndCall is not a part of ERC20 - it was specified in ERC827 and slightly diverged for some implementations. This one is identical to approveAndCall behavior of KEEP token. approveAndCall executes receiveApproval function on the spender as specified in IReceiveApproval interface. Approves spender to withdraw from the caller multiple times, up to the value amount. If this function is called again, it overwrites the current allowance with the provided value. Reverts if the approval operation reverted or if receiveApproval call on the spender reverted.
3ecf33c
to
4799cdf
Compare
|
||
pragma solidity <0.9.0; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; |
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 think we can remove this import
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.
🔥 in d671d1a
@@ -5,6 +5,37 @@ pragma solidity <0.9.0; | |||
import "./ERC20WithPermit.sol"; | |||
import "./MisfundRecovery.sol"; | |||
|
|||
interface IReceiveApproval { |
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.
In TBTC v1 this interface is named ITokenRecipient. Was there a reason why we don't want to name it the same?
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.
In retrospect, I think ITokenRecipient
is too broad. It is about a specific way of receiving approval and maybe receiving tokens if the implementation decides for that.
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.
Sure, I'm okay with both, but what I liked about ITokenRecipient
is that it tells me right away in its name that this contract will receive tokens. IReceiveApproval(spender).receiveApproval
also looks a bit redundant.
Depends on #4
approveAndCall
is not a part of ERC20 - it was specified in ERC827 andslightly diverged for some implementations. This one is identical to
approveAndCall
behavior of KEEP token.approveAndCall
executesreceiveApproval
function on the spender asspecified in
IReceiveApproval
interface. Approves spender to withdrawfrom the caller multiple times, up to the value amount. If this function
is called again, it overwrites the current allowance with the provided
value. Reverts if the approval operation reverted or if
receiveApproval
call on the spender reverted.