update cycle
This commit is contained in:
+58
-31
@@ -62,9 +62,6 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
|
||||
async claim(round) {
|
||||
console.log("claim");
|
||||
const walletStore = useWalletStoreV2();
|
||||
// return await this.contract.methods.claim(round).call();
|
||||
console.log(this.contract.methods.claim(round));
|
||||
// return await this.contract.methods.claim(round).send({from: walletStore.address, to: this.contractAddress});
|
||||
return await this.contract.write.claim([round]);
|
||||
},
|
||||
async claimAll() {
|
||||
@@ -90,44 +87,74 @@ export const useRewardLockerStore = defineStore("rewardlocker", {
|
||||
},
|
||||
async orderUnstake() {
|
||||
try {
|
||||
return await this.contract.write.orderUnstake();
|
||||
} catch (error) {
|
||||
return;
|
||||
}
|
||||
return await this.contract.write.orderUnstake();
|
||||
} catch (error) {
|
||||
return;
|
||||
}
|
||||
},
|
||||
async unstake(unstakeRound) {
|
||||
return await this.contract.write.unstake([unstakeRound]);
|
||||
},
|
||||
async stakeBloodline(tokenNumber) {
|
||||
console.log("tokenNumber", tokenNumber);
|
||||
const walletStore = useWalletStoreV2();
|
||||
const tokenStore = useTokenStore();
|
||||
},
|
||||
async stakeBloodline(tokenNumber) {
|
||||
console.log("tokenNumber", tokenNumber);
|
||||
const walletStore = useWalletStoreV2();
|
||||
const tokenStore = useTokenStore();
|
||||
|
||||
const fromAddress = walletStore.address;
|
||||
const spender = this.config.contractAddress;
|
||||
const deadline = Date.now() + 20 * 60;
|
||||
const decimals = tokenStore.getToken(walletStore.memeToken.contractAddress).decimals;
|
||||
const value = (tokenNumber * Math.pow(10, decimals)).toString();
|
||||
const nonce = await tokenStore.memeToken.contract.read.nonces([fromAddress]);
|
||||
console.log("nonce", nonce);
|
||||
const { types, message, domain, primaryType } = createPermitObject(fromAddress, spender, nonce, deadline, value);
|
||||
const fromAddress = walletStore.address;
|
||||
const spender = this.config.contractAddress;
|
||||
const deadline = Date.now() + 20 * 60;
|
||||
const decimals = tokenStore.getToken(walletStore.memeToken.contractAddress).decimals;
|
||||
const value = (tokenNumber * Math.pow(10, decimals)).toString();
|
||||
const nonce = await tokenStore.memeToken.contract.read.nonces([fromAddress]);
|
||||
console.log("nonce", nonce);
|
||||
const { types, message, domain, primaryType } = createPermitObject(
|
||||
fromAddress,
|
||||
spender,
|
||||
nonce,
|
||||
deadline,
|
||||
value
|
||||
);
|
||||
|
||||
const signature = await signTypedData({
|
||||
domain: domain,
|
||||
message: message,
|
||||
primaryType: primaryType,
|
||||
types: types,
|
||||
});
|
||||
const signature = await signTypedData({
|
||||
domain: domain,
|
||||
message: message,
|
||||
primaryType: primaryType,
|
||||
types: types,
|
||||
});
|
||||
|
||||
const { r, s, v } = getSignatureRSV(signature);
|
||||
const { r, s, v } = getSignatureRSV(signature);
|
||||
|
||||
const hash = await this.contract.write.stakeToBeSecured([value, deadline, v, r, s]);
|
||||
console.log("hash", hash);
|
||||
const hash = await this.contract.write.stakeToBeSecured([value, deadline, v, r, s]);
|
||||
console.log("hash", hash);
|
||||
|
||||
const data = await waitForTransaction({
|
||||
const data = await waitForTransaction({
|
||||
hash: hash,
|
||||
});
|
||||
console.log("data", data);
|
||||
}
|
||||
},
|
||||
async stakeAndClaimRound(stakeCoefficient, round) {
|
||||
// stakeCoefficient 25% = 2500, 50% = 5000
|
||||
const tokenStore = useTokenStore();
|
||||
const addresses = tokenStore.sacrificeToken.map((obj) => obj.contractAddress);
|
||||
const hash = await this.contract.write.stakeAndClaim([stakeCoefficient, [round], addresses]);
|
||||
const data = await waitForTransaction({
|
||||
hash: hash,
|
||||
});
|
||||
const walletStore = useWalletStoreV2();
|
||||
await walletStore.loadWalletData();
|
||||
// todo reload roundData and wallet data
|
||||
},
|
||||
async stakeAndClaimAllRounds(stakeCoefficient) {
|
||||
console.log("stakeAndClaimAllRounds");
|
||||
const tokenStore = useTokenStore();
|
||||
const roundsStore = useRoundsStore();
|
||||
const rounds = await roundsStore.getFinshedRoundNumbers();
|
||||
const addresses = tokenStore.sacrificeToken.map((obj) => obj.contractAddress);
|
||||
console.log({ stakeCoefficient, rounds, addresses });
|
||||
const hash = await this.contract.write.stakeAndClaim([stakeCoefficient, rounds, addresses]);
|
||||
// todo reload roundData and wallet data
|
||||
const walletStore = useWalletStoreV2();
|
||||
await walletStore.loadWalletData();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user