@hsuite/native-connect-angular 2.1.1 → 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.
Files changed (287) hide show
  1. package/LICENSE +146 -0
  2. package/package.json +30 -13
  3. package/USAGE_EXAMPLES.md +0 -476
  4. package/assets/wallets/extension.svg +0 -7
  5. package/assets/wallets/hashpack.svg +0 -6
  6. package/assets/wallets/hsuite.svg +0 -11
  7. package/assets/wallets/kabila.svg +0 -11
  8. package/assets/wallets/walletconnect.svg +0 -13
  9. package/coverage/base.css +0 -224
  10. package/coverage/block-navigation.js +0 -87
  11. package/coverage/coverage-summary.json +0 -54
  12. package/coverage/favicon.png +0 -0
  13. package/coverage/index.html +0 -476
  14. package/coverage/lcov-report/base.css +0 -224
  15. package/coverage/lcov-report/block-navigation.js +0 -87
  16. package/coverage/lcov-report/favicon.png +0 -0
  17. package/coverage/lcov-report/index.html +0 -476
  18. package/coverage/lcov-report/lib/components/account-selector/account-actions/account-actions.component.ts.html +0 -868
  19. package/coverage/lcov-report/lib/components/account-selector/account-actions/index.html +0 -116
  20. package/coverage/lcov-report/lib/components/account-selector/account-filter/account-filter.component.ts.html +0 -1288
  21. package/coverage/lcov-report/lib/components/account-selector/account-filter/index.html +0 -116
  22. package/coverage/lcov-report/lib/components/account-selector/account-formatting.service.ts.html +0 -679
  23. package/coverage/lcov-report/lib/components/account-selector/account-grouping.service.ts.html +0 -766
  24. package/coverage/lcov-report/lib/components/account-selector/account-list/account-list.component.ts.html +0 -1495
  25. package/coverage/lcov-report/lib/components/account-selector/account-list/index.html +0 -116
  26. package/coverage/lcov-report/lib/components/account-selector/account-selector.component.ts.html +0 -1495
  27. package/coverage/lcov-report/lib/components/account-selector/account-selector.service.ts.html +0 -1588
  28. package/coverage/lcov-report/lib/components/account-selector/index.html +0 -161
  29. package/coverage/lcov-report/lib/components/wallet-account-display/index.html +0 -116
  30. package/coverage/lcov-report/lib/components/wallet-account-display/wallet-account-display.component.ts.html +0 -505
  31. package/coverage/lcov-report/lib/components/wallet-connect-button/index.html +0 -116
  32. package/coverage/lcov-report/lib/components/wallet-connect-button/wallet-connect-button.component.ts.html +0 -829
  33. package/coverage/lcov-report/lib/components/wallet-connect-prompt/index.html +0 -116
  34. package/coverage/lcov-report/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts.html +0 -409
  35. package/coverage/lcov-report/lib/components/wallet-connected-guard/index.html +0 -116
  36. package/coverage/lcov-report/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts.html +0 -304
  37. package/coverage/lcov-report/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts.html +0 -436
  38. package/coverage/lcov-report/lib/components/wallet-connection-modal/connection-method-step/index.html +0 -116
  39. package/coverage/lcov-report/lib/components/wallet-connection-modal/index.html +0 -116
  40. package/coverage/lcov-report/lib/components/wallet-connection-modal/qr-pairing-step/index.html +0 -116
  41. package/coverage/lcov-report/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts.html +0 -2287
  42. package/coverage/lcov-report/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts.html +0 -2518
  43. package/coverage/lcov-report/lib/components/wallet-session-display/index.html +0 -116
  44. package/coverage/lcov-report/lib/components/wallet-session-display/wallet-session-display.component.ts.html +0 -676
  45. package/coverage/lcov-report/lib/components/wallet-transaction-status/index.html +0 -116
  46. package/coverage/lcov-report/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts.html +0 -703
  47. package/coverage/lcov-report/lib/directives/index.html +0 -146
  48. package/coverage/lcov-report/lib/directives/wallet-connected.directive.ts.html +0 -670
  49. package/coverage/lcov-report/lib/directives/wallet-context.directive.ts.html +0 -547
  50. package/coverage/lcov-report/lib/directives/wallet-events.directive.ts.html +0 -781
  51. package/coverage/lcov-report/lib/hsuite-wallet.module.ts.html +0 -715
  52. package/coverage/lcov-report/lib/index.html +0 -116
  53. package/coverage/lcov-report/lib/models/connection-config.model.ts.html +0 -280
  54. package/coverage/lcov-report/lib/models/index.html +0 -131
  55. package/coverage/lcov-report/lib/models/provider-types.ts.html +0 -583
  56. package/coverage/lcov-report/lib/providers/base-wallet-provider.ts.html +0 -1138
  57. package/coverage/lcov-report/lib/providers/hsuite-native/channel-client.service.ts.html +0 -2674
  58. package/coverage/lcov-report/lib/providers/hsuite-native/index.html +0 -116
  59. package/coverage/lcov-report/lib/providers/hsuite-native-provider.ts.html +0 -2347
  60. package/coverage/lcov-report/lib/providers/index.html +0 -146
  61. package/coverage/lcov-report/lib/providers/p2p-native/index.html +0 -131
  62. package/coverage/lcov-report/lib/providers/p2p-native/p2p-native.provider.ts.html +0 -2254
  63. package/coverage/lcov-report/lib/providers/p2p-native/p2p-session-manager.ts.html +0 -2173
  64. package/coverage/lcov-report/lib/providers/wallet-error-handler.ts.html +0 -1132
  65. package/coverage/lcov-report/lib/providers/walletconnect/core/index.html +0 -176
  66. package/coverage/lcov-report/lib/providers/walletconnect/core/session-health.ts.html +0 -673
  67. package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-client-manager.ts.html +0 -1177
  68. package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-provider.ts.html +0 -2566
  69. package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-session-store.ts.html +0 -904
  70. package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts.html +0 -982
  71. package/coverage/lcov-report/lib/providers/walletconnect/signers/hedera-signer.ts.html +0 -1915
  72. package/coverage/lcov-report/lib/providers/walletconnect/signers/index.html +0 -146
  73. package/coverage/lcov-report/lib/providers/walletconnect/signers/signer-factory.ts.html +0 -445
  74. package/coverage/lcov-report/lib/providers/walletconnect/signers/xrpl-signer.ts.html +0 -1519
  75. package/coverage/lcov-report/lib/services/hsuite-auth.interceptor.ts.html +0 -568
  76. package/coverage/lcov-report/lib/services/index.html +0 -221
  77. package/coverage/lcov-report/lib/services/logger.service.ts.html +0 -463
  78. package/coverage/lcov-report/lib/services/smart-session.service.ts.html +0 -1264
  79. package/coverage/lcov-report/lib/services/transaction-builders/active-account-source.ts.html +0 -250
  80. package/coverage/lcov-report/lib/services/transaction-builders/base-transaction-builder.service.ts.html +0 -1840
  81. package/coverage/lcov-report/lib/services/transaction-builders/hedera-amount-utils.ts.html +0 -337
  82. package/coverage/lcov-report/lib/services/transaction-builders/hedera-transaction-builder.service.ts.html +0 -3940
  83. package/coverage/lcov-report/lib/services/transaction-builders/index.html +0 -176
  84. package/coverage/lcov-report/lib/services/transaction-builders/xrpl-transaction-builder.service.ts.html +0 -2581
  85. package/coverage/lcov-report/lib/services/transaction.service.ts.html +0 -1120
  86. package/coverage/lcov-report/lib/services/unified-wallet.service.ts.html +0 -2638
  87. package/coverage/lcov-report/lib/services/wallet-context.service.ts.html +0 -637
  88. package/coverage/lcov-report/lib/services/wallet-event-bus.service.ts.html +0 -643
  89. package/coverage/lcov-report/lib/services/wallet-providers.service.ts.html +0 -493
  90. package/coverage/lcov-report/lib/transports/chrome-extension-transport.ts.html +0 -823
  91. package/coverage/lcov-report/lib/transports/index.html +0 -116
  92. package/coverage/lcov-report/lib/utils/index.html +0 -131
  93. package/coverage/lcov-report/lib/utils/ledger-icons.util.ts.html +0 -412
  94. package/coverage/lcov-report/lib/utils/ledger-ui-registry.ts.html +0 -676
  95. package/coverage/lcov-report/prettify.css +0 -1
  96. package/coverage/lcov-report/prettify.js +0 -2
  97. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  98. package/coverage/lcov-report/sorter.js +0 -210
  99. package/coverage/lcov.info +0 -20366
  100. package/coverage/lib/components/account-selector/account-actions/account-actions.component.ts.html +0 -868
  101. package/coverage/lib/components/account-selector/account-actions/index.html +0 -116
  102. package/coverage/lib/components/account-selector/account-filter/account-filter.component.ts.html +0 -1288
  103. package/coverage/lib/components/account-selector/account-filter/index.html +0 -116
  104. package/coverage/lib/components/account-selector/account-formatting.service.ts.html +0 -679
  105. package/coverage/lib/components/account-selector/account-grouping.service.ts.html +0 -766
  106. package/coverage/lib/components/account-selector/account-list/account-list.component.ts.html +0 -1495
  107. package/coverage/lib/components/account-selector/account-list/index.html +0 -116
  108. package/coverage/lib/components/account-selector/account-selector.component.ts.html +0 -1495
  109. package/coverage/lib/components/account-selector/account-selector.service.ts.html +0 -1588
  110. package/coverage/lib/components/account-selector/index.html +0 -161
  111. package/coverage/lib/components/wallet-account-display/index.html +0 -116
  112. package/coverage/lib/components/wallet-account-display/wallet-account-display.component.ts.html +0 -505
  113. package/coverage/lib/components/wallet-connect-button/index.html +0 -116
  114. package/coverage/lib/components/wallet-connect-button/wallet-connect-button.component.ts.html +0 -829
  115. package/coverage/lib/components/wallet-connect-prompt/index.html +0 -116
  116. package/coverage/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts.html +0 -409
  117. package/coverage/lib/components/wallet-connected-guard/index.html +0 -116
  118. package/coverage/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts.html +0 -304
  119. package/coverage/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts.html +0 -436
  120. package/coverage/lib/components/wallet-connection-modal/connection-method-step/index.html +0 -116
  121. package/coverage/lib/components/wallet-connection-modal/index.html +0 -116
  122. package/coverage/lib/components/wallet-connection-modal/qr-pairing-step/index.html +0 -116
  123. package/coverage/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts.html +0 -2287
  124. package/coverage/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts.html +0 -2518
  125. package/coverage/lib/components/wallet-session-display/index.html +0 -116
  126. package/coverage/lib/components/wallet-session-display/wallet-session-display.component.ts.html +0 -676
  127. package/coverage/lib/components/wallet-transaction-status/index.html +0 -116
  128. package/coverage/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts.html +0 -703
  129. package/coverage/lib/directives/index.html +0 -146
  130. package/coverage/lib/directives/wallet-connected.directive.ts.html +0 -670
  131. package/coverage/lib/directives/wallet-context.directive.ts.html +0 -547
  132. package/coverage/lib/directives/wallet-events.directive.ts.html +0 -781
  133. package/coverage/lib/hsuite-wallet.module.ts.html +0 -715
  134. package/coverage/lib/index.html +0 -116
  135. package/coverage/lib/models/connection-config.model.ts.html +0 -280
  136. package/coverage/lib/models/index.html +0 -131
  137. package/coverage/lib/models/provider-types.ts.html +0 -583
  138. package/coverage/lib/providers/base-wallet-provider.ts.html +0 -1138
  139. package/coverage/lib/providers/hsuite-native/channel-client.service.ts.html +0 -2674
  140. package/coverage/lib/providers/hsuite-native/index.html +0 -116
  141. package/coverage/lib/providers/hsuite-native-provider.ts.html +0 -2347
  142. package/coverage/lib/providers/index.html +0 -146
  143. package/coverage/lib/providers/p2p-native/index.html +0 -131
  144. package/coverage/lib/providers/p2p-native/p2p-native.provider.ts.html +0 -2254
  145. package/coverage/lib/providers/p2p-native/p2p-session-manager.ts.html +0 -2173
  146. package/coverage/lib/providers/wallet-error-handler.ts.html +0 -1132
  147. package/coverage/lib/providers/walletconnect/core/index.html +0 -176
  148. package/coverage/lib/providers/walletconnect/core/session-health.ts.html +0 -673
  149. package/coverage/lib/providers/walletconnect/core/walletconnect-client-manager.ts.html +0 -1177
  150. package/coverage/lib/providers/walletconnect/core/walletconnect-provider.ts.html +0 -2566
  151. package/coverage/lib/providers/walletconnect/core/walletconnect-session-store.ts.html +0 -904
  152. package/coverage/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts.html +0 -982
  153. package/coverage/lib/providers/walletconnect/signers/hedera-signer.ts.html +0 -1915
  154. package/coverage/lib/providers/walletconnect/signers/index.html +0 -146
  155. package/coverage/lib/providers/walletconnect/signers/signer-factory.ts.html +0 -445
  156. package/coverage/lib/providers/walletconnect/signers/xrpl-signer.ts.html +0 -1519
  157. package/coverage/lib/services/hsuite-auth.interceptor.ts.html +0 -568
  158. package/coverage/lib/services/index.html +0 -221
  159. package/coverage/lib/services/logger.service.ts.html +0 -463
  160. package/coverage/lib/services/smart-session.service.ts.html +0 -1264
  161. package/coverage/lib/services/transaction-builders/active-account-source.ts.html +0 -250
  162. package/coverage/lib/services/transaction-builders/base-transaction-builder.service.ts.html +0 -1840
  163. package/coverage/lib/services/transaction-builders/hedera-amount-utils.ts.html +0 -337
  164. package/coverage/lib/services/transaction-builders/hedera-transaction-builder.service.ts.html +0 -3940
  165. package/coverage/lib/services/transaction-builders/index.html +0 -176
  166. package/coverage/lib/services/transaction-builders/xrpl-transaction-builder.service.ts.html +0 -2581
  167. package/coverage/lib/services/transaction.service.ts.html +0 -1120
  168. package/coverage/lib/services/unified-wallet.service.ts.html +0 -2638
  169. package/coverage/lib/services/wallet-context.service.ts.html +0 -637
  170. package/coverage/lib/services/wallet-event-bus.service.ts.html +0 -643
  171. package/coverage/lib/services/wallet-providers.service.ts.html +0 -493
  172. package/coverage/lib/transports/chrome-extension-transport.ts.html +0 -823
  173. package/coverage/lib/transports/index.html +0 -116
  174. package/coverage/lib/utils/index.html +0 -131
  175. package/coverage/lib/utils/ledger-icons.util.ts.html +0 -412
  176. package/coverage/lib/utils/ledger-ui-registry.ts.html +0 -676
  177. package/coverage/prettify.css +0 -1
  178. package/coverage/prettify.js +0 -2
  179. package/coverage/sort-arrow-sprite.png +0 -0
  180. package/coverage/sorter.js +0 -210
  181. package/examples/minimal-connect.ts +0 -178
  182. package/examples/multi-protocol.ts +0 -495
  183. package/examples/transaction-signing.ts +0 -361
  184. package/jest.config.json +0 -45
  185. package/karma.conf.js +0 -42
  186. package/ng-package.json +0 -20
  187. package/src/index.ts +0 -229
  188. package/src/lib/components/account-selector/account-actions/account-actions.component.ts +0 -261
  189. package/src/lib/components/account-selector/account-filter/account-filter.component.ts +0 -401
  190. package/src/lib/components/account-selector/account-formatting.service.ts +0 -198
  191. package/src/lib/components/account-selector/account-grouping.service.ts +0 -227
  192. package/src/lib/components/account-selector/account-list/account-list.component.ts +0 -470
  193. package/src/lib/components/account-selector/account-selector.component.html +0 -135
  194. package/src/lib/components/account-selector/account-selector.component.scss +0 -2039
  195. package/src/lib/components/account-selector/account-selector.component.ts +0 -470
  196. package/src/lib/components/account-selector/account-selector.service.ts +0 -501
  197. package/src/lib/components/wallet-account-display/wallet-account-display.component.html +0 -34
  198. package/src/lib/components/wallet-account-display/wallet-account-display.component.scss +0 -99
  199. package/src/lib/components/wallet-account-display/wallet-account-display.component.ts +0 -140
  200. package/src/lib/components/wallet-connect-button/wallet-connect-button.component.html +0 -14
  201. package/src/lib/components/wallet-connect-button/wallet-connect-button.component.scss +0 -272
  202. package/src/lib/components/wallet-connect-button/wallet-connect-button.component.spec.ts +0 -89
  203. package/src/lib/components/wallet-connect-button/wallet-connect-button.component.ts +0 -248
  204. package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.html +0 -24
  205. package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.scss +0 -50
  206. package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts +0 -108
  207. package/src/lib/components/wallet-connected-guard/wallet-connected-guard.component.html +0 -24
  208. package/src/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts +0 -73
  209. package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.html +0 -56
  210. package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.scss +0 -218
  211. package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts +0 -117
  212. package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.html +0 -94
  213. package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.scss +0 -272
  214. package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts +0 -734
  215. package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.html +0 -192
  216. package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.scss +0 -678
  217. package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.spec.ts +0 -173
  218. package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts +0 -811
  219. package/src/lib/components/wallet-session-display/wallet-session-display.component.html +0 -110
  220. package/src/lib/components/wallet-session-display/wallet-session-display.component.scss +0 -179
  221. package/src/lib/components/wallet-session-display/wallet-session-display.component.ts +0 -197
  222. package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.html +0 -65
  223. package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.scss +0 -254
  224. package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts +0 -206
  225. package/src/lib/directives/wallet-connected.directive.ts +0 -195
  226. package/src/lib/directives/wallet-context.directive.ts +0 -154
  227. package/src/lib/directives/wallet-events.directive.ts +0 -232
  228. package/src/lib/hsuite-wallet.module.ts +0 -210
  229. package/src/lib/models/connection-config.model.ts +0 -65
  230. package/src/lib/models/provider-types.ts +0 -166
  231. package/src/lib/models/unified-account.model.ts +0 -79
  232. package/src/lib/models/wallet-context.model.ts +0 -121
  233. package/src/lib/models/wallet-events.model.ts +0 -158
  234. package/src/lib/providers/base-wallet-provider.ts +0 -351
  235. package/src/lib/providers/hsuite-native/channel-client.service.spec.ts +0 -73
  236. package/src/lib/providers/hsuite-native/channel-client.service.ts +0 -863
  237. package/src/lib/providers/hsuite-native/index.ts +0 -8
  238. package/src/lib/providers/hsuite-native-provider.ts +0 -754
  239. package/src/lib/providers/mobile-native/mobile-native.provider.spec.ts +0 -19
  240. package/src/lib/providers/p2p-native/index.ts +0 -30
  241. package/src/lib/providers/p2p-native/p2p-native.provider.spec.ts +0 -523
  242. package/src/lib/providers/p2p-native/p2p-native.provider.ts +0 -723
  243. package/src/lib/providers/p2p-native/p2p-session-manager.ts +0 -696
  244. package/src/lib/providers/wallet-error-handler.ts +0 -349
  245. package/src/lib/providers/walletconnect/core/base-signer.interface.ts +0 -122
  246. package/src/lib/providers/walletconnect/core/session-health.ts +0 -196
  247. package/src/lib/providers/walletconnect/core/walletconnect-client-manager.ts +0 -364
  248. package/src/lib/providers/walletconnect/core/walletconnect-provider.integration.spec.ts +0 -348
  249. package/src/lib/providers/walletconnect/core/walletconnect-provider.ts +0 -827
  250. package/src/lib/providers/walletconnect/core/walletconnect-session-store.ts +0 -273
  251. package/src/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts +0 -299
  252. package/src/lib/providers/walletconnect/core/walletconnect-types.ts +0 -48
  253. package/src/lib/providers/walletconnect/index.ts +0 -33
  254. package/src/lib/providers/walletconnect/signers/hedera-signer.spec.ts +0 -367
  255. package/src/lib/providers/walletconnect/signers/hedera-signer.ts +0 -610
  256. package/src/lib/providers/walletconnect/signers/signer-factory.spec.ts +0 -62
  257. package/src/lib/providers/walletconnect/signers/signer-factory.ts +0 -120
  258. package/src/lib/providers/walletconnect/signers/xrpl-signer.spec.ts +0 -296
  259. package/src/lib/providers/walletconnect/signers/xrpl-signer.ts +0 -478
  260. package/src/lib/services/hsuite-auth.interceptor.ts +0 -159
  261. package/src/lib/services/logger.service.ts +0 -126
  262. package/src/lib/services/smart-session.service.ts +0 -378
  263. package/src/lib/services/transaction-builders/active-account-source.spec.ts +0 -75
  264. package/src/lib/services/transaction-builders/active-account-source.ts +0 -55
  265. package/src/lib/services/transaction-builders/base-transaction-builder.service.ts +0 -585
  266. package/src/lib/services/transaction-builders/hedera-amount-utils.ts +0 -84
  267. package/src/lib/services/transaction-builders/hedera-transaction-builder.service.spec.ts +0 -741
  268. package/src/lib/services/transaction-builders/hedera-transaction-builder.service.ts +0 -1285
  269. package/src/lib/services/transaction-builders/index.ts +0 -55
  270. package/src/lib/services/transaction-builders/xrpl-transaction-builder.service.spec.ts +0 -937
  271. package/src/lib/services/transaction-builders/xrpl-transaction-builder.service.ts +0 -832
  272. package/src/lib/services/transaction.service.ts +0 -349
  273. package/src/lib/services/unified-wallet.service.spec.ts +0 -1382
  274. package/src/lib/services/unified-wallet.service.ts +0 -851
  275. package/src/lib/services/wallet-context.service.ts +0 -184
  276. package/src/lib/services/wallet-event-bus.service.ts +0 -186
  277. package/src/lib/services/wallet-providers.service.ts +0 -136
  278. package/src/lib/transports/chrome-extension-transport.ts +0 -246
  279. package/src/lib/utils/index.ts +0 -15
  280. package/src/lib/utils/ledger-icons.util.ts +0 -109
  281. package/src/lib/utils/ledger-ui-registry.ts +0 -197
  282. package/test/test-setup.ts +0 -21
  283. package/test-setup.ts +0 -63
  284. package/tsconfig.build.json +0 -11
  285. package/tsconfig.json +0 -29
  286. package/tsconfig.spec.json +0 -15
  287. package/vitest.config.ts +0 -48
