@hsuite/native-connect-angular 2.1.0 → 2.1.1
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/coverage/coverage-summary.json +25 -21
- package/coverage/index.html +108 -108
- package/coverage/lcov-report/index.html +108 -108
- package/coverage/lcov-report/lib/components/account-selector/account-actions/account-actions.component.ts.html +1 -1
- package/coverage/lcov-report/lib/components/account-selector/account-actions/index.html +1 -1
- package/coverage/lcov-report/lib/components/account-selector/account-filter/account-filter.component.ts.html +1 -1
- package/coverage/lcov-report/lib/components/account-selector/account-filter/index.html +1 -1
- package/coverage/lcov-report/lib/components/account-selector/account-formatting.service.ts.html +13 -19
- package/coverage/lcov-report/lib/components/account-selector/account-grouping.service.ts.html +1 -1
- package/coverage/lcov-report/lib/components/account-selector/account-list/account-list.component.ts.html +1 -1
- package/coverage/lcov-report/lib/components/account-selector/account-list/index.html +1 -1
- package/coverage/lcov-report/lib/components/account-selector/account-selector.component.ts.html +1 -1
- package/coverage/lcov-report/lib/components/account-selector/account-selector.service.ts.html +1 -1
- package/coverage/lcov-report/lib/components/account-selector/index.html +5 -5
- package/coverage/lcov-report/lib/components/wallet-account-display/index.html +1 -1
- package/coverage/lcov-report/lib/components/wallet-account-display/wallet-account-display.component.ts.html +10 -10
- package/coverage/lcov-report/lib/components/wallet-connect-button/index.html +1 -1
- package/coverage/lcov-report/lib/components/wallet-connect-button/wallet-connect-button.component.ts.html +1 -1
- package/coverage/lcov-report/lib/components/wallet-connect-prompt/index.html +1 -1
- package/coverage/lcov-report/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts.html +1 -1
- package/coverage/lcov-report/lib/components/wallet-connected-guard/index.html +1 -1
- package/coverage/lcov-report/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts.html +1 -1
- package/coverage/lcov-report/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts.html +1 -1
- package/coverage/lcov-report/lib/components/wallet-connection-modal/connection-method-step/index.html +1 -1
- package/coverage/lcov-report/lib/components/wallet-connection-modal/index.html +15 -15
- package/coverage/lcov-report/lib/components/wallet-connection-modal/qr-pairing-step/index.html +1 -1
- package/coverage/lcov-report/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts.html +1 -1
- package/coverage/lcov-report/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts.html +84 -36
- package/coverage/lcov-report/lib/components/wallet-session-display/index.html +1 -1
- package/coverage/lcov-report/lib/components/wallet-session-display/wallet-session-display.component.ts.html +1 -1
- package/coverage/lcov-report/lib/components/wallet-transaction-status/index.html +1 -1
- package/coverage/lcov-report/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts.html +1 -1
- package/coverage/lcov-report/lib/directives/index.html +1 -1
- package/coverage/lcov-report/lib/directives/wallet-connected.directive.ts.html +1 -1
- package/coverage/lcov-report/lib/directives/wallet-context.directive.ts.html +1 -1
- package/coverage/lcov-report/lib/directives/wallet-events.directive.ts.html +1 -1
- package/coverage/lcov-report/lib/hsuite-wallet.module.ts.html +1 -1
- package/coverage/lcov-report/lib/index.html +1 -1
- package/coverage/lcov-report/lib/models/connection-config.model.ts.html +1 -1
- package/coverage/lcov-report/lib/models/index.html +7 -7
- package/coverage/lcov-report/lib/models/provider-types.ts.html +11 -5
- package/coverage/lcov-report/lib/providers/base-wallet-provider.ts.html +20 -20
- package/coverage/lcov-report/lib/providers/hsuite-native/channel-client.service.ts.html +639 -636
- package/coverage/lcov-report/lib/providers/hsuite-native/index.html +19 -19
- package/coverage/lcov-report/lib/providers/hsuite-native-provider.ts.html +1 -1
- package/coverage/lcov-report/lib/providers/index.html +18 -18
- package/coverage/lcov-report/lib/providers/p2p-native/index.html +22 -22
- package/coverage/lcov-report/lib/providers/p2p-native/p2p-native.provider.ts.html +993 -993
- package/coverage/lcov-report/lib/providers/p2p-native/p2p-session-manager.ts.html +7 -4
- package/coverage/lcov-report/lib/providers/wallet-error-handler.ts.html +1 -1
- package/coverage/lcov-report/lib/providers/walletconnect/core/index.html +65 -65
- package/coverage/lcov-report/lib/providers/walletconnect/core/session-health.ts.html +240 -240
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-client-manager.ts.html +559 -559
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-provider.ts.html +1108 -1105
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-session-store.ts.html +493 -493
- package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts.html +366 -366
- package/coverage/lcov-report/lib/providers/walletconnect/signers/hedera-signer.ts.html +730 -730
- package/coverage/lcov-report/lib/providers/walletconnect/signers/index.html +43 -43
- package/coverage/lcov-report/lib/providers/walletconnect/signers/signer-factory.ts.html +234 -234
- package/coverage/lcov-report/lib/providers/walletconnect/signers/xrpl-signer.ts.html +650 -650
- package/coverage/lcov-report/lib/services/hsuite-auth.interceptor.ts.html +568 -0
- package/coverage/lcov-report/lib/services/index.html +50 -20
- package/coverage/lcov-report/lib/services/logger.service.ts.html +1 -1
- package/coverage/lcov-report/lib/services/smart-session.service.ts.html +1264 -0
- package/coverage/lcov-report/lib/services/transaction-builders/active-account-source.ts.html +250 -0
- package/coverage/lcov-report/lib/services/transaction-builders/base-transaction-builder.service.ts.html +1 -1
- package/coverage/lcov-report/lib/services/transaction-builders/hedera-amount-utils.ts.html +155 -155
- package/coverage/lcov-report/lib/services/transaction-builders/hedera-transaction-builder.service.ts.html +2156 -2156
- package/coverage/lcov-report/lib/services/transaction-builders/index.html +58 -43
- package/coverage/lcov-report/lib/services/transaction-builders/xrpl-transaction-builder.service.ts.html +1674 -1674
- package/coverage/lcov-report/lib/services/transaction.service.ts.html +4 -4
- package/coverage/lcov-report/lib/services/unified-wallet.service.ts.html +3 -3
- package/coverage/lcov-report/lib/services/wallet-context.service.ts.html +1 -1
- package/coverage/lcov-report/lib/services/wallet-event-bus.service.ts.html +249 -249
- package/coverage/lcov-report/lib/services/wallet-providers.service.ts.html +1 -1
- package/coverage/lcov-report/lib/transports/chrome-extension-transport.ts.html +1 -1
- package/coverage/lcov-report/lib/transports/index.html +1 -1
- package/coverage/lcov-report/lib/utils/index.html +36 -21
- package/coverage/lcov-report/lib/utils/ledger-icons.util.ts.html +254 -161
- package/coverage/lcov-report/lib/utils/ledger-ui-registry.ts.html +676 -0
- package/coverage/lcov.info +8567 -6896
- package/coverage/lib/components/account-selector/account-actions/account-actions.component.ts.html +1 -1
- package/coverage/lib/components/account-selector/account-actions/index.html +1 -1
- package/coverage/lib/components/account-selector/account-filter/account-filter.component.ts.html +1 -1
- package/coverage/lib/components/account-selector/account-filter/index.html +1 -1
- package/coverage/lib/components/account-selector/account-formatting.service.ts.html +13 -19
- package/coverage/lib/components/account-selector/account-grouping.service.ts.html +1 -1
- package/coverage/lib/components/account-selector/account-list/account-list.component.ts.html +1 -1
- package/coverage/lib/components/account-selector/account-list/index.html +1 -1
- package/coverage/lib/components/account-selector/account-selector.component.ts.html +1 -1
- package/coverage/lib/components/account-selector/account-selector.service.ts.html +1 -1
- package/coverage/lib/components/account-selector/index.html +5 -5
- package/coverage/lib/components/wallet-account-display/index.html +1 -1
- package/coverage/lib/components/wallet-account-display/wallet-account-display.component.ts.html +10 -10
- package/coverage/lib/components/wallet-connect-button/index.html +1 -1
- package/coverage/lib/components/wallet-connect-button/wallet-connect-button.component.ts.html +1 -1
- package/coverage/lib/components/wallet-connect-prompt/index.html +1 -1
- package/coverage/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts.html +1 -1
- package/coverage/lib/components/wallet-connected-guard/index.html +1 -1
- package/coverage/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts.html +1 -1
- package/coverage/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts.html +1 -1
- package/coverage/lib/components/wallet-connection-modal/connection-method-step/index.html +1 -1
- package/coverage/lib/components/wallet-connection-modal/index.html +15 -15
- package/coverage/lib/components/wallet-connection-modal/qr-pairing-step/index.html +1 -1
- package/coverage/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts.html +1 -1
- package/coverage/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts.html +84 -36
- package/coverage/lib/components/wallet-session-display/index.html +1 -1
- package/coverage/lib/components/wallet-session-display/wallet-session-display.component.ts.html +1 -1
- package/coverage/lib/components/wallet-transaction-status/index.html +1 -1
- package/coverage/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts.html +1 -1
- package/coverage/lib/directives/index.html +1 -1
- package/coverage/lib/directives/wallet-connected.directive.ts.html +1 -1
- package/coverage/lib/directives/wallet-context.directive.ts.html +1 -1
- package/coverage/lib/directives/wallet-events.directive.ts.html +1 -1
- package/coverage/lib/hsuite-wallet.module.ts.html +1 -1
- package/coverage/lib/index.html +1 -1
- package/coverage/lib/models/connection-config.model.ts.html +1 -1
- package/coverage/lib/models/index.html +7 -7
- package/coverage/lib/models/provider-types.ts.html +11 -5
- package/coverage/lib/providers/base-wallet-provider.ts.html +20 -20
- package/coverage/lib/providers/hsuite-native/channel-client.service.ts.html +639 -636
- package/coverage/lib/providers/hsuite-native/index.html +19 -19
- package/coverage/lib/providers/hsuite-native-provider.ts.html +1 -1
- package/coverage/lib/providers/index.html +18 -18
- package/coverage/lib/providers/p2p-native/index.html +22 -22
- package/coverage/lib/providers/p2p-native/p2p-native.provider.ts.html +993 -993
- package/coverage/lib/providers/p2p-native/p2p-session-manager.ts.html +7 -4
- package/coverage/lib/providers/wallet-error-handler.ts.html +1 -1
- package/coverage/lib/providers/walletconnect/core/index.html +65 -65
- package/coverage/lib/providers/walletconnect/core/session-health.ts.html +240 -240
- package/coverage/lib/providers/walletconnect/core/walletconnect-client-manager.ts.html +559 -559
- package/coverage/lib/providers/walletconnect/core/walletconnect-provider.ts.html +1108 -1105
- package/coverage/lib/providers/walletconnect/core/walletconnect-session-store.ts.html +493 -493
- package/coverage/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts.html +366 -366
- package/coverage/lib/providers/walletconnect/signers/hedera-signer.ts.html +730 -730
- package/coverage/lib/providers/walletconnect/signers/index.html +43 -43
- package/coverage/lib/providers/walletconnect/signers/signer-factory.ts.html +234 -234
- package/coverage/lib/providers/walletconnect/signers/xrpl-signer.ts.html +650 -650
- package/coverage/lib/services/hsuite-auth.interceptor.ts.html +568 -0
- package/coverage/lib/services/index.html +50 -20
- package/coverage/lib/services/logger.service.ts.html +1 -1
- package/coverage/lib/services/smart-session.service.ts.html +1264 -0
- package/coverage/lib/services/transaction-builders/active-account-source.ts.html +250 -0
- package/coverage/lib/services/transaction-builders/base-transaction-builder.service.ts.html +1 -1
- package/coverage/lib/services/transaction-builders/hedera-amount-utils.ts.html +155 -155
- package/coverage/lib/services/transaction-builders/hedera-transaction-builder.service.ts.html +2156 -2156
- package/coverage/lib/services/transaction-builders/index.html +58 -43
- package/coverage/lib/services/transaction-builders/xrpl-transaction-builder.service.ts.html +1674 -1674
- package/coverage/lib/services/transaction.service.ts.html +4 -4
- package/coverage/lib/services/unified-wallet.service.ts.html +3 -3
- package/coverage/lib/services/wallet-context.service.ts.html +1 -1
- package/coverage/lib/services/wallet-event-bus.service.ts.html +249 -249
- package/coverage/lib/services/wallet-providers.service.ts.html +1 -1
- package/coverage/lib/transports/chrome-extension-transport.ts.html +1 -1
- package/coverage/lib/transports/index.html +1 -1
- package/coverage/lib/utils/index.html +36 -21
- package/coverage/lib/utils/ledger-icons.util.ts.html +254 -161
- package/coverage/lib/utils/ledger-ui-registry.ts.html +676 -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 +4 -4
- package/src/index.ts +26 -0
- package/src/lib/components/account-selector/account-formatting.service.ts +8 -10
- package/src/lib/components/wallet-account-display/wallet-account-display.component.ts +9 -9
- package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts +34 -18
- package/src/lib/models/provider-types.ts +3 -1
- package/src/lib/models/unified-account.model.ts +4 -1
- package/src/lib/providers/hsuite-native/channel-client.service.ts +1 -0
- package/src/lib/providers/p2p-native/p2p-session-manager.ts +1 -0
- package/src/lib/providers/walletconnect/core/walletconnect-provider.ts +2 -1
- package/src/lib/services/hsuite-auth.interceptor.ts +159 -0
- package/src/lib/services/smart-session.service.ts +378 -0
- package/src/lib/services/transaction-builders/active-account-source.spec.ts +75 -0
- package/src/lib/services/transaction-builders/active-account-source.ts +55 -0
- package/src/lib/services/transaction-builders/hedera-transaction-builder.service.ts +4 -4
- package/src/lib/services/transaction-builders/index.ts +1 -0
- package/src/lib/services/transaction.service.ts +7 -3
- package/src/lib/services/unified-wallet.service.spec.ts +1 -1
- package/src/lib/services/unified-wallet.service.ts +2 -2
- package/src/lib/utils/index.ts +1 -0
- package/src/lib/utils/ledger-icons.util.ts +61 -30
- package/src/lib/utils/ledger-ui-registry.ts +197 -0
|
@@ -8,70 +8,101 @@
|
|
|
8
8
|
* visit https://hsuite.finance/licensing
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import { LedgerUIRegistry } from './ledger-ui-registry';
|
|
12
|
+
|
|
11
13
|
/**
|
|
12
14
|
* @module LedgerIconsUtil
|
|
13
|
-
* Utilities for getting default icon URLs for ledgers and their native tokens.
|
|
14
15
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
16
|
+
* Backward-compatible facade over {@link LedgerUIRegistry}.
|
|
17
|
+
*
|
|
18
|
+
* Every value here is **derived from the registry** so there is exactly one
|
|
19
|
+
* source of truth for ledger presentation. New code should prefer
|
|
20
|
+
* {@link LedgerUIRegistry} directly (it is open/extensible and richer); these
|
|
21
|
+
* getters and constant maps remain for the existing public API surface.
|
|
22
|
+
*
|
|
23
|
+
* The constant maps below are snapshots taken at module load — they include the
|
|
24
|
+
* built-in ledgers (Hedera, XRPL). Ledgers registered later at runtime are
|
|
25
|
+
* always reachable through the getters and {@link LedgerUIRegistry}, but will
|
|
26
|
+
* not retroactively appear in these legacy snapshots; prefer the registry when
|
|
27
|
+
* extensibility matters.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Default raster icon URLs for native ledger tokens, keyed by ledger id.
|
|
32
|
+
* Derived from {@link LedgerUiDescriptor.tokenIconUrl}.
|
|
17
33
|
*/
|
|
34
|
+
export const DEFAULT_LEDGER_ICONS: Record<string, string> = Object.fromEntries(
|
|
35
|
+
LedgerUIRegistry.list()
|
|
36
|
+
.filter((descriptor) => descriptor.tokenIconUrl)
|
|
37
|
+
.map((descriptor) => [descriptor.id, descriptor.tokenIconUrl as string]),
|
|
38
|
+
);
|
|
18
39
|
|
|
19
40
|
/**
|
|
20
|
-
*
|
|
41
|
+
* Brand colours (hex) for each ledger, keyed by ledger id.
|
|
42
|
+
* Derived from {@link LedgerUiDescriptor.brandColor}.
|
|
21
43
|
*/
|
|
22
|
-
export const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
44
|
+
export const LEDGER_COLORS: Record<string, string> = Object.fromEntries(
|
|
45
|
+
LedgerUIRegistry.list().map((descriptor) => [descriptor.id, descriptor.brandColor]),
|
|
46
|
+
);
|
|
26
47
|
|
|
27
48
|
/**
|
|
28
|
-
*
|
|
49
|
+
* Display names for each ledger, keyed by ledger id.
|
|
50
|
+
* Derived from {@link LedgerUiDescriptor.displayName}.
|
|
29
51
|
*/
|
|
30
|
-
export const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
52
|
+
export const LEDGER_NAMES: Record<string, string> = Object.fromEntries(
|
|
53
|
+
LedgerUIRegistry.list().map((descriptor) => [descriptor.id, descriptor.displayName]),
|
|
54
|
+
);
|
|
34
55
|
|
|
35
56
|
/**
|
|
36
|
-
*
|
|
57
|
+
* Ionicons names under which each ledger's brand SVG is registered, keyed by
|
|
58
|
+
* ledger id. Reference these from `<ion-icon [name]="...">`.
|
|
59
|
+
* Derived from {@link LedgerUiDescriptor.iconName}.
|
|
37
60
|
*/
|
|
38
|
-
export const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
61
|
+
export const LEDGER_ICON_NAMES: Record<string, string> = Object.fromEntries(
|
|
62
|
+
LedgerUIRegistry.list().map((descriptor) => [descriptor.id, descriptor.iconName]),
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Register the ledger brand SVGs with Ionicons so they can be referenced by name
|
|
67
|
+
* (see {@link LEDGER_ICON_NAMES}). Idempotent; safe to call from multiple
|
|
68
|
+
* consumers. Delegates to {@link LedgerUIRegistry.registerIcons}.
|
|
69
|
+
*/
|
|
70
|
+
export function registerLedgerIcons(): void {
|
|
71
|
+
LedgerUIRegistry.registerIcons();
|
|
72
|
+
}
|
|
42
73
|
|
|
43
74
|
/**
|
|
44
|
-
* Get the default icon URL for a ledger
|
|
45
|
-
* @param ledgerId - Ledger identifier (e.g
|
|
46
|
-
* @returns Icon URL or empty string if
|
|
75
|
+
* Get the default raster token icon URL for a ledger.
|
|
76
|
+
* @param ledgerId - Ledger identifier (e.g. `'hedera'`, `'xrpl'`)
|
|
77
|
+
* @returns Icon URL, or empty string if the ledger has none.
|
|
47
78
|
*/
|
|
48
79
|
export function getLedgerIcon(ledgerId: string): string {
|
|
49
|
-
return
|
|
80
|
+
return LedgerUIRegistry.get(ledgerId?.toLowerCase())?.tokenIconUrl ?? '';
|
|
50
81
|
}
|
|
51
82
|
|
|
52
83
|
/**
|
|
53
|
-
* Get the brand
|
|
84
|
+
* Get the brand colour (hex) for a ledger.
|
|
54
85
|
* @param ledgerId - Ledger identifier
|
|
55
|
-
* @returns Hex
|
|
86
|
+
* @returns Hex colour string, or the Ionic primary CSS variable as fallback.
|
|
56
87
|
*/
|
|
57
88
|
export function getLedgerColor(ledgerId: string): string {
|
|
58
|
-
return
|
|
89
|
+
return LedgerUIRegistry.get(ledgerId?.toLowerCase())?.brandColor ?? 'var(--ion-color-primary)';
|
|
59
90
|
}
|
|
60
91
|
|
|
61
92
|
/**
|
|
62
|
-
* Get the display name for a ledger
|
|
93
|
+
* Get the display name for a ledger.
|
|
63
94
|
* @param ledgerId - Ledger identifier
|
|
64
|
-
* @returns Human-readable ledger name
|
|
95
|
+
* @returns Human-readable ledger name, or the raw id if unknown.
|
|
65
96
|
*/
|
|
66
97
|
export function getLedgerName(ledgerId: string): string {
|
|
67
|
-
return
|
|
98
|
+
return LedgerUIRegistry.get(ledgerId?.toLowerCase())?.displayName ?? ledgerId;
|
|
68
99
|
}
|
|
69
100
|
|
|
70
101
|
/**
|
|
71
|
-
* Get token icon URL, falling back to ledger default if not provided
|
|
102
|
+
* Get a token icon URL, falling back to the ledger default if not provided.
|
|
72
103
|
* @param tokenIconUrl - Specific token icon URL (optional)
|
|
73
104
|
* @param ledgerId - Ledger identifier for fallback
|
|
74
|
-
* @returns Icon URL or empty string
|
|
105
|
+
* @returns Icon URL, or empty string.
|
|
75
106
|
*/
|
|
76
107
|
export function getTokenIcon(tokenIconUrl: string | undefined, ledgerId: string): string {
|
|
77
108
|
return tokenIconUrl || getLedgerIcon(ledgerId);
|
|
@@ -0,0 +1,197 @@
|
|
|
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
|
+
import type { LedgerId } from '@hsuite/native-connect-types';
|
|
12
|
+
import { addIcons } from 'ionicons';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @module LedgerUiRegistry
|
|
16
|
+
*
|
|
17
|
+
* Single source of truth for **how a ledger is presented** in the Angular SDK —
|
|
18
|
+
* its display name, native currency, brand colours, and brand icon.
|
|
19
|
+
*
|
|
20
|
+
* ## Why a registry
|
|
21
|
+
*
|
|
22
|
+
* The core SDK keys everything off the canonical, open {@link LedgerId} type
|
|
23
|
+
* (`z.string().min(1)` in `@hsuite/native-connect-types`) and discovers chains
|
|
24
|
+
* dynamically via `WalletCore.registerLedger(adapter)` / `LedgerRegistry`. This
|
|
25
|
+
* registry mirrors that pattern for the **presentation layer**: ledgers are
|
|
26
|
+
* registered, not hard-coded into closed `'hedera' | 'xrpl'` maps. Adding a new
|
|
27
|
+
* chain is a single {@link LedgerUIRegistry.register} call — no union to widen,
|
|
28
|
+
* no scattered `Record<>` literals to keep in sync.
|
|
29
|
+
*
|
|
30
|
+
* Presentation lives in the presentation package (this Angular SDK) so the core
|
|
31
|
+
* SDK stays headless: the descriptor carries the framework-agnostic data plus
|
|
32
|
+
* the Ionic-specific icon binding ({@link LedgerUiDescriptor.iconName} /
|
|
33
|
+
* {@link LedgerUiDescriptor.iconSvg}) that `<ion-icon>` renders.
|
|
34
|
+
*
|
|
35
|
+
* @see {@link LedgerUiDescriptor} for the per-ledger contract.
|
|
36
|
+
* @see `docs/guides/adding-a-new-chain.md` for the end-to-end "add a chain" flow.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Presentation contract for one ledger.
|
|
41
|
+
*
|
|
42
|
+
* Keyed by the canonical {@link LedgerId} (open `string`) so the registry is
|
|
43
|
+
* extensible to any number of chains. Built-in ledgers are registered at module
|
|
44
|
+
* load; first-party chains add a descriptor here, third-party/plugin chains call
|
|
45
|
+
* {@link LedgerUIRegistry.register} at runtime.
|
|
46
|
+
*/
|
|
47
|
+
export interface LedgerUiDescriptor {
|
|
48
|
+
/** Canonical ledger identity, e.g. `'hedera'`, `'xrpl'` (see {@link LedgerId}). */
|
|
49
|
+
readonly id: LedgerId;
|
|
50
|
+
/** Full human-readable name, e.g. `'Hedera'`, `'XRP Ledger'`. */
|
|
51
|
+
readonly displayName: string;
|
|
52
|
+
/** Compact name for badges/dense surfaces, e.g. `'Hedera'`, `'XRPL'`. */
|
|
53
|
+
readonly shortName: string;
|
|
54
|
+
/** Native currency ticker, e.g. `'HBAR'`, `'XRP'`. */
|
|
55
|
+
readonly currencySymbol: string;
|
|
56
|
+
/** Native currency decimal places, e.g. `8` (Hedera), `6` (XRPL). */
|
|
57
|
+
readonly currencyDecimals: number;
|
|
58
|
+
/** Brand colour as a hex string, used for CSS accents, e.g. `'#8259ef'`. */
|
|
59
|
+
readonly brandColor: string;
|
|
60
|
+
/** Ionic semantic colour name for `<ion-badge color="...">`, e.g. `'success'`. */
|
|
61
|
+
readonly badgeColor: string;
|
|
62
|
+
/**
|
|
63
|
+
* Ionicons name under which {@link iconSvg} is registered, e.g.
|
|
64
|
+
* `'ledger-hedera'`. Reference it from `<ion-icon [name]="...">`. The SVG is
|
|
65
|
+
* flushed to Ionicons by {@link LedgerUIRegistry.registerIcons}.
|
|
66
|
+
*/
|
|
67
|
+
readonly iconName: string;
|
|
68
|
+
/**
|
|
69
|
+
* Self-contained brand SVG markup. Inlined (rather than shipped as an asset
|
|
70
|
+
* file) so the packaged library needs no runtime asset pipeline or external
|
|
71
|
+
* CDN. `currentColor` fills inherit the host `<ion-icon>` colour; explicit
|
|
72
|
+
* fills are preserved.
|
|
73
|
+
*/
|
|
74
|
+
readonly iconSvg: string;
|
|
75
|
+
/**
|
|
76
|
+
* Optional CDN URL for a raster icon of the native token, used as a fallback
|
|
77
|
+
* when an inline brand SVG is not the right surface (e.g. token lists).
|
|
78
|
+
*/
|
|
79
|
+
readonly tokenIconUrl?: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Open, string-keyed registry of {@link LedgerUiDescriptor}s.
|
|
84
|
+
*
|
|
85
|
+
* A static registry (like `AccountLabelManager`) because ledger presentation is
|
|
86
|
+
* process-global — Ionicons' own icon table is global too. Mirrors the core
|
|
87
|
+
* `LedgerRegistry` shape (`register` / `get` / `has` / `list`) so the two read
|
|
88
|
+
* the same way.
|
|
89
|
+
*/
|
|
90
|
+
export class LedgerUIRegistry {
|
|
91
|
+
private static readonly descriptors = new Map<LedgerId, LedgerUiDescriptor>();
|
|
92
|
+
|
|
93
|
+
/** Whether {@link registerIcons} has already flushed SVGs to Ionicons. */
|
|
94
|
+
private static iconsFlushed = false;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Register (or replace) the presentation descriptor for a ledger.
|
|
98
|
+
*
|
|
99
|
+
* If icons were already flushed to Ionicons (i.e. {@link registerIcons} ran),
|
|
100
|
+
* the new ledger's SVG is registered immediately so late registrations still
|
|
101
|
+
* render.
|
|
102
|
+
*
|
|
103
|
+
* @param descriptor - The ledger's presentation contract.
|
|
104
|
+
*/
|
|
105
|
+
static register(descriptor: LedgerUiDescriptor): void {
|
|
106
|
+
LedgerUIRegistry.descriptors.set(descriptor.id, descriptor);
|
|
107
|
+
if (LedgerUIRegistry.iconsFlushed) {
|
|
108
|
+
addIcons({ [descriptor.iconName]: descriptor.iconSvg });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Look up a ledger's presentation descriptor.
|
|
114
|
+
*
|
|
115
|
+
* @param ledgerId - Canonical ledger id (case-sensitive; callers normalise).
|
|
116
|
+
* @returns The descriptor, or `undefined` if the ledger is not registered.
|
|
117
|
+
*/
|
|
118
|
+
static get(ledgerId: LedgerId): LedgerUiDescriptor | undefined {
|
|
119
|
+
return LedgerUIRegistry.descriptors.get(ledgerId);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @param ledgerId - Canonical ledger id.
|
|
124
|
+
* @returns `true` if a descriptor is registered for `ledgerId`.
|
|
125
|
+
*/
|
|
126
|
+
static has(ledgerId: LedgerId): boolean {
|
|
127
|
+
return LedgerUIRegistry.descriptors.has(ledgerId);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @returns All registered descriptors, in registration order.
|
|
132
|
+
*/
|
|
133
|
+
static list(): LedgerUiDescriptor[] {
|
|
134
|
+
return Array.from(LedgerUIRegistry.descriptors.values());
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Flush every registered ledger's brand SVG to Ionicons so the icons resolve
|
|
139
|
+
* by name from `<ion-icon>`. Idempotent and cheap to call repeatedly — call it
|
|
140
|
+
* before the icons are first rendered (e.g. from a component constructor or
|
|
141
|
+
* once at app bootstrap).
|
|
142
|
+
*/
|
|
143
|
+
static registerIcons(): void {
|
|
144
|
+
if (LedgerUIRegistry.iconsFlushed) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const icons: Record<string, string> = {};
|
|
149
|
+
for (const descriptor of LedgerUIRegistry.descriptors.values()) {
|
|
150
|
+
icons[descriptor.iconName] = descriptor.iconSvg;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
addIcons(icons);
|
|
154
|
+
LedgerUIRegistry.iconsFlushed = true;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// ---------------------------------------------------------------------------
|
|
159
|
+
// Built-in ledgers
|
|
160
|
+
//
|
|
161
|
+
// The only place the first-party ledger set is enumerated. Adding a new
|
|
162
|
+
// first-party chain is one more `register(...)` here; everything downstream
|
|
163
|
+
// (icons, colours, names, the connection modal's "Choose Blockchain" step)
|
|
164
|
+
// derives from these descriptors.
|
|
165
|
+
// ---------------------------------------------------------------------------
|
|
166
|
+
|
|
167
|
+
LedgerUIRegistry.register({
|
|
168
|
+
id: 'hedera',
|
|
169
|
+
displayName: 'Hedera',
|
|
170
|
+
shortName: 'Hedera',
|
|
171
|
+
currencySymbol: 'HBAR',
|
|
172
|
+
currencyDecimals: 8,
|
|
173
|
+
brandColor: '#8259ef',
|
|
174
|
+
badgeColor: 'success',
|
|
175
|
+
iconName: 'ledger-hedera',
|
|
176
|
+
// Brand disc themed with `brandColor` (#8259ef) + a white "H" so the mark stays
|
|
177
|
+
// brand-correct and legible on any background (incl. the dark modal card).
|
|
178
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><g fill="none"><path fill="#8259ef" d="M12 4a8 8 0 1 0 0 16a8 8 0 0 0 0-16"/><path fill="#fff" d="M15.252 15.46h-1.016V13.3H9.764v2.16H8.748V8.456h1.016v2.108h4.472V8.456h1.016zm-5.44-2.968h4.472v-1.116H9.812z"/></g></svg>`,
|
|
179
|
+
tokenIconUrl: 'https://assets.coingecko.com/coins/images/3688/standard/hbar.png?1696504364',
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
LedgerUIRegistry.register({
|
|
183
|
+
id: 'xrpl',
|
|
184
|
+
displayName: 'XRP Ledger',
|
|
185
|
+
shortName: 'XRPL',
|
|
186
|
+
currencySymbol: 'XRP',
|
|
187
|
+
currencyDecimals: 6,
|
|
188
|
+
brandColor: '#23292f',
|
|
189
|
+
badgeColor: 'tertiary',
|
|
190
|
+
iconName: 'ledger-xrpl',
|
|
191
|
+
// `currentColor` so the mark adopts the host `<ion-icon>` colour — the XRPL
|
|
192
|
+
// brand black (#23292f) is invisible on the dark modal card, so the icon
|
|
193
|
+
// inherits the theme colour while `brandColor` stays the canonical accent.
|
|
194
|
+
iconSvg: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M21.778 4h-2.837l-4.49 4.371a3.52 3.52 0 0 1-2.451.99a3.52 3.52 0 0 1-2.452-.99L5.062 4h-2.84L8.13 9.754c2.14 2.083 5.607 2.083 7.745 0zM2.223 20H5.05l4.508-4.385a3.5 3.5 0 0 1 2.443-.985c.914 0 1.792.354 2.443.985L18.952 20h2.826l-5.92-5.761c-2.132-2.073-5.585-2.073-7.715 0z"/></svg>`,
|
|
195
|
+
tokenIconUrl:
|
|
196
|
+
'https://assets.coingecko.com/coins/images/44/standard/xrp-symbol-white-128.png?1696501442',
|
|
197
|
+
});
|