Publicapi

The DAppClient has to be used in decentralized applications. It handles all the logic related to connecting to beacon-compatible wallets and sending requests.

Hierarchy

Constructors

Properties

Accessors

Methods

Constructors

Properties

_activeAccount: ExposedPromise<undefined | AccountInfo, unknown> = ...

The currently active account. For all requests that are associated to a specific request (operation request, signing request), the active account is used to determine the network and destination wallet

_activePeer: ExposedPromise<undefined | PeerInfoType, unknown> = ...

The currently active peer. This is used to address a peer in case the active account is not set. (Eg. for permission requests)

_beaconId: ExposedPromise<string, unknown>

The beaconId is a public key that is used to identify one specific application (dapp or wallet). This is used inside a message to specify the sender, for example.

_initPromise: undefined | Promise<TransportType>
_keyPair: ExposedPromise<KeyPair, unknown>

The local keypair that is used for the communication encryption

_transport: ExposedPromise<Transport<any, any, any>, unknown>
accountManager: AccountManager
activeAccountLoaded: Promise<undefined | AccountInfo>
appMetadataManager: AppMetadataManager
appUrl?: string

The URL of the dApp.

blockExplorer: BlockExplorer

The block explorer used by the SDK

blockchains: Map<string, Blockchain> = ...
bugReportStorage: IndexedDBStorage = ...
debounceSetActiveAccount: boolean = false
description?: string

The description of the app

disclaimerText?: string
enableAppSwitching: boolean

Automatically switch between apps on Mobile Devices (Enabled by Default)

enableMetrics?: boolean

Enable metrics tracking (Disabled by Default)

errorMessages: Record<string, Record<string | number, string>>
events: BeaconEventHandler = ...
featuredWallets: undefined | string[]
handleResponse: ((_event, connectionInfo) => void)

Type declaration

iconUrl?: string

The URL of the dApp Icon. This can be used to display the icon of the dApp on in the wallet

isGetActiveAccountHandled: boolean = false
isInitPending: boolean = false
matrixNodes: NodeDistributions
multiTabChannel: MultiTabChannel = ...
name: string

The name of the client

network: Network
openRequests: Map<string, ExposedPromise<{
    connectionInfo: ConnectionContext;
    message: BeaconMessage | BeaconMessageWrapper<BeaconBaseMessage>;
}, ErrorResponse>> = ...

A map of requests that are currently "open", meaning we have sent them to a wallet and are still awaiting a response.

openRequestsOtherTabs: Set<string> = ...
p2pTransport: undefined | DappP2PTransport
postMessageTransport: undefined | DappPostMessageTransport
rateLimit: number

How many requests can be sent after another

rateLimitWindowInSeconds: number

The time window in seconds in which the "rateLimit" is checked

requestCounter: number[]

Stores the times when requests have been made to determine if the rate limit has been reached

storage: Storage
storageValidator: StorageValidator
userId?: string
walletConnectTransport: undefined | DappWalletConnectTransport
wcProjectId?: string
wcRelayUrl?: string

Accessors

  • get beaconId(): Promise<string>
  • Returns Promise<string>

  • get connectionStatus(): TransportStatus
  • Returns the connection status of the Client

    Returns TransportStatus

  • get keyPair(): Promise<KeyPair>
  • Returns Promise<KeyPair>

  • get ready(): Promise<void>
  • Returns whether or not the transaport is ready

    Returns Promise<void>

  • get transport(): Promise<Transport<any, any, any>>
  • Returns Promise<Transport<any, any, any>>

