Skip to content

Commit

Permalink
Merge pull request #76 from re2005/main
Browse files Browse the repository at this point in the history
fix: metamask can't clone reactive object
  • Loading branch information
re2005 authored Aug 24, 2022
2 parents fa91313 + 245cd9e commit f4fb4f7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Step 2. By default, VueDapp includes `Mainnet` and `Goerli` networks, but you ca
```javascript
app.use(VueDapp, {
80001: {
chainId: '0x' + 80001,
chainId: ethers.utils.hexValue(80001),
blockExplorerUrls: ['https://mumbai.polygonscan.com/'],
chainName: 'Mumbai',
rpcUrls: ['https://rpc-mumbai.maticvigil.com/'],
Expand Down
3 changes: 2 additions & 1 deletion demo/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import App from './App.vue'
import 'windi.css'
import './style.css'
import { VueDapp } from 'vue-dapp'
import { ethers } from 'ethers'

const app = createApp(App)

app.use(VueDapp, {
80001: {
chainId: '0x' + 80001,
chainId: ethers.utils.hexValue(80001),
blockExplorerUrls: ['https://mumbai.polygonscan.com/'],
chainName: 'Mumbai',
rpcUrls: ['https://rpc-mumbai.maticvigil.com/'],
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Step 2. By default, VueDapp includes `Mainnet` and `Goerli` networks, but you ca
```javascript
app.use(VueDapp, {
80001: {
chainId: '0x' + 80001,
chainId: ethers.utils.hexValue(80001),
blockExplorerUrls: ['https://mumbai.polygonscan.com/'],
chainName: 'Mumbai',
rpcUrls: ['https://rpc-mumbai.maticvigil.com/'],
Expand Down
5 changes: 4 additions & 1 deletion src/wallets/metaMask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ export class MetaMaskConnector extends Connector<
if (!this.#provider) throw new ProviderNotFoundError()
const id = hexValue(chainId)
const { availableNetworks } = useEthers() as any
const _availableNetworks = JSON.parse(
JSON.stringify(availableNetworks.value),
)

try {
await this.#provider.request({
Expand All @@ -195,7 +198,7 @@ export class MetaMaskConnector extends Connector<
if ((<ProviderRpcError>err).code === 4902) {
try {
await this.addChain(
availableNetworks[
_availableNetworks[
chainId as keyof typeof NETWORK_DETAILS
] as AddEthereumChainParameter,
)
Expand Down

0 comments on commit f4fb4f7

Please sign in to comment.