code clean up + claimcomponent value update#

This commit is contained in:
EmberSpirit
2023-10-06 16:14:18 +02:00
parent dd7a0a113d
commit ea60d365d5
2 changed files with 54 additions and 19 deletions
+52 -18
View File
@@ -30,8 +30,13 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
* @param {*} tokenAddress
* @returns Rewards for specific token and specific round
*/
async getRewards(walletAddress, roundNumber, tokenAddress) {
return await this.contract.read.rewards([walletAddress, roundNumber, tokenAddress]);
async getRewards(walletAddress, roundNumber, tokenAddress) {
try {
return await this.contract.read.rewards([walletAddress, roundNumber, tokenAddress]);
} catch (error) {
console.error("getRewards", error);
}
},
async getRewardsForAllToken(roundNumber) {
console.log("getRewardsForAllToken");
@@ -53,16 +58,28 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
// const multicallStore = useMultiCallStore();
return data;
},
async getSacrificedTokenCoefficient(roundNumber, sacrificedToken) {
async getSacrificedTokenCoefficient(roundNumber, sacrificedToken) {
try {
return await this.contract.read.getSacrificedTokenCoefficient([roundNumber, sacrificedToken]);
} catch (error) {
console.error("getSacrificedTokenCoefficient", error);
}
},
async lastCompletedRound() {
return await this.contract.read.lastCompletedRound();
try {
return await this.contract.read.lastCompletedRound();
} catch (error) {
console.error("lastCompletedRound", error);
}
},
async claim(round) {
console.log("claim");
const walletStore = useWalletStoreV2();
return await this.contract.write.claim([round]);
try {
console.log("claim");
return await this.contract.write.claim([round]);
} catch (error) {
console.error("claim", error);
}
},
async claimAll() {
console.log("claimAll");
@@ -74,26 +91,44 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
return await this.contract.write.claim([rounds]);
},
async getTotalRewardsOf(address, rounds) {
return await this.contract.read.getTotalRewardsOf([address, rounds]);
try {
return await this.contract.read.getTotalRewardsOf([address, rounds]);
} catch (error) {
console.error("getTotalRewardsOf", error);
}
},
async getTotalRewards(address) {
console.log("this.contract", this.contract);
const roundsStore = useRoundsStore();
const rounds = await roundsStore.getFinshedRoundNumbers();
return await this.contract.read.getTotalRewardsOf([address, rounds]);
try {
console.log("this.contract", this.contract);
const roundsStore = useRoundsStore();
const rounds = await roundsStore.getFinshedRoundNumbers();
return await this.contract.read.getTotalRewardsOf([address, rounds]);
} catch (error) {
console.error("getTotalRewards", error);
}
},
async getStaked(address) {
return await this.contract.read.staked([address]);
try {
return await this.contract.read.staked([address]);
} catch (error) {
console.error("getStaked", error);
}
},
async orderUnstake() {
try {
return await this.contract.write.orderUnstake();
} catch (error) {
return;
} catch (error) {
console.error("orderUnstake", error);
}
},
async unstake(unstakeRound) {
return await this.contract.write.unstake([unstakeRound]);
async unstake(unstakeRound) {
try {
return await this.contract.write.unstake([unstakeRound]);
} catch (error) {
console.error("unstake", error);
}
},
async stakeBloodline(tokenNumber) {
console.log("tokenNumber", tokenNumber);
@@ -151,7 +186,6 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
var stakeCoefficientInt = Math.round(stakeCoefficient);
const hash = await this.contract.write.stakeAndClaim([stakeCoefficientInt, rounds, addresses]);
return hash;
},
},
});