SDK相关的整理
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
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" };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.24",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "aaa01f0f-e74c-48a2-85ed-da571f0c2643",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user