@@ -18,18 +18,14 @@ export const updateAccountBalances = async (plugin: RunTab, dispatch: React.Disp
1818export const fillAccountsList = async ( plugin : RunTab , dispatch : React . Dispatch < any > ) => {
1919 try {
2020 dispatch ( fetchAccountsListRequest ( ) )
21- const promise = plugin . blockchain . getAccounts ( )
21+ try {
22+ let accounts = await plugin . blockchain . getAccounts ( )
23+ if ( ! accounts ) accounts = [ ]
2224
23- promise . then ( async ( accounts : string [ ] ) => {
2425 const loadedAccounts = { }
2526
26- if ( ! accounts ) accounts = [ ]
27- // allSettled is undefined..
28- // so the current promise (all) will finish when:
29- // - all the promises resolve
30- // - at least one reject
31- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all
32- for ( const account of accounts ) {
27+
28+ for ( const account of accounts ) {
3329 const balance = await plugin . blockchain . getBalanceInEther ( account )
3430 loadedAccounts [ account ] = shortenAddress ( account , balance )
3531 }
@@ -40,9 +36,9 @@ export const fillAccountsList = async (plugin: RunTab, dispatch: React.Dispatch<
4036 if ( ! ( Object . keys ( loadedAccounts ) . includes ( toChecksumAddress ( selectedAddress ) ) ) ) setAccount ( dispatch , null )
4137 }
4238 dispatch ( fetchAccountsListSuccess ( loadedAccounts ) )
43- } ) . catch ( ( e ) => {
39+ } catch ( e ) {
4440 dispatch ( fetchAccountsListFailed ( e . message ) )
45- } )
41+ }
4642 } catch ( e ) {
4743 dispatch ( displayPopUp ( `Cannot get account list: ${ e } ` ) )
4844 }
0 commit comments