Skip to content
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

refactor: Remove useArbTokenBridge from store #1479

Draft
wants to merge 28 commits into
base: master
Choose a base branch
from

Conversation

chrstph-dvx
Copy link
Contributor

@chrstph-dvx chrstph-dvx commented Jan 26, 2024

You should read this comment before reviewing it as it will be easier to review

@chrstph-dvx chrstph-dvx requested review from a team, douglance and fionnachan January 26, 2024 19:55
@chrstph-dvx chrstph-dvx linked an issue Jan 26, 2024 that may be closed by this pull request
@cla-bot cla-bot bot added the cla-signed label Jan 26, 2024
Copy link

vercel bot commented Jan 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
arbitrum-token-bridge ❌ Failed (Inspect) Mar 20, 2024 11:12am

@@ -853,6 +854,7 @@ export function TransferPanelMain({
networks.destinationChain,
isTestnetMode,
setNetworks,
actions.app,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be better if we just kept this out so we don't introduce unnecessary rerenders

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actions.app is the same reference every time, it doesn't cause rerender

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff on this file is actually fairly simple:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be browsed from commit 7dc7d8c

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes on this files are only to wrap the returned functions with useCallback

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes on this files are mostly to wrap the returned functions with useCallback. One more change is making sure that the connector.change listener is properly cleaned up on unmount

@chrstph-dvx chrstph-dvx self-assigned this Jan 30, 2024
@chrstph-dvx chrstph-dvx marked this pull request as ready for review January 30, 2024 18:45
@chrstph-dvx chrstph-dvx changed the title WIP: Remove useArbTokenBridge from store refactor: Remove useArbTokenBridge from store Jan 30, 2024
@chrstph-dvx chrstph-dvx mentioned this pull request Jan 31, 2024
3 tasks
@@ -85,12 +86,12 @@ export function useClaimWithdrawal(): UseClaimWithdrawalResult {
throw 'Signer is undefined'
}
if (tx.assetType === AssetType.ETH) {
res = await arbTokenBridge.eth.triggerOutbox({
res = await ethTriggerOutbox({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious, why don't we simply call eth.triggerOutbox?

yarn.lock Outdated
Comment on lines 1287 to 1291
"@ledgerhq/connect-kit-loader@^1.0.1":
version "1.1.8"
resolved "https://registry.yarnpkg.com/@ledgerhq/connect-kit-loader/-/connect-kit-loader-1.1.8.tgz#6cc32191660dd9d6e8f89047af09b0f201e30190"
integrity sha512-mDJsOucVW8m3Lk2fdQst+P74SgiKebvq1iBk4sXLbADQOwhL9bWGaArvO+tW7jPJZwEfSPWBdHcHoYi11XAwZw==

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove

Comment on lines -171 to -113
l1NetworkChainId: parentChain.id,
l2NetworkChainId: childChain.id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now the Injector has a few unused vars from hooks

Comment on lines 29 to 37
if (
state.app.l1NetworkChainId !== newChainId &&
state.app.l2NetworkChainId !== newChainId
state.app.sourceChainId !== newChainId &&
state.app.destinationChainId !== newChainId
) {
// only reset the selected token if we are not switching between the pair of l1-l2 networks.
// we dont want to reset the token if we are switching from Goerli to Arbitrum Goerli for example
// because we are maybe in the process of auto switching the network and triggering deposit or withdraw
state.app.selectedToken = null
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this condition causes the bug we had with selected token (which is hackily fixed now by resetting the selected token to null whenever we change source/destination chain id in TransferPanelMain)

here with this code snippet, when user's source is Ethereum, and destination is Arb One, and then user changes destination chain to Arb Nova, the source chain id === new chain id, so the selected token remains the same but the token data should have been different

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use useNetworksRelationship inside useArbTokenBridge
3 participants