rounds implemented + over all improvements

This commit is contained in:
EmberSpirit
2023-07-10 21:18:05 +02:00
parent 86f4e97f23
commit 9565f494ea
12 changed files with 350 additions and 127 deletions
+21
View File
@@ -1,5 +1,8 @@
import { defineStore } from "pinia";
import RewardLockerJson from "@/assets/contracts/RewardLocker.json";
import { useTokenStore } from "./tokens";
import { useMultiCallStore } from "./multicall";
import { useWalletStore } from "./wallet";
export const useRewardLockerStore = defineStore("rewardlocker", {
state: () => ({
@@ -17,8 +20,26 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
async getRewards(walletAddress, roundNumber, tokenAddress) {
return await this.contract.methods.rewards(walletAddress, roundNumber, tokenAddress).call();
},
async getRewardsForAllToken(roundNumber) {
console.log("getRewardsForAllToken");
const tokenStore = useTokenStore();
const walletStore = useWalletStore();
const calls = [];
for (let index = 0; index < tokenStore.token.length; index++) {
const token = tokenStore.token[index];
calls.push(this.contract.methods.rewards(walletStore.address, roundNumber, token.contractAddress));
}
const multicallStore = useMultiCallStore();
return await multicallStore.aggregate(calls);
},
async lastCompletedRound() {
return await this.contract.methods.lastCompletedRound().call();
},
async claim(round) {
return await this.contract.methods.claim(round).call();
},
async getTotalRewardsOf(address, rounds) {
return await this.contract.methods.getTotalRewardsOf(address, rounds).call();
},
},
});