49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
|
|
// Copyright (C) 2026 Whiterun LLC,
|
||
|
|
// This software is licensed under the GNU Lesser General Public License (LGPL), version 3.0 or later.
|
||
|
|
// A copy of the license can be found in the LICENSE file or at https://www.gnu.org/licenses/lgpl-3.0.html
|
||
|
|
|
||
|
|
import { DerivationPath } from "./derivation-path.js";
|
||
|
|
import { SignTransactionRequest } from "@wizardconnect/core";
|
||
|
|
|
||
|
|
export interface SignTransactionResult {
|
||
|
|
signedTransaction: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Abstract interface that wallets implement to integrate with WizardConnect.
|
||
|
|
*/
|
||
|
|
export interface WalletAdapter {
|
||
|
|
/** Human-readable wallet name shown to dapps */
|
||
|
|
walletName: string;
|
||
|
|
/** URL to wallet icon (used in wallet_ready handshake) */
|
||
|
|
walletIcon: string;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Return the relay identity private key for this session.
|
||
|
|
* May be ephemeral (random per session) or stable (HD-derived) — both work.
|
||
|
|
* The dapp learns the wallet's public key dynamically via wallet_ready
|
||
|
|
* so stability across restarts is not required.
|
||
|
|
*/
|
||
|
|
getRelayPrivateKey(): Uint8Array;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Derive the compressed public key (33 bytes) for a given HD path and index.
|
||
|
|
*/
|
||
|
|
getPublicKey(path: DerivationPath, index: bigint): Uint8Array;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* BIP32 xpub string for the given derivation path.
|
||
|
|
* Used to allow dapps to derive all needed pubkeys locally without round-trips.
|
||
|
|
*/
|
||
|
|
getXpub(path: DerivationPath): string;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Sign a transaction request from a dapp.
|
||
|
|
* The wallet should verify the request and return the signed transaction hex,
|
||
|
|
* or throw if the user rejects or signing fails.
|
||
|
|
*/
|
||
|
|
signTransaction(
|
||
|
|
request: SignTransactionRequest,
|
||
|
|
): Promise<SignTransactionResult>;
|
||
|
|
}
|