Skip to content

Commit 31eef17

Browse files
committed
Add sep43Modules and a filterBy parameter for both allowAllModules and sep43Modules
1 parent 0119405 commit 31eef17

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
StellarWalletsKit,
8686
WalletNetwork,
8787
allowAllModules,
88+
XBULL_ID
8889
} from './build/index.mjs';
8990
import { WalletConnectModule, WalletConnectAllowedMethods } from './build/modules/walletconnect.module.mjs'
9091
import { LedgerModule } from './build/modules/ledger.module.mjs'
@@ -93,7 +94,7 @@
9394
const kit = new StellarWalletsKit({
9495
network: WalletNetwork.TESTNET,
9596
modules: [
96-
...allowAllModules(),
97+
...allowAllModules({ filterBy: module => module.productId === XBULL_ID }),
9798
new LedgerModule(),
9899
new TrezorModule({
99100
appUrl: 'http://localhost:5173',

src/utils.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ import { HotWalletModule } from './modules/hotwallet.module';
77
import { HanaModule } from './modules/hana.module';
88
import { ModuleInterface } from './types';
99

10-
export function allowAllModules(): ModuleInterface[] {
11-
return [
10+
/**
11+
* This method returns all modules that don't require extra configuration before they can be loaded
12+
* You can provide a filter function if needed
13+
*/
14+
export function allowAllModules(opts?: { filterBy: (module: ModuleInterface) => boolean }): ModuleInterface[] {
15+
const modules: ModuleInterface[] = [
1216
new AlbedoModule(),
1317
new FreighterModule(),
1418
new RabetModule(),
@@ -17,6 +21,16 @@ export function allowAllModules(): ModuleInterface[] {
1721
new HanaModule(),
1822
new HotWalletModule(),
1923
];
24+
return opts?.filterBy ? modules.filter(opts.filterBy) : modules;
25+
}
26+
27+
/**
28+
* This method only returns those modules from wallet that follow exactly the SEP-43 standard and don't require extra configuration before they can be loaded
29+
* You can provide a filter function if needed
30+
*/
31+
export function sep43Modules(opts?: { filterBy: (module: ModuleInterface) => boolean }): ModuleInterface[] {
32+
const modules: ModuleInterface[] = [new FreighterModule(), new HotWalletModule()];
33+
return opts?.filterBy ? modules.filter(opts.filterBy) : modules;
2034
}
2135

2236
export function parseError(e: any) {

0 commit comments

Comments
 (0)