update bigint + smaller style issues fixes
This commit is contained in:
+49
-42
@@ -38,35 +38,43 @@ export const useWalletStoreV2 = defineStore("walletV2", {
|
||||
walletClient: null,
|
||||
config: null,
|
||||
chain: null,
|
||||
token: [],
|
||||
token: [],
|
||||
}),
|
||||
getters: {
|
||||
sacrificeToken: (state) => state.token.filter((obj) => {
|
||||
const tokenStore = useTokenStore();
|
||||
|
||||
return obj.contractAddress !== tokenStore.memeToken.contractAddress;
|
||||
}),
|
||||
memeToken: (state) => state.token.find((obj) => {
|
||||
const tokenStore = useTokenStore();
|
||||
|
||||
return obj.contractAddress === tokenStore.memeToken.contractAddress;
|
||||
}),
|
||||
sacrificeToken: (state) =>
|
||||
state.token.filter((obj) => {
|
||||
const tokenStore = useTokenStore();
|
||||
|
||||
return obj.contractAddress !== tokenStore.memeToken.contractAddress;
|
||||
}),
|
||||
memeToken: (state) =>
|
||||
state.token.find((obj) => {
|
||||
const tokenStore = useTokenStore();
|
||||
|
||||
return obj.contractAddress === tokenStore.memeToken.contractAddress;
|
||||
}),
|
||||
unclaimedRewards() {
|
||||
const tokenStore = useTokenStore();
|
||||
if (!this.memeToken?.unclaimedRewards) {
|
||||
return 0n;
|
||||
}
|
||||
return this.memeToken.unclaimedRewards / 10n ** tokenStore.memeToken.decimals;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
async init() {
|
||||
console.log("wallet init");
|
||||
|
||||
const account = getAccount();
|
||||
|
||||
if (account.address) {
|
||||
this.address = account.address;
|
||||
this.connected = true;
|
||||
}
|
||||
|
||||
const account = getAccount();
|
||||
|
||||
if (account.address) {
|
||||
this.address = account.address;
|
||||
this.connected = true;
|
||||
}
|
||||
},
|
||||
async connectWallet(connector) {
|
||||
try {
|
||||
console.log("connector.name", connector.name);
|
||||
console.log("connector.name", connector.name);
|
||||
// if (!account.isConnected) {
|
||||
const connection = await connect({
|
||||
chainId: goerli.id,
|
||||
@@ -74,12 +82,12 @@ export const useWalletStoreV2 = defineStore("walletV2", {
|
||||
});
|
||||
|
||||
console.log("connection", connection);
|
||||
} catch (error) {
|
||||
if (error.message.includes("Connector not found")) {
|
||||
} catch (error) {
|
||||
if (error.message.includes("Connector not found")) {
|
||||
console.warn("Connector not found");
|
||||
}
|
||||
console.error(error);
|
||||
}
|
||||
console.error(error);
|
||||
}
|
||||
// this.address = connection.account;
|
||||
},
|
||||
async getTokenBalance(token) {
|
||||
@@ -87,8 +95,8 @@ export const useWalletStoreV2 = defineStore("walletV2", {
|
||||
return result;
|
||||
},
|
||||
async getTokenBalances() {
|
||||
console.log("getTokenBalances");
|
||||
this.token = []
|
||||
console.log("getTokenBalances");
|
||||
this.token = [];
|
||||
const tokenStore = useTokenStore();
|
||||
var contracts = [];
|
||||
for (let index = 0; index < tokenStore.token.length; index++) {
|
||||
@@ -100,29 +108,28 @@ export const useWalletStoreV2 = defineStore("walletV2", {
|
||||
contracts,
|
||||
});
|
||||
for (let index = 0; index < tokenStore.token.length; index++) {
|
||||
const token = tokenStore.token[index];
|
||||
const token = tokenStore.token[index];
|
||||
this.token.push({
|
||||
contractAddress: token.contractAddress,
|
||||
balanceOf: data[index].result
|
||||
balanceOf: data[index].result,
|
||||
});
|
||||
}
|
||||
},
|
||||
async loadWalletData() {
|
||||
if (!this.connected) {
|
||||
return
|
||||
}
|
||||
console.log("loadWalletData");
|
||||
},
|
||||
async loadWalletData() {
|
||||
if (!this.connected) {
|
||||
return;
|
||||
}
|
||||
console.log("loadWalletData");
|
||||
const rewardlockerStore = useRewardLockerStore();
|
||||
|
||||
await this.getTokenBalances();
|
||||
//MemeToken Staked
|
||||
const tokenStore = useTokenStore();
|
||||
this.memeToken.staked = await rewardlockerStore.getStaked(this.address);
|
||||
const unclaimedRewardsArray = await rewardlockerStore.getTotalRewards(this.address);
|
||||
const unclaimedRewards = unclaimedRewardsArray[0] + unclaimedRewardsArray[1];
|
||||
this.memeToken.unclaimedRewards = unclaimedRewards
|
||||
|
||||
}
|
||||
await this.getTokenBalances();
|
||||
//MemeToken Staked
|
||||
const tokenStore = useTokenStore();
|
||||
this.memeToken.staked = await rewardlockerStore.getStaked(this.address);
|
||||
const unclaimedRewardsArray = await rewardlockerStore.getTotalRewards(this.address);
|
||||
const unclaimedRewards = unclaimedRewardsArray[0] + unclaimedRewardsArray[1];
|
||||
this.memeToken.unclaimedRewards = unclaimedRewards;
|
||||
},
|
||||
},
|
||||
// persist: true,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user