@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,345 +0,0 @@
1
- /**
2
- * HSuite Native Connect
3
- * Copyright 2024-2025 HSuite (https://hsuite.finance)
4
- *
5
- * SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
6
- *
7
- * This file is part of HSuite Native Connect. For commercial licensing,
8
- * visit https://hsuite.finance/licensing
9
- */
10
-
11
- /**
12
- * @file High-level transaction service with automatic state management.
13
- *
14
- * @module services/transaction
15
- *
16
- * @description
17
- * TransactionService provides simplified methods for common transaction operations
18
- * with built-in state management, error handling, and UI feedback. It wraps
19
- * UnifiedWalletService operations with additional convenience features.
20
- *
21
- * **Key Features:**
22
- * - Automatic processing state tracking via Angular signals
23
- * - Toast notifications for success and error states
24
- * - Error propagation with proper error types
25
- * - Result and error state tracking for UI binding
26
- * - Support for batch transactions
27
- *
28
- * **Signal-based State:**
29
- * - `isProcessing()` - True while a transaction is in progress
30
- * - `lastResult()` - The result of the last successful transaction
31
- * - `lastError()` - The error from the last failed transaction
32
- *
33
- * @Component({
34
- * template: `
35
- * <button [disabled]="txService.isProcessing()" (click)="send()">
36
- * {{ txService.isProcessing() ? 'Processing...' : 'Send' }}
37
- * </button>
38
- * `
39
- * })
40
- * export class MyComponent {
41
- * txService = inject(TransactionService);
42
- *
43
- * async send() {
44
- * const result = await this.txService.signAndSubmit(payload);
45
- * console.log('Transaction ID:', result.transactionId);
46
- * }
47
- * }
48
- * ```
49
- */
50
-
51
- import { Injectable, inject, signal, type Signal, type WritableSignal } from '@angular/core';
52
- import { getLogger } from '@hsuite/native-connect-sdk';
53
- import { ToastController } from '@ionic/angular/standalone';
54
-
55
- import type { SignResult, SubmitResult } from '../providers/base-wallet-provider';
56
-
57
- import { UnifiedWalletService } from './unified-wallet.service';
58
- import { WalletEventBus } from './wallet-event-bus.service';
59
-
60
- const logger = getLogger().scoped?.('TransactionService') ?? getLogger();
61
-
62
- /**
63
- * High-level transaction service with automatic state management.
64
- *
65
- * @service TransactionService
66
- *
67
- * @description
68
- * Simplifies common transaction operations with built-in features:
69
- * - Automatic processing state management via Angular signals
70
- * - Error propagation with toast notifications
71
- * - Event emission for tracking and debugging
72
- * - Signal-based reactive state (modern Angular pattern)
73
- *
74
- * This service is the recommended way to perform transactions in dApps,
75
- * as it handles all the boilerplate around state management and user feedback.
76
- *
77
- * @providedIn root
78
- */
79
- @Injectable({ providedIn: 'root' })
80
- export class TransactionService {
81
- private readonly walletService = inject(UnifiedWalletService);
82
- private readonly eventBus = inject(WalletEventBus);
83
- private readonly toastController = inject(ToastController);
84
-
85
- // Internal writable signals for state management
86
- private readonly _isProcessing: WritableSignal<boolean> = signal(false);
87
- private readonly _lastResult: WritableSignal<unknown> = signal(null);
88
- private readonly _lastError: WritableSignal<Error | null> = signal(null);
89
-
90
- /**
91
- * Signal indicating if a transaction is currently processing
92
- */
93
- readonly isProcessing: Signal<boolean> = this._isProcessing.asReadonly();
94
-
95
- /**
96
- * Signal of the last transaction result
97
- */
98
- readonly lastResult: Signal<unknown> = this._lastResult.asReadonly();
99
-
100
- /**
101
- * Signal of the last error
102
- */
103
- readonly lastError: Signal<Error | null> = this._lastError.asReadonly();
104
-
105
- /**
106
- * Sign a transaction
107
- *
108
- * Automatically handles:
109
- * - Processing state
110
- * - Error propagation
111
- * - Success toast notification
112
- *
113
- * @param payload - Transaction payload (base64 or transaction bytes)
114
- * @returns Sign result
115
- */
116
- async signTransaction(payload: string): Promise<SignResult> {
117
- return this.executeTransaction(async () => {
118
- const result = (await this.walletService.signTransaction(payload)) as SignResult;
119
- logger.info('Transaction signed', {
120
- hasSignature: !!(result as { signedTransaction?: string }).signedTransaction,
121
- });
122
- await this.showSuccessToast(
123
- 'Transaction Signed',
124
- 'Your transaction has been signed successfully.',
125
- );
126
- return result;
127
- });
128
- }
129
-
130
- /**
131
- * Submit a transaction
132
- *
133
- * Automatically handles:
134
- * - Processing state
135
- * - Error propagation
136
- * - Success toast notification
137
- *
138
- * @param payload - Transaction payload (base64 or transaction bytes)
139
- * @returns Submit result
140
- */
141
- async submitTransaction(payload: string): Promise<SubmitResult> {
142
- return this.executeTransaction(async () => {
143
- const result = (await this.walletService.submitTransaction(payload)) as SubmitResult;
144
- logger.info('Transaction submitted', { transactionId: result.transactionId });
145
- await this.showSuccessToast(
146
- 'Transaction Submitted',
147
- `Transaction ID: ${result.transactionId || 'Success'}`,
148
- );
149
- return result;
150
- });
151
- }
152
-
153
- /**
154
- * Sign and submit a transaction in one call
155
- *
156
- * Uses the wallet's native sign+submit method when available (e.g., WalletConnect's signAndExecuteTransaction).
157
- * This prevents double prompts and provides a better UX.
158
- *
159
- * @param payload - Transaction payload
160
- * @returns Submit result
161
- */
162
- async signAndSubmit(payload: string): Promise<SubmitResult> {
163
- return this.executeTransaction(async () => {
164
- // Use the wallet's signAndExecuteTransaction method directly
165
- // This uses hedera_signAndExecuteTransaction for WalletConnect (one prompt!)
166
- const result = (await this.walletService.signAndExecuteTransaction(payload)) as SubmitResult;
167
- logger.info('Transaction signed and submitted', { transactionId: result.transactionId });
168
- await this.showSuccessToast(
169
- 'Transaction Complete',
170
- `Transaction ID: ${result.transactionId || 'Success'}`,
171
- );
172
- return result;
173
- });
174
- }
175
-
176
- /**
177
- * Submit a batch transaction
178
- *
179
- * Batch transactions require unsigned inner transactions that the wallet will sign.
180
- * The wallet signs each inner transaction with the account's key, then builds and
181
- * executes the BatchTransaction.
182
- *
183
- * @param options - Batch transaction options
184
- * @param options.batchKey - Public key for batch (typically account's public key)
185
- * @param options.innerTransactions - Array of unsigned inner transactions
186
- * @returns Submit result
187
- */
188
- async submitBatchTransaction(options: {
189
- batchKey: string;
190
- innerTransactions: Array<{ payload: string; description?: string }>;
191
- }): Promise<SubmitResult> {
192
- return this.executeTransaction(async () => {
193
- const result = (await this.walletService.submitTransaction('', {
194
- isBatch: true,
195
- batchKey: options.batchKey,
196
- innerTransactions: options.innerTransactions,
197
- })) as SubmitResult;
198
- logger.info('Batch transaction submitted', { transactionId: result.transactionId });
199
- await this.showSuccessToast(
200
- 'Batch Transaction Complete',
201
- `Transaction ID: ${result.transactionId || 'Success'}`,
202
- );
203
- return result;
204
- });
205
- }
206
-
207
- /**
208
- * Sign a message
209
- *
210
- * @param message - Message to sign
211
- * @returns Sign result with signature
212
- */
213
- async signMessage(message: string): Promise<SignResult> {
214
- return this.executeTransaction(async () => {
215
- const result = (await this.walletService.signMessage(message)) as SignResult;
216
- logger.info('Message signed', { hasSignature: !!result.signature });
217
- await this.showSuccessToast('Message Signed', 'Your message has been signed successfully.');
218
- return result;
219
- });
220
- }
221
-
222
- /**
223
- * Show a success toast notification
224
- * Uses cssClass-only styling (no Ionic color property) for theme compatibility.
225
- * @param header
226
- * @param message
227
- */
228
- private async showSuccessToast(header: string, message: string): Promise<void> {
229
- const toast = await this.toastController.create({
230
- header,
231
- message,
232
- icon: 'checkmark-circle-outline',
233
- cssClass: 'toast-success toast-compact',
234
- duration: 4000,
235
- position: 'top',
236
- buttons: [{ icon: 'close', role: 'cancel' }],
237
- });
238
- await toast.present();
239
- }
240
-
241
- /**
242
- * Show an error toast notification
243
- * Uses cssClass-only styling (no Ionic color property) for theme compatibility.
244
- * @param header
245
- * @param message
246
- */
247
- private async showErrorToast(header: string, message: string): Promise<void> {
248
- const toast = await this.toastController.create({
249
- header,
250
- message,
251
- icon: 'close-circle-outline',
252
- cssClass: 'toast-danger toast-compact',
253
- duration: 6000,
254
- position: 'top',
255
- buttons: [{ icon: 'close', role: 'cancel' }],
256
- });
257
- await toast.present();
258
- }
259
-
260
- /**
261
- * Execute a transaction with automatic state management
262
- *
263
- * Internal helper that wraps transaction operations with:
264
- * - Processing state updates
265
- * - Error handling with toast notifications
266
- * - Result tracking
267
- * @param operation
268
- */
269
- private async executeTransaction<T>(operation: () => Promise<T>): Promise<T> {
270
- // Set processing state
271
- this.setProcessing(true);
272
- this.clearError();
273
-
274
- try {
275
- // Execute the operation
276
- const result = await operation();
277
-
278
- // Update result state
279
- this.setResult(result);
280
-
281
- return result;
282
- } catch (error) {
283
- // Update error state
284
- const err = error instanceof Error ? error : new Error(String(error));
285
- this.setError(err);
286
-
287
- // Show error toast
288
- await this.showErrorToast(
289
- 'Transaction Failed',
290
- err.message || 'An error occurred during the transaction.',
291
- );
292
-
293
- // Re-throw for caller to handle
294
- throw err;
295
- } finally {
296
- // Clear processing state
297
- this.setProcessing(false);
298
- }
299
- }
300
-
301
- /**
302
- * Update processing state
303
- * @param processing
304
- */
305
- private setProcessing(processing: boolean): void {
306
- this._isProcessing.set(processing);
307
- }
308
-
309
- /**
310
- * Update result state
311
- * @param result
312
- */
313
- private setResult(result: unknown): void {
314
- this._lastResult.set(result);
315
- }
316
-
317
- /**
318
- * Update error state
319
- * @param error
320
- */
321
- private setError(error: Error): void {
322
- this._lastError.set(error);
323
- }
324
-
325
- /**
326
- * Clear error state
327
- */
328
- private clearError(): void {
329
- this._lastError.set(null);
330
- }
331
-
332
- /**
333
- * Resets all transaction state to initial values.
334
- *
335
- * @description
336
- * Clears the processing flag, last result, and last error.
337
- * Useful when navigating away from a transaction page or
338
- * starting a fresh transaction flow.
339
- */
340
- resetState(): void {
341
- this.setProcessing(false);
342
- this.setResult(null);
343
- this.clearError();
344
- }
345
- }