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
+2 -1
View File
@@ -128,6 +128,7 @@ function openUnstake() {
async function stakeAndClaimAllRounds() { async function stakeAndClaimAllRounds() {
try { try {
const unclaimedRewards = walletStore.memeToken?.unclaimedRewards;
stateClaim.value = 2; stateClaim.value = 2;
console.log("tokenNumber.value", tokenNumber.value); console.log("tokenNumber.value", tokenNumber.value);
console.log("walletStore.memeToken?.unclaimedRewards", walletStore.memeToken?.unclaimedRewards); console.log("walletStore.memeToken?.unclaimedRewards", walletStore.memeToken?.unclaimedRewards);
@@ -140,7 +141,7 @@ async function stakeAndClaimAllRounds() {
stateClaim.value = 4; stateClaim.value = 4;
await walletStore.loadWalletData(); await walletStore.loadWalletData();
showSuccessToast( showSuccessToast(
walletStore.memeToken?.unclaimedRewards, unclaimedRewards,
"Success!", "Success!",
"You just claimed and staked", "You just claimed and staked",
"Join the next cycle to increase your rewards and win with your clan" "Join the next cycle to increase your rewards and win with your clan"
+37 -3
View File
@@ -31,7 +31,12 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
* @returns Rewards for specific token and specific round * @returns Rewards for specific token and specific round
*/ */
async getRewards(walletAddress, roundNumber, tokenAddress) { async getRewards(walletAddress, roundNumber, tokenAddress) {
try {
return await this.contract.read.rewards([walletAddress, roundNumber, tokenAddress]); return await this.contract.read.rewards([walletAddress, roundNumber, tokenAddress]);
} catch (error) {
console.error("getRewards", error);
}
}, },
async getRewardsForAllToken(roundNumber) { async getRewardsForAllToken(roundNumber) {
console.log("getRewardsForAllToken"); console.log("getRewardsForAllToken");
@@ -54,15 +59,27 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
return data; return data;
}, },
async getSacrificedTokenCoefficient(roundNumber, sacrificedToken) { async getSacrificedTokenCoefficient(roundNumber, sacrificedToken) {
try {
return await this.contract.read.getSacrificedTokenCoefficient([roundNumber, sacrificedToken]); return await this.contract.read.getSacrificedTokenCoefficient([roundNumber, sacrificedToken]);
} catch (error) {
console.error("getSacrificedTokenCoefficient", error);
}
}, },
async lastCompletedRound() { async lastCompletedRound() {
try {
return await this.contract.read.lastCompletedRound(); return await this.contract.read.lastCompletedRound();
} catch (error) {
console.error("lastCompletedRound", error);
}
}, },
async claim(round) { async claim(round) {
try {
console.log("claim"); console.log("claim");
const walletStore = useWalletStoreV2();
return await this.contract.write.claim([round]); return await this.contract.write.claim([round]);
} catch (error) {
console.error("claim", error);
}
}, },
async claimAll() { async claimAll() {
console.log("claimAll"); console.log("claimAll");
@@ -74,26 +91,44 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
return await this.contract.write.claim([rounds]); return await this.contract.write.claim([rounds]);
}, },
async getTotalRewardsOf(address, rounds) { async getTotalRewardsOf(address, rounds) {
try {
return await this.contract.read.getTotalRewardsOf([address, rounds]); return await this.contract.read.getTotalRewardsOf([address, rounds]);
} catch (error) {
console.error("getTotalRewardsOf", error);
}
}, },
async getTotalRewards(address) { async getTotalRewards(address) {
try {
console.log("this.contract", this.contract); console.log("this.contract", this.contract);
const roundsStore = useRoundsStore(); const roundsStore = useRoundsStore();
const rounds = await roundsStore.getFinshedRoundNumbers(); const rounds = await roundsStore.getFinshedRoundNumbers();
return await this.contract.read.getTotalRewardsOf([address, rounds]); return await this.contract.read.getTotalRewardsOf([address, rounds]);
} catch (error) {
console.error("getTotalRewards", error);
}
}, },
async getStaked(address) { async getStaked(address) {
try {
return await this.contract.read.staked([address]); return await this.contract.read.staked([address]);
} catch (error) {
console.error("getStaked", error);
}
}, },
async orderUnstake() { async orderUnstake() {
try { try {
return await this.contract.write.orderUnstake(); return await this.contract.write.orderUnstake();
} catch (error) { } catch (error) {
return; console.error("orderUnstake", error);
} }
}, },
async unstake(unstakeRound) { async unstake(unstakeRound) {
try {
return await this.contract.write.unstake([unstakeRound]); return await this.contract.write.unstake([unstakeRound]);
} catch (error) {
console.error("unstake", error);
}
}, },
async stakeBloodline(tokenNumber) { async stakeBloodline(tokenNumber) {
console.log("tokenNumber", tokenNumber); console.log("tokenNumber", tokenNumber);
@@ -151,7 +186,6 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
var stakeCoefficientInt = Math.round(stakeCoefficient); var stakeCoefficientInt = Math.round(stakeCoefficient);
const hash = await this.contract.write.stakeAndClaim([stakeCoefficientInt, rounds, addresses]); const hash = await this.contract.write.stakeAndClaim([stakeCoefficientInt, rounds, addresses]);
return hash; return hash;
}, },
}, },
}); });