Fixing provider state and wallet change listener, formatting balance

Co-authored-by: RcleydsonR <rafael.cleydson@gmail.com>
This commit is contained in:
brunoedcf
2022-11-16 17:15:56 -03:00
parent 85d76c9e42
commit d7f6294e6d
4 changed files with 52 additions and 34 deletions

View File

@@ -1,21 +1,16 @@
import type { ethers } from "ethers";
import { defineStore } from "pinia";
export const useEtherStore = defineStore("ether", {
state: () => ({
walletAddress: "",
balance: 0,
provider: null as ethers.providers.Web3Provider | null,
balance: "",
}),
actions: {
setWalletAddress(walletAddress: string) {
this.walletAddress = walletAddress;
},
setBalance(balance: number) {
setBalance(balance: string) {
this.balance = balance;
},
setProvider(provider: ethers.providers.Web3Provider | null) {
this.provider = provider;
},
},
});