forked from InjectiveLabs/injective-helix-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.vue
53 lines (44 loc) · 1.66 KB
/
app.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<script setup lang="ts">
import { Status, StatusType } from '@injectivelabs/utils'
import * as WalletTracker from '@/app/providers/mixpanel/WalletTracker'
import { UnknownTokenStatusKey } from '@/types'
const route = useRoute()
const appStore = useAppStore()
const spotStore = useSpotStore()
const tokenStore = useTokenStore()
const walletStore = useWalletStore()
const derivativeStore = useDerivativeStore()
const sharedWalletStore = useSharedWalletStore()
const { $onError } = useNuxtApp()
const { addTokensToPriceWatchList } = useTokenUsdPrice()
const status = reactive(new Status(StatusType.Loading))
const unknownTokenStatus = reactive(new Status(StatusType.Loading))
onMounted(() => {
const queryMarketId = route.query.marketId as string | undefined
// coinGeckoIds only exist on verified tokens (manually added tokens to injective-list)
addTokensToPriceWatchList(tokenStore.verifiedTokens)
tokenStore.fetchUntrackedTokens().finally(() => unknownTokenStatus.setIdle())
Promise.all([
walletStore.init(),
spotStore.initFromTradingPage(queryMarketId),
derivativeStore.initFromTradingPage(queryMarketId)
])
.catch($onError)
.then(() => {
if (sharedWalletStore.isUserConnected) {
WalletTracker.trackWalletAddress(sharedWalletStore.injectiveAddress)
}
})
.finally(() => status.setIdle())
// Actions that should't block the app from loading
Promise.all([appStore.init(), appStore.fetchBlockHeight()])
})
provide(UnknownTokenStatusKey, unknownTokenStatus)
</script>
<template>
<AppHocLoading is-helix wrapper-class="h-screen" :status="status">
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</AppHocLoading>
</template>