Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): add excludeWallets to walletsListConfiguration #315

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/ui/README.md
Original file line number Diff line number Diff line change
@@ -686,6 +686,18 @@ tonConnectUI.uiOptions = {
}
```

### Exclude wallets
Pass wallet names to be excluded from the wallets list. Passed names will be used to filter out any wallet to be hidden.

Since the filtering with `excludeWallets` is processed last when applying wallet configuration, it should take precedence over `includeWallets`.
```ts
tonConnectUI.uiOptions = {
walletsListConfiguration: {
excludeWallets: ['xtonwallet']
}
}
```

## Add connect request parameters (ton_proof)
Use `tonConnectUI.setConnectRequestParameters` function to pass your connect request parameters.

6 changes: 6 additions & 0 deletions packages/ui/src/app/utils/wallets.ts
Original file line number Diff line number Diff line change
@@ -31,6 +31,12 @@ export function applyWalletsListConfiguration(
);
}

if (configuration.excludeWallets?.length) {
walletsList = walletsList.filter(v => {
return !configuration.excludeWallets?.find(w => eqWalletName(v, w));
});
}

return walletsList;
}

3 changes: 2 additions & 1 deletion packages/ui/src/dev.ts
Original file line number Diff line number Diff line change
@@ -31,7 +31,8 @@ async function dev(): Promise<void> {
imageUrl: 'https://tonkeeper.com/assets/tonconnect-icon.png',
platforms: ['ios']
}
]
],
excludeWallets: ['xtonwallet']
}*/
});

3 changes: 2 additions & 1 deletion packages/ui/src/models/wallets-list-configuration.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { UIWallet } from './ui-wallet';

/**
* Add corrections to the default wallets list in the modal: add custom wallets and change wallets order.
* Add corrections to the default wallets list in the modal: add custom wallets, exclude wallets and change wallets order.
*/
export type WalletsListConfiguration = {
/**
* Allows to include extra wallets to the wallets list in the modal.
*/
includeWallets?: UIWallet[];
excludeWallets?: UIWallet['name'][];
};