-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
feat: Upgrade assets controllers to 43 with multichain polling for token lists + detection #28447
Merged
Merged
Changes from 3 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
f024224
upgrade
bergeron cfb46d1
remove unit test
bergeron 2f36b23
Merge branch 'develop' into brian/upgrade-assets-controllers-43
bergeron 25f5ed0
Update LavaMoat policies
metamaskbot 6c216f8
yarn dedupe
bergeron 2822c58
add unit test
bergeron 3d5323a
Update LavaMoat policies
metamaskbot ae198fb
lint
bergeron e1f3843
Merge branch 'brian/upgrade-assets-controllers-43' of github.com:Meta…
bergeron b090b3c
lint and fix test
bergeron 38fc254
onboarding
bergeron 6338a00
fix race condition
bergeron 6b22521
temporarily disable token detection polling
bergeron 5206a35
patch
bergeron 757d880
package json
bergeron abf8e11
fix unit test
bergeron c662098
update sentry state
bergeron 8f1cfb1
sentry state
bergeron 1411c2a
Merge branch 'develop' into brian/upgrade-assets-controllers-43
bergeron 05554a3
Merge branch 'develop' into brian/upgrade-assets-controllers-43
bergeron 729d07d
update patch
bergeron 21fcda3
dont poll when locked
bergeron 8b6391f
remove commented out code
bergeron b635ab8
fix e2e tests
bergeron ec38722
fix unit test
bergeron 79a451f
avoid calling hook different order
bergeron 979a3af
lint
bergeron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
...s-controllers-npm-42.0.0-57b3d695bb.patch → ...s-controllers-npm-43.1.1-c223d56176.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import React, { ReactNode } from 'react'; | ||
import useCurrencyRatePolling from '../hooks/useCurrencyRatePolling'; | ||
import useTokenRatesPolling from '../hooks/useTokenRatesPolling'; | ||
import useTokenDetectionPolling from '../hooks/useTokenDetectionPolling'; | ||
import useTokenListPolling from '../hooks/useTokenListPolling'; | ||
|
||
// This provider is a step towards making controller polling fully UI based. | ||
// Eventually, individual UI components will call the use*Polling hooks to | ||
// poll and return particular data. This polls globally in the meantime. | ||
export const AssetPollingProvider = ({ children }: { children: ReactNode }) => { | ||
useCurrencyRatePolling(); | ||
useTokenRatesPolling(); | ||
useTokenDetectionPolling(); | ||
useTokenListPolling(); | ||
|
||
return <>{children}</>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useSelector } from 'react-redux'; | ||
import { | ||
getNetworkConfigurationsByChainId, | ||
getUseTokenDetection, | ||
} from '../selectors'; | ||
import { | ||
tokenDetectionStartPolling, | ||
tokenDetectionStopPollingByPollingToken, | ||
} from '../store/actions'; | ||
import useMultiPolling from './useMultiPolling'; | ||
|
||
const useTokenDetectionPolling = () => { | ||
const useTokenDetection = useSelector(getUseTokenDetection); | ||
const networkConfigurations = useSelector(getNetworkConfigurationsByChainId); | ||
const chainIds = Object.keys(networkConfigurations); | ||
|
||
useMultiPolling({ | ||
startPolling: tokenDetectionStartPolling, | ||
stopPollingByPollingToken: tokenDetectionStopPollingByPollingToken, | ||
input: useTokenDetection ? [chainIds] : [], | ||
}); | ||
|
||
return { | ||
}; | ||
}; | ||
|
||
export default useTokenDetectionPolling; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { useSelector } from 'react-redux'; | ||
import { | ||
getNetworkConfigurationsByChainId, | ||
getPetnamesEnabled, | ||
getUseTokenDetection, | ||
getUseTransactionSimulations, | ||
} from '../selectors'; | ||
import { | ||
tokenListStartPolling, | ||
tokenListStopPollingByPollingToken, | ||
} from '../store/actions'; | ||
import useMultiPolling from './useMultiPolling'; | ||
|
||
const useTokenListPolling = () => { | ||
const networkConfigurations = useSelector(getNetworkConfigurationsByChainId); | ||
const useTokenDetection = useSelector(getUseTokenDetection); | ||
const useTransactionSimulations = useSelector(getUseTransactionSimulations); | ||
const petnamesEnabled = useSelector(getPetnamesEnabled); | ||
|
||
const enabled = | ||
useTokenDetection || petnamesEnabled || useTransactionSimulations; | ||
|
||
useMultiPolling({ | ||
startPolling: tokenListStartPolling, | ||
stopPollingByPollingToken: tokenListStopPollingByPollingToken, | ||
input: enabled ? Object.keys(networkConfigurations) : [], | ||
}); | ||
|
||
return { | ||
}; | ||
}; | ||
|
||
export default useTokenListPolling; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I've never understood the purpose of
preventPollingOnNetworkRestart
, so I don't know whether it still makes sense. When it's set to true, all it seems to do is reset the state when switching chains. Keeping it around for now.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.
I saw this same thing and had similar thoughts. Sounds good