Skip to content

Commit 3e0d01a

Browse files
committed
Add Lobstr extension support
1 parent 50544bc commit 3e0d01a

File tree

7 files changed

+75
-2
lines changed

7 files changed

+75
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
### [0.8.0](https://github.com/Creit-Tech/Stellar-Wallets-Kit/compare/v0.7.0...v0.8.0) (2024-04-16)
6+
### Add
7+
- Add Lobstr extension support
8+
59
### [0.7.0](https://github.com/Creit-Tech/Stellar-Wallets-Kit/compare/v0.6.1...v0.7.0) (2024-03-15)
610
### Add
711
- Bring back Wallet Connect module

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ A kit to handle all Stellar Wallets at once with a simple API and without caring
66
- Albedo
77
- Freighter
88
- Rabet (extension version)
9+
- WalletConnect
10+
- Lobstr
911

1012
## Installation
1113

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@creit.tech/stellar-wallets-kit",
3-
"version": "0.7.0",
3+
"version": "0.8.0",
44
"description": "A kit to handle all Stellar Wallets at once",
55
"author": {
66
"name": "Creit Technologies LLP",
@@ -33,6 +33,7 @@
3333
"dependencies": {
3434
"@albedo-link/intent": "^0.12.0",
3535
"@creit-tech/xbull-wallet-connect": "github:Creit-Tech/xBull-Wallet-Connect#0.2.0",
36+
"@lobstrco/signer-extension-api": "^1.0.0-beta.0",
3637
"@stellar/freighter-api": "1.7.0",
3738
"@walletconnect/modal": "^2.6.2",
3839
"@walletconnect/sign-client": "^2.11.2",

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ export * from './modules/freighter/freighter.module';
88
export * from './modules/albedo/albedo.module';
99
export * from './modules/rabet/rabet.module';
1010
export * from './modules/walletconnect/walletconnect.module';
11+
export * from './modules/lobstr/lobstr.module';
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { isConnected, getPublicKey, signTransaction } from '@lobstrco/signer-extension-api';
2+
import { ModuleInterface, ModuleType, WalletNetwork } from '../../types';
3+
4+
export const LOBSTR_ID = 'lobstr';
5+
6+
export class LobstrModule implements ModuleInterface {
7+
moduleType: ModuleType = ModuleType.HOT_WALLET;
8+
9+
productId: string = LOBSTR_ID;
10+
productName: string = 'Lobstr';
11+
productUrl: string = 'https://lobstr.co';
12+
productIcon: string = 'https://stellar.creit.tech/wallet-icons/lobstr.svg';
13+
14+
async isAvailable(): Promise<boolean> {
15+
return isConnected();
16+
}
17+
18+
async getPublicKey(): Promise<string> {
19+
if (!(await isConnected())) {
20+
throw new Error(`Lobstr is not connected`);
21+
}
22+
23+
return getPublicKey();
24+
}
25+
26+
async signTx(params: { xdr: string; publicKeys: string[]; network: WalletNetwork }): Promise<{ result: string }> {
27+
if (!(await isConnected())) {
28+
throw new Error(`Lobstr is not connected`);
29+
}
30+
31+
if (params.publicKeys.length > 0) {
32+
console.warn(`Lobstr doesn't allow specifying what public key should sign the transaction, we skip the value`);
33+
}
34+
35+
if (params.network) {
36+
console.warn(`Lobstr doesn't allow specifying the network that should be used, we skip the value`);
37+
}
38+
39+
return { result: await signTransaction(params.xdr) };
40+
}
41+
42+
// @ts-expect-error - This is not a supported operation so we don't use the params
43+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
44+
async signBlob(params: { blob: string; publicKey?: string }): Promise<{ result: string }> {
45+
throw new Error('Lobstr does not support signing random blobs');
46+
}
47+
48+
// @ts-expect-error - This is not a supported operation so we don't use the params
49+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
50+
async signAuthEntry(params: { entryPreimageXDR: string; publicKey?: string }): Promise<{ result: string }> {
51+
throw new Error('Lobstr does not support signing authorization entries');
52+
}
53+
}

src/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { AlbedoModule } from './modules/albedo/albedo.module';
22
import { FreighterModule } from './modules/freighter/freighter.module';
3+
import { LobstrModule } from './modules/lobstr/lobstr.module';
34
import { RabetModule } from './modules/rabet/rabet.module';
45
import { xBullModule } from './modules/xbull/xbull.module';
56
import { ModuleInterface } from './types';
67

78
export function allowAllModules(): ModuleInterface[] {
8-
return [new AlbedoModule(), new FreighterModule(), new RabetModule(), new xBullModule()];
9+
return [new AlbedoModule(), new FreighterModule(), new RabetModule(), new xBullModule(), new LobstrModule()];
910
}

0 commit comments

Comments
 (0)