contract changes init

This commit is contained in:
Michel Fromme
2023-07-27 12:29:12 +02:00
parent 0bab85fe75
commit 5157308745
5 changed files with 109 additions and 94 deletions
+14 -10
View File
@@ -9,7 +9,8 @@ import {
getAccount,
getContract,
connect,
getWalletClient,
getWalletClient,
getPublicClient,
disconnect,
InjectedConnector,
watchAccount,
@@ -33,12 +34,12 @@ export const useWalletStoreV2 = defineStore("walletV2", {
web3: null,
provider: null,
client: null,
pubilcClient: null,
publicClient: null,
walletClient: null,
config: null
}),
getters: {},
actions: {
actions: {
async init() {
console.log("wallet init");
@@ -48,8 +49,8 @@ export const useWalletStoreV2 = defineStore("walletV2", {
const { chains, publicClient, webSocketPublicClient } = configureChains(
[goerli],
[alchemyProvider({ apiKey: goerliKey }), publicProvider()]
);
);
this.config = createConfig({
autoConnect: true,
connectors: [
@@ -76,8 +77,9 @@ export const useWalletStoreV2 = defineStore("walletV2", {
],
publicClient,
webSocketPublicClient,
});
});
this.publicClient = publicClient;
this.walletClient = await getWalletClient();
// await this.isConnected();
// const goerliKey = import.meta.env.VITE_GOERLI_KEY;
// if (this.connected) {
@@ -121,9 +123,11 @@ export const useWalletStoreV2 = defineStore("walletV2", {
// this.address = connection.account;
},
async getTokenBalance(token) {
const tokenStore = useTokenStore();
const contract = tokenStore.getTokenContract(token);
const result = await contract.methods.balanceOf(this.address).call();
// 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 isConnected() {