update contracts+ desktop version

This commit is contained in:
EmberSpirit
2023-09-24 11:38:12 +02:00
parent 1b2ea9b2a2
commit 5c7053c0d9
40 changed files with 2327 additions and 2586 deletions
+32 -26
View File
@@ -19,21 +19,21 @@ export const useMemeburnerStore = defineStore("memeburner", {
console.log("-----------init memeburner-------------");
const walletStore = useWalletStoreV2();
// const roundsStore = useRoundsStore();
console.log("walletStore.walletClient", walletStore.walletClient);
console.log("walletStore.walletClient", walletStore.walletClient);
this.contract = getContract({
address: this.config.contractAddress,
abi: this.config.abi,
walletClient: walletStore.walletClient || walletStore.publicClient,
});
console.log("this.contract", this.contract);
abi: this.config.abi,
walletClient: walletStore.walletClient || walletStore.publicClient,
});
console.log("this.contract", this.contract);
},
async getRewardFor(amount) {
const tokenStore = useTokenStore();
// var rewards = await this.contract.methods
// .getRewardFor(tokenStore.activeToken.contractAddress, amount)
// .call();
const rewards = await this.contract.read.getRewardFor([tokenStore.activeToken.contractAddress, amount]);
console.log("rewards", rewards);
const rewards = await this.contract.read.getRewardForSacrifice([
tokenStore.activeToken.contractAddress,
amount,
]);
console.log("rewards", rewards);
return rewards;
},
async getCurrentRound() {
@@ -47,7 +47,7 @@ export const useMemeburnerStore = defineStore("memeburner", {
return await this.contract.read.getSacrificedMeme([roundnumber, tokenAddress]);
},
async getAmountToReachGoal(tokenAddress) {
return await this.contract.read.getAmountToReachGoal([tokenAddress]);
return await this.contract.read.getAmountToReachGoal([tokenAddress, 0]);
},
async getSacrificedRound(roundnumber) {
console.log("getSacrificedRound", roundnumber);
@@ -58,15 +58,19 @@ export const useMemeburnerStore = defineStore("memeburner", {
console.log("token.contractAddress", token.contractAddress);
console.log("roundnumber", roundnumber);
// contracts.push(this.contract.methods.getSacrificedMeme(roundnumber, token.contractAddress));
contracts.push({ ...this.contract, functionName: "getSacrificedMeme", args: [roundnumber, token.contractAddress] });
contracts.push({
...this.contract,
functionName: "getSacrificedMeme",
args: [roundnumber, token.contractAddress],
});
}
// console.log("this.contract", this.contract);
// const multicallStore = useMultiCallStore();
// return await multicallStore.aggregate(calls);
const data = await multicall({
const data = await multicall({
contracts,
});
return data;
});
return data;
},
async sacrificeMeme(amount) {
const tokenStore = useTokenStore();
@@ -75,25 +79,27 @@ export const useMemeburnerStore = defineStore("memeburner", {
//todo error
console.error("amount is 0 or null or undefined");
return;
}
}
this.loading = true;
const amountDecimal = BigInt(amount * Math.pow(10, tokenStore.activeToken.decimals));
console.log("this.contract", this.contract);
console.log("amountDecimal", amountDecimal.toString());
console.log("tokenStore.activeToken.contractAddress", tokenStore.activeToken.contractAddress);
var hash = await this.contract.write
.sacrificeMeme([tokenStore.activeToken.contractAddress, amountDecimal.toString()])
return hash;
console.log("this.contract", this.contract);
console.log("amountDecimal", amountDecimal.toString());
console.log("tokenStore.activeToken.contractAddress", tokenStore.activeToken.contractAddress);
var hash = await this.contract.write.sacrificeMeme([
tokenStore.activeToken.contractAddress,
amountDecimal.toString(),
0
]);
return hash;
} catch (error) {
console.error(error);
throw new Error(error)
throw new Error(error);
} finally {
this.loading = false;
}
},
async getGoalInBLD(roundNumber) {
return await this.contract.read.getGoalInBLD([roundNumber]);
async getGoalInBLOOD(roundNumber) {
return await this.contract.read.getGoalInBLOOD([roundNumber]);
},
},
});