钱包SDK

This commit is contained in:
chen wei bo
2025-09-27 14:04:13 +08:00
parent 6d1a705991
commit 19417f1089
9 changed files with 141 additions and 43 deletions
+5 -16
View File
@@ -1,6 +1,7 @@
/**
* 定义钱包 SDK 的统一接口,用于封装不同平台的钱包接入逻辑(例如 Luffa、MetaMask、Phantom)。
*
* 钱包基础能力接口
* - 只包含连接 / 断开 / 获取地址
* - 更高级的签名、交易能力通过扩展接口实现
*/
import { ISDK } from "./ISDK";
@@ -16,7 +17,7 @@ export interface IWalletSDK extends ISDK {
* - address: 钱包地址(字符串)
* - publicKey?: 钱包公钥(部分钱包可能返回,用于后续签名验证)
*/
connect(cb: (address: string, publicKey?: string) => void): void;
connectWallet(cb: (address: string, publicKey?: string) => void): void;
/**
* 断开钱包连接
@@ -24,7 +25,7 @@ export interface IWalletSDK extends ISDK {
* 清理当前钱包的会话信息(如地址、公钥、缓存的 session)。
* 调用后 getWalletAddress() 应返回 null。
*/
disconnect(): void;
disconnectWallet(): void;
/**
* 获取当前钱包地址
@@ -33,16 +34,4 @@ export interface IWalletSDK extends ISDK {
* 如果尚未连接,则返回 null。
*/
getWalletAddress(): string | null;
//
signMessage(message: string, nonce: number, options?: any): Promise<any>;
//
buildTransaction(payload: any): Promise<any>;
//
signTransaction(rawData: any): Promise<any>;
//
sendTransaction(signedData: any): Promise<{ hash: string }>;
}