@@ -1,811 +0,0 @@
1
- /**
2
- * @file wallet-connection-modal.component.ts
3
- * @description Multi-protocol wallet connection modal with step-by-step flow
4
- *
5
- * Provides a beautiful, user-friendly interface for connecting wallets across
6
- * multiple protocols (HSuite Native, WalletConnect) and ledgers (Hedera, XRPL).
7
- *
8
- * Features:
9
- * - Step-by-step connection wizard with direct selection (no Next button)
10
- * - Dynamic step indicator showing only relevant steps per protocol path
11
- * - Network selection (Mainnet, Testnet)
12
- * - Protocol selection (HSuite Native vs WalletConnect)
13
- * - Connection method selection (Desktop or Mobile QR)
14
- * - Ledger selection (Hedera, XRPL) for WalletConnect
15
- * - QR code display for mobile P2P connections
16
- * - Beautiful animations and loading states
17
- *
18
- * Step Paths:
19
- * - HSuite Native + Desktop: Network → Protocol → Method (3 steps)
20
- * - HSuite Native + Mobile QR: Network → Protocol → Method → QR Pairing (4 steps)
21
- * - WalletConnect: Network → Protocol → Ledger → Connect (4 steps)
22
- */
23
-
24
- import { CommonModule } from '@angular/common';
25
- import {
26
- Component,
27
- Input,
28
- Output,
29
- EventEmitter,
30
- OnInit,
31
- signal,
32
- computed,
33
- inject,
34
- } from '@angular/core';
35
- import { getLogger } from '@hsuite/native-connect-sdk';
36
- import type { SupportedLedger } from '@hsuite/native-connect-sdk';
37
- import { IonicModule, ModalController, Platform } from '@ionic/angular';
38
-
39
- import type { WalletConnectV2Config } from '../../models/provider-types';
40
- import { DEFAULT_WALLET_URL } from '../../models/provider-types';
41
- import { P2PNativeProvider } from '../../providers/p2p-native/p2p-native.provider';
42
- import { UnifiedWalletService } from '../../services/unified-wallet.service';
43
- import { registerLedgerIcons } from '../../utils/ledger-icons.util';
44
- import { LedgerUIRegistry } from '../../utils/ledger-ui-registry';
45
-
46
- import {
47
- ConnectionMethodStepComponent,
48
- type ConnectionMethodOption,
49
- } from './connection-method-step/connection-method-step.component';
50
- import { QrPairingStepComponent } from './qr-pairing-step/qr-pairing-step.component';
51
-
52
- const logger = getLogger().scoped?.('WalletConnectionModal') ?? getLogger();
53
-
54
- /**
55
- * Connection step enumeration for the wizard flow
56
- */
57
- enum ConnectionStep {
58
- NetworkSelection = 1,
59
- ProtocolSelection = 2,
60
- ConnectionMethodSelection = 3,
61
- LedgerSelection = 4,
62
- QrPairing = 5,
63
- ConnectionProgress = 6,
64
- }
65
-
66
- /**
67
- * Connection method type.
68
- * - desktop: Uses extension if available, otherwise opens PWA in new tab (SDK auto-selects)
69
- * - mobile-qr: Two-way QR scan for cross-device P2P connection
70
- */
71
- type ConnectionMethod = 'desktop' | 'mobile-qr';
72
-
73
- /**
74
- * Network configuration options
75
- */
76
- interface NetworkOption {
77
- id: string;
78
- name: string;
79
- description: string;
80
- icon?: string;
81
- recommended?: boolean;
82
- }
83
-
84
- /**
85
- * Protocol configuration options
86
- */
87
- interface ProtocolOption {
88
- id: 'hsuite-native' | 'walletconnect';
89
- name: string;
90
- description: string;
91
- icon: string;
92
- features: string[];
93
- }
94
-
95
- /**
96
- * Ledger configuration options
97
- */
98
- interface LedgerOption {
99
- id: SupportedLedger;
100
- name: string;
101
- description: string;
102
- icon: string;
103
- }
104
-
105
- /**
106
- * Per-ledger copy for the WalletConnect "Choose Blockchain" step.
107
- *
108
- * Keyed by {@link SupportedLedger} (the closed set of ledgers the WalletConnect
109
- * provider brokers) via `satisfies`, so widening that union forces a description
110
- * here. Display name and icon come from {@link LedgerUIRegistry}; this map holds
111
- * only the connection-flow copy specific to this surface.
112
- */
113
- const LEDGER_DESCRIPTIONS = {
114
- hedera: 'Hedera Hashgraph network',
115
- xrpl: 'XRP Ledger network',
116
- } satisfies Record<SupportedLedger, string>;
117
-
118
- /**
119
- * Step configuration for dynamic step indicator.
120
- * Defines the total steps and labels based on selected protocol path.
121
- */
122
- interface StepConfig {
123
- /** Total number of steps in the current path */
124
- total: number;
125
- /** Labels for each step in the progress indicator */
126
- labels: string[];
127
- }
128
-
129
- /**
130
- * Main wallet connection modal component.
131
- * Orchestrates the multi-step connection flow.
132
- */
133
- @Component({
134
- selector: 'hsuite-wallet-connection-modal',
135
- standalone: true,
136
- imports: [CommonModule, IonicModule, ConnectionMethodStepComponent, QrPairingStepComponent],
137
- templateUrl: './wallet-connection-modal.component.html',
138
- styleUrls: ['./wallet-connection-modal.component.scss'],
139
- })
140
- export class WalletConnectionModalComponent implements OnInit {
141
- /**
142
- * WalletConnect project ID (required for WalletConnect)
143
- */
144
- @Input() projectId?: string;
145
-
146
- /**
147
- * Pins the connection network and hides the network-selection step.
148
- *
149
- * When set to `'mainnet'` or `'testnet'`, the host dApp decides the network
150
- * and the user is never shown the network picker — the modal opens directly
151
- * on protocol selection. When omitted (default), the user chooses the network
152
- * as the first step.
153
- */
154
- @Input() network?: 'mainnet' | 'testnet';
155
-
156
- /**
157
- * App name for WalletConnect metadata
158
- */
159
- @Input() appName: string = 'HSuite Demo';
160
-
161
- /**
162
- * App description for WalletConnect metadata
163
- */
164
- @Input() appDescription: string = 'Multi-chain wallet connection';
165
-
166
- /**
167
- * Wallet URL for HSuite Native connection
168
- */
169
- @Input() walletUrl: string = DEFAULT_WALLET_URL;
170
-
171
- /**
172
- * Event emitted when connection is successful
173
- */
174
- @Output() connected = new EventEmitter<unknown>();
175
-
176
- // Note: answerScannerRequested removed - new Nostr-first flow doesn't need answer scanning
177
-
178
- private readonly platform = inject(Platform);
179
- private readonly p2pNativeProvider = inject(P2PNativeProvider);
180
-
181
- // Step management
182
- readonly currentStep = signal<ConnectionStep>(ConnectionStep.NetworkSelection);
183
- readonly ConnectionStep = ConnectionStep;
184
-
185
- // Selection state
186
- readonly selectedNetwork = signal<string>('testnet');
187
- readonly selectedProtocol = signal<'hsuite-native' | 'walletconnect' | null>(null);
188
- readonly selectedConnectionMethod = signal<ConnectionMethod | null>(null);
189
- readonly selectedLedger = signal<SupportedLedger | null>(null);
190
-
191
- // Loading state
192
- readonly isConnecting = signal<boolean>(false);
193
- readonly connectionError = signal<string | null>(null);
194
-
195
- // QR Pairing state
196
- readonly pairingOffer = signal<string>('');
197
- readonly isGeneratingOffer = signal<boolean>(false);
198
-
199
- /**
200
- * Indicates we're waiting for the wallet to scan the QR and connect via Nostr.
201
- */
202
- readonly isWaitingForWallet = signal<boolean>(false);
203
-
204
- /**
205
- * Indicates we're waiting for the wallet user to approve the session.
206
- * Nostr connection is established, but session approval is pending.
207
- */
208
- readonly isWaitingForApproval = signal<boolean>(false);
209
-
210
- // Platform detection
211
- readonly isMobile = signal<boolean>(this.detectMobile());
212
- readonly isExtensionAvailable = signal<boolean>(this.detectExtension());
213
-
214
- // Configuration options
215
- readonly networkOptions: NetworkOption[] = [
216
- {
217
- id: 'mainnet',
218
- name: 'Mainnet',
219
- description: 'Production network with real assets',
220
- icon: 'shield-checkmark',
221
- },
222
- {
223
- id: 'testnet',
224
- name: 'Testnet',
225
- description: 'Test network for development',
226
- icon: 'flask',
227
- recommended: true,
228
- },
229
- ];
230
-
231
- readonly protocolOptions = computed<ProtocolOption[]>(() => {
232
- const options: ProtocolOption[] = [
233
- {
234
- id: 'hsuite-native',
235
- name: 'HSuite Native Connect',
236
- description: 'Direct connection to HSuite Wallet',
237
- icon: 'link',
238
- features: [
239
- 'Multiple chains in one session',
240
- 'Multiple wallets per session',
241
- 'Seamless multi-chain operations',
242
- 'Best for HSuite Wallet users',
243
- ],
244
- },
245
- ];
246
-
247
- // Only show WalletConnect if projectId is provided
248
- if (this.projectId) {
249
- options.push({
250
- id: 'walletconnect',
251
- name: 'WalletConnect',
252
- description: 'Universal wallet connection protocol',
253
- icon: 'scan',
254
- features: [
255
- 'Connect via QR code or extension',
256
- 'Compatible with HashPack, Kabila, and more',
257
- 'Industry-standard protocol',
258
- 'One wallet per session',
259
- ],
260
- });
261
- }
262
-
263
- return options;
264
- });
265
-
266
- readonly ledgerOptions: LedgerOption[] = (
267
- Object.keys(LEDGER_DESCRIPTIONS) as SupportedLedger[]
268
- ).map((id) => {
269
- const ui = LedgerUIRegistry.get(id);
270
- return {
271
- id,
272
- name: ui?.displayName ?? id,
273
- description: LEDGER_DESCRIPTIONS[id],
274
- icon: ui?.iconName ?? '',
275
- };
276
- });
277
-
278
- /**
279
- * Connection method options for HSuite Native.
280
- * Simplified to two options:
281
- * - HSuite Wallet (desktop): SDK auto-selects extension or PWA
282
- * - Mobile Wallet (QR): Cross-device P2P connection
283
- */
284
- readonly connectionMethodOptions = computed<ConnectionMethodOption[]>(() => [
285
- {
286
- id: 'desktop',
287
- name: 'HSuite Wallet',
288
- description: this.isExtensionAvailable()
289
- ? 'Connect via browser extension'
290
- : 'Open HSuite Wallet in new tab',
291
- icon: this.isExtensionAvailable() ? 'extension-puzzle-outline' : 'open-outline',
292
- available: true,
293
- recommended: !this.isMobile(),
294
- features: this.isExtensionAvailable()
295
- ? ['Extension detected', 'Fastest connection']
296
- : ['Opens in new tab', 'Works everywhere'],
297
- },
298
- {
299
- id: 'mobile-qr',
300
- name: 'Mobile Wallet (QR)',
301
- description: 'Two-way QR scan for cross-device connection',
302
- icon: 'qr-code-outline',
303
- available: true,
304
- recommended: this.isMobile(),
305
- features: ['Cross-device', 'P2P', 'No server needed'],
306
- },
307
- ]);
308
-
309
- // Computed properties
310
- readonly canProceed = computed(() => {
311
- const step = this.currentStep();
312
- switch (step) {
313
- case ConnectionStep.NetworkSelection:
314
- return !!this.selectedNetwork();
315
- case ConnectionStep.ProtocolSelection:
316
- return !!this.selectedProtocol();
317
- case ConnectionStep.ConnectionMethodSelection:
318
- return !!this.selectedConnectionMethod();
319
- case ConnectionStep.LedgerSelection:
320
- return !!this.selectedLedger();
321
- default:
322
- return false;
323
- }
324
- });
325
-
326
- readonly stepTitle = computed(() => {
327
- const step = this.currentStep();
328
- switch (step) {
329
- case ConnectionStep.NetworkSelection:
330
- return 'Select Network';
331
- case ConnectionStep.ProtocolSelection:
332
- return 'Choose Connection Protocol';
333
- case ConnectionStep.ConnectionMethodSelection:
334
- return 'Choose Connection Method';
335
- case ConnectionStep.LedgerSelection:
336
- return 'Select Ledger';
337
- case ConnectionStep.QrPairing:
338
- return 'Connect Mobile Wallet';
339
- case ConnectionStep.ConnectionProgress:
340
- return 'Connecting...';
341
- default:
342
- return '';
343
- }
344
- });
345
-
346
- /**
347
- * Dynamic step configuration based on selected protocol and connection method.
348
- * Returns the total number of steps and labels for the progress indicator.
349
- *
350
- * Step Paths:
351
- * - Initial (no protocol): 3 placeholder steps
352
- * - HSuite Native + Desktop: 3 steps (Network, Protocol, Method)
353
- * - HSuite Native + Mobile QR: 4 steps (Network, Protocol, Method, Pair)
354
- * - WalletConnect: 4 steps (Network, Protocol, Ledger, Connect)
355
- */
356
- readonly stepConfig = computed<StepConfig>(() => {
357
- const protocol = this.selectedProtocol();
358
- const method = this.selectedConnectionMethod();
359
-
360
- let base: StepConfig;
361
-
362
- // Initial state: show 3 placeholder steps until protocol is selected
363
- if (!protocol) {
364
- base = { total: 3, labels: ['Network', 'Protocol', '...'] };
365
- } else if (protocol === 'hsuite-native') {
366
- // HSuite Native path
367
- base =
368
- method === 'mobile-qr'
369
- ? // Mobile QR needs 4 steps
370
- { total: 4, labels: ['Network', 'Protocol', 'Method', 'Pair'] }
371
- : // Desktop connects immediately after method selection (3 steps)
372
- { total: 3, labels: ['Network', 'Protocol', 'Method'] };
373
- } else {
374
- // WalletConnect path: 4 steps
375
- base = { total: 4, labels: ['Network', 'Protocol', 'Ledger', 'Connect'] };
376
- }
377
-
378
- // When the network is pinned by the host dApp the network step is never
379
- // shown — drop it from the indicator so the numbering stays accurate.
380
- if (this.network) {
381
- return { total: base.total - 1, labels: base.labels.slice(1) };
382
- }
383
- return base;
384
- });
385
-
386
- /**
387
- * Maps the internal ConnectionStep enum to display position (1-based).
388
- * Different protocol paths have different step mappings.
389
- */
390
- readonly displayStep = computed<number>(() => {
391
- const step = this.currentStep();
392
- // Protocol could be used for protocol-specific step mapping in the future
393
- const _protocol = this.selectedProtocol();
394
-
395
- // When the network is pinned the network step is removed, so every
396
- // subsequent step shifts down one position in the indicator.
397
- const networkOffset = this.network ? 1 : 0;
398
-
399
- // Map internal step to display position based on protocol path
400
- switch (step) {
401
- case ConnectionStep.NetworkSelection:
402
- return 1;
403
- case ConnectionStep.ProtocolSelection:
404
- return 2 - networkOffset;
405
- case ConnectionStep.ConnectionMethodSelection:
406
- return 3 - networkOffset;
407
- case ConnectionStep.LedgerSelection:
408
- // WalletConnect ledger selection is step 3
409
- return 3 - networkOffset;
410
- case ConnectionStep.QrPairing:
411
- // QR pairing is step 4 for both paths that use it
412
- return 4 - networkOffset;
413
- case ConnectionStep.ConnectionProgress:
414
- // Connection progress is always the last step
415
- return this.stepConfig().total;
416
- default:
417
- return 1;
418
- }
419
- });
420
-
421
- /**
422
- * Whether a back affordance should be offered for the current step.
423
- * The first reachable step has no back target — that is protocol selection
424
- * when the network is pinned, otherwise network selection. The connection
425
- * progress step manages its own retry navigation instead.
426
- */
427
- readonly canGoBack = computed<boolean>(() => {
428
- const step = this.currentStep();
429
- if (step === ConnectionStep.ConnectionProgress) {
430
- return false;
431
- }
432
- const firstStep = this.network
433
- ? ConnectionStep.ProtocolSelection
434
- : ConnectionStep.NetworkSelection;
435
- return step > firstStep;
436
- });
437
-
438
- /**
439
- *
440
- * @param modalController
441
- * @param unifiedWalletService
442
- */
443
- constructor(
444
- private modalController: ModalController,
445
- private unifiedWalletService: UnifiedWalletService,
446
- ) {
447
- // Set up mobile provider connection callback
448
- this.p2pNativeProvider.onPeerConnected(() => {
449
- this.onMobileConnected();
450
- });
451
-
452
- // Register the shared ledger brand logos so <ion-icon> can resolve them by name.
453
- registerLedgerIcons();
454
- }
455
-
456
- /**
457
- * Apply the pinned network (if any) before the first render.
458
- *
459
- * When the host dApp provides a {@link network}, lock the selection to it and
460
- * skip straight to protocol selection so the user never sees — and cannot
461
- * change — the network. With no input, the modal opens on network selection.
462
- */
463
- ngOnInit(): void {
464
- if (this.network) {
465
- this.selectedNetwork.set(this.network);
466
- this.currentStep.set(ConnectionStep.ProtocolSelection);
467
- }
468
- }
469
-
470
- /**
471
- * Select a network option (internal, use selectNetworkAndProceed for UI)
472
- * @param networkId
473
- */
474
- selectNetwork(networkId: string): void {
475
- this.selectedNetwork.set(networkId);
476
- }
477
-
478
- /**
479
- * Select a network and automatically proceed to the next step.
480
- * This enables direct selection behavior without requiring a "Next" button.
481
- * @param networkId - The network ID to select ('mainnet' or 'testnet')
482
- */
483
- selectNetworkAndProceed(networkId: string): void {
484
- this.selectedNetwork.set(networkId);
485
- // Auto-advance to protocol selection
486
- this.currentStep.set(ConnectionStep.ProtocolSelection);
487
- }
488
-
489
- /**
490
- * Select a protocol option (internal, use selectProtocolAndProceed for UI)
491
- * @param protocolId
492
- */
493
- selectProtocol(protocolId: 'hsuite-native' | 'walletconnect'): void {
494
- this.selectedProtocol.set(protocolId);
495
- }
496
-
497
- /**
498
- * Select a protocol and automatically proceed to the appropriate next step.
499
- * - HSuite Native → Connection Method Selection
500
- * - WalletConnect → Ledger Selection
501
- * @param protocolId - The protocol ID to select
502
- */
503
- selectProtocolAndProceed(protocolId: 'hsuite-native' | 'walletconnect'): void {
504
- this.selectedProtocol.set(protocolId);
505
-
506
- if (protocolId === 'hsuite-native') {
507
- // HSuite Native: Go to connection method selection
508
- this.currentStep.set(ConnectionStep.ConnectionMethodSelection);
509
- } else {
510
- // WalletConnect: Go to ledger selection
511
- this.currentStep.set(ConnectionStep.LedgerSelection);
512
- }
513
- }
514
-
515
- /**
516
- * Select a connection method (internal)
517
- * @param methodId
518
- */
519
- selectConnectionMethod(methodId: string): void {
520
- this.selectedConnectionMethod.set(methodId as ConnectionMethod);
521
- }
522
-
523
- /**
524
- * Handle connection method selection from step component.
525
- * Automatically proceeds to connect or QR pairing based on method.
526
- * @param methodId
527
- */
528
- onConnectionMethodSelected(methodId: string): void {
529
- this.selectConnectionMethod(methodId);
530
- void this.next();
531
- }
532
-
533
- /**
534
- * Select a ledger option (internal, use selectLedgerAndConnect for UI)
535
- * @param ledgerId
536
- */
537
- selectLedger(ledgerId: SupportedLedger): void {
538
- this.selectedLedger.set(ledgerId);
539
- }
540
-
541
- /**
542
- * Select a ledger and automatically initiate connection.
543
- * This enables direct selection behavior for WalletConnect ledger step.
544
- * @param ledgerId - The ledger ID to select ('hedera' or 'xrpl')
545
- */
546
- selectLedgerAndConnect(ledgerId: SupportedLedger): void {
547
- this.selectedLedger.set(ledgerId);
548
- // Auto-connect with the selected ledger
549
- void this.connect();
550
- }
551
-
552
- /**
553
- * Proceed to the next step in the wizard
554
- */
555
- async next(): Promise<void> {
556
- const currentStep = this.currentStep();
557
-
558
- if (currentStep === ConnectionStep.NetworkSelection) {
559
- this.currentStep.set(ConnectionStep.ProtocolSelection);
560
- } else if (currentStep === ConnectionStep.ProtocolSelection) {
561
- const protocol = this.selectedProtocol();
562
- if (protocol === 'hsuite-native') {
563
- // HSuite Native: Show connection method selection
564
- this.currentStep.set(ConnectionStep.ConnectionMethodSelection);
565
- } else {
566
- // WalletConnect: Show ledger selection
567
- this.currentStep.set(ConnectionStep.LedgerSelection);
568
- }
569
- } else if (currentStep === ConnectionStep.ConnectionMethodSelection) {
570
- const method = this.selectedConnectionMethod();
571
- if (method === 'mobile-qr') {
572
- // Mobile QR: Show QR pairing step
573
- await this.initiateQrPairing();
574
- } else {
575
- // Desktop: Connect directly (SDK auto-selects extension or PWA)
576
- await this.connect();
577
- }
578
- } else if (currentStep === ConnectionStep.LedgerSelection) {
579
- // Connect with selected ledger
580
- await this.connect();
581
- }
582
- }
583
-
584
- /**
585
- * Go back to the previous step
586
- */
587
- back(): void {
588
- const currentStep = this.currentStep();
589
- if (currentStep === ConnectionStep.ProtocolSelection) {
590
- // When the network is pinned, protocol selection is the first reachable
591
- // step — there is no network step to return to.
592
- if (!this.network) {
593
- this.currentStep.set(ConnectionStep.NetworkSelection);
594
- }
595
- } else if (currentStep === ConnectionStep.ConnectionMethodSelection) {
596
- this.currentStep.set(ConnectionStep.ProtocolSelection);
597
- } else if (currentStep === ConnectionStep.LedgerSelection) {
598
- this.currentStep.set(ConnectionStep.ProtocolSelection);
599
- } else if (currentStep === ConnectionStep.QrPairing) {
600
- this.currentStep.set(ConnectionStep.ConnectionMethodSelection);
601
- this.pairingOffer.set('');
602
- this.connectionError.set(null);
603
- } else if (currentStep === ConnectionStep.ConnectionProgress) {
604
- // Go back to appropriate step based on protocol and method
605
- const protocol = this.selectedProtocol();
606
- const method = this.selectedConnectionMethod();
607
- if (protocol === 'walletconnect') {
608
- this.currentStep.set(ConnectionStep.LedgerSelection);
609
- } else if (method === 'mobile-qr') {
610
- this.currentStep.set(ConnectionStep.QrPairing);
611
- } else {
612
- this.currentStep.set(ConnectionStep.ConnectionMethodSelection);
613
- }
614
- // Clear error state
615
- this.connectionError.set(null);
616
- this.isConnecting.set(false);
617
- }
618
- }
619
-
620
- /**
621
- * Connect to the selected protocol and ledger
622
- */
623
- private async connect(): Promise<void> {
624
- this.currentStep.set(ConnectionStep.ConnectionProgress);
625
- this.isConnecting.set(true);
626
- this.connectionError.set(null);
627
-
628
- try {
629
- const protocol = this.selectedProtocol();
630
- const network = this.selectedNetwork();
631
-
632
- if (protocol === 'hsuite-native') {
633
- // Connect to HSuite Native (multi-chain by default)
634
- // Use the input walletUrl and pass targetWindow metadata for consistent window naming
635
- await this.unifiedWalletService.connect('hsuite-native', {
636
- type: 'hsuite-native',
637
- appId: 'hsuite-demo',
638
- appName: this.appName,
639
- ledgerId: 'multi-chain',
640
- networkId: network || 'testnet',
641
- walletUrl: this.walletUrl,
642
- metadata: {
643
- targetWindow: 'hsuite-wallet',
644
- },
645
- });
646
- } else if (protocol === 'walletconnect') {
647
- // Connect to WalletConnect (ledger-specific)
648
- const ledger = this.selectedLedger();
649
- if (!ledger) {
650
- throw new Error('No ledger selected');
651
- }
652
-
653
- if (!this.projectId) {
654
- throw new Error(
655
- 'WalletConnect projectId is required. Get one from https://cloud.walletconnect.com',
656
- );
657
- }
658
-
659
- const config: WalletConnectV2Config = {
660
- type: 'walletconnect-v2',
661
- projectId: this.projectId,
662
- ledgerId: ledger,
663
- networkId: `${ledger}:${network}`,
664
- appName: this.appName,
665
- appDescription: this.appDescription,
666
- };
667
-
668
- await this.unifiedWalletService.connect('walletconnect-v2', config);
669
- }
670
-
671
- // Success! Emit event and close modal
672
- this.connected.emit({ protocol, network });
673
- await this.modalController.dismiss({ connected: true });
674
- } catch (error) {
675
- logger.error('Connection failed', {
676
- error: error instanceof Error ? error.message : String(error),
677
- });
678
- this.connectionError.set(
679
- error instanceof Error ? error.message : 'Connection failed. Please try again.',
680
- );
681
- this.isConnecting.set(false);
682
- // Stay on ConnectionProgress to show the error and "Try Again" button
683
- // Don't auto-navigate away - let user click "Try Again" which calls back()
684
- }
685
- }
686
-
687
- /**
688
- * Close the modal without connecting
689
- */
690
- async dismiss(): Promise<void> {
691
- await this.modalController.dismiss({ connected: false });
692
- }
693
-
694
- // ========== QR Pairing Methods ==========
695
-
696
- /**
697
- * Initiate QR pairing flow for mobile connection (Nostr-first protocol).
698
- *
699
- * Flow:
700
- * 1. Generate session invite QR code
701
- * 2. Wait for wallet to scan and connect via Nostr
702
- * 3. Wait for wallet user to approve session
703
- * 4. P2P upgrade happens automatically in background
704
- */
705
- private async initiateQrPairing(): Promise<void> {
706
- this.currentStep.set(ConnectionStep.QrPairing);
707
- this.isGeneratingOffer.set(true);
708
- this.connectionError.set(null);
709
-
710
- try {
711
- const network = this.selectedNetwork();
712
- const result = await this.p2pNativeProvider.createPairingOffer({
713
- type: 'mobile-native',
714
- appId: 'hsuite-dapp',
715
- appName: this.appName,
716
- ledgerId: 'multi-chain',
717
- networkId: network || 'testnet',
718
- });
719
-
720
- this.pairingOffer.set(result.qrData);
721
- this.isGeneratingOffer.set(false);
722
- this.isWaitingForWallet.set(true);
723
-
724
- // Start waiting for wallet to connect and approve
725
- this.waitForWalletApproval();
726
- } catch (error) {
727
- logger.error('Failed to create pairing offer', { error });
728
- this.connectionError.set(
729
- error instanceof Error ? error.message : 'Failed to generate QR code',
730
- );
731
- this.isGeneratingOffer.set(false);
732
- }
733
- }
734
-
735
- /**
736
- * Wait for wallet to connect via Nostr and approve the session.
737
- * This is the new single-QR flow - no answer scanning needed.
738
- */
739
- private async waitForWalletApproval(): Promise<void> {
740
- try {
741
- // This blocks until wallet scans QR, connects via Nostr, and user approves
742
- const session = await this.p2pNativeProvider.waitForSessionApproval();
743
-
744
- logger.info('Session approved by wallet', {
745
- sessionId: session?.sessionId,
746
- accounts: session?.accounts?.length,
747
- });
748
-
749
- this.onMobileConnected();
750
- } catch (error) {
751
- // Only show error if we're still on the QR pairing step (not cancelled)
752
- if (this.currentStep() === ConnectionStep.QrPairing) {
753
- logger.error('Session approval failed', { error });
754
- this.connectionError.set(
755
- error instanceof Error ? error.message : 'Session approval failed or rejected',
756
- );
757
- }
758
- this.isWaitingForWallet.set(false);
759
- this.isWaitingForApproval.set(false);
760
- }
761
- }
762
-
763
- /**
764
- * Handle QR code expiry
765
- */
766
- onQrExpired(): void {
767
- logger.debug('QR code expired');
768
- this.pairingOffer.set('');
769
- this.isWaitingForWallet.set(false);
770
- }
771
-
772
- /**
773
- * Refresh the QR pairing offer
774
- */
775
- async onQrRefresh(): Promise<void> {
776
- this.isWaitingForWallet.set(false);
777
- this.isWaitingForApproval.set(false);
778
- await this.initiateQrPairing();
779
- }
780
-
781
- /**
782
- * Handle successful mobile connection
783
- */
784
- private onMobileConnected(): void {
785
- logger.info('Mobile wallet connected');
786
- this.connected.emit({ protocol: 'mobile-native', method: 'qr' });
787
- void this.modalController.dismiss({ connected: true });
788
- }
789
-
790
- // ========== Platform Detection ==========
791
-
792
- /**
793
- * Detect if running on mobile device
794
- */
795
- private detectMobile(): boolean {
796
- return this.platform.is('mobile') || this.platform.is('android') || this.platform.is('ios');
797
- }
798
-
799
- /**
800
- * Detect if HSuite extension is available.
801
- * Checks for the flag injected by the extension's content script.
802
- */
803
- private detectExtension(): boolean {
804
- if (typeof window === 'undefined') return false;
805
- // Check for HSuite extension marker (injected by extension's inject-flags.ts)
806
- return (
807
- (window as unknown as { __HSUITE_WALLET_EXTENSION__?: boolean })
808
- .__HSUITE_WALLET_EXTENSION__ === true
809
- );
810
- }
811
- }