@ledgerhq/live-common 34.36.0-nightly.2 → 34.36.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 (280) hide show
  1. package/lib/__tests__/test-helpers/bridge.d.ts.map +1 -1
  2. package/lib/__tests__/test-helpers/bridge.js +4 -4
  3. package/lib/__tests__/test-helpers/bridge.js.map +1 -1
  4. package/lib/bridge/impl.d.ts.map +1 -1
  5. package/lib/bridge/impl.js +3 -59
  6. package/lib/bridge/impl.js.map +1 -1
  7. package/lib/config/index.d.ts +2 -3
  8. package/lib/config/index.d.ts.map +1 -1
  9. package/lib/config/index.js +1 -9
  10. package/lib/config/index.js.map +1 -1
  11. package/lib/config/sharedConfig.d.ts.map +1 -1
  12. package/lib/config/sharedConfig.js +0 -7
  13. package/lib/config/sharedConfig.js.map +1 -1
  14. package/lib/e2e/enum/{Provider.d.ts → Swap.d.ts} +1 -2
  15. package/lib/e2e/enum/Swap.d.ts.map +1 -0
  16. package/lib/e2e/enum/{Provider.js → Swap.js} +1 -2
  17. package/lib/e2e/enum/Swap.js.map +1 -0
  18. package/lib/e2e/index.d.ts +0 -4
  19. package/lib/e2e/index.d.ts.map +1 -1
  20. package/lib/e2e/models/BuySell.d.ts +0 -2
  21. package/lib/e2e/models/BuySell.d.ts.map +1 -1
  22. package/lib/families/xrp/setup.d.ts +6 -3
  23. package/lib/families/xrp/setup.d.ts.map +1 -1
  24. package/lib/families/xrp/setup.js +7 -1
  25. package/lib/families/xrp/setup.js.map +1 -1
  26. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  27. package/lib/featureFlags/defaultFeatures.js +0 -2
  28. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  29. package/lib/featureFlags/useFeature.d.ts +1 -1
  30. package/lib/featureFlags/useFeature.d.ts.map +1 -1
  31. package/lib/generated/bridge/js.d.ts +1 -0
  32. package/lib/generated/bridge/js.d.ts.map +1 -1
  33. package/lib/generated/bridge/js.js +6 -4
  34. package/lib/generated/bridge/js.js.map +1 -1
  35. package/lib-es/__tests__/test-helpers/bridge.d.ts.map +1 -1
  36. package/lib-es/__tests__/test-helpers/bridge.js +4 -4
  37. package/lib-es/__tests__/test-helpers/bridge.js.map +1 -1
  38. package/lib-es/bridge/impl.d.ts.map +1 -1
  39. package/lib-es/bridge/impl.js +3 -59
  40. package/lib-es/bridge/impl.js.map +1 -1
  41. package/lib-es/config/index.d.ts +2 -3
  42. package/lib-es/config/index.d.ts.map +1 -1
  43. package/lib-es/config/index.js +1 -8
  44. package/lib-es/config/index.js.map +1 -1
  45. package/lib-es/config/sharedConfig.d.ts.map +1 -1
  46. package/lib-es/config/sharedConfig.js +0 -7
  47. package/lib-es/config/sharedConfig.js.map +1 -1
  48. package/lib-es/e2e/enum/{Provider.d.ts → Swap.d.ts} +1 -2
  49. package/lib-es/e2e/enum/Swap.d.ts.map +1 -0
  50. package/lib-es/e2e/enum/{Provider.js → Swap.js} +1 -2
  51. package/lib-es/e2e/enum/Swap.js.map +1 -0
  52. package/lib-es/e2e/index.d.ts +0 -4
  53. package/lib-es/e2e/index.d.ts.map +1 -1
  54. package/lib-es/e2e/models/BuySell.d.ts +0 -2
  55. package/lib-es/e2e/models/BuySell.d.ts.map +1 -1
  56. package/lib-es/families/xrp/setup.d.ts +6 -3
  57. package/lib-es/families/xrp/setup.d.ts.map +1 -1
  58. package/lib-es/families/xrp/setup.js +7 -2
  59. package/lib-es/families/xrp/setup.js.map +1 -1
  60. package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
  61. package/lib-es/featureFlags/defaultFeatures.js +0 -2
  62. package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
  63. package/lib-es/featureFlags/useFeature.d.ts +1 -1
  64. package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
  65. package/lib-es/generated/bridge/js.d.ts +1 -0
  66. package/lib-es/generated/bridge/js.d.ts.map +1 -1
  67. package/lib-es/generated/bridge/js.js +2 -0
  68. package/lib-es/generated/bridge/js.js.map +1 -1
  69. package/package.json +63 -64
  70. package/src/__tests__/test-helpers/bridge.ts +4 -2
  71. package/src/bridge/impl.ts +5 -87
  72. package/src/config/index.ts +2 -11
  73. package/src/config/sharedConfig.ts +0 -8
  74. package/src/e2e/enum/{Provider.ts → Swap.ts} +0 -1
  75. package/src/e2e/models/BuySell.ts +0 -2
  76. package/src/families/xrp/setup.ts +15 -2
  77. package/src/featureFlags/defaultFeatures.ts +0 -2
  78. package/src/generated/bridge/js.ts +2 -0
  79. package/lib/bridge/generic-alpaca/accountBridge.d.ts +0 -3
  80. package/lib/bridge/generic-alpaca/accountBridge.d.ts.map +0 -1
  81. package/lib/bridge/generic-alpaca/accountBridge.js +0 -34
  82. package/lib/bridge/generic-alpaca/accountBridge.js.map +0 -1
  83. package/lib/bridge/generic-alpaca/alpaca/index.d.ts +0 -3
  84. package/lib/bridge/generic-alpaca/alpaca/index.d.ts.map +0 -1
  85. package/lib/bridge/generic-alpaca/alpaca/index.js +0 -20
  86. package/lib/bridge/generic-alpaca/alpaca/index.js.map +0 -1
  87. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +0 -16
  88. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +0 -1
  89. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js +0 -123
  90. package/lib/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +0 -1
  91. package/lib/bridge/generic-alpaca/broadcast.d.ts +0 -3
  92. package/lib/bridge/generic-alpaca/broadcast.d.ts.map +0 -1
  93. package/lib/bridge/generic-alpaca/broadcast.js +0 -11
  94. package/lib/bridge/generic-alpaca/broadcast.js.map +0 -1
  95. package/lib/bridge/generic-alpaca/createTransaction.d.ts +0 -16
  96. package/lib/bridge/generic-alpaca/createTransaction.d.ts.map +0 -1
  97. package/lib/bridge/generic-alpaca/createTransaction.js +0 -20
  98. package/lib/bridge/generic-alpaca/createTransaction.js.map +0 -1
  99. package/lib/bridge/generic-alpaca/currencyBridge.d.ts +0 -3
  100. package/lib/bridge/generic-alpaca/currencyBridge.d.ts.map +0 -1
  101. package/lib/bridge/generic-alpaca/currencyBridge.js +0 -20
  102. package/lib/bridge/generic-alpaca/currencyBridge.js.map +0 -1
  103. package/lib/bridge/generic-alpaca/estimateMaxSpendable.d.ts +0 -3
  104. package/lib/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +0 -1
  105. package/lib/bridge/generic-alpaca/estimateMaxSpendable.js +0 -26
  106. package/lib/bridge/generic-alpaca/estimateMaxSpendable.js.map +0 -1
  107. package/lib/bridge/generic-alpaca/getAccountShape.d.ts +0 -3
  108. package/lib/bridge/generic-alpaca/getAccountShape.d.ts.map +0 -1
  109. package/lib/bridge/generic-alpaca/getAccountShape.js +0 -58
  110. package/lib/bridge/generic-alpaca/getAccountShape.js.map +0 -1
  111. package/lib/bridge/generic-alpaca/getTransactionStatus.d.ts +0 -3
  112. package/lib/bridge/generic-alpaca/getTransactionStatus.d.ts.map +0 -1
  113. package/lib/bridge/generic-alpaca/getTransactionStatus.js +0 -36
  114. package/lib/bridge/generic-alpaca/getTransactionStatus.js.map +0 -1
  115. package/lib/bridge/generic-alpaca/prepareTransaction.d.ts +0 -3
  116. package/lib/bridge/generic-alpaca/prepareTransaction.d.ts.map +0 -1
  117. package/lib/bridge/generic-alpaca/prepareTransaction.js +0 -21
  118. package/lib/bridge/generic-alpaca/prepareTransaction.js.map +0 -1
  119. package/lib/bridge/generic-alpaca/signOperation.d.ts +0 -7
  120. package/lib/bridge/generic-alpaca/signOperation.d.ts.map +0 -1
  121. package/lib/bridge/generic-alpaca/signOperation.js +0 -49
  122. package/lib/bridge/generic-alpaca/signOperation.js.map +0 -1
  123. package/lib/bridge/generic-alpaca/signer/index.d.ts +0 -11
  124. package/lib/bridge/generic-alpaca/signer/index.d.ts.map +0 -1
  125. package/lib/bridge/generic-alpaca/signer/index.js +0 -28
  126. package/lib/bridge/generic-alpaca/signer/index.js.map +0 -1
  127. package/lib/bridge/generic-alpaca/signer/signTransaction.d.ts +0 -5
  128. package/lib/bridge/generic-alpaca/signer/signTransaction.d.ts.map +0 -1
  129. package/lib/bridge/generic-alpaca/signer/signTransaction.js +0 -11
  130. package/lib/bridge/generic-alpaca/signer/signTransaction.js.map +0 -1
  131. package/lib/bridge/generic-alpaca/signer/types.d.ts +0 -5
  132. package/lib/bridge/generic-alpaca/signer/types.d.ts.map +0 -1
  133. package/lib/bridge/generic-alpaca/signer/types.js +0 -3
  134. package/lib/bridge/generic-alpaca/signer/types.js.map +0 -1
  135. package/lib/bridge/generic-alpaca/tests/estimateMaxSpendable.test.d.ts +0 -2
  136. package/lib/bridge/generic-alpaca/tests/estimateMaxSpendable.test.d.ts.map +0 -1
  137. package/lib/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js +0 -90
  138. package/lib/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js.map +0 -1
  139. package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.d.ts +0 -2
  140. package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.d.ts.map +0 -1
  141. package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.js +0 -53
  142. package/lib/bridge/generic-alpaca/tests/prepareTransaction.test.js.map +0 -1
  143. package/lib/bridge/generic-alpaca/tests/signOperation.test.d.ts +0 -2
  144. package/lib/bridge/generic-alpaca/tests/signOperation.test.d.ts.map +0 -1
  145. package/lib/bridge/generic-alpaca/tests/signOperation.test.js +0 -79
  146. package/lib/bridge/generic-alpaca/tests/signOperation.test.js.map +0 -1
  147. package/lib/bridge/generic-alpaca/utils.d.ts +0 -6
  148. package/lib/bridge/generic-alpaca/utils.d.ts.map +0 -1
  149. package/lib/bridge/generic-alpaca/utils.js +0 -55
  150. package/lib/bridge/generic-alpaca/utils.js.map +0 -1
  151. package/lib/e2e/enum/OperationType.d.ts +0 -5
  152. package/lib/e2e/enum/OperationType.d.ts.map +0 -1
  153. package/lib/e2e/enum/OperationType.js +0 -9
  154. package/lib/e2e/enum/OperationType.js.map +0 -1
  155. package/lib/e2e/enum/Provider.d.ts.map +0 -1
  156. package/lib/e2e/enum/Provider.js.map +0 -1
  157. package/lib/hooks/useOFACGeoBlockCheck.d.ts +0 -8
  158. package/lib/hooks/useOFACGeoBlockCheck.d.ts.map +0 -1
  159. package/lib/hooks/useOFACGeoBlockCheck.js +0 -32
  160. package/lib/hooks/useOFACGeoBlockCheck.js.map +0 -1
  161. package/lib/sanction/errors.d.ts +0 -13
  162. package/lib/sanction/errors.d.ts.map +0 -1
  163. package/lib/sanction/errors.js +0 -36
  164. package/lib/sanction/errors.js.map +0 -1
  165. package/lib/sanction/index.d.ts +0 -3
  166. package/lib/sanction/index.d.ts.map +0 -1
  167. package/lib/sanction/index.js +0 -51
  168. package/lib/sanction/index.js.map +0 -1
  169. package/lib-es/bridge/generic-alpaca/accountBridge.d.ts +0 -3
  170. package/lib-es/bridge/generic-alpaca/accountBridge.d.ts.map +0 -1
  171. package/lib-es/bridge/generic-alpaca/accountBridge.js +0 -27
  172. package/lib-es/bridge/generic-alpaca/accountBridge.js.map +0 -1
  173. package/lib-es/bridge/generic-alpaca/alpaca/index.d.ts +0 -3
  174. package/lib-es/bridge/generic-alpaca/alpaca/index.d.ts.map +0 -1
  175. package/lib-es/bridge/generic-alpaca/alpaca/index.js +0 -16
  176. package/lib-es/bridge/generic-alpaca/alpaca/index.js.map +0 -1
  177. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts +0 -16
  178. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.d.ts.map +0 -1
  179. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js +0 -116
  180. package/lib-es/bridge/generic-alpaca/alpaca/network/network-alpaca.js.map +0 -1
  181. package/lib-es/bridge/generic-alpaca/broadcast.d.ts +0 -3
  182. package/lib-es/bridge/generic-alpaca/broadcast.d.ts.map +0 -1
  183. package/lib-es/bridge/generic-alpaca/broadcast.js +0 -7
  184. package/lib-es/bridge/generic-alpaca/broadcast.js.map +0 -1
  185. package/lib-es/bridge/generic-alpaca/createTransaction.d.ts +0 -16
  186. package/lib-es/bridge/generic-alpaca/createTransaction.d.ts.map +0 -1
  187. package/lib-es/bridge/generic-alpaca/createTransaction.js +0 -13
  188. package/lib-es/bridge/generic-alpaca/createTransaction.js.map +0 -1
  189. package/lib-es/bridge/generic-alpaca/currencyBridge.d.ts +0 -3
  190. package/lib-es/bridge/generic-alpaca/currencyBridge.d.ts.map +0 -1
  191. package/lib-es/bridge/generic-alpaca/currencyBridge.js +0 -16
  192. package/lib-es/bridge/generic-alpaca/currencyBridge.js.map +0 -1
  193. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.d.ts +0 -3
  194. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.d.ts.map +0 -1
  195. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js +0 -19
  196. package/lib-es/bridge/generic-alpaca/estimateMaxSpendable.js.map +0 -1
  197. package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts +0 -3
  198. package/lib-es/bridge/generic-alpaca/getAccountShape.d.ts.map +0 -1
  199. package/lib-es/bridge/generic-alpaca/getAccountShape.js +0 -51
  200. package/lib-es/bridge/generic-alpaca/getAccountShape.js.map +0 -1
  201. package/lib-es/bridge/generic-alpaca/getTransactionStatus.d.ts +0 -3
  202. package/lib-es/bridge/generic-alpaca/getTransactionStatus.d.ts.map +0 -1
  203. package/lib-es/bridge/generic-alpaca/getTransactionStatus.js +0 -29
  204. package/lib-es/bridge/generic-alpaca/getTransactionStatus.js.map +0 -1
  205. package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts +0 -3
  206. package/lib-es/bridge/generic-alpaca/prepareTransaction.d.ts.map +0 -1
  207. package/lib-es/bridge/generic-alpaca/prepareTransaction.js +0 -14
  208. package/lib-es/bridge/generic-alpaca/prepareTransaction.js.map +0 -1
  209. package/lib-es/bridge/generic-alpaca/signOperation.d.ts +0 -7
  210. package/lib-es/bridge/generic-alpaca/signOperation.d.ts.map +0 -1
  211. package/lib-es/bridge/generic-alpaca/signOperation.js +0 -45
  212. package/lib-es/bridge/generic-alpaca/signOperation.js.map +0 -1
  213. package/lib-es/bridge/generic-alpaca/signer/index.d.ts +0 -11
  214. package/lib-es/bridge/generic-alpaca/signer/index.d.ts.map +0 -1
  215. package/lib-es/bridge/generic-alpaca/signer/index.js +0 -21
  216. package/lib-es/bridge/generic-alpaca/signer/index.js.map +0 -1
  217. package/lib-es/bridge/generic-alpaca/signer/signTransaction.d.ts +0 -5
  218. package/lib-es/bridge/generic-alpaca/signer/signTransaction.d.ts.map +0 -1
  219. package/lib-es/bridge/generic-alpaca/signer/signTransaction.js +0 -7
  220. package/lib-es/bridge/generic-alpaca/signer/signTransaction.js.map +0 -1
  221. package/lib-es/bridge/generic-alpaca/signer/types.d.ts +0 -5
  222. package/lib-es/bridge/generic-alpaca/signer/types.d.ts.map +0 -1
  223. package/lib-es/bridge/generic-alpaca/signer/types.js +0 -2
  224. package/lib-es/bridge/generic-alpaca/signer/types.js.map +0 -1
  225. package/lib-es/bridge/generic-alpaca/tests/estimateMaxSpendable.test.d.ts +0 -2
  226. package/lib-es/bridge/generic-alpaca/tests/estimateMaxSpendable.test.d.ts.map +0 -1
  227. package/lib-es/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js +0 -62
  228. package/lib-es/bridge/generic-alpaca/tests/estimateMaxSpendable.test.js.map +0 -1
  229. package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.d.ts +0 -2
  230. package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.d.ts.map +0 -1
  231. package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.js +0 -48
  232. package/lib-es/bridge/generic-alpaca/tests/prepareTransaction.test.js.map +0 -1
  233. package/lib-es/bridge/generic-alpaca/tests/signOperation.test.d.ts +0 -2
  234. package/lib-es/bridge/generic-alpaca/tests/signOperation.test.d.ts.map +0 -1
  235. package/lib-es/bridge/generic-alpaca/tests/signOperation.test.js +0 -77
  236. package/lib-es/bridge/generic-alpaca/tests/signOperation.test.js.map +0 -1
  237. package/lib-es/bridge/generic-alpaca/utils.d.ts +0 -6
  238. package/lib-es/bridge/generic-alpaca/utils.d.ts.map +0 -1
  239. package/lib-es/bridge/generic-alpaca/utils.js +0 -46
  240. package/lib-es/bridge/generic-alpaca/utils.js.map +0 -1
  241. package/lib-es/e2e/enum/OperationType.d.ts +0 -5
  242. package/lib-es/e2e/enum/OperationType.d.ts.map +0 -1
  243. package/lib-es/e2e/enum/OperationType.js +0 -6
  244. package/lib-es/e2e/enum/OperationType.js.map +0 -1
  245. package/lib-es/e2e/enum/Provider.d.ts.map +0 -1
  246. package/lib-es/e2e/enum/Provider.js.map +0 -1
  247. package/lib-es/hooks/useOFACGeoBlockCheck.d.ts +0 -8
  248. package/lib-es/hooks/useOFACGeoBlockCheck.d.ts.map +0 -1
  249. package/lib-es/hooks/useOFACGeoBlockCheck.js +0 -28
  250. package/lib-es/hooks/useOFACGeoBlockCheck.js.map +0 -1
  251. package/lib-es/sanction/errors.d.ts +0 -13
  252. package/lib-es/sanction/errors.d.ts.map +0 -1
  253. package/lib-es/sanction/errors.js +0 -29
  254. package/lib-es/sanction/errors.js.map +0 -1
  255. package/lib-es/sanction/index.d.ts +0 -3
  256. package/lib-es/sanction/index.d.ts.map +0 -1
  257. package/lib-es/sanction/index.js +0 -44
  258. package/lib-es/sanction/index.js.map +0 -1
  259. package/src/bridge/generic-alpaca/accountBridge.ts +0 -32
  260. package/src/bridge/generic-alpaca/alpaca/index.ts +0 -20
  261. package/src/bridge/generic-alpaca/alpaca/network/network-alpaca.ts +0 -182
  262. package/src/bridge/generic-alpaca/broadcast.ts +0 -11
  263. package/src/bridge/generic-alpaca/createTransaction.ts +0 -27
  264. package/src/bridge/generic-alpaca/currencyBridge.ts +0 -17
  265. package/src/bridge/generic-alpaca/estimateMaxSpendable.ts +0 -27
  266. package/src/bridge/generic-alpaca/getAccountShape.ts +0 -62
  267. package/src/bridge/generic-alpaca/getTransactionStatus.ts +0 -38
  268. package/src/bridge/generic-alpaca/prepareTransaction.ts +0 -22
  269. package/src/bridge/generic-alpaca/signOperation.ts +0 -83
  270. package/src/bridge/generic-alpaca/signer/index.ts +0 -33
  271. package/src/bridge/generic-alpaca/signer/signTransaction.ts +0 -13
  272. package/src/bridge/generic-alpaca/signer/types.ts +0 -4
  273. package/src/bridge/generic-alpaca/tests/estimateMaxSpendable.test.ts +0 -76
  274. package/src/bridge/generic-alpaca/tests/prepareTransaction.test.ts +0 -66
  275. package/src/bridge/generic-alpaca/tests/signOperation.test.ts +0 -96
  276. package/src/bridge/generic-alpaca/utils.ts +0 -63
  277. package/src/e2e/enum/OperationType.ts +0 -4
  278. package/src/hooks/useOFACGeoBlockCheck.ts +0 -37
  279. package/src/sanction/errors.ts +0 -31
  280. package/src/sanction/index.ts +0 -59
