update slideoutpanel, open errors tokeninit

This commit is contained in:
EmberSpirit
2023-08-05 12:03:19 +02:00
parent 6c4933a6a8
commit ceac2a1083
26 changed files with 10440 additions and 16822 deletions
+15 -43
View File
@@ -5,7 +5,6 @@ import { useTokenStore } from "./tokens";
import {
createConfig,
configureChains,
mainnet,
getAccount,
getContract,
connect,
@@ -13,13 +12,14 @@ import {
InjectedConnector,
watchAccount,
getWalletClient,
fetchBalance
} 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 { goerli } from "@wagmi/core/chains";
import { goerli, mainnet } from "@wagmi/core/chains";
import { publicProvider } from "@wagmi/core/providers/public";
import { alchemyProvider } from "@wagmi/core/providers/alchemy";
@@ -30,7 +30,6 @@ export const useWalletStoreV2 = defineStore("walletV2", {
alchemy: null,
connected: false,
address: null,
web3: null,
provider: null,
client: null,
publicClient: null,
@@ -47,7 +46,7 @@ export const useWalletStoreV2 = defineStore("walletV2", {
const projectId = "d8e5ecb0353c02e21d4c0867d4473ac5";
const { chains, publicClient, webSocketPublicClient } = configureChains(
[goerli],
[goerli, mainnet],
[alchemyProvider({ apiKey: goerliKey }), publicProvider()]
);
@@ -84,39 +83,8 @@ export const useWalletStoreV2 = defineStore("walletV2", {
console.log("this.config", this.config);
const walletClient = await getWalletClient();
console.log("walletClient", walletClient);
// await this.isConnected();
// const goerliKey = import.meta.env.VITE_GOERLI_KEY;
// if (this.connected) {
// const web3 = new Web3(window.ethereum);
// this.web3 = markRaw(web3);
// console.log("hierabc");
// window.ethereum.on("accountsChanged", async (data) => {
// console.log("accountsChanged", data);
// console.log("data", data);
// if (data.length > 0) {
// this.address = data[0];
// this.connected = true;
// } else {
// this.address = null;
// this.connected = false;
// }
// });
// // provider = new ethers.BrowserProvider(window.ethereum);
// } else {
// const url = `https://eth-goerli.g.alchemy.com/v2/${goerliKey}`;
// this.web3 = new Web3(url);
// // provider = new ethers.AlchemyProvider("goerli", goerliKey);
// }
// //Websocket
// this.web3socket = new Web3(
// new Web3.providers.WebsocketProvider(`wss://eth-goerli.g.alchemy.com/v2/${goerliKey}`)
// );
},
// connectWalletV2(connector) {
// this.address = data[0];
// },
async connectWallet(connector) {
console.log("connector.name", connector.name);
// if (!account.isConnected) {
@@ -124,16 +92,20 @@ export const useWalletStoreV2 = defineStore("walletV2", {
chainId: goerli.id,
connector: connector,
});
console.log("connection", connection);
// this.address = connection.account;
},
async getTokenBalance(token) {
// const tokenStore = useTokenStore();
// const contract = tokenStore.getTokenContract(token);
// const result = await contract.methods.balanceOf(this.address).call();
console.log("this.address", this.address);
const result = await token.contract.read.balanceOf([this.address]);
return result;
},
async getTokenBalance(token) {
console.log("token", token);
console.log("address", this.address);
// const result = await token.contract.read.balanceOf([this.address]);
// return result;
},
async getTokenBalances() {
//todo
}
// async isConnected() {
// try {
// this.loading = true;