update profilepage
This commit is contained in:
+104
-3
@@ -1,5 +1,9 @@
|
||||
import './assets/sass/main.sass'
|
||||
import { useWalletStoreV2 } from "@/stores/walletV2";
|
||||
import { useTokenStore } from "@/stores/tokens";
|
||||
import { useMemeburnerStore } from "@/stores/memeburner";
|
||||
import { useRewardLockerStore } from "@/stores/rewardlocker";
|
||||
import { useRoundsStore } from "@/stores/rounds";
|
||||
|
||||
import { createApp } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
@@ -8,12 +12,17 @@ import piniaPluginPersistedstate from "pinia-plugin-persistedstate";
|
||||
import {
|
||||
createConfig,
|
||||
configureChains,
|
||||
getAccount,
|
||||
getAccount,
|
||||
getNetwork,
|
||||
getContract,
|
||||
connect,
|
||||
disconnect,
|
||||
InjectedConnector,
|
||||
watchAccount,
|
||||
watchAccount,
|
||||
watchWalletClient,
|
||||
watchPublicClient,
|
||||
watchContractEvent,
|
||||
watchNetwork,
|
||||
getWalletClient,
|
||||
fetchBalance,
|
||||
multicall,
|
||||
@@ -71,8 +80,12 @@ pinia.use(piniaPluginPersistedstate);
|
||||
app.use(pinia);
|
||||
|
||||
|
||||
|
||||
const walletStore = useWalletStoreV2();
|
||||
const tokenStore = useTokenStore();
|
||||
const memeBurnerStore = useMemeburnerStore();
|
||||
const rewardLockerStore = useRewardLockerStore();
|
||||
const roundsStore = useRoundsStore();
|
||||
|
||||
|
||||
const goerliKey = import.meta.env.VITE_GOERLI_KEY;
|
||||
const projectId = "d8e5ecb0353c02e21d4c0867d4473ac5";
|
||||
@@ -82,6 +95,7 @@ const { chains, publicClient, webSocketPublicClient } = configureChains(
|
||||
[alchemyProvider({ apiKey: goerliKey }), publicProvider()]
|
||||
);
|
||||
|
||||
|
||||
walletStore.config = createConfig({
|
||||
autoConnect: true,
|
||||
connectors: [
|
||||
@@ -111,6 +125,93 @@ walletStore.config = createConfig({
|
||||
});
|
||||
walletStore.publicClient = publicClient;
|
||||
|
||||
const networkId = getNetwork()?.chain?.id;
|
||||
|
||||
watchWalletClient(
|
||||
{
|
||||
chainId: networkId,
|
||||
},
|
||||
async (walletClient) => {
|
||||
walletStore.walletClient = walletClient;
|
||||
}
|
||||
);
|
||||
|
||||
watchPublicClient(
|
||||
{
|
||||
chainId: networkId,
|
||||
},
|
||||
(publicClient) => console.log("publicClient", publicClient)
|
||||
);
|
||||
|
||||
watchContractEvent(
|
||||
{
|
||||
address: memeBurnerStore.config.contractAddress,
|
||||
abi: memeBurnerStore.config.abi,
|
||||
eventName: "MemeSacrificed",
|
||||
},
|
||||
async (log) => {
|
||||
console.log("memeSacrificedEvent", log);
|
||||
const token = log[0].args.sacrificedToken;
|
||||
await roundsStore.updateCurrentRound(token);
|
||||
}
|
||||
);
|
||||
|
||||
watchAccount(async (account) => {
|
||||
console.log("watchAccount", account);
|
||||
|
||||
// {chainId: }
|
||||
if (account.address) {
|
||||
walletStore.address = account.address;
|
||||
walletStore.connected = true;
|
||||
let chainObject = walletStore.chain;
|
||||
if (!walletStore.chain) {
|
||||
const { chain, chains } = getNetwork();
|
||||
chainObject = chain;
|
||||
}
|
||||
// var walletClient = await getWalletClient({
|
||||
// account: account.address,
|
||||
// chainId: chainObject.id,
|
||||
// });
|
||||
|
||||
// walletStore.walletClient = walletClient;
|
||||
|
||||
await memeBurnerStore.init();
|
||||
await tokenStore.initV2();
|
||||
await rewardLockerStore.init();
|
||||
await walletStore.loadWalletData();
|
||||
} else {
|
||||
walletStore.address = null;
|
||||
walletStore.connected = false;
|
||||
walletStore.walletClient = null;
|
||||
}
|
||||
});
|
||||
|
||||
watchNetwork((network) => {
|
||||
console.log("network123", network);
|
||||
if (network.chain) {
|
||||
walletStore.chain = network.chain;
|
||||
}
|
||||
});
|
||||
|
||||
watchContractEvent(
|
||||
{
|
||||
address: memeBurnerStore.config.contractAddress,
|
||||
abi: memeBurnerStore.config.abi,
|
||||
eventName: "MemeSacrificed",
|
||||
},
|
||||
async (log) => {
|
||||
console.log("memeSacrificedEvent", log);
|
||||
const token = log[0].args.sacrificedToken;
|
||||
await roundsStore.updateCurrentRound(token);
|
||||
}
|
||||
);
|
||||
|
||||
await walletStore.init();
|
||||
await tokenStore.initV2();
|
||||
await memeBurnerStore.init();
|
||||
await rewardLockerStore.init();
|
||||
await memeBurnerStore.init();
|
||||
|
||||
app.use(router)
|
||||
app.component('font-awesome-icon', FontAwesomeIcon)
|
||||
app.mount('#app')
|
||||
|
||||
Reference in New Issue
Block a user