Methods

  • Parameters

    Returns Promise<void>

  • Add a new peer to the known peers

    Parameters

    Returns Promise<void>

  • Add a new request (current timestamp) to the pending requests, remove old ones and check if we are above the limit

    Returns Promise<boolean>

  • Parameters

    • action: "message" | "connect" | "disconnect"
    • status: "error" | "start" | "abort" | "success"

    Returns Promise<RequestInit>

  • Check if we have permissions to send the specific message type to the active account. If no active account is set, only permission requests are allowed.

    Parameters

    Returns Promise<boolean>

  • Returns Promise<void>

  • Destroy the instance.

    WARNING: Call destroy whenever you no longer need dAppClient as it frees internal subscriptions to the transport and therefore the instance may no longer work properly. If you wish to disconnect your dApp, use disconnect instead.

    Returns Promise<void>

  • Return the account by ID

    Parameters

    • accountIdentifier: string

      The ID of an account

    Returns Promise<undefined | AccountInfo>

  • Return all locally known accounts

    Returns Promise<AccountInfo[]>

  • Return all known peers

    Returns Promise<PeerInfo[]>

  • Returns Promise<undefined | {
        icon: string;
        key: string;
        name: string;
        type: "mobile" | "extension" | "web" | "desktop";
        url?: string;
    }>

  • This method handles sending of requests to the DApp. It makes sure that the DAppClient is initialized and connected to the transport. After that rate limits and permissions will be checked, an ID is attached and the request is sent to the DApp over the transport.

    Type Parameters

    Parameters

    • requestInput: T

      The BeaconMessage to be sent to the wallet

    • Optional otherTabMessageId: string

    Returns Promise<{
        connectionInfo: ConnectionContext;
        message: U;
    }>

  • Remove all peers and all accounts that have been connected through those peers

    Parameters

    • sendDisconnectToPeers: boolean = false

    Returns Promise<void>

  • This method sends an OperationRequest to the wallet. This method should be used for all kinds of operations, eg. transaction or delegation. Not all properties have to be provided. Data like "counter" and fees will be fetched and calculated by the wallet (but they can still be provided if required).

    Parameters

    Returns Promise<OperationResponse>

  • Send a proof of event request to the wallet. The wallet will either accept or decline the challenge. If it is accepted, the challenge will be stored, meaning that even if the user refresh the page, the DAppClient will keep checking if the challenge has been fulfilled. Once the challenge is stored, a challenge stored message will be sent to the wallet. It's highly recommended to run a proof of event challenge to check the identity of an abstracted account

    Parameters

    Returns Promise<ProofOfEventChallengeResponse>

  • Send a simulated proof of event request to the wallet. The wallet will either accept or decline the challenge. It's the same than requestProofOfEventChallenge but rather than executing operations on the blockchain to prove the identity, The wallet will return a list of operations that you'll be able to run on your side to verify the identity of the abstracted account It's highly recommended to run a proof of event challenge to check the identity of an abstracted account

    Parameters

    Returns Promise<SimulatedProofOfEventChallengeResponse>

  • Parameters

    Returns Promise<void>

  • This method will emit an internal error message.

    Parameters

    • errorMessage: string

      The error message to send.

    Returns Promise<void>

  • Parameters

    • uri: string
    • Optional options: RequestInit
    • Optional thenHandler: ((res) => void)
        • (res): void
        • Parameters

          • res: Response

          Returns void

    • Optional catchHandler: ((err) => void)
        • (err): void
        • Parameters

          • err: Error

          Returns void

    Returns void

  • Parameters

    • title: string
    • message: string
    • payload: string
    • protocolIdentifier: string

    Returns Promise<string>

  • Parameters

    • notification: {
          accessToken: string;
          body: string;
          payload: string;
          protocolIdentifier: string;
          recipient: string;
          title: string;
          url: string;
      }
      • accessToken: string
      • body: string
      • payload: string
      • protocolIdentifier: string
      • recipient: string
      • title: string
      • url: string

    Returns Promise<string>

  • Allows the user to subscribe to specific events that are fired in the SDK

    Type Parameters

    Parameters

    • internalEvent: K

      The event to subscribe to

    • eventCallback: BeaconEventHandlerFunction<BeaconEventType[K]>

      The callback that will be called when the event occurs

    Returns Promise<void>

Generated using TypeDoc