Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace walletconnet library #832

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
},
"dependencies": {
"@amcharts/amcharts4": "^4.10.13",
"@anxolin/walletconnect-connector": "6.1.9",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@josojo What would we have to have from this @anxolin library to adapt to this repository?

I have tested the minerva wallet with the new web3-react library, and found no problems.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you don't need to use my library any more :)
u are welcome to use it, but this was a temporal fix while they would accept my PR

"@web3-react/walletconnect-connector": "^6.2.8",
"@babel/helper-define-map": "^7.12.13",
"@babel/helper-regex": "^7.10.5",
"@ethersproject/address": "^5.0.0-beta.134",
Expand Down Expand Up @@ -148,7 +148,7 @@
"use-media": "^1.4.0"
},
"resolutions": {
"@walletconnect/web3-provider": "1.4.2-rc.2"
"@walletconnect/ethereum-provider": "1.6.4"
},
"lint-staged": {
"src/**/*.{js,jsx,ts,tsx}": [
Expand Down
14 changes: 6 additions & 8 deletions src/components/common/UserDropdown/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react'
import styled from 'styled-components'

import { WalletConnectConnector } from '@anxolin/walletconnect-connector'
import { useWeb3React } from '@web3-react/core'
import { WalletConnectConnector } from '@web3-react/walletconnect-connector'

import { useActiveWeb3React } from '../../../hooks'
import { useDarkModeManager } from '../../../state/user/hooks'
Expand Down Expand Up @@ -193,9 +193,7 @@ export const UserDropdown: React.FC<Props> = (props) => {

const disconnect = React.useCallback(async () => {
deactivate()
if (connector instanceof WalletConnectConnector && typeof connector.close === 'function') {
connector.close()
connector.walletConnectProvider = null
if (connector instanceof WalletConnectConnector) {
localStorage.removeItem('walletconnect')
}
}, [connector, deactivate])
Expand Down Expand Up @@ -227,11 +225,11 @@ export const UserDropdown: React.FC<Props> = (props) => {
{items.map((item, index) => {
return (
<Item
disabled={item.disabled && item.disabled}
hasOnClick={item.onClick && item.onClick ? true : false}
hide={item.hide && item.hide}
disabled={item && item.disabled}
hasOnClick={item && item.onClick ? true : false}
hide={item && item.hide}
key={index}
onClick={item.onClick && item.onClick}
onClick={item && item.onClick}
>
<Title>{item.title}</Title>
<Value>{item.value}</Value>
Expand Down
6 changes: 3 additions & 3 deletions src/components/modals/WalletModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React, { useEffect, useState } from 'react'
import { NavLink } from 'react-router-dom'
import styled from 'styled-components'

import { WalletConnectConnector } from '@anxolin/walletconnect-connector'
import { AbstractConnector } from '@web3-react/abstract-connector'
import { UnsupportedChainIdError, useWeb3React } from '@web3-react/core'
import { WalletConnectConnector } from '@web3-react/walletconnect-connector'
import { event } from 'react-ga'

import { injected } from '../../../connectors'
Expand Down Expand Up @@ -164,8 +164,8 @@ const WalletModal: React.FC = () => {

const walletConnect = connector[chainId]
// if the user has already tried to connect, manually reset the connector
if (walletConnect.walletConnectProvider?.wc?.uri) {
walletConnect.walletConnectProvider = undefined
if (walletConnect.walletConnectProvider) {
walletConnect.walletConnectProvider = null
}

await activate(walletConnect, undefined, true)
Expand Down
8 changes: 1 addition & 7 deletions src/connectors/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { WalletConnectConnector } from '@anxolin/walletconnect-connector'
import { InjectedConnector } from '@web3-react/injected-connector'
import { NetworkConnector } from '@web3-react/network-connector'
import { PortisConnector } from '@web3-react/portis-connector'
import { WalletConnectConnector } from '@web3-react/walletconnect-connector'
import { WalletLinkConnector } from '@web3-react/walletlink-connector'

import { NETWORK_URL_MAINNET, PORTIS_ID } from '../constants/config'
import { ChainId, NETWORK_CONFIGS } from './../utils/index'

const POLLING_INTERVAL = 10000
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Polling has now been disabled as mentioned here


const urls: string[] = []

// TOOD Try to use reduce to improve types
Expand Down Expand Up @@ -36,19 +34,16 @@ export const walletconnect = {
rpc: { 1: NETWORK_CONFIGS[1].rpc },
bridge: 'https://safe-walletconnect.gnosis.io',
qrcode: true,
pollingInterval: POLLING_INTERVAL,
}),
100: new WalletConnectConnector({
rpc: { 100: NETWORK_CONFIGS[100].rpc },
bridge: 'https://safe-walletconnect.gnosis.io',
qrcode: true,
pollingInterval: POLLING_INTERVAL,
}),
4: new WalletConnectConnector({
rpc: { 4: NETWORK_CONFIGS[4].rpc },
bridge: 'https://safe-walletconnect.gnosis.io',
qrcode: true,
pollingInterval: POLLING_INTERVAL,
}),
// if no network is defined, we look whether wallet connect supports all possible chains
// this might cause issues on the auction overview page.
Expand All @@ -57,7 +52,6 @@ export const walletconnect = {
rpc: rpcs,
bridge: 'https://safe-walletconnect.gnosis.io',
qrcode: true,
pollingInterval: POLLING_INTERVAL,
}),
}

Expand Down
Loading