@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,227 @@
|
|
|
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-grouping.service.ts
|
|
13
|
+
* @description Account grouping and organization logic
|
|
14
|
+
*
|
|
15
|
+
* Provides account grouping utilities for the AccountSelectorComponent.
|
|
16
|
+
* Extracted to reduce component size and enable reuse.
|
|
17
|
+
*
|
|
18
|
+
* Supports three grouping modes:
|
|
19
|
+
* - 'nested': Protocol → Network → Accounts (2 clicks)
|
|
20
|
+
* - 'flat': Network → Accounts (1 click)
|
|
21
|
+
* - 'none': All accounts flat (0 clicks)
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { Injectable } from '@angular/core';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Grouping mode for account display.
|
|
28
|
+
*/
|
|
29
|
+
export type AccountGroupingMode = 'nested' | 'flat' | 'none';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Network group containing sessions and account count.
|
|
33
|
+
*/
|
|
34
|
+
export interface NetworkGroup {
|
|
35
|
+
network: string;
|
|
36
|
+
sessions: unknown[];
|
|
37
|
+
accountCount: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Protocol group containing networks.
|
|
42
|
+
*/
|
|
43
|
+
export interface ProtocolGroup {
|
|
44
|
+
protocol: string;
|
|
45
|
+
networks: NetworkGroup[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Ledger group containing accounts with session info.
|
|
50
|
+
*/
|
|
51
|
+
export interface LedgerGroup {
|
|
52
|
+
ledgerName: string;
|
|
53
|
+
ledgerId: string;
|
|
54
|
+
accounts: Array<{ account: any; session: any }>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Account grouping service.
|
|
59
|
+
*
|
|
60
|
+
* Provides utilities for organizing accounts into hierarchical groups
|
|
61
|
+
* for display in account selector components.
|
|
62
|
+
*/
|
|
63
|
+
@Injectable({ providedIn: 'root' })
|
|
64
|
+
export class AccountGroupingService {
|
|
65
|
+
/**
|
|
66
|
+
* Group sessions by protocol and network.
|
|
67
|
+
*
|
|
68
|
+
* @param sessions - Array of session objects
|
|
69
|
+
* @param mode - Grouping mode
|
|
70
|
+
* @returns Grouped sessions
|
|
71
|
+
*/
|
|
72
|
+
groupSessions(sessions: any[], mode: AccountGroupingMode): ProtocolGroup[] {
|
|
73
|
+
if (mode === 'none') {
|
|
74
|
+
return this.groupFlat(sessions);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (mode === 'flat') {
|
|
78
|
+
return this.groupByNetwork(sessions);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return this.groupNested(sessions);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Group accounts by ledger (Hedera, XRPL, etc.).
|
|
86
|
+
*
|
|
87
|
+
* @param items - Array of account items with session info
|
|
88
|
+
* @param getLedgerName - Function to get display name for ledger
|
|
89
|
+
* @returns Grouped accounts by ledger
|
|
90
|
+
*/
|
|
91
|
+
groupByLedger(
|
|
92
|
+
items: Array<{ account: any; session: any }>,
|
|
93
|
+
getLedgerName: (ledgerId: string) => string,
|
|
94
|
+
): LedgerGroup[] {
|
|
95
|
+
const ledgerMap = new Map<string, Array<{ account: any; session: any }>>();
|
|
96
|
+
|
|
97
|
+
for (const item of items) {
|
|
98
|
+
const { account } = item;
|
|
99
|
+
if (!account?.ledgerId) continue;
|
|
100
|
+
|
|
101
|
+
const ledgerId = account.ledgerId;
|
|
102
|
+
if (!ledgerMap.has(ledgerId)) {
|
|
103
|
+
ledgerMap.set(ledgerId, []);
|
|
104
|
+
}
|
|
105
|
+
ledgerMap.get(ledgerId)!.push(item);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return Array.from(ledgerMap.entries()).map(([ledgerId, accounts]) => ({
|
|
109
|
+
ledgerName: getLedgerName(ledgerId),
|
|
110
|
+
ledgerId,
|
|
111
|
+
accounts,
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Create flat grouping (no hierarchy).
|
|
117
|
+
* @private
|
|
118
|
+
*/
|
|
119
|
+
private groupFlat(sessions: any[]): ProtocolGroup[] {
|
|
120
|
+
return [
|
|
121
|
+
{
|
|
122
|
+
protocol: 'All Accounts',
|
|
123
|
+
networks: [
|
|
124
|
+
{
|
|
125
|
+
network: 'all',
|
|
126
|
+
sessions,
|
|
127
|
+
accountCount: sessions.reduce((sum: number, s) => sum + (s?.accounts?.length || 0), 0),
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Group by network only (flat mode).
|
|
136
|
+
* @private
|
|
137
|
+
*/
|
|
138
|
+
private groupByNetwork(sessions: any[]): ProtocolGroup[] {
|
|
139
|
+
const networkGroups = new Map<string, unknown[]>();
|
|
140
|
+
|
|
141
|
+
for (const session of sessions) {
|
|
142
|
+
const network = this.extractNetwork(
|
|
143
|
+
session.metadata?.networkId || session.accounts?.[0]?.networkId,
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
if (!networkGroups.has(network)) {
|
|
147
|
+
networkGroups.set(network, []);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
networkGroups.get(network)!.push(session);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return [
|
|
154
|
+
{
|
|
155
|
+
protocol: 'Wallets',
|
|
156
|
+
networks: Array.from(networkGroups.entries()).map(([network, netSessions]) => ({
|
|
157
|
+
network,
|
|
158
|
+
sessions: netSessions,
|
|
159
|
+
accountCount: netSessions.reduce(
|
|
160
|
+
(sum: number, s: any) => sum + (s?.accounts?.length || 0),
|
|
161
|
+
0,
|
|
162
|
+
) as number,
|
|
163
|
+
})),
|
|
164
|
+
},
|
|
165
|
+
];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Group by network then protocol (nested mode).
|
|
170
|
+
* @private
|
|
171
|
+
*/
|
|
172
|
+
private groupNested(sessions: any[]): ProtocolGroup[] {
|
|
173
|
+
const grouped = new Map<string, Map<string, any[]>>();
|
|
174
|
+
|
|
175
|
+
for (const session of sessions) {
|
|
176
|
+
const network = this.extractNetwork(
|
|
177
|
+
session.metadata?.networkId || session.accounts?.[0]?.networkId,
|
|
178
|
+
);
|
|
179
|
+
const protocol = session.providerType === 'hsuite-native' ? 'HSuite Native' : 'WalletConnect';
|
|
180
|
+
|
|
181
|
+
if (!grouped.has(network)) {
|
|
182
|
+
grouped.set(network, new Map());
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const networkGroup = grouped.get(network)!;
|
|
186
|
+
if (!networkGroup.has(protocol)) {
|
|
187
|
+
networkGroup.set(protocol, []);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
networkGroup.get(protocol)!.push(session);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return Array.from(grouped.entries()).map(([network, protocols]) => ({
|
|
194
|
+
protocol: network,
|
|
195
|
+
networks: Array.from(protocols.entries()).map(([proto, protoSessions]) => ({
|
|
196
|
+
network: proto,
|
|
197
|
+
sessions: protoSessions,
|
|
198
|
+
accountCount: protoSessions.reduce(
|
|
199
|
+
(sum: number, s: any) => sum + (s?.accounts?.length || 0),
|
|
200
|
+
0,
|
|
201
|
+
) as number,
|
|
202
|
+
})),
|
|
203
|
+
}));
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Extract network name from networkId.
|
|
208
|
+
*
|
|
209
|
+
* @param networkId - Full network ID (e.g., "hedera:testnet")
|
|
210
|
+
* @returns Network name (e.g., "testnet")
|
|
211
|
+
*/
|
|
212
|
+
extractNetwork(networkId?: string): string {
|
|
213
|
+
if (!networkId) return 'unknown';
|
|
214
|
+
const parts = networkId.split(':');
|
|
215
|
+
return parts[parts.length - 1] || networkId;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Get total account count for a protocol group.
|
|
220
|
+
*
|
|
221
|
+
* @param protocolGroup - Protocol group
|
|
222
|
+
* @returns Total account count
|
|
223
|
+
*/
|
|
224
|
+
getTotalAccounts(protocolGroup: ProtocolGroup): number {
|
|
225
|
+
return protocolGroup.networks.reduce((sum, network) => sum + network.accountCount, 0);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
@@ -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-list.component.ts
|
|
13
|
+
* @description Account list rendering component
|
|
14
|
+
*
|
|
15
|
+
* Renders a list of wallet accounts grouped by ledger.
|
|
16
|
+
* Extracted from AccountSelectorComponent for better maintainability.
|
|
17
|
+
*
|
|
18
|
+
* **Features:**
|
|
19
|
+
* - Renders accounts grouped by ledger (Hedera, XRPL, etc.)
|
|
20
|
+
* - Collapsible ledger groups
|
|
21
|
+
* - Selection state management
|
|
22
|
+
* - Wallet logos and network badges
|
|
23
|
+
* - Accessibility support (ARIA labels, keyboard navigation)
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import {
|
|
27
|
+
Component,
|
|
28
|
+
EventEmitter,
|
|
29
|
+
Input,
|
|
30
|
+
Output,
|
|
31
|
+
inject,
|
|
32
|
+
signal,
|
|
33
|
+
ChangeDetectionStrategy,
|
|
34
|
+
ViewEncapsulation,
|
|
35
|
+
} from '@angular/core';
|
|
36
|
+
import { CommonModule } from '@angular/common';
|
|
37
|
+
import { IonBadge, IonIcon, IonButton, IonSpinner } from '@ionic/angular/standalone';
|
|
38
|
+
import { addIcons } from 'ionicons';
|
|
39
|
+
import {
|
|
40
|
+
chevronDownOutline,
|
|
41
|
+
closeOutline,
|
|
42
|
+
walletOutline,
|
|
43
|
+
alertCircleOutline,
|
|
44
|
+
peopleOutline,
|
|
45
|
+
personOutline,
|
|
46
|
+
} from 'ionicons/icons';
|
|
47
|
+
import { AccountFormattingService } from '../account-formatting.service';
|
|
48
|
+
import { getLedgerIcon, getLedgerColor } from '../../../utils/ledger-icons.util';
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Account item with session context
|
|
52
|
+
*/
|
|
53
|
+
export interface AccountItem {
|
|
54
|
+
account: {
|
|
55
|
+
id: string;
|
|
56
|
+
address: string;
|
|
57
|
+
ledgerId: string;
|
|
58
|
+
networkId: string;
|
|
59
|
+
label?: string;
|
|
60
|
+
metadata?: {
|
|
61
|
+
channelType?: string;
|
|
62
|
+
isMultisig?: boolean;
|
|
63
|
+
[key: string]: unknown;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
session: {
|
|
67
|
+
providerId: string;
|
|
68
|
+
providerType: string;
|
|
69
|
+
metadata?: {
|
|
70
|
+
sessionKey?: string;
|
|
71
|
+
channelType?: string;
|
|
72
|
+
isMultisig?: boolean;
|
|
73
|
+
[key: string]: unknown;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Ledger group containing accounts
|
|
80
|
+
*/
|
|
81
|
+
export interface LedgerGroup {
|
|
82
|
+
ledgerName: string;
|
|
83
|
+
ledgerId: string;
|
|
84
|
+
accounts: AccountItem[];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @component AccountListComponent
|
|
89
|
+
* Renders a list of wallet accounts grouped by ledger.
|
|
90
|
+
*/
|
|
91
|
+
@Component({
|
|
92
|
+
selector: 'wallet-account-list',
|
|
93
|
+
standalone: true,
|
|
94
|
+
imports: [CommonModule, IonBadge, IonIcon, IonButton, IonSpinner],
|
|
95
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
96
|
+
encapsulation: ViewEncapsulation.None,
|
|
97
|
+
template: `
|
|
98
|
+
<!-- Loading Overlay -->
|
|
99
|
+
<div class="loading-overlay" *ngIf="isLoading">
|
|
100
|
+
<ion-spinner name="crescent"></ion-spinner>
|
|
101
|
+
<p>Processing...</p>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<!-- Account List Content -->
|
|
105
|
+
<div
|
|
106
|
+
*ngIf="ledgerGroups.length > 0"
|
|
107
|
+
class="account-list-content"
|
|
108
|
+
[class.inline-mode]="!isModal"
|
|
109
|
+
[class.modal-mode]="isModal"
|
|
110
|
+
>
|
|
111
|
+
<!-- Description -->
|
|
112
|
+
<div class="selector-description" *ngIf="showDescription">
|
|
113
|
+
Select an account you want to use:
|
|
114
|
+
</div>
|
|
115
|
+
|
|
116
|
+
<!-- Ledger Groups -->
|
|
117
|
+
<div class="sessions-groups">
|
|
118
|
+
<ng-container *ngFor="let ledgerGroup of ledgerGroups; trackBy: trackByLedger">
|
|
119
|
+
<div class="ledger-group" [class.modal-group]="isModal">
|
|
120
|
+
<!-- Ledger Header -->
|
|
121
|
+
<div
|
|
122
|
+
class="ledger-header-row"
|
|
123
|
+
[class.modal-header]="isModal"
|
|
124
|
+
(click)="toggleLedger(ledgerGroup.ledgerName); $event.stopPropagation()"
|
|
125
|
+
>
|
|
126
|
+
<div class="ledger-label">
|
|
127
|
+
<img
|
|
128
|
+
*ngIf="getLedgerIconUrl(ledgerGroup.ledgerId)"
|
|
129
|
+
[src]="getLedgerIconUrl(ledgerGroup.ledgerId)"
|
|
130
|
+
[alt]="ledgerGroup.ledgerName + ' icon'"
|
|
131
|
+
class="ledger-icon-img"
|
|
132
|
+
/>
|
|
133
|
+
<ion-icon
|
|
134
|
+
*ngIf="!getLedgerIconUrl(ledgerGroup.ledgerId)"
|
|
135
|
+
name="wallet-outline"
|
|
136
|
+
class="ledger-icon"
|
|
137
|
+
>
|
|
138
|
+
</ion-icon>
|
|
139
|
+
<span class="ledger-name">{{ ledgerGroup.ledgerName }}</span>
|
|
140
|
+
<ion-badge class="account-count-badge" color="medium">
|
|
141
|
+
{{ ledgerGroup.accounts.length }}
|
|
142
|
+
</ion-badge>
|
|
143
|
+
</div>
|
|
144
|
+
<ion-icon
|
|
145
|
+
name="chevron-down-outline"
|
|
146
|
+
class="expand-icon"
|
|
147
|
+
[class.expanded]="isLedgerExpanded(ledgerGroup.ledgerName)"
|
|
148
|
+
>
|
|
149
|
+
</ion-icon>
|
|
150
|
+
</div>
|
|
151
|
+
|
|
152
|
+
<!-- Accounts List -->
|
|
153
|
+
<div
|
|
154
|
+
class="accounts-list"
|
|
155
|
+
[class.modal-list]="isModal"
|
|
156
|
+
role="radiogroup"
|
|
157
|
+
[attr.aria-label]="'Accounts for ' + ledgerGroup.ledgerName"
|
|
158
|
+
*ngIf="isLedgerExpanded(ledgerGroup.ledgerName)"
|
|
159
|
+
>
|
|
160
|
+
<ng-container
|
|
161
|
+
*ngFor="let accountItem of ledgerGroup.accounts; trackBy: trackByAccount"
|
|
162
|
+
>
|
|
163
|
+
<!-- Account Item - Compact Card -->
|
|
164
|
+
<div
|
|
165
|
+
class="account-card"
|
|
166
|
+
[class.modal-item]="isModal"
|
|
167
|
+
[class.selected]="isAccountSelected(accountItem.account.id)"
|
|
168
|
+
(click)="selectAccount(accountItem)"
|
|
169
|
+
role="radio"
|
|
170
|
+
tabindex="0"
|
|
171
|
+
[attr.aria-checked]="isAccountSelected(accountItem.account.id)"
|
|
172
|
+
(keydown.enter)="selectAccount(accountItem)"
|
|
173
|
+
(keydown.space)="$event.preventDefault(); selectAccount(accountItem)"
|
|
174
|
+
>
|
|
175
|
+
<!-- Left: Selection Indicator + Logo -->
|
|
176
|
+
<div class="card-left">
|
|
177
|
+
<div
|
|
178
|
+
class="selection-indicator"
|
|
179
|
+
[class.active]="isAccountSelected(accountItem.account.id)"
|
|
180
|
+
>
|
|
181
|
+
<div
|
|
182
|
+
class="indicator-dot"
|
|
183
|
+
*ngIf="isAccountSelected(accountItem.account.id)"
|
|
184
|
+
></div>
|
|
185
|
+
</div>
|
|
186
|
+
<img
|
|
187
|
+
[src]="getWalletLogo(accountItem.session)"
|
|
188
|
+
[alt]="formatting.getProviderName(accountItem.session.providerType)"
|
|
189
|
+
class="wallet-logo-sm"
|
|
190
|
+
/>
|
|
191
|
+
</div>
|
|
192
|
+
|
|
193
|
+
<!-- Center: Account Details -->
|
|
194
|
+
<div class="card-center">
|
|
195
|
+
<div class="account-label" *ngIf="accountItem.account.label">
|
|
196
|
+
{{ accountItem.account.label }}
|
|
197
|
+
</div>
|
|
198
|
+
<div class="account-address" [class.has-label]="accountItem.account.label">
|
|
199
|
+
{{ formatting.truncateAddress(accountItem.account.address, 10, 8) }}
|
|
200
|
+
</div>
|
|
201
|
+
</div>
|
|
202
|
+
|
|
203
|
+
<!-- Right: Badges + Actions -->
|
|
204
|
+
<div class="card-right">
|
|
205
|
+
<div class="badge-stack">
|
|
206
|
+
<ion-badge
|
|
207
|
+
[color]="formatting.getNetworkColor(accountItem.account.networkId)"
|
|
208
|
+
class="network-badge"
|
|
209
|
+
>
|
|
210
|
+
{{ formatting.formatNetwork(accountItem.account.networkId) }}
|
|
211
|
+
</ion-badge>
|
|
212
|
+
<div class="provider-badge-row">
|
|
213
|
+
<ion-badge
|
|
214
|
+
*ngIf="isMultisigSession(accountItem)"
|
|
215
|
+
class="signing-badge multisig"
|
|
216
|
+
color="tertiary"
|
|
217
|
+
>
|
|
218
|
+
<ion-icon name="people-outline" class="signing-icon"></ion-icon>
|
|
219
|
+
Multisig
|
|
220
|
+
</ion-badge>
|
|
221
|
+
<ion-badge class="provider-badge" color="primary">
|
|
222
|
+
{{ formatting.getProviderName(accountItem.session.providerType) }}
|
|
223
|
+
</ion-badge>
|
|
224
|
+
</div>
|
|
225
|
+
</div>
|
|
226
|
+
<ion-button
|
|
227
|
+
*ngIf="canDisconnectSession(accountItem.session) && isModal"
|
|
228
|
+
class="disconnect-btn"
|
|
229
|
+
fill="clear"
|
|
230
|
+
color="danger"
|
|
231
|
+
size="small"
|
|
232
|
+
(click)="requestDisconnect(accountItem, $event)"
|
|
233
|
+
[disabled]="isLoading"
|
|
234
|
+
>
|
|
235
|
+
<ion-icon slot="icon-only" name="close-outline"></ion-icon>
|
|
236
|
+
</ion-button>
|
|
237
|
+
</div>
|
|
238
|
+
</div>
|
|
239
|
+
</ng-container>
|
|
240
|
+
</div>
|
|
241
|
+
</div>
|
|
242
|
+
</ng-container>
|
|
243
|
+
</div>
|
|
244
|
+
</div>
|
|
245
|
+
|
|
246
|
+
<!-- No Accounts State -->
|
|
247
|
+
<div class="no-accounts" *ngIf="ledgerGroups.length === 0 && !isModal">
|
|
248
|
+
<div class="empty-state-content">
|
|
249
|
+
<ion-icon name="wallet-outline"></ion-icon>
|
|
250
|
+
<h3>No Accounts Connected</h3>
|
|
251
|
+
<p>Connect a wallet to get started with multi-chain transactions.</p>
|
|
252
|
+
</div>
|
|
253
|
+
</div>
|
|
254
|
+
|
|
255
|
+
<!-- No Accounts State (Modal) -->
|
|
256
|
+
<div class="no-accounts-modal" *ngIf="ledgerGroups.length === 0 && isModal">
|
|
257
|
+
<ion-icon name="wallet-outline"></ion-icon>
|
|
258
|
+
<h3>No Accounts Connected</h3>
|
|
259
|
+
<p>Connect a wallet to get started</p>
|
|
260
|
+
</div>
|
|
261
|
+
|
|
262
|
+
<!-- Error State -->
|
|
263
|
+
<div class="error-state" *ngIf="error">
|
|
264
|
+
<ion-icon name="alert-circle-outline" color="danger"></ion-icon>
|
|
265
|
+
<h3>Something went wrong</h3>
|
|
266
|
+
<p>{{ error }}</p>
|
|
267
|
+
<ion-button expand="block" fill="outline" (click)="dismissError()"> Dismiss </ion-button>
|
|
268
|
+
</div>
|
|
269
|
+
`,
|
|
270
|
+
styles: [
|
|
271
|
+
`
|
|
272
|
+
:host {
|
|
273
|
+
display: block;
|
|
274
|
+
width: 100%;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/* Inherit styles from parent component's SCSS */
|
|
278
|
+
`,
|
|
279
|
+
],
|
|
280
|
+
})
|
|
281
|
+
export class AccountListComponent {
|
|
282
|
+
protected readonly formatting = inject(AccountFormattingService);
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Ledger groups containing accounts to display
|
|
286
|
+
*/
|
|
287
|
+
@Input() ledgerGroups: LedgerGroup[] = [];
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Currently selected account ID
|
|
291
|
+
*/
|
|
292
|
+
@Input() selectedId?: string;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Whether this is displayed in modal mode
|
|
296
|
+
*/
|
|
297
|
+
@Input() isModal = false;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Loading state
|
|
301
|
+
*/
|
|
302
|
+
@Input() isLoading = false;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Error message to display
|
|
306
|
+
*/
|
|
307
|
+
@Input() error: string | null = null;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Whether to show description text
|
|
311
|
+
*/
|
|
312
|
+
@Input() showDescription = true;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Active account ID from wallet service
|
|
316
|
+
*/
|
|
317
|
+
@Input() activeAccountId?: string;
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Emitted when an account is selected
|
|
321
|
+
*/
|
|
322
|
+
@Output() accountSelected = new EventEmitter<AccountItem>();
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Emitted when disconnect is requested
|
|
326
|
+
*/
|
|
327
|
+
@Output() disconnectRequested = new EventEmitter<{
|
|
328
|
+
providerId: string;
|
|
329
|
+
sessionKey?: string;
|
|
330
|
+
}>();
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Emitted when error is dismissed
|
|
334
|
+
*/
|
|
335
|
+
@Output() errorDismissed = new EventEmitter<void>();
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Track which ledger groups are expanded
|
|
339
|
+
*/
|
|
340
|
+
protected readonly expandedLedgers = signal<Set<string>>(
|
|
341
|
+
new Set(['Hedera', 'XRPL', 'hedera', 'xrpl']),
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
constructor() {
|
|
345
|
+
addIcons({
|
|
346
|
+
chevronDownOutline,
|
|
347
|
+
closeOutline,
|
|
348
|
+
walletOutline,
|
|
349
|
+
alertCircleOutline,
|
|
350
|
+
peopleOutline,
|
|
351
|
+
personOutline,
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Toggle ledger group expansion
|
|
357
|
+
*/
|
|
358
|
+
protected toggleLedger(ledgerName: string): void {
|
|
359
|
+
this.expandedLedgers.update((set) => {
|
|
360
|
+
const newSet = new Set(set);
|
|
361
|
+
if (newSet.has(ledgerName)) {
|
|
362
|
+
newSet.delete(ledgerName);
|
|
363
|
+
} else {
|
|
364
|
+
newSet.add(ledgerName);
|
|
365
|
+
}
|
|
366
|
+
return newSet;
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Check if ledger group is expanded
|
|
372
|
+
*/
|
|
373
|
+
protected isLedgerExpanded(ledgerName: string): boolean {
|
|
374
|
+
return this.expandedLedgers().has(ledgerName);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Check if account is currently selected
|
|
379
|
+
*/
|
|
380
|
+
protected isAccountSelected(accountId: string): boolean {
|
|
381
|
+
return this.selectedId === accountId || this.activeAccountId === accountId;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Check if session can be disconnected (WalletConnect sessions only)
|
|
386
|
+
*/
|
|
387
|
+
protected canDisconnectSession(session: any): boolean {
|
|
388
|
+
return session.providerType === 'walletconnect-v2';
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Check if this is a multisig session
|
|
393
|
+
*/
|
|
394
|
+
protected isMultisigSession(accountItem: AccountItem): boolean {
|
|
395
|
+
// Check session metadata first, then account metadata
|
|
396
|
+
const sessionMeta = accountItem.session.metadata;
|
|
397
|
+
const accountMeta = accountItem.account.metadata;
|
|
398
|
+
return (
|
|
399
|
+
sessionMeta?.isMultisig === true ||
|
|
400
|
+
sessionMeta?.channelType === 'party' ||
|
|
401
|
+
accountMeta?.isMultisig === true ||
|
|
402
|
+
accountMeta?.channelType === 'party'
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Get wallet logo path based on provider type
|
|
408
|
+
*/
|
|
409
|
+
protected getWalletLogo(session: any): string {
|
|
410
|
+
const providerType = session?.providerType;
|
|
411
|
+
if (providerType === 'walletconnect-v2') {
|
|
412
|
+
return 'assets/wallets/walletconnect.svg';
|
|
413
|
+
}
|
|
414
|
+
return 'assets/wallets/hsuite.svg';
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Handle account selection
|
|
419
|
+
*/
|
|
420
|
+
protected selectAccount(accountItem: AccountItem): void {
|
|
421
|
+
this.accountSelected.emit(accountItem);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Request disconnect for a session
|
|
426
|
+
*/
|
|
427
|
+
protected requestDisconnect(accountItem: AccountItem, event: Event): void {
|
|
428
|
+
event.stopPropagation();
|
|
429
|
+
event.preventDefault();
|
|
430
|
+
this.disconnectRequested.emit({
|
|
431
|
+
providerId: accountItem.session.providerId,
|
|
432
|
+
sessionKey: accountItem.session.metadata?.sessionKey,
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Dismiss error state
|
|
438
|
+
*/
|
|
439
|
+
protected dismissError(): void {
|
|
440
|
+
this.errorDismissed.emit();
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* TrackBy function for ledger groups
|
|
445
|
+
*/
|
|
446
|
+
protected trackByLedger(_index: number, ledgerGroup: LedgerGroup): string {
|
|
447
|
+
return ledgerGroup.ledgerId;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* TrackBy function for accounts
|
|
452
|
+
*/
|
|
453
|
+
protected trackByAccount(_index: number, accountItem: AccountItem): string {
|
|
454
|
+
return accountItem.account.id;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Get icon URL for ledger type (uses CoinGecko CDN)
|
|
459
|
+
*/
|
|
460
|
+
protected getLedgerIconUrl(ledgerId: string): string {
|
|
461
|
+
return getLedgerIcon(ledgerId);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Get icon color for ledger type
|
|
466
|
+
*/
|
|
467
|
+
protected getLedgerIconColor(ledgerId: string): string {
|
|
468
|
+
return getLedgerColor(ledgerId);
|
|
469
|
+
}
|
|
470
|
+
}
|