-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Class FungibleToken
is not checking if onNEP17Payment method exists before calling it. Should it?
#3097
Comments
That's exactly the intended behavior and it's compliant with NEP-17. |
So if a contract wishes to be able to receive tokens, it must implement the callback. This is not stated in the document. What about the part about "the receiver must call abort"? In my use case, I didn't call abort, and it was rejected. In practice, there is no need to fail the transfer. Or is there? |
I agree. thats why i created neo-project/proposals#164 Its to loose currently and miss leading... and contradicts itself. |
NEP-17: "If the receiver is a deployed contract, the function MUST call onNEP17Payment method on receiver contract". There are no conditions, just a method call. No method --- failure, because it MUST be called.
https://github.com/AxLabs/grantshares-contracts/blob/aec526734132f762c99df01bb7642d2b5209c529/src/main/java/com/axlabs/neo/grantshares/GrantSharesTreasury.java#L175 |
So in this case, this code is incorrect: if (ContractManagement.get_contract(to_address) is not None):
if (ContractManagement.has_method(to_address, 'onNEP17Payment', 3)):
contract.call_contract(to_address, 'onNEP17Payment',
args=[from_address, amount, data]) We should use this instead: if (ContractManagement.get_contract(to_address) is not None):
contract.call_contract(to_address, 'onNEP17Payment',
args=[from_address, amount, data]) ? |
The NEP-17 standard states that if a contract wants to refuse an incoming transfer, it MUST call Abort.
The existing FungibleToken implementation does not check if the method exists. This causes transfers to fail if the recipient contract didn't implement the
onNEP17Payment
instead of failing only unless the receiver aborts it. This may be fine, but this isn't what the standard was proposing.Contracts should only call the
onNEP17Payment
callback after checking that it exists, likely usingContractManagement.hasMethod
.Changing the FungibleToken native contract is a huge breaking change. It's easier if we just change the standard to say that smart contract SHOULD check for the onNEP17Payment before calling it.
The text was updated successfully, but these errors were encountered: