feat: add chains dynamicconfig for feature flags (#7389)
* feat: add feature flags dynamic config for chains * fix * add better chainid error checking * quiet linter * refactor & should be quick_route_chains only
This commit is contained in:
parent
3a4dc91e49
commit
cbec108172
10
src/featureFlags/dynamicConfig/index.tsx
Normal file
10
src/featureFlags/dynamicConfig/index.tsx
Normal file
@ -0,0 +1,10 @@
|
||||
import { DynamicConfig, useConfig } from 'statsig-react'
|
||||
|
||||
export enum DynamicConfigName {
|
||||
quickRouteChains = 'quick_route_chains',
|
||||
}
|
||||
|
||||
export function useDynamicConfig(configName: DynamicConfigName): DynamicConfig {
|
||||
const { config } = useConfig(configName)
|
||||
return config
|
||||
}
|
15
src/featureFlags/dynamicConfig/quickRouteChains.ts
Normal file
15
src/featureFlags/dynamicConfig/quickRouteChains.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { ChainId } from '@uniswap/sdk-core'
|
||||
|
||||
import { DynamicConfigName, useDynamicConfig } from '.'
|
||||
|
||||
// eslint-disable-next-line import/no-unused-modules
|
||||
export function useQuickRouteChains(): ChainId[] {
|
||||
const config = useDynamicConfig(DynamicConfigName.quickRouteChains)
|
||||
const chains = config.get('chains', [])
|
||||
if (chains.every((c) => Object.values(ChainId).includes(c))) {
|
||||
return chains as ChainId[]
|
||||
} else {
|
||||
console.error('feature flag config chains contain invalid ChainId')
|
||||
return []
|
||||
}
|
||||
}
|
@ -57,7 +57,7 @@ export function useUpdateFlag() {
|
||||
}
|
||||
|
||||
export function FeatureFlagsProvider({ children }: { children: ReactNode }) {
|
||||
// TODO(vm): `isLoaded` to `true` so `App.tsx` will render. Later, this will be dependent on
|
||||
// TODO: `isLoaded` to `true` so `App.tsx` will render. Later, this will be dependent on
|
||||
// flags loading from Amplitude, with a timeout.
|
||||
const featureFlags = useAtomValue(featureFlagSettings)
|
||||
const value = {
|
||||
|
Loading…
Reference in New Issue
Block a user