@ledgerhq/live-common 34.45.0-nightly.0 → 34.45.0-nightly.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 (298) hide show
  1. package/lib/__tests__/test-helpers/bridge.d.ts.map +1 -1
  2. package/lib/__tests__/test-helpers/bridge.js +3 -1
  3. package/lib/__tests__/test-helpers/bridge.js.map +1 -1
  4. package/lib/braze/anonymousUsers.d.ts +1 -0
  5. package/lib/braze/anonymousUsers.d.ts.map +1 -1
  6. package/lib/braze/anonymousUsers.js +7 -5
  7. package/lib/braze/anonymousUsers.js.map +1 -1
  8. package/lib/bridge/generic-alpaca/accountBridge.d.ts +1 -1
  9. package/lib/bridge/generic-alpaca/accountBridge.d.ts.map +1 -1
  10. package/lib/bridge/generic-alpaca/accountBridge.js.map +1 -1
  11. package/lib/bridge/generic-alpaca/alpaca/index.d.ts +1 -1
  12. package/lib/bridge/generic-alpaca/alpaca/index.d.ts.map +1 -1
  13. package/lib/bridge/generic-alpaca/alpaca/index.js +4 -2
  14. package/lib/bridge/generic-alpaca/alpaca/index.js.map +1 -1
  15. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +4 -4
  16. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
  17. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js +10 -10
  18. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
  19. package/lib/bridge/generic-alpaca/broadcast.d.ts +1 -1
  20. package/lib/bridge/generic-alpaca/broadcast.d.ts.map +1 -1
  21. package/lib/bridge/generic-alpaca/broadcast.js.map +1 -1
  22. package/lib/bridge/generic-alpaca/buildSubAccounts.d.ts +17 -0
  23. package/lib/bridge/generic-alpaca/buildSubAccounts.d.ts.map +1 -0
  24. package/lib/bridge/generic-alpaca/buildSubAccounts.js +75 -0
  25. package/lib/bridge/generic-alpaca/buildSubAccounts.js.map +1 -0
  26. package/lib/bridge/generic-alpaca/createTransaction.d.ts +17 -9
  27. package/lib/bridge/generic-alpaca/createTransaction.d.ts.map +1 -1
  28. package/lib/bridge/generic-alpaca/createTransaction.js +36 -10
  29. package/lib/bridge/generic-alpaca/createTransaction.js.map +1 -1
  30. package/lib/bridge/generic-alpaca/currencyBridge.d.ts +1 -1
  31. package/lib/bridge/generic-alpaca/currencyBridge.d.ts.map +1 -1
  32. package/lib/bridge/generic-alpaca/currencyBridge.js.map +1 -1
  33. package/lib/bridge/generic-alpaca/estimateMaxSpendable.d.ts +1 -1
  34. package/lib/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -1
  35. package/lib/bridge/generic-alpaca/estimateMaxSpendable.js +9 -0
  36. package/lib/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -1
  37. package/lib/bridge/generic-alpaca/getAccountShape.d.ts +1 -1
  38. package/lib/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
  39. package/lib/bridge/generic-alpaca/getAccountShape.js +66 -37
  40. package/lib/bridge/generic-alpaca/getAccountShape.js.map +1 -1
  41. package/lib/bridge/generic-alpaca/getTransactionStatus.d.ts +1 -1
  42. package/lib/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
  43. package/lib/bridge/generic-alpaca/getTransactionStatus.js +27 -15
  44. package/lib/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
  45. package/lib/bridge/generic-alpaca/prepareTransaction.d.ts +5 -1
  46. package/lib/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
  47. package/lib/bridge/generic-alpaca/prepareTransaction.js +28 -5
  48. package/lib/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
  49. package/lib/bridge/generic-alpaca/signOperation.d.ts +1 -1
  50. package/lib/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
  51. package/lib/bridge/generic-alpaca/signOperation.js +64 -13
  52. package/lib/bridge/generic-alpaca/signOperation.js.map +1 -1
  53. package/lib/bridge/generic-alpaca/signer/index.d.ts +1 -1
  54. package/lib/bridge/generic-alpaca/signer/index.d.ts.map +1 -1
  55. package/lib/bridge/generic-alpaca/signer/index.js +38 -5
  56. package/lib/bridge/generic-alpaca/signer/index.js.map +1 -1
  57. package/lib/bridge/generic-alpaca/signer/signTransaction.d.ts +2 -0
  58. package/lib/bridge/generic-alpaca/signer/signTransaction.d.ts.map +1 -1
  59. package/lib/bridge/generic-alpaca/signer/signTransaction.js +8 -1
  60. package/lib/bridge/generic-alpaca/signer/signTransaction.js.map +1 -1
  61. package/lib/bridge/generic-alpaca/signer/types.d.ts +3 -0
  62. package/lib/bridge/generic-alpaca/signer/types.d.ts.map +1 -1
  63. package/lib/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js +70 -46
  64. package/lib/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js.map +1 -1
  65. package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.js +1 -1
  66. package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.js.map +1 -1
  67. package/lib/bridge/generic-alpaca/tests/signOperation.test.js +25 -22
  68. package/lib/bridge/generic-alpaca/tests/signOperation.test.js.map +1 -1
  69. package/lib/bridge/generic-alpaca/tests/utils.test.d.ts.map +1 -0
  70. package/lib/bridge/generic-alpaca/{utils.test.js → tests/utils.test.js} +1 -1
  71. package/lib/bridge/generic-alpaca/tests/utils.test.js.map +1 -0
  72. package/lib/bridge/generic-alpaca/utils.d.ts +36 -1
  73. package/lib/bridge/generic-alpaca/utils.d.ts.map +1 -1
  74. package/lib/bridge/generic-alpaca/utils.js +130 -14
  75. package/lib/bridge/generic-alpaca/utils.js.map +1 -1
  76. package/lib/bridge/impl.d.ts.map +1 -1
  77. package/lib/bridge/impl.js +5 -4
  78. package/lib/bridge/impl.js.map +1 -1
  79. package/lib/e2e/enum/Account.js +4 -4
  80. package/lib/e2e/enum/Account.js.map +1 -1
  81. package/lib/e2e/enum/AppInfos.d.ts +1 -1
  82. package/lib/e2e/enum/AppInfos.d.ts.map +1 -1
  83. package/lib/e2e/enum/AppInfos.js +1 -1
  84. package/lib/e2e/enum/AppInfos.js.map +1 -1
  85. package/lib/e2e/enum/Currency.d.ts.map +1 -1
  86. package/lib/e2e/enum/Currency.js +3 -3
  87. package/lib/e2e/enum/Currency.js.map +1 -1
  88. package/lib/e2e/speculos.js +2 -2
  89. package/lib/e2e/speculos.js.map +1 -1
  90. package/lib/exchange/index.d.ts.map +1 -1
  91. package/lib/exchange/index.js +1 -0
  92. package/lib/exchange/index.js.map +1 -1
  93. package/lib/families/stellar/bridge/logic.d.ts +1 -1
  94. package/lib/families/stellar/bridge/logic.d.ts.map +1 -1
  95. package/lib/families/stellar/bridge/logic.js +1 -1
  96. package/lib/families/stellar/bridge/logic.js.map +1 -1
  97. package/lib/families/stellar/bridge/mock.js +2 -2
  98. package/lib/families/stellar/bridge/mock.js.map +1 -1
  99. package/lib/families/stellar/setup.d.ts +3 -6
  100. package/lib/families/stellar/setup.d.ts.map +1 -1
  101. package/lib/families/stellar/setup.js +3 -12
  102. package/lib/families/stellar/setup.js.map +1 -1
  103. package/lib/families/xrp/bridge/mock.js +2 -2
  104. package/lib/families/xrp/bridge/mock.js.map +1 -1
  105. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  106. package/lib/featureFlags/defaultFeatures.js +4 -2
  107. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  108. package/lib/generated/bridge/js.d.ts +0 -1
  109. package/lib/generated/bridge/js.d.ts.map +1 -1
  110. package/lib/generated/bridge/js.js +12 -14
  111. package/lib/generated/bridge/js.js.map +1 -1
  112. package/lib/generated/transaction.d.ts +1 -1
  113. package/lib/modularDrawer/__test__/useModularDrawerVisibility.test.js +229 -14
  114. package/lib/modularDrawer/__test__/useModularDrawerVisibility.test.js.map +1 -1
  115. package/lib/modularDrawer/enums.d.ts +0 -1
  116. package/lib/modularDrawer/enums.d.ts.map +1 -1
  117. package/lib/modularDrawer/enums.js +0 -1
  118. package/lib/modularDrawer/enums.js.map +1 -1
  119. package/lib/modularDrawer/useModularDrawerVisibility.d.ts +7 -1
  120. package/lib/modularDrawer/useModularDrawerVisibility.d.ts.map +1 -1
  121. package/lib/modularDrawer/useModularDrawerVisibility.js +18 -2
  122. package/lib/modularDrawer/useModularDrawerVisibility.js.map +1 -1
  123. package/lib-es/__tests__/test-helpers/bridge.d.ts.map +1 -1
  124. package/lib-es/__tests__/test-helpers/bridge.js +3 -1
  125. package/lib-es/__tests__/test-helpers/bridge.js.map +1 -1
  126. package/lib-es/braze/anonymousUsers.d.ts +1 -0
  127. package/lib-es/braze/anonymousUsers.d.ts.map +1 -1
  128. package/lib-es/braze/anonymousUsers.js +5 -4
  129. package/lib-es/braze/anonymousUsers.js.map +1 -1
  130. package/lib-es/bridge/generic-alpaca/accountBridge.d.ts +1 -1
  131. package/lib-es/bridge/generic-alpaca/accountBridge.d.ts.map +1 -1
  132. package/lib-es/bridge/generic-alpaca/accountBridge.js.map +1 -1
  133. package/lib-es/bridge/generic-alpaca/alpaca/index.d.ts +1 -1
  134. package/lib-es/bridge/generic-alpaca/alpaca/index.d.ts.map +1 -1
  135. package/lib-es/bridge/generic-alpaca/alpaca/index.js +4 -2
  136. package/lib-es/bridge/generic-alpaca/alpaca/index.js.map +1 -1
  137. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +4 -4
  138. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +1 -1
  139. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js +10 -10
  140. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +1 -1
  141. package/lib-es/bridge/generic-alpaca/broadcast.d.ts +1 -1
  142. package/lib-es/bridge/generic-alpaca/broadcast.d.ts.map +1 -1
  143. package/lib-es/bridge/generic-alpaca/broadcast.js.map +1 -1
  144. package/lib-es/bridge/generic-alpaca/buildSubAccounts.d.ts +17 -0
  145. package/lib-es/bridge/generic-alpaca/buildSubAccounts.d.ts.map +1 -0
  146. package/lib-es/bridge/generic-alpaca/buildSubAccounts.js +65 -0
  147. package/lib-es/bridge/generic-alpaca/buildSubAccounts.js.map +1 -0
  148. package/lib-es/bridge/generic-alpaca/createTransaction.d.ts +17 -9
  149. package/lib-es/bridge/generic-alpaca/createTransaction.d.ts.map +1 -1
  150. package/lib-es/bridge/generic-alpaca/createTransaction.js +35 -9
  151. package/lib-es/bridge/generic-alpaca/createTransaction.js.map +1 -1
  152. package/lib-es/bridge/generic-alpaca/currencyBridge.d.ts +1 -1
  153. package/lib-es/bridge/generic-alpaca/currencyBridge.d.ts.map +1 -1
  154. package/lib-es/bridge/generic-alpaca/currencyBridge.js.map +1 -1
  155. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.d.ts +1 -1
  156. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +1 -1
  157. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js +9 -0
  158. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js.map +1 -1
  159. package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts +1 -1
  160. package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts.map +1 -1
  161. package/lib-es/bridge/generic-alpaca/getAccountShape.js +66 -37
  162. package/lib-es/bridge/generic-alpaca/getAccountShape.js.map +1 -1
  163. package/lib-es/bridge/generic-alpaca/getTransactionStatus.d.ts +1 -1
  164. package/lib-es/bridge/generic-alpaca/getTransactionStatus.d.ts.map +1 -1
  165. package/lib-es/bridge/generic-alpaca/getTransactionStatus.js +27 -15
  166. package/lib-es/bridge/generic-alpaca/getTransactionStatus.js.map +1 -1
  167. package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts +5 -1
  168. package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts.map +1 -1
  169. package/lib-es/bridge/generic-alpaca/prepareTransaction.js +26 -4
  170. package/lib-es/bridge/generic-alpaca/prepareTransaction.js.map +1 -1
  171. package/lib-es/bridge/generic-alpaca/signOperation.d.ts +1 -1
  172. package/lib-es/bridge/generic-alpaca/signOperation.d.ts.map +1 -1
  173. package/lib-es/bridge/generic-alpaca/signOperation.js +61 -13
  174. package/lib-es/bridge/generic-alpaca/signOperation.js.map +1 -1
  175. package/lib-es/bridge/generic-alpaca/signer/index.d.ts +1 -1
  176. package/lib-es/bridge/generic-alpaca/signer/index.d.ts.map +1 -1
  177. package/lib-es/bridge/generic-alpaca/signer/index.js +39 -6
  178. package/lib-es/bridge/generic-alpaca/signer/index.js.map +1 -1
  179. package/lib-es/bridge/generic-alpaca/signer/signTransaction.d.ts +2 -0
  180. package/lib-es/bridge/generic-alpaca/signer/signTransaction.d.ts.map +1 -1
  181. package/lib-es/bridge/generic-alpaca/signer/signTransaction.js +6 -0
  182. package/lib-es/bridge/generic-alpaca/signer/signTransaction.js.map +1 -1
  183. package/lib-es/bridge/generic-alpaca/signer/types.d.ts +3 -0
  184. package/lib-es/bridge/generic-alpaca/signer/types.d.ts.map +1 -1
  185. package/lib-es/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js +70 -46
  186. package/lib-es/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js.map +1 -1
  187. package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.js +1 -1
  188. package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.js.map +1 -1
  189. package/lib-es/bridge/generic-alpaca/tests/signOperation.test.js +25 -22
  190. package/lib-es/bridge/generic-alpaca/tests/signOperation.test.js.map +1 -1
  191. package/lib-es/bridge/generic-alpaca/tests/utils.test.d.ts.map +1 -0
  192. package/lib-es/bridge/generic-alpaca/{utils.test.js → tests/utils.test.js} +1 -1
  193. package/lib-es/bridge/generic-alpaca/tests/utils.test.js.map +1 -0
  194. package/lib-es/bridge/generic-alpaca/utils.d.ts +36 -1
  195. package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -1
  196. package/lib-es/bridge/generic-alpaca/utils.js +130 -14
  197. package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
  198. package/lib-es/bridge/impl.d.ts.map +1 -1
  199. package/lib-es/bridge/impl.js +5 -4
  200. package/lib-es/bridge/impl.js.map +1 -1
  201. package/lib-es/e2e/enum/Account.js +4 -4
  202. package/lib-es/e2e/enum/Account.js.map +1 -1
  203. package/lib-es/e2e/enum/AppInfos.d.ts +1 -1
  204. package/lib-es/e2e/enum/AppInfos.d.ts.map +1 -1
  205. package/lib-es/e2e/enum/AppInfos.js +1 -1
  206. package/lib-es/e2e/enum/AppInfos.js.map +1 -1
  207. package/lib-es/e2e/enum/Currency.d.ts.map +1 -1
  208. package/lib-es/e2e/enum/Currency.js +3 -3
  209. package/lib-es/e2e/enum/Currency.js.map +1 -1
  210. package/lib-es/e2e/speculos.js +2 -2
  211. package/lib-es/e2e/speculos.js.map +1 -1
  212. package/lib-es/exchange/index.d.ts.map +1 -1
  213. package/lib-es/exchange/index.js +1 -0
  214. package/lib-es/exchange/index.js.map +1 -1
  215. package/lib-es/families/stellar/bridge/logic.d.ts +1 -1
  216. package/lib-es/families/stellar/bridge/logic.d.ts.map +1 -1
  217. package/lib-es/families/stellar/bridge/logic.js +1 -1
  218. package/lib-es/families/stellar/bridge/logic.js.map +1 -1
  219. package/lib-es/families/stellar/bridge/mock.js +2 -2
  220. package/lib-es/families/stellar/bridge/mock.js.map +1 -1
  221. package/lib-es/families/stellar/setup.d.ts +3 -6
  222. package/lib-es/families/stellar/setup.d.ts.map +1 -1
  223. package/lib-es/families/stellar/setup.js +2 -10
  224. package/lib-es/families/stellar/setup.js.map +1 -1
  225. package/lib-es/families/xrp/bridge/mock.js +2 -2
  226. package/lib-es/families/xrp/bridge/mock.js.map +1 -1
  227. package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
  228. package/lib-es/featureFlags/defaultFeatures.js +4 -2
  229. package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
  230. package/lib-es/generated/bridge/js.d.ts +0 -1
  231. package/lib-es/generated/bridge/js.d.ts.map +1 -1
  232. package/lib-es/generated/bridge/js.js +0 -2
  233. package/lib-es/generated/bridge/js.js.map +1 -1
  234. package/lib-es/generated/transaction.d.ts +1 -1
  235. package/lib-es/modularDrawer/__test__/useModularDrawerVisibility.test.js +229 -14
  236. package/lib-es/modularDrawer/__test__/useModularDrawerVisibility.test.js.map +1 -1
  237. package/lib-es/modularDrawer/enums.d.ts +0 -1
  238. package/lib-es/modularDrawer/enums.d.ts.map +1 -1
  239. package/lib-es/modularDrawer/enums.js +0 -1
  240. package/lib-es/modularDrawer/enums.js.map +1 -1
  241. package/lib-es/modularDrawer/useModularDrawerVisibility.d.ts +7 -1
  242. package/lib-es/modularDrawer/useModularDrawerVisibility.d.ts.map +1 -1
  243. package/lib-es/modularDrawer/useModularDrawerVisibility.js +18 -2
  244. package/lib-es/modularDrawer/useModularDrawerVisibility.js.map +1 -1
  245. package/package.json +49 -48
  246. package/src/__tests__/test-helpers/bridge.ts +3 -1
  247. package/src/braze/anonymousUsers.ts +7 -4
  248. package/src/bridge/generic-alpaca/accountBridge.ts +1 -4
  249. package/src/bridge/generic-alpaca/alpaca/index.ts +7 -2
  250. package/src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts +17 -22
  251. package/src/bridge/generic-alpaca/broadcast.ts +1 -4
  252. package/src/bridge/generic-alpaca/buildSubAccounts.ts +110 -0
  253. package/src/bridge/generic-alpaca/createTransaction.ts +48 -18
  254. package/src/bridge/generic-alpaca/currencyBridge.ts +1 -1
  255. package/src/bridge/generic-alpaca/estimateMaxSpendable.ts +13 -4
  256. package/src/bridge/generic-alpaca/getAccountShape.ts +84 -46
  257. package/src/bridge/generic-alpaca/getTransactionStatus.ts +46 -22
  258. package/src/bridge/generic-alpaca/prepareTransaction.ts +41 -7
  259. package/src/bridge/generic-alpaca/signOperation.ts +85 -18
  260. package/src/bridge/generic-alpaca/signer/index.ts +43 -7
  261. package/src/bridge/generic-alpaca/signer/signTransaction.ts +11 -0
  262. package/src/bridge/generic-alpaca/signer/types.ts +1 -0
  263. package/src/bridge/generic-alpaca/tests/estimateMaxSpendable.test.ts +72 -47
  264. package/src/bridge/generic-alpaca/tests/prepareTransaction.test.ts +1 -1
  265. package/src/bridge/generic-alpaca/tests/signOperation.test.ts +28 -26
  266. package/src/bridge/generic-alpaca/{utils.test.ts → tests/utils.test.ts} +1 -1
  267. package/src/bridge/generic-alpaca/utils.ts +158 -18
  268. package/src/bridge/impl.ts +5 -4
  269. package/src/e2e/enum/Account.ts +4 -4
  270. package/src/e2e/enum/AppInfos.ts +1 -1
  271. package/src/e2e/enum/Currency.ts +3 -13
  272. package/src/e2e/speculos.ts +2 -2
  273. package/src/exchange/index.ts +1 -0
  274. package/src/families/stellar/__snapshots__/bridge.integration.test.ts.snap +569 -2068
  275. package/src/families/stellar/bridge/logic.ts +1 -1
  276. package/src/families/stellar/bridge/mock.ts +2 -2
  277. package/src/families/stellar/setup.ts +2 -22
  278. package/src/families/xrp/bridge/mock.ts +2 -2
  279. package/src/featureFlags/defaultFeatures.ts +4 -2
  280. package/src/generated/bridge/js.ts +0 -2
  281. package/src/modularDrawer/__test__/useModularDrawerVisibility.test.ts +345 -14
  282. package/src/modularDrawer/enums.ts +0 -1
  283. package/src/modularDrawer/useModularDrawerVisibility.ts +26 -2
  284. package/lib/bridge/generic-alpaca/utils.test.d.ts.map +0 -1
  285. package/lib/bridge/generic-alpaca/utils.test.js.map +0 -1
  286. package/lib/families/canton/bridge.integration.test.d.ts +0 -2
  287. package/lib/families/canton/bridge.integration.test.d.ts.map +0 -1
  288. package/lib/families/canton/bridge.integration.test.js +0 -7
  289. package/lib/families/canton/bridge.integration.test.js.map +0 -1
  290. package/lib-es/bridge/generic-alpaca/utils.test.d.ts.map +0 -1
  291. package/lib-es/bridge/generic-alpaca/utils.test.js.map +0 -1
  292. package/lib-es/families/canton/bridge.integration.test.d.ts +0 -2
  293. package/lib-es/families/canton/bridge.integration.test.d.ts.map +0 -1
  294. package/lib-es/families/canton/bridge.integration.test.js +0 -5
  295. package/lib-es/families/canton/bridge.integration.test.js.map +0 -1
  296. package/src/families/canton/bridge.integration.test.ts +0 -6
  297. /package/lib/bridge/generic-alpaca/{utils.test.d.ts → tests/utils.test.d.ts} +0 -0
  298. /package/lib-es/bridge/generic-alpaca/{utils.test.d.ts → tests/utils.test.d.ts} +0 -0
