code clean up + claimcomponent value update#
This commit is contained in:
@@ -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"
|
||||||
|
|||||||
+52
-18
@@ -30,8 +30,13 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
|
|||||||
* @param {*} tokenAddress
|
* @param {*} tokenAddress
|
||||||
* @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) {
|
||||||
return await this.contract.read.rewards([walletAddress, roundNumber, tokenAddress]);
|
try {
|
||||||
|
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");
|
||||||
@@ -53,16 +58,28 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
|
|||||||
// const multicallStore = useMultiCallStore();
|
// const multicallStore = useMultiCallStore();
|
||||||
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() {
|
||||||
return await this.contract.read.lastCompletedRound();
|
try {
|
||||||
|
return await this.contract.read.lastCompletedRound();
|
||||||
|
} catch (error) {
|
||||||
|
console.error("lastCompletedRound", error);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async claim(round) {
|
async claim(round) {
|
||||||
console.log("claim");
|
try {
|
||||||
const walletStore = useWalletStoreV2();
|
console.log("claim");
|
||||||
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) {
|
||||||
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) {
|
async getTotalRewards(address) {
|
||||||
console.log("this.contract", this.contract);
|
try {
|
||||||
const roundsStore = useRoundsStore();
|
console.log("this.contract", this.contract);
|
||||||
const rounds = await roundsStore.getFinshedRoundNumbers();
|
const roundsStore = useRoundsStore();
|
||||||
return await this.contract.read.getTotalRewardsOf([address, rounds]);
|
const rounds = await roundsStore.getFinshedRoundNumbers();
|
||||||
|
return await this.contract.read.getTotalRewardsOf([address, rounds]);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("getTotalRewards", error);
|
||||||
|
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async getStaked(address) {
|
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() {
|
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) {
|
||||||
return await this.contract.write.unstake([unstakeRound]);
|
try {
|
||||||
|
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;
|
||||||
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user