Skip to content

Commit db4737a

Browse files
authored
Merge pull request #86 from BitgetWalletTeam/feat-bitget-wallet
feat: support bitget wallet
2 parents 355726e + df56e6c commit db4737a

1 file changed

Lines changed: 81 additions & 0 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import { type ModuleInterface, ModuleType } from "../../types/mod.ts";
2+
3+
declare global {
4+
interface Window {
5+
bitkeep?: any;
6+
}
7+
}
8+
9+
export const BitgetWallet_ID = "bitgetWallet";
10+
11+
export class BitgetWalletModule implements ModuleInterface {
12+
moduleType: ModuleType = ModuleType.HOT_WALLET;
13+
productId: string = BitgetWallet_ID;
14+
productName: string = "Bitget Wallet";
15+
productUrl: string = "https://web3.bitget.com";
16+
productIcon: string =
17+
"https://raw.githubusercontent.com/bitgetwallet/download/refs/heads/main/logo/png/small-circle-logo180.png";
18+
provider: any;
19+
20+
constructor() {
21+
this.provider = window.bitkeep?.stellar;
22+
}
23+
24+
async isAvailable() {
25+
return !!this.provider;
26+
}
27+
async getAddress() {
28+
const address = await this.provider.connect();
29+
return { address };
30+
}
31+
async signMessage(
32+
message: string,
33+
opts?: {
34+
networkPassphrase?: string;
35+
address?: string;
36+
path?: string;
37+
}
38+
) {
39+
const signatureHex = await this.provider.signMessage(
40+
message,
41+
opts?.address
42+
);
43+
44+
return { signedMessage: signatureHex };
45+
}
46+
47+
async signTransaction(
48+
xdr: string,
49+
opts?: {
50+
networkPassphrase?: string;
51+
address?: string;
52+
path?: string;
53+
submit?: boolean;
54+
submitUrl?: string;
55+
}
56+
) {
57+
const signedTxXdr = await this.provider.signTransaction(xdr, opts);
58+
return { signedTxXdr };
59+
}
60+
61+
async signAuthEntry(
62+
authEntry: string,
63+
opts?: {
64+
networkPassphrase?: string;
65+
address?: string;
66+
path?: string;
67+
}
68+
): Promise<{
69+
signedAuthEntry: string;
70+
signerAddress?: string;
71+
}> {
72+
throw {
73+
code: -3,
74+
message: `${this.productName} does not support the "signAuthEntry" function`,
75+
};
76+
}
77+
78+
async getNetwork() {
79+
return this.provider.network();
80+
}
81+
}

0 commit comments

Comments
 (0)