useDApp icon indicating copy to clipboard operation
useDApp copied to clipboard

Following useDApp Example - TypeError within config's 'connectors' object

Open aceaspades-worldspark opened this issue 2 years ago • 2 comments

Describe the bug UPDATE: I've read the documentation for config, and I see that 'connectors' is not an option. It must have been at some point, because your dApp example uses the connectors field when the config is declared, then destructures 'connectors' from context on line 7 in ConnectorsPage.tsx. https://github.com/TrueFiEng/useDApp/tree/master/packages/example/src/pages/ConnectorsPage.tsx

That means your example now uses a broken/deprecated field. Should I roll back versions (I wouldn't want to do that), or do you have a better example that I can use?


I'm getting a TypeError within the config's connectors field:

(property) connectors: { metamask: any; walletConnect: WalletConnectConnector; } Type '{ readOnlyChainId: number; readOnlyUrls: NodeUrls; multicallVersion: 1; fastMulticallEncoding: true; noMetamaskDeactivate: true; connectors: { metamask: any; walletConnect: WalletConnectConnector; }; }' is not assignable to type 'RecursivePartial<FullConfig, { notifications: {}; }>'. Object literal may only specify known properties, and 'connectors' does not exist in type 'RecursivePartial<FullConfig, { notifications: {}; }>'.ts(2322)

To Reproduce

import '../styles/globals.css'
import { SessionProvider } from 'next-auth/react'
import type { AppProps } from "next/app"
import type { Session } from "next-auth"
import {
  Mainnet,
  DAppProvider,
  Config,
  MetamaskConnector,
} from '@usedapp/core'
import { WalletConnectConnector } from '@usedapp/wallet-connect-connector'

const readOnlyUrls: Config['readOnlyUrls'] = {
  [Mainnet.chainId]: 'https://rpc.ankr.com/eth'
}


const config: Config = {
  readOnlyChainId: Mainnet.chainId,
  readOnlyUrls,
  multicallVersion: 1 as const,
  fastMulticallEncoding: true,
  noMetamaskDeactivate: true,
  connectors: {
    metamask: new MetamaskConnector(),
    walletConnect: new WalletConnectConnector({}),
  },
}

function MyApp({ Component, pageProps: { session, ...pageProps }, }: AppProps<{ session: Session }>) {
  return (
    <SessionProvider session={session}>
      <DAppProvider config={config}>
        <Component {...pageProps} />
      </DAppProvider>
    </SessionProvider>
  )
}

export default MyApp

Software versions

"@usedapp/core": "^1.1.5",
"@usedapp/wallet-connect-connector": "^1.0.0-dev.0de1fa4",
"@walletconnect/web3-provider": "^1.8.0",
  • yarn
  • Node version v16.14.2

aceaspades-worldspark avatar Oct 15 '22 08:10 aceaspades-worldspark

Hi, connectors are going to be introduced in [email protected] and if you want to use it right now you have to install the dev version, for example: @usedapp/[email protected]

jakvbs avatar Oct 17 '22 07:10 jakvbs

@jakvbs is there an estimate on when 1.2.0 will be released? ✨

albertoramires avatar Oct 17 '22 14:10 albertoramires

I think it's a matter of a week or two.

jakvbs avatar Oct 18 '22 10:10 jakvbs