首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >什么是“从@binance-chain/bsc-use-钱包”导入{ useWallet }的多边形?

什么是“从@binance-chain/bsc-use-钱包”导入{ useWallet }的多边形?
EN

Ethereum用户
提问于 2021-08-23 04:49:41
回答 1查看 308关注 0票数 0

我正在学习一个私有代码教程,用于构建一个名为import { useWallet } from '@binance-chain/bsc-use-wallet'的bsc。然而,我目前的项目是为多边形网络。如果我想在多边形中使用useWallet,对应的模块/库和函数是什么?

下面是代码和库https://github.com/binance-chain/bsc-use-wallet/blob/master/types/index.d.ts#L71

代码语言:javascript
复制
declare module '@binance-chain/bsc-use-wallet' {
  import { ReactNode } from 'react'

  type Connectors = Partial<{
    authereum: {}
    fortmatic: { apiKey: string }
    frame: {}
    injected: {}
    portis: { dAppId: string }
    squarelink: { clientId: string; options: object }
    provided: {}
    torus: {
      chainId?: number
      initOptions: object
      constructorOptions: object
    }
    walletconnect: { rpcUrl: string }
    walletlink: { url: string; appName: string; appLogoUrl: string }
    bsc: {}
  }>

  export interface Wallet<T> {
    account: string | null
    balance: string
    chainId: number | null
    connect(connectorId: keyof Connectors): Promise<void>
    connector: keyof Connectors
    connectors: Connectors
    error:
      | UnsupportedChainError
      | UnsupportedChainError
      | RejectedActivationError
      | ConnectorConfigError
    ethereum: T
    networkName: string
    getBlockNumber(): number
    reset(): void
    status: string
    type: string | null
  }

  interface UseWalletProviderProps {
    chainId: number
    children: ReactNode
    connectors?: Connectors
    pollBalanceInterval?: number
    pollBlockNumberInterval?: number
  }

  interface UseWalletProps {
    pollBalanceInterval?: number
    pollBlockNumberInterval?: number
  }

  export class ChainUnsupportedError extends Error {
    name: 'ChainUnsupportedError'
  }

  export class ConnectorUnsupportedError extends Error {
    name: 'ConnectorUnsupportedError'
  }

  export class ConnectionRejectedError extends Error {
    name: 'ConnectionRejectedError'
  }

  export class ConnectorConfigError extends Error {
    name: 'ConnectorConfigError'
  }

  export function useWallet<T>(props?: UseWalletProps): Wallet<T>

  export function UseWalletProvider(props: UseWalletProviderProps)
}
EN

回答 1

Ethereum用户

发布于 2021-08-24 16:52:55

只需在代码中使用137作为链id,然后@binance-chain/bsc-use-wallet就可以工作了。

票数 1
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/107593

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档