我正在学习一个私有代码教程,用于构建一个名为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
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)
}发布于 2021-08-24 16:52:55
只需在代码中使用137作为链id,然后@binance-chain/bsc-use-wallet就可以工作了。
https://ethereum.stackexchange.com/questions/107593
复制相似问题