@hsuite/native-connect-angular 2.1.0 → 2.1.2
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/LICENSE +146 -0
- package/dist/fesm2022/hsuite-native-connect-angular.mjs +854 -308
- package/dist/fesm2022/hsuite-native-connect-angular.mjs.map +1 -1
- package/dist/index.d.ts +456 -30
- package/package.json +30 -13
- package/USAGE_EXAMPLES.md +0 -476
- package/assets/wallets/extension.svg +0 -7
- package/assets/wallets/hashpack.svg +0 -6
- package/assets/wallets/hsuite.svg +0 -11
- package/assets/wallets/kabila.svg +0 -11
- package/assets/wallets/walletconnect.svg +0 -13
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/coverage-summary.json +0 -50
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -476
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -476
- package/coverage/lcov-report/lib/components/account-selector/account-actions/account-actions.component.ts.html +0 -868
- package/coverage/lcov-report/lib/components/account-selector/account-actions/index.html +0 -116
- package/coverage/lcov-report/lib/components/account-selector/account-filter/account-filter.component.ts.html +0 -1288
- package/coverage/lcov-report/lib/components/account-selector/account-filter/index.html +0 -116
- package/coverage/lcov-report/lib/components/account-selector/account-formatting.service.ts.html +0 -685
- package/coverage/lcov-report/lib/components/account-selector/account-grouping.service.ts.html +0 -766
- package/coverage/lcov-report/lib/components/account-selector/account-list/account-list.component.ts.html +0 -1495
- package/coverage/lcov-report/lib/components/account-selector/account-list/index.html +0 -116
- package/coverage/lcov-report/lib/components/account-selector/account-selector.component.ts.html +0 -1495
- package/coverage/lcov-report/lib/components/account-selector/account-selector.service.ts.html +0 -1588
- package/coverage/lcov-report/lib/components/account-selector/index.html +0 -161
- package/coverage/lcov-report/lib/components/wallet-account-display/index.html +0 -116
- package/coverage/lcov-report/lib/components/wallet-account-display/wallet-account-display.component.ts.html +0 -505
- package/coverage/lcov-report/lib/components/wallet-connect-button/index.html +0 -116
- package/coverage/lcov-report/lib/components/wallet-connect-button/wallet-connect-button.component.ts.html +0 -829
- package/coverage/lcov-report/lib/components/wallet-connect-prompt/index.html +0 -116
- package/coverage/lcov-report/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts.html +0 -409
- package/coverage/lcov-report/lib/components/wallet-connected-guard/index.html +0 -116
- package/coverage/lcov-report/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts.html +0 -304
- package/coverage/lcov-report/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts.html +0 -436
- package/coverage/lcov-report/lib/components/wallet-connection-modal/connection-method-step/index.html +0 -116
- package/coverage/lcov-report/lib/components/wallet-connection-modal/index.html +0 -116
- package/coverage/lcov-report/lib/components/wallet-connection-modal/qr-pairing-step/index.html +0 -116
- package/coverage/lcov-report/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts.html +0 -2287
- package/coverage/lcov-report/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts.html +0 -2470
- package/coverage/lcov-report/lib/components/wallet-session-display/index.html +0 -116
- package/coverage/lcov-report/lib/components/wallet-session-display/wallet-session-display.component.ts.html +0 -676
- package/coverage/lcov-report/lib/components/wallet-transaction-status/index.html +0 -116
- package/coverage/lcov-report/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts.html +0 -703
- package/coverage/lcov-report/lib/directives/index.html +0 -146
- package/coverage/lcov-report/lib/directives/wallet-connected.directive.ts.html +0 -670
- package/coverage/lcov-report/lib/directives/wallet-context.directive.ts.html +0 -547
- package/coverage/lcov-report/lib/directives/wallet-events.directive.ts.html +0 -781
- package/coverage/lcov-report/lib/hsuite-wallet.module.ts.html +0 -715
- package/coverage/lcov-report/lib/index.html +0 -116
- package/coverage/lcov-report/lib/models/connection-config.model.ts.html +0 -280
- package/coverage/lcov-report/lib/models/index.html +0 -131
- package/coverage/lcov-report/lib/models/provider-types.ts.html +0 -577
- package/coverage/lcov-report/lib/providers/base-wallet-provider.ts.html +0 -1138
- package/coverage/lcov-report/lib/providers/hsuite-native/channel-client.service.ts.html +0 -2671
- package/coverage/lcov-report/lib/providers/hsuite-native/index.html +0 -116
- package/coverage/lcov-report/lib/providers/hsuite-native-provider.ts.html +0 -2347
- package/coverage/lcov-report/lib/providers/index.html +0 -146
- package/coverage/lcov-report/lib/providers/p2p-native/index.html +0 -131
- package/coverage/lcov-report/lib/providers/p2p-native/p2p-native.provider.ts.html +0 -2254
- package/coverage/lcov-report/lib/providers/p2p-native/p2p-session-manager.ts.html +0 -2170
- package/coverage/lcov-report/lib/providers/wallet-error-handler.ts.html +0 -1132
- package/coverage/lcov-report/lib/providers/walletconnect/core/index.html +0 -176
- package/coverage/lcov-report/lib/providers/walletconnect/core/session-health.ts.html +0 -673
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-client-manager.ts.html +0 -1177
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-provider.ts.html +0 -2563
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-session-store.ts.html +0 -904
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts.html +0 -982
- package/coverage/lcov-report/lib/providers/walletconnect/signers/hedera-signer.ts.html +0 -1915
- package/coverage/lcov-report/lib/providers/walletconnect/signers/index.html +0 -146
- package/coverage/lcov-report/lib/providers/walletconnect/signers/signer-factory.ts.html +0 -445
- package/coverage/lcov-report/lib/providers/walletconnect/signers/xrpl-signer.ts.html +0 -1519
- package/coverage/lcov-report/lib/services/index.html +0 -191
- package/coverage/lcov-report/lib/services/logger.service.ts.html +0 -463
- package/coverage/lcov-report/lib/services/transaction-builders/base-transaction-builder.service.ts.html +0 -1840
- package/coverage/lcov-report/lib/services/transaction-builders/hedera-amount-utils.ts.html +0 -337
- package/coverage/lcov-report/lib/services/transaction-builders/hedera-transaction-builder.service.ts.html +0 -3940
- package/coverage/lcov-report/lib/services/transaction-builders/index.html +0 -161
- package/coverage/lcov-report/lib/services/transaction-builders/xrpl-transaction-builder.service.ts.html +0 -2581
- package/coverage/lcov-report/lib/services/transaction.service.ts.html +0 -1120
- package/coverage/lcov-report/lib/services/unified-wallet.service.ts.html +0 -2638
- package/coverage/lcov-report/lib/services/wallet-context.service.ts.html +0 -637
- package/coverage/lcov-report/lib/services/wallet-event-bus.service.ts.html +0 -643
- package/coverage/lcov-report/lib/services/wallet-providers.service.ts.html +0 -493
- package/coverage/lcov-report/lib/transports/chrome-extension-transport.ts.html +0 -823
- package/coverage/lcov-report/lib/transports/index.html +0 -116
- package/coverage/lcov-report/lib/utils/index.html +0 -116
- package/coverage/lcov-report/lib/utils/ledger-icons.util.ts.html +0 -319
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov.info +0 -18695
- package/coverage/lib/components/account-selector/account-actions/account-actions.component.ts.html +0 -868
- package/coverage/lib/components/account-selector/account-actions/index.html +0 -116
- package/coverage/lib/components/account-selector/account-filter/account-filter.component.ts.html +0 -1288
- package/coverage/lib/components/account-selector/account-filter/index.html +0 -116
- package/coverage/lib/components/account-selector/account-formatting.service.ts.html +0 -685
- package/coverage/lib/components/account-selector/account-grouping.service.ts.html +0 -766
- package/coverage/lib/components/account-selector/account-list/account-list.component.ts.html +0 -1495
- package/coverage/lib/components/account-selector/account-list/index.html +0 -116
- package/coverage/lib/components/account-selector/account-selector.component.ts.html +0 -1495
- package/coverage/lib/components/account-selector/account-selector.service.ts.html +0 -1588
- package/coverage/lib/components/account-selector/index.html +0 -161
- package/coverage/lib/components/wallet-account-display/index.html +0 -116
- package/coverage/lib/components/wallet-account-display/wallet-account-display.component.ts.html +0 -505
- package/coverage/lib/components/wallet-connect-button/index.html +0 -116
- package/coverage/lib/components/wallet-connect-button/wallet-connect-button.component.ts.html +0 -829
- package/coverage/lib/components/wallet-connect-prompt/index.html +0 -116
- package/coverage/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts.html +0 -409
- package/coverage/lib/components/wallet-connected-guard/index.html +0 -116
- package/coverage/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts.html +0 -304
- package/coverage/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts.html +0 -436
- package/coverage/lib/components/wallet-connection-modal/connection-method-step/index.html +0 -116
- package/coverage/lib/components/wallet-connection-modal/index.html +0 -116
- package/coverage/lib/components/wallet-connection-modal/qr-pairing-step/index.html +0 -116
- package/coverage/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts.html +0 -2287
- package/coverage/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts.html +0 -2470
- package/coverage/lib/components/wallet-session-display/index.html +0 -116
- package/coverage/lib/components/wallet-session-display/wallet-session-display.component.ts.html +0 -676
- package/coverage/lib/components/wallet-transaction-status/index.html +0 -116
- package/coverage/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts.html +0 -703
- package/coverage/lib/directives/index.html +0 -146
- package/coverage/lib/directives/wallet-connected.directive.ts.html +0 -670
- package/coverage/lib/directives/wallet-context.directive.ts.html +0 -547
- package/coverage/lib/directives/wallet-events.directive.ts.html +0 -781
- package/coverage/lib/hsuite-wallet.module.ts.html +0 -715
- package/coverage/lib/index.html +0 -116
- package/coverage/lib/models/connection-config.model.ts.html +0 -280
- package/coverage/lib/models/index.html +0 -131
- package/coverage/lib/models/provider-types.ts.html +0 -577
- package/coverage/lib/providers/base-wallet-provider.ts.html +0 -1138
- package/coverage/lib/providers/hsuite-native/channel-client.service.ts.html +0 -2671
- package/coverage/lib/providers/hsuite-native/index.html +0 -116
- package/coverage/lib/providers/hsuite-native-provider.ts.html +0 -2347
- package/coverage/lib/providers/index.html +0 -146
- package/coverage/lib/providers/p2p-native/index.html +0 -131
- package/coverage/lib/providers/p2p-native/p2p-native.provider.ts.html +0 -2254
- package/coverage/lib/providers/p2p-native/p2p-session-manager.ts.html +0 -2170
- package/coverage/lib/providers/wallet-error-handler.ts.html +0 -1132
- package/coverage/lib/providers/walletconnect/core/index.html +0 -176
- package/coverage/lib/providers/walletconnect/core/session-health.ts.html +0 -673
- package/coverage/lib/providers/walletconnect/core/walletconnect-client-manager.ts.html +0 -1177
- package/coverage/lib/providers/walletconnect/core/walletconnect-provider.ts.html +0 -2563
- package/coverage/lib/providers/walletconnect/core/walletconnect-session-store.ts.html +0 -904
- package/coverage/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts.html +0 -982
- package/coverage/lib/providers/walletconnect/signers/hedera-signer.ts.html +0 -1915
- package/coverage/lib/providers/walletconnect/signers/index.html +0 -146
- package/coverage/lib/providers/walletconnect/signers/signer-factory.ts.html +0 -445
- package/coverage/lib/providers/walletconnect/signers/xrpl-signer.ts.html +0 -1519
- package/coverage/lib/services/index.html +0 -191
- package/coverage/lib/services/logger.service.ts.html +0 -463
- package/coverage/lib/services/transaction-builders/base-transaction-builder.service.ts.html +0 -1840
- package/coverage/lib/services/transaction-builders/hedera-amount-utils.ts.html +0 -337
- package/coverage/lib/services/transaction-builders/hedera-transaction-builder.service.ts.html +0 -3940
- package/coverage/lib/services/transaction-builders/index.html +0 -161
- package/coverage/lib/services/transaction-builders/xrpl-transaction-builder.service.ts.html +0 -2581
- package/coverage/lib/services/transaction.service.ts.html +0 -1120
- package/coverage/lib/services/unified-wallet.service.ts.html +0 -2638
- package/coverage/lib/services/wallet-context.service.ts.html +0 -637
- package/coverage/lib/services/wallet-event-bus.service.ts.html +0 -643
- package/coverage/lib/services/wallet-providers.service.ts.html +0 -493
- package/coverage/lib/transports/chrome-extension-transport.ts.html +0 -823
- package/coverage/lib/transports/index.html +0 -116
- package/coverage/lib/utils/index.html +0 -116
- package/coverage/lib/utils/ledger-icons.util.ts.html +0 -319
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -210
- package/examples/minimal-connect.ts +0 -178
- package/examples/multi-protocol.ts +0 -495
- package/examples/transaction-signing.ts +0 -361
- package/jest.config.json +0 -45
- package/karma.conf.js +0 -42
- package/ng-package.json +0 -20
- package/src/index.ts +0 -203
- package/src/lib/components/account-selector/account-actions/account-actions.component.ts +0 -261
- package/src/lib/components/account-selector/account-filter/account-filter.component.ts +0 -401
- package/src/lib/components/account-selector/account-formatting.service.ts +0 -200
- package/src/lib/components/account-selector/account-grouping.service.ts +0 -227
- package/src/lib/components/account-selector/account-list/account-list.component.ts +0 -470
- package/src/lib/components/account-selector/account-selector.component.html +0 -135
- package/src/lib/components/account-selector/account-selector.component.scss +0 -2039
- package/src/lib/components/account-selector/account-selector.component.ts +0 -470
- package/src/lib/components/account-selector/account-selector.service.ts +0 -501
- package/src/lib/components/wallet-account-display/wallet-account-display.component.html +0 -34
- package/src/lib/components/wallet-account-display/wallet-account-display.component.scss +0 -99
- package/src/lib/components/wallet-account-display/wallet-account-display.component.ts +0 -140
- package/src/lib/components/wallet-connect-button/wallet-connect-button.component.html +0 -14
- package/src/lib/components/wallet-connect-button/wallet-connect-button.component.scss +0 -272
- package/src/lib/components/wallet-connect-button/wallet-connect-button.component.spec.ts +0 -89
- package/src/lib/components/wallet-connect-button/wallet-connect-button.component.ts +0 -248
- package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.html +0 -24
- package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.scss +0 -50
- package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts +0 -108
- package/src/lib/components/wallet-connected-guard/wallet-connected-guard.component.html +0 -24
- package/src/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts +0 -73
- package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.html +0 -56
- package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.scss +0 -218
- package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts +0 -117
- package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.html +0 -94
- package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.scss +0 -272
- package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts +0 -734
- package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.html +0 -192
- package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.scss +0 -678
- package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.spec.ts +0 -173
- package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts +0 -795
- package/src/lib/components/wallet-session-display/wallet-session-display.component.html +0 -110
- package/src/lib/components/wallet-session-display/wallet-session-display.component.scss +0 -179
- package/src/lib/components/wallet-session-display/wallet-session-display.component.ts +0 -197
- package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.html +0 -65
- package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.scss +0 -254
- package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts +0 -206
- package/src/lib/directives/wallet-connected.directive.ts +0 -195
- package/src/lib/directives/wallet-context.directive.ts +0 -154
- package/src/lib/directives/wallet-events.directive.ts +0 -232
- package/src/lib/hsuite-wallet.module.ts +0 -210
- package/src/lib/models/connection-config.model.ts +0 -65
- package/src/lib/models/provider-types.ts +0 -164
- package/src/lib/models/unified-account.model.ts +0 -76
- package/src/lib/models/wallet-context.model.ts +0 -121
- package/src/lib/models/wallet-events.model.ts +0 -158
- package/src/lib/providers/base-wallet-provider.ts +0 -351
- package/src/lib/providers/hsuite-native/channel-client.service.spec.ts +0 -73
- package/src/lib/providers/hsuite-native/channel-client.service.ts +0 -862
- package/src/lib/providers/hsuite-native/index.ts +0 -8
- package/src/lib/providers/hsuite-native-provider.ts +0 -754
- package/src/lib/providers/mobile-native/mobile-native.provider.spec.ts +0 -19
- package/src/lib/providers/p2p-native/index.ts +0 -30
- package/src/lib/providers/p2p-native/p2p-native.provider.spec.ts +0 -523
- package/src/lib/providers/p2p-native/p2p-native.provider.ts +0 -723
- package/src/lib/providers/p2p-native/p2p-session-manager.ts +0 -695
- package/src/lib/providers/wallet-error-handler.ts +0 -349
- package/src/lib/providers/walletconnect/core/base-signer.interface.ts +0 -122
- package/src/lib/providers/walletconnect/core/session-health.ts +0 -196
- package/src/lib/providers/walletconnect/core/walletconnect-client-manager.ts +0 -364
- package/src/lib/providers/walletconnect/core/walletconnect-provider.integration.spec.ts +0 -348
- package/src/lib/providers/walletconnect/core/walletconnect-provider.ts +0 -826
- package/src/lib/providers/walletconnect/core/walletconnect-session-store.ts +0 -273
- package/src/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts +0 -299
- package/src/lib/providers/walletconnect/core/walletconnect-types.ts +0 -48
- package/src/lib/providers/walletconnect/index.ts +0 -33
- package/src/lib/providers/walletconnect/signers/hedera-signer.spec.ts +0 -367
- package/src/lib/providers/walletconnect/signers/hedera-signer.ts +0 -610
- package/src/lib/providers/walletconnect/signers/signer-factory.spec.ts +0 -62
- package/src/lib/providers/walletconnect/signers/signer-factory.ts +0 -120
- package/src/lib/providers/walletconnect/signers/xrpl-signer.spec.ts +0 -296
- package/src/lib/providers/walletconnect/signers/xrpl-signer.ts +0 -478
- package/src/lib/services/logger.service.ts +0 -126
- package/src/lib/services/transaction-builders/base-transaction-builder.service.ts +0 -585
- package/src/lib/services/transaction-builders/hedera-amount-utils.ts +0 -84
- package/src/lib/services/transaction-builders/hedera-transaction-builder.service.spec.ts +0 -741
- package/src/lib/services/transaction-builders/hedera-transaction-builder.service.ts +0 -1285
- package/src/lib/services/transaction-builders/index.ts +0 -54
- package/src/lib/services/transaction-builders/xrpl-transaction-builder.service.spec.ts +0 -937
- package/src/lib/services/transaction-builders/xrpl-transaction-builder.service.ts +0 -832
- package/src/lib/services/transaction.service.ts +0 -345
- package/src/lib/services/unified-wallet.service.spec.ts +0 -1382
- package/src/lib/services/unified-wallet.service.ts +0 -851
- package/src/lib/services/wallet-context.service.ts +0 -184
- package/src/lib/services/wallet-event-bus.service.ts +0 -186
- package/src/lib/services/wallet-providers.service.ts +0 -136
- package/src/lib/transports/chrome-extension-transport.ts +0 -246
- package/src/lib/utils/index.ts +0 -14
- package/src/lib/utils/ledger-icons.util.ts +0 -78
- package/test/test-setup.ts +0 -21
- package/test-setup.ts +0 -63
- package/tsconfig.build.json +0 -11
- package/tsconfig.json +0 -29
- package/tsconfig.spec.json +0 -15
- package/vitest.config.ts +0 -48
|
@@ -1,200 +0,0 @@
|
|
|
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-formatting.service.ts
|
|
13
|
-
* @description Account display formatting utilities
|
|
14
|
-
*
|
|
15
|
-
* Provides formatting utilities for displaying accounts, addresses,
|
|
16
|
-
* networks, and ledgers in the AccountSelectorComponent.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import { Injectable } from '@angular/core';
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Account formatting service.
|
|
23
|
-
*
|
|
24
|
-
* Provides utilities for formatting account-related display strings.
|
|
25
|
-
*/
|
|
26
|
-
@Injectable({ providedIn: 'root' })
|
|
27
|
-
export class AccountFormattingService {
|
|
28
|
-
/**
|
|
29
|
-
* Truncate address for display.
|
|
30
|
-
*
|
|
31
|
-
* @param address - Full address
|
|
32
|
-
* @param prefixLength - Characters to show at start (default: 6)
|
|
33
|
-
* @param suffixLength - Characters to show at end (default: 4)
|
|
34
|
-
* @returns Truncated address with ellipsis
|
|
35
|
-
*/
|
|
36
|
-
truncateAddress(address: string, prefixLength = 6, suffixLength = 4): string {
|
|
37
|
-
if (!address) return '';
|
|
38
|
-
if (address.length <= prefixLength + suffixLength + 3) return address;
|
|
39
|
-
return `${address.substring(0, prefixLength)}...${address.substring(address.length - suffixLength)}`;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Get display name for a ledger.
|
|
44
|
-
*
|
|
45
|
-
* @param ledgerId - Ledger ID
|
|
46
|
-
* @returns Display name
|
|
47
|
-
*/
|
|
48
|
-
getLedgerName(ledgerId: string): string {
|
|
49
|
-
const names: Record<string, string> = {
|
|
50
|
-
hedera: 'Hedera',
|
|
51
|
-
xrpl: 'XRPL',
|
|
52
|
-
};
|
|
53
|
-
return names[ledgerId?.toLowerCase()] || ledgerId?.toUpperCase() || 'Unknown';
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Get color for a ledger badge.
|
|
58
|
-
*
|
|
59
|
-
* @param ledgerId - Ledger ID
|
|
60
|
-
* @returns Ionic color name
|
|
61
|
-
*/
|
|
62
|
-
getLedgerColor(ledgerId: string): string {
|
|
63
|
-
const colors: Record<string, string> = {
|
|
64
|
-
hedera: 'success',
|
|
65
|
-
xrpl: 'tertiary',
|
|
66
|
-
};
|
|
67
|
-
return colors[ledgerId?.toLowerCase()] || 'medium';
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Format network display name with proper casing.
|
|
72
|
-
*
|
|
73
|
-
* @param networkId - Network ID (e.g., "hedera:testnet")
|
|
74
|
-
* @returns Formatted network name (e.g., "Testnet")
|
|
75
|
-
*/
|
|
76
|
-
formatNetwork(networkId: string): string {
|
|
77
|
-
const network = this.extractNetwork(networkId);
|
|
78
|
-
const names: Record<string, string> = {
|
|
79
|
-
mainnet: 'Mainnet',
|
|
80
|
-
testnet: 'Testnet',
|
|
81
|
-
devnet: 'Devnet',
|
|
82
|
-
};
|
|
83
|
-
return names[network.toLowerCase()] || network;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Extract network name from full networkId.
|
|
88
|
-
*
|
|
89
|
-
* @param networkId - Full network ID
|
|
90
|
-
* @returns Network name only
|
|
91
|
-
*/
|
|
92
|
-
extractNetwork(networkId?: string): string {
|
|
93
|
-
if (!networkId) return 'unknown';
|
|
94
|
-
const parts = networkId.split(':');
|
|
95
|
-
return parts[parts.length - 1] || networkId;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Get color for a network badge.
|
|
100
|
-
*
|
|
101
|
-
* @param networkId - Network ID
|
|
102
|
-
* @returns Ionic color name
|
|
103
|
-
*/
|
|
104
|
-
getNetworkColor(networkId: string): string {
|
|
105
|
-
const network = this.extractNetwork(networkId).toLowerCase();
|
|
106
|
-
const colors: Record<string, string> = {
|
|
107
|
-
mainnet: 'primary',
|
|
108
|
-
testnet: 'warning',
|
|
109
|
-
devnet: 'secondary',
|
|
110
|
-
};
|
|
111
|
-
return colors[network] || 'medium';
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Get display name for a provider type.
|
|
116
|
-
*
|
|
117
|
-
* @param providerType - Provider type ID
|
|
118
|
-
* @returns Display name
|
|
119
|
-
*/
|
|
120
|
-
getProviderName(providerType: string): string {
|
|
121
|
-
const names: Record<string, string> = {
|
|
122
|
-
'hsuite-native': 'HSuite Native',
|
|
123
|
-
'walletconnect-v2': 'WalletConnect',
|
|
124
|
-
};
|
|
125
|
-
return names[providerType] || providerType;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Get provider display name from provider ID.
|
|
130
|
-
*
|
|
131
|
-
* @param providerId - Provider ID
|
|
132
|
-
* @returns Display name
|
|
133
|
-
*/
|
|
134
|
-
getProviderDisplayName(providerId: string): string {
|
|
135
|
-
const nameMap: Record<string, string> = {
|
|
136
|
-
'walletconnect-v2': 'WalletConnect',
|
|
137
|
-
'hsuite-native': 'HSuite Wallet',
|
|
138
|
-
};
|
|
139
|
-
return nameMap[providerId] || providerId;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Get wallet logo path based on provider type.
|
|
144
|
-
*
|
|
145
|
-
* @param providerType - Provider type
|
|
146
|
-
* @returns Asset path for logo
|
|
147
|
-
*/
|
|
148
|
-
getWalletLogo(providerType: string): string {
|
|
149
|
-
if (providerType === 'walletconnect-v2') {
|
|
150
|
-
return 'assets/wallets/walletconnect.svg';
|
|
151
|
-
}
|
|
152
|
-
return 'assets/wallets/hsuite.svg';
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Get wallet logo for provider name string.
|
|
157
|
-
*
|
|
158
|
-
* @param providerName - Provider display name
|
|
159
|
-
* @returns Asset path for logo
|
|
160
|
-
*/
|
|
161
|
-
getWalletLogoForProvider(providerName: string): string {
|
|
162
|
-
if (providerName === 'WalletConnect') {
|
|
163
|
-
return 'assets/wallets/walletconnect.svg';
|
|
164
|
-
}
|
|
165
|
-
return 'assets/wallets/hsuite.svg';
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Get protocol icon name.
|
|
170
|
-
*
|
|
171
|
-
* @param protocol - Protocol name
|
|
172
|
-
* @returns Ionicon name
|
|
173
|
-
*/
|
|
174
|
-
getProtocolIcon(protocol: string): string {
|
|
175
|
-
return protocol === 'HSuite Native' ? 'link' : 'scan';
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Format account label.
|
|
180
|
-
*
|
|
181
|
-
* @param account - Account object
|
|
182
|
-
* @returns Display label
|
|
183
|
-
*/
|
|
184
|
-
formatAccountLabel(account: any): string {
|
|
185
|
-
return account?.label || 'Account';
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Format full account label with ledger and address.
|
|
190
|
-
*
|
|
191
|
-
* @param account - Account object
|
|
192
|
-
* @returns Full display label
|
|
193
|
-
*/
|
|
194
|
-
formatAccountLabelFull(account: any): string {
|
|
195
|
-
const label = account?.label || 'Account';
|
|
196
|
-
const ledger = this.getLedgerName(account?.ledgerId);
|
|
197
|
-
const address = this.truncateAddress(account?.address);
|
|
198
|
-
return `${label} (${ledger}) - ${address}`;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
@@ -1,227 +0,0 @@
|
|
|
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
|
-
}
|