This PR includes a fix for the problem of not getting the gas estimation right for the approvals before the actual transaction.
First, it updates the internal state before deciding if it's even needed to modify the current approval.
Only if the current approval is not enough for the desired amount, it will trigger a reset transaction (setting the approvals to zero), and immediately after that, it triggers the normally approve transaction with the exact amount entered by the user.
These changes did not require the library to be modified.
Test scenarios
You gotta have at least 5 USTD in the Ethereum chain and some ETH to pay the fees.
Here you can check your current approval state. To do that, use the allowed read function using your address as the first argument and the bridge contract (0x9c5ebCbE531aA81bD82013aBF97401f5C6111d76) as the second.
If you need to change the approval, go to the write tab, and use the approve function with the contract address as the spender and the value with the amount desired (enter 1000000 for 1USDT)
select USDT from the Ethereum blockchain as the origin
select Telos EVM as the destination
play with different values and check all of them pass throw with no errors
Cases are:
1 - you have More approval than you are willing to transfer. Best case: you don't need to approve anything.
2 - you cave 0 approval. Normal case: This will cause you to only approve the Transaction without resetting anything.
3 - you have some but not enough approval. Rarest case: This will trigger the reset and then the exact approval you need.
Fixes #101
Description
This PR includes a fix for the problem of not getting the gas estimation right for the approvals before the actual transaction.
approve
transaction with the exact amount entered by the user.These changes did not require the library to be modified.
Test scenarios
You gotta have at least 5 USTD in the Ethereum chain and some ETH to pay the fees.
go to USDT contract code on etherscan.
allowed
read function using your address as the first argument and the bridge contract (0x9c5ebCbE531aA81bD82013aBF97401f5C6111d76) as the second.approve
function with the contract address as the spender and the value with the amount desired (enter1000000
for 1USDT)select USDT from the Ethereum blockchain as the origin
select Telos EVM as the destination
play with different values and check all of them pass throw with no errors
Cases are: 1 - you have More approval than you are willing to transfer. Best case: you don't need to approve anything. 2 - you cave 0 approval. Normal case: This will cause you to only approve the Transaction without resetting anything. 3 - you have some but not enough approval. Rarest case: This will trigger the reset and then the exact approval you need.
Screenshots
telos-bridge--resetting-approvals.webm