rounds implemented + over all improvements
This commit is contained in:
@@ -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();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user