@@ -2,6 +2,7 @@ import { Account, AccountBridge, TransactionCommon } from "@ledgerhq/types-live"
2
2
  import { getAlpacaApi } from "./alpaca";
3
3
  import { transactionToIntent } from "./utils";
4
4
  import BigNumber from "bignumber.js";
5
+ import { NetworkInfo } from "./createTransaction";
5
6
 
6
7
  function bnEq(a: BigNumber | null | undefined, b: BigNumber | null | undefined): boolean {
7
8
  return !a && !b ? true : !a || !b ? false : a.eq(b);
@@ -9,18 +10,51 @@ function bnEq(a: BigNumber | null | undefined, b: BigNumber | null | undefined):
9
10
 
10
11
  export function genericPrepareTransaction(
11
12
  network: string,
12
- kind: "local" | "remote",
13
+ kind,
13
14
  ): AccountBridge<TransactionCommon, Account, any, any>["prepareTransaction"] {
14
- return async (account, transaction: TransactionCommon & { fees: BigNumber }) => {
15
+ return async (
16
+ account,
17
+ transaction: TransactionCommon & {
18
+ fees: BigNumber | null | undefined;
19
+ assetReference?: string;
20
+ assetOwner?: string;
21
+ subAccountId?: string;
22
+ networkInfo?: NetworkInfo | null;
23
+ },
24
+ ) => {
25
+ const [assetReference, assetOwner] = getAssetInfos(transaction);
15
26
  const fees = await getAlpacaApi(network, kind).estimateFees(
16
- transactionToIntent(account, transaction),
27
+ transactionToIntent(account, {
28
+ ...transaction,
29
+ fees: transaction.fees ? BigInt(transaction.fees.toString()) : 0n,
30
+ }),
17
31
  );
18
- const bnFee = BigNumber(fees.value.toString());
19
-
20
- if (!bnEq(transaction.fees, bnFee)) {
21
- return { ...transaction, fees: bnFee };
32
+ // NOTE: this is problematic, we should maybe have a method / object that lists what field warrant an update per chain
33
+ // for reference, stellar checked this:
34
+ // transaction.networkInfo !== networkInfo ||
35
+ // transaction.baseReserve !== baseReserve
36
+ if (!bnEq(transaction.fees, new BigNumber(fees.value.toString()))) {
37
+ return {
38
+ ...transaction,
39
+ fees: new BigNumber(fees.value.toString()),
40
+ assetReference,
41
+ assetOwner,
42
+ networkInfo: {
43
+ fees: new BigNumber(fees.value.toString()),
44
+ },
45
+ };
22
46
  }
23
47
 
24
48
  return transaction;
25
49
  };
26
50
  }
51
+
52
+ export function getAssetInfos(
53
+ tr: TransactionCommon & { assetReference?: string; assetOwner?: string },
54
+ ): string[] {
55
+ if (tr.subAccountId) {
56
+ const assetString = tr.subAccountId.split("+")[1];
57
+ return assetString.split(":");
58
+ }
59
+ return [tr.assetReference || "", tr.assetOwner || ""];
60
+ }
@@ -12,12 +12,69 @@ import { buildOptimisticOperation, transactionToIntent } from "./utils";
12
12
  import { FeeNotLoaded } from "@ledgerhq/errors";
13
13
  import { Result } from "@ledgerhq/coin-framework/derivation";
14
14
  import { MapMemo, TransactionIntent } from "@ledgerhq/coin-framework/api/types";
15
+ import { StellarMemo } from "@ledgerhq/coin-stellar/types/bridge";
16
+ import BigNumber from "bignumber.js";
15
17
 
18
+ /**
19
+ * Applies memo information to transaction intent
20
+ * Handles both destination tags (XRP-like) and Stellar-style memos
21
+ */
22
+ function applyMemoToIntent(
23
+ transactionIntent: TransactionIntent<any>,
24
+ transaction: TransactionCommon,
25
+ ): TransactionIntent<any> {
26
+ // Handle destination tag memo (for XRP-like chains)
27
+ if (transaction["tag"]) {
28
+ const txWithMemoTag = transactionIntent as TransactionIntent<MapMemo<string, string>>;
29
+ const txMemo = String(transaction["tag"]);
30
+
31
+ txWithMemoTag.memo = {
32
+ type: "map",
33
+ memos: new Map(),
34
+ };
35
+ txWithMemoTag.memo.memos.set("destinationTag", txMemo);
36
+
37
+ return txWithMemoTag;
38
+ }
39
+
40
+ // Handle Stellar-style memo
41
+ if (transaction["memoType"] && transaction["memoValue"]) {
42
+ const txWithMemo = transactionIntent as TransactionIntent<StellarMemo>;
43
+ const txMemoType = String(transaction["memoType"]);
44
+ const txMemoValue = String(transaction["memoValue"]);
45
+
46
+ txWithMemo.memo = {
47
+ type: txMemoType as "NO_MEMO" | "MEMO_TEXT" | "MEMO_ID" | "MEMO_HASH" | "MEMO_RETURN",
48
+ value: txMemoValue,
49
+ };
50
+
51
+ return txWithMemo;
52
+ }
53
+
54
+ return transactionIntent;
55
+ }
56
+
57
+ /**
58
+ * Enriches transaction intent with memo and asset information
59
+ */
60
+ function enrichTransactionIntent(
61
+ transactionIntent: TransactionIntent<any>,
62
+ transaction: TransactionCommon,
63
+ publicKey: string,
64
+ ): TransactionIntent<any> {
65
+ // Set sender public key
66
+ transactionIntent.senderPublicKey = publicKey;
67
+
68
+ // Apply memo information
69
+ transactionIntent = applyMemoToIntent(transactionIntent, transaction);
70
+
71
+ return transactionIntent;
72
+ }
16
73
  /**
17
74
  * Sign Transaction with Ledger hardware
18
75
  */
19
76
  export const genericSignOperation =
20
- (network: string, kind: "local" | "remote") =>
77
+ (network, kind) =>
21
78
  (signerContext: SignerContext<any>): AccountBridge<TransactionCommon>["signOperation"] =>
22
79
  ({
23
80
  account,
@@ -30,30 +87,40 @@ export const genericSignOperation =
30
87
  }): Observable<SignOperationEvent> =>
31
88
  new Observable(o => {
32
89
  async function main() {
90
+ // NOTE: checking field that's not inside TransactionCommon, improve
33
91
  if (!transaction["fees"]) throw new FeeNotLoaded();
34
-
92
+ const fees = BigInt(transaction["fees"]?.toString() || "0");
93
+ if (transaction["useAllAmount"]) {
94
+ const draftTransaction = {
95
+ recipient: transaction.recipient,
96
+ amount: transaction.amount ?? 0,
97
+ fees: fees,
98
+ useAllAmount: !!transaction.useAllAmount,
99
+ assetReference: transaction?.["assetReference"] || "",
100
+ assetOwner: transaction?.["assetOwner"] || "",
101
+ subAccountId: transaction.subAccountId || "",
102
+ };
103
+ const { amount } = await getAlpacaApi(network, kind).validateIntent(
104
+ transactionToIntent(account, draftTransaction),
105
+ );
106
+ transaction.amount = new BigNumber(amount.toString());
107
+ }
35
108
  const signedInfo = await signerContext(deviceId, async signer => {
36
109
  const derivationPath = account.freshAddressPath;
37
-
38
110
  const { publicKey } = (await signer.getAddress(derivationPath)) as Result;
39
111
 
40
- const transactionIntent = transactionToIntent(account, transaction);
112
+ let transactionIntent = transactionToIntent(account, { ...transaction, fees });
41
113
  transactionIntent.senderPublicKey = publicKey;
42
- // NOTE: is setting the memo here instead of transactionToIntent sensible?
43
- const txWithMemo = transactionIntent as TransactionIntent<MapMemo<string, string>>;
44
- if (transaction["tag"]) {
45
- const txMemo = String(transaction["tag"]);
46
- txWithMemo.memo = {
47
- type: "map",
48
- memos: new Map(),
49
- };
50
- txWithMemo.memo.memos.set("destinationTag", txMemo);
51
- }
52
-
53
- const accountInfo = await getAlpacaApi(network, kind).getAccountInfo(
114
+
115
+ // Enrich with memo and asset information
116
+ transactionIntent = enrichTransactionIntent(transactionIntent, transaction, publicKey);
117
+
118
+ // TODO: should compute it and pass it down to craftTransaction (duplicate call right now)
119
+ const sequenceNumber = await getAlpacaApi(network, kind).getSequence(
54
120
  transactionIntent.sender,
55
121
  );
56
- transactionIntent.sequence = accountInfo.sequence;
122
+ transactionIntent.sequence = sequenceNumber;
123
+
57
124
  /* Craft unsigned blob via Alpaca */
58
125
  const unsigned: string = await getAlpacaApi(network, kind).craftTransaction(
59
126
  transactionIntent,
@@ -76,8 +143,8 @@ export const genericSignOperation =
76
143
  signedInfo.txnSig,
77
144
  signedInfo.publicKey,
78
145
  );
79
-
80
146
  const operation = buildOptimisticOperation(account, transaction, signedInfo.sequence);
147
+
81
148
  // NOTE: we set the transactionSequenceNumber before on the operation
82
149
  // now that we create it in craftTransaction, we might need to return it back from craftTransaction also
83
150
  o.next({
@@ -1,12 +1,15 @@
1
1
  import { GetAddressFn } from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
2
2
  import xrpGetAddress from "@ledgerhq/coin-xrp/signer/getAddress";
3
+ import stellarGetAddress from "@ledgerhq/coin-stellar/signer/getAddress";
3
4
  import { CreateSigner, executeWithSigner } from "../../setup";
4
5
  import Xrp from "@ledgerhq/hw-app-xrp";
6
+ import Stellar from "@ledgerhq/hw-app-str";
5
7
 
6
8
  import Transport from "@ledgerhq/hw-transport";
7
- import { signTransaction } from "./signTransaction";
9
+ import { signTransaction, stellarSignTransaction } from "./signTransaction";
8
10
  import { SignerContext } from "@ledgerhq/coin-framework/signer";
9
11
  import { SignTransactionOptions } from "./types";
12
+ import { StrKey } from "@stellar/stellar-sdk";
10
13
 
11
14
  export type AlpacaSigner = {
12
15
  getAddress: GetAddressFn;
@@ -15,17 +18,50 @@ export type AlpacaSigner = {
15
18
  context: SignerContext<any>;
16
19
  };
17
20
 
18
- export function getSigner(network: string): AlpacaSigner {
21
+ const createSignerXrp: CreateSigner<Xrp> = (transport: Transport) => {
22
+ return new Xrp(transport);
23
+ };
24
+ const signerContextXrp = executeWithSigner(createSignerXrp);
25
+
26
+ const createSignerStellar: CreateSigner<Stellar> = (transport: Transport) => {
27
+ const stellar = new Stellar(transport);
28
+ const originalSignTransaction = stellar.signTransaction;
29
+ // Return the original Stellar instance with overridden methods
30
+ return Object.assign(stellar, {
31
+ signTransaction: async (path: string, transaction: string) => {
32
+ const unsignedPayload: Buffer = Buffer.from(transaction, "base64");
33
+ const { signature } = await originalSignTransaction(path, unsignedPayload);
34
+ return signature.toString("base64");
35
+ },
36
+ getAddress: async (path: string, verify?: boolean) => {
37
+ const { rawPublicKey } = await stellar.getPublicKey(path, verify);
38
+ const publicKey = StrKey.encodeEd25519PublicKey(rawPublicKey);
39
+ return {
40
+ path,
41
+ address: publicKey,
42
+ publicKey: publicKey,
43
+ };
44
+ },
45
+ });
46
+ };
47
+
48
+ const signerContextStellar = executeWithSigner(createSignerStellar);
49
+
50
+ export function getSigner(network): AlpacaSigner {
19
51
  switch (network) {
20
52
  case "ripple":
21
53
  case "xrp": {
22
- const createSigner: CreateSigner<Xrp> = (transport: Transport) => {
23
- return new Xrp(transport);
54
+ return {
55
+ getAddress: xrpGetAddress(signerContextXrp),
56
+ signTransaction: signTransaction(signerContextXrp),
57
+ context: signerContextXrp,
24
58
  };
59
+ }
60
+ case "stellar": {
25
61
  return {
26
- getAddress: xrpGetAddress(executeWithSigner(createSigner)),
27
- signTransaction: signTransaction(executeWithSigner(createSigner)),
28
- context: executeWithSigner(createSigner),
62
+ getAddress: stellarGetAddress(signerContextStellar),
63
+ signTransaction: stellarSignTransaction(signerContextStellar),
64
+ context: signerContextStellar,
29
65
  };
30
66
  }
31
67
  }
@@ -1,6 +1,7 @@
1
1
  import { SignerContext } from "@ledgerhq/coin-framework/signer";
2
2
  import { XrpSigner } from "@ledgerhq/coin-xrp/index";
3
3
  import { SignTransactionOptions } from "./types";
4
+ import { StellarSigner } from "@ledgerhq/coin-stellar/types/signer";
4
5
 
5
6
  export const signTransaction = (signerContext: SignerContext<XrpSigner>) => {
6
7
  return async (deviceId: string, { path, rawTxHex }: SignTransactionOptions) => {
@@ -11,3 +12,13 @@ export const signTransaction = (signerContext: SignerContext<XrpSigner>) => {
11
12
  return signedTx;
12
13
  };
13
14
  };
15
+
16
+ export const stellarSignTransaction = (signerContext: SignerContext<StellarSigner>) => {
17
+ return async (deviceId: string, { path, transaction }: SignTransactionOptions) => {
18
+ const signedTx = await signerContext(deviceId, signer =>
19
+ signer.signTransaction(path, transaction),
20
+ );
21
+
22
+ return signedTx.signature.toString("base64"); // It should return a Buffer
23
+ };
24
+ };
@@ -1,4 +1,5 @@
1
1
  export type SignTransactionOptions = {
2
2
  rawTxHex: string;
3
3
  path: string;
4
+ transaction: Buffer;
4
5
  };
@@ -11,66 +11,91 @@ jest.mock("../alpaca", () => ({
11
11
  const mockedGetAlpacaApi = alpaca.getAlpacaApi as jest.Mock;
12
12
 
13
13
  // Dummy data
14
- const dummyAccount = {
15
- id: "js:2:ripple:r123:",
16
- type: "Account", // <-- this is mandatory for getMainAccount to work
17
- spendableBalance: new BigNumber(50000000),
18
- currency: { id: "ripple", name: "XRP", units: [{ name: "XRP", magnitude: 6 }] },
19
- freshAddress: "r123",
20
- } as unknown as Account;
14
+ const dummyAccounts = [
15
+ {
16
+ id: "js:2:ripple:r123:",
17
+ type: "Account",
18
+ spendableBalance: new BigNumber(50000000),
19
+ balance: new BigNumber(60000000),
20
+ currency: { id: "ripple", family: "xrp", name: "XRP", units: [{ name: "XRP", magnitude: 6 }] },
21
+ freshAddress: "r123",
22
+ pendingOperations: [],
23
+ },
24
+ {
25
+ id: "js:2:stellar:s123:",
26
+ type: "Account",
27
+ spendableBalance: new BigNumber(50000000),
28
+ balance: new BigNumber(60000000),
29
+ currency: {
30
+ id: "stellar",
31
+ family: "stellar",
32
+ name: "Stellar",
33
+ units: [{ name: "XLM", magnitude: 7 }],
34
+ },
35
+ freshAddress: "s123",
36
+ pendingOperations: [],
37
+ },
38
+ ] as unknown as Account[];
21
39
 
22
- describe("genericEstimateMaxSpendable", () => {
23
- afterEach(() => {
24
- jest.clearAllMocks();
25
- });
40
+ ["xrp", "stellar"].forEach((currencyName, idx) => {
41
+ describe(`genericEstimateMaxSpendable for ${currencyName}`, () => {
42
+ const dummyAccount = dummyAccounts[idx];
26
43
 
27
- it("subtracts estimated fee from spendable balance", async () => {
28
- mockedGetAlpacaApi.mockReturnValue({
29
- estimateFees: jest.fn().mockResolvedValue({ value: 10000n }), // 0.01 XRP
44
+ afterEach(() => {
45
+ jest.clearAllMocks();
30
46
  });
31
47
 
32
- const estimate = genericEstimateMaxSpendable("xrp", "local");
33
- const result = await estimate({
34
- account: dummyAccount,
35
- parentAccount: null,
36
- transaction: {},
48
+ it("subtracts estimated fee from spendable balance", async () => {
49
+ mockedGetAlpacaApi.mockReturnValue({
50
+ estimateFees: jest.fn().mockResolvedValue({ value: 10000n }),
51
+ validateIntent: jest.fn().mockResolvedValue({ amount: 49990000n }),
52
+ });
53
+
54
+ const estimate = genericEstimateMaxSpendable(currencyName, "local");
55
+ const result = await estimate({
56
+ account: dummyAccount,
57
+ parentAccount: null,
58
+ transaction: {},
59
+ });
60
+
61
+ expect(result.toString()).toBe("49990000");
37
62
  });
38
63
 
39
- expect(result.toString()).toBe("49990000"); // 50_000_000 - 10_000
40
- });
64
+ it("returns 0 if fee is higher than spendable", async () => {
65
+ const poorAccount = {
66
+ ...dummyAccount,
67
+ spendableBalance: new BigNumber(5000),
68
+ };
41
69
 
42
- it("returns 0 if fee is higher than spendable", async () => {
43
- const poorAccount = {
44
- ...dummyAccount,
45
- spendableBalance: new BigNumber(5000), // very low
46
- };
70
+ mockedGetAlpacaApi.mockReturnValue({
71
+ estimateFees: jest.fn().mockResolvedValue({ value: 10000n }),
72
+ validateIntent: jest.fn().mockResolvedValue({ amount: 0n }),
73
+ });
47
74
 
48
- mockedGetAlpacaApi.mockReturnValue({
49
- estimateFees: jest.fn().mockResolvedValue({ value: 10000n }),
50
- });
75
+ const estimate = genericEstimateMaxSpendable(currencyName, "local");
76
+ const result = await estimate({
77
+ account: poorAccount,
78
+ parentAccount: null,
79
+ transaction: {},
80
+ });
51
81
 
52
- const estimate = genericEstimateMaxSpendable("xrp", "local");
53
- const result = await estimate({
54
- account: poorAccount,
55
- parentAccount: null,
56
- transaction: {},
82
+ expect(result.toString()).toBe("0");
57
83
  });
58
84
 
59
- expect(result.toString()).toBe("0");
60
- });
85
+ it("returns full spendable balance if fee is 0", async () => {
86
+ mockedGetAlpacaApi.mockReturnValue({
87
+ estimateFees: jest.fn().mockResolvedValue({ value: 0n }),
88
+ validateIntent: jest.fn().mockResolvedValue({ amount: 50000000n }),
89
+ });
61
90
 
62
- it("returns full spendable balance if fee is 0", async () => {
63
- mockedGetAlpacaApi.mockReturnValue({
64
- estimateFees: jest.fn().mockResolvedValue({ value: 0n }),
65
- });
91
+ const estimate = genericEstimateMaxSpendable(currencyName, "local");
92
+ const result = await estimate({
93
+ account: dummyAccount,
94
+ parentAccount: null,
95
+ transaction: {},
96
+ });
66
97
 
67
- const estimate = genericEstimateMaxSpendable("xrp", "local");
68
- const result = await estimate({
69
- account: dummyAccount,
70
- parentAccount: null,
71
- transaction: {},
98
+ expect(result.toString()).toBe("50000000");
72
99
  });
73
-
74
- expect(result.toString()).toBe("50000000");
75
100
  });
76
101
  });
@@ -47,7 +47,7 @@ describe("genericPrepareTransaction", () => {
47
47
  expect((result as any).fees.toString()).toBe(newFee.toString());
48
48
  expect(transactionToIntent).toHaveBeenCalledWith(
49
49
  account,
50
- expect.objectContaining(baseTransaction),
50
+ expect.objectContaining({ ...baseTransaction, fees: 500n }),
51
51
  );
52
52
  });
53
53
 
@@ -13,9 +13,8 @@ jest.mock("../utils", () => ({
13
13
  buildOptimisticOperation: jest.fn(),
14
14
  transactionToIntent: jest.fn(),
15
15
  }));
16
-
17
16
  describe("genericSignOperation", () => {
18
- const network = "xrp";
17
+ const networks = ["xrp", "stellar"];
19
18
  const kind = "local";
20
19
 
21
20
  const mockSignerContext = jest.fn();
@@ -55,6 +54,7 @@ describe("genericSignOperation", () => {
55
54
  craftTransaction: jest.fn().mockResolvedValue(unsignedTx),
56
55
  getAccountInfo: jest.fn().mockResolvedValue(pubKey),
57
56
  combine: jest.fn().mockResolvedValue(signedTx),
57
+ getSequence: jest.fn().mockResolvedValue(1),
58
58
  });
59
59
 
60
60
  (transactionToIntent as jest.Mock).mockReturnValue(txIntent);
@@ -65,33 +65,35 @@ describe("genericSignOperation", () => {
65
65
  mockSignerContext.mockImplementation(async (_deviceId, cb) => cb(mockSigner));
66
66
  });
67
67
 
68
- it("emits full sign operation flow", async () => {
69
- const signOperation = genericSignOperation(network, kind)(mockSignerContext);
70
- const observable = signOperation({ account, transaction, deviceId });
71
-
72
- const events = await lastValueFrom(observable.pipe(toArray()));
73
-
74
- expect(events[0]).toEqual({ type: "device-signature-requested" });
75
- expect(events[1]).toEqual({ type: "device-signature-granted" });
76
- expect(events[2]).toEqual({
77
- type: "signed",
78
- signedOperation: {
79
- operation: { id: "mock-op" },
80
- signature: signedTx,
81
- },
68
+ networks.forEach(network => {
69
+ it(`emits full sign operation flow for ${network}`, async () => {
70
+ const signOperation = genericSignOperation(network, kind)(mockSignerContext);
71
+ const observable = signOperation({ account, transaction, deviceId });
72
+
73
+ const events = await lastValueFrom(observable.pipe(toArray()));
74
+
75
+ expect(events[0]).toEqual({ type: "device-signature-requested" });
76
+ expect(events[1]).toEqual({ type: "device-signature-granted" });
77
+ expect(events[2]).toEqual({
78
+ type: "signed",
79
+ signedOperation: {
80
+ operation: { id: "mock-op" },
81
+ signature: signedTx,
82
+ },
83
+ });
84
+
85
+ expect(transactionToIntent).toHaveBeenCalledWith(account, transaction);
86
+ expect(txIntent.memo.memos.get("destinationTag")).toBe("1234");
82
87
  });
83
88
 
84
- expect(transactionToIntent).toHaveBeenCalledWith(account, transaction);
85
- expect(txIntent.memo.memos.get("destinationTag")).toBe("1234");
86
- });
87
-
88
- it("throws FeeNotLoaded if fees are missing", async () => {
89
- const txWithoutFees = { ...transaction };
90
- delete txWithoutFees.fees;
89
+ it(`throws FeeNotLoaded if fees are missing for ${network}`, async () => {
90
+ const txWithoutFees = { ...transaction };
91
+ delete txWithoutFees.fees;
91
92
 
92
- const signOperation = genericSignOperation(network, kind)(mockSignerContext);
93
- const observable = signOperation({ account, transaction: txWithoutFees, deviceId });
93
+ const signOperation = genericSignOperation(network, kind)(mockSignerContext);
94
+ const observable = signOperation({ account, transaction: txWithoutFees, deviceId });
94
95
 
95
- await expect(observable.toPromise()).rejects.toThrow(FeeNotLoaded);
96
+ await expect(observable.toPromise()).rejects.toThrow(FeeNotLoaded);
97
+ });
96
98
  });
97
99
  });
@@ -1,4 +1,4 @@
1
- import { extractBalance } from "./utils";
1
+ import { extractBalance } from "../utils";
2
2
 
3
3
  describe("Alpaca utils", () => {
4
4
  describe("extractBalance", () => {