@hsuite/native-connect-angular 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -0
- package/USAGE_EXAMPLES.md +476 -0
- package/assets/wallets/extension.svg +7 -0
- package/assets/wallets/hashpack.svg +6 -0
- package/assets/wallets/hsuite.svg +11 -0
- package/assets/wallets/kabila.svg +11 -0
- package/assets/wallets/walletconnect.svg +13 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/coverage-summary.json +50 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +476 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +476 -0
- package/coverage/lcov-report/lib/components/account-selector/account-actions/account-actions.component.ts.html +868 -0
- package/coverage/lcov-report/lib/components/account-selector/account-actions/index.html +116 -0
- package/coverage/lcov-report/lib/components/account-selector/account-filter/account-filter.component.ts.html +1288 -0
- package/coverage/lcov-report/lib/components/account-selector/account-filter/index.html +116 -0
- package/coverage/lcov-report/lib/components/account-selector/account-formatting.service.ts.html +685 -0
- package/coverage/lcov-report/lib/components/account-selector/account-grouping.service.ts.html +766 -0
- package/coverage/lcov-report/lib/components/account-selector/account-list/account-list.component.ts.html +1495 -0
- package/coverage/lcov-report/lib/components/account-selector/account-list/index.html +116 -0
- package/coverage/lcov-report/lib/components/account-selector/account-selector.component.ts.html +1495 -0
- package/coverage/lcov-report/lib/components/account-selector/account-selector.service.ts.html +1588 -0
- package/coverage/lcov-report/lib/components/account-selector/index.html +161 -0
- package/coverage/lcov-report/lib/components/wallet-account-display/index.html +116 -0
- package/coverage/lcov-report/lib/components/wallet-account-display/wallet-account-display.component.ts.html +505 -0
- package/coverage/lcov-report/lib/components/wallet-connect-button/index.html +116 -0
- package/coverage/lcov-report/lib/components/wallet-connect-button/wallet-connect-button.component.ts.html +805 -0
- package/coverage/lcov-report/lib/components/wallet-connect-prompt/index.html +116 -0
- package/coverage/lcov-report/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts.html +409 -0
- package/coverage/lcov-report/lib/components/wallet-connected-guard/index.html +116 -0
- package/coverage/lcov-report/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts.html +304 -0
- package/coverage/lcov-report/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts.html +436 -0
- package/coverage/lcov-report/lib/components/wallet-connection-modal/connection-method-step/index.html +116 -0
- package/coverage/lcov-report/lib/components/wallet-connection-modal/index.html +116 -0
- package/coverage/lcov-report/lib/components/wallet-connection-modal/qr-pairing-step/index.html +116 -0
- package/coverage/lcov-report/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts.html +2287 -0
- package/coverage/lcov-report/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts.html +2275 -0
- package/coverage/lcov-report/lib/components/wallet-session-display/index.html +116 -0
- package/coverage/lcov-report/lib/components/wallet-session-display/wallet-session-display.component.ts.html +676 -0
- package/coverage/lcov-report/lib/components/wallet-transaction-status/index.html +116 -0
- package/coverage/lcov-report/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts.html +703 -0
- package/coverage/lcov-report/lib/directives/index.html +146 -0
- package/coverage/lcov-report/lib/directives/wallet-connected.directive.ts.html +670 -0
- package/coverage/lcov-report/lib/directives/wallet-context.directive.ts.html +547 -0
- package/coverage/lcov-report/lib/directives/wallet-events.directive.ts.html +781 -0
- package/coverage/lcov-report/lib/hsuite-wallet.module.ts.html +715 -0
- package/coverage/lcov-report/lib/index.html +116 -0
- package/coverage/lcov-report/lib/models/connection-config.model.ts.html +280 -0
- package/coverage/lcov-report/lib/models/index.html +131 -0
- package/coverage/lcov-report/lib/models/provider-types.ts.html +577 -0
- package/coverage/lcov-report/lib/providers/base-wallet-provider.ts.html +1138 -0
- package/coverage/lcov-report/lib/providers/hsuite-native/channel-client.service.ts.html +2671 -0
- package/coverage/lcov-report/lib/providers/hsuite-native/index.html +116 -0
- package/coverage/lcov-report/lib/providers/hsuite-native-provider.ts.html +2347 -0
- package/coverage/lcov-report/lib/providers/index.html +146 -0
- package/coverage/lcov-report/lib/providers/p2p-native/index.html +131 -0
- package/coverage/lcov-report/lib/providers/p2p-native/p2p-native.provider.ts.html +2254 -0
- package/coverage/lcov-report/lib/providers/p2p-native/p2p-session-manager.ts.html +2170 -0
- package/coverage/lcov-report/lib/providers/wallet-error-handler.ts.html +1132 -0
- package/coverage/lcov-report/lib/providers/walletconnect/core/index.html +176 -0
- package/coverage/lcov-report/lib/providers/walletconnect/core/session-health.ts.html +673 -0
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-client-manager.ts.html +1177 -0
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-provider.ts.html +2563 -0
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-session-store.ts.html +904 -0
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts.html +982 -0
- package/coverage/lcov-report/lib/providers/walletconnect/signers/hedera-signer.ts.html +1915 -0
- package/coverage/lcov-report/lib/providers/walletconnect/signers/index.html +146 -0
- package/coverage/lcov-report/lib/providers/walletconnect/signers/signer-factory.ts.html +445 -0
- package/coverage/lcov-report/lib/providers/walletconnect/signers/xrpl-signer.ts.html +1519 -0
- package/coverage/lcov-report/lib/services/index.html +191 -0
- package/coverage/lcov-report/lib/services/logger.service.ts.html +463 -0
- package/coverage/lcov-report/lib/services/transaction-builders/base-transaction-builder.service.ts.html +1840 -0
- package/coverage/lcov-report/lib/services/transaction-builders/hedera-amount-utils.ts.html +337 -0
- package/coverage/lcov-report/lib/services/transaction-builders/hedera-transaction-builder.service.ts.html +3940 -0
- package/coverage/lcov-report/lib/services/transaction-builders/index.html +161 -0
- package/coverage/lcov-report/lib/services/transaction-builders/xrpl-transaction-builder.service.ts.html +2581 -0
- package/coverage/lcov-report/lib/services/transaction.service.ts.html +1123 -0
- package/coverage/lcov-report/lib/services/unified-wallet.service.ts.html +2641 -0
- package/coverage/lcov-report/lib/services/wallet-context.service.ts.html +637 -0
- package/coverage/lcov-report/lib/services/wallet-event-bus.service.ts.html +643 -0
- package/coverage/lcov-report/lib/services/wallet-providers.service.ts.html +496 -0
- package/coverage/lcov-report/lib/transports/chrome-extension-transport.ts.html +823 -0
- package/coverage/lcov-report/lib/transports/index.html +116 -0
- package/coverage/lcov-report/lib/utils/index.html +116 -0
- package/coverage/lcov-report/lib/utils/ledger-icons.util.ts.html +319 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov.info +19252 -0
- package/coverage/lib/components/account-selector/account-actions/account-actions.component.ts.html +868 -0
- package/coverage/lib/components/account-selector/account-actions/index.html +116 -0
- package/coverage/lib/components/account-selector/account-filter/account-filter.component.ts.html +1288 -0
- package/coverage/lib/components/account-selector/account-filter/index.html +116 -0
- package/coverage/lib/components/account-selector/account-formatting.service.ts.html +685 -0
- package/coverage/lib/components/account-selector/account-grouping.service.ts.html +766 -0
- package/coverage/lib/components/account-selector/account-list/account-list.component.ts.html +1495 -0
- package/coverage/lib/components/account-selector/account-list/index.html +116 -0
- package/coverage/lib/components/account-selector/account-selector.component.ts.html +1495 -0
- package/coverage/lib/components/account-selector/account-selector.service.ts.html +1588 -0
- package/coverage/lib/components/account-selector/index.html +161 -0
- package/coverage/lib/components/wallet-account-display/index.html +116 -0
- package/coverage/lib/components/wallet-account-display/wallet-account-display.component.ts.html +505 -0
- package/coverage/lib/components/wallet-connect-button/index.html +116 -0
- package/coverage/lib/components/wallet-connect-button/wallet-connect-button.component.ts.html +805 -0
- package/coverage/lib/components/wallet-connect-prompt/index.html +116 -0
- package/coverage/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts.html +409 -0
- package/coverage/lib/components/wallet-connected-guard/index.html +116 -0
- package/coverage/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts.html +304 -0
- package/coverage/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts.html +436 -0
- package/coverage/lib/components/wallet-connection-modal/connection-method-step/index.html +116 -0
- package/coverage/lib/components/wallet-connection-modal/index.html +116 -0
- package/coverage/lib/components/wallet-connection-modal/qr-pairing-step/index.html +116 -0
- package/coverage/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts.html +2287 -0
- package/coverage/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts.html +2275 -0
- package/coverage/lib/components/wallet-session-display/index.html +116 -0
- package/coverage/lib/components/wallet-session-display/wallet-session-display.component.ts.html +676 -0
- package/coverage/lib/components/wallet-transaction-status/index.html +116 -0
- package/coverage/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts.html +703 -0
- package/coverage/lib/directives/index.html +146 -0
- package/coverage/lib/directives/wallet-connected.directive.ts.html +670 -0
- package/coverage/lib/directives/wallet-context.directive.ts.html +547 -0
- package/coverage/lib/directives/wallet-events.directive.ts.html +781 -0
- package/coverage/lib/hsuite-wallet.module.ts.html +715 -0
- package/coverage/lib/index.html +116 -0
- package/coverage/lib/models/connection-config.model.ts.html +280 -0
- package/coverage/lib/models/index.html +131 -0
- package/coverage/lib/models/provider-types.ts.html +577 -0
- package/coverage/lib/providers/base-wallet-provider.ts.html +1138 -0
- package/coverage/lib/providers/hsuite-native/channel-client.service.ts.html +2671 -0
- package/coverage/lib/providers/hsuite-native/index.html +116 -0
- package/coverage/lib/providers/hsuite-native-provider.ts.html +2347 -0
- package/coverage/lib/providers/index.html +146 -0
- package/coverage/lib/providers/p2p-native/index.html +131 -0
- package/coverage/lib/providers/p2p-native/p2p-native.provider.ts.html +2254 -0
- package/coverage/lib/providers/p2p-native/p2p-session-manager.ts.html +2170 -0
- package/coverage/lib/providers/wallet-error-handler.ts.html +1132 -0
- package/coverage/lib/providers/walletconnect/core/index.html +176 -0
- package/coverage/lib/providers/walletconnect/core/session-health.ts.html +673 -0
- package/coverage/lib/providers/walletconnect/core/walletconnect-client-manager.ts.html +1177 -0
- package/coverage/lib/providers/walletconnect/core/walletconnect-provider.ts.html +2563 -0
- package/coverage/lib/providers/walletconnect/core/walletconnect-session-store.ts.html +904 -0
- package/coverage/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts.html +982 -0
- package/coverage/lib/providers/walletconnect/signers/hedera-signer.ts.html +1915 -0
- package/coverage/lib/providers/walletconnect/signers/index.html +146 -0
- package/coverage/lib/providers/walletconnect/signers/signer-factory.ts.html +445 -0
- package/coverage/lib/providers/walletconnect/signers/xrpl-signer.ts.html +1519 -0
- package/coverage/lib/services/index.html +191 -0
- package/coverage/lib/services/logger.service.ts.html +463 -0
- package/coverage/lib/services/transaction-builders/base-transaction-builder.service.ts.html +1840 -0
- package/coverage/lib/services/transaction-builders/hedera-amount-utils.ts.html +337 -0
- package/coverage/lib/services/transaction-builders/hedera-transaction-builder.service.ts.html +3940 -0
- package/coverage/lib/services/transaction-builders/index.html +161 -0
- package/coverage/lib/services/transaction-builders/xrpl-transaction-builder.service.ts.html +2581 -0
- package/coverage/lib/services/transaction.service.ts.html +1123 -0
- package/coverage/lib/services/unified-wallet.service.ts.html +2641 -0
- package/coverage/lib/services/wallet-context.service.ts.html +637 -0
- package/coverage/lib/services/wallet-event-bus.service.ts.html +643 -0
- package/coverage/lib/services/wallet-providers.service.ts.html +496 -0
- package/coverage/lib/transports/chrome-extension-transport.ts.html +823 -0
- package/coverage/lib/transports/index.html +116 -0
- package/coverage/lib/utils/index.html +116 -0
- package/coverage/lib/utils/ledger-icons.util.ts.html +319 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +210 -0
- package/dist/README.md +48 -0
- package/dist/fesm2022/hsuite-native-connect-angular.mjs +14592 -0
- package/dist/fesm2022/hsuite-native-connect-angular.mjs.map +1 -0
- package/dist/index.d.ts +6949 -0
- package/examples/minimal-connect.ts +178 -0
- package/examples/multi-protocol.ts +495 -0
- package/examples/transaction-signing.ts +361 -0
- package/jest.config.json +45 -0
- package/karma.conf.js +42 -0
- package/ng-package.json +20 -0
- package/package.json +60 -0
- package/src/index.ts +203 -0
- package/src/lib/components/account-selector/account-actions/account-actions.component.ts +261 -0
- package/src/lib/components/account-selector/account-filter/account-filter.component.ts +401 -0
- package/src/lib/components/account-selector/account-formatting.service.ts +200 -0
- package/src/lib/components/account-selector/account-grouping.service.ts +227 -0
- package/src/lib/components/account-selector/account-list/account-list.component.ts +470 -0
- package/src/lib/components/account-selector/account-selector.component.html +135 -0
- package/src/lib/components/account-selector/account-selector.component.scss +2039 -0
- package/src/lib/components/account-selector/account-selector.component.ts +470 -0
- package/src/lib/components/account-selector/account-selector.service.ts +501 -0
- package/src/lib/components/wallet-account-display/wallet-account-display.component.html +34 -0
- package/src/lib/components/wallet-account-display/wallet-account-display.component.scss +99 -0
- package/src/lib/components/wallet-account-display/wallet-account-display.component.ts +140 -0
- package/src/lib/components/wallet-connect-button/wallet-connect-button.component.html +14 -0
- package/src/lib/components/wallet-connect-button/wallet-connect-button.component.scss +272 -0
- package/src/lib/components/wallet-connect-button/wallet-connect-button.component.ts +240 -0
- package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.html +24 -0
- package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.scss +50 -0
- package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts +108 -0
- package/src/lib/components/wallet-connected-guard/wallet-connected-guard.component.html +24 -0
- package/src/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts +73 -0
- package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.html +56 -0
- package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.scss +218 -0
- package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts +117 -0
- package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.html +94 -0
- package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.scss +272 -0
- package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts +734 -0
- package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.html +197 -0
- package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.scss +678 -0
- package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts +730 -0
- package/src/lib/components/wallet-session-display/wallet-session-display.component.html +110 -0
- package/src/lib/components/wallet-session-display/wallet-session-display.component.scss +179 -0
- package/src/lib/components/wallet-session-display/wallet-session-display.component.ts +197 -0
- package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.html +65 -0
- package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.scss +254 -0
- package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts +206 -0
- package/src/lib/directives/wallet-connected.directive.ts +195 -0
- package/src/lib/directives/wallet-context.directive.ts +154 -0
- package/src/lib/directives/wallet-events.directive.ts +232 -0
- package/src/lib/hsuite-wallet.module.ts +210 -0
- package/src/lib/models/connection-config.model.ts +65 -0
- package/src/lib/models/provider-types.ts +164 -0
- package/src/lib/models/unified-account.model.ts +76 -0
- package/src/lib/models/wallet-context.model.ts +121 -0
- package/src/lib/models/wallet-events.model.ts +158 -0
- package/src/lib/providers/base-wallet-provider.ts +351 -0
- package/src/lib/providers/hsuite-native/channel-client.service.spec.ts +73 -0
- package/src/lib/providers/hsuite-native/channel-client.service.ts +862 -0
- package/src/lib/providers/hsuite-native/index.ts +8 -0
- package/src/lib/providers/hsuite-native-provider.ts +754 -0
- package/src/lib/providers/mobile-native/mobile-native.provider.spec.ts +19 -0
- package/src/lib/providers/p2p-native/index.ts +30 -0
- package/src/lib/providers/p2p-native/p2p-native.provider.spec.ts +523 -0
- package/src/lib/providers/p2p-native/p2p-native.provider.ts +723 -0
- package/src/lib/providers/p2p-native/p2p-session-manager.ts +695 -0
- package/src/lib/providers/wallet-error-handler.ts +349 -0
- package/src/lib/providers/walletconnect/core/base-signer.interface.ts +122 -0
- package/src/lib/providers/walletconnect/core/session-health.ts +196 -0
- package/src/lib/providers/walletconnect/core/walletconnect-client-manager.ts +364 -0
- package/src/lib/providers/walletconnect/core/walletconnect-provider.integration.spec.ts +348 -0
- package/src/lib/providers/walletconnect/core/walletconnect-provider.ts +826 -0
- package/src/lib/providers/walletconnect/core/walletconnect-session-store.ts +273 -0
- package/src/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts +299 -0
- package/src/lib/providers/walletconnect/core/walletconnect-types.ts +48 -0
- package/src/lib/providers/walletconnect/index.ts +33 -0
- package/src/lib/providers/walletconnect/signers/hedera-signer.spec.ts +367 -0
- package/src/lib/providers/walletconnect/signers/hedera-signer.ts +610 -0
- package/src/lib/providers/walletconnect/signers/signer-factory.spec.ts +62 -0
- package/src/lib/providers/walletconnect/signers/signer-factory.ts +120 -0
- package/src/lib/providers/walletconnect/signers/xrpl-signer.spec.ts +296 -0
- package/src/lib/providers/walletconnect/signers/xrpl-signer.ts +478 -0
- package/src/lib/services/logger.service.ts +126 -0
- package/src/lib/services/transaction-builders/base-transaction-builder.service.ts +585 -0
- package/src/lib/services/transaction-builders/hedera-amount-utils.ts +84 -0
- package/src/lib/services/transaction-builders/hedera-transaction-builder.service.spec.ts +741 -0
- package/src/lib/services/transaction-builders/hedera-transaction-builder.service.ts +1285 -0
- package/src/lib/services/transaction-builders/index.ts +54 -0
- package/src/lib/services/transaction-builders/xrpl-transaction-builder.service.spec.ts +937 -0
- package/src/lib/services/transaction-builders/xrpl-transaction-builder.service.ts +832 -0
- package/src/lib/services/transaction.service.ts +346 -0
- package/src/lib/services/unified-wallet.service.spec.ts +1382 -0
- package/src/lib/services/unified-wallet.service.ts +852 -0
- package/src/lib/services/wallet-context.service.ts +184 -0
- package/src/lib/services/wallet-event-bus.service.ts +186 -0
- package/src/lib/services/wallet-providers.service.ts +137 -0
- package/src/lib/transports/chrome-extension-transport.ts +246 -0
- package/src/lib/utils/index.ts +14 -0
- package/src/lib/utils/ledger-icons.util.ts +78 -0
- package/test/test-setup.ts +21 -0
- package/test-setup.ts +63 -0
- package/tsconfig.build.json +11 -0
- package/tsconfig.json +29 -0
- package/tsconfig.spec.json +15 -0
- package/vitest.config.ts +48 -0
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HSuite Native Connect
|
|
3
|
+
* Copyright 2024-2025 HSuite (https://hsuite.finance)
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
|
|
6
|
+
*
|
|
7
|
+
* This file is part of HSuite Native Connect. For commercial licensing,
|
|
8
|
+
* visit https://hsuite.finance/licensing
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @file account-selector.component.ts
|
|
13
|
+
* @description Flexible account selector with both inline and modal presentation modes
|
|
14
|
+
*
|
|
15
|
+
* Orchestrator component for account selection functionality.
|
|
16
|
+
* Delegates to child components for rendering and service for business logic.
|
|
17
|
+
*
|
|
18
|
+
* **Features:**
|
|
19
|
+
* - Dual presentation: inline (default) or modal
|
|
20
|
+
* - Collapsible groups by Protocol / Network / Accounts
|
|
21
|
+
* - Full keyboard navigation and accessibility support
|
|
22
|
+
* - Shows all accounts from all sessions (multi-session WalletConnect support)
|
|
23
|
+
* - Displays session metadata (sessionKey, topic for WalletConnect)
|
|
24
|
+
* - Disconnect button per WalletConnect session with confirmation
|
|
25
|
+
* - Optional balance and metadata display
|
|
26
|
+
* - Theme-aware styling with dark mode support
|
|
27
|
+
*
|
|
28
|
+
* **Architecture:**
|
|
29
|
+
* This component acts as an orchestrator, delegating to:
|
|
30
|
+
* - `AccountListComponent` - List rendering
|
|
31
|
+
* - `AccountFilterComponent` - Compact header and filtering
|
|
32
|
+
* - `AccountActionsComponent` - Action buttons
|
|
33
|
+
* - `AccountSelectorService` - Business logic
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
import {
|
|
37
|
+
Component,
|
|
38
|
+
EventEmitter,
|
|
39
|
+
Input,
|
|
40
|
+
Output,
|
|
41
|
+
inject,
|
|
42
|
+
OnInit,
|
|
43
|
+
HostBinding,
|
|
44
|
+
computed,
|
|
45
|
+
signal,
|
|
46
|
+
ViewEncapsulation,
|
|
47
|
+
} from '@angular/core';
|
|
48
|
+
import { CommonModule } from '@angular/common';
|
|
49
|
+
import { IonContent, IonButton, IonIcon, ModalController } from '@ionic/angular/standalone';
|
|
50
|
+
import { addIcons } from 'ionicons';
|
|
51
|
+
import { closeOutline, walletOutline } from 'ionicons/icons';
|
|
52
|
+
|
|
53
|
+
// Child components
|
|
54
|
+
import {
|
|
55
|
+
AccountListComponent,
|
|
56
|
+
AccountItem,
|
|
57
|
+
LedgerGroup,
|
|
58
|
+
} from './account-list/account-list.component';
|
|
59
|
+
import {
|
|
60
|
+
AccountFilterComponent,
|
|
61
|
+
CompactHeaderFormat,
|
|
62
|
+
CompactHeaderSize,
|
|
63
|
+
} from './account-filter/account-filter.component';
|
|
64
|
+
import { AccountActionsComponent } from './account-actions/account-actions.component';
|
|
65
|
+
|
|
66
|
+
// Services
|
|
67
|
+
import { AccountSelectorService, SelectedAccountData } from './account-selector.service';
|
|
68
|
+
import { AccountFormattingService } from './account-formatting.service';
|
|
69
|
+
import { UnifiedWalletService } from '../../services/unified-wallet.service';
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Presentation mode for the Account Selector
|
|
73
|
+
*/
|
|
74
|
+
export type AccountSelectorPresentationMode = 'inline' | 'modal';
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Grouping mode for account display
|
|
78
|
+
*/
|
|
79
|
+
export type AccountGroupingMode = 'nested' | 'flat' | 'none';
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Configuration options for the Account Selector
|
|
83
|
+
*/
|
|
84
|
+
export interface AccountSelectorConfig {
|
|
85
|
+
/** Presentation mode: 'inline' (default) or 'modal' */
|
|
86
|
+
presentationMode?: AccountSelectorPresentationMode;
|
|
87
|
+
/** Display account balances (if available) */
|
|
88
|
+
showBalances?: boolean;
|
|
89
|
+
/** Display last activity timestamp */
|
|
90
|
+
showLastActivity?: boolean;
|
|
91
|
+
/** Display online/offline network status */
|
|
92
|
+
showNetworkStatus?: boolean;
|
|
93
|
+
/** Enable search/filter functionality */
|
|
94
|
+
enableSearch?: boolean;
|
|
95
|
+
/** Default expansion state for groups */
|
|
96
|
+
defaultExpanded?: 'all' | 'first' | 'none';
|
|
97
|
+
/** Show compact header with wallet info and count */
|
|
98
|
+
showCompactHeader?: boolean;
|
|
99
|
+
/** Format for compact header display */
|
|
100
|
+
compactHeaderFormat?: CompactHeaderFormat;
|
|
101
|
+
/** Size variant for compact header */
|
|
102
|
+
compactHeaderSize?: CompactHeaderSize;
|
|
103
|
+
/** Allow collapse/expand via compact header (inline mode) */
|
|
104
|
+
collapsible?: boolean;
|
|
105
|
+
/** Grouping mode: 'nested' | 'flat' | 'none' */
|
|
106
|
+
groupingMode?: AccountGroupingMode;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @component AccountSelectorComponent
|
|
111
|
+
* Flexible account selector with both inline and modal presentation modes.
|
|
112
|
+
*/
|
|
113
|
+
@Component({
|
|
114
|
+
selector: 'wallet-account-selector',
|
|
115
|
+
standalone: true,
|
|
116
|
+
imports: [
|
|
117
|
+
CommonModule,
|
|
118
|
+
IonContent,
|
|
119
|
+
IonButton,
|
|
120
|
+
IonIcon,
|
|
121
|
+
AccountListComponent,
|
|
122
|
+
AccountFilterComponent,
|
|
123
|
+
AccountActionsComponent,
|
|
124
|
+
],
|
|
125
|
+
templateUrl: './account-selector.component.html',
|
|
126
|
+
styleUrls: ['./account-selector.component.scss'],
|
|
127
|
+
encapsulation: ViewEncapsulation.None,
|
|
128
|
+
})
|
|
129
|
+
export class AccountSelectorComponent implements OnInit {
|
|
130
|
+
/**
|
|
131
|
+
* Presentation mode: 'inline' (default) or 'modal'
|
|
132
|
+
*/
|
|
133
|
+
@Input() presentationMode: AccountSelectorPresentationMode = 'inline';
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Configuration options for the component
|
|
137
|
+
*/
|
|
138
|
+
@Input() config: AccountSelectorConfig = {
|
|
139
|
+
presentationMode: 'inline',
|
|
140
|
+
showBalances: false,
|
|
141
|
+
showLastActivity: false,
|
|
142
|
+
showNetworkStatus: false,
|
|
143
|
+
enableSearch: false,
|
|
144
|
+
defaultExpanded: 'none',
|
|
145
|
+
showCompactHeader: false,
|
|
146
|
+
compactHeaderFormat: 'label-count',
|
|
147
|
+
compactHeaderSize: 'default',
|
|
148
|
+
collapsible: true,
|
|
149
|
+
groupingMode: 'nested',
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Currently selected account ID (optional, for highlighting)
|
|
154
|
+
*/
|
|
155
|
+
@Input() selectedId?: string;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Address-based selection (legacy support)
|
|
159
|
+
*/
|
|
160
|
+
@Input() selectedAddress?: string;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Header title text
|
|
164
|
+
*/
|
|
165
|
+
@Input() headerTitle = 'Select Account';
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Custom header text for inline expandable mode
|
|
169
|
+
*/
|
|
170
|
+
@Input() customHeaderText?: string;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Optional: Manually provide ModalController instance
|
|
174
|
+
*/
|
|
175
|
+
@Input() set modalControllerInstance(controller: ModalController | undefined) {
|
|
176
|
+
if (controller) {
|
|
177
|
+
this.modalController = controller;
|
|
178
|
+
this.selectorService.setModalController(controller);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Emitted when user selects a different account (inline mode)
|
|
184
|
+
*/
|
|
185
|
+
@Output() accountChanged = new EventEmitter<SelectedAccountData>();
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Emitted when user disconnects a session (inline mode)
|
|
189
|
+
*/
|
|
190
|
+
@Output() sessionDisconnected = new EventEmitter<{
|
|
191
|
+
providerId: string;
|
|
192
|
+
sessionKey?: string;
|
|
193
|
+
}>();
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Emitted when user clicks the Connect Wallet button (inline mode)
|
|
197
|
+
*/
|
|
198
|
+
@Output() connectWalletRequested = new EventEmitter<void>();
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Host binding for presentation mode styling
|
|
202
|
+
*/
|
|
203
|
+
@HostBinding('attr.data-presentation-mode')
|
|
204
|
+
get hostPresentationMode(): string {
|
|
205
|
+
return this.effectivePresentationMode;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Injected services
|
|
209
|
+
protected readonly selectorService = inject(AccountSelectorService);
|
|
210
|
+
protected readonly formatting = inject(AccountFormattingService);
|
|
211
|
+
protected readonly wallet = inject(UnifiedWalletService);
|
|
212
|
+
protected modalController = inject(ModalController, { optional: true });
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Track if the account list is collapsed (inline mode with compact header)
|
|
216
|
+
*/
|
|
217
|
+
protected readonly isCollapsed = signal<boolean>(false);
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Computed: ledger groups from service
|
|
221
|
+
*/
|
|
222
|
+
protected readonly groupedByLedger = computed<LedgerGroup[]>(() =>
|
|
223
|
+
this.selectorService.groupedByLedger(),
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Computed: active account for filter component
|
|
228
|
+
*/
|
|
229
|
+
protected readonly activeAccountData = computed(() => {
|
|
230
|
+
const active = this.selectorService.activeAccount();
|
|
231
|
+
if (!active) return null;
|
|
232
|
+
return {
|
|
233
|
+
address: active.address,
|
|
234
|
+
networkId: active.networkId,
|
|
235
|
+
label: active.label,
|
|
236
|
+
providerType: active.providerType,
|
|
237
|
+
};
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Computed: currently connected account with session
|
|
242
|
+
*/
|
|
243
|
+
protected readonly currentlyConnectedAccount = computed(() =>
|
|
244
|
+
this.selectorService.currentlyConnectedAccount(),
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Computed: total account count
|
|
249
|
+
*/
|
|
250
|
+
protected readonly totalAccountCount = computed(() => this.selectorService.totalAccountCount());
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Computed: wallet logo for active account
|
|
254
|
+
*/
|
|
255
|
+
protected readonly activeWalletLogo = computed(() => this.selectorService.getActiveWalletLogo());
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Computed: loading state from service
|
|
259
|
+
*/
|
|
260
|
+
protected readonly isLoading = computed(() => this.selectorService.isLoading());
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Computed: error state from service
|
|
264
|
+
*/
|
|
265
|
+
protected readonly error = computed(() => this.selectorService.error());
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Computed: has connected sessions
|
|
269
|
+
*/
|
|
270
|
+
protected readonly hasAccounts = computed(() => this.wallet.getActiveSessions().length > 0);
|
|
271
|
+
|
|
272
|
+
constructor() {
|
|
273
|
+
addIcons({ closeOutline, walletOutline });
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Get effective presentation mode
|
|
278
|
+
*/
|
|
279
|
+
protected get effectivePresentationMode(): AccountSelectorPresentationMode {
|
|
280
|
+
return this.presentationMode || this.config.presentationMode || 'inline';
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Check if we're in modal mode
|
|
285
|
+
*/
|
|
286
|
+
protected get isModalMode(): boolean {
|
|
287
|
+
return this.effectivePresentationMode === 'modal';
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Check if we're in inline mode
|
|
292
|
+
*/
|
|
293
|
+
protected get isInlineMode(): boolean {
|
|
294
|
+
return this.effectivePresentationMode === 'inline';
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Initialize component state
|
|
299
|
+
*/
|
|
300
|
+
ngOnInit(): void {
|
|
301
|
+
this.initializeCollapsedState();
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Initialize collapsed state for compact header
|
|
306
|
+
*/
|
|
307
|
+
private initializeCollapsedState(): void {
|
|
308
|
+
if (this.config.showCompactHeader && this.config.defaultExpanded === 'none') {
|
|
309
|
+
this.isCollapsed.set(true);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Toggle collapse/expand of account list
|
|
315
|
+
*/
|
|
316
|
+
protected toggleCollapse(): void {
|
|
317
|
+
if (this.config.collapsible && this.isInlineMode && this.config.showCompactHeader) {
|
|
318
|
+
this.isCollapsed.update((value) => !value);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Handle account selection from list component
|
|
324
|
+
*/
|
|
325
|
+
protected async onAccountSelected(accountItem: AccountItem): Promise<void> {
|
|
326
|
+
const accountData = await this.selectorService.selectAccount(
|
|
327
|
+
accountItem,
|
|
328
|
+
this.effectivePresentationMode,
|
|
329
|
+
);
|
|
330
|
+
|
|
331
|
+
if (accountData) {
|
|
332
|
+
if (this.isInlineMode) {
|
|
333
|
+
this.accountChanged.emit(accountData);
|
|
334
|
+
} else if (this.isModalMode && this.modalController) {
|
|
335
|
+
await this.modalController.dismiss({ account: accountData });
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Handle disconnect request from list component
|
|
342
|
+
*/
|
|
343
|
+
protected async onDisconnectRequested(event: {
|
|
344
|
+
providerId: string;
|
|
345
|
+
sessionKey?: string;
|
|
346
|
+
}): Promise<void> {
|
|
347
|
+
const success = await this.selectorService.disconnectSession(
|
|
348
|
+
event.providerId,
|
|
349
|
+
event.sessionKey,
|
|
350
|
+
this.effectivePresentationMode,
|
|
351
|
+
);
|
|
352
|
+
|
|
353
|
+
if (success && this.isInlineMode) {
|
|
354
|
+
this.sessionDisconnected.emit(event);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Handle disconnect all action
|
|
360
|
+
*/
|
|
361
|
+
protected async onDisconnectAll(): Promise<void> {
|
|
362
|
+
const success = await this.selectorService.disconnectAll(this.effectivePresentationMode);
|
|
363
|
+
if (success && this.isModalMode && this.modalController) {
|
|
364
|
+
await this.modalController.dismiss({ disconnectedAll: true });
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Handle add account action
|
|
370
|
+
*/
|
|
371
|
+
protected async onAddAccount(): Promise<void> {
|
|
372
|
+
if (this.isModalMode && this.modalController) {
|
|
373
|
+
await this.modalController.dismiss({ action: 'add-account' });
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Handle connect wallet button click
|
|
379
|
+
*/
|
|
380
|
+
protected onConnectWalletClick(): void {
|
|
381
|
+
this.connectWalletRequested.emit();
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Dismiss error state
|
|
386
|
+
*/
|
|
387
|
+
protected onErrorDismissed(): void {
|
|
388
|
+
this.selectorService.clearError();
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Close the modal (modal mode only)
|
|
393
|
+
*/
|
|
394
|
+
protected async dismiss(): Promise<void> {
|
|
395
|
+
if (this.isModalMode && this.modalController) {
|
|
396
|
+
await this.modalController.dismiss({ cancelled: true });
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Handle keyboard events for accessibility
|
|
402
|
+
*/
|
|
403
|
+
protected handleKeyDown(event: KeyboardEvent): void {
|
|
404
|
+
if (this.isModalMode && event.key === 'Escape') {
|
|
405
|
+
event.preventDefault();
|
|
406
|
+
this.dismiss();
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// Arrow key navigation
|
|
411
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
412
|
+
event.preventDefault();
|
|
413
|
+
const direction = event.key === 'ArrowDown' ? 1 : -1;
|
|
414
|
+
const nextId = this.selectorService.navigateAccounts(
|
|
415
|
+
direction,
|
|
416
|
+
this.selectedId || this.selectorService.activeAccount()?.id,
|
|
417
|
+
);
|
|
418
|
+
if (nextId) {
|
|
419
|
+
// Find and select the account
|
|
420
|
+
const accounts = this.selectorService.allAccounts();
|
|
421
|
+
const account = accounts.find((a) => a.id === nextId);
|
|
422
|
+
if (account) {
|
|
423
|
+
const sessions = this.wallet.getActiveSessions();
|
|
424
|
+
for (const session of sessions) {
|
|
425
|
+
const matchedAccount = session.accounts?.find((a) => a.id === nextId);
|
|
426
|
+
if (matchedAccount) {
|
|
427
|
+
this.onAccountSelected({
|
|
428
|
+
account: matchedAccount,
|
|
429
|
+
session: {
|
|
430
|
+
providerId: session.providerId,
|
|
431
|
+
providerType: session.providerType,
|
|
432
|
+
metadata: session.metadata,
|
|
433
|
+
},
|
|
434
|
+
});
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// Home/End keys
|
|
444
|
+
if (event.key === 'Home' || event.key === 'End') {
|
|
445
|
+
event.preventDefault();
|
|
446
|
+
const targetId = this.selectorService.navigateToEdge(event.key === 'Home');
|
|
447
|
+
if (targetId) {
|
|
448
|
+
const accounts = this.selectorService.allAccounts();
|
|
449
|
+
const account = accounts.find((a) => a.id === targetId);
|
|
450
|
+
if (account) {
|
|
451
|
+
const sessions = this.wallet.getActiveSessions();
|
|
452
|
+
for (const session of sessions) {
|
|
453
|
+
const matchedAccount = session.accounts?.find((a) => a.id === targetId);
|
|
454
|
+
if (matchedAccount) {
|
|
455
|
+
this.onAccountSelected({
|
|
456
|
+
account: matchedAccount,
|
|
457
|
+
session: {
|
|
458
|
+
providerId: session.providerId,
|
|
459
|
+
providerType: session.providerType,
|
|
460
|
+
metadata: session.metadata,
|
|
461
|
+
},
|
|
462
|
+
});
|
|
463
|
+
break;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|