@hsuite/native-connect-angular 1.0.0

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 (276) hide show
  1. package/README.md +48 -0
  2. package/USAGE_EXAMPLES.md +476 -0
  3. package/assets/wallets/extension.svg +7 -0
  4. package/assets/wallets/hashpack.svg +6 -0
  5. package/assets/wallets/hsuite.svg +11 -0
  6. package/assets/wallets/kabila.svg +11 -0
  7. package/assets/wallets/walletconnect.svg +13 -0
  8. package/coverage/base.css +224 -0
  9. package/coverage/block-navigation.js +87 -0
  10. package/coverage/coverage-summary.json +50 -0
  11. package/coverage/favicon.png +0 -0
  12. package/coverage/index.html +476 -0
  13. package/coverage/lcov-report/base.css +224 -0
  14. package/coverage/lcov-report/block-navigation.js +87 -0
  15. package/coverage/lcov-report/favicon.png +0 -0
  16. package/coverage/lcov-report/index.html +476 -0
  17. package/coverage/lcov-report/lib/components/account-selector/account-actions/account-actions.component.ts.html +868 -0
  18. package/coverage/lcov-report/lib/components/account-selector/account-actions/index.html +116 -0
  19. package/coverage/lcov-report/lib/components/account-selector/account-filter/account-filter.component.ts.html +1288 -0
  20. package/coverage/lcov-report/lib/components/account-selector/account-filter/index.html +116 -0
  21. package/coverage/lcov-report/lib/components/account-selector/account-formatting.service.ts.html +685 -0
  22. package/coverage/lcov-report/lib/components/account-selector/account-grouping.service.ts.html +766 -0
  23. package/coverage/lcov-report/lib/components/account-selector/account-list/account-list.component.ts.html +1495 -0
  24. package/coverage/lcov-report/lib/components/account-selector/account-list/index.html +116 -0
  25. package/coverage/lcov-report/lib/components/account-selector/account-selector.component.ts.html +1495 -0
  26. package/coverage/lcov-report/lib/components/account-selector/account-selector.service.ts.html +1588 -0
  27. package/coverage/lcov-report/lib/components/account-selector/index.html +161 -0
  28. package/coverage/lcov-report/lib/components/wallet-account-display/index.html +116 -0
  29. package/coverage/lcov-report/lib/components/wallet-account-display/wallet-account-display.component.ts.html +505 -0
  30. package/coverage/lcov-report/lib/components/wallet-connect-button/index.html +116 -0
  31. package/coverage/lcov-report/lib/components/wallet-connect-button/wallet-connect-button.component.ts.html +805 -0
  32. package/coverage/lcov-report/lib/components/wallet-connect-prompt/index.html +116 -0
  33. package/coverage/lcov-report/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts.html +409 -0
  34. package/coverage/lcov-report/lib/components/wallet-connected-guard/index.html +116 -0
  35. package/coverage/lcov-report/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts.html +304 -0
  36. package/coverage/lcov-report/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts.html +436 -0
  37. package/coverage/lcov-report/lib/components/wallet-connection-modal/connection-method-step/index.html +116 -0
  38. package/coverage/lcov-report/lib/components/wallet-connection-modal/index.html +116 -0
  39. package/coverage/lcov-report/lib/components/wallet-connection-modal/qr-pairing-step/index.html +116 -0
  40. package/coverage/lcov-report/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts.html +2287 -0
  41. package/coverage/lcov-report/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts.html +2275 -0
  42. package/coverage/lcov-report/lib/components/wallet-session-display/index.html +116 -0
  43. package/coverage/lcov-report/lib/components/wallet-session-display/wallet-session-display.component.ts.html +676 -0
  44. package/coverage/lcov-report/lib/components/wallet-transaction-status/index.html +116 -0
  45. package/coverage/lcov-report/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts.html +703 -0
  46. package/coverage/lcov-report/lib/directives/index.html +146 -0
  47. package/coverage/lcov-report/lib/directives/wallet-connected.directive.ts.html +670 -0
  48. package/coverage/lcov-report/lib/directives/wallet-context.directive.ts.html +547 -0
  49. package/coverage/lcov-report/lib/directives/wallet-events.directive.ts.html +781 -0
  50. package/coverage/lcov-report/lib/hsuite-wallet.module.ts.html +715 -0
  51. package/coverage/lcov-report/lib/index.html +116 -0
  52. package/coverage/lcov-report/lib/models/connection-config.model.ts.html +280 -0
  53. package/coverage/lcov-report/lib/models/index.html +131 -0
  54. package/coverage/lcov-report/lib/models/provider-types.ts.html +577 -0
  55. package/coverage/lcov-report/lib/providers/base-wallet-provider.ts.html +1138 -0
  56. package/coverage/lcov-report/lib/providers/hsuite-native/channel-client.service.ts.html +2671 -0
  57. package/coverage/lcov-report/lib/providers/hsuite-native/index.html +116 -0
  58. package/coverage/lcov-report/lib/providers/hsuite-native-provider.ts.html +2347 -0
  59. package/coverage/lcov-report/lib/providers/index.html +146 -0
  60. package/coverage/lcov-report/lib/providers/p2p-native/index.html +131 -0
  61. package/coverage/lcov-report/lib/providers/p2p-native/p2p-native.provider.ts.html +2254 -0
  62. package/coverage/lcov-report/lib/providers/p2p-native/p2p-session-manager.ts.html +2170 -0
  63. package/coverage/lcov-report/lib/providers/wallet-error-handler.ts.html +1132 -0
  64. package/coverage/lcov-report/lib/providers/walletconnect/core/index.html +176 -0
  65. package/coverage/lcov-report/lib/providers/walletconnect/core/session-health.ts.html +673 -0
  66. package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-client-manager.ts.html +1177 -0
  67. package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-provider.ts.html +2563 -0
  68. package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-session-store.ts.html +904 -0
  69. package/coverage/lcov-report/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts.html +982 -0
  70. package/coverage/lcov-report/lib/providers/walletconnect/signers/hedera-signer.ts.html +1915 -0
  71. package/coverage/lcov-report/lib/providers/walletconnect/signers/index.html +146 -0
  72. package/coverage/lcov-report/lib/providers/walletconnect/signers/signer-factory.ts.html +445 -0
  73. package/coverage/lcov-report/lib/providers/walletconnect/signers/xrpl-signer.ts.html +1519 -0
  74. package/coverage/lcov-report/lib/services/index.html +191 -0
  75. package/coverage/lcov-report/lib/services/logger.service.ts.html +463 -0
  76. package/coverage/lcov-report/lib/services/transaction-builders/base-transaction-builder.service.ts.html +1840 -0
  77. package/coverage/lcov-report/lib/services/transaction-builders/hedera-amount-utils.ts.html +337 -0
  78. package/coverage/lcov-report/lib/services/transaction-builders/hedera-transaction-builder.service.ts.html +3940 -0
  79. package/coverage/lcov-report/lib/services/transaction-builders/index.html +161 -0
  80. package/coverage/lcov-report/lib/services/transaction-builders/xrpl-transaction-builder.service.ts.html +2581 -0
  81. package/coverage/lcov-report/lib/services/transaction.service.ts.html +1123 -0
  82. package/coverage/lcov-report/lib/services/unified-wallet.service.ts.html +2641 -0
  83. package/coverage/lcov-report/lib/services/wallet-context.service.ts.html +637 -0
  84. package/coverage/lcov-report/lib/services/wallet-event-bus.service.ts.html +643 -0
  85. package/coverage/lcov-report/lib/services/wallet-providers.service.ts.html +496 -0
  86. package/coverage/lcov-report/lib/transports/chrome-extension-transport.ts.html +823 -0
  87. package/coverage/lcov-report/lib/transports/index.html +116 -0
  88. package/coverage/lcov-report/lib/utils/index.html +116 -0
  89. package/coverage/lcov-report/lib/utils/ledger-icons.util.ts.html +319 -0
  90. package/coverage/lcov-report/prettify.css +1 -0
  91. package/coverage/lcov-report/prettify.js +2 -0
  92. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  93. package/coverage/lcov-report/sorter.js +210 -0
  94. package/coverage/lcov.info +19252 -0
  95. package/coverage/lib/components/account-selector/account-actions/account-actions.component.ts.html +868 -0
  96. package/coverage/lib/components/account-selector/account-actions/index.html +116 -0
  97. package/coverage/lib/components/account-selector/account-filter/account-filter.component.ts.html +1288 -0
  98. package/coverage/lib/components/account-selector/account-filter/index.html +116 -0
  99. package/coverage/lib/components/account-selector/account-formatting.service.ts.html +685 -0
  100. package/coverage/lib/components/account-selector/account-grouping.service.ts.html +766 -0
  101. package/coverage/lib/components/account-selector/account-list/account-list.component.ts.html +1495 -0
  102. package/coverage/lib/components/account-selector/account-list/index.html +116 -0
  103. package/coverage/lib/components/account-selector/account-selector.component.ts.html +1495 -0
  104. package/coverage/lib/components/account-selector/account-selector.service.ts.html +1588 -0
  105. package/coverage/lib/components/account-selector/index.html +161 -0
  106. package/coverage/lib/components/wallet-account-display/index.html +116 -0
  107. package/coverage/lib/components/wallet-account-display/wallet-account-display.component.ts.html +505 -0
  108. package/coverage/lib/components/wallet-connect-button/index.html +116 -0
  109. package/coverage/lib/components/wallet-connect-button/wallet-connect-button.component.ts.html +805 -0
  110. package/coverage/lib/components/wallet-connect-prompt/index.html +116 -0
  111. package/coverage/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts.html +409 -0
  112. package/coverage/lib/components/wallet-connected-guard/index.html +116 -0
  113. package/coverage/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts.html +304 -0
  114. package/coverage/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts.html +436 -0
  115. package/coverage/lib/components/wallet-connection-modal/connection-method-step/index.html +116 -0
  116. package/coverage/lib/components/wallet-connection-modal/index.html +116 -0
  117. package/coverage/lib/components/wallet-connection-modal/qr-pairing-step/index.html +116 -0
  118. package/coverage/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts.html +2287 -0
  119. package/coverage/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts.html +2275 -0
  120. package/coverage/lib/components/wallet-session-display/index.html +116 -0
  121. package/coverage/lib/components/wallet-session-display/wallet-session-display.component.ts.html +676 -0
  122. package/coverage/lib/components/wallet-transaction-status/index.html +116 -0
  123. package/coverage/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts.html +703 -0
  124. package/coverage/lib/directives/index.html +146 -0
  125. package/coverage/lib/directives/wallet-connected.directive.ts.html +670 -0
  126. package/coverage/lib/directives/wallet-context.directive.ts.html +547 -0
  127. package/coverage/lib/directives/wallet-events.directive.ts.html +781 -0
  128. package/coverage/lib/hsuite-wallet.module.ts.html +715 -0
  129. package/coverage/lib/index.html +116 -0
  130. package/coverage/lib/models/connection-config.model.ts.html +280 -0
  131. package/coverage/lib/models/index.html +131 -0
  132. package/coverage/lib/models/provider-types.ts.html +577 -0
  133. package/coverage/lib/providers/base-wallet-provider.ts.html +1138 -0
  134. package/coverage/lib/providers/hsuite-native/channel-client.service.ts.html +2671 -0
  135. package/coverage/lib/providers/hsuite-native/index.html +116 -0
  136. package/coverage/lib/providers/hsuite-native-provider.ts.html +2347 -0
  137. package/coverage/lib/providers/index.html +146 -0
  138. package/coverage/lib/providers/p2p-native/index.html +131 -0
  139. package/coverage/lib/providers/p2p-native/p2p-native.provider.ts.html +2254 -0
  140. package/coverage/lib/providers/p2p-native/p2p-session-manager.ts.html +2170 -0
  141. package/coverage/lib/providers/wallet-error-handler.ts.html +1132 -0
  142. package/coverage/lib/providers/walletconnect/core/index.html +176 -0
  143. package/coverage/lib/providers/walletconnect/core/session-health.ts.html +673 -0
  144. package/coverage/lib/providers/walletconnect/core/walletconnect-client-manager.ts.html +1177 -0
  145. package/coverage/lib/providers/walletconnect/core/walletconnect-provider.ts.html +2563 -0
  146. package/coverage/lib/providers/walletconnect/core/walletconnect-session-store.ts.html +904 -0
  147. package/coverage/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts.html +982 -0
  148. package/coverage/lib/providers/walletconnect/signers/hedera-signer.ts.html +1915 -0
  149. package/coverage/lib/providers/walletconnect/signers/index.html +146 -0
  150. package/coverage/lib/providers/walletconnect/signers/signer-factory.ts.html +445 -0
  151. package/coverage/lib/providers/walletconnect/signers/xrpl-signer.ts.html +1519 -0
  152. package/coverage/lib/services/index.html +191 -0
  153. package/coverage/lib/services/logger.service.ts.html +463 -0
  154. package/coverage/lib/services/transaction-builders/base-transaction-builder.service.ts.html +1840 -0
  155. package/coverage/lib/services/transaction-builders/hedera-amount-utils.ts.html +337 -0
  156. package/coverage/lib/services/transaction-builders/hedera-transaction-builder.service.ts.html +3940 -0
  157. package/coverage/lib/services/transaction-builders/index.html +161 -0
  158. package/coverage/lib/services/transaction-builders/xrpl-transaction-builder.service.ts.html +2581 -0
  159. package/coverage/lib/services/transaction.service.ts.html +1123 -0
  160. package/coverage/lib/services/unified-wallet.service.ts.html +2641 -0
  161. package/coverage/lib/services/wallet-context.service.ts.html +637 -0
  162. package/coverage/lib/services/wallet-event-bus.service.ts.html +643 -0
  163. package/coverage/lib/services/wallet-providers.service.ts.html +496 -0
  164. package/coverage/lib/transports/chrome-extension-transport.ts.html +823 -0
  165. package/coverage/lib/transports/index.html +116 -0
  166. package/coverage/lib/utils/index.html +116 -0
  167. package/coverage/lib/utils/ledger-icons.util.ts.html +319 -0
  168. package/coverage/prettify.css +1 -0
  169. package/coverage/prettify.js +2 -0
  170. package/coverage/sort-arrow-sprite.png +0 -0
  171. package/coverage/sorter.js +210 -0
  172. package/dist/README.md +48 -0
  173. package/dist/fesm2022/hsuite-native-connect-angular.mjs +14592 -0
  174. package/dist/fesm2022/hsuite-native-connect-angular.mjs.map +1 -0
  175. package/dist/index.d.ts +6949 -0
  176. package/examples/minimal-connect.ts +178 -0
  177. package/examples/multi-protocol.ts +495 -0
  178. package/examples/transaction-signing.ts +361 -0
  179. package/jest.config.json +45 -0
  180. package/karma.conf.js +42 -0
  181. package/ng-package.json +20 -0
  182. package/package.json +60 -0
  183. package/src/index.ts +203 -0
  184. package/src/lib/components/account-selector/account-actions/account-actions.component.ts +261 -0
  185. package/src/lib/components/account-selector/account-filter/account-filter.component.ts +401 -0
  186. package/src/lib/components/account-selector/account-formatting.service.ts +200 -0
  187. package/src/lib/components/account-selector/account-grouping.service.ts +227 -0
  188. package/src/lib/components/account-selector/account-list/account-list.component.ts +470 -0
  189. package/src/lib/components/account-selector/account-selector.component.html +135 -0
  190. package/src/lib/components/account-selector/account-selector.component.scss +2039 -0
  191. package/src/lib/components/account-selector/account-selector.component.ts +470 -0
  192. package/src/lib/components/account-selector/account-selector.service.ts +501 -0
  193. package/src/lib/components/wallet-account-display/wallet-account-display.component.html +34 -0
  194. package/src/lib/components/wallet-account-display/wallet-account-display.component.scss +99 -0
  195. package/src/lib/components/wallet-account-display/wallet-account-display.component.ts +140 -0
  196. package/src/lib/components/wallet-connect-button/wallet-connect-button.component.html +14 -0
  197. package/src/lib/components/wallet-connect-button/wallet-connect-button.component.scss +272 -0
  198. package/src/lib/components/wallet-connect-button/wallet-connect-button.component.ts +240 -0
  199. package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.html +24 -0
  200. package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.scss +50 -0
  201. package/src/lib/components/wallet-connect-prompt/wallet-connect-prompt.component.ts +108 -0
  202. package/src/lib/components/wallet-connected-guard/wallet-connected-guard.component.html +24 -0
  203. package/src/lib/components/wallet-connected-guard/wallet-connected-guard.component.ts +73 -0
  204. package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.html +56 -0
  205. package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.scss +218 -0
  206. package/src/lib/components/wallet-connection-modal/connection-method-step/connection-method-step.component.ts +117 -0
  207. package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.html +94 -0
  208. package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.scss +272 -0
  209. package/src/lib/components/wallet-connection-modal/qr-pairing-step/qr-pairing-step.component.ts +734 -0
  210. package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.html +197 -0
  211. package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.scss +678 -0
  212. package/src/lib/components/wallet-connection-modal/wallet-connection-modal.component.ts +730 -0
  213. package/src/lib/components/wallet-session-display/wallet-session-display.component.html +110 -0
  214. package/src/lib/components/wallet-session-display/wallet-session-display.component.scss +179 -0
  215. package/src/lib/components/wallet-session-display/wallet-session-display.component.ts +197 -0
  216. package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.html +65 -0
  217. package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.scss +254 -0
  218. package/src/lib/components/wallet-transaction-status/wallet-transaction-status.component.ts +206 -0
  219. package/src/lib/directives/wallet-connected.directive.ts +195 -0
  220. package/src/lib/directives/wallet-context.directive.ts +154 -0
  221. package/src/lib/directives/wallet-events.directive.ts +232 -0
  222. package/src/lib/hsuite-wallet.module.ts +210 -0
  223. package/src/lib/models/connection-config.model.ts +65 -0
  224. package/src/lib/models/provider-types.ts +164 -0
  225. package/src/lib/models/unified-account.model.ts +76 -0
  226. package/src/lib/models/wallet-context.model.ts +121 -0
  227. package/src/lib/models/wallet-events.model.ts +158 -0
  228. package/src/lib/providers/base-wallet-provider.ts +351 -0
  229. package/src/lib/providers/hsuite-native/channel-client.service.spec.ts +73 -0
  230. package/src/lib/providers/hsuite-native/channel-client.service.ts +862 -0
  231. package/src/lib/providers/hsuite-native/index.ts +8 -0
  232. package/src/lib/providers/hsuite-native-provider.ts +754 -0
  233. package/src/lib/providers/mobile-native/mobile-native.provider.spec.ts +19 -0
  234. package/src/lib/providers/p2p-native/index.ts +30 -0
  235. package/src/lib/providers/p2p-native/p2p-native.provider.spec.ts +523 -0
  236. package/src/lib/providers/p2p-native/p2p-native.provider.ts +723 -0
  237. package/src/lib/providers/p2p-native/p2p-session-manager.ts +695 -0
  238. package/src/lib/providers/wallet-error-handler.ts +349 -0
  239. package/src/lib/providers/walletconnect/core/base-signer.interface.ts +122 -0
  240. package/src/lib/providers/walletconnect/core/session-health.ts +196 -0
  241. package/src/lib/providers/walletconnect/core/walletconnect-client-manager.ts +364 -0
  242. package/src/lib/providers/walletconnect/core/walletconnect-provider.integration.spec.ts +348 -0
  243. package/src/lib/providers/walletconnect/core/walletconnect-provider.ts +826 -0
  244. package/src/lib/providers/walletconnect/core/walletconnect-session-store.ts +273 -0
  245. package/src/lib/providers/walletconnect/core/walletconnect-signing-orchestrator.ts +299 -0
  246. package/src/lib/providers/walletconnect/core/walletconnect-types.ts +48 -0
  247. package/src/lib/providers/walletconnect/index.ts +33 -0
  248. package/src/lib/providers/walletconnect/signers/hedera-signer.spec.ts +367 -0
  249. package/src/lib/providers/walletconnect/signers/hedera-signer.ts +610 -0
  250. package/src/lib/providers/walletconnect/signers/signer-factory.spec.ts +62 -0
  251. package/src/lib/providers/walletconnect/signers/signer-factory.ts +120 -0
  252. package/src/lib/providers/walletconnect/signers/xrpl-signer.spec.ts +296 -0
  253. package/src/lib/providers/walletconnect/signers/xrpl-signer.ts +478 -0
  254. package/src/lib/services/logger.service.ts +126 -0
  255. package/src/lib/services/transaction-builders/base-transaction-builder.service.ts +585 -0
  256. package/src/lib/services/transaction-builders/hedera-amount-utils.ts +84 -0
  257. package/src/lib/services/transaction-builders/hedera-transaction-builder.service.spec.ts +741 -0
  258. package/src/lib/services/transaction-builders/hedera-transaction-builder.service.ts +1285 -0
  259. package/src/lib/services/transaction-builders/index.ts +54 -0
  260. package/src/lib/services/transaction-builders/xrpl-transaction-builder.service.spec.ts +937 -0
  261. package/src/lib/services/transaction-builders/xrpl-transaction-builder.service.ts +832 -0
  262. package/src/lib/services/transaction.service.ts +346 -0
  263. package/src/lib/services/unified-wallet.service.spec.ts +1382 -0
  264. package/src/lib/services/unified-wallet.service.ts +852 -0
  265. package/src/lib/services/wallet-context.service.ts +184 -0
  266. package/src/lib/services/wallet-event-bus.service.ts +186 -0
  267. package/src/lib/services/wallet-providers.service.ts +137 -0
  268. package/src/lib/transports/chrome-extension-transport.ts +246 -0
  269. package/src/lib/utils/index.ts +14 -0
  270. package/src/lib/utils/ledger-icons.util.ts +78 -0
  271. package/test/test-setup.ts +21 -0
  272. package/test-setup.ts +63 -0
  273. package/tsconfig.build.json +11 -0
  274. package/tsconfig.json +29 -0
  275. package/tsconfig.spec.json +15 -0
  276. package/vitest.config.ts +48 -0
