From 0421577273a583a4b7a828e75ffff1645caf200b Mon Sep 17 00:00:00 2001 From: Nishant Ghodke Date: Fri, 29 Sep 2023 14:59:14 +0530 Subject: [PATCH] feat: add Coin98 type interface also, move `Window` to `global` scope --- .../sdk/src/browser-wallets/coin98/types.ts | 25 +++++++++++++++++++ packages/sdk/src/types.d.ts | 15 ++++++++--- 2 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 packages/sdk/src/browser-wallets/coin98/types.ts diff --git a/packages/sdk/src/browser-wallets/coin98/types.ts b/packages/sdk/src/browser-wallets/coin98/types.ts new file mode 100644 index 00000000..d3a23d0d --- /dev/null +++ b/packages/sdk/src/browser-wallets/coin98/types.ts @@ -0,0 +1,25 @@ +import { RequireAtLeastOne } from "../../utils/types" +import { UnisatNetwork } from "../unisat" + +interface Coin98SignPSBTOptions { + autoFinalized?: boolean + toSignInputs?: Array< + RequireAtLeastOne<{ + address?: string + publicKey?: string + }> & { + index: number + sigHashTypes?: number[] + } + > +} + +export interface Coin98 { + requestAccounts: () => Promise + getAccounts: () => Promise + getNetwork: () => Promise + getPublicKey: () => Promise + signMessage: (message: string) => Promise + signPsbt: (hex: string, { autoFinalized = true, toSignInputs }: Coin98SignPSBTOptions) => Promise + switchNetwork: (network: UnisatNetwork) => Promise +} diff --git a/packages/sdk/src/types.d.ts b/packages/sdk/src/types.d.ts index 000f412a..a3255915 100644 --- a/packages/sdk/src/types.d.ts +++ b/packages/sdk/src/types.d.ts @@ -1,7 +1,14 @@ -declare interface Window { - unisat: Unisat - satsConnect: any - ethereum: MetaMask +import { BitcoinProvider } from "sats-connect" + +import { Coin98 } from "./browser-wallets/coin98/types" + +declare global { + interface Window { + unisat: Unisat + coin98: { bitcoin: Coin98 } + BitcoinProvider: BitcoinProvider + ethereum: MetaMask + } } type Unisat = {