contract changes init
This commit is contained in:
+14
-10
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user