@@ -0,0 +1,832 @@
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 Service for building XRPL (Ripple) transactions using the xrpl package.
13
+ *
14
+ * @module services/transaction-builders/xrpl
15
+ *
16
+ * @description
17
+ * XrplTransactionBuilderService provides methods to construct various XRPL transaction
18
+ * types and serialize them to base64 payloads ready for signing. It supports all major
19
+ * XRPL transaction types including payments, trust lines, DEX orders, escrows, payment
20
+ * channels, checks, and NFTs.
21
+ *
22
+ * **Supported Transaction Types:**
23
+ * - Payment - XRP and token transfers
24
+ * - TrustSet - Trust line creation/modification
25
+ * - OfferCreate/Cancel - DEX order management
26
+ * - AccountSet - Account configuration
27
+ * - EscrowCreate/Finish/Cancel - Escrow operations
28
+ * - PaymentChannel operations - Payment channels
29
+ * - Check operations - XRPL checks
30
+ * - DepositPreauth - Deposit preauthorization
31
+ * - SignerListSet - Multi-signature configuration
32
+ * - TicketCreate - Ticket creation
33
+ * - NFT operations - NFTokenMint, Burn, CreateOffer, etc.
34
+ * - Batch transactions - Multiple operations atomically
35
+ *
36
+ * **Amount Format:**
37
+ * - XRP amounts are in "drops" (1 XRP = 1,000,000 drops)
38
+ * - Token amounts use the IssuedCurrency format { currency, issuer, value }
39
+ */
40
+
41
+ import { Injectable } from '@angular/core';
42
+ import type {
43
+ Payment,
44
+ TrustSet,
45
+ OfferCreate,
46
+ OfferCancel,
47
+ AccountSet,
48
+ EscrowCreate,
49
+ EscrowFinish,
50
+ EscrowCancel,
51
+ PaymentChannelCreate,
52
+ PaymentChannelFund,
53
+ PaymentChannelClaim,
54
+ CheckCreate,
55
+ CheckCash,
56
+ CheckCancel,
57
+ DepositPreauth,
58
+ SignerListSet,
59
+ TicketCreate,
60
+ NFTokenMint,
61
+ NFTokenBurn,
62
+ NFTokenCreateOffer,
63
+ NFTokenAcceptOffer,
64
+ NFTokenCancelOffer,
65
+ Transaction,
66
+ } from 'xrpl';
67
+
68
+ /**
69
+ * Service for building XRPL (Ripple) transactions using the xrpl package.
70
+ *
71
+ * @service XrplTransactionBuilderService
72
+ *
73
+ * @description
74
+ * Provides methods to construct various XRPL transaction types and serialize them
75
+ * to base64 payloads ready for signing. All build methods return a base64-encoded
76
+ * JSON representation of the transaction.
77
+ *
78
+ * Unlike Hedera transactions which are frozen with a client, XRPL transactions
79
+ * are serialized as JSON and can be signed without network connection.
80
+ *
81
+ * @providedIn root
82
+ *
83
+ * @Component({ ... })
84
+ * export class SendPage {
85
+ * private builder = inject(XrplTransactionBuilderService);
86
+ * private wallet = inject(UnifiedWalletService);
87
+ *
88
+ * async sendXrp(to: string, drops: string) {
89
+ * const from = this.wallet.activeAccount()?.address;
90
+ * const payload = await this.builder.buildPayment(from!, to, drops);
91
+ * return this.wallet.submitTransaction({ payload });
92
+ * }
93
+ * }
94
+ * ```
95
+ */
96
+ @Injectable({
97
+ providedIn: 'root',
98
+ })
99
+ export class XrplTransactionBuilderService {
100
+ /**
101
+ * Builds a Payment transaction (XRP or token).
102
+ *
103
+ * @description
104
+ * Creates a Payment transaction that sends XRP or issued currency tokens
105
+ * from one account to another. For XRP, the amount is in drops (1 XRP = 1,000,000 drops).
106
+ *
107
+ * @param account - Source account address (r...)
108
+ * @param destination - Destination account address (r...)
109
+ * @param amount - Amount (XRP in drops, or token value string)
110
+ * @param isToken - Whether this is a token payment (default: false)
111
+ * @param currency - Token currency code (required if isToken)
112
+ * @param issuer - Token issuer address (required if isToken)
113
+ *
114
+ * @returns Base64 encoded transaction JSON
115
+ */
116
+ async buildPayment(
117
+ account: string,
118
+ destination: string,
119
+ amount: string,
120
+ isToken = false,
121
+ currency?: string,
122
+ issuer?: string,
123
+ ): Promise<string> {
124
+ const tx: Payment = {
125
+ TransactionType: 'Payment',
126
+ Account: account,
127
+ Destination: destination,
128
+ Amount:
129
+ isToken && currency && issuer
130
+ ? {
131
+ currency,
132
+ issuer,
133
+ value: amount,
134
+ }
135
+ : amount,
136
+ };
137
+
138
+ return this.serializeTransaction(tx);
139
+ }
140
+
141
+ /**
142
+ * Builds a TrustSet transaction to establish or modify a trust line.
143
+ *
144
+ * @description
145
+ * Creates a TrustSet transaction that establishes a trust line between
146
+ * your account and a token issuer. Trust lines are required before you
147
+ * can hold issued currency tokens on XRPL.
148
+ *
149
+ * @param account - Your account address (r...)
150
+ * @param currency - Currency code (e.g., 'USD', 'EUR', or hex code)
151
+ * @param issuer - Token issuer address (r...)
152
+ * @param limit - Maximum amount willing to hold (e.g., '1000000')
153
+ *
154
+ * @returns Base64 encoded transaction JSON
155
+ */
156
+ async buildTrustSet(
157
+ account: string,
158
+ currency: string,
159
+ issuer: string,
160
+ limit: string,
161
+ ): Promise<string> {
162
+ const tx: TrustSet = {
163
+ TransactionType: 'TrustSet',
164
+ Account: account,
165
+ LimitAmount: {
166
+ currency,
167
+ issuer,
168
+ value: limit,
169
+ },
170
+ };
171
+
172
+ return this.serializeTransaction(tx);
173
+ }
174
+
175
+ /**
176
+ * Build an OfferCreate transaction (DEX order)
177
+ * @param account - Account address
178
+ * @param takerPays - What taker pays (amount object or XRP drops)
179
+ * @param takerGets - What taker gets (amount object or XRP drops)
180
+ * @returns Base64 encoded transaction
181
+ */
182
+ async buildOfferCreate(
183
+ account: string,
184
+ takerPays: string | { currency: string; issuer: string; value: string },
185
+ takerGets: string | { currency: string; issuer: string; value: string },
186
+ ): Promise<string> {
187
+ const tx: OfferCreate = {
188
+ TransactionType: 'OfferCreate',
189
+ Account: account,
190
+ TakerPays: takerPays,
191
+ TakerGets: takerGets,
192
+ };
193
+
194
+ return this.serializeTransaction(tx);
195
+ }
196
+
197
+ /**
198
+ * Build an OfferCancel transaction
199
+ * @param account - Account address
200
+ * @param offerSequence - Sequence number of the offer to cancel
201
+ * @returns Base64 encoded transaction
202
+ */
203
+ async buildOfferCancel(account: string, offerSequence: number): Promise<string> {
204
+ const tx: OfferCancel = {
205
+ TransactionType: 'OfferCancel',
206
+ Account: account,
207
+ OfferSequence: offerSequence,
208
+ };
209
+
210
+ return this.serializeTransaction(tx);
211
+ }
212
+
213
+ /**
214
+ * Build an AccountSet transaction
215
+ * @param account - Account address
216
+ * @param options - Account set options (domain, emailHash, flags, etc.)
217
+ * @param options.domain
218
+ * @param options.emailHash
219
+ * @param options.messageKey
220
+ * @param options.transferRate
221
+ * @param options.tickSize
222
+ * @param options.setFlag
223
+ * @param options.clearFlag
224
+ * @returns Base64 encoded transaction
225
+ */
226
+ async buildAccountSet(
227
+ account: string,
228
+ options: {
229
+ domain?: string;
230
+ emailHash?: string;
231
+ messageKey?: string;
232
+ transferRate?: number;
233
+ tickSize?: number;
234
+ setFlag?: number;
235
+ clearFlag?: number;
236
+ },
237
+ ): Promise<string> {
238
+ const tx: AccountSet = {
239
+ TransactionType: 'AccountSet',
240
+ Account: account,
241
+ ...options,
242
+ };
243
+
244
+ return this.serializeTransaction(tx);
245
+ }
246
+
247
+ /**
248
+ * Build an EscrowCreate transaction
249
+ * @param account - Account address
250
+ * @param destination - Destination account
251
+ * @param amount - Amount in drops
252
+ * @param finishAfter - Ripple Epoch (seconds since 2000-01-01 UTC). Callers
253
+ * that hold Unix timestamps must convert first; an unmodified Unix value
254
+ * would put the escrow ~30 years in the future. The XRPL Time Utilities
255
+ * in `xrpl.js` expose helpers, or compute as `unixSeconds - 946684800`.
256
+ * @param cancelAfter - Optional. Same Ripple Epoch contract as finishAfter.
257
+ * @returns Base64 encoded transaction
258
+ */
259
+ async buildEscrowCreate(
260
+ account: string,
261
+ destination: string,
262
+ amount: string,
263
+ finishAfter: number,
264
+ cancelAfter?: number,
265
+ ): Promise<string> {
266
+ const tx: EscrowCreate = {
267
+ TransactionType: 'EscrowCreate',
268
+ Account: account,
269
+ Destination: destination,
270
+ Amount: amount,
271
+ FinishAfter: finishAfter,
272
+ ...(cancelAfter && { CancelAfter: cancelAfter }),
273
+ };
274
+
275
+ return this.serializeTransaction(tx);
276
+ }
277
+
278
+ /**
279
+ * Build an EscrowFinish transaction
280
+ * @param account - Account address
281
+ * @param owner - Escrow owner account
282
+ * @param offerSequence - Sequence number of EscrowCreate transaction
283
+ * @returns Base64 encoded transaction
284
+ */
285
+ async buildEscrowFinish(account: string, owner: string, offerSequence: number): Promise<string> {
286
+ const tx: EscrowFinish = {
287
+ TransactionType: 'EscrowFinish',
288
+ Account: account,
289
+ Owner: owner,
290
+ OfferSequence: offerSequence,
291
+ };
292
+
293
+ return this.serializeTransaction(tx);
294
+ }
295
+
296
+ /**
297
+ * Build an EscrowCancel transaction
298
+ * @param account - Account address
299
+ * @param owner - Escrow owner account
300
+ * @param offerSequence - Sequence number of EscrowCreate transaction
301
+ * @returns Base64 encoded transaction
302
+ */
303
+ async buildEscrowCancel(account: string, owner: string, offerSequence: number): Promise<string> {
304
+ const tx: EscrowCancel = {
305
+ TransactionType: 'EscrowCancel',
306
+ Account: account,
307
+ Owner: owner,
308
+ OfferSequence: offerSequence,
309
+ };
310
+
311
+ return this.serializeTransaction(tx);
312
+ }
313
+
314
+ /**
315
+ * Build a PaymentChannelCreate transaction
316
+ * @param account - Account address
317
+ * @param destination - Destination account
318
+ * @param amount - Amount in drops
319
+ * @param settleDelay - Settle delay in seconds
320
+ * @param publicKey - Public key for channel
321
+ * @returns Base64 encoded transaction
322
+ */
323
+ async buildPaymentChannelCreate(
324
+ account: string,
325
+ destination: string,
326
+ amount: string,
327
+ settleDelay: number,
328
+ publicKey: string,
329
+ ): Promise<string> {
330
+ const tx: PaymentChannelCreate = {
331
+ TransactionType: 'PaymentChannelCreate',
332
+ Account: account,
333
+ Destination: destination,
334
+ Amount: amount,
335
+ SettleDelay: settleDelay,
336
+ PublicKey: publicKey,
337
+ };
338
+
339
+ return this.serializeTransaction(tx);
340
+ }
341
+
342
+ /**
343
+ * Build a PaymentChannelFund transaction
344
+ * @param account - Account address
345
+ * @param channel - Channel ID
346
+ * @param amount - Amount in drops to add
347
+ * @returns Base64 encoded transaction
348
+ */
349
+ async buildPaymentChannelFund(account: string, channel: string, amount: string): Promise<string> {
350
+ const tx: PaymentChannelFund = {
351
+ TransactionType: 'PaymentChannelFund',
352
+ Account: account,
353
+ Channel: channel,
354
+ Amount: amount,
355
+ };
356
+
357
+ return this.serializeTransaction(tx);
358
+ }
359
+
360
+ /**
361
+ * Build a PaymentChannelClaim transaction
362
+ * @param account - Account address
363
+ * @param channel - Channel ID
364
+ * @param amount - Amount in drops to claim
365
+ * @returns Base64 encoded transaction
366
+ */
367
+ async buildPaymentChannelClaim(
368
+ account: string,
369
+ channel: string,
370
+ amount?: string,
371
+ ): Promise<string> {
372
+ const tx: PaymentChannelClaim = {
373
+ TransactionType: 'PaymentChannelClaim',
374
+ Account: account,
375
+ Channel: channel,
376
+ ...(amount && { Amount: amount }),
377
+ };
378
+
379
+ return this.serializeTransaction(tx);
380
+ }
381
+
382
+ /**
383
+ * Build a CheckCreate transaction
384
+ * @param account - Account address
385
+ * @param destination - Destination account
386
+ * @param sendMax - Maximum amount that can be cashed
387
+ * @returns Base64 encoded transaction
388
+ */
389
+ async buildCheckCreate(account: string, destination: string, sendMax: string): Promise<string> {
390
+ const tx: CheckCreate = {
391
+ TransactionType: 'CheckCreate',
392
+ Account: account,
393
+ Destination: destination,
394
+ SendMax: sendMax,
395
+ };
396
+
397
+ return this.serializeTransaction(tx);
398
+ }
399
+
400
+ /**
401
+ * Build a CheckCash transaction
402
+ * @param account - Account address
403
+ * @param checkID - Check ID to cash
404
+ * @param amount - Amount to cash (optional, uses DeliverMin if not provided)
405
+ * @param deliverMin - Minimum amount to deliver (optional)
406
+ * @returns Base64 encoded transaction
407
+ */
408
+ async buildCheckCash(
409
+ account: string,
410
+ checkID: string,
411
+ amount?: string,
412
+ deliverMin?: string,
413
+ ): Promise<string> {
414
+ const tx: CheckCash = {
415
+ TransactionType: 'CheckCash',
416
+ Account: account,
417
+ CheckID: checkID,
418
+ ...(amount && { Amount: amount }),
419
+ ...(deliverMin && { DeliverMin: deliverMin }),
420
+ };
421
+
422
+ return this.serializeTransaction(tx);
423
+ }
424
+
425
+ /**
426
+ * Build a CheckCancel transaction
427
+ * @param account - Account address
428
+ * @param checkID - Check ID to cancel
429
+ * @returns Base64 encoded transaction
430
+ */
431
+ async buildCheckCancel(account: string, checkID: string): Promise<string> {
432
+ const tx: CheckCancel = {
433
+ TransactionType: 'CheckCancel',
434
+ Account: account,
435
+ CheckID: checkID,
436
+ };
437
+
438
+ return this.serializeTransaction(tx);
439
+ }
440
+
441
+ /**
442
+ * Build a DepositPreauth transaction
443
+ * @param account - Account address
444
+ * @param authorize - Account to preauthorize (optional)
445
+ * @param unauthorize - Account to remove authorization (optional)
446
+ * @returns Base64 encoded transaction
447
+ */
448
+ async buildDepositPreauth(
449
+ account: string,
450
+ authorize?: string,
451
+ unauthorize?: string,
452
+ ): Promise<string> {
453
+ const tx: DepositPreauth = {
454
+ TransactionType: 'DepositPreauth',
455
+ Account: account,
456
+ ...(authorize && { Authorize: authorize }),
457
+ ...(unauthorize && { Unauthorize: unauthorize }),
458
+ };
459
+
460
+ return this.serializeTransaction(tx);
461
+ }
462
+
463
+ /**
464
+ * Build a SignerListSet transaction
465
+ * @param account - Account address
466
+ * @param signerQuorum - Required signature weight
467
+ * @param signerEntries - Array of signer entries
468
+ * @returns Base64 encoded transaction
469
+ */
470
+ async buildSignerListSet(
471
+ account: string,
472
+ signerQuorum: number,
473
+ signerEntries: Array<{ account: string; weight: number }>,
474
+ ): Promise<string> {
475
+ const tx: SignerListSet = {
476
+ TransactionType: 'SignerListSet',
477
+ Account: account,
478
+ SignerQuorum: signerQuorum,
479
+ SignerEntries: signerEntries.map((entry) => ({
480
+ SignerEntry: {
481
+ Account: entry.account,
482
+ SignerWeight: entry.weight,
483
+ },
484
+ })),
485
+ };
486
+
487
+ return this.serializeTransaction(tx);
488
+ }
489
+
490
+ /**
491
+ * Build a TicketCreate transaction
492
+ * @param account - Account address
493
+ * @param ticketCount - Number of tickets to create
494
+ * @returns Base64 encoded transaction
495
+ */
496
+ async buildTicketCreate(account: string, ticketCount: number): Promise<string> {
497
+ const tx: TicketCreate = {
498
+ TransactionType: 'TicketCreate',
499
+ Account: account,
500
+ TicketCount: ticketCount,
501
+ };
502
+
503
+ return this.serializeTransaction(tx);
504
+ }
505
+
506
+ /**
507
+ * Build an NFTokenMint transaction
508
+ * @param account - Account address
509
+ * @param uri - NFT URI (hex encoded)
510
+ * @param flags - NFT flags
511
+ * @param transferFee - Transfer fee in basis points
512
+ * @param taxon - NFT taxon
513
+ * @returns Base64 encoded transaction
514
+ */
515
+ async buildNFTMint(
516
+ account: string,
517
+ uri: string,
518
+ flags: number,
519
+ transferFee: number,
520
+ taxon: number,
521
+ ): Promise<string> {
522
+ const tx: NFTokenMint = {
523
+ TransactionType: 'NFTokenMint',
524
+ Account: account,
525
+ URI: uri,
526
+ Flags: flags,
527
+ TransferFee: transferFee,
528
+ NFTokenTaxon: taxon,
529
+ };
530
+
531
+ return this.serializeTransaction(tx);
532
+ }
533
+
534
+ /**
535
+ * Build an NFTokenBurn transaction
536
+ * @param account - Account address
537
+ * @param nftokenID - NFT ID to burn
538
+ * @returns Base64 encoded transaction
539
+ */
540
+ async buildNFTBurn(account: string, nftokenID: string): Promise<string> {
541
+ const tx: NFTokenBurn = {
542
+ TransactionType: 'NFTokenBurn',
543
+ Account: account,
544
+ NFTokenID: nftokenID,
545
+ };
546
+
547
+ return this.serializeTransaction(tx);
548
+ }
549
+
550
+ /**
551
+ * Build an NFTokenCreateOffer transaction
552
+ * @param account - Account address
553
+ * @param nftokenID - NFT ID
554
+ * @param amount - Offer amount
555
+ * @param flags - Offer flags (1=sell, 0=buy)
556
+ * @param destination - Optional destination account
557
+ * @returns Base64 encoded transaction
558
+ */
559
+ async buildNFTCreateOffer(
560
+ account: string,
561
+ nftokenID: string,
562
+ amount: string,
563
+ flags: number,
564
+ destination?: string,
565
+ ): Promise<string> {
566
+ const tx: NFTokenCreateOffer = {
567
+ TransactionType: 'NFTokenCreateOffer',
568
+ Account: account,
569
+ NFTokenID: nftokenID,
570
+ Amount: amount,
571
+ Flags: flags,
572
+ ...(destination && { Destination: destination }),
573
+ };
574
+
575
+ return this.serializeTransaction(tx);
576
+ }
577
+
578
+ /**
579
+ * Build an NFTokenAcceptOffer transaction
580
+ * @param account - Account address
581
+ * @param nftokenSellOffer - Sell offer ID (optional)
582
+ * @param nftokenBuyOffer - Buy offer ID (optional)
583
+ * @returns Base64 encoded transaction
584
+ */
585
+ async buildNFTAcceptOffer(
586
+ account: string,
587
+ nftokenSellOffer?: string,
588
+ nftokenBuyOffer?: string,
589
+ ): Promise<string> {
590
+ const tx: NFTokenAcceptOffer = {
591
+ TransactionType: 'NFTokenAcceptOffer',
592
+ Account: account,
593
+ ...(nftokenSellOffer && { NFTokenSellOffer: nftokenSellOffer }),
594
+ ...(nftokenBuyOffer && { NFTokenBuyOffer: nftokenBuyOffer }),
595
+ };
596
+
597
+ return this.serializeTransaction(tx);
598
+ }
599
+
600
+ /**
601
+ * Build an NFTokenCancelOffer transaction
602
+ * @param account - Account address
603
+ * @param nftokenOffers - Array of offer IDs to cancel
604
+ * @returns Base64 encoded transaction
605
+ */
606
+ async buildNFTCancelOffer(account: string, nftokenOffers: string[]): Promise<string> {
607
+ const tx: NFTokenCancelOffer = {
608
+ TransactionType: 'NFTokenCancelOffer',
609
+ Account: account,
610
+ NFTokenOffers: nftokenOffers,
611
+ };
612
+
613
+ return this.serializeTransaction(tx);
614
+ }
615
+
616
+ /**
617
+ * Build a Batch transaction with multiple inner transactions
618
+ * @param account - Account executing the batch
619
+ * @param innerTransactions - Array of transaction descriptors
620
+ * @returns Base64 encoded batch transaction JSON
621
+ */
622
+ async buildBatchTransaction(
623
+ account: string,
624
+ innerTransactions: Array<{
625
+ type: 'payment' | 'trust-set' | 'nft-mint';
626
+ destination?: string;
627
+ amount?: string;
628
+ currency?: string;
629
+ issuer?: string;
630
+ }>,
631
+ ): Promise<string> {
632
+ const tfInnerBatchTxn = 1073741824;
633
+ const tfAllOrNothing = 65536;
634
+
635
+ const rawTransactions = innerTransactions.map((tx, index) => {
636
+ let innerTx: any;
637
+
638
+ switch (tx.type) {
639
+ case 'payment':
640
+ innerTx = {
641
+ TransactionType: 'Payment',
642
+ Flags: tfInnerBatchTxn,
643
+ Account: account,
644
+ Destination: tx.destination || '',
645
+ Amount: tx.amount || '1000000',
646
+ Fee: '0',
647
+ Sequence: index + 1,
648
+ SigningPubKey: '',
649
+ };
650
+
651
+ if (tx.currency && tx.issuer) {
652
+ innerTx.Amount = {
653
+ currency: tx.currency,
654
+ issuer: tx.issuer,
655
+ value: tx.amount || '1',
656
+ };
657
+ }
658
+ break;
659
+
660
+ case 'trust-set':
661
+ innerTx = {
662
+ TransactionType: 'TrustSet',
663
+ Flags: tfInnerBatchTxn,
664
+ Account: account,
665
+ LimitAmount: {
666
+ currency: tx.currency || 'USD',
667
+ issuer: tx.issuer || '',
668
+ value: tx.amount || '1000000',
669
+ },
670
+ Fee: '0',
671
+ Sequence: index + 1,
672
+ SigningPubKey: '',
673
+ };
674
+ break;
675
+
676
+ case 'nft-mint':
677
+ innerTx = {
678
+ TransactionType: 'NFTokenMint',
679
+ Flags: tfInnerBatchTxn,
680
+ Account: account,
681
+ NFTokenTaxon: 0,
682
+ Fee: '0',
683
+ Sequence: index + 1,
684
+ SigningPubKey: '',
685
+ };
686
+ break;
687
+
688
+ default:
689
+ innerTx = {
690
+ TransactionType: 'Payment',
691
+ Flags: tfInnerBatchTxn,
692
+ Account: account,
693
+ Destination: account,
694
+ Amount: '1',
695
+ Fee: '0',
696
+ Sequence: index + 1,
697
+ SigningPubKey: '',
698
+ };
699
+ }
700
+
701
+ return { RawTransaction: innerTx };
702
+ });
703
+
704
+ const batchTx = {
705
+ TransactionType: 'Batch',
706
+ Account: account,
707
+ Flags: tfAllOrNothing,
708
+ RawTransactions: rawTransactions,
709
+ };
710
+
711
+ return this.serializeTransaction(batchTx as any);
712
+ }
713
+
714
+ /**
715
+ * Build inner transactions for batch (unsigned, with batch flags set)
716
+ * @param account - Account executing the batch
717
+ * @param innerTransactions - Array of transaction descriptors
718
+ * @returns Array of base64 encoded unsigned inner transactions
719
+ */
720
+ async buildBatchInnerTransactions(
721
+ account: string,
722
+ innerTransactions: Array<{
723
+ type: 'payment' | 'trust-set' | 'nft-mint';
724
+ destination?: string;
725
+ amount?: string;
726
+ currency?: string;
727
+ issuer?: string;
728
+ uri?: string;
729
+ taxon?: number;
730
+ }>,
731
+ ): Promise<Array<{ payload: string; description: string }>> {
732
+ const tfInnerBatchTxn = 1073741824;
733
+ const results: Array<{ payload: string; description: string }> = [];
734
+
735
+ for (let index = 0; index < innerTransactions.length; index++) {
736
+ const tx = innerTransactions[index];
737
+ let innerTx: any;
738
+ let description: string;
739
+
740
+ switch (tx.type) {
741
+ case 'payment':
742
+ if (tx.currency && tx.issuer) {
743
+ innerTx = {
744
+ TransactionType: 'Payment',
745
+ Flags: tfInnerBatchTxn,
746
+ Account: account,
747
+ Destination: tx.destination || '',
748
+ Amount: {
749
+ currency: tx.currency,
750
+ issuer: tx.issuer,
751
+ value: tx.amount || '1',
752
+ },
753
+ Fee: '0',
754
+ Sequence: index + 1,
755
+ SigningPubKey: '',
756
+ };
757
+ description = `Send ${tx.amount} ${tx.currency} to ${tx.destination}`;
758
+ } else {
759
+ innerTx = {
760
+ TransactionType: 'Payment',
761
+ Flags: tfInnerBatchTxn,
762
+ Account: account,
763
+ Destination: tx.destination || '',
764
+ Amount: tx.amount || '1000000',
765
+ Fee: '0',
766
+ Sequence: index + 1,
767
+ SigningPubKey: '',
768
+ };
769
+ description = `Send ${Number(tx.amount || '1000000') / 1000000} XRP to ${tx.destination}`;
770
+ }
771
+ break;
772
+
773
+ case 'trust-set':
774
+ innerTx = {
775
+ TransactionType: 'TrustSet',
776
+ Flags: tfInnerBatchTxn,
777
+ Account: account,
778
+ LimitAmount: {
779
+ currency: tx.currency || 'USD',
780
+ issuer: tx.issuer || '',
781
+ value: tx.amount || '1000000',
782
+ },
783
+ Fee: '0',
784
+ Sequence: index + 1,
785
+ SigningPubKey: '',
786
+ };
787
+ description = `Set trust line for ${tx.currency} (${tx.amount})`;
788
+ break;
789
+
790
+ case 'nft-mint':
791
+ innerTx = {
792
+ TransactionType: 'NFTokenMint',
793
+ Flags: tfInnerBatchTxn,
794
+ Account: account,
795
+ URI: tx.uri || '',
796
+ NFTokenTaxon: tx.taxon || 0,
797
+ Fee: '0',
798
+ Sequence: index + 1,
799
+ SigningPubKey: '',
800
+ };
801
+ description = `Mint NFT (taxon: ${tx.taxon})`;
802
+ break;
803
+
804
+ default:
805
+ throw new Error(`Unknown transaction type: ${(tx as any).type}`);
806
+ }
807
+
808
+ results.push({
809
+ payload: btoa(JSON.stringify(innerTx)),
810
+ description,
811
+ });
812
+ }
813
+
814
+ return results;
815
+ }
816
+
817
+ /**
818
+ * Serializes a transaction to base64 encoded JSON.
819
+ *
820
+ * @description
821
+ * Converts the transaction object to a JSON string and encodes it as base64.
822
+ * This format is used for transport to the wallet for signing.
823
+ *
824
+ * @param transaction - The XRPL transaction object
825
+ *
826
+ * @returns Base64 encoded JSON string
827
+ */
828
+ private async serializeTransaction(transaction: Transaction): Promise<string> {
829
+ const jsonString = JSON.stringify(transaction);
830
+ return btoa(jsonString);
831
+ }
832
+ }