![]()
@@ -8,7 +8,7 @@
{{ connector.name }}
-
disconnect
+
disconnect
Connected: {{ walletStore.connected }}
@@ -73,7 +73,10 @@ const instance = getCurrentInstance();
async function disconnectWallet() {
console.log("disconnectWallet");
try {
+ instance.parent.emit("update:modelValue", false);
await disconnect();
+ // walletStore.connected = false;
+ // walletStore.address = null;
} catch (error) {
console.log("error", error);
}
diff --git a/src/stores/rounds.js b/src/stores/rounds.js
index 321fd5a..b4430f4 100644
--- a/src/stores/rounds.js
+++ b/src/stores/rounds.js
@@ -22,13 +22,13 @@ export const useRoundsStore = defineStore("rounds", {
async init() {
//fill initial round
},
- async updateCurrentRound(sacrificedToken, sacrificedAmount) {
+ async updateCurrentRound(sacrificedToken) {
const tokenStore = useTokenStore();
const memeBurnerStore = useMemeburnerStore();
- var data = await memeBurnerStore.getSacrificedRound(this.currentRound)
+ var data = await memeBurnerStore.getSacrificedRound(this.currentRound);
console.log("data123", data);
var tokenIndex = this.rounds[this.currentRound].token.findIndex((tokenData) => tokenData.contractAddress === sacrificedToken);
- this.rounds[this.currentRound].token[tokenIndex].amount = data[tokenIndex][1];
+ this.rounds[this.currentRound].token[tokenIndex].amount = data[tokenIndex].result[1];
},
async fillRound() {
@@ -46,7 +46,7 @@ export const useRoundsStore = defineStore("rounds", {
console.log("vor error");
var data = await memeBurnerStore.getSacrificedRound(this.activeRound)
let rewardData = null;
- if (await walletStore.isConnected()) {
+ if (walletStore.connected) {
rewardData = await rewardLockerStore.getRewardsForAllToken(this.activeRound);
}
console.log("rewardData123", rewardData);
@@ -54,8 +54,8 @@ export const useRoundsStore = defineStore("rounds", {
var goal = await memeBurnerStore.getGoal(this.activeRound);
console.log("goal", goal);
var tokenArray = []
- var rewards_clan = BigInt(0);
- var rewards_sacrifice = BigInt(0);
+ var rewards_clan = 0
+ var rewards_sacrifice = 0
for (let index = 0; index < data.length; index++) {
var tokenData = {};
const token = tokenStore.token[index];
@@ -70,15 +70,16 @@ export const useRoundsStore = defineStore("rounds", {
tokenData.amount = data[index].result[1];
tokenData.getAmountToReachGoal= await memeBurnerStore.getAmountToReachGoal(token.contractAddress);
if (this.currentRound !== this.activeRound && walletStore.connected) {
- console.log("rewarddata", rewardData);
- const clanwin = BigInt((testcoef / 10000 - 1) * rewardData[index]);
- const sacrificeRewards = BigInt(rewardData[index]) - clanwin;
- tokenData.rewards_ges = rewardData[index];
- tokenData.rewards_clan = clanwin;
- tokenData.rewards_sacrifice = sacrificeRewards;
- rewards_clan = rewards_clan + BigInt(clanwin / BigInt(Math.pow(10, token.decimals)));
+ const clanwin = (Number(testcoef) / 10000 - 1) * Number(rewardData[index].result);
+ const sacrificeRewards = Number(rewardData[index].result) - clanwin;
+
+ tokenData.rewards_ges = BigInt(rewardData[index].result);
+ tokenData.rewards_clan = BigInt(clanwin);
+ tokenData.rewards_sacrifice = BigInt(sacrificeRewards);
+
+ rewards_clan = rewards_clan + (clanwin / Math.pow(10, token.decimals));
rewards_sacrifice =
- rewards_sacrifice + BigInt(sacrificeRewards / BigInt(Math.pow(10, token.decimals)));
+ rewards_sacrifice + sacrificeRewards / Math.pow(10, token.decimals);
}
tokenArray.push(tokenData);
}
@@ -87,9 +88,9 @@ export const useRoundsStore = defineStore("rounds", {
goal: goal[0],
goalInBLD: goalInBLD / BigInt(Math.pow(10, tokenStore.memeToken.decimals)),
expirationTimestamp: goal[1],
- rewards_clan: rewards_clan,
- rewards_sacrifice: rewards_sacrifice,
- rewards_total: rewards_clan + rewards_sacrifice,
+ rewards_clan: BigInt(rewards_clan),
+ rewards_sacrifice: BigInt(rewards_sacrifice),
+ rewards_total: BigInt(rewards_clan + rewards_sacrifice),
token: tokenArray,
};
console.log("this.rounds[this.activeRound]", this.rounds[this.activeRound]);
diff --git a/src/stores/walletV2.js b/src/stores/walletV2.js
index 8675fc0..9e63626 100644
--- a/src/stores/walletV2.js
+++ b/src/stores/walletV2.js
@@ -129,42 +129,42 @@ export const useWalletStoreV2 = defineStore("walletV2", {
const result = await token.contract.read.balanceOf([this.address]);
return result;
},
- async isConnected() {
- try {
- this.loading = true;
- if (!window.ethereum) {
- console.warn("Metamask not installed"), (this.connected = false);
- return;
- }
- const accounts = await window.ethereum.request({ method: "eth_accounts" });
- if (accounts.length) {
- this.connected = true;
- this.address = accounts[0];
- console.log(`You're connected to: ${accounts[0]}`);
- // const web3 = new Web3(window.ethereum);
- // const tokenStore = useTokenStore();
- // console.log("tokenStore.activeToken", tokenStore.activeToken);
- // if (tokenStore.activeToken.contractAddress) {
- // tokenStore.activeToken.balance = await this.getTokenBalance(
- // tokenStore.activeToken
- // );
- // tokenStore.activeToken.allowance = await tokenStore.allowance();
- // }
- // tokenStore.memeBurner.contract = new web3.eth.Contract(
- // tokenStore.memeBurner.config.abi,
- // tokenStore.memeBurner.config.contractAddress
- // );
- } else {
- console.log("Metamask is not connected");
- this.connected = false;
- }
- } catch (error) {
- console.log("error", error);
- } finally {
- this.loading = false;
- return this.connected;
- }
- },
+ // async isConnected() {
+ // try {
+ // this.loading = true;
+ // if (!window.ethereum) {
+ // console.warn("Metamask not installed"), (this.connected = false);
+ // return;
+ // }
+ // const accounts = await window.ethereum.request({ method: "eth_accounts" });
+ // if (accounts.length) {
+ // this.connected = true;
+ // this.address = accounts[0];
+ // console.log(`You're connected to: ${accounts[0]}`);
+ // // const web3 = new Web3(window.ethereum);
+ // // const tokenStore = useTokenStore();
+ // // console.log("tokenStore.activeToken", tokenStore.activeToken);
+ // // if (tokenStore.activeToken.contractAddress) {
+ // // tokenStore.activeToken.balance = await this.getTokenBalance(
+ // // tokenStore.activeToken
+ // // );
+ // // tokenStore.activeToken.allowance = await tokenStore.allowance();
+ // // }
+ // // tokenStore.memeBurner.contract = new web3.eth.Contract(
+ // // tokenStore.memeBurner.config.abi,
+ // // tokenStore.memeBurner.config.contractAddress
+ // // );
+ // } else {
+ // console.log("Metamask is not connected");
+ // this.connected = false;
+ // }
+ // } catch (error) {
+ // console.log("error", error);
+ // } finally {
+ // this.loading = false;
+ // return this.connected;
+ // }
+ // },
},
persist: true,
});