@@ -12,6 +12,7 @@ import { AddStakeEvent, ApiValidator, RawValidator, useStakingStore } from './st
1212import { ENV_MAIN , STAKING_CONTRACT_ADDRESS } from './lib/Constants' ;
1313import { reportToSentry } from './lib/Sentry' ;
1414import { useAccountStore } from './stores/Account' ;
15+ import { useDemoStore } from './stores/Demo' ;
1516
1617let isLaunched = false ;
1718let clientPromise : Promise < Client > ;
@@ -102,6 +103,7 @@ export async function launchNetwork() {
102103 const transactionsStore = useTransactionsStore ( ) ;
103104 const addressStore = useAddressStore ( ) ;
104105 const stakingStore = useStakingStore ( ) ;
106+ const demoStore = useDemoStore ( ) ;
105107
106108 const subscribedAddresses = new Set < string > ( ) ;
107109
@@ -118,7 +120,7 @@ export async function launchNetwork() {
118120 network$ . fetchingTxHistory -- ;
119121
120122 async function updateBalances ( addresses : string [ ] = [ ...balances . keys ( ) ] ) {
121- if ( ! addresses . length ) return ;
123+ if ( ! addresses . length || demoStore . isDemoEnabled ) return ;
122124 await client . waitForConsensusEstablished ( ) ;
123125 const accounts = await retry ( ( ) => client . getAccounts ( addresses ) ) . catch ( reportFor ( 'getAccounts' ) ) ;
124126 if ( ! accounts ) return ;
@@ -303,6 +305,7 @@ export async function launchNetwork() {
303305 } ) ( ) ;
304306
305307 function transactionListener ( plain : PlainTransactionDetails ) {
308+ if ( demoStore . isDemoEnabled ) return ;
306309 if ( plain . recipient === STAKING_CONTRACT_ADDRESS ) {
307310 if ( plain . data . type === 'add-stake' ) {
308311 if ( ! balances . has ( plain . sender ) && 'staker' in plain . data ) {
@@ -340,6 +343,7 @@ export async function launchNetwork() {
340343 }
341344
342345 function subscribe ( addresses : string [ ] ) {
346+ if ( demoStore . isDemoEnabled ) return false ;
343347 client . addTransactionListener ( transactionListener , addresses ) ;
344348 updateBalances ( addresses ) ;
345349 updateStakes ( addresses ) ;
@@ -349,6 +353,7 @@ export async function launchNetwork() {
349353 // Subscribe to new addresses (for balance updates and transactions)
350354 // Also remove logged out addresses from fetched (so that they get fetched on next login)
351355 watch ( addressStore . addressInfos , ( ) => {
356+ if ( demoStore . isDemoEnabled ) return ;
352357 const newAddresses : string [ ] = [ ] ;
353358 const removedAddresses = new Set ( subscribedAddresses ) ;
354359
@@ -380,6 +385,7 @@ export async function launchNetwork() {
380385
381386 // Fetch transactions for active address
382387 watch ( [ addressStore . activeAddress , txFetchTrigger ] , ( [ activeAddress , trigger ] ) => {
388+ if ( demoStore . isDemoEnabled ) return ;
383389 const address = activeAddress as string | null ;
384390 if ( ! address || fetchedAddresses . value . includes ( address ) ) return ;
385391 addFetchedAddress ( address ) ;
@@ -428,6 +434,7 @@ export async function launchNetwork() {
428434 // Fetch transactions for proxies
429435 const proxyStore = useProxyStore ( ) ;
430436 watch ( proxyStore . networkTrigger , ( ) => {
437+ if ( demoStore . isDemoEnabled ) return ;
431438 const newProxies : string [ ] = [ ] ;
432439 const addressesToSubscribe : string [ ] = [ ] ;
433440 for ( const proxyAddress of proxyStore . allProxies . value ) {
0 commit comments