1
1
import { useEffect , useRef } from 'react' ;
2
+
2
3
import { getNetworkConfigFromApi , useGetAccountFromApi } from 'apiCalls' ;
3
4
import {
4
5
DEVNET_CHAIN_ID ,
@@ -15,6 +16,7 @@ import {
15
16
import { loginAction } from 'reduxStore/commonActions' ;
16
17
import { useDispatch , useSelector } from 'reduxStore/DappProviderContext' ;
17
18
import {
19
+ accountSelector ,
18
20
addressSelector ,
19
21
ledgerAccountSelector
20
22
} from 'reduxStore/selectors/accountInfoSelectors' ;
@@ -52,34 +54,38 @@ import {
52
54
refreshAccount
53
55
} from 'utils/account' ;
54
56
import { parseNavigationParams } from 'utils/parseNavigationParams' ;
55
-
56
57
import { isContract } from 'utils/smartContracts' ;
58
+
57
59
import {
58
60
getOperaProvider ,
59
61
getCrossWindowProvider ,
60
62
getExtensionProvider ,
61
63
getPasskeyProvider ,
62
64
processModifiedAccount ,
63
65
getMetamaskProvider ,
64
- getIframeProvider
66
+ getIframeProvider ,
67
+ handleGuardianWarning
65
68
} from './helpers' ;
66
69
import { useSetLedgerProvider } from './hooks' ;
67
70
68
71
let initalizingLedger = false ;
69
72
70
73
export function ProviderInitializer ( ) {
74
+ const { loginMethod, iframeLoginType } = useSelector ( loginInfoSelector ) ;
75
+
71
76
const network = useSelector ( networkSelector ) ;
72
77
const walletAddress = useSelector ( walletAddressSelector ) ;
73
78
const walletConnectLogin = useSelector ( walletConnectLoginSelector ) ;
74
- const { loginMethod, iframeLoginType } = useSelector ( loginInfoSelector ) ;
75
79
const walletLogin = useSelector ( walletLoginSelector ) ;
76
80
const address = useSelector ( addressSelector ) ;
77
81
const ledgerAccount = useSelector ( ledgerAccountSelector ) ;
78
82
const ledgerLogin = useSelector ( ledgerLoginSelector ) ;
79
83
const isLoggedIn = useSelector ( isLoggedInSelector ) ;
80
84
const chainID = useSelector ( chainIDSelector ) ;
81
85
const tokenLogin = useSelector ( tokenLoginSelector ) ;
86
+ const userAccount = useSelector ( accountSelector ) ;
82
87
const nativeAuthConfig = tokenLogin ?. nativeAuthConfig ;
88
+
83
89
const loginService = useLoginService (
84
90
nativeAuthConfig ? nativeAuthConfig : false
85
91
) ;
@@ -124,6 +130,12 @@ export function ProviderInitializer() {
124
130
setLedgerAccountInfo ( ) ;
125
131
} , [ ledgerAccount , isLoggedIn , ledgerData ] ) ;
126
132
133
+ useEffect ( ( ) => {
134
+ if ( isLoggedIn && userAccount . address ) {
135
+ handleGuardianWarning ( userAccount ) ;
136
+ }
137
+ } , [ isLoggedIn , userAccount ] ) ;
138
+
127
139
// We need to get the roundDuration for networks that do not support websocket (e.g. sovereign)
128
140
// The round duration is used for polling interval
129
141
async function refreshNetworkConfig ( ) {
0 commit comments