web3-react
web3-react copied to clipboard
Add Torus connector
It would be great to bring back the connector for Torus.
for reference: https://github.com/NoahZinsmeister/web3-react#adding-connectors
I try to add torus connector and i probably made something wrong but i don't understand why, when activate is called useAccount and provider is always undefined some one can help me :)
` import { TorusParams } from '@toruslabs/torus-embed' import type { Actions, AddEthereumChainParameter, Provider, ProviderConnectInfo, ProviderRpcError, } from '@web3-react/types'
import { Connector } from '@web3-react/types'
interface TorusConnectorArguments { chainId: number initOptions?: TorusParams constructorOptions?: TorusCtorArgs loginOptions?: any } interface TorusCtorArgs { buttonPosition?: 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left' }
export class TorusConnector extends Connector {
/** {@inheritdoc Connector.provider} */
public provider: Provider | undefined
private readonly chainId: number
private readonly initOptions: TorusParams
private readonly constructorOptions: TorusCtorArgs
private readonly loginOptions: any
public torus: any
constructor(
actions: Actions,
{ chainId, constructorOptions = {}, initOptions = {} }: TorusConnectorArguments ) {
super(actions)
this.chainId = chainId
this.constructorOptions = constructorOptions
this.initOptions = initOptions
}
// the connected property, is bugged, but this works as a hack to check connection status
public async activate(): Promise
Sorry for the issue finaly it's works my import package in the client didn't update correctly now it sync
Will provide a PR for this @NoahZinsmeister!
My connector finally works. I need to add test and adapt type with abstract connector to be compliance to your practice manifest but if it can help to go faster I can send PR. It will allow me to import one npm package web3-react and not web3-react and my custom connector to handle torus. Thanks for your answer, best regards.