-
-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(suite-native): move coin enabling to settings menu
- Loading branch information
Showing
26 changed files
with
246 additions
and
78 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "@suite-native/coin-enabling", | ||
"version": "1.0.0", | ||
"private": true, | ||
"license": "See LICENSE.md in repo root", | ||
"sideEffects": false, | ||
"main": "src/index", | ||
"scripts": { | ||
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'", | ||
"depcheck": "yarn g:depcheck", | ||
"type-check": "yarn g:tsc --build" | ||
}, | ||
"dependencies": { | ||
"@reduxjs/toolkit": "1.9.5", | ||
"@suite-common/wallet-config": "workspace:*", | ||
"@suite-common/wallet-core": "workspace:*", | ||
"@suite-native/atoms": "workspace:*", | ||
"@suite-native/discovery": "workspace:*", | ||
"@suite-native/feature-flags": "workspace:*", | ||
"react": "18.2.0", | ||
"react-native": "0.74.1", | ||
"react-redux": "8.0.7" | ||
} | ||
} |
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,7 @@ | ||
import { AsyncThunkAction } from '@reduxjs/toolkit'; | ||
|
||
declare module 'redux' { | ||
export interface Dispatch { | ||
<TThunk extends AsyncThunkAction<any, any, any>>(thunk: TThunk): ReturnType<TThunk>; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
suite-native/coin-enabling/src/components/DiscoveryCoinsFilter.tsx
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,36 @@ | ||
import { useDispatch } from 'react-redux'; | ||
|
||
import { VStack, Text, HStack, Switch, Card } from '@suite-native/atoms'; | ||
import { NetworkSymbol } from '@suite-common/wallet-config'; | ||
import { toggleEnabledDiscoveryNetworkSymbol } from '@suite-native/discovery'; | ||
|
||
import { useCoinEnabling } from '../hooks/useCoinEnabling'; | ||
|
||
export const DiscoveryCoinsFilter = () => { | ||
const dispatch = useDispatch(); | ||
|
||
const { enabledNetworkSymbols, availableNetworks } = useCoinEnabling(); | ||
|
||
const uniqueNetworkSymbols = [...new Set(availableNetworks.map(n => n.symbol))]; | ||
|
||
return ( | ||
<Card> | ||
<VStack spacing="small"> | ||
<Text variant="titleSmall">Enable discovery of networks</Text> | ||
<VStack> | ||
{uniqueNetworkSymbols.map((networkSymbol: NetworkSymbol) => ( | ||
<HStack justifyContent="space-between" key={networkSymbol}> | ||
<Text>{networkSymbol.toUpperCase()}</Text> | ||
<Switch | ||
onChange={() => | ||
dispatch(toggleEnabledDiscoveryNetworkSymbol(networkSymbol)) | ||
} | ||
isChecked={enabledNetworkSymbols.includes(networkSymbol)} | ||
/> | ||
</HStack> | ||
))} | ||
</VStack> | ||
</VStack> | ||
</Card> | ||
); | ||
}; |
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 { FeatureFlag, FeatureFlagsRootState, useFeatureFlag } from '@suite-native/feature-flags'; | ||
import { | ||
selectAreTestnetsEnabled, | ||
selectEnabledDiscoveryNetworkSymbols, | ||
selectDiscoverySupportedNetworks, | ||
DiscoveryConfigSliceRootState, | ||
} from '@suite-native/discovery'; | ||
import { DeviceRootState } from '@suite-common/wallet-core'; | ||
|
||
export const useCoinEnabling = () => { | ||
const [isCoinEnablingActive] = useFeatureFlag(FeatureFlag.IsCoinEnablingActive); | ||
const areTestnetsEnabled = useSelector(selectAreTestnetsEnabled); | ||
const availableNetworks = useSelector((state: DeviceRootState) => | ||
selectDiscoverySupportedNetworks(state, areTestnetsEnabled), | ||
); | ||
const enabledNetworkSymbols = useSelector( | ||
(state: DiscoveryConfigSliceRootState & DeviceRootState & FeatureFlagsRootState) => | ||
selectEnabledDiscoveryNetworkSymbols(state, areTestnetsEnabled), | ||
); | ||
|
||
const applyDiscoveryChanges = () => { | ||
// TODO: remove disabled network accounts and run discovery check | ||
}; | ||
|
||
return { | ||
isCoinEnablingActive, | ||
enabledNetworkSymbols, | ||
availableNetworks, | ||
applyDiscoveryChanges, | ||
}; | ||
}; |
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,2 @@ | ||
export * from './components/DiscoveryCoinsFilter'; | ||
export * from './hooks/useCoinEnabling'; |
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,15 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { "outDir": "libDev" }, | ||
"references": [ | ||
{ | ||
"path": "../../suite-common/wallet-config" | ||
}, | ||
{ | ||
"path": "../../suite-common/wallet-core" | ||
}, | ||
{ "path": "../atoms" }, | ||
{ "path": "../discovery" }, | ||
{ "path": "../feature-flags" } | ||
] | ||
} |
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
51 changes: 0 additions & 51 deletions
51
suite-native/module-dev-utils/src/components/DiscoveryCoinsFilter.tsx
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.