45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import { IWalletSDK } from "../core/IWalletSDK";
|
|
|
|
export class LuffaWalletSDK implements IWalletSDK {
|
|
private address: string | null = null;
|
|
|
|
init(cb?: Function): void {
|
|
console.log("Luffa 钱包初始化");
|
|
cb && cb();
|
|
}
|
|
|
|
connect(cb: (address: string, publicKey?: string) => void): void {
|
|
console.log("连接 Luffa 钱包");
|
|
this.address = "0x123456"; // 模拟地址
|
|
cb(this.address, "public-key");
|
|
}
|
|
|
|
disconnect(): void {
|
|
this.address = null;
|
|
}
|
|
|
|
getWalletAddress(): string | null {
|
|
return this.address;
|
|
}
|
|
|
|
async signMessage(message: string, nonce: number): Promise<any> {
|
|
console.log("调用 Luffa 单签签名");
|
|
return { signature: "xxx", fullMessage: `${message}-${nonce}` };
|
|
}
|
|
|
|
async buildTransaction(payload: any): Promise<any> {
|
|
console.log("构建交易", payload);
|
|
return { raw: "rawTx" };
|
|
}
|
|
|
|
async signTransaction(rawData: any): Promise<any> {
|
|
console.log("签名交易", rawData);
|
|
return { signed: "signedTx" };
|
|
}
|
|
|
|
async sendTransaction(signed: any): Promise<{ hash: string }> {
|
|
console.log("发送交易", signed);
|
|
return { hash: "0xabcdef" };
|
|
}
|
|
}
|