diff --git a/src/App.vue b/src/App.vue index 109be82..6b8c650 100644 --- a/src/App.vue +++ b/src/App.vue @@ -18,6 +18,7 @@ import { watchAccount, watchNetwork, watchContractEvent, + watchWalletClient, getAccount, getNetwork, getPublicClient, @@ -38,6 +39,7 @@ const showPanel = ref(false); const eventWatch = ref(null); const netWorkEvent = ref(null); const memeSacrificedEvent = ref(null); +const clientClientEvent = ref(null); isMobile.value = isMobileFunc(); onUnmounted(() => { @@ -45,6 +47,8 @@ onUnmounted(() => { eventWatch.value(); netWorkEvent.value(); + memeSacrificedEvent.value(); + clientClientEvent.value(); console.log("unsubscribe"); }); const handleWindowSizeChange = () => { @@ -64,36 +68,25 @@ function isMobileFunc() { } } provide("isMobile", isMobile); +provide("showPanel", showPanel); onMounted(async () => { window.addEventListener("resize", handleWindowSizeChange); handleWindowSizeChange(); - // initContracts await walletStore.init(); - await tokenStore.initV2(); - await memeBurnerStore.init(); - await rewardLockerStore.init(); - await memeBurnerStore.init(); - // await multiCallStore.init(); - //Memeburner Contract const account = getAccount(); - + const network = getNetwork(); + console.log("netWork", network); console.log("account", account); if (account.address) { walletStore.address = account.address; walletStore.connected = true; + var walletClient123 = await getWalletClient(); + console.log("walletClient123123123", walletClient123); } - //init - roundsStore.currentRound = parseInt( - await memeBurnerStore.getCurrentRound() - ); - console.log("roundsStore.currentRound", roundsStore.currentRound); - roundsStore.activeRound = roundsStore.currentRound; - await roundsStore.fillRound(roundsStore.activeRound); - //events eventWatch.value = watchAccount(async (account) => { console.log("account123", account); @@ -111,10 +104,13 @@ onMounted(async () => { chainObject = chain; } var walletClient = await getWalletClient({ + account: account.address, chainId: chainObject.id, }); walletStore.walletClient = walletClient; await memeBurnerStore.init(); + console.log("hierabc"); + await tokenStore.initV2(); } else { walletStore.address = null; walletStore.connected = false; @@ -141,6 +137,29 @@ onMounted(async () => { await roundsStore.updateCurrentRound(token); } ); + + clientClientEvent.value = watchWalletClient( + { + chainId: network.chain.id, + }, + (walletClient) => { + walletStore.walletClient = walletClient; + console.log("wc123", walletClient); + } + ); + + await tokenStore.initV2(); + await memeBurnerStore.init(); + await rewardLockerStore.init(); + await memeBurnerStore.init(); + + //init + roundsStore.currentRound = parseInt( + await memeBurnerStore.getCurrentRound() + ); + console.log("roundsStore.currentRound", roundsStore.currentRound); + roundsStore.activeRound = roundsStore.currentRound; + await roundsStore.fillRound(roundsStore.activeRound); }); diff --git a/src/components/Navbar.vue b/src/components/Navbar.vue index 563c3ee..8cf3f7d 100644 --- a/src/components/Navbar.vue +++ b/src/components/Navbar.vue @@ -7,8 +7,7 @@ const emit = defineEmits(["showPanel"]); const walletStore = useWalletStoreV2(); const { connected, address } = storeToRefs(walletStore); const isMobile = inject("isMobile"); - -const showPanel = ref(false); +const showPanel = inject("showPanel"); const showNavbar = ref(true); const lastScrollPosition = ref(0); @@ -67,10 +66,10 @@ onBeforeUnmount(() => {