@@ -13,7 +13,7 @@ import { storedAllowlist, storedCredentials } from '@shared/storage/access';
13
13
import { GRPCTIMEOUT , mainnet } from '@shared/constants/networkConfiguration' ;
14
14
import { atomWithChromeStorage } from './utils' ;
15
15
import { selectedAccountAtom } from './account' ;
16
- import { selectedIdentityIndexAtom } from './identity' ;
16
+ import { identityProvidersAtom , selectedIdentityIndexAtom } from './identity' ;
17
17
18
18
export const encryptedSeedPhraseAtom = atomWithChromeStorage < EncryptedData | undefined > (
19
19
ChromeStorageKey . SeedPhrase ,
@@ -37,8 +37,12 @@ export const networkConfigurationAtom = atom<NetworkConfiguration, NetworkConfig
37
37
const selectedAccount = credentials ?. length ? credentials [ 0 ] ?. address : undefined ;
38
38
const accountPromise = set ( selectedAccountAtom , selectedAccount ) ;
39
39
40
+ // As identity providers are different per network, we must also reset the list of cached
41
+ // identity providers when the network configuration is changed.
42
+ const identityProviderPromise = set ( identityProvidersAtom , [ ] ) ;
43
+
40
44
// Wait for all the derived state of a network change to be done before broadcasting
41
- await Promise . all ( [ networkPromise , identityPromise , accountPromise ] ) ;
45
+ await Promise . all ( [ networkPromise , identityPromise , accountPromise , identityProviderPromise ] ) ;
42
46
43
47
const allowlist = await storedAllowlist . get ( ) ;
44
48
popupMessageHandler . broadcast ( EventType . ChainChanged , networkConfiguration . genesisHash , {
0 commit comments