Skip to main content

Demos Providers Discovery Mechanism

Mechanism

This mechanism allows for the discovery of multiple providers without race conditions. The injected providers communicate with the DApp through window events. When the DApp needs the list of available providers, it sends a “request” event. When a request is triggered, the providers must send an “announce” event. It follows that the DApp and the providers must be listening for, respectively, “announce” and “request” events.

Request

interface DemosRequestProviderEvent extends Event{
    type:"demosRequestProvider",
}

Announce

interface DemosAnnounceProviderEvent extends CustomEvent{
    type:"demosAnnounceProvider",
    detail: DemosProviderDetail;
}

DemosProviderDetail

interface DemosProviderDetail {
    info: DemosProviderInfo;
    provider: DemosProvider;
}

DemosProviderInfo

export default interface DemosProviderInfo {
    uuid: string;
    name: string;
    icon: string;
    url: string;
}