@@ -44,6 +44,8 @@ import {
44
44
WALLET_CONSTS ,
45
45
WALLET_TYPES ,
46
46
AlertsApiService ,
47
+ initWallet ,
48
+ waitForCore ,
47
49
} from ' @soramitsu/soraneo-wallet-web' ;
48
50
import debounce from ' lodash/debounce' ;
49
51
import { Component , Mixins , Watch } from ' vue-property-decorator' ;
@@ -54,15 +56,15 @@ import AppHeader from '@/components/App/Header/AppHeader.vue';
54
56
import AppMenu from ' @/components/App/Menu/AppMenu.vue' ;
55
57
import NodeErrorMixin from ' @/components/mixins/NodeErrorMixin' ;
56
58
import SoraLogo from ' @/components/shared/Logo/Sora.vue' ;
57
- import { PageNames , Components , Language , BreakpointClass , Breakpoint } from ' @/consts' ;
59
+ import { PageNames , Components , Language , BreakpointClass , Breakpoint , WalletPermissions } from ' @/consts' ;
58
60
import { getLocale } from ' @/lang' ;
59
61
import router , { goTo , lazyComponent } from ' @/router' ;
60
62
import { action , getter , mutation , state } from ' @/store/decorators' ;
61
63
import { getMobileCssClasses , preloadFontFace , updateDocumentTitle } from ' @/utils' ;
64
+ import type { NodesConnection } from ' @/utils/connection' ;
62
65
63
66
import type { FeatureFlags } from ' ./store/settings/types' ;
64
67
import type { EthBridgeSettings , SubNetworkApps } from ' ./store/web3/types' ;
65
- import type { ConnectToNodeOptions , Node } from ' ./types/nodes' ;
66
68
import type { History , HistoryItem } from ' @sora-substrate/util' ;
67
69
import type { WhitelistArrayItem } from ' @sora-substrate/util/build/assets/types' ;
68
70
import type { EvmNetwork } from ' @sora-substrate/util/build/bridgeProxy/evm/types' ;
@@ -95,13 +97,15 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
95
97
showNotifsDarkPage = false ;
96
98
responsiveClass = BreakpointClass .LargeDesktop ;
97
99
100
+ @state .settings .appConnection appConnection! : NodesConnection ;
98
101
@state .settings .browserNotifPopupVisibility private browserNotifPopup! : boolean ;
99
102
@state .settings .browserNotifPopupBlockedVisibility private browserNotifPopupBlocked! : boolean ;
100
103
@state .wallet .account .assetsToNotifyQueue assetsToNotifyQueue! : Array <WhitelistArrayItem >;
101
104
@state .referrals .storageReferrer storageReferrer! : string ;
102
105
@state .settings .disclaimerVisibility disclaimerVisibility! : boolean ;
103
106
@state .router .loading pageLoading! : boolean ;
104
107
108
+ @getter .settings .nodeIsConnected nodeIsConnected! : boolean ;
105
109
@getter .settings .chartsEnabled private chartsEnabled! : boolean ;
106
110
@getter .wallet .transactions .firstReadyTx firstReadyTransaction! : Nullable <HistoryItem >;
107
111
@getter .wallet .account .isLoggedIn isSoraAccountConnected! : boolean ;
@@ -114,8 +118,6 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
114
118
endpoint: string ;
115
119
}) => void ;
116
120
117
- @mutation .settings .setDefaultNodes private setDefaultNodes! : (nodes : Array <Node >) => void ;
118
- @mutation .settings .setNetworkChainGenesisHash private setNetworkChainGenesisHash! : (hash ? : string ) => void ;
119
121
@mutation .settings .setFaucetUrl private setFaucetUrl! : (url : string ) => void ;
120
122
@mutation .settings .setFeatureFlags private setFeatureFlags! : (data : FeatureFlags ) => void ;
121
123
@mutation .settings .setBrowserNotifsPopupEnabled private setBrowserNotifsPopup! : (flag : boolean ) => void ;
@@ -125,15 +127,14 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
125
127
@mutation .settings .setScreenBreakpointClass private setScreenBreakpointClass! : (cssClass : string ) => void ;
126
128
@mutation .referrals .unsubscribeFromInvitedUsers private unsubscribeFromInvitedUsers! : FnWithoutArgs ;
127
129
@mutation .web3 .setEvmNetworksApp private setEvmNetworksApp! : (data : EvmNetwork []) => void ;
130
+ @mutation .web3 .setSubNetworkApps private setSubNetworkApps! : (data : SubNetworkApps ) => void ;
128
131
@mutation .web3 .setEthBridgeSettings private setEthBridgeSettings! : (settings : EthBridgeSettings ) => Promise <void >;
129
132
@mutation .referrals .resetStorageReferrer private resetStorageReferrer! : FnWithoutArgs ;
130
133
131
- @action .web3 .setSubNetworkApps private setSubNetworkApps! : (data : SubNetworkApps ) => void ;
132
134
@action .wallet .settings .setApiKeys private setApiKeys! : (apiKeys : WALLET_TYPES .ApiKeysObject ) => Promise <void >;
133
135
@action .wallet .subscriptions .resetNetworkSubscriptions private resetNetworkSubscriptions! : AsyncFnWithoutArgs ;
134
136
@action .wallet .subscriptions .resetInternalSubscriptions private resetInternalSubscriptions! : AsyncFnWithoutArgs ;
135
137
@action .wallet .subscriptions .activateNetwokSubscriptions private activateNetwokSubscriptions! : AsyncFnWithoutArgs ;
136
- @action .settings .connectToNode private connectToNode! : (options : ConnectToNodeOptions ) => Promise <void >;
137
138
@action .settings .setLanguage private setLanguage! : (lang : Language ) => Promise <void >;
138
139
@action .settings .setBlockNumber private setBlockNumber! : AsyncFnWithoutArgs ;
139
140
@action .settings .fetchAdsArray private fetchAdsArray! : AsyncFnWithoutArgs ;
@@ -239,7 +240,6 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
239
240
await this .setEthBridgeSettings (data .ETH_BRIDGE );
240
241
this .setFeatureFlags (data ?.FEATURE_FLAGS );
241
242
this .setSoraNetwork (data .NETWORK_TYPE );
242
- this .setDefaultNodes (data ?.DEFAULT_NETWORKS );
243
243
this .setEvmNetworksApp (data .EVM_NETWORKS_IDS );
244
244
this .setSubNetworkApps (data .SUB_NETWORKS );
245
245
@@ -253,9 +253,9 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
253
253
if (data .FAUCET_URL ) {
254
254
this .setFaucetUrl (data .FAUCET_URL );
255
255
}
256
- if ( data . CHAIN_GENESIS_HASH ) {
257
- this .setNetworkChainGenesisHash (data . CHAIN_GENESIS_HASH );
258
- }
256
+
257
+ this .appConnection . setDefaultNodes (data ?. DEFAULT_NETWORKS );
258
+ this . appConnection . setNetworkChainGenesisHash ( data ?. CHAIN_GENESIS_HASH );
259
259
260
260
// connection to node
261
261
await this .runAppConnectionToNode ();
@@ -269,10 +269,6 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
269
269
window .addEventListener (' resize' , this .setResponsiveClassDebounced );
270
270
}
271
271
272
- private get isSwapPageWithCharts(): boolean {
273
- return this .$route .name === PageNames .Swap && this .chartsEnabled ;
274
- }
275
-
276
272
private get mobileCssClasses(): string [] | undefined {
277
273
return getMobileCssClasses ();
278
274
}
@@ -281,10 +277,6 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
281
277
return this .$route .name === PageNames .About ;
282
278
}
283
279
284
- get isCurrentPageTooWide(): boolean {
285
- return this .isAboutPage || this .isSwapPageWithCharts || this .$route .name === PageNames .Tokens ;
286
- }
287
-
288
280
get dsProviderClasses(): string [] | BreakpointClass {
289
281
return this .mobileCssClasses ?.length ? [... this .mobileCssClasses , this .responsiveClass ] : this .responsiveClass ;
290
282
}
@@ -295,9 +287,6 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
295
287
if (this .$route .name ) {
296
288
cssClasses .push (` ${baseClass }--${this .$route .name .toLowerCase ()} ` );
297
289
}
298
- if (this .isSwapPageWithCharts ) {
299
- cssClasses .push (` ${baseClass }--has-charts ` );
300
- }
301
290
return cssClasses ;
302
291
}
303
292
@@ -373,12 +362,28 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
373
362
}
374
363
375
364
private async runAppConnectionToNode() {
365
+ const walletOptions = {
366
+ permissions: WalletPermissions ,
367
+ appName: WALLET_CONSTS .TranslationConsts .Polkaswap ,
368
+ };
369
+
376
370
try {
377
- await this .connectToNode ({
378
- onError : (error ) => this .handleNodeError (error , true ), // prefer notification on connection success
379
- onDisconnect: this .handleNodeDisconnect ,
380
- onReconnect: this .handleNodeReconnect ,
381
- });
371
+ // Run in parallel
372
+ // 1) Wallet core initialization (node connection independent)
373
+ // 2) Connection to node
374
+ await Promise .all ([
375
+ waitForCore (walletOptions ),
376
+ this .appConnection .connect ({
377
+ onError: this .handleNodeError ,
378
+ onDisconnect: this .handleNodeDisconnect ,
379
+ onReconnect: this .handleNodeConnect ,
380
+ }),
381
+ ]);
382
+
383
+ // Wallet node connection dependent logic
384
+ if (! this .isWalletLoaded ) {
385
+ await initWallet (walletOptions );
386
+ }
382
387
} catch (error ) {
383
388
// we handled error using callback, do nothing
384
389
}
@@ -568,13 +573,12 @@ i.icon-divider {
568
573
}
569
574
570
575
@include desktop {
571
- .app-main {
572
- & .app-main--swap.app-main--has-charts {
576
+ .app-main--swap {
577
+ & .app-main {
573
578
.app-menu {
574
579
& :not (.collapsed ) {
575
580
position : relative ;
576
581
}
577
-
578
582
& .collapsed {
579
583
& + .app-body {
580
584
margin-left : 74px ;
0 commit comments