@hsuite/native-connect-angular 1.0.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.
Files changed (188) hide show
  1. package/coverage/coverage-summary.json +53 -49
  2. package/coverage/index.html +100 -100
  3. package/coverage/lcov-report/index.html +100 -100
  4. package/coverage/lcov-report/lib/components/account-selector/account-actions/account-actions.component.ts.html +1 -1
  5. package/coverage/lcov-report/lib/components/account-selector/account-actions/index.html +1 -1
  6. package/coverage/lcov-report/lib/components/account-selector/account-filter/account-filter.component.ts.html +1 -1
  7. package/coverage/lcov-report/lib/components/account-selector/account-filter/index.html +1 -1
  8. package/coverage/lcov-report/lib/components/account-selector/account-formatting.service.ts.html +13 -19
  9. package/coverage/lcov-report/lib/components/account-selector/account-grouping.service.ts.html +1 -1
  10. package/coverage/lcov-report/lib/components/account-selector/account-list/account-list.component.ts.html +1 -1
  11. package/coverage/lcov-report/lib/components/account-selector/account-list/index.html +1 -1
  12. package/coverage/lcov-report/lib/components/account-selector/account-selector.component.ts.html +1 -1
  13. package/coverage/lcov-report/lib/components/account-selector/account-selector.service.ts.html +1 -1
  14. package/coverage/lcov-report/lib/components/account-selector/index.html +5 -5
  15. package/coverage/lcov-report/lib/components/wallet-account-display/index.html +1 -1
  16. package/coverage/lcov-report/lib/components/wallet-account-display/wallet-account-display.component.ts.html +10 -10
  17. package/coverage/lcov-report/lib/components/wallet-connect-button/index.html +21 -21
  18. package/coverage/lcov-report/lib/components/wallet-connect-button/wallet-connect-button.component.ts.html +475 -451
  19. package/coverage/lcov-report/lib/components/wallet-connect-prompt/index.html +1 -1
  20. package/coverage/lcov-report/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts.html +1 -1
  21. package/coverage/lcov-report/lib/components/wallet-connected-guard/index.html +1 -1
  22. package/coverage/lcov-report/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts.html +1 -1
  23. package/coverage/lcov-report/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts.html +148 -148
  24. package/coverage/lcov-report/lib/components/wallet-connection-modal/connection-method-step/index.html +17 -17
  25. package/coverage/lcov-report/lib/components/wallet-connection-modal/index.html +21 -21
  26. package/coverage/lcov-report/lib/components/wallet-connection-modal/qr-pairing-step/index.html +17 -17
  27. package/coverage/lcov-report/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts.html +838 -838
  28. package/coverage/lcov-report/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts.html +1230 -987
  29. package/coverage/lcov-report/lib/components/wallet-session-display/index.html +1 -1
  30. package/coverage/lcov-report/lib/components/wallet-session-display/wallet-session-display.component.ts.html +1 -1
  31. package/coverage/lcov-report/lib/components/wallet-transaction-status/index.html +1 -1
  32. package/coverage/lcov-report/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts.html +1 -1
  33. package/coverage/lcov-report/lib/directives/index.html +1 -1
  34. package/coverage/lcov-report/lib/directives/wallet-connected.directive.ts.html +1 -1
  35. package/coverage/lcov-report/lib/directives/wallet-context.directive.ts.html +1 -1
  36. package/coverage/lcov-report/lib/directives/wallet-events.directive.ts.html +1 -1
  37. package/coverage/lcov-report/lib/hsuite-wallet.module.ts.html +1 -1
  38. package/coverage/lcov-report/lib/index.html +1 -1
  39. package/coverage/lcov-report/lib/models/connection-config.model.ts.html +1 -1
  40. package/coverage/lcov-report/lib/models/index.html +7 -7
  41. package/coverage/lcov-report/lib/models/provider-types.ts.html +11 -5
  42. package/coverage/lcov-report/lib/providers/base-wallet-provider.ts.html +1 -1
  43. package/coverage/lcov-report/lib/providers/hsuite-native/channel-client.service.ts.html +9 -6
  44. package/coverage/lcov-report/lib/providers/hsuite-native/index.html +10 -10
  45. package/coverage/lcov-report/lib/providers/hsuite-native-provider.ts.html +1 -1
  46. package/coverage/lcov-report/lib/providers/index.html +1 -1
  47. package/coverage/lcov-report/lib/providers/p2p-native/index.html +7 -7
  48. package/coverage/lcov-report/lib/providers/p2p-native/p2p-native.provider.ts.html +1 -1
  49. package/coverage/lcov-report/lib/providers/p2p-native/p2p-session-manager.ts.html +7 -4
  50. package/coverage/lcov-report/lib/providers/wallet-error-handler.ts.html +1 -1
  51. package/coverage/lcov-report/lib/providers/walletconnect/core/index.html +10 -10
  52. package/coverage/lcov-report/lib/providers/walletconnect/core/session-health.ts.html +1 -1
  53. package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-client-manager.ts.html +1 -1
  54. package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-provider.ts.html +10 -7
  55. package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-session-store.ts.html +1 -1
  56. package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts.html +1 -1
  57. package/coverage/lcov-report/lib/providers/walletconnect/signers/hedera-signer.ts.html +1 -1
  58. package/coverage/lcov-report/lib/providers/walletconnect/signers/index.html +1 -1
  59. package/coverage/lcov-report/lib/providers/walletconnect/signers/signer-factory.ts.html +49 -49
  60. package/coverage/lcov-report/lib/providers/walletconnect/signers/xrpl-signer.ts.html +1 -1
  61. package/coverage/lcov-report/lib/services/hsuite-auth.interceptor.ts.html +568 -0
  62. package/coverage/lcov-report/lib/services/index.html +50 -20
  63. package/coverage/lcov-report/lib/services/logger.service.ts.html +4 -4
  64. package/coverage/lcov-report/lib/services/smart-session.service.ts.html +1264 -0
  65. package/coverage/lcov-report/lib/services/transaction-builders/active-account-source.ts.html +250 -0
  66. package/coverage/lcov-report/lib/services/transaction-builders/base-transaction-builder.service.ts.html +1 -1
  67. package/coverage/lcov-report/lib/services/transaction-builders/hedera-amount-utils.ts.html +1 -1
  68. package/coverage/lcov-report/lib/services/transaction-builders/hedera-transaction-builder.service.ts.html +318 -318
  69. package/coverage/lcov-report/lib/services/transaction-builders/index.html +24 -9
  70. package/coverage/lcov-report/lib/services/transaction-builders/xrpl-transaction-builder.service.ts.html +1 -1
  71. package/coverage/lcov-report/lib/services/transaction.service.ts.html +7 -10
  72. package/coverage/lcov-report/lib/services/unified-wallet.service.ts.html +9 -12
  73. package/coverage/lcov-report/lib/services/wallet-context.service.ts.html +1 -1
  74. package/coverage/lcov-report/lib/services/wallet-event-bus.service.ts.html +1 -1
  75. package/coverage/lcov-report/lib/services/wallet-providers.service.ts.html +4 -7
  76. package/coverage/lcov-report/lib/transports/chrome-extension-transport.ts.html +1 -1
  77. package/coverage/lcov-report/lib/transports/index.html +1 -1
  78. package/coverage/lcov-report/lib/utils/index.html +36 -21
  79. package/coverage/lcov-report/lib/utils/ledger-icons.util.ts.html +254 -161
  80. package/coverage/lcov-report/lib/utils/ledger-ui-registry.ts.html +676 -0
  81. package/coverage/lcov.info +3236 -2122
  82. package/coverage/lib/components/account-selector/account-actions/account-actions.component.ts.html +1 -1
  83. package/coverage/lib/components/account-selector/account-actions/index.html +1 -1
  84. package/coverage/lib/components/account-selector/account-filter/account-filter.component.ts.html +1 -1
  85. package/coverage/lib/components/account-selector/account-filter/index.html +1 -1
  86. package/coverage/lib/components/account-selector/account-formatting.service.ts.html +13 -19
  87. package/coverage/lib/components/account-selector/account-grouping.service.ts.html +1 -1
  88. package/coverage/lib/components/account-selector/account-list/account-list.component.ts.html +1 -1
  89. package/coverage/lib/components/account-selector/account-list/index.html +1 -1
  90. package/coverage/lib/components/account-selector/account-selector.component.ts.html +1 -1
  91. package/coverage/lib/components/account-selector/account-selector.service.ts.html +1 -1
  92. package/coverage/lib/components/account-selector/index.html +5 -5
  93. package/coverage/lib/components/wallet-account-display/index.html +1 -1
  94. package/coverage/lib/components/wallet-account-display/wallet-account-display.component.ts.html +10 -10
  95. package/coverage/lib/components/wallet-connect-button/index.html +21 -21
  96. package/coverage/lib/components/wallet-connect-button/wallet-connect-button.component.ts.html +475 -451
  97. package/coverage/lib/components/wallet-connect-prompt/index.html +1 -1
  98. package/coverage/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts.html +1 -1
  99. package/coverage/lib/components/wallet-connected-guard/index.html +1 -1
  100. package/coverage/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts.html +1 -1
  101. package/coverage/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts.html +148 -148
  102. package/coverage/lib/components/wallet-connection-modal/connection-method-step/index.html +17 -17
  103. package/coverage/lib/components/wallet-connection-modal/index.html +21 -21
  104. package/coverage/lib/components/wallet-connection-modal/qr-pairing-step/index.html +17 -17
  105. package/coverage/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts.html +838 -838
  106. package/coverage/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts.html +1230 -987
  107. package/coverage/lib/components/wallet-session-display/index.html +1 -1
  108. package/coverage/lib/components/wallet-session-display/wallet-session-display.component.ts.html +1 -1
  109. package/coverage/lib/components/wallet-transaction-status/index.html +1 -1
  110. package/coverage/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts.html +1 -1
  111. package/coverage/lib/directives/index.html +1 -1
  112. package/coverage/lib/directives/wallet-connected.directive.ts.html +1 -1
  113. package/coverage/lib/directives/wallet-context.directive.ts.html +1 -1
  114. package/coverage/lib/directives/wallet-events.directive.ts.html +1 -1
  115. package/coverage/lib/hsuite-wallet.module.ts.html +1 -1
  116. package/coverage/lib/index.html +1 -1
  117. package/coverage/lib/models/connection-config.model.ts.html +1 -1
  118. package/coverage/lib/models/index.html +7 -7
  119. package/coverage/lib/models/provider-types.ts.html +11 -5
  120. package/coverage/lib/providers/base-wallet-provider.ts.html +1 -1
  121. package/coverage/lib/providers/hsuite-native/channel-client.service.ts.html +9 -6
  122. package/coverage/lib/providers/hsuite-native/index.html +10 -10
  123. package/coverage/lib/providers/hsuite-native-provider.ts.html +1 -1
  124. package/coverage/lib/providers/index.html +1 -1
  125. package/coverage/lib/providers/p2p-native/index.html +7 -7
  126. package/coverage/lib/providers/p2p-native/p2p-native.provider.ts.html +1 -1
  127. package/coverage/lib/providers/p2p-native/p2p-session-manager.ts.html +7 -4
  128. package/coverage/lib/providers/wallet-error-handler.ts.html +1 -1
  129. package/coverage/lib/providers/walletconnect/core/index.html +10 -10
  130. package/coverage/lib/providers/walletconnect/core/session-health.ts.html +1 -1
  131. package/coverage/lib/providers/walletconnect/core/walletconnect-client-manager.ts.html +1 -1
  132. package/coverage/lib/providers/walletconnect/core/walletconnect-provider.ts.html +10 -7
  133. package/coverage/lib/providers/walletconnect/core/walletconnect-session-store.ts.html +1 -1
  134. package/coverage/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts.html +1 -1
  135. package/coverage/lib/providers/walletconnect/signers/hedera-signer.ts.html +1 -1
  136. package/coverage/lib/providers/walletconnect/signers/index.html +1 -1
  137. package/coverage/lib/providers/walletconnect/signers/signer-factory.ts.html +49 -49
  138. package/coverage/lib/providers/walletconnect/signers/xrpl-signer.ts.html +1 -1
  139. package/coverage/lib/services/hsuite-auth.interceptor.ts.html +568 -0
  140. package/coverage/lib/services/index.html +50 -20
  141. package/coverage/lib/services/logger.service.ts.html +4 -4
  142. package/coverage/lib/services/smart-session.service.ts.html +1264 -0
  143. package/coverage/lib/services/transaction-builders/active-account-source.ts.html +250 -0
  144. package/coverage/lib/services/transaction-builders/base-transaction-builder.service.ts.html +1 -1
  145. package/coverage/lib/services/transaction-builders/hedera-amount-utils.ts.html +1 -1
  146. package/coverage/lib/services/transaction-builders/hedera-transaction-builder.service.ts.html +318 -318
  147. package/coverage/lib/services/transaction-builders/index.html +24 -9
  148. package/coverage/lib/services/transaction-builders/xrpl-transaction-builder.service.ts.html +1 -1
  149. package/coverage/lib/services/transaction.service.ts.html +7 -10
  150. package/coverage/lib/services/unified-wallet.service.ts.html +9 -12
  151. package/coverage/lib/services/wallet-context.service.ts.html +1 -1
  152. package/coverage/lib/services/wallet-event-bus.service.ts.html +1 -1
  153. package/coverage/lib/services/wallet-providers.service.ts.html +4 -7
  154. package/coverage/lib/transports/chrome-extension-transport.ts.html +1 -1
  155. package/coverage/lib/transports/index.html +1 -1
  156. package/coverage/lib/utils/index.html +36 -21
  157. package/coverage/lib/utils/ledger-icons.util.ts.html +254 -161
  158. package/coverage/lib/utils/ledger-ui-registry.ts.html +676 -0
  159. package/dist/fesm2022/hsuite-native-connect-angular.mjs +939 -328
  160. package/dist/fesm2022/hsuite-native-connect-angular.mjs.map +1 -1
  161. package/dist/index.d.ts +489 -33
  162. package/package.json +4 -4
  163. package/src/index.ts +26 -0
  164. package/src/lib/components/account-selector/account-formatting.service.ts +8 -10
  165. package/src/lib/components/wallet-account-display/wallet-account-display.component.ts +9 -9
  166. package/src/lib/components/wallet-connect-button/wallet-connect-button.component.spec.ts +89 -0
  167. package/src/lib/components/wallet-connect-button/wallet-connect-button.component.ts +8 -0
  168. package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.html +1 -6
  169. package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.spec.ts +173 -0
  170. package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts +118 -37
  171. package/src/lib/models/provider-types.ts +3 -1
  172. package/src/lib/models/unified-account.model.ts +4 -1
  173. package/src/lib/providers/hsuite-native/channel-client.service.ts +1 -0
  174. package/src/lib/providers/p2p-native/p2p-session-manager.ts +1 -0
  175. package/src/lib/providers/walletconnect/core/walletconnect-provider.ts +2 -1
  176. package/src/lib/services/hsuite-auth.interceptor.ts +159 -0
  177. package/src/lib/services/smart-session.service.ts +378 -0
  178. package/src/lib/services/transaction-builders/active-account-source.spec.ts +75 -0
  179. package/src/lib/services/transaction-builders/active-account-source.ts +55 -0
  180. package/src/lib/services/transaction-builders/hedera-transaction-builder.service.ts +4 -4
  181. package/src/lib/services/transaction-builders/index.ts +1 -0
  182. package/src/lib/services/transaction.service.ts +7 -4
  183. package/src/lib/services/unified-wallet.service.spec.ts +1 -1
  184. package/src/lib/services/unified-wallet.service.ts +2 -3
  185. package/src/lib/services/wallet-providers.service.ts +0 -1
  186. package/src/lib/utils/index.ts +1 -0
  187. package/src/lib/utils/ledger-icons.util.ts +61 -30
  188. 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
