@@ -17,6 +17,7 @@ import { launchElectrum } from './electrum';
1717import { launchPolygon } from './ethers' ;
1818import { useAccountStore } from './stores/Account' ;
1919import { useFiatStore } from './stores/Fiat' ;
20+ import { useDemoStore } from './stores/Demo' ;
2021import { useSettingsStore } from './stores/Settings' ;
2122import router from './router' ;
2223import { i18n , loadLanguage } from './i18n/i18n-setup' ;
@@ -48,14 +49,21 @@ Vue.use(VuePortal, { name: 'Portal' });
4849
4950async function start ( ) {
5051 initPwa ( ) ; // Must be called as soon as possible to catch early browser events related to PWA
51- await initStorage ( ) ; // Must be awaited before starting Vue
52- initTrials ( ) ; // Must be called after storage was initialized, can affect Config
53- // Must run after VueCompositionApi has been enabled and after storage was initialized. Could potentially run in
54- // background and in parallel to syncFromHub, but RedirectRpcClient.init does not actually run async code anyways.
55- await initHubApi ( ) ;
56- syncFromHub ( ) ; // Can run parallel to Vue initialization; must be called after storage was initialized.
57-
58- serviceWorkerHasUpdate . then ( ( hasUpdate ) => useSettingsStore ( ) . state . updateAvailable = hasUpdate ) ;
52+ const { isDemoEnabled } = useDemoStore ( ) ;
53+
54+ if ( ! isDemoEnabled . value ) {
55+ await initStorage ( ) ; // Must be awaited before starting Vue
56+ initTrials ( ) ; // Must be called after storage was initialized, can affect Config
57+ // Must run after VueCompositionApi has been enabled and after storage was initialized. Could potentially run in
58+ // background and in parallel to syncFromHub, but RedirectRpcClient.init does not actually run async code
59+ // anyways.
60+ await initHubApi ( ) ;
61+ syncFromHub ( ) ; // Can run parallel to Vue initialization; must be called after storage was initialized.
62+
63+ serviceWorkerHasUpdate . then ( ( hasUpdate ) => useSettingsStore ( ) . state . updateAvailable = hasUpdate ) ;
64+ } else {
65+ useDemoStore ( ) . initialize ( router ) ;
66+ }
5967
6068 // Update exchange rates every 2 minutes or every 10 minutes, depending on whether the Wallet is currently actively
6169 // used. If an update takes longer than that time due to a provider's rate limit, wait until the update succeeds
@@ -94,28 +102,34 @@ async function start() {
94102 const { language } = useSettingsStore ( ) ;
95103 loadLanguage ( language . value ) ;
96104
97- startSentry ( ) ;
105+ if ( ! isDemoEnabled . value ) {
106+ startSentry ( ) ;
107+ }
98108
99109 const { config } = useConfig ( ) ;
100110
101- if ( config . environment !== ENV_MAIN ) {
111+ if ( isDemoEnabled . value ) {
112+ document . title = 'Nimiq Wallet Demo' ;
113+ } else if ( config . environment !== ENV_MAIN ) {
102114 document . title = 'Nimiq Testnet Wallet' ;
103115 }
104116
105- watch ( ( ) => {
106- if ( ! config . fastspot . apiEndpoint || ! config . fastspot . apiKey ) return ;
107- initFastspotApi ( config . fastspot . apiEndpoint , config . fastspot . apiKey ) ;
108- } ) ;
109-
110- watch ( ( ) => {
111- if ( ! config . oasis . apiEndpoint ) return ;
112- initOasisApi ( config . oasis . apiEndpoint ) ;
113- } ) ;
114-
115- watch ( ( ) => {
116- if ( ! config . ten31Pass . enabled ) return ;
117- initKycConnection ( ) ;
118- } ) ;
117+ if ( ! isDemoEnabled . value ) {
118+ watch ( ( ) => {
119+ if ( ! config . fastspot . apiEndpoint || ! config . fastspot . apiKey ) return ;
120+ initFastspotApi ( config . fastspot . apiEndpoint , config . fastspot . apiKey ) ;
121+ } ) ;
122+
123+ watch ( ( ) => {
124+ if ( ! config . oasis . apiEndpoint ) return ;
125+ initOasisApi ( config . oasis . apiEndpoint ) ;
126+ } ) ;
127+
128+ watch ( ( ) => {
129+ if ( ! config . ten31Pass . enabled ) return ;
130+ initKycConnection ( ) ;
131+ } ) ;
132+ }
119133
120134 // Make reactive config accessible in components
121135 Vue . prototype . $config = config ;
0 commit comments