@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,741 +0,0 @@
1
- /**
2
- * @fileoverview Unit tests for HederaTransactionBuilderService
3
- *
4
- * Tests cover:
5
- * - HBAR/token/NFT transfer transactions
6
- * - Token association/dissociation
7
- * - Atomic transactions with multiple transfers
8
- * - Token/topic/account creation
9
- * - Multisig key configuration
10
- * - Error handling
11
- *
12
- * @module services/transaction-builders/hedera-transaction-builder
13
- * @since 2.0.0
14
- */
15
-
16
- import { TestBed } from '@angular/core/testing';
17
- import { describe, it, expect, beforeEach, vi, type MockedFunction } from 'vitest';
18
- import {
19
- HederaTransactionBuilderService,
20
- type HederaKeyConfig,
21
- type TokenCreateOptions,
22
- type TopicCreateOptions,
23
- type AccountCreateOptions,
24
- } from './hedera-transaction-builder.service';
25
- import { UnifiedWalletService } from '../unified-wallet.service';
26
- import { LoggerService } from '../logger.service';
27
- import { signal } from '@angular/core';
28
- import type { WalletAccount } from '@hsuite/native-connect-types';
29
-
30
- // Mock Hedera SDK
31
- vi.mock('@hashgraph/sdk', () => {
32
- const mockTransactionId = {
33
- generate: vi.fn().mockReturnValue('mock-tx-id'),
34
- };
35
-
36
- const mockAccountId = {
37
- fromString: vi.fn((s: string) => ({ toString: () => s })),
38
- };
39
-
40
- const mockTokenId = {
41
- fromString: vi.fn((s: string) => ({ toString: () => s })),
42
- };
43
-
44
- const mockHbar = vi.fn((amount: number) => ({
45
- toTinybars: () => amount * 100_000_000,
46
- amount,
47
- }));
48
- mockHbar.fromTinybars = vi.fn((amount: number) => ({ amount }));
49
-
50
- const createMockTransaction = () => ({
51
- setTransactionId: vi.fn().mockReturnThis(),
52
- freezeWith: vi.fn().mockResolvedValue({
53
- toBytes: () => new Uint8Array([1, 2, 3, 4]),
54
- }),
55
- toBytes: () => new Uint8Array([1, 2, 3, 4]),
56
- addHbarTransfer: vi.fn().mockReturnThis(),
57
- addTokenTransfer: vi.fn().mockReturnThis(),
58
- addNftTransfer: vi.fn().mockReturnThis(),
59
- setAccountId: vi.fn().mockReturnThis(),
60
- setTokenIds: vi.fn().mockReturnThis(),
61
- setBatchKey: vi.fn().mockReturnThis(),
62
- setAmount: vi.fn().mockReturnThis(),
63
- setTokenId: vi.fn().mockReturnThis(),
64
- setMetadata: vi.fn().mockReturnThis(),
65
- setScheduledTransaction: vi.fn().mockReturnThis(),
66
- setPayerAccountId: vi.fn().mockReturnThis(),
67
- setScheduleMemo: vi.fn().mockReturnThis(),
68
- setTokenName: vi.fn().mockReturnThis(),
69
- setTokenSymbol: vi.fn().mockReturnThis(),
70
- setDecimals: vi.fn().mockReturnThis(),
71
- setInitialSupply: vi.fn().mockReturnThis(),
72
- setTreasuryAccountId: vi.fn().mockReturnThis(),
73
- setTokenType: vi.fn().mockReturnThis(),
74
- setSupplyType: vi.fn().mockReturnThis(),
75
- setMaxSupply: vi.fn().mockReturnThis(),
76
- setTokenMemo: vi.fn().mockReturnThis(),
77
- setAdminKey: vi.fn().mockReturnThis(),
78
- setSupplyKey: vi.fn().mockReturnThis(),
79
- setFreezeKey: vi.fn().mockReturnThis(),
80
- setWipeKey: vi.fn().mockReturnThis(),
81
- setPauseKey: vi.fn().mockReturnThis(),
82
- setKycKey: vi.fn().mockReturnThis(),
83
- setFeeScheduleKey: vi.fn().mockReturnThis(),
84
- setTopicMemo: vi.fn().mockReturnThis(),
85
- setAutoRenewAccountId: vi.fn().mockReturnThis(),
86
- setSubmitKey: vi.fn().mockReturnThis(),
87
- setKey: vi.fn().mockReturnThis(),
88
- setInitialBalance: vi.fn().mockReturnThis(),
89
- setAccountMemo: vi.fn().mockReturnThis(),
90
- setMaxAutomaticTokenAssociations: vi.fn().mockReturnThis(),
91
- setReceiverSignatureRequired: vi.fn().mockReturnThis(),
92
- setAlias: vi.fn().mockReturnThis(),
93
- addTransaction: vi.fn().mockReturnThis(),
94
- setInnerTransactionIndex: vi.fn().mockReturnThis(),
95
- });
96
-
97
- const mockNftId = vi.fn((tokenId: unknown, serial: number) => ({
98
- tokenId,
99
- serial,
100
- }));
101
-
102
- const mockPublicKey = {
103
- fromString: vi.fn((s: string) => ({ _key: s, toString: () => s })),
104
- };
105
-
106
- const mockKeyList = vi.fn((keys: unknown[], threshold: number) => ({
107
- keys,
108
- threshold,
109
- }));
110
-
111
- const mockPrivateKey = {
112
- generate: vi.fn().mockReturnValue({
113
- publicKey: { toString: () => 'mock-public-key' },
114
- }),
115
- };
116
-
117
- const mockClient = {
118
- forMainnet: vi.fn().mockReturnValue({ network: 'mainnet' }),
119
- forTestnet: vi.fn().mockReturnValue({ network: 'testnet' }),
120
- forPreviewnet: vi.fn().mockReturnValue({ network: 'previewnet' }),
121
- };
122
-
123
- const TokenType = {
124
- FungibleCommon: 0,
125
- NonFungibleUnique: 1,
126
- };
127
-
128
- const TokenSupplyType = {
129
- Infinite: 0,
130
- Finite: 1,
131
- };
132
-
133
- return {
134
- TransferTransaction: vi.fn(createMockTransaction),
135
- TokenAssociateTransaction: vi.fn(createMockTransaction),
136
- TokenDissociateTransaction: vi.fn(createMockTransaction),
137
- TokenCreateTransaction: vi.fn(createMockTransaction),
138
- TokenMintTransaction: vi.fn(createMockTransaction),
139
- TokenBurnTransaction: vi.fn(createMockTransaction),
140
- TopicCreateTransaction: vi.fn(createMockTransaction),
141
- TopicMessageSubmitTransaction: vi.fn(createMockTransaction),
142
- AccountCreateTransaction: vi.fn(createMockTransaction),
143
- AccountUpdateTransaction: vi.fn(createMockTransaction),
144
- ScheduleCreateTransaction: vi.fn(createMockTransaction),
145
- BatchTransaction: vi.fn(createMockTransaction),
146
- Transaction: vi.fn(createMockTransaction),
147
- TransactionId: mockTransactionId,
148
- AccountId: mockAccountId,
149
- TokenId: mockTokenId,
150
- NftId: mockNftId,
151
- Hbar: mockHbar,
152
- Client: mockClient,
153
- PublicKey: mockPublicKey,
154
- PrivateKey: mockPrivateKey,
155
- KeyList: mockKeyList,
156
- Key: vi.fn(),
157
- TokenType,
158
- TokenSupplyType,
159
- };
160
- });
161
-
162
- describe('HederaTransactionBuilderService', () => {
163
- let service: HederaTransactionBuilderService;
164
- let mockWalletService: {
165
- activeAccount: ReturnType<typeof signal<WalletAccount | undefined>>;
166
- };
167
- let mockLogger: {
168
- debug: MockedFunction<(...args: unknown[]) => void>;
169
- warn: MockedFunction<(...args: unknown[]) => void>;
170
- error: MockedFunction<(...args: unknown[]) => void>;
171
- scoped: MockedFunction<(scope: string) => typeof mockLogger>;
172
- };
173
-
174
- const mockAccount: WalletAccount = {
175
- address: '0.0.12345',
176
- ledgerId: 'hedera',
177
- networkId: 'hedera:testnet',
178
- label: 'Test Account',
179
- balance: '100',
180
- metadata: {
181
- publicKey: 'mock-public-key-hex',
182
- },
183
- };
184
-
185
- beforeEach(async () => {
186
- mockWalletService = {
187
- activeAccount: signal<WalletAccount | undefined>(mockAccount),
188
- };
189
-
190
- mockLogger = {
191
- debug: vi.fn(),
192
- warn: vi.fn(),
193
- error: vi.fn(),
194
- scoped: vi.fn().mockReturnThis(),
195
- };
196
-
197
- await TestBed.configureTestingModule({
198
- providers: [
199
- HederaTransactionBuilderService,
200
- { provide: UnifiedWalletService, useValue: mockWalletService },
201
- { provide: LoggerService, useValue: mockLogger },
202
- ],
203
- }).compileComponents();
204
-
205
- service = TestBed.inject(HederaTransactionBuilderService);
206
- });
207
-
208
- it('should create', () => {
209
- expect(service).toBeTruthy();
210
- });
211
-
212
- // ==================== HBAR TRANSFER ====================
213
- describe('buildSendHbar', () => {
214
- it('should build HBAR transfer transaction', async () => {
215
- const result = await service.buildSendHbar('0.0.12345', '0.0.67890', 10);
216
-
217
- expect(result).toBeDefined();
218
- expect(typeof result).toBe('string');
219
- // Base64 encoded
220
- expect(result.match(/^[A-Za-z0-9+/]+=*$/)).toBeTruthy();
221
- });
222
-
223
- it('should throw error when no active wallet session', async () => {
224
- mockWalletService.activeAccount.set(undefined);
225
-
226
- await expect(service.buildSendHbar('0.0.12345', '0.0.67890', 10)).rejects.toThrow(
227
- 'No active wallet session',
228
- );
229
- });
230
- });
231
-
232
- // ==================== TOKEN TRANSFER ====================
233
- describe('buildSendToken', () => {
234
- it('should build token transfer transaction', async () => {
235
- const result = await service.buildSendToken('0.0.12345', '0.0.67890', '0.0.98765', 100, 8);
236
-
237
- expect(result).toBeDefined();
238
- expect(typeof result).toBe('string');
239
- });
240
-
241
- it('should use default decimals of 0', async () => {
242
- const result = await service.buildSendToken('0.0.12345', '0.0.67890', '0.0.98765', 100);
243
-
244
- expect(result).toBeDefined();
245
- });
246
- });
247
-
248
- // ==================== NFT TRANSFER ====================
249
- describe('buildSendNft', () => {
250
- it('should build NFT transfer transaction', async () => {
251
- const result = await service.buildSendNft('0.0.12345', '0.0.67890', '0.0.98765', 1);
252
-
253
- expect(result).toBeDefined();
254
- expect(typeof result).toBe('string');
255
- });
256
- });
257
-
258
- // ==================== TOKEN ASSOCIATION ====================
259
- describe('buildAssociateToken', () => {
260
- it('should build token association transaction', async () => {
261
- const result = await service.buildAssociateToken('0.0.12345', ['0.0.98765']);
262
-
263
- expect(result).toBeDefined();
264
- expect(typeof result).toBe('string');
265
- });
266
-
267
- it('should handle multiple token IDs', async () => {
268
- const result = await service.buildAssociateToken('0.0.12345', [
269
- '0.0.98765',
270
- '0.0.98766',
271
- '0.0.98767',
272
- ]);
273
-
274
- expect(result).toBeDefined();
275
- });
276
- });
277
-
278
- // ==================== TOKEN DISSOCIATION ====================
279
- describe('buildDissociateToken', () => {
280
- it('should build token dissociation transaction', async () => {
281
- const result = await service.buildDissociateToken('0.0.12345', ['0.0.98765']);
282
-
283
- expect(result).toBeDefined();
284
- expect(typeof result).toBe('string');
285
- });
286
- });
287
-
288
- // ==================== SCHEDULED TRANSACTION ====================
289
- describe('buildScheduledTransaction', () => {
290
- it('should build scheduled transaction', async () => {
291
- const innerTxBase64 = btoa('mock-inner-tx');
292
- const result = await service.buildScheduledTransaction(innerTxBase64, '0.0.12345');
293
-
294
- expect(result).toBeDefined();
295
- expect(typeof result).toBe('string');
296
- });
297
-
298
- it('should build scheduled transaction with memo', async () => {
299
- const innerTxBase64 = btoa('mock-inner-tx');
300
- const result = await service.buildScheduledTransaction(
301
- innerTxBase64,
302
- '0.0.12345',
303
- 'Test scheduled transaction',
304
- );
305
-
306
- expect(result).toBeDefined();
307
- });
308
- });
309
-
310
- // ==================== BATCH TRANSACTIONS ====================
311
- describe('buildBatchTransactions', () => {
312
- it('should return transactions as-is', async () => {
313
- const transactions = ['tx1', 'tx2', 'tx3'];
314
- const result = await service.buildBatchTransactions(transactions);
315
-
316
- expect(result).toEqual(transactions);
317
- });
318
- });
319
-
320
- // ==================== ATOMIC TRANSACTION ====================
321
- describe('buildAtomicTransaction', () => {
322
- it('should build atomic transaction with HBAR transfers', async () => {
323
- const result = await service.buildAtomicTransaction([
324
- {
325
- type: 'hbar',
326
- fromAccount: '0.0.12345',
327
- toAccount: '0.0.67890',
328
- amount: 10,
329
- },
330
- {
331
- type: 'hbar',
332
- fromAccount: '0.0.12345',
333
- toAccount: '0.0.11111',
334
- amount: 5,
335
- },
336
- ]);
337
-
338
- expect(result).toBeDefined();
339
- expect(typeof result).toBe('string');
340
- });
341
-
342
- it('should build atomic transaction with token transfers', async () => {
343
- const result = await service.buildAtomicTransaction([
344
- {
345
- type: 'token',
346
- fromAccount: '0.0.12345',
347
- toAccount: '0.0.67890',
348
- amount: 100,
349
- tokenId: '0.0.98765',
350
- decimals: 8,
351
- },
352
- ]);
353
-
354
- expect(result).toBeDefined();
355
- });
356
-
357
- it('should build atomic transaction with mixed transfers', async () => {
358
- const result = await service.buildAtomicTransaction([
359
- {
360
- type: 'hbar',
361
- fromAccount: '0.0.12345',
362
- toAccount: '0.0.67890',
363
- amount: 10,
364
- },
365
- {
366
- type: 'token',
367
- fromAccount: '0.0.12345',
368
- toAccount: '0.0.67890',
369
- amount: 100,
370
- tokenId: '0.0.98765',
371
- },
372
- ]);
373
-
374
- expect(result).toBeDefined();
375
- });
376
-
377
- it('should throw error for empty transfers', async () => {
378
- await expect(service.buildAtomicTransaction([])).rejects.toThrow(
379
- 'At least one transfer is required',
380
- );
381
- });
382
- });
383
-
384
- // ==================== TOKEN CREATE ====================
385
- describe('buildTokenCreate', () => {
386
- it('should build token creation with object options', async () => {
387
- const options: TokenCreateOptions = {
388
- name: 'Test Token',
389
- symbol: 'TST',
390
- decimals: 8,
391
- initialSupply: 1_000_000,
392
- };
393
-
394
- const result = await service.buildTokenCreate('0.0.12345', options);
395
-
396
- expect(result).toBeDefined();
397
- expect(typeof result).toBe('string');
398
- });
399
-
400
- it('should build token creation with positional args', async () => {
401
- const result = await service.buildTokenCreate('0.0.12345', 'Test Token', 'TST', 8, 1_000_000);
402
-
403
- expect(result).toBeDefined();
404
- });
405
-
406
- it('should build NFT token creation', async () => {
407
- const options: TokenCreateOptions = {
408
- name: 'Test NFT',
409
- symbol: 'TNFT',
410
- decimals: 0,
411
- initialSupply: 0,
412
- tokenType: 'NFT',
413
- };
414
-
415
- const result = await service.buildTokenCreate('0.0.12345', options);
416
-
417
- expect(result).toBeDefined();
418
- });
419
-
420
- it('should build token with max supply', async () => {
421
- const options: TokenCreateOptions = {
422
- name: 'Limited Token',
423
- symbol: 'LTD',
424
- decimals: 8,
425
- initialSupply: 1_000_000,
426
- maxSupply: 10_000_000,
427
- };
428
-
429
- const result = await service.buildTokenCreate('0.0.12345', options);
430
-
431
- expect(result).toBeDefined();
432
- });
433
-
434
- it('should build token with memo', async () => {
435
- const options: TokenCreateOptions = {
436
- name: 'Memo Token',
437
- symbol: 'MEM',
438
- decimals: 8,
439
- initialSupply: 1_000_000,
440
- memo: 'This is a test token',
441
- };
442
-
443
- const result = await service.buildTokenCreate('0.0.12345', options);
444
-
445
- expect(result).toBeDefined();
446
- });
447
- });
448
-
449
- // ==================== TOPIC CREATE ====================
450
- describe('buildTopicCreate', () => {
451
- it('should build topic creation transaction', async () => {
452
- const options: TopicCreateOptions = {
453
- memo: 'Test topic',
454
- };
455
-
456
- const result = await service.buildTopicCreate('0.0.12345', options);
457
-
458
- expect(result).toBeDefined();
459
- expect(typeof result).toBe('string');
460
- });
461
-
462
- it('should build topic with simple memo string', async () => {
463
- const result = await service.buildTopicCreate('0.0.12345', 'Simple memo');
464
-
465
- expect(result).toBeDefined();
466
- });
467
-
468
- it('should build topic with auto-renew account', async () => {
469
- const options: TopicCreateOptions = {
470
- memo: 'Auto-renew topic',
471
- autoRenewAccountId: '0.0.67890',
472
- };
473
-
474
- const result = await service.buildTopicCreate('0.0.12345', options);
475
-
476
- expect(result).toBeDefined();
477
- });
478
- });
479
-
480
- // ==================== ACCOUNT CREATE ====================
481
- describe('buildAccountCreate', () => {
482
- it('should build account creation transaction', async () => {
483
- const options: AccountCreateOptions = {
484
- initialBalance: 10,
485
- key: { publicKey: 'mock-public-key' },
486
- };
487
-
488
- const result = await service.buildAccountCreate('0.0.12345', options);
489
-
490
- expect(result).toBeDefined();
491
- expect(typeof result).toBe('string');
492
- });
493
-
494
- it('should build account with memo', async () => {
495
- const options: AccountCreateOptions = {
496
- initialBalance: 10,
497
- memo: 'Test account',
498
- };
499
-
500
- const result = await service.buildAccountCreate('0.0.12345', options);
501
-
502
- expect(result).toBeDefined();
503
- });
504
-
505
- it('should build account with max automatic associations', async () => {
506
- const options: AccountCreateOptions = {
507
- initialBalance: 10,
508
- maxAutomaticTokenAssociations: 100,
509
- };
510
-
511
- const result = await service.buildAccountCreate('0.0.12345', options);
512
-
513
- expect(result).toBeDefined();
514
- });
515
-
516
- it('should build account requiring receiver signature', async () => {
517
- const options: AccountCreateOptions = {
518
- initialBalance: 10,
519
- receiverSignatureRequired: true,
520
- };
521
-
522
- const result = await service.buildAccountCreate('0.0.12345', options);
523
-
524
- expect(result).toBeDefined();
525
- });
526
-
527
- it('should build multisig account', async () => {
528
- const options: AccountCreateOptions = {
529
- initialBalance: 10,
530
- key: {
531
- signerPublicKeys: ['key1', 'key2', 'key3'],
532
- threshold: 2,
533
- },
534
- };
535
-
536
- const result = await service.buildAccountCreate('0.0.12345', options);
537
-
538
- expect(result).toBeDefined();
539
- });
540
- });
541
-
542
- // ==================== ACCOUNT UPDATE ====================
543
- describe('buildAccountUpdate', () => {
544
- it('should build account update transaction', async () => {
545
- const result = await service.buildAccountUpdate('0.0.12345', {
546
- key: { publicKey: 'new-public-key' },
547
- });
548
-
549
- expect(result).toBeDefined();
550
- expect(typeof result).toBe('string');
551
- });
552
-
553
- it('should build account update with memo', async () => {
554
- const result = await service.buildAccountUpdate('0.0.12345', {
555
- memo: 'Updated memo',
556
- });
557
-
558
- expect(result).toBeDefined();
559
- });
560
-
561
- it('should build account update with max automatic associations', async () => {
562
- const result = await service.buildAccountUpdate('0.0.12345', {
563
- maxAutomaticTokenAssociations: 50,
564
- });
565
-
566
- expect(result).toBeDefined();
567
- });
568
- });
569
-
570
- // ==================== BATCH INNER TRANSACTIONS ====================
571
- describe('buildBatchInnerTransactions', () => {
572
- const mockBatchKey = 'mock-batch-public-key';
573
-
574
- it('should build batch with send-hbar', async () => {
575
- const result = await service.buildBatchInnerTransactions('0.0.12345', mockBatchKey, [
576
- { type: 'send-hbar', toAccount: '0.0.67890', amount: 100_000_000 },
577
- ]);
578
-
579
- expect(result).toBeDefined();
580
- expect(Array.isArray(result)).toBe(true);
581
- expect(result.length).toBe(1);
582
- expect(result[0].payload).toBeDefined();
583
- expect(result[0].description).toContain('tinybar');
584
- });
585
-
586
- it('should build batch with send-token', async () => {
587
- const result = await service.buildBatchInnerTransactions('0.0.12345', mockBatchKey, [
588
- {
589
- type: 'send-token',
590
- toAccount: '0.0.67890',
591
- tokenId: '0.0.98765',
592
- amount: 1000,
593
- },
594
- ]);
595
-
596
- expect(result).toBeDefined();
597
- expect(result.length).toBe(1);
598
- });
599
-
600
- it('should build batch with token-mint', async () => {
601
- const result = await service.buildBatchInnerTransactions('0.0.12345', mockBatchKey, [
602
- { type: 'token-mint', tokenId: '0.0.98765', amount: 100 },
603
- ]);
604
-
605
- expect(result).toBeDefined();
606
- expect(result.length).toBe(1);
607
- });
608
-
609
- it('should build batch with token-mint and metadata', async () => {
610
- const result = await service.buildBatchInnerTransactions('0.0.12345', mockBatchKey, [
611
- { type: 'token-mint', tokenId: '0.0.98765', amount: 1, metadata: 'test-metadata' },
612
- ]);
613
-
614
- expect(result).toBeDefined();
615
- });
616
-
617
- it('should build batch with token-associate', async () => {
618
- const result = await service.buildBatchInnerTransactions('0.0.12345', mockBatchKey, [
619
- { type: 'token-associate', tokenId: '0.0.98765' },
620
- ]);
621
-
622
- expect(result).toBeDefined();
623
- expect(result.length).toBe(1);
624
- });
625
-
626
- it('should build batch with multiple transactions', async () => {
627
- const result = await service.buildBatchInnerTransactions('0.0.12345', mockBatchKey, [
628
- { type: 'send-hbar', toAccount: '0.0.67890', amount: 100_000_000 },
629
- { type: 'send-hbar', toAccount: '0.0.11111', amount: 50_000_000 },
630
- { type: 'token-associate', tokenId: '0.0.98765' },
631
- ]);
632
-
633
- expect(result).toBeDefined();
634
- expect(result.length).toBe(3);
635
- });
636
-
637
- it('should throw error for unknown transaction type', async () => {
638
- await expect(
639
- service.buildBatchInnerTransactions('0.0.12345', mockBatchKey, [
640
- { type: 'unknown-type' as any, toAccount: '0.0.67890' },
641
- ]),
642
- ).rejects.toThrow('Unknown transaction type');
643
- });
644
- });
645
-
646
- // ==================== KEY CONFIG ====================
647
- describe('key configuration', () => {
648
- it('should auto-detect single-sig key from active account', async () => {
649
- // Active account has publicKey in metadata
650
- const options: TokenCreateOptions = {
651
- name: 'Auto Key Token',
652
- symbol: 'AKT',
653
- decimals: 8,
654
- initialSupply: 1_000_000,
655
- };
656
-
657
- const result = await service.buildTokenCreate('0.0.12345', options);
658
-
659
- expect(result).toBeDefined();
660
- // The logger should have been called with debug about single-sig
661
- });
662
-
663
- it('should auto-detect multisig key from active account', async () => {
664
- // Set up multisig account
665
- mockWalletService.activeAccount.set({
666
- ...mockAccount,
667
- metadata: {
668
- isMultisig: true,
669
- signerPublicKeys: ['key1', 'key2', 'key3'],
670
- threshold: 2,
671
- },
672
- });
673
-
674
- const options: TokenCreateOptions = {
675
- name: 'Multisig Token',
676
- symbol: 'MST',
677
- decimals: 8,
678
- initialSupply: 1_000_000,
679
- };
680
-
681
- const result = await service.buildTokenCreate('0.0.12345', options);
682
-
683
- expect(result).toBeDefined();
684
- });
685
-
686
- it('should use explicitly provided key config over auto-detected', async () => {
687
- const options: TokenCreateOptions = {
688
- name: 'Explicit Key Token',
689
- symbol: 'EKT',
690
- decimals: 8,
691
- initialSupply: 1_000_000,
692
- adminKey: { publicKey: 'explicit-admin-key' },
693
- supplyKey: { publicKey: 'explicit-supply-key' },
694
- };
695
-
696
- const result = await service.buildTokenCreate('0.0.12345', options);
697
-
698
- expect(result).toBeDefined();
699
- });
700
- });
701
-
702
- // ==================== NETWORK SELECTION ====================
703
- describe('network selection', () => {
704
- it('should use testnet for hedera:testnet', async () => {
705
- mockWalletService.activeAccount.set({
706
- ...mockAccount,
707
- networkId: 'hedera:testnet',
708
- });
709
-
710
- const result = await service.buildSendHbar('0.0.12345', '0.0.67890', 10);
711
-
712
- expect(result).toBeDefined();
713
- });
714
-
715
- it('should use mainnet for hedera:mainnet', async () => {
716
- mockWalletService.activeAccount.set({
717
- ...mockAccount,
718
- networkId: 'hedera:mainnet',
719
- });
720
-
721
- const result = await service.buildSendHbar('0.0.12345', '0.0.67890', 10);
722
-
723
- expect(result).toBeDefined();
724
- });
725
-
726
- it('should default to testnet for unknown network', async () => {
727
- mockWalletService.activeAccount.set({
728
- ...mockAccount,
729
- networkId: 'hedera:unknown',
730
- });
731
-
732
- const result = await service.buildSendHbar('0.0.12345', '0.0.67890', 10);
733
-
734
- expect(result).toBeDefined();
735
- expect(mockLogger.warn).toHaveBeenCalledWith(
736
- 'Unknown Hedera network, defaulting to testnet',
737
- expect.any(Object),
738
- );
739
- });
740
- });
741
- });