- * Uses CoinGecko's public CDN for reliable, high-quality token icons.
16
- * Shared across wallet and dApp for consistency.
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
- * Default icon URLs for native ledger tokens
41
+ * Brand colours (hex) for each ledger, keyed by ledger id.
42
+ * Derived from {@link LedgerUiDescriptor.brandColor}.
21
43
  */
22
- export const DEFAULT_LEDGER_ICONS: Record<string, string> = {
23
- hedera: 'https://assets.coingecko.com/coins/images/3688/standard/hbar.png?1696504364',
24
- xrpl: 'https://assets.coingecko.com/coins/images/44/standard/xrp-symbol-white-128.png?1696501442',
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
- * Brand colors for each ledger
49
+ * Display names for each ledger, keyed by ledger id.
50
+ * Derived from {@link LedgerUiDescriptor.displayName}.
29
51
  */
30
- export const LEDGER_COLORS: Record<string, string> = {
31
- hedera: '#8259ef',
32
- xrpl: '#23292f',
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
- * Display names for each ledger
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 LEDGER_NAMES: Record<string, string> = {
39
- hedera: 'Hedera',
40
- xrpl: 'XRP Ledger',
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., 'hedera', 'xrpl')
46
- * @returns Icon URL or empty string if not found
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 DEFAULT_LEDGER_ICONS[ledgerId?.toLowerCase()] || '';
80
+ return LedgerUIRegistry.get(ledgerId?.toLowerCase())?.tokenIconUrl ?? '';
50
81
  }
51
82
 
52
83
  /**
53
- * Get the brand color for a ledger
84
+ * Get the brand colour (hex) for a ledger.
54
85
  * @param ledgerId - Ledger identifier
55
- * @returns Hex color string or primary color fallback
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 LEDGER_COLORS[ledgerId?.toLowerCase()] || 'var(--ion-color-primary)';
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 LEDGER_NAMES[ledgerId?.toLowerCase()] || ledgerId;
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
+ });