@hsuite/native-connect-angular 2.1.0 → 2.1.2

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