Uniswap / web3-react

A simple, maximally extensible, dependency minimized framework for building modern Ethereum dApps
https://web3-react-mu.vercel.app/
GNU General Public License v3.0
5.5k stars 1.52k forks source link

Documentation? #663

Open bnbon opened 1 year ago

bnbon commented 1 year ago

It would appear one of these packages relies on some outdated packages, but I am really struggling to migrate over from v6 as the v8 example is both in typescript, and not documented.

What is the replacement for @web3-react/injected-connector?

I want to migrate this, and the connect buttons;

import { InjectedConnector } from '@web3-react/injected-connector';

// preamble

  useEffect(() => {
    if (
      Boolean(injectedConnector.supportedChainIds) &&
      !injectedConnector.supportedChainIds.includes(chainId)
    ) {
      setErrorStatus(true);
    } else {
      setErrorStatus(false);
    }
  }, [chainId]);

I also have these buttons which call actions like

  const handleWalletConnect = () => {
    activate(connectors.walletConnect);
  };

and this is my connectors which I import into the above button file;

import { InjectedConnector } from '@web3-react/injected-connector';
import { WalletConnectConnector } from '@web3-react/walletconnect-connector';
import { WalletLinkConnector } from '@web3-react/walletlink-connector';
import { NFT_CHAIN_ID } from '@constants';

const injected = new InjectedConnector({
  supportedChainIds: [NFT_CHAIN_ID],
});

const walletConnect = new WalletConnectConnector({
  rpcUrl: `${process.env.INFURA_ENDPOINT}${process.env.INFURA_KEY}`,
  bridge: 'https://bridge.walletconnect.org',
  qrcode: true,
});

const walletLink = new WalletLinkConnector({
  url: `${process.env.INFURA_ENDPOINT}${process.env.INFURA_KEY}`,
  appName: 'Example,
});

export const connectors = {
  injected: injected,
  walletConnect: walletConnect,
  coinbaseWallet: walletLink,
};

Amy advice on how to proceed? It appears nowhere has a tutorial for v8.x

Thanks

rafinskipg commented 1 year ago

I would say metamask or network are the replacement, but i'm not sure, i'm looking for it too

DavNej commented 1 year ago

Hi @bonbonio,

Have you tried to use initializeConnector from v8 ?

https://github.com/Uniswap/web3-react/blob/%40web3-react/core%408.0.35-beta.0/packages/core/src/hooks.ts