@xylabs/sdk-react
    Preparing search index...

    Class PhantomConnector

    Base class for connecting to an ethereum compatible wallet

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _providerName: string | undefined
    accountChangeNotifiers: Listener[]
    allowedAccounts: string[]
    chainChangedNotifiers: Listener[]
    chainIdHex: string | undefined
    provider: BrowserProvider | undefined
    providerErrorLog: LRUCache<string, Error, unknown>
    providerInfo: EIP6963ProviderInfo | undefined
    providerName: string
    rawProvider: Eip1193Provider | undefined

    Accessors

    • get chainId(): number | undefined

      Returns number | undefined

    • get chainName(): string | undefined

      Returns string | undefined

    • get installed(): boolean

      Returns boolean

    Methods

    • Request to enable accounts in the wallet Note: This call is not wrapped in a try/catch by design. Errors from connecting to a wallet can be intentional behavior (i.e. the user rejected the request to connect). Handle errors in the calling code.

      Returns Promise<string[] | null | undefined>

    • Request the current active allowed from the wallet

      Returns Promise<string[] | undefined>

    • Request the current chain id selection on the wallet

      Returns Promise<string | undefined>

    • Parameters

      • Optionalprovider: BrowserProvider

      Returns void

    • Parameters

      • listener: Listener

      Returns void

    • Keep class state internally consistent

      Returns Promise<void>

    • Parameters

      • listener: Listener

      Returns void

    • Keep class state internally consistent

      Returns Promise<void>

    • Parameters

      • listener: Listener

      Returns void

    • Parameters

      • listener: Listener

      Returns void

    • Get a signer from a given address

      Parameters

      • Optionaladdress: string

        Fetch a signer for a given address

      Returns Promise<JsonRpcSigner | undefined>

    • Sign a string with a specific account enabled in the wallet

      Parameters

      • message: string

        Message to sign with the signer

      • OptionalallowedAccount: string

        Account being used to sign the message

      Returns Promise<string | undefined>

    • Sign a typed message with a specific account enabled in the wallet according to EIP-712

      Parameters

      • domain: TypedDataDomain

        eip712Domain

      • types: TypedDataTypes

        A specific field of a structured eip-712 type.

      • value: TypedDataValues

        The contents of the message to sign

      • OptionalallowedAccount: string

        Account being used to sign the message

      Returns Promise<string | undefined>

      see - https://eips.ethereum.org/EIPS/eip-712

    • Pass a callback to be notified when accounts are changed Note: This is a notifier so it does not return updated values so check the allowed accounts after the passed listener is invoked

      Parameters

      • listener: () => void

        A notify function that will be called when allowed accounts change

      Returns () => void

    • Pass a callback to be notified when chainId is changed Note: This is a notifier so it does not return updated values so check the chainId after the passed listener is invoked

      Parameters

      • listener: () => void

        A notify function that will be called when chainId changes

      Returns () => void

    • Verify a typed data signature according to EIP-712

      Parameters

      • domain: TypedDataDomain

        eip712Domain

      • types: TypedDataTypes

        A specific field of a structured eip-712 type.

      • value: TypedDataValues

        The contents of the message to sign

      • signature: string

        Signature produced by signTypedMessage

      • expectedSignerAddress: string

        Expected signer address to verify against

      Returns boolean

      boolean indicating if the signature is valid