Skip to content

Commit

Permalink
Replace availableProvider.value with getBrowserProvider method in eth…
Browse files Browse the repository at this point in the history
…ers.js
  • Loading branch information
ccali11 committed May 19, 2023
1 parent 69ee3c9 commit f5d7231
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions apps/web/src/composables/ethers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function useEthers() {
const ethersProviderList = ['BraveWallet', 'CoinbaseWallet', 'MetaMask', 'OkxWallet', 'TrustWallet']

async function addEthersNetwork (providerString: ProviderString, network: any) {
const provider = availableProviders.value[providerString as keyof BrowserProviders]
const provider = getBrowserProvider(providerString)
try {
await provider.request({
method: 'wallet_addEthereumChain',
Expand Down Expand Up @@ -134,7 +134,7 @@ export default function useEthers() {

async function getEthersBrowserProviderSelectedCurrency(providerString: ProviderString) {
// IOTEX Smart Contract Address: 0x6fb3e0a217407efff7ca062d46c26e5d60a14d69
const browserProvider = availableProviders.value[providerString as keyof BrowserProviders]
const browserProvider = getBrowserProvider(providerString)
const web3Provider: ethers.providers.Web3Provider = new ethers.providers.Web3Provider(browserProvider as EthersProvider)
const network = await web3Provider.getNetwork()
// console.log('network.chainId :>> ', network.chainId)
Expand Down Expand Up @@ -202,7 +202,7 @@ export default function useEthers() {

async function signEthersMessage(messageInit: MessageInit): Promise<string> {
const { providerString, message } = messageInit
const browserProvider = availableProviders.value[providerString as keyof BrowserProviders]
const browserProvider = getBrowserProvider(providerString)
const web3Provider: ethers.providers.Web3Provider =
new ethers.providers.Web3Provider(browserProvider as EthersProvider)
const signer = web3Provider.getSigner()
Expand All @@ -211,7 +211,7 @@ export default function useEthers() {
}

async function switchEthersNetwork (providerString: ProviderString, chainId: string) {
const provider = availableProviders.value[providerString as keyof BrowserProviders]
const provider = getBrowserProvider(providerString)
const currentChainId = await provider.networkVersion
if (chainId === '5') {
chainId = '0x5'
Expand Down

0 comments on commit f5d7231

Please sign in to comment.