1
1
import { Network } from '@invariant-labs/a0-sdk'
2
2
import DotIcon from '@mui/icons-material/FiberManualRecord'
3
- import { Button , Grid , Input , Popover , Typography } from '@mui/material'
3
+ import { Box , Button , Grid , Input , Popover , Typography } from '@mui/material'
4
4
import { ISelectNetwork } from '@store/consts/types'
5
5
import classNames from 'classnames'
6
6
import React , { useEffect , useRef , useState } from 'react'
7
7
import useStyles from './styles'
8
+ import { RpcStatus } from '@store/reducers/connection'
9
+ import { RECOMMENDED_RPC_ADDRESS } from '@store/consts/static'
10
+ import icons from '@static/icons'
8
11
9
12
export interface ISelectMainnetRPC {
10
13
networks : ISelectNetwork [ ]
@@ -13,14 +16,16 @@ export interface ISelectMainnetRPC {
13
16
onSelect : ( networkType : Network , rpcAddress : string , rpcName ?: string ) => void
14
17
handleClose : ( ) => void
15
18
activeRPC : string
19
+ rpcStatus : RpcStatus
16
20
}
17
21
export const SelectMainnetRPC : React . FC < ISelectMainnetRPC > = ( {
18
22
networks,
19
23
anchorEl,
20
24
open,
21
25
onSelect,
22
26
handleClose,
23
- activeRPC
27
+ activeRPC,
28
+ rpcStatus
24
29
} ) => {
25
30
const { classes } = useStyles ( )
26
31
@@ -50,8 +55,13 @@ export const SelectMainnetRPC: React.FC<ISelectMainnetRPC> = ({
50
55
setButtonApplied ( true )
51
56
setActiveCustom ( true )
52
57
setAddress ( activeRPC )
58
+ } else {
59
+ setCustomApplied ( false )
60
+ setButtonApplied ( false )
61
+ setActiveCustom ( false )
62
+ setAddress ( '' )
53
63
}
54
- } , [ ] )
64
+ } , [ activeRPC ] )
55
65
56
66
return (
57
67
< Popover
@@ -72,6 +82,15 @@ export const SelectMainnetRPC: React.FC<ISelectMainnetRPC> = ({
72
82
} } >
73
83
< Grid className = { classes . root } >
74
84
< Typography className = { classes . title } > Select mainnet RPC to use</ Typography >
85
+ { rpcStatus === RpcStatus . IgnoredWithError &&
86
+ activeRPC !== RECOMMENDED_RPC_ADDRESS [ Network . Mainnet ] && (
87
+ < div className = { classes . warningContainer } >
88
+ < img className = { classes . warningIcon } src = { icons . warningIcon } alt = 'Warning icon' />
89
+ < Typography className = { classes . warningText } >
90
+ Current RPC might not work properly
91
+ </ Typography >
92
+ </ div >
93
+ ) }
75
94
< Grid className = { classes . list } container alignContent = 'space-around' direction = 'column' >
76
95
{ networks . map ( ( { networkType, rpc, rpcName } ) => (
77
96
< Grid
@@ -89,7 +108,12 @@ export const SelectMainnetRPC: React.FC<ISelectMainnetRPC> = ({
89
108
setButtonApplied ( false )
90
109
handleClose ( )
91
110
} } >
92
- < Typography className = { classes . name } > { rpcName } </ Typography >
111
+ < Box width = '100%' display = 'flex' justifyContent = 'space-between' alignItems = 'center' >
112
+ < Typography className = { classes . name } > { rpcName } </ Typography >
113
+ < Typography className = { classes . recommendedText } >
114
+ { RECOMMENDED_RPC_ADDRESS [ Network . Mainnet ] === rpc && 'RECOMMENDED' }
115
+ </ Typography >
116
+ </ Box >
93
117
< DotIcon className = { classes . dotIcon } />
94
118
</ Grid >
95
119
) ) }
@@ -105,7 +129,9 @@ export const SelectMainnetRPC: React.FC<ISelectMainnetRPC> = ({
105
129
setActiveCustom ( true )
106
130
inputRef . current ?. focus ( )
107
131
} } >
108
- < Typography className = { classes . name } > Custom RPC</ Typography >
132
+ < Box width = '100%' display = 'flex' justifyContent = 'space-between' alignItems = 'center' >
133
+ < Typography className = { classes . name } > Custom RPC</ Typography >
134
+ </ Box >
109
135
< DotIcon className = { classes . dotIcon } />
110
136
</ Grid >
111
137
</ Grid >
0 commit comments