images + update wagmi
This commit is contained in:
+32
-4
@@ -17,6 +17,9 @@ import ConnectWallet from "./components/ConnectWallet.vue";
|
||||
import {
|
||||
watchAccount,
|
||||
watchNetwork,
|
||||
watchContractEvent,
|
||||
getAccount,
|
||||
getNetwork,
|
||||
getPublicClient,
|
||||
getWalletClient,
|
||||
} from "@wagmi/core";
|
||||
@@ -34,6 +37,7 @@ const isMobile = ref(false);
|
||||
const showPanel = ref(false);
|
||||
const eventWatch = ref(null);
|
||||
const netWorkEvent = ref(null);
|
||||
const memeSacrificedEvent = ref(null);
|
||||
|
||||
isMobile.value = isMobileFunc();
|
||||
onUnmounted(() => {
|
||||
@@ -74,6 +78,14 @@ onMounted(async () => {
|
||||
// await multiCallStore.init();
|
||||
//Memeburner Contract
|
||||
|
||||
const account = getAccount();
|
||||
|
||||
console.log("account", account);
|
||||
if (account.address) {
|
||||
walletStore.address = account.address;
|
||||
walletStore.connected = true;
|
||||
}
|
||||
|
||||
//init
|
||||
roundsStore.currentRound = parseInt(
|
||||
await memeBurnerStore.getCurrentRound()
|
||||
@@ -85,7 +97,7 @@ onMounted(async () => {
|
||||
//events
|
||||
eventWatch.value = watchAccount(async (account) => {
|
||||
console.log("account123", account);
|
||||
const publicClient = await getPublicClient();
|
||||
const publicClient = getPublicClient();
|
||||
console.log("publicClient", publicClient);
|
||||
|
||||
// {chainId: }
|
||||
@@ -93,8 +105,13 @@ onMounted(async () => {
|
||||
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({
|
||||
chainId: walletStore.chain.id,
|
||||
chainId: chainObject.id,
|
||||
});
|
||||
walletStore.walletClient = walletClient;
|
||||
await memeBurnerStore.init();
|
||||
@@ -109,10 +126,21 @@ onMounted(async () => {
|
||||
console.log("network123", network);
|
||||
if (network.chain) {
|
||||
walletStore.chain = network.chain;
|
||||
} else {
|
||||
walletStore.chain = null;
|
||||
}
|
||||
});
|
||||
|
||||
memeSacrificedEvent.value = 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);
|
||||
}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user