diff --git a/packages/sdk/src/browser-wallets/unisat/addresses.ts b/packages/sdk/src/browser-wallets/unisat/addresses.ts index 6693be22..b7e98c8b 100644 --- a/packages/sdk/src/browser-wallets/unisat/addresses.ts +++ b/packages/sdk/src/browser-wallets/unisat/addresses.ts @@ -2,7 +2,7 @@ import { getAddressFormat } from "../.." import { Network } from "../../config/types" import { isUnisatInstalled, UnisatNetwork } from "./utils" -export async function getAddresses(network: Network) { +export async function getAddresses(network: Network, readOnly?: boolean) { if (!isUnisatInstalled()) { throw new Error("Unisat not installed.") } @@ -22,7 +22,7 @@ export async function getAddresses(network: Network) { await window.unisat.switchNetwork(targetNetwork) } - const accounts = await window.unisat.requestAccounts() + const accounts = readOnly ? await window.unisat.getAccounts() : await window.unisat.requestAccounts() const publicKey = await window.unisat.getPublicKey() if (!accounts[0]) { diff --git a/packages/sdk/src/types.d.ts b/packages/sdk/src/types.d.ts index 000f412a..37c3fe82 100644 --- a/packages/sdk/src/types.d.ts +++ b/packages/sdk/src/types.d.ts @@ -8,6 +8,7 @@ type Unisat = { getNetwork: () => Promise switchNetwork: (targetNetwork: UnisatNetwork) => Promise requestAccounts: () => Promise + getAccounts: () => Promise getPublicKey: () => Promise signPsbt: (hex: string, { autoFinalized }: Record) => Promise signMessage: (message: string) => Promise