update getRewardsFor function
This commit is contained in:
+136
-137
@@ -89,156 +89,155 @@ app.use(pinia);
|
||||
app.use(Toast, {});
|
||||
|
||||
|
||||
const walletStore = useWalletStoreV2();
|
||||
const tokenStore = useTokenStore();
|
||||
const memeBurnerStore = useMemeburnerStore();
|
||||
const rewardLockerStore = useRewardLockerStore();
|
||||
const roundsStore = useRoundsStore();
|
||||
const uniswapStore = useUniswapStore();
|
||||
try {
|
||||
const walletStore = useWalletStoreV2();
|
||||
const tokenStore = useTokenStore();
|
||||
const memeBurnerStore = useMemeburnerStore();
|
||||
const rewardLockerStore = useRewardLockerStore();
|
||||
const roundsStore = useRoundsStore();
|
||||
const uniswapStore = useUniswapStore();
|
||||
|
||||
const goerliKey = import.meta.env.VITE_GOERLI_KEY;
|
||||
const projectId = "d8e5ecb0353c02e21d4c0867d4473ac5";
|
||||
console.log("hier chains");
|
||||
const { chains, publicClient, webSocketPublicClient } = configureChains(
|
||||
[goerli, mainnet],
|
||||
[alchemyProvider({ apiKey: goerliKey }), publicProvider()]
|
||||
);
|
||||
|
||||
const goerliKey = import.meta.env.VITE_GOERLI_KEY;
|
||||
const projectId = "d8e5ecb0353c02e21d4c0867d4473ac5";
|
||||
console.log("hier chains");
|
||||
const { chains, publicClient, webSocketPublicClient } = configureChains(
|
||||
[goerli, mainnet],
|
||||
[alchemyProvider({ apiKey: goerliKey }), publicProvider()]
|
||||
);
|
||||
|
||||
|
||||
walletStore.config = createConfig({
|
||||
autoConnect: true,
|
||||
connectors: [
|
||||
new CoinbaseWalletConnector({
|
||||
chains,
|
||||
options: {
|
||||
appName: "wagmi demo",
|
||||
},
|
||||
}),
|
||||
new MetaMaskConnector({ chains }),
|
||||
new WalletConnectConnector({
|
||||
chains,
|
||||
options: {
|
||||
projectId: projectId,
|
||||
showQrModal: true,
|
||||
metadata: {
|
||||
name: "Bloodline-App",
|
||||
description: "TODO Bloodline Description",
|
||||
url: "https://gitea.loseyourip.com/",
|
||||
icons: ["https://gitea.loseyourip.com/assets/img/vampir.png"],
|
||||
walletStore.config = createConfig({
|
||||
autoConnect: true,
|
||||
connectors: [
|
||||
new CoinbaseWalletConnector({
|
||||
chains,
|
||||
options: {
|
||||
appName: "wagmi demo",
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
publicClient,
|
||||
webSocketPublicClient,
|
||||
});
|
||||
walletStore.publicClient = publicClient;
|
||||
}),
|
||||
new MetaMaskConnector({ chains }),
|
||||
new WalletConnectConnector({
|
||||
chains,
|
||||
options: {
|
||||
projectId: projectId,
|
||||
showQrModal: true,
|
||||
metadata: {
|
||||
name: "Bloodline-App",
|
||||
description: "TODO Bloodline Description",
|
||||
url: "https://gitea.loseyourip.com/",
|
||||
icons: ["https://gitea.loseyourip.com/assets/img/vampir.png"],
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
publicClient,
|
||||
webSocketPublicClient,
|
||||
});
|
||||
walletStore.publicClient = publicClient;
|
||||
|
||||
const networkId = getNetwork()?.chain?.id;
|
||||
const networkId = getNetwork()?.chain?.id;
|
||||
|
||||
// watchWalletClient(
|
||||
// {
|
||||
// chainId: networkId,
|
||||
// },
|
||||
// async (walletClient) => {
|
||||
// console.log("watchWalletClient", walletClient);
|
||||
// walletStore.walletClient = walletClient;
|
||||
// }
|
||||
// );
|
||||
// watchWalletClient(
|
||||
// {
|
||||
// chainId: networkId,
|
||||
// },
|
||||
// async (walletClient) => {
|
||||
// console.log("watchWalletClient", walletClient);
|
||||
// walletStore.walletClient = walletClient;
|
||||
// }
|
||||
// );
|
||||
|
||||
// watchPublicClient(
|
||||
// {
|
||||
// chainId: networkId,
|
||||
// },
|
||||
// (publicClient) => console.log("publicClient", publicClient)
|
||||
// );
|
||||
// watchPublicClient(
|
||||
// {
|
||||
// chainId: networkId,
|
||||
// },
|
||||
// (publicClient) => console.log("publicClient", publicClient)
|
||||
// );
|
||||
|
||||
watchContractEvent(
|
||||
{
|
||||
address: memeBurnerStore.config.contractAddress,
|
||||
abi: memeBurnerStore.config.abi,
|
||||
eventName: "MemeSacrificed",
|
||||
},
|
||||
async (log) => {
|
||||
console.log("memeSacrificedEvent", log);
|
||||
const token = log[0].args.sacrificedToken;
|
||||
await roundsStore.updateCurrentRound(token);
|
||||
}
|
||||
);
|
||||
|
||||
watchContractEvent(
|
||||
{
|
||||
address: rewardLockerStore.config.contractAddress,
|
||||
abi: rewardLockerStore.config.abi,
|
||||
eventName: "RoundCompleted",
|
||||
},
|
||||
async (log) => {
|
||||
console.log("roundCompleted", log);
|
||||
await roundsStore.fillRound(roundsStore.currentRound);
|
||||
roundsStore.currentRound++;
|
||||
await roundsStore.fillRound(roundsStore.currentRound);
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
watchAccount(async (account) => {
|
||||
console.log("watchAccount", account);
|
||||
|
||||
// {chainId: }
|
||||
if (account.address) {
|
||||
walletStore.address = account.address;
|
||||
walletStore.connected = true;
|
||||
let chainObject = walletStore.chain;
|
||||
if (!walletStore.chain) {
|
||||
const { chain, chains } = getNetwork();
|
||||
chainObject = chain;
|
||||
watchContractEvent(
|
||||
{
|
||||
address: memeBurnerStore.config.contractAddress,
|
||||
abi: memeBurnerStore.config.abi,
|
||||
eventName: "MemeSacrificed",
|
||||
},
|
||||
async (log) => {
|
||||
console.log("memeSacrificedEvent", log);
|
||||
const token = log[0].args.sacrificedToken;
|
||||
await roundsStore.updateCurrentRound(token);
|
||||
}
|
||||
var walletClient = await getWalletClient({
|
||||
account: account.address,
|
||||
chainId: chainObject.id,
|
||||
});
|
||||
);
|
||||
|
||||
walletStore.walletClient = walletClient;
|
||||
|
||||
await memeBurnerStore.init();
|
||||
await tokenStore.initV2();
|
||||
await rewardLockerStore.init();
|
||||
await walletStore.loadWalletData();
|
||||
await uniswapStore.init();
|
||||
} else {
|
||||
walletStore.address = null;
|
||||
walletStore.connected = false;
|
||||
walletStore.walletClient = null;
|
||||
}
|
||||
});
|
||||
watchContractEvent(
|
||||
{
|
||||
address: rewardLockerStore.config.contractAddress,
|
||||
abi: rewardLockerStore.config.abi,
|
||||
eventName: "RoundCompleted",
|
||||
},
|
||||
async (log) => {
|
||||
console.log("roundCompleted", log);
|
||||
await roundsStore.fillRound(roundsStore.currentRound);
|
||||
roundsStore.currentRound++;
|
||||
await roundsStore.fillRound(roundsStore.currentRound);
|
||||
}
|
||||
);
|
||||
|
||||
watchNetwork((network) => {
|
||||
if (network.chain) {
|
||||
walletStore.chain = network.chain;
|
||||
}
|
||||
});
|
||||
watchAccount(async (account) => {
|
||||
console.log("watchAccount", account);
|
||||
|
||||
// {chainId: }
|
||||
if (account.address) {
|
||||
walletStore.address = account.address;
|
||||
walletStore.connected = true;
|
||||
let chainObject = walletStore.chain;
|
||||
if (!walletStore.chain) {
|
||||
const { chain, chains } = getNetwork();
|
||||
chainObject = chain;
|
||||
}
|
||||
var walletClient = await getWalletClient({
|
||||
account: account.address,
|
||||
chainId: chainObject.id,
|
||||
});
|
||||
|
||||
walletStore.walletClient = walletClient;
|
||||
|
||||
// watchContractEvent(
|
||||
// {
|
||||
// address: memeBurnerStore.config.contractAddress,
|
||||
// abi: memeBurnerStore.config.abi,
|
||||
// eventName: "MemeSacrificed",
|
||||
// },
|
||||
// async (log) => {
|
||||
// console.log("memeSacrificedEvent", log);
|
||||
// const token = log[0].args.sacrificedToken;
|
||||
// await roundsStore.updateCurrentRound(token);
|
||||
// }
|
||||
// );
|
||||
|
||||
await walletStore.init();
|
||||
await tokenStore.initV2();
|
||||
await memeBurnerStore.init();
|
||||
await rewardLockerStore.init();
|
||||
await memeBurnerStore.init();
|
||||
await memeBurnerStore.init();
|
||||
await tokenStore.initV2();
|
||||
await rewardLockerStore.init();
|
||||
await walletStore.loadWalletData();
|
||||
await uniswapStore.init();
|
||||
} else {
|
||||
walletStore.address = null;
|
||||
walletStore.connected = false;
|
||||
walletStore.walletClient = null;
|
||||
}
|
||||
});
|
||||
|
||||
watchNetwork((network) => {
|
||||
if (network.chain) {
|
||||
walletStore.chain = network.chain;
|
||||
}
|
||||
});
|
||||
|
||||
// watchContractEvent(
|
||||
// {
|
||||
// address: memeBurnerStore.config.contractAddress,
|
||||
// abi: memeBurnerStore.config.abi,
|
||||
// eventName: "MemeSacrificed",
|
||||
// },
|
||||
// async (log) => {
|
||||
// console.log("memeSacrificedEvent", log);
|
||||
// const token = log[0].args.sacrificedToken;
|
||||
// await roundsStore.updateCurrentRound(token);
|
||||
// }
|
||||
// );
|
||||
|
||||
await walletStore.init();
|
||||
await tokenStore.initV2();
|
||||
await memeBurnerStore.init();
|
||||
await rewardLockerStore.init();
|
||||
await memeBurnerStore.init();
|
||||
} catch (error) {
|
||||
console.error("main-init", error)
|
||||
}
|
||||
|
||||
app.use(router)
|
||||
app.component('font-awesome-icon', FontAwesomeIcon)
|
||||
|
||||
Reference in New Issue
Block a user