Skip to content

Commit

Permalink
feat: add Coin98 type interface
Browse files Browse the repository at this point in the history
also, move `Window` to `global` scope
  • Loading branch information
iamcrazycoder committed Sep 29, 2023
1 parent 7420afa commit 3cc2c13
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
25 changes: 25 additions & 0 deletions packages/sdk/src/browser-wallets/coin98/types.ts
Original file line number Diff line number Diff line change
@@ -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<string[]>
getAccounts: () => Promise<string>
getNetwork: () => Promise<UnisatNetwork>
getPublicKey: () => Promise<string>
signMessage: (message: string) => Promise<string>
signPsbt: (hex: string, { autoFinalized = true, toSignInputs }: Coin98SignPSBTOptions) => Promise<string>
switchNetwork: (network: UnisatNetwork) => Promise<void>
}
15 changes: 11 additions & 4 deletions packages/sdk/src/types.d.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down

0 comments on commit 3cc2c13

Please sign in to comment.