comments + contract update +
smaller design issues
This commit is contained in:
+1
-28
@@ -39,7 +39,6 @@ export const useWalletStoreV2 = defineStore("walletV2", {
|
||||
config: null,
|
||||
chain: null,
|
||||
token: [],
|
||||
stateSacrifice: 0,
|
||||
}),
|
||||
getters: {
|
||||
sacrificeToken: (state) => state.token.filter((obj) => {
|
||||
@@ -57,7 +56,6 @@ export const useWalletStoreV2 = defineStore("walletV2", {
|
||||
async init() {
|
||||
console.log("wallet init");
|
||||
|
||||
|
||||
const account = getAccount();
|
||||
|
||||
if (account.address) {
|
||||
@@ -65,24 +63,6 @@ export const useWalletStoreV2 = defineStore("walletV2", {
|
||||
this.connected = true;
|
||||
}
|
||||
|
||||
// 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;
|
||||
// }
|
||||
// });
|
||||
|
||||
},
|
||||
async connectWallet(connector) {
|
||||
try {
|
||||
@@ -103,17 +83,13 @@ export const useWalletStoreV2 = defineStore("walletV2", {
|
||||
// this.address = connection.account;
|
||||
},
|
||||
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() {
|
||||
console.log("getTokenBalances");
|
||||
this.token = []
|
||||
const tokenStore = useTokenStore();
|
||||
console.log("tokenStore.token.length", tokenStore.token.length);
|
||||
var contracts = [];
|
||||
for (let index = 0; index < tokenStore.token.length; index++) {
|
||||
const token = tokenStore.token[index];
|
||||
@@ -123,11 +99,8 @@ export const useWalletStoreV2 = defineStore("walletV2", {
|
||||
const data = await multicall({
|
||||
contracts,
|
||||
});
|
||||
console.log("data", data);
|
||||
for (let index = 0; index < tokenStore.token.length; index++) {
|
||||
const token = tokenStore.token[index];
|
||||
console.log("token", token);
|
||||
console.log("data[index].result", data[index].result);
|
||||
const balanceOfDecimal = data[index].result / BigInt(Math.pow(10, token.decimals));
|
||||
this.token.push({
|
||||
contractAddress: token.contractAddress,
|
||||
@@ -153,5 +126,5 @@ export const useWalletStoreV2 = defineStore("walletV2", {
|
||||
|
||||
}
|
||||
},
|
||||
persist: true,
|
||||
// persist: true,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user