contracts update
This commit is contained in:
Generated
+14207
-16585
File diff suppressed because it is too large
Load Diff
+34
-36
@@ -1,38 +1,36 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-ethereum2",
|
"name": "vue-ethereum2",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore"
|
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fortawesome/fontawesome-svg-core": "^6.4.0",
|
"@fortawesome/fontawesome-svg-core": "^6.4.0",
|
||||||
"@fortawesome/free-brands-svg-icons": "^6.4.0",
|
"@fortawesome/free-brands-svg-icons": "^6.4.0",
|
||||||
"@fortawesome/free-solid-svg-icons": "^6.4.0",
|
"@fortawesome/free-solid-svg-icons": "^6.4.0",
|
||||||
"@fortawesome/vue-fontawesome": "^3.0.3",
|
"@fortawesome/vue-fontawesome": "^3.0.3",
|
||||||
"@walletconnect/ethereum-provider": "^2.9.0",
|
"@wagmi/core": "^1.3.8",
|
||||||
"@walletconnect/modal": "^2.6.0",
|
"abi-decoder": "^2.4.0",
|
||||||
"@walletconnect/web3-provider": "^1.8.0",
|
"ethers": "^6.6.3",
|
||||||
"@web3modal/html": "^2.7.0",
|
"pinia": "^2.0.36",
|
||||||
"abi-decoder": "^2.4.0",
|
"pinia-plugin-persistedstate": "^3.1.0",
|
||||||
"ethers": "^6.6.3",
|
"sass": "^1.62.1",
|
||||||
"pinia": "^2.0.36",
|
"swiper": "^9.4.1",
|
||||||
"pinia-plugin-persistedstate": "^3.1.0",
|
"viem": "^1.4.1",
|
||||||
"sass": "^1.62.1",
|
"vue": "^3.3.2",
|
||||||
"swiper": "^9.4.1",
|
"vue-router": "^4.2.0",
|
||||||
"vue": "^3.3.2",
|
"web3": "^v1.9.0"
|
||||||
"vue-router": "^4.2.0",
|
},
|
||||||
"web3": "^v1.9.0"
|
"devDependencies": {
|
||||||
},
|
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
|
||||||
"devDependencies": {
|
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
|
||||||
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
|
"@vitejs/plugin-vue": "^4.2.3",
|
||||||
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
|
"eslint": "^8.39.0",
|
||||||
"@vitejs/plugin-vue": "^4.2.3",
|
"eslint-plugin-vue": "^9.11.0",
|
||||||
"eslint": "^8.39.0",
|
"vite": "^4.3.5"
|
||||||
"eslint-plugin-vue": "^9.11.0",
|
}
|
||||||
"vite": "^4.3.5"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+35
-12
@@ -4,7 +4,6 @@ import { storeToRefs } from "pinia";
|
|||||||
|
|
||||||
import Navbar from "./components/Navbar.vue";
|
import Navbar from "./components/Navbar.vue";
|
||||||
import { useWalletStoreV2 } from "@/stores/walletV2";
|
import { useWalletStoreV2 } from "@/stores/walletV2";
|
||||||
const walletStore = useWalletStoreV2();
|
|
||||||
import { useTokenStore } from "@/stores/tokens";
|
import { useTokenStore } from "@/stores/tokens";
|
||||||
import { useContractStore } from "@/stores/contracts";
|
import { useContractStore } from "@/stores/contracts";
|
||||||
import { useMemeburnerStore } from "@/stores/memeburner";
|
import { useMemeburnerStore } from "@/stores/memeburner";
|
||||||
@@ -15,7 +14,12 @@ import { useRoundsStore } from "@/stores/rounds";
|
|||||||
import SlideoutPanel from "./components/SlideoutPanel.vue";
|
import SlideoutPanel from "./components/SlideoutPanel.vue";
|
||||||
import ConnectWallet from "./components/ConnectWallet.vue";
|
import ConnectWallet from "./components/ConnectWallet.vue";
|
||||||
|
|
||||||
import { watchAccount, getPublicClient, getWalletClient } from "@wagmi/core";
|
import {
|
||||||
|
watchAccount,
|
||||||
|
watchNetwork,
|
||||||
|
getPublicClient,
|
||||||
|
getWalletClient,
|
||||||
|
} from "@wagmi/core";
|
||||||
|
|
||||||
const tokenStore = useTokenStore();
|
const tokenStore = useTokenStore();
|
||||||
const contractStore = useContractStore();
|
const contractStore = useContractStore();
|
||||||
@@ -23,17 +27,20 @@ const memeBurnerStore = useMemeburnerStore();
|
|||||||
const rewardLockerStore = useRewardLockerStore();
|
const rewardLockerStore = useRewardLockerStore();
|
||||||
const multiCallStore = useMultiCallStore();
|
const multiCallStore = useMultiCallStore();
|
||||||
const roundsStore = useRoundsStore();
|
const roundsStore = useRoundsStore();
|
||||||
|
const walletStore = useWalletStoreV2();
|
||||||
const { memeBurner, token } = storeToRefs(tokenStore);
|
const { memeBurner, token } = storeToRefs(tokenStore);
|
||||||
const { list } = storeToRefs(contractStore);
|
const { list } = storeToRefs(contractStore);
|
||||||
const isMobile = ref(false);
|
const isMobile = ref(false);
|
||||||
const showPanel = ref(false);
|
const showPanel = ref(false);
|
||||||
const eventWatch = ref(null);
|
const eventWatch = ref(null);
|
||||||
|
const netWorkEvent = ref(null);
|
||||||
|
|
||||||
isMobile.value = isMobileFunc();
|
isMobile.value = isMobileFunc();
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
window.removeEventListener("resize", handleWindowSizeChange);
|
window.removeEventListener("resize", handleWindowSizeChange);
|
||||||
|
|
||||||
eventWatch.value();
|
eventWatch.value();
|
||||||
|
netWorkEvent.value();
|
||||||
console.log("unsubscribe");
|
console.log("unsubscribe");
|
||||||
});
|
});
|
||||||
const handleWindowSizeChange = () => {
|
const handleWindowSizeChange = () => {
|
||||||
@@ -62,32 +69,48 @@ onMounted(async () => {
|
|||||||
await walletStore.init();
|
await walletStore.init();
|
||||||
await tokenStore.initV2();
|
await tokenStore.initV2();
|
||||||
await memeBurnerStore.init();
|
await memeBurnerStore.init();
|
||||||
// await rewardLockerStore.init();
|
await rewardLockerStore.init();
|
||||||
// await memeBurnerStore.init();
|
await memeBurnerStore.init();
|
||||||
// await multiCallStore.init();
|
// await multiCallStore.init();
|
||||||
//Memeburner Contract
|
//Memeburner Contract
|
||||||
|
|
||||||
//init
|
//init
|
||||||
// roundsStore.currentRound = parseInt(
|
roundsStore.currentRound = parseInt(
|
||||||
// await memeBurnerStore.getCurrentRound()
|
await memeBurnerStore.getCurrentRound()
|
||||||
// );
|
);
|
||||||
// console.log("roundsStore.currentRound", roundsStore.currentRound);
|
console.log("roundsStore.currentRound", roundsStore.currentRound);
|
||||||
// roundsStore.activeRound = roundsStore.currentRound;
|
roundsStore.activeRound = roundsStore.currentRound;
|
||||||
// await roundsStore.fillRound(roundsStore.activeRound);
|
await roundsStore.fillRound(roundsStore.activeRound);
|
||||||
|
|
||||||
//events
|
//events
|
||||||
eventWatch.value = watchAccount(async (account) => {
|
eventWatch.value = watchAccount(async (account) => {
|
||||||
console.log("account123", account);
|
console.log("account123", account);
|
||||||
const publicClient = getPublicClient();
|
const publicClient = await getPublicClient();
|
||||||
console.log("publicClient", publicClient);
|
console.log("publicClient", publicClient);
|
||||||
var walletClient = await getWalletClient();
|
|
||||||
|
// {chainId: }
|
||||||
console.log("walletClient", walletClient);
|
console.log("walletClient", walletClient);
|
||||||
if (account.address) {
|
if (account.address) {
|
||||||
walletStore.address = account.address;
|
walletStore.address = account.address;
|
||||||
walletStore.connected = true;
|
walletStore.connected = true;
|
||||||
|
var walletClient = await getWalletClient({
|
||||||
|
chainId: walletStore.chain.id,
|
||||||
|
});
|
||||||
|
walletStore.walletClient = walletClient;
|
||||||
|
await memeBurnerStore.init();
|
||||||
} else {
|
} else {
|
||||||
walletStore.address = null;
|
walletStore.address = null;
|
||||||
walletStore.connected = false;
|
walletStore.connected = false;
|
||||||
|
walletStore.walletClient = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
netWorkEvent.value = watchNetwork((network) => {
|
||||||
|
console.log("network123", network);
|
||||||
|
if (network.chain) {
|
||||||
|
walletStore.chain = network.chain;
|
||||||
|
} else {
|
||||||
|
walletStore.chain = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<h3>Connect Wallet</h3>
|
<h3>Connect Wallet</h3>
|
||||||
<div class="connectors-wrapper">
|
<div class="connectors-wrapper">
|
||||||
<div class="connectors-element" v-for="connector in walletStore.connectors" @click="connectWallet(connector)">
|
<div class="connectors-element" v-for="connector in walletStore.config?.connectors" @click="connectWallet(connector)">
|
||||||
<div class="connector-icon">
|
<div class="connector-icon">
|
||||||
<img :src="`/assets/img/connectors/${connector.id}.svg`" :alt="`${connector.name} Logo`">
|
<img :src="`/assets/img/connectors/${connector.id}.svg`" :alt="`${connector.name} Logo`">
|
||||||
</div>
|
</div>
|
||||||
@@ -9,7 +9,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div @click="disconnectWallet">disconnect</div>
|
<div @click="disconnectWallet">disconnect</div>
|
||||||
<div @click="getWalletClientTest">getwalletclient</div>
|
|
||||||
<div>Connected: {{ walletStore.connected }}</div>
|
<div>Connected: {{ walletStore.connected }}</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -28,7 +27,6 @@ import {
|
|||||||
disconnect,
|
disconnect,
|
||||||
InjectedConnector,
|
InjectedConnector,
|
||||||
watchAccount,
|
watchAccount,
|
||||||
getWalletClient,
|
|
||||||
} from "@wagmi/core";
|
} from "@wagmi/core";
|
||||||
|
|
||||||
const walletStore = useWalletStoreV2();
|
const walletStore = useWalletStoreV2();
|
||||||
@@ -81,21 +79,6 @@ async function disconnectWallet() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getWalletClientTest() {
|
|
||||||
const walletClient = await getWalletClient();
|
|
||||||
console.log("walletClient", walletClient);
|
|
||||||
const contract = getContract({
|
|
||||||
address: Meme1Json.contractAddress,
|
|
||||||
abi: Meme1Json.abi,
|
|
||||||
walletClient,
|
|
||||||
});
|
|
||||||
const result = await contract.read.totalSupply();
|
|
||||||
console.log("result", result);
|
|
||||||
|
|
||||||
// console.log("obj", obj);
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
|
|
||||||
async function connectWallet(connector) {
|
async function connectWallet(connector) {
|
||||||
instance.parent.emit("update:modelValue", false);
|
instance.parent.emit("update:modelValue", false);
|
||||||
await walletStore.connectWallet(toRaw(connector));
|
await walletStore.connectWallet(toRaw(connector));
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
import { ref, onMounted, onBeforeUnmount, inject } from "vue";
|
import { ref, onMounted, onBeforeUnmount, inject } from "vue";
|
||||||
import { useWalletStore } from "@/stores/wallet";
|
import { useWalletStoreV2 } from "@/stores/walletV2";
|
||||||
const walletStore = useWalletStore();
|
const emit = defineEmits(["showPanel"]);
|
||||||
|
|
||||||
|
const walletStore = useWalletStoreV2();
|
||||||
const { connected, address } = storeToRefs(walletStore);
|
const { connected, address } = storeToRefs(walletStore);
|
||||||
const isMobile = inject("isMobile");
|
const isMobile = inject("isMobile");
|
||||||
|
|
||||||
|
const showPanel = ref(false);
|
||||||
|
|
||||||
const showNavbar = ref(true);
|
const showNavbar = ref(true);
|
||||||
const lastScrollPosition = ref(0);
|
const lastScrollPosition = ref(0);
|
||||||
|
|
||||||
@@ -62,8 +66,9 @@ onBeforeUnmount(() => {
|
|||||||
</div>
|
</div>
|
||||||
<div class="navbar-end">
|
<div class="navbar-end">
|
||||||
<div v-if="!isMobile">
|
<div v-if="!isMobile">
|
||||||
<div v-if="!connected" class="btn btn-immortal" @click="walletStore.connectWallet">connect</div>
|
<!-- <div v-if="!connected" class="btn btn-immortal" @click="walletStore.connectWallet">connect</div> -->
|
||||||
<span v-else> {{ address }}</span>
|
<div v-if="!address" class="btn btn-immortal" @click="$emit('showPanel', true)">connect</div>
|
||||||
|
<span v-else @click="$emit('showPanel', true)"> {{ address }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="hamburger-menu">
|
<div v-else class="hamburger-menu">
|
||||||
<font-awesome-icon :icon="['fas', 'bars']" />
|
<font-awesome-icon :icon="['fas', 'bars']" />
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ export function getImageUrl(url) {
|
|||||||
export function getPercentage(amount, goal) {
|
export function getPercentage(amount, goal) {
|
||||||
console.log("amount", amount);
|
console.log("amount", amount);
|
||||||
console.log("goal", goal);
|
console.log("goal", goal);
|
||||||
return ((amount / goal) * 100).toFixed(2);
|
|
||||||
|
return ((Number(amount) / Number(goal)) * 100).toFixed(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+29
-26
@@ -6,7 +6,7 @@ import { useWalletStore } from "./wallet";
|
|||||||
import { useWalletStoreV2 } from "./walletV2";
|
import { useWalletStoreV2 } from "./walletV2";
|
||||||
import { useRoundsStore } from "@/stores/rounds";
|
import { useRoundsStore } from "@/stores/rounds";
|
||||||
|
|
||||||
import { multicall, getContract, fetchToken } from "@wagmi/core";
|
import { multicall, getContract, fetchToken, waitForTransaction } from "@wagmi/core";
|
||||||
|
|
||||||
|
|
||||||
export const useMemeburnerStore = defineStore("memeburner", {
|
export const useMemeburnerStore = defineStore("memeburner", {
|
||||||
@@ -21,15 +21,14 @@ export const useMemeburnerStore = defineStore("memeburner", {
|
|||||||
console.log("-----------init memeburner-------------");
|
console.log("-----------init memeburner-------------");
|
||||||
const walletStore = useWalletStoreV2();
|
const walletStore = useWalletStoreV2();
|
||||||
// const roundsStore = useRoundsStore();
|
// const roundsStore = useRoundsStore();
|
||||||
|
console.log("walletStore.walletClient", walletStore.walletClient);
|
||||||
// this.contract = new walletStore.web3.eth.Contract(this.config.abi, this.config.contractAddress);
|
// this.contract = new walletStore.web3.eth.Contract(this.config.abi, this.config.contractAddress);
|
||||||
this.contract = getContract({
|
this.contract = getContract({
|
||||||
address: this.config.contractAddress,
|
address: this.config.contractAddress,
|
||||||
abi: this.config.abi,
|
abi: this.config.abi,
|
||||||
PublicClient: walletStore.publicClient,
|
walletClient: walletStore.walletClient || walletStore.publicClient,
|
||||||
WalletClient: walletStore.walletClient,
|
});
|
||||||
});
|
console.log("this.contract", this.contract);
|
||||||
|
|
||||||
// const websocketMemeBurner = new walletStore.web3socket.eth.Contract(
|
// const websocketMemeBurner = new walletStore.web3socket.eth.Contract(
|
||||||
// this.config.abi,
|
// this.config.abi,
|
||||||
// this.config.contractAddress
|
// this.config.contractAddress
|
||||||
@@ -56,35 +55,36 @@ export const useMemeburnerStore = defineStore("memeburner", {
|
|||||||
return rewards;
|
return rewards;
|
||||||
},
|
},
|
||||||
async getCurrentRound() {
|
async getCurrentRound() {
|
||||||
return await this.contract.methods.currentRound().call();
|
return await this.contract.read.currentRound();
|
||||||
},
|
},
|
||||||
async getGoal(roundnumber) {
|
async getGoal(roundnumber) {
|
||||||
return await this.contract.methods.rounds(roundnumber).call();
|
return await this.contract.read.rounds([roundnumber]);
|
||||||
},
|
},
|
||||||
//returns participated, amount achieved
|
//returns participated, amount achieved
|
||||||
async getSacrificedMeme(roundnumber, tokenAddress) {
|
async getSacrificedMeme(roundnumber, tokenAddress) {
|
||||||
return await this.contract.methods.getSacrificedMeme(roundnumber, tokenAddress).call();
|
return await this.contract.read.getSacrificedMeme([roundnumber, tokenAddress]);
|
||||||
},
|
},
|
||||||
async getAmountToReachGoal(tokenAddress) {
|
async getAmountToReachGoal(tokenAddress) {
|
||||||
return await this.contract.methods.getAmountToReachGoal(tokenAddress).call();
|
return await this.contract.read.getAmountToReachGoal([tokenAddress]);
|
||||||
},
|
},
|
||||||
async getSacrificedRound(roundnumber) {
|
async getSacrificedRound(roundnumber) {
|
||||||
console.log("getSacrificedRound", roundnumber);
|
console.log("getSacrificedRound", roundnumber);
|
||||||
const tokenStore = useTokenStore();
|
const tokenStore = useTokenStore();
|
||||||
const calls = [];
|
const contracts = [];
|
||||||
// const calls1 = [];
|
|
||||||
for (let index = 0; index < tokenStore.token.length; index++) {
|
for (let index = 0; index < tokenStore.token.length; index++) {
|
||||||
const token = tokenStore.token[index];
|
const token = tokenStore.token[index];
|
||||||
console.log("token.contractAddress", token.contractAddress);
|
console.log("token.contractAddress", token.contractAddress);
|
||||||
console.log("roundnumber", roundnumber);
|
console.log("roundnumber", roundnumber);
|
||||||
var test = await this.getSacrificedMeme(roundnumber, token.contractAddress);
|
// contracts.push(this.contract.methods.getSacrificedMeme(roundnumber, token.contractAddress));
|
||||||
console.log(token.name, test);
|
contracts.push({ ...this.contract, functionName: "getSacrificedMeme", args: [roundnumber, token.contractAddress] });
|
||||||
calls.push(this.contract.methods.getSacrificedMeme(roundnumber, token.contractAddress));
|
|
||||||
// calls1.push(this.contract.methods.getAmountToReachGoal(token.contractAddress));
|
|
||||||
}
|
}
|
||||||
console.log("this.contract", this.contract);
|
// console.log("this.contract", this.contract);
|
||||||
const multicallStore = useMultiCallStore();
|
// const multicallStore = useMultiCallStore();
|
||||||
return await multicallStore.aggregate(calls);
|
// return await multicallStore.aggregate(calls);
|
||||||
|
const data = await multicall({
|
||||||
|
contracts,
|
||||||
|
});
|
||||||
|
return data;
|
||||||
},
|
},
|
||||||
async sacrificeMeme(amount) {
|
async sacrificeMeme(amount) {
|
||||||
const walletStore = useWalletStore();
|
const walletStore = useWalletStore();
|
||||||
@@ -97,11 +97,14 @@ export const useMemeburnerStore = defineStore("memeburner", {
|
|||||||
}
|
}
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
const amountDecimal = BigInt(amount * Math.pow(10, tokenStore.activeToken.decimals));
|
const amountDecimal = BigInt(amount * Math.pow(10, tokenStore.activeToken.decimals));
|
||||||
var reward = await this.contract.methods
|
console.log("this.contract", this.contract);
|
||||||
.sacrificeMeme(tokenStore.activeToken.contractAddress, amountDecimal)
|
var hash = await this.contract.write
|
||||||
.send({ from: walletStore.address });
|
.sacrificeMeme([tokenStore.activeToken.contractAddress, amountDecimal])
|
||||||
console.log("reward", reward);
|
console.log("hash", hash);
|
||||||
tokenStore.activeToken.allowance = await tokenStore.allowance();
|
const data = await waitForTransaction({
|
||||||
|
hash: hash,
|
||||||
|
});
|
||||||
|
tokenStore.activeToken.allowance = await tokenStore.allowance();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -109,7 +112,7 @@ export const useMemeburnerStore = defineStore("memeburner", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async getGoalInBLD(roundNumber) {
|
async getGoalInBLD(roundNumber) {
|
||||||
return await this.contract.methods.getGoalInBLD(roundNumber).call();
|
return await this.contract.read.getGoalInBLD([roundNumber]);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
+31
-14
@@ -3,7 +3,10 @@ import RewardLockerJson from "@/assets/contracts/RewardLocker.json";
|
|||||||
import { useTokenStore } from "./tokens";
|
import { useTokenStore } from "./tokens";
|
||||||
import { useMultiCallStore } from "./multicall";
|
import { useMultiCallStore } from "./multicall";
|
||||||
import { useWalletStore } from "./wallet";
|
import { useWalletStore } from "./wallet";
|
||||||
|
import { useWalletStoreV2 } from "./walletV2";
|
||||||
import { ethers } from "ethers";
|
import { ethers } from "ethers";
|
||||||
|
import { multicall, getContract } from "@wagmi/core";
|
||||||
|
|
||||||
|
|
||||||
export const useRewardLockerStore = defineStore("rewardlocker", {
|
export const useRewardLockerStore = defineStore("rewardlocker", {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
@@ -15,8 +18,13 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
|
|||||||
actions: {
|
actions: {
|
||||||
async init() {
|
async init() {
|
||||||
console.log("-----------init rewardlocker-------------");
|
console.log("-----------init rewardlocker-------------");
|
||||||
const walletStore = useWalletStore();
|
const walletStore = useWalletStoreV2();
|
||||||
this.contract = new walletStore.web3.eth.Contract(this.config.abi, this.config.contractAddress);
|
this.contract = getContract({
|
||||||
|
address: this.config.contractAddress,
|
||||||
|
abi: this.config.abi,
|
||||||
|
walletClient: walletStore.walletClient || walletStore.publicClient,
|
||||||
|
});
|
||||||
|
// this.contract = new walletStore.web3.eth.Contract(this.config.abi, this.config.contractAddress);
|
||||||
},
|
},
|
||||||
/*
|
/*
|
||||||
* @param {*} walletAddress
|
* @param {*} walletAddress
|
||||||
@@ -25,34 +33,43 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
|
|||||||
* @returns Rewards for specific token and specific round
|
* @returns Rewards for specific token and specific round
|
||||||
*/
|
*/
|
||||||
async getRewards(walletAddress, roundNumber, tokenAddress) {
|
async getRewards(walletAddress, roundNumber, tokenAddress) {
|
||||||
return await this.contract.methods.rewards(walletAddress, roundNumber, tokenAddress).call();
|
return await this.contract.read.rewards([walletAddress, roundNumber, tokenAddress]);
|
||||||
},
|
},
|
||||||
async getRewardsForAllToken(roundNumber) {
|
async getRewardsForAllToken(roundNumber) {
|
||||||
console.log("getRewardsForAllToken");
|
console.log("getRewardsForAllToken");
|
||||||
const tokenStore = useTokenStore();
|
const tokenStore = useTokenStore();
|
||||||
const walletStore = useWalletStore();
|
const walletStore = useWalletStoreV2();
|
||||||
const calls = [];
|
const contracts = [];
|
||||||
for (let index = 0; index < tokenStore.token.length; index++) {
|
for (let index = 0; index < tokenStore.token.length; index++) {
|
||||||
const token = tokenStore.token[index];
|
const token = tokenStore.token[index];
|
||||||
calls.push(this.contract.methods.rewards(walletStore.address, roundNumber, token.contractAddress));
|
// calls.push(this.contract.methods.rewards(walletStore.address, roundNumber, token.contractAddress));
|
||||||
}
|
contracts.push({
|
||||||
const multicallStore = useMultiCallStore();
|
...this.contract,
|
||||||
return await multicallStore.aggregate(calls);
|
functionName: "rewards",
|
||||||
|
args: [walletStore.address, roundNumber, token.contractAddress],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const data = await multicall({
|
||||||
|
contracts,
|
||||||
|
});
|
||||||
|
// const multicallStore = useMultiCallStore();
|
||||||
|
return data
|
||||||
},
|
},
|
||||||
async getSacrificedTokenCoefficient(roundNumber, sacrificedToken) {
|
async getSacrificedTokenCoefficient(roundNumber, sacrificedToken) {
|
||||||
return await this.contract.methods.getSacrificedTokenCoefficient(roundNumber, sacrificedToken).call();
|
return await this.contract.read.getSacrificedTokenCoefficient([roundNumber, sacrificedToken]);
|
||||||
},
|
},
|
||||||
async lastCompletedRound() {
|
async lastCompletedRound() {
|
||||||
return await this.contract.methods.lastCompletedRound().call();
|
return await this.contract.read.lastCompletedRound();
|
||||||
},
|
},
|
||||||
async claim(round) {
|
async claim(round) {
|
||||||
const walletStore = useWalletStore();
|
const walletStore = useWalletStoreV2();
|
||||||
// return await this.contract.methods.claim(round).call();
|
// return await this.contract.methods.claim(round).call();
|
||||||
console.log(this.contract.methods.claim(round));
|
console.log(this.contract.methods.claim(round));
|
||||||
return await this.contract.methods.claim(round).send({from: walletStore.address, to: this.contractAddress});
|
// return await this.contract.methods.claim(round).send({from: walletStore.address, to: this.contractAddress});
|
||||||
|
return await this.contract.write.claim([round]);
|
||||||
},
|
},
|
||||||
async getTotalRewardsOf(address, rounds) {
|
async getTotalRewardsOf(address, rounds) {
|
||||||
return await this.contract.methods.getTotalRewardsOf(address, rounds).call();
|
return await this.contract.read.getTotalRewardsOf([address, rounds]);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
+12
-10
@@ -3,6 +3,7 @@ import { useMemeburnerStore } from "./memeburner";
|
|||||||
import { useTokenStore } from "./tokens";
|
import { useTokenStore } from "./tokens";
|
||||||
import { useRewardLockerStore } from "./rewardlocker";
|
import { useRewardLockerStore } from "./rewardlocker";
|
||||||
import { useWalletStore } from "./wallet";
|
import { useWalletStore } from "./wallet";
|
||||||
|
import { useWalletStoreV2 } from "./walletV2";
|
||||||
|
|
||||||
|
|
||||||
export const useRoundsStore = defineStore("rounds", {
|
export const useRoundsStore = defineStore("rounds", {
|
||||||
@@ -34,7 +35,7 @@ export const useRoundsStore = defineStore("rounds", {
|
|||||||
console.log("fillRound");
|
console.log("fillRound");
|
||||||
const memeBurnerStore = useMemeburnerStore();
|
const memeBurnerStore = useMemeburnerStore();
|
||||||
const tokenStore = useTokenStore();
|
const tokenStore = useTokenStore();
|
||||||
const walletStore = useWalletStore();
|
const walletStore = useWalletStoreV2();
|
||||||
const rewardLockerStore = useRewardLockerStore();
|
const rewardLockerStore = useRewardLockerStore();
|
||||||
|
|
||||||
// if (this.activeRound === this.currentRound) {
|
// if (this.activeRound === this.currentRound) {
|
||||||
@@ -51,7 +52,7 @@ export const useRoundsStore = defineStore("rounds", {
|
|||||||
console.log("rewardData123", rewardData);
|
console.log("rewardData123", rewardData);
|
||||||
|
|
||||||
var goal = await memeBurnerStore.getGoal(this.activeRound);
|
var goal = await memeBurnerStore.getGoal(this.activeRound);
|
||||||
|
console.log("goal", goal);
|
||||||
var tokenArray = []
|
var tokenArray = []
|
||||||
var rewards_clan = BigInt(0);
|
var rewards_clan = BigInt(0);
|
||||||
var rewards_sacrifice = BigInt(0);
|
var rewards_sacrifice = BigInt(0);
|
||||||
@@ -66,9 +67,10 @@ export const useRoundsStore = defineStore("rounds", {
|
|||||||
tokenData.contractAddress = token.contractAddress;
|
tokenData.contractAddress = token.contractAddress;
|
||||||
tokenData.vamplogo = token.vamp.logo;
|
tokenData.vamplogo = token.vamp.logo;
|
||||||
tokenData.vampname = token.vamp.name;
|
tokenData.vampname = token.vamp.name;
|
||||||
tokenData.amount = data[index][1];
|
tokenData.amount = data[index].result[1];
|
||||||
tokenData.getAmountToReachGoal= await memeBurnerStore.getAmountToReachGoal(token.contractAddress);
|
tokenData.getAmountToReachGoal= await memeBurnerStore.getAmountToReachGoal(token.contractAddress);
|
||||||
if (this.currentRound !== this.activeRound && await walletStore.isConnected()) {
|
if (this.currentRound !== this.activeRound && walletStore.connected) {
|
||||||
|
console.log("rewarddata", rewardData);
|
||||||
const clanwin = BigInt((testcoef / 10000 - 1) * rewardData[index]);
|
const clanwin = BigInt((testcoef / 10000 - 1) * rewardData[index]);
|
||||||
const sacrificeRewards = BigInt(rewardData[index]) - clanwin;
|
const sacrificeRewards = BigInt(rewardData[index]) - clanwin;
|
||||||
tokenData.rewards_ges = rewardData[index];
|
tokenData.rewards_ges = rewardData[index];
|
||||||
@@ -80,17 +82,17 @@ export const useRoundsStore = defineStore("rounds", {
|
|||||||
}
|
}
|
||||||
tokenArray.push(tokenData);
|
tokenArray.push(tokenData);
|
||||||
}
|
}
|
||||||
|
|
||||||
const goalInBLD = await memeBurnerStore.getGoalInBLD(this.activeRound);
|
const goalInBLD = await memeBurnerStore.getGoalInBLD(this.activeRound);
|
||||||
this.rounds[this.activeRound] = {
|
this.rounds[this.activeRound] = {
|
||||||
goal: goal.goal,
|
goal: goal[0],
|
||||||
goalInBLD: goalInBLD /Math.pow(10, tokenStore.memeToken.decimals),
|
goalInBLD: goalInBLD / BigInt(Math.pow(10, tokenStore.memeToken.decimals)),
|
||||||
expirationTimestamp: goal.expirationTimestamp,
|
expirationTimestamp: goal[1],
|
||||||
rewards_clan: rewards_clan,
|
rewards_clan: rewards_clan,
|
||||||
rewards_sacrifice: rewards_sacrifice,
|
rewards_sacrifice: rewards_sacrifice,
|
||||||
rewards_total: rewards_clan + rewards_sacrifice,
|
rewards_total: rewards_clan + rewards_sacrifice,
|
||||||
token: tokenArray,
|
token: tokenArray,
|
||||||
};
|
};
|
||||||
|
console.log("this.rounds[this.activeRound]", this.rounds[this.activeRound]);
|
||||||
} else {
|
} else {
|
||||||
console.log("round already filled");
|
console.log("round already filled");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,9 +78,8 @@ export const useTokenStore = defineStore("token", {
|
|||||||
token.contract = getContract({
|
token.contract = getContract({
|
||||||
address: token.contractAddress,
|
address: token.contractAddress,
|
||||||
abi: token.abi,
|
abi: token.abi,
|
||||||
PublicClient: walletStore.publicClient,
|
WalletClient: walletStore.walletClient || walletStore.publicClient,
|
||||||
WalletClient: walletStore.walletClient
|
});
|
||||||
});
|
|
||||||
contracts.push({...token.contract, functionName: "decimals"})
|
contracts.push({...token.contract, functionName: "decimals"})
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -137,6 +136,7 @@ export const useTokenStore = defineStore("token", {
|
|||||||
const decimals = this.activeToken.decimals;
|
const decimals = this.activeToken.decimals;
|
||||||
|
|
||||||
allowance = BigInt(allowance / BigInt(Math.pow(10, decimals)));
|
allowance = BigInt(allowance / BigInt(Math.pow(10, decimals)));
|
||||||
|
console.log("allowance", allowance);
|
||||||
return allowance;
|
return allowance;
|
||||||
},
|
},
|
||||||
async approveToken(amount) {
|
async approveToken(amount) {
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import {
|
|||||||
getAccount,
|
getAccount,
|
||||||
getContract,
|
getContract,
|
||||||
connect,
|
connect,
|
||||||
getWalletClient,
|
|
||||||
getPublicClient,
|
|
||||||
disconnect,
|
disconnect,
|
||||||
InjectedConnector,
|
InjectedConnector,
|
||||||
watchAccount,
|
watchAccount,
|
||||||
@@ -36,7 +34,8 @@ export const useWalletStoreV2 = defineStore("walletV2", {
|
|||||||
client: null,
|
client: null,
|
||||||
publicClient: null,
|
publicClient: null,
|
||||||
walletClient: null,
|
walletClient: null,
|
||||||
config: null
|
config: null,
|
||||||
|
chain: null,
|
||||||
}),
|
}),
|
||||||
getters: {},
|
getters: {},
|
||||||
actions: {
|
actions: {
|
||||||
@@ -50,6 +49,7 @@ export const useWalletStoreV2 = defineStore("walletV2", {
|
|||||||
[goerli],
|
[goerli],
|
||||||
[alchemyProvider({ apiKey: goerliKey }), publicProvider()]
|
[alchemyProvider({ apiKey: goerliKey }), publicProvider()]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
this.config = createConfig({
|
this.config = createConfig({
|
||||||
autoConnect: true,
|
autoConnect: true,
|
||||||
@@ -79,7 +79,6 @@ export const useWalletStoreV2 = defineStore("walletV2", {
|
|||||||
webSocketPublicClient,
|
webSocketPublicClient,
|
||||||
});
|
});
|
||||||
this.publicClient = publicClient;
|
this.publicClient = publicClient;
|
||||||
this.walletClient = await getWalletClient();
|
|
||||||
// await this.isConnected();
|
// await this.isConnected();
|
||||||
// const goerliKey = import.meta.env.VITE_GOERLI_KEY;
|
// const goerliKey = import.meta.env.VITE_GOERLI_KEY;
|
||||||
// if (this.connected) {
|
// if (this.connected) {
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ onBeforeUnmount(() => {
|
|||||||
|
|
||||||
function timeBetweenDates() {
|
function timeBetweenDates() {
|
||||||
const dateEntered = new Date(
|
const dateEntered = new Date(
|
||||||
getCurrentRoundData.value?.expirationTimestamp * 1000
|
Number(getCurrentRoundData.value?.expirationTimestamp) * 1000
|
||||||
);
|
);
|
||||||
|
|
||||||
if (dateEntered) {
|
if (dateEntered) {
|
||||||
@@ -153,7 +153,8 @@ function timeBetweenDates() {
|
|||||||
<tr>
|
<tr>
|
||||||
<td>Sacrifice:</td>
|
<td>Sacrifice:</td>
|
||||||
<td class="divider"></td>
|
<td class="divider"></td>
|
||||||
<td>{{ getCurrentRoundData?.goalInBLD?.toFixed(2) }} $BDL</td>
|
<!-- <td>{{ getCurrentRoundData?.goalInBLD?.toFixed(2) }} $BDL</td> -->
|
||||||
|
<td>{{ getCurrentRoundData?.goalInBLD }} $BDL</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Time left:</td>
|
<td>Time left:</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user