contract changes init
This commit is contained in:
+47
-38
@@ -3,46 +3,56 @@ import MemeBurnerJson from "@/assets/contracts/MemeBurner.json";
|
||||
import { useTokenStore } from "./tokens";
|
||||
import { useMultiCallStore } from "./multicall";
|
||||
import { useWalletStore } from "./wallet";
|
||||
import { useWalletStoreV2 } from "./walletV2";
|
||||
import { useRoundsStore } from "@/stores/rounds";
|
||||
|
||||
import { multicall, getContract, fetchToken } from "@wagmi/core";
|
||||
|
||||
|
||||
export const useMemeburnerStore = defineStore("memeburner", {
|
||||
state: () => ({
|
||||
config: MemeBurnerJson,
|
||||
contract: null,
|
||||
loading: false,
|
||||
|
||||
contract: null,
|
||||
loading: false,
|
||||
}),
|
||||
getters: {},
|
||||
actions: {
|
||||
async init() {
|
||||
console.log("-----------init memeburner-------------");
|
||||
const walletStore = useWalletStore();
|
||||
const roundsStore = useRoundsStore();
|
||||
|
||||
this.contract = new walletStore.web3.eth.Contract(this.config.abi, this.config.contractAddress);
|
||||
|
||||
const walletStore = useWalletStoreV2();
|
||||
// const roundsStore = useRoundsStore();
|
||||
|
||||
const websocketMemeBurner = new walletStore.web3socket.eth.Contract(
|
||||
this.config.abi,
|
||||
this.config.contractAddress
|
||||
);
|
||||
websocketMemeBurner.events
|
||||
.MemeSacrificed()
|
||||
.on("data", async (event) => {
|
||||
console.log("sacrificedAmount", event.returnValues.sacrificedAmount);
|
||||
console.log("sacrificedToken", event.returnValues.sacrificedToken);
|
||||
await roundsStore.updateCurrentRound(
|
||||
event.returnValues.sacrificedToken,
|
||||
event.returnValues.sacrificedAmount
|
||||
);
|
||||
})
|
||||
.on("error", (error) => console.log("MemeSacrificederror", error));
|
||||
// this.contract = new walletStore.web3.eth.Contract(this.config.abi, this.config.contractAddress);
|
||||
this.contract = getContract({
|
||||
address: this.config.contractAddress,
|
||||
abi: this.config.abi,
|
||||
PublicClient: walletStore.publicClient,
|
||||
WalletClient: walletStore.walletClient,
|
||||
});
|
||||
|
||||
// const websocketMemeBurner = new walletStore.web3socket.eth.Contract(
|
||||
// this.config.abi,
|
||||
// this.config.contractAddress
|
||||
// );
|
||||
// websocketMemeBurner.events
|
||||
// .MemeSacrificed()
|
||||
// .on("data", async (event) => {
|
||||
// console.log("sacrificedAmount", event.returnValues.sacrificedAmount);
|
||||
// console.log("sacrificedToken", event.returnValues.sacrificedToken);
|
||||
// await roundsStore.updateCurrentRound(
|
||||
// event.returnValues.sacrificedToken,
|
||||
// event.returnValues.sacrificedAmount
|
||||
// );
|
||||
// })
|
||||
// .on("error", (error) => console.log("MemeSacrificederror", error));
|
||||
},
|
||||
async getRewardsFor(amount) {
|
||||
async getRewardFor(amount) {
|
||||
const tokenStore = useTokenStore();
|
||||
var rewards = await this.contract.methods
|
||||
.getRewardFor(tokenStore.activeToken.contractAddress, amount)
|
||||
.call();
|
||||
// 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);
|
||||
return rewards;
|
||||
},
|
||||
async getCurrentRound() {
|
||||
@@ -54,10 +64,10 @@ export const useMemeburnerStore = defineStore("memeburner", {
|
||||
//returns participated, amount achieved
|
||||
async getSacrificedMeme(roundnumber, tokenAddress) {
|
||||
return await this.contract.methods.getSacrificedMeme(roundnumber, tokenAddress).call();
|
||||
},
|
||||
async getAmountToReachGoal(tokenAddress) {
|
||||
return await this.contract.methods.getAmountToReachGoal(tokenAddress).call();
|
||||
},
|
||||
},
|
||||
async getAmountToReachGoal(tokenAddress) {
|
||||
return await this.contract.methods.getAmountToReachGoal(tokenAddress).call();
|
||||
},
|
||||
async getSacrificedRound(roundnumber) {
|
||||
console.log("getSacrificedRound", roundnumber);
|
||||
const tokenStore = useTokenStore();
|
||||
@@ -68,9 +78,9 @@ export const useMemeburnerStore = defineStore("memeburner", {
|
||||
console.log("token.contractAddress", token.contractAddress);
|
||||
console.log("roundnumber", roundnumber);
|
||||
var test = await this.getSacrificedMeme(roundnumber, token.contractAddress);
|
||||
console.log(token.name, test);
|
||||
calls.push(this.contract.methods.getSacrificedMeme(roundnumber, token.contractAddress));
|
||||
// calls1.push(this.contract.methods.getAmountToReachGoal(token.contractAddress));
|
||||
console.log(token.name, test);
|
||||
calls.push(this.contract.methods.getSacrificedMeme(roundnumber, token.contractAddress));
|
||||
// calls1.push(this.contract.methods.getAmountToReachGoal(token.contractAddress));
|
||||
}
|
||||
console.log("this.contract", this.contract);
|
||||
const multicallStore = useMultiCallStore();
|
||||
@@ -97,10 +107,9 @@ export const useMemeburnerStore = defineStore("memeburner", {
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
async getGoalInBLD(roundNumber) {
|
||||
},
|
||||
async getGoalInBLD(roundNumber) {
|
||||
return await this.contract.methods.getGoalInBLD(roundNumber).call();
|
||||
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user