diff --git a/src/components/ClaimComponent.vue b/src/components/ClaimComponent.vue index 5d3e8a9..ab96d50 100644 --- a/src/components/ClaimComponent.vue +++ b/src/components/ClaimComponent.vue @@ -128,6 +128,7 @@ function openUnstake() { async function stakeAndClaimAllRounds() { try { + const unclaimedRewards = walletStore.memeToken?.unclaimedRewards; stateClaim.value = 2; console.log("tokenNumber.value", tokenNumber.value); console.log("walletStore.memeToken?.unclaimedRewards", walletStore.memeToken?.unclaimedRewards); @@ -140,7 +141,7 @@ async function stakeAndClaimAllRounds() { stateClaim.value = 4; await walletStore.loadWalletData(); showSuccessToast( - walletStore.memeToken?.unclaimedRewards, + unclaimedRewards, "Success!", "You just claimed and staked", "Join the next cycle to increase your rewards and win with your clan" diff --git a/src/stores/rewardlocker.js b/src/stores/rewardlocker.js index 97dd7c0..ed6c720 100644 --- a/src/stores/rewardlocker.js +++ b/src/stores/rewardlocker.js @@ -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; - }, }, });