delete txt

This commit is contained in:
EmberSpirit
2023-07-10 21:16:30 +02:00
parent 86f4e97f23
commit 9b76ef48e5
12 changed files with 350 additions and 127 deletions
+64
View File
@@ -0,0 +1,64 @@
import { defineStore } from "pinia";
import { useMemeburnerStore } from "./memeburner";
import { useTokenStore } from "./tokens";
import { useRewardLockerStore } from "./rewardlocker";
export const useRoundsStore = defineStore("rounds", {
state: () => ({
rounds: [
],
activeRound: null,
currentRound: null
}),
getters: {
getCurrentRoundData() {
return this.rounds[this.activeRound];
}
},
actions: {
async updateCurrentRound(sacrificedToken, sacrificedAmount) {
const tokenStore = useTokenStore();
const memeBurnerStore = useMemeburnerStore();
var data = await memeBurnerStore.getSacrificedRound(this.currentRound)
var tokenIndex = this.rounds[this.currentRound].token.findIndex((tokenData) => tokenData.contractAddress === sacrificedToken);
this.rounds[this.currentRound].token[tokenIndex].amount = data[tokenIndex][1];
},
async fillRound() {
console.log("fillRound");
const memeBurnerStore = useMemeburnerStore();
const tokenStore = useTokenStore();
const rewardLockerStore = useRewardLockerStore();
// if (this.activeRound === this.currentRound) {
// console.log("activeRound is not completed");
// } else
if (!this.rounds[this.activeRound]) {
console.log("round not filled --> fill round");
var data = await memeBurnerStore.getSacrificedRound(this.activeRound)
var rewardData = await rewardLockerStore.getRewardsForAllToken(this.activeRound);
var goal = await memeBurnerStore.getGoal(this.activeRound);
console.log("data", data);
var tokenArray = []
for (let index = 0; index < data.length; index++) {
var tokenData = {};
const token = tokenStore.token[index];
console.log("token", token);
tokenData.name = token.name;
tokenData.contractAddress = token.contractAddress;
tokenData.vamplogo = token.vamp.logo;
tokenData.vampname = token.vamp.name;
tokenData.amount = data[index][1];
tokenData.rewards = rewardData[index]
tokenArray.push(tokenData);
}
this.rounds[this.activeRound] = {
goal: goal, token: tokenArray
}
} else {
console.log("round already filled");
}
console.log("this.rounds123", this.rounds);
},
},
});