226 lines
5.9 KiB
JavaScript
226 lines
5.9 KiB
JavaScript
import './assets/sass/main.sass'
|
|
import { useWalletStoreV2 } from "@/stores/walletV2";
|
|
import { useTokenStore } from "@/stores/tokens";
|
|
import { useMemeburnerStore } from "@/stores/memeburner";
|
|
import { useRewardLockerStore } from "@/stores/rewardlocker";
|
|
import { useUniswapStore } from "@/stores/uniswap";
|
|
import { useCycleStore } from "@/stores/cycles";
|
|
|
|
import { createApp } from 'vue'
|
|
import { createPinia } from 'pinia'
|
|
import piniaPluginPersistedstate from "pinia-plugin-persistedstate";
|
|
|
|
import {
|
|
createConfig,
|
|
configureChains,
|
|
getNetwork,
|
|
watchAccount,
|
|
watchContractEvent,
|
|
watchNetwork,
|
|
getWalletClient,
|
|
} from "@wagmi/core";
|
|
import { WalletConnectConnector } from "@wagmi/core/connectors/walletConnect";
|
|
import { MetaMaskConnector } from "@wagmi/core/connectors/metaMask";
|
|
import { CoinbaseWalletConnector } from "@wagmi/core/connectors/coinbaseWallet";
|
|
import { InjectedConnector } from "@wagmi/core/connectors/injected";
|
|
|
|
import { goerli, mainnet } from "@wagmi/core/chains";
|
|
import { publicProvider } from "@wagmi/core/providers/public";
|
|
import { alchemyProvider } from "@wagmi/core/providers/alchemy";
|
|
|
|
import App from './App.vue'
|
|
import router from './router'
|
|
|
|
/* import the fontawesome core */
|
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
|
|
|
/* import font awesome icon component */
|
|
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
|
|
|
|
/* import specific icons */
|
|
import { faArrowDown, faArrowRight, faSpinner, faPlus, faCaretLeft, faCaretRight, faBars, faAnglesRight, faChevronDown, faChevronUp, faArrowRightToBracket, faArrowRightFromBracket, faDroplet, faMoon, faPerson, faWallet } from "@fortawesome/free-solid-svg-icons";
|
|
|
|
import { faDiscord, faTwitter, faTelegram } from "@fortawesome/free-brands-svg-icons";
|
|
|
|
import Toast from "vue-toastification";
|
|
// Import the CSS or use your own!
|
|
import "vue-toastification/dist/index.css";
|
|
|
|
/* add icons to the library */
|
|
library.add(
|
|
faArrowDown,
|
|
faArrowRight,
|
|
faDiscord,
|
|
faTwitter,
|
|
faTelegram,
|
|
faSpinner,
|
|
faPlus,
|
|
faCaretLeft,
|
|
faCaretRight,
|
|
faBars,
|
|
faAnglesRight,
|
|
faArrowRightToBracket,
|
|
faArrowRightFromBracket,
|
|
faChevronDown,
|
|
faChevronUp,
|
|
faDroplet,
|
|
faMoon,
|
|
faPerson,
|
|
faWallet
|
|
);
|
|
|
|
var logging = localStorage.getItem("LOGGING");
|
|
if (logging === "true") {
|
|
} else {
|
|
if (!window.console) window.console = {};
|
|
var methods = ["log", "debug", "warn", "info"];
|
|
for (let i = 0; i < methods.length; i++) {
|
|
console[methods[i]] = function () {};
|
|
}
|
|
}
|
|
|
|
const app = createApp(App)
|
|
|
|
|
|
const pinia = createPinia();
|
|
pinia.use(piniaPluginPersistedstate);
|
|
|
|
app.use(pinia);
|
|
|
|
|
|
|
|
app.use(Toast, {
|
|
transition: "Vue-Toastification__fade",
|
|
containerClassName: "bloodline-toast-container",
|
|
});
|
|
|
|
|
|
try {
|
|
const walletStore = useWalletStoreV2();
|
|
const tokenStore = useTokenStore();
|
|
const memeBurnerStore = useMemeburnerStore();
|
|
const rewardLockerStore = useRewardLockerStore();
|
|
const cycleStore = useCycleStore();
|
|
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()]
|
|
);
|
|
|
|
walletStore.config = createConfig({
|
|
autoConnect: true,
|
|
connectors: [
|
|
new CoinbaseWalletConnector({
|
|
chains,
|
|
options: {
|
|
appName: "wagmi demo",
|
|
},
|
|
}),
|
|
new MetaMaskConnector({ chains }),
|
|
new InjectedConnector({
|
|
chains,
|
|
getProvider: () => (typeof window !== "undefined" ? window.myInjectedWallet : undefined),
|
|
}),
|
|
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;
|
|
|
|
watchContractEvent(
|
|
{
|
|
address: memeBurnerStore.config.contractAddress,
|
|
abi: memeBurnerStore.config.abi,
|
|
eventName: "MemeSacrificed",
|
|
},
|
|
async (log) => {
|
|
console.log("memeSacrificedEvent", log);
|
|
const token = log[0].args.sacrificedToken;
|
|
await cycleStore.updateCurrentCycle(token);
|
|
}
|
|
);
|
|
|
|
watchContractEvent(
|
|
{
|
|
address: rewardLockerStore.config.contractAddress,
|
|
abi: rewardLockerStore.config.abi,
|
|
eventName: "CycleCompleted",
|
|
},
|
|
async (log) => {
|
|
console.log("CycleCompleted", log);
|
|
await cycleStore.fillCycle(cycleStore.currentCycle, true);
|
|
cycleStore.currentCycle++;
|
|
await cycleStore.fillCycle(cycleStore.currentCycle, true);
|
|
}
|
|
);
|
|
|
|
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;
|
|
|
|
await memeBurnerStore.init();
|
|
await tokenStore.initV2();
|
|
await rewardLockerStore.init();
|
|
await walletStore.loadWalletData();
|
|
await cycleStore.fillCycle(cycleStore.currentCycle, true);
|
|
await uniswapStore.init();
|
|
} else {
|
|
walletStore.address = null;
|
|
walletStore.connected = false;
|
|
walletStore.walletClient = null;
|
|
}
|
|
});
|
|
|
|
watchNetwork((network) => {
|
|
if (network.chain) {
|
|
walletStore.chain = network.chain;
|
|
}
|
|
});
|
|
|
|
|
|
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)
|
|
app.mount('#app')
|
|
|