-
Notifications
You must be signed in to change notification settings - Fork 214
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
fix: Fix useBalance delay when switching networks #1755
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
4d3c52b
to
98f6e67
Compare
packages/arb-token-bridge-ui/src/hooks/useBalanceOnSourceChain.ts
Outdated
Show resolved
Hide resolved
@@ -82,54 +87,8 @@ describe('useBalance', () => { | |||
expect(erc20Balances).toBeNull() | |||
}) | |||
|
|||
it('getter return null for missing chainId', async () => { |
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.
why is this test deleted?
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.
It became invalid after the changes in useBalance. We accept chainId, not provider anymore
1 | ||
) | ||
jest.mock('../../token-bridge-sdk/utils', () => ({ | ||
getProviderForChainId: function A() { |
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.
What's function A
?
Can't we just use anonymous function () => provider
here?
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.
100% yes, it's a leftover from debug (I would probably rename it to getProviderForChainIdMock
rather than use anonymous function, it's easier to debug
Summary
We have an issue when user would switch source network from network A to network B, and balance from
useBalanceOnSourceChain
would be the balance on network A for a second. This led touseGasEstimate
call despite the balance check.Steps to test