import { createRouter, createWebHistory } from 'vue-router' import HomeView from '../views/HomeView.vue' import { useWalletStoreV2 } from "@/stores/walletV2"; import { useTokenStore } from "@/stores/tokens"; import { useContractStore } from "@/stores/contracts"; import { useMemeburnerStore } from "@/stores/memeburner"; import { useRewardLockerStore } from "@/stores/rewardlocker"; import { useMultiCallStore } from "@/stores/multicall"; import { useRoundsStore } from "@/stores/rounds"; import { getAccount, } from "@wagmi/core"; const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), routes: [ { path: "/", name: "home", component: HomeView, }, // { // path: "/about", // name: "about", // // route level code-splitting // // this generates a separate chunk (About.[hash].js) for this route // // which is lazy-loaded when the route is visited. // component: () => import("../views/AboutView.vue"), // }, { path: "/test", name: "Test", component: () => import("../views/TestView.vue"), }, { path: "/wagmi", name: "Wagmi", component: () => import("../views/WagmiView.vue"), }, { path: "/profile", name: "Profile", component: () => import("../views/ProfileView.vue"), }, { path: "/cycle", name: "Cycle", component: () => import("../views/CycleView.vue"), }, ], }); router.beforeEach(async (to, from) => { //init const tokenStore = useTokenStore(); const memeBurnerStore = useMemeburnerStore(); const rewardLockerStore = useRewardLockerStore(); const roundsStore = useRoundsStore(); const walletStore = useWalletStoreV2(); if (!walletStore.publicClient) { await walletStore.init(); await tokenStore.initV2(); await memeBurnerStore.init(); await rewardLockerStore.init(); await memeBurnerStore.init(); if (!roundsStore.currentRound) { roundsStore.currentRound = parseInt(await memeBurnerStore.getCurrentRound()); console.log("roundsStore.currentRound", roundsStore.currentRound); roundsStore.activeRound = roundsStore.currentRound; } } // initContracts return true; }); export default router