@@ -1,96 +0,0 @@
1
- import { lastValueFrom } from "rxjs";
2
- import { toArray } from "rxjs/operators";
3
- import { genericSignOperation } from "../signOperation";
4
- import { FeeNotLoaded } from "@ledgerhq/errors";
5
- import { getAlpacaApi } from "../alpaca";
6
- import { buildOptimisticOperation, transactionToIntent } from "../utils";
7
-
8
- jest.mock("../alpaca", () => ({
9
- getAlpacaApi: jest.fn(),
10
- }));
11
-
12
- jest.mock("../utils", () => ({
13
- buildOptimisticOperation: jest.fn(),
14
- transactionToIntent: jest.fn(),
15
- }));
16
-
17
- describe("genericSignOperation", () => {
18
- const network = "xrp";
19
- const kind = "local";
20
-
21
- const mockSignerContext = jest.fn();
22
- const mockSigner = {
23
- getAddress: jest.fn(),
24
- signTransaction: jest.fn(),
25
- };
26
-
27
- const account = {
28
- freshAddressPath: "44'/144'/0'/0/0",
29
- address: "rTestAddress",
30
- } as any;
31
-
32
- const transaction = {
33
- amount: 100_000n,
34
- fees: 500n,
35
- tag: 1234,
36
- } as any;
37
-
38
- const deviceId = "mockDevice";
39
-
40
- const txIntent = {
41
- memo: {
42
- type: "map",
43
- memos: new Map(),
44
- },
45
- };
46
-
47
- const unsignedTx = "unsignedTx";
48
- const signedTx = "signedTx";
49
- const pubKey = "pubKey";
50
-
51
- beforeEach(() => {
52
- jest.clearAllMocks();
53
-
54
- (getAlpacaApi as jest.Mock).mockReturnValue({
55
- craftTransaction: jest.fn().mockResolvedValue(unsignedTx),
56
- combine: jest.fn().mockResolvedValue(signedTx),
57
- });
58
-
59
- (transactionToIntent as jest.Mock).mockReturnValue(txIntent);
60
- (buildOptimisticOperation as jest.Mock).mockReturnValue({ id: "mock-op" });
61
-
62
- mockSigner.getAddress.mockResolvedValue({ publicKey: pubKey });
63
- mockSigner.signTransaction.mockResolvedValue("sig");
64
- mockSignerContext.mockImplementation(async (_deviceId, cb) => cb(mockSigner));
65
- });
66
-
67
- it("emits full sign operation flow", async () => {
68
- const signOperation = genericSignOperation(network, kind)(mockSignerContext);
69
- const observable = signOperation({ account, transaction, deviceId });
70
-
71
- const events = await lastValueFrom(observable.pipe(toArray()));
72
-
73
- expect(events[0]).toEqual({ type: "device-signature-requested" });
74
- expect(events[1]).toEqual({ type: "device-signature-granted" });
75
- expect(events[2]).toEqual({
76
- type: "signed",
77
- signedOperation: {
78
- operation: { id: "mock-op" },
79
- signature: signedTx,
80
- },
81
- });
82
-
83
- expect(transactionToIntent).toHaveBeenCalledWith(account, transaction);
84
- expect(txIntent.memo.memos.get("destinationTag")).toBe("1234");
85
- });
86
-
87
- it("throws FeeNotLoaded if fees are missing", async () => {
88
- const txWithoutFees = { ...transaction };
89
- delete txWithoutFees.fees;
90
-
91
- const signOperation = genericSignOperation(network, kind)(mockSignerContext);
92
- const observable = signOperation({ account, transaction: txWithoutFees, deviceId });
93
-
94
- await expect(observable.toPromise()).rejects.toThrow(FeeNotLoaded);
95
- });
96
- });
@@ -1,63 +0,0 @@
1
- import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
2
- import { Account, Operation, OperationType, TransactionCommon } from "@ledgerhq/types-live";
3
- import {
4
- Operation as CoreOperation,
5
- Asset,
6
- TransactionIntent,
7
- } from "@ledgerhq/coin-framework/api/types";
8
- import BigNumber from "bignumber.js";
9
- import { fromBigNumberToBigInt } from "@ledgerhq/coin-framework/utils";
10
-
11
- export function adaptCoreOperationToLiveOperation(
12
- accountId: string,
13
- op: CoreOperation<Asset>,
14
- ): Operation {
15
- return {
16
- id: encodeOperationId(accountId, op.tx.hash, op.type),
17
- hash: op.tx.hash,
18
- accountId,
19
- type: op.type as OperationType,
20
- value: new BigNumber(op.value.toString()),
21
- fee: new BigNumber(op.tx.fees.toString()),
22
- blockHash: op.tx.block.hash,
23
- blockHeight: op.tx.block.height,
24
- senders: op.senders,
25
- recipients: op.recipients,
26
- date: op.tx.date,
27
- transactionSequenceNumber: op.details?.sequence as number,
28
- extra: {},
29
- };
30
- }
31
-
32
- export function transactionToIntent(
33
- _account: Account,
34
- transaction: TransactionCommon,
35
- ): TransactionIntent<any> {
36
- return {
37
- type: "Payment",
38
- sender: _account.freshAddress,
39
- recipient: transaction.recipient,
40
- amount: fromBigNumberToBigInt(transaction.amount, BigInt(0)),
41
- asset: null,
42
- };
43
- }
44
-
45
- export const buildOptimisticOperation = (
46
- account: Account,
47
- transaction: TransactionCommon,
48
- ): Operation => {
49
- return {
50
- id: encodeOperationId(account.id, "", "OUT"),
51
- hash: "",
52
- type: "OUT",
53
- value: transaction.amount,
54
- fee: transaction["fees"] ?? BigNumber(0),
55
- blockHash: null,
56
- blockHeight: null,
57
- senders: [account.freshAddress.toString()],
58
- recipients: [transaction.recipient],
59
- accountId: account.id,
60
- date: new Date(),
61
- extra: {},
62
- };
63
- };
@@ -1,4 +0,0 @@
1
- export enum OperationType {
2
- Buy = "Buy",
3
- Sell = "Sell",
4
- }
@@ -1,37 +0,0 @@
1
- import { useEffect, useState } from "react";
2
- import { useFeature } from "../featureFlags";
3
- import { useQuery } from "@tanstack/react-query";
4
- import { getEnv } from "@ledgerhq/live-env";
5
-
6
- const baseURL = () => getEnv("LEDGER_COUNTERVALUES_API");
7
-
8
- export const useOFACGeoBlockCheck = ({
9
- onFinish,
10
- geoBlockingFeatureFlagKey,
11
- }: {
12
- onFinish?: () => void;
13
- geoBlockingFeatureFlagKey: "llmOfacGeoBlocking" | "lldOfacGeoBlocking";
14
- }) => {
15
- const [blocked, setBlocked] = useState<boolean>(false);
16
-
17
- const platformOfacGeoBlocking = useFeature(geoBlockingFeatureFlagKey);
18
-
19
- const { data, isLoading } = useQuery({
20
- queryKey: ["ofac-geo-block", geoBlockingFeatureFlagKey],
21
- queryFn: async () => {
22
- if (!platformOfacGeoBlocking?.enabled) return false;
23
- const res = await fetch(`${baseURL()}/v3/market`);
24
- return res.status === 451;
25
- },
26
- });
27
-
28
- useEffect(() => {
29
- if (!platformOfacGeoBlocking?.enabled) return;
30
- setBlocked(data ?? false);
31
- if (typeof onFinish === "function") {
32
- onFinish();
33
- }
34
- }, [data, onFinish, platformOfacGeoBlocking]);
35
-
36
- return { blocked, isLoading };
37
- };
@@ -1,31 +0,0 @@
1
- export class UserAddressSanctionedError extends Error {
2
- constructor() {
3
- super();
4
- this.message = this.constructor.name;
5
- this.name = this.constructor.name;
6
- }
7
- }
8
-
9
- export class UserAddressSanctionedForSendError extends Error {
10
- constructor() {
11
- super();
12
- this.message = this.constructor.name;
13
- this.name = this.constructor.name;
14
- }
15
- }
16
-
17
- export class UserAddressSanctionedForStakingError extends Error {
18
- constructor() {
19
- super();
20
- this.message = this.constructor.name;
21
- this.name = this.constructor.name;
22
- }
23
- }
24
-
25
- export class RecipientAddressSanctionedError extends Error {
26
- constructor() {
27
- super();
28
- this.message = this.constructor.name;
29
- this.name = this.constructor.name;
30
- }
31
- }
@@ -1,59 +0,0 @@
1
- import { LiveConfig } from "@ledgerhq/live-config/LiveConfig";
2
- import axios from "axios";
3
- import { hours, makeLRUCache } from "@ledgerhq/live-network/cache";
4
- import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
5
- import { getCurrencyConfiguration, getSharedConfiguration } from "../config";
6
- import { CurrencyConfig } from "@ledgerhq/coin-framework/config";
7
-
8
- const cache = makeLRUCache(fetchSanctionedAddresses, () => "all_sanctioned_addresses", hours(12));
9
-
10
- async function fetchSanctionedAddresses(): Promise<Record<string, string[]>> {
11
- const { data } = await axios.get(
12
- "https://ofac-compliance.pages.dev/all_sanctioned_addresses.json",
13
- );
14
- return data;
15
- }
16
-
17
- export async function isAddressSanctioned(
18
- currency: CryptoCurrency,
19
- address: string,
20
- ): Promise<boolean> {
21
- if (!isCheckBlacklistAddressEnabled(currency)) {
22
- return false;
23
- }
24
-
25
- // Only for testing, should be deleted after
26
- const temporarySanctionedAddresses: string[] | undefined =
27
- LiveConfig.getValueByKey(`tmp_sanctioned_addresses`);
28
-
29
- const data: Record<string, string[]> = await cache();
30
- const addresses = data[currency.ticker] || [];
31
-
32
- if (temporarySanctionedAddresses) {
33
- return addresses.concat(temporarySanctionedAddresses).includes(address);
34
- }
35
-
36
- return addresses.includes(address);
37
- }
38
-
39
- function isCheckBlacklistAddressEnabled(currency: CryptoCurrency): boolean {
40
- const currencyConfig = tryGetCurrencyConfig(currency);
41
- if (currencyConfig && "checkBlacklistAddress" in currencyConfig) {
42
- return currencyConfig.checkBlacklistAddress === true;
43
- } else {
44
- const sharedConfiguration = getSharedConfiguration();
45
- if ("checkBlacklistAddress" in sharedConfiguration) {
46
- return sharedConfiguration.checkBlacklistAddress === true;
47
- }
48
- }
49
-
50
- return false;
51
- }
52
-
53
- function tryGetCurrencyConfig(currency: CryptoCurrency): CurrencyConfig | undefined {
54
- try {
55
- return getCurrencyConfiguration(currency);
56
- } catch (error) {
57
- return undefined;
58
- }
59
- }