From c6daa019573c78138cb978b4894f04c9c1708fc2 Mon Sep 17 00:00:00 2001 From: KaffinPX Date: Wed, 24 Jan 2024 00:28:46 +0300 Subject: [PATCH] new provider "boilerplate" --- src/provider/Api.d.ts | 7 ------- src/provider/Content.ts | 20 +++++++++++++++++--- 2 files changed, 17 insertions(+), 10 deletions(-) delete mode 100644 src/provider/Api.d.ts diff --git a/src/provider/Api.d.ts b/src/provider/Api.d.ts deleted file mode 100644 index 8e7d5eb..0000000 --- a/src/provider/Api.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -interface Window { - kaspa: ProviderApi -} - -interface ProviderApi { - network: string -} diff --git a/src/provider/Content.ts b/src/provider/Content.ts index 310a5b2..11940a9 100644 --- a/src/provider/Content.ts +++ b/src/provider/Content.ts @@ -1,5 +1,19 @@ -window.kaspa = { - network: "TESTNET" +interface ProviderInfo { + name: string } -export {} +function announceProvider() { + const info: ProviderInfo = { + name: "Kaspian" + } + + window.dispatchEvent(new CustomEvent("kaspa:provider", { + detail: Object.freeze({ info }), + })) +} + +window.addEventListener("kaspa:requestProviders", () => { + announceProvider() +}) + +announceProvider() \ No newline at end of file