Scaffold-Stark / speedrunstark

SpeedRunStark challenges (Powered by Scaffold-Stark)
https://www.speedrunstark.com
18 stars 18 forks source link

Ch - 1: User account balance shows wrong value #41

Closed gianalarcon closed 6 months ago

gianalarcon commented 6 months ago

Issue Overview

During testing of challenge-1. After I deploy the contract the UI shows the correct balance of user account,it is 1000 eth

Screenshot from 2024-04-27 23-39-57

Then, I do a stake 0.5 operation(I clicked in stake0.5 button ) , so it should decrease the balance of the current user account by 0.5 eth Screenshot from 2024-04-27 23-03-12

In the right top corner of this pic I expect to see 999.499 eth but UI shows 999.0499 eth On the same picture you can see I called fn balanceOf and it retrieves the balance from the blockchain, it shows 9994993......

After that I call withdraw operation (click on withdraw button) and I expect to see 999.998 eth but UI shows 999.0998 eth Screenshot from 2024-04-27 23-04-59

Proposed Solutions or Ideas

Fix on UI.

edulanasca commented 6 months ago

@gianalarcon if you're in devnet it takes time to refresh the balance, it's a blockchain thing If you're in sepolia that also takes time to refresh (it happened a lot using Argent)

gianalarcon commented 6 months ago

Same challenge, Other finding, it shows balance of the contract is 4.05eth instead of 4.5eth image

After exploring the code I found the bug here https://github.com/Quantum3-Labs/speedrunstark/blob/602082df2daabbf90449798bb8b6646e96c1f7c8/packages/nextjs/hooks/scaffold-stark/useScaffoldEthBalance.ts#L35