@@ -77,11 +77,22 @@ const scanForWallets = async () => {
77
77
} ) ;
78
78
79
79
walletInfo . value = await aeSdk . value . connectToWallet ( foundWallet . getConnection ( ) )
80
+ status . value = 'asking_account_access'
80
81
await aeSdk . value . subscribeAddress ( 'subscribe' , 'current' )
81
- await connectToNode ( walletInfo . value . networkId )
82
+ await fetchAccountInfo ( )
83
+ }
84
+
85
+ const isSupportedNetwork = ( ) => {
86
+ const { networkId, status } = toRefs ( state )
87
+ const res = networkId . value === process . env . VUE_APP_NETWORK_ID
88
+ if ( ! res ) {
89
+ status . value = `failed: Connected to wrong network. Please switch to ${ process . env . VUE_APP_NETWORK_NAME } in your wallet.`
90
+ }
91
+ return res
82
92
}
83
93
84
94
const fetchAccountInfo = async ( ) => {
95
+ if ( ! isSupportedNetwork ( ) ) return ;
85
96
const { balance, status } = toRefs ( state )
86
97
status . value = 'fetching_info'
87
98
balance . value = await state . aeSdk . getBalance ( state . aeSdk . address , {
@@ -91,12 +102,9 @@ const fetchAccountInfo = async () => {
91
102
}
92
103
93
104
const connectToNode = async ( selectedNetworkId ) => {
94
- const { networkId, status, aeSdk } = toRefs ( state )
95
- if ( selectedNetworkId !== process . env . VUE_APP_NETWORK_ID ) {
96
- status . value = `failed: Connected to wrong network. Please switch to ${ process . env . VUE_APP_NETWORK_NAME } in your wallet.`
97
- return
98
- }
105
+ const { networkId, aeSdk } = toRefs ( state )
99
106
networkId . value = selectedNetworkId
107
+ if ( ! isSupportedNetwork ( ) ) return
100
108
aeSdk . value . selectNode ( selectedNetworkId )
101
- await fetchAccountInfo ( )
109
+ if ( aeSdk . value . addresses ( ) . length ) await fetchAccountInfo ( )
102
110
}
0 commit comments