-
Notifications
You must be signed in to change notification settings - Fork 53
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
Bug in NFT and FT allowances in the precompile #67
Comments
This bug is also affecting granting an allowance to an account using ERC20 standard calls. Currently, users cannot grant an allowance to an account and complete a token transfer. Please see the link below for the repo, an explanation of what is being done in the repo, and steps to reproduce: This below code example does the following: Steps to reproduce: https://gitpod.io/#snapshot/7f7e3241-10f9-443b-88d0-cae4d43222c8
|
To add to this discussion: HederaTokenService.sol approveNFT method takes a uint256 input for the serial (per the gitpod example) however it dynamically binds to send to the precompile using the IHederaTokenService which expects an int64. If I create my own method making the low-level call dynamically to precompile via IHederaTokenService passing an int64 then I get it to work. This is not the only case of inconsistency, unfortunately.
|
HI @Burstall thanks for highlighting this. @ed-marquez and @a-ridley thanks for the original issue. |
The code from gitpod completes succesfully without any errors and the |
The issue is resolved. I had to make the following change to the smart contract: use delegatecall instead of call. The CRYPTO_APPROVE_ALLOWANCE transaction completes successfully. |
looks good now on the latest set I saw. I see things moving around a little and am trying to keep up to date accordingly. thanks. |
Description
When approving allowances for FTs and NFTs via the precompiles, the process does not complete as expected because there's a bug where the precompile doesn't seem to understand that a token and an account are already associated.
This same process works OK and as expected when done through the SDKs.
In the FT/NFT example:
The Issue:
The allowance transfer throws the error:
SPENDER_DOES_NOT_HAVE_ALLOWANCE
. See the error file for console output and additional details. Approval-Allowance bug - error message.txtThe crypto transfer tx in Alice's tx history in HashScan correctly shows that she doesn't have the allowance.
The operator tx history, specifically the failed contract call for approving the allowance FALSELY shows:
TOKEN_NOT_ASSOCIATED_TO_ACCOUNT
.The console output (and tx history) shows that both Alice and Bob are associated with the token. As a test, the treasury already sent some tokens to Alice using the SDK before calling the contract.
So even though Alice already owns tokens, the precompile seems to think that Alice is not associated to the token => thus the allowance approval via precompile fails => thus the approved token transfer fails.
Tagging @Nana-EC @tinker-michaelj for visibility. Thank you in advanced team : )
Steps to reproduce
.env
file with your own credentials0_test_precompile_FT.js
and0_test_precompile_NFT.js
Additional context
No response
Hedera network
mainnet, testnet
Version
v2.18
Operating system
Windows
The text was updated successfully, but these errors were encountered: