@ledgerhq/coin-filecoin 1.3.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 (316) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/.unimportedrc.json +21 -0
  3. package/CHANGELOG.md +19 -0
  4. package/LICENSE.txt +21 -0
  5. package/jest.config.js +8 -0
  6. package/lib/api/api.d.ts +9 -0
  7. package/lib/api/api.d.ts.map +1 -0
  8. package/lib/api/api.js +99 -0
  9. package/lib/api/api.js.map +1 -0
  10. package/lib/api/index.d.ts +2 -0
  11. package/lib/api/index.d.ts.map +1 -0
  12. package/lib/api/index.js +18 -0
  13. package/lib/api/index.js.map +1 -0
  14. package/lib/bridge/broadcast.d.ts +4 -0
  15. package/lib/bridge/broadcast.d.ts.map +1 -0
  16. package/lib/bridge/broadcast.js +27 -0
  17. package/lib/bridge/broadcast.js.map +1 -0
  18. package/lib/bridge/buildOptimisticOperation.d.ts +5 -0
  19. package/lib/bridge/buildOptimisticOperation.d.ts.map +1 -0
  20. package/lib/bridge/buildOptimisticOperation.js +62 -0
  21. package/lib/bridge/buildOptimisticOperation.js.map +1 -0
  22. package/lib/bridge/createTransaction.d.ts +4 -0
  23. package/lib/bridge/createTransaction.d.ts.map +1 -0
  24. package/lib/bridge/createTransaction.js +24 -0
  25. package/lib/bridge/createTransaction.js.map +1 -0
  26. package/lib/bridge/deviceTransactionConfig.d.ts +33 -0
  27. package/lib/bridge/deviceTransactionConfig.d.ts.map +1 -0
  28. package/lib/bridge/deviceTransactionConfig.js +71 -0
  29. package/lib/bridge/deviceTransactionConfig.js.map +1 -0
  30. package/lib/bridge/estimateMaxSpendable.d.ts +4 -0
  31. package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -0
  32. package/lib/bridge/estimateMaxSpendable.js +100 -0
  33. package/lib/bridge/estimateMaxSpendable.js.map +1 -0
  34. package/lib/bridge/getTransactionStatus.d.ts +4 -0
  35. package/lib/bridge/getTransactionStatus.d.ts.map +1 -0
  36. package/lib/bridge/getTransactionStatus.js +84 -0
  37. package/lib/bridge/getTransactionStatus.js.map +1 -0
  38. package/lib/bridge/index.d.ts +8 -0
  39. package/lib/bridge/index.d.ts.map +1 -0
  40. package/lib/bridge/index.js +54 -0
  41. package/lib/bridge/index.js.map +1 -0
  42. package/lib/bridge/prepareTransaction.d.ts +4 -0
  43. package/lib/bridge/prepareTransaction.d.ts.map +1 -0
  44. package/lib/bridge/prepareTransaction.js +75 -0
  45. package/lib/bridge/prepareTransaction.js.map +1 -0
  46. package/lib/bridge/serializer.d.ts +13 -0
  47. package/lib/bridge/serializer.d.ts.map +1 -0
  48. package/lib/bridge/serializer.js +65 -0
  49. package/lib/bridge/serializer.js.map +1 -0
  50. package/lib/bridge/signOperation.d.ts +5 -0
  51. package/lib/bridge/signOperation.d.ts.map +1 -0
  52. package/lib/bridge/signOperation.js +80 -0
  53. package/lib/bridge/signOperation.js.map +1 -0
  54. package/lib/bridge/transaction.d.ts +14 -0
  55. package/lib/bridge/transaction.d.ts.map +1 -0
  56. package/lib/bridge/transaction.js +41 -0
  57. package/lib/bridge/transaction.js.map +1 -0
  58. package/lib/bridge/utils.d.ts +26 -0
  59. package/lib/bridge/utils.d.ts.map +1 -0
  60. package/lib/bridge/utils.js +67 -0
  61. package/lib/bridge/utils.js.map +1 -0
  62. package/lib/bridge/utils.unit.test.d.ts +2 -0
  63. package/lib/bridge/utils.unit.test.d.ts.map +1 -0
  64. package/lib/bridge/utils.unit.test.js +23 -0
  65. package/lib/bridge/utils.unit.test.js.map +1 -0
  66. package/lib/common-logic/index.d.ts +2 -0
  67. package/lib/common-logic/index.d.ts.map +1 -0
  68. package/lib/common-logic/index.js +13 -0
  69. package/lib/common-logic/index.js.map +1 -0
  70. package/lib/common-logic/utils.d.ts +22 -0
  71. package/lib/common-logic/utils.d.ts.map +1 -0
  72. package/lib/common-logic/utils.js +189 -0
  73. package/lib/common-logic/utils.js.map +1 -0
  74. package/lib/erc20/ERC20.json +12 -0
  75. package/lib/erc20/tokenAccounts.d.ts +10 -0
  76. package/lib/erc20/tokenAccounts.d.ts.map +1 -0
  77. package/lib/erc20/tokenAccounts.js +169 -0
  78. package/lib/erc20/tokenAccounts.js.map +1 -0
  79. package/lib/errors.d.ts +7 -0
  80. package/lib/errors.d.ts.map +1 -0
  81. package/lib/errors.js +13 -0
  82. package/lib/errors.js.map +1 -0
  83. package/lib/hw-signMessage.d.ts +12 -0
  84. package/lib/hw-signMessage.d.ts.map +1 -0
  85. package/lib/hw-signMessage.js +32 -0
  86. package/lib/hw-signMessage.js.map +1 -0
  87. package/lib/index.d.ts +2 -0
  88. package/lib/index.d.ts.map +1 -0
  89. package/lib/index.js +6 -0
  90. package/lib/index.js.map +1 -0
  91. package/lib/network/addresses.d.ts +16 -0
  92. package/lib/network/addresses.d.ts.map +1 -0
  93. package/lib/network/addresses.js +75 -0
  94. package/lib/network/addresses.js.map +1 -0
  95. package/lib/network/index.d.ts +2 -0
  96. package/lib/network/index.d.ts.map +1 -0
  97. package/lib/network/index.js +18 -0
  98. package/lib/network/index.js.map +1 -0
  99. package/lib/signer/getAddress.d.ts +6 -0
  100. package/lib/signer/getAddress.d.ts.map +1 -0
  101. package/lib/signer/getAddress.js +30 -0
  102. package/lib/signer/getAddress.js.map +1 -0
  103. package/lib/signer/index.d.ts +3 -0
  104. package/lib/signer/index.d.ts.map +1 -0
  105. package/lib/signer/index.js +8 -0
  106. package/lib/signer/index.js.map +1 -0
  107. package/lib/test/bot-specs.d.ts +7 -0
  108. package/lib/test/bot-specs.d.ts.map +1 -0
  109. package/lib/test/bot-specs.js +151 -0
  110. package/lib/test/bot-specs.js.map +1 -0
  111. package/lib/test/bridgeDatasetTest.d.ts +4 -0
  112. package/lib/test/bridgeDatasetTest.d.ts.map +1 -0
  113. package/lib/test/bridgeDatasetTest.js +401 -0
  114. package/lib/test/bridgeDatasetTest.js.map +1 -0
  115. package/lib/test/cli.d.ts +19 -0
  116. package/lib/test/cli.d.ts.map +1 -0
  117. package/lib/test/cli.js +59 -0
  118. package/lib/test/cli.js.map +1 -0
  119. package/lib/test/index.d.ts +6 -0
  120. package/lib/test/index.d.ts.map +1 -0
  121. package/lib/test/index.js +26 -0
  122. package/lib/test/index.js.map +1 -0
  123. package/lib/test/speculos-deviceActions.d.ts +5 -0
  124. package/lib/test/speculos-deviceActions.d.ts.map +1 -0
  125. package/lib/test/speculos-deviceActions.js +159 -0
  126. package/lib/test/speculos-deviceActions.js.map +1 -0
  127. package/lib/types/bridge.d.ts +35 -0
  128. package/lib/types/bridge.d.ts.map +1 -0
  129. package/lib/types/bridge.js +3 -0
  130. package/lib/types/bridge.js.map +1 -0
  131. package/lib/types/common.d.ts +96 -0
  132. package/lib/types/common.d.ts.map +1 -0
  133. package/lib/types/common.js +10 -0
  134. package/lib/types/common.js.map +1 -0
  135. package/lib/types/index.d.ts +4 -0
  136. package/lib/types/index.d.ts.map +1 -0
  137. package/lib/types/index.js +20 -0
  138. package/lib/types/index.js.map +1 -0
  139. package/lib/types/signer.d.ts +19 -0
  140. package/lib/types/signer.d.ts.map +1 -0
  141. package/lib/types/signer.js +3 -0
  142. package/lib/types/signer.js.map +1 -0
  143. package/lib-es/api/api.d.ts +9 -0
  144. package/lib-es/api/api.d.ts.map +1 -0
  145. package/lib-es/api/api.js +87 -0
  146. package/lib-es/api/api.js.map +1 -0
  147. package/lib-es/api/index.d.ts +2 -0
  148. package/lib-es/api/index.d.ts.map +1 -0
  149. package/lib-es/api/index.js +2 -0
  150. package/lib-es/api/index.js.map +1 -0
  151. package/lib-es/bridge/broadcast.d.ts +4 -0
  152. package/lib-es/bridge/broadcast.d.ts.map +1 -0
  153. package/lib-es/bridge/broadcast.js +23 -0
  154. package/lib-es/bridge/broadcast.js.map +1 -0
  155. package/lib-es/bridge/buildOptimisticOperation.d.ts +5 -0
  156. package/lib-es/bridge/buildOptimisticOperation.d.ts.map +1 -0
  157. package/lib-es/bridge/buildOptimisticOperation.js +58 -0
  158. package/lib-es/bridge/buildOptimisticOperation.js.map +1 -0
  159. package/lib-es/bridge/createTransaction.d.ts +4 -0
  160. package/lib-es/bridge/createTransaction.d.ts.map +1 -0
  161. package/lib-es/bridge/createTransaction.js +17 -0
  162. package/lib-es/bridge/createTransaction.js.map +1 -0
  163. package/lib-es/bridge/deviceTransactionConfig.d.ts +33 -0
  164. package/lib-es/bridge/deviceTransactionConfig.d.ts.map +1 -0
  165. package/lib-es/bridge/deviceTransactionConfig.js +69 -0
  166. package/lib-es/bridge/deviceTransactionConfig.js.map +1 -0
  167. package/lib-es/bridge/estimateMaxSpendable.d.ts +4 -0
  168. package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -0
  169. package/lib-es/bridge/estimateMaxSpendable.js +93 -0
  170. package/lib-es/bridge/estimateMaxSpendable.js.map +1 -0
  171. package/lib-es/bridge/getTransactionStatus.d.ts +4 -0
  172. package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -0
  173. package/lib-es/bridge/getTransactionStatus.js +80 -0
  174. package/lib-es/bridge/getTransactionStatus.js.map +1 -0
  175. package/lib-es/bridge/index.d.ts +8 -0
  176. package/lib-es/bridge/index.d.ts.map +1 -0
  177. package/lib-es/bridge/index.js +47 -0
  178. package/lib-es/bridge/index.js.map +1 -0
  179. package/lib-es/bridge/prepareTransaction.d.ts +4 -0
  180. package/lib-es/bridge/prepareTransaction.d.ts.map +1 -0
  181. package/lib-es/bridge/prepareTransaction.js +68 -0
  182. package/lib-es/bridge/prepareTransaction.js.map +1 -0
  183. package/lib-es/bridge/serializer.d.ts +13 -0
  184. package/lib-es/bridge/serializer.d.ts.map +1 -0
  185. package/lib-es/bridge/serializer.js +58 -0
  186. package/lib-es/bridge/serializer.js.map +1 -0
  187. package/lib-es/bridge/signOperation.d.ts +5 -0
  188. package/lib-es/bridge/signOperation.d.ts.map +1 -0
  189. package/lib-es/bridge/signOperation.js +76 -0
  190. package/lib-es/bridge/signOperation.js.map +1 -0
  191. package/lib-es/bridge/transaction.d.ts +14 -0
  192. package/lib-es/bridge/transaction.d.ts.map +1 -0
  193. package/lib-es/bridge/transaction.js +33 -0
  194. package/lib-es/bridge/transaction.js.map +1 -0
  195. package/lib-es/bridge/utils.d.ts +26 -0
  196. package/lib-es/bridge/utils.d.ts.map +1 -0
  197. package/lib-es/bridge/utils.js +57 -0
  198. package/lib-es/bridge/utils.js.map +1 -0
  199. package/lib-es/bridge/utils.unit.test.d.ts +2 -0
  200. package/lib-es/bridge/utils.unit.test.d.ts.map +1 -0
  201. package/lib-es/bridge/utils.unit.test.js +21 -0
  202. package/lib-es/bridge/utils.unit.test.js.map +1 -0
  203. package/lib-es/common-logic/index.d.ts +2 -0
  204. package/lib-es/common-logic/index.d.ts.map +1 -0
  205. package/lib-es/common-logic/index.js +2 -0
  206. package/lib-es/common-logic/index.js.map +1 -0
  207. package/lib-es/common-logic/utils.d.ts +22 -0
  208. package/lib-es/common-logic/utils.d.ts.map +1 -0
  209. package/lib-es/common-logic/utils.js +175 -0
  210. package/lib-es/common-logic/utils.js.map +1 -0
  211. package/lib-es/erc20/ERC20.json +12 -0
  212. package/lib-es/erc20/tokenAccounts.d.ts +10 -0
  213. package/lib-es/erc20/tokenAccounts.d.ts.map +1 -0
  214. package/lib-es/erc20/tokenAccounts.js +158 -0
  215. package/lib-es/erc20/tokenAccounts.js.map +1 -0
  216. package/lib-es/errors.d.ts +7 -0
  217. package/lib-es/errors.d.ts.map +1 -0
  218. package/lib-es/errors.js +10 -0
  219. package/lib-es/errors.js.map +1 -0
  220. package/lib-es/hw-signMessage.d.ts +12 -0
  221. package/lib-es/hw-signMessage.d.ts.map +1 -0
  222. package/lib-es/hw-signMessage.js +28 -0
  223. package/lib-es/hw-signMessage.js.map +1 -0
  224. package/lib-es/index.d.ts +2 -0
  225. package/lib-es/index.d.ts.map +1 -0
  226. package/lib-es/index.js +2 -0
  227. package/lib-es/index.js.map +1 -0
  228. package/lib-es/network/addresses.d.ts +16 -0
  229. package/lib-es/network/addresses.d.ts.map +1 -0
  230. package/lib-es/network/addresses.js +64 -0
  231. package/lib-es/network/addresses.js.map +1 -0
  232. package/lib-es/network/index.d.ts +2 -0
  233. package/lib-es/network/index.d.ts.map +1 -0
  234. package/lib-es/network/index.js +2 -0
  235. package/lib-es/network/index.js.map +1 -0
  236. package/lib-es/signer/getAddress.d.ts +6 -0
  237. package/lib-es/signer/getAddress.d.ts.map +1 -0
  238. package/lib-es/signer/getAddress.js +28 -0
  239. package/lib-es/signer/getAddress.js.map +1 -0
  240. package/lib-es/signer/index.d.ts +3 -0
  241. package/lib-es/signer/index.d.ts.map +1 -0
  242. package/lib-es/signer/index.js +3 -0
  243. package/lib-es/signer/index.js.map +1 -0
  244. package/lib-es/test/bot-specs.d.ts +7 -0
  245. package/lib-es/test/bot-specs.d.ts.map +1 -0
  246. package/lib-es/test/bot-specs.js +146 -0
  247. package/lib-es/test/bot-specs.js.map +1 -0
  248. package/lib-es/test/bridgeDatasetTest.d.ts +4 -0
  249. package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -0
  250. package/lib-es/test/bridgeDatasetTest.js +395 -0
  251. package/lib-es/test/bridgeDatasetTest.js.map +1 -0
  252. package/lib-es/test/cli.d.ts +19 -0
  253. package/lib-es/test/cli.d.ts.map +1 -0
  254. package/lib-es/test/cli.js +53 -0
  255. package/lib-es/test/cli.js.map +1 -0
  256. package/lib-es/test/index.d.ts +6 -0
  257. package/lib-es/test/index.d.ts.map +1 -0
  258. package/lib-es/test/index.js +6 -0
  259. package/lib-es/test/index.js.map +1 -0
  260. package/lib-es/test/speculos-deviceActions.d.ts +5 -0
  261. package/lib-es/test/speculos-deviceActions.d.ts.map +1 -0
  262. package/lib-es/test/speculos-deviceActions.js +152 -0
  263. package/lib-es/test/speculos-deviceActions.js.map +1 -0
  264. package/lib-es/types/bridge.d.ts +35 -0
  265. package/lib-es/types/bridge.d.ts.map +1 -0
  266. package/lib-es/types/bridge.js +2 -0
  267. package/lib-es/types/bridge.js.map +1 -0
  268. package/lib-es/types/common.d.ts +96 -0
  269. package/lib-es/types/common.d.ts.map +1 -0
  270. package/lib-es/types/common.js +7 -0
  271. package/lib-es/types/common.js.map +1 -0
  272. package/lib-es/types/index.d.ts +4 -0
  273. package/lib-es/types/index.d.ts.map +1 -0
  274. package/lib-es/types/index.js +4 -0
  275. package/lib-es/types/index.js.map +1 -0
  276. package/lib-es/types/signer.d.ts +19 -0
  277. package/lib-es/types/signer.d.ts.map +1 -0
  278. package/lib-es/types/signer.js +2 -0
  279. package/lib-es/types/signer.js.map +1 -0
  280. package/package.json +135 -0
  281. package/src/api/api.ts +125 -0
  282. package/src/api/index.ts +1 -0
  283. package/src/bridge/broadcast.ts +20 -0
  284. package/src/bridge/buildOptimisticOperation.ts +58 -0
  285. package/src/bridge/createTransaction.ts +20 -0
  286. package/src/bridge/deviceTransactionConfig.ts +119 -0
  287. package/src/bridge/estimateMaxSpendable.ts +120 -0
  288. package/src/bridge/getTransactionStatus.ts +80 -0
  289. package/src/bridge/index.ts +63 -0
  290. package/src/bridge/prepareTransaction.ts +82 -0
  291. package/src/bridge/serializer.ts +63 -0
  292. package/src/bridge/signOperation.ts +97 -0
  293. package/src/bridge/transaction.ts +69 -0
  294. package/src/bridge/utils.ts +73 -0
  295. package/src/bridge/utils.unit.test.ts +27 -0
  296. package/src/common-logic/index.ts +10 -0
  297. package/src/common-logic/utils.ts +232 -0
  298. package/src/erc20/ERC20.json +12 -0
  299. package/src/erc20/tokenAccounts.ts +183 -0
  300. package/src/errors.ts +13 -0
  301. package/src/hw-signMessage.ts +27 -0
  302. package/src/index.ts +1 -0
  303. package/src/network/addresses.ts +93 -0
  304. package/src/network/index.ts +1 -0
  305. package/src/signer/getAddress.ts +28 -0
  306. package/src/signer/index.ts +3 -0
  307. package/src/test/bot-specs.ts +163 -0
  308. package/src/test/bridgeDatasetTest.ts +403 -0
  309. package/src/test/cli.ts +80 -0
  310. package/src/test/index.ts +6 -0
  311. package/src/test/speculos-deviceActions.ts +166 -0
  312. package/src/types/bridge.ts +42 -0
  313. package/src/types/common.ts +105 -0
  314. package/src/types/index.ts +3 -0
  315. package/src/types/signer.ts +19 -0
  316. package/tsconfig.json +14 -0
@@ -0,0 +1,152 @@
1
+ import { deviceActionFlow, formatDeviceAmount, SpeculosButton, } from "@ledgerhq/coin-framework/bot/specs";
2
+ import { BotScenario, expectedToFieldForTokenTransfer, Methods, methodToString, } from "../bridge/utils";
3
+ import { isFilEthAddress } from "../network";
4
+ import { fromEthAddress, fromString, toEthAddress } from "iso-filecoin/address";
5
+ import { getSubAccount } from "../common-logic";
6
+ import invariant from "invariant";
7
+ export const generateDeviceActionFlow = (scenario) => {
8
+ const data = { steps: [] };
9
+ data.steps = data.steps.concat([
10
+ {
11
+ title: "Please",
12
+ button: SpeculosButton.RIGHT,
13
+ },
14
+ ]);
15
+ if (scenario == BotScenario.F4_RECIPIENT) {
16
+ data.steps.push({
17
+ title: "To",
18
+ button: SpeculosButton.RIGHT,
19
+ expectedValue: ({ transaction }) => {
20
+ const addr = fromString(transaction.recipient);
21
+ if (isFilEthAddress(addr)) {
22
+ return toEthAddress(addr) + transaction.recipient;
23
+ }
24
+ return "unexpected flow... address should be eth type";
25
+ },
26
+ });
27
+ }
28
+ else if (scenario == BotScenario.ETH_RECIPIENT) {
29
+ data.steps.push({
30
+ title: "To",
31
+ button: SpeculosButton.RIGHT,
32
+ expectedValue: ({ transaction }) => {
33
+ const addr = fromEthAddress(transaction.recipient, "mainnet");
34
+ return transaction.recipient + addr.toString();
35
+ },
36
+ });
37
+ }
38
+ else if (scenario == BotScenario.TOKEN_TRANSFER) {
39
+ data.steps.push({
40
+ title: "To",
41
+ button: SpeculosButton.RIGHT,
42
+ expectedValue: ({ transaction }) => {
43
+ return expectedToFieldForTokenTransfer(transaction.recipient);
44
+ },
45
+ });
46
+ }
47
+ else {
48
+ data.steps.push({
49
+ title: "To",
50
+ button: SpeculosButton.RIGHT,
51
+ expectedValue: ({ transaction }) => transaction.recipient,
52
+ });
53
+ }
54
+ data.steps = data.steps.concat([
55
+ {
56
+ title: "From",
57
+ button: SpeculosButton.RIGHT,
58
+ expectedValue: ({ account }) => account.freshAddress,
59
+ },
60
+ {
61
+ title: "Nonce",
62
+ button: SpeculosButton.RIGHT,
63
+ expectedValue: ({ transaction }) => transaction.nonce.toString(),
64
+ },
65
+ ]);
66
+ if (scenario == BotScenario.TOKEN_TRANSFER) {
67
+ data.steps.push({
68
+ title: "Value",
69
+ button: SpeculosButton.RIGHT,
70
+ expectedValue: ({ account, transaction }) => {
71
+ const subAccount = getSubAccount(account, transaction);
72
+ invariant(subAccount, "subAccount is required for token transfer");
73
+ return formatDeviceAmount(subAccount.token, transaction.amount, {
74
+ hideCode: false,
75
+ showAllDigits: true,
76
+ });
77
+ },
78
+ });
79
+ }
80
+ else {
81
+ data.steps.push({
82
+ title: "Value",
83
+ button: SpeculosButton.RIGHT,
84
+ expectedValue: ({ account, status }) => formatDeviceAmount(account.currency, status.amount, {
85
+ hideCode: true,
86
+ showAllDigits: true,
87
+ }),
88
+ });
89
+ }
90
+ if (scenario === BotScenario.TOKEN_TRANSFER) {
91
+ data.steps.push({
92
+ title: "Gas Limit",
93
+ button: SpeculosButton.RIGHT,
94
+ expectedValue: ({ transaction, account }) => formatDeviceAmount(account.currency, transaction.gasLimit, {
95
+ hideCode: false,
96
+ showAllDigits: true,
97
+ }),
98
+ });
99
+ }
100
+ else {
101
+ data.steps = data.steps.concat([
102
+ {
103
+ title: "Gas Limit",
104
+ button: SpeculosButton.RIGHT,
105
+ expectedValue: ({ transaction }) => transaction.gasLimit.toFixed(),
106
+ },
107
+ {
108
+ title: "Gas Premium",
109
+ button: SpeculosButton.RIGHT,
110
+ expectedValue: ({ account, transaction }) => formatDeviceAmount(account.currency, transaction.gasPremium, {
111
+ hideCode: true,
112
+ showAllDigits: true,
113
+ }),
114
+ },
115
+ {
116
+ title: "Gas Fee Cap",
117
+ button: SpeculosButton.RIGHT,
118
+ expectedValue: ({ account, transaction }) => formatDeviceAmount(account.currency, transaction.gasFeeCap, {
119
+ hideCode: true,
120
+ showAllDigits: true,
121
+ }),
122
+ },
123
+ ]);
124
+ }
125
+ if (scenario == BotScenario.ETH_RECIPIENT || scenario == BotScenario.F4_RECIPIENT) {
126
+ data.steps.push({
127
+ title: "Method",
128
+ button: SpeculosButton.RIGHT,
129
+ expectedValue: () => Methods.InvokeEVM.toString(),
130
+ });
131
+ }
132
+ else if (scenario == BotScenario.TOKEN_TRANSFER) {
133
+ data.steps.push({
134
+ title: "Method",
135
+ button: SpeculosButton.RIGHT,
136
+ expectedValue: () => methodToString(Methods.ERC20Transfer),
137
+ });
138
+ }
139
+ else {
140
+ data.steps.push({
141
+ title: "Method",
142
+ button: SpeculosButton.RIGHT,
143
+ expectedValue: () => "Transfer",
144
+ });
145
+ }
146
+ data.steps.push({
147
+ title: "APPROVE",
148
+ button: SpeculosButton.BOTH,
149
+ });
150
+ return deviceActionFlow(data);
151
+ };
152
+ //# sourceMappingURL=speculos-deviceActions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"speculos-deviceActions.js","sourceRoot":"","sources":["../../src/test/speculos-deviceActions.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,WAAW,EACX,+BAA+B,EAC/B,OAAO,EACP,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,QAAqB,EAAkC,EAAE;IAChG,MAAM,IAAI,GAAwD,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAChF,I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AAC,CAAC;AAChC,CAAC,CAAC"}
@@ -0,0 +1,35 @@
1
+ /// <reference types="node" />
2
+ import { TransactionCommon, TransactionCommonRaw, TransactionStatusCommon, TransactionStatusCommonRaw } from "@ledgerhq/types-live";
3
+ import { BigNumber } from "bignumber.js";
4
+ type FamilyType = "filecoin";
5
+ export type NetworkInfo = {
6
+ family: FamilyType;
7
+ };
8
+ export type NetworkInfoRaw = {
9
+ family: FamilyType;
10
+ };
11
+ export type Transaction = TransactionCommon & {
12
+ family: FamilyType;
13
+ nonce: number;
14
+ data?: Buffer;
15
+ method: number;
16
+ version: number;
17
+ params?: string | undefined;
18
+ gasLimit: BigNumber;
19
+ gasFeeCap: BigNumber;
20
+ gasPremium: BigNumber;
21
+ };
22
+ export type TransactionRaw = TransactionCommonRaw & {
23
+ family: FamilyType;
24
+ version: number;
25
+ nonce: number;
26
+ data?: string;
27
+ method: number;
28
+ gasLimit: number;
29
+ gasFeeCap: string;
30
+ gasPremium: string;
31
+ };
32
+ export type TransactionStatus = TransactionStatusCommon;
33
+ export type TransactionStatusRaw = TransactionStatusCommonRaw;
34
+ export {};
35
+ //# sourceMappingURL=bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/types/bridge.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,KAAK,UAAU,GAAG,UAAU,CAAC;AAE7B,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,UAAU,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG;IAC5C,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,SAAS,CAAC;CACvB,CAAC;AACF,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAAG;IAClD,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;AAExD,MAAM,MAAM,oBAAoB,GAAG,0BAA0B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../src/types/bridge.ts"],"names":[],"mappings":""}
@@ -0,0 +1,96 @@
1
+ export declare const BroadcastBlockIncl = 1;
2
+ export declare enum TxStatus {
3
+ Ok = "Ok",
4
+ Fail = "Fail"
5
+ }
6
+ export interface EstimatedFeesRequest {
7
+ to?: string | undefined;
8
+ from: string;
9
+ methodNum?: number;
10
+ blockIncl?: number;
11
+ params?: string;
12
+ value?: string;
13
+ }
14
+ export interface EstimatedFeesResponse {
15
+ gas_limit: number;
16
+ gas_fee_cap: string;
17
+ gas_premium: string;
18
+ nonce: number;
19
+ }
20
+ export interface TransactionsResponse {
21
+ txs: TransactionResponse[];
22
+ }
23
+ export interface TransactionResponse {
24
+ amount: number;
25
+ to: string;
26
+ from: string;
27
+ status: string;
28
+ type: string;
29
+ hash: string;
30
+ timestamp: number;
31
+ height: number;
32
+ fee?: number;
33
+ }
34
+ export interface BalanceResponse {
35
+ locked_balance: string;
36
+ spendable_balance: string;
37
+ total_balance: string;
38
+ }
39
+ export interface NetworkStatusResponse {
40
+ current_block_identifier: BlockIdentifier;
41
+ genesis_block_identifier: BlockIdentifier;
42
+ oldest_block_identifier?: BlockIdentifier;
43
+ current_block_timestamp: number;
44
+ }
45
+ export interface BroadcastTransactionRequest {
46
+ message: {
47
+ version: number;
48
+ to: string;
49
+ from: string;
50
+ nonce: number;
51
+ value: string;
52
+ gaslimit: number;
53
+ gasfeecap: string;
54
+ gaspremium: string;
55
+ method: number;
56
+ params: string;
57
+ };
58
+ signature: {
59
+ type: number;
60
+ data: string;
61
+ };
62
+ }
63
+ export interface BroadcastTransactionResponse {
64
+ hash: string;
65
+ }
66
+ interface BlockIdentifier {
67
+ index: number;
68
+ hash: string;
69
+ }
70
+ export interface ConvertFilToEthResponse {
71
+ address: string;
72
+ }
73
+ export interface FetchERC20TransactionsResponse {
74
+ txs: ERC20Transfer[];
75
+ }
76
+ export interface ERC20Transfer {
77
+ id: string;
78
+ height: number;
79
+ type: string;
80
+ status: string;
81
+ to: string;
82
+ from: string;
83
+ amount: string;
84
+ contract_address: string;
85
+ timestamp: number;
86
+ tx_hash: string;
87
+ tx_cid?: string;
88
+ }
89
+ export interface ERC20BalanceResponse {
90
+ data: {
91
+ balance: string;
92
+ height: number;
93
+ }[];
94
+ }
95
+ export {};
96
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC,oBAAY,QAAQ;IAClB,EAAE,OAAO;IACT,IAAI,SAAS;CACd;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,I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AAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,SAAS,EAAE;QACT,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,8BAA8B;IAC7C,GAAG,EAAE,aAAa,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC7C"}
@@ -0,0 +1,7 @@
1
+ export const BroadcastBlockIncl = 1;
2
+ export var TxStatus;
3
+ (function (TxStatus) {
4
+ TxStatus["Ok"] = "Ok";
5
+ TxStatus["Fail"] = "Fail";
6
+ })(TxStatus || (TxStatus = {}));
7
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAEpC,MAAM,CAAN,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,qBAAS,CAAA;IACT,yBAAa,CAAA;AACf,CAAC,EAHW,QAAQ,KAAR,QAAQ,QAGnB"}
@@ -0,0 +1,4 @@
1
+ export * from "./bridge";
2
+ export * from "./signer";
3
+ export * from "./common";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./bridge";
2
+ export * from "./signer";
3
+ export * from "./common";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,19 @@
1
+ export type FilecoinSignature = {
2
+ return_code: number;
3
+ error_message: string;
4
+ signature_der: Uint8Array;
5
+ signature_compact: Uint8Array;
6
+ };
7
+ export type FilecoinGetAddrResponse = {
8
+ addrByte: Uint8Array;
9
+ addrString: string;
10
+ compressed_pk: Uint8Array;
11
+ return_code: number;
12
+ error_message: string;
13
+ };
14
+ export interface FilecoinSigner {
15
+ showAddressAndPubKey(path: string): Promise<FilecoinGetAddrResponse>;
16
+ getAddressAndPubKey(path: string): Promise<FilecoinGetAddrResponse>;
17
+ sign(path: string, message: Uint8Array): Promise<FilecoinSignature>;
18
+ }
19
+ //# sourceMappingURL=signer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/types/signer.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,UAAU,CAAC;IAC1B,iBAAiB,EAAE,UAAU,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,UAAU,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,UAAU,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AACF,MAAM,WAAW,cAAc;IAC7B,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACrE,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACpE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACrE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=signer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/types/signer.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,135 @@
1
+ {
2
+ "name": "@ledgerhq/coin-filecoin",
3
+ "version": "1.3.2",
4
+ "description": "Ledger Filecoin Coin integration",
5
+ "keywords": [
6
+ "Ledger",
7
+ "LedgerWallet",
8
+ "fil",
9
+ "Filecoin",
10
+ "Hardware Wallet"
11
+ ],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/LedgerHQ/ledger-live.git"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/LedgerHQ/ledger-live/issues"
18
+ },
19
+ "homepage": "https://github.com/LedgerHQ/ledger-live/tree/develop/libs/coin-modules/coin-filecoin",
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "typesVersions": {
24
+ "*": {
25
+ "lib/*": [
26
+ "lib/*"
27
+ ],
28
+ "lib-es/*": [
29
+ "lib-es/*"
30
+ ],
31
+ "specs": [
32
+ "lib/test/bot-specs"
33
+ ],
34
+ "*": [
35
+ "lib/*",
36
+ "lib/api/*",
37
+ "lib/bridge/*",
38
+ "lib/common-logic/*",
39
+ "lib/signer/*",
40
+ "lib/test/*",
41
+ "lib/types/*"
42
+ ]
43
+ }
44
+ },
45
+ "exports": {
46
+ "./lib/*": "./lib/*.js",
47
+ "./lib-es/*": "./lib-es/*.js",
48
+ "./api": {
49
+ "require": "./lib/api/index.js",
50
+ "default": "./lib-es/api/index.js"
51
+ },
52
+ "./deviceTransactionConfig": {
53
+ "require": "./lib/bridge/deviceTransactionConfig.js",
54
+ "default": "./lib-es/bridge/deviceTransactionConfig.js"
55
+ },
56
+ "./erc20": {
57
+ "require": "./lib/erc20/tokenAccounts.js",
58
+ "default": "./lib-es/erc20/tokenAccounts.js"
59
+ },
60
+ "./logic": {
61
+ "require": "./lib/common-logic/index.js",
62
+ "default": "./lib-es/common-logic/index.js"
63
+ },
64
+ "./network": {
65
+ "require": "./lib/network/index.js",
66
+ "default": "./lib-es/network/index.js"
67
+ },
68
+ "./signer": {
69
+ "require": "./lib/signer/index.js",
70
+ "default": "./lib-es/signer/index.js"
71
+ },
72
+ "./specs": {
73
+ "require": "./lib/test/bot-specs.js",
74
+ "default": "./lib-es/test/bot-specs.js"
75
+ },
76
+ "./transaction": {
77
+ "require": "./lib/bridge/transaction.js",
78
+ "default": "./lib-es/bridge/transaction.js"
79
+ },
80
+ "./types": {
81
+ "require": "./lib/types/index.js",
82
+ "default": "./lib-es/types/index.js"
83
+ },
84
+ "./*": {
85
+ "require": "./lib/*.js",
86
+ "default": "./lib-es/*.js"
87
+ },
88
+ ".": {
89
+ "require": "./lib/index.js",
90
+ "default": "./lib-es/index.js"
91
+ },
92
+ "./package.json": "./package.json"
93
+ },
94
+ "license": "Apache-2.0",
95
+ "dependencies": {
96
+ "@zondax/cbor": "v8.1.0-zondax-no-bigint",
97
+ "bignumber.js": "^9.1.2",
98
+ "ethers": "5.7.2",
99
+ "invariant": "^2.2.2",
100
+ "iso-filecoin": "^4.1.0",
101
+ "lodash": "^4.17.21",
102
+ "rxjs": "^7.8.1",
103
+ "@ledgerhq/coin-framework": "^0.19.0-nightly.5",
104
+ "@ledgerhq/cryptoassets": "^13.7.0-nightly.4",
105
+ "@ledgerhq/devices": "8.4.4",
106
+ "@ledgerhq/errors": "^6.19.1",
107
+ "@ledgerhq/live-env": "^2.4.1-nightly.2",
108
+ "@ledgerhq/live-network": "^2.0.3-nightly.2",
109
+ "@ledgerhq/logs": "^6.12.0",
110
+ "@ledgerhq/types-cryptoassets": "^7.17.0-nightly.1",
111
+ "@ledgerhq/types-live": "^6.53.0-nightly.4"
112
+ },
113
+ "devDependencies": {
114
+ "@types/invariant": "^2.2.2",
115
+ "@types/jest": "^29.5.10",
116
+ "@types/lodash": "^4.14.191",
117
+ "@types/semver": "^7.5.8",
118
+ "jest": "^29.7.0",
119
+ "ts-jest": "^29.1.1",
120
+ "axios": "1.7.7"
121
+ },
122
+ "scripts": {
123
+ "clean": "rimraf lib lib-es",
124
+ "build": "tsc && tsc -m ES6 --outDir lib-es",
125
+ "coverage": "jest --coverage --testPathIgnorePatterns='/bridge.integration.test.ts|node_modules|lib-es|lib/' --passWithNoTests && mv coverage/coverage-final.json coverage/coverage-filecoin.json",
126
+ "prewatch": "pnpm build",
127
+ "watch": "tsc --watch",
128
+ "watch:es": "tsc --watch -m ES6 --outDir lib-es",
129
+ "doc": "documentation readme src/** --section=API --pe ts --re ts --re d.ts",
130
+ "lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache",
131
+ "lint:fix": "pnpm lint --fix",
132
+ "test": "jest",
133
+ "unimported": "unimported"
134
+ }
135
+ }
package/src/api/api.ts ADDED
@@ -0,0 +1,125 @@
1
+ import { log } from "@ledgerhq/logs";
2
+ import { AxiosRequestConfig, AxiosResponse } from "axios";
3
+
4
+ import network from "@ledgerhq/live-network/network";
5
+ import { makeLRUCache } from "@ledgerhq/live-network/cache";
6
+ import { getEnv } from "@ledgerhq/live-env";
7
+
8
+ import {
9
+ BalanceResponse,
10
+ BroadcastTransactionRequest,
11
+ BroadcastTransactionResponse,
12
+ EstimatedFeesRequest,
13
+ EstimatedFeesResponse,
14
+ NetworkStatusResponse,
15
+ TransactionResponse,
16
+ TransactionsResponse,
17
+ FetchERC20TransactionsResponse,
18
+ ERC20Transfer,
19
+ ERC20BalanceResponse,
20
+ } from "../types";
21
+ import { FilecoinFeeEstimationFailed } from "../errors";
22
+
23
+ const getFilecoinURL = (path?: string): string => {
24
+ const baseUrl = getEnv("API_FILECOIN_ENDPOINT");
25
+ if (!baseUrl) throw new Error("API base URL not available");
26
+
27
+ return `${baseUrl}${path ? path : ""}`;
28
+ };
29
+
30
+ const fetch = async <T>(path: string) => {
31
+ const url = getFilecoinURL(path);
32
+
33
+ // We force data to this way as network func is not using the correct param type. Changing that func will generate errors in other implementations
34
+ const opts: AxiosRequestConfig = {
35
+ method: "GET",
36
+ url,
37
+ };
38
+
39
+ const rawResponse = await network(opts);
40
+
41
+ // We force data to this way as network func is not using the correct param type. Changing that func will generate errors in other implementations
42
+ const { data } = rawResponse as AxiosResponse<T>;
43
+
44
+ log("http", url);
45
+ return data;
46
+ };
47
+
48
+ const send = async <T>(path: string, data: Record<string, any>) => {
49
+ const url = getFilecoinURL(path);
50
+
51
+ const opts: AxiosRequestConfig = {
52
+ method: "POST",
53
+ url,
54
+ data: JSON.stringify(data),
55
+ headers: { "Content-Type": "application/json" },
56
+ };
57
+
58
+ const rawResponse = await network(opts);
59
+
60
+ // We force data to this way as network func is not using generics. Changing that func will generate errors in other implementations
61
+ const { data: responseData } = rawResponse as AxiosResponse<T>;
62
+
63
+ log("http", url);
64
+ return responseData;
65
+ };
66
+
67
+ export const fetchBalances = async (addr: string): Promise<BalanceResponse> => {
68
+ const data = await fetch<BalanceResponse>(`/addresses/${addr}/balance`);
69
+ return data; // TODO Validate if the response fits this interface
70
+ };
71
+
72
+ export const fetchEstimatedFees = makeLRUCache(
73
+ async (request: EstimatedFeesRequest): Promise<EstimatedFeesResponse> => {
74
+ try {
75
+ const data = await send<EstimatedFeesResponse>(`/fees/estimate`, request);
76
+ return data; // TODO Validate if the response fits this interface
77
+ } catch (e: any) {
78
+ log("error", "filecoin fetchEstimatedFees", e);
79
+ throw new FilecoinFeeEstimationFailed();
80
+ }
81
+ },
82
+ request => `${request.from}-${request.to}`,
83
+ {
84
+ ttl: 5 * 1000, // 5 seconds
85
+ },
86
+ );
87
+
88
+ export const fetchBlockHeight = async (): Promise<NetworkStatusResponse> => {
89
+ const data = await fetch<NetworkStatusResponse>("/network/status");
90
+ return data as NetworkStatusResponse; // TODO Validate if the response fits this interface
91
+ };
92
+
93
+ export const fetchTxs = async (addr: string): Promise<TransactionResponse[]> => {
94
+ const response = await fetch<TransactionsResponse>(`/addresses/${addr}/transactions`);
95
+ return response.txs; // TODO Validate if the response fits this interface
96
+ };
97
+
98
+ export const broadcastTx = async (
99
+ message: BroadcastTransactionRequest,
100
+ ): Promise<BroadcastTransactionResponse> => {
101
+ const response = await send<BroadcastTransactionResponse>(`/transaction/broadcast`, message);
102
+ return response; // TODO Validate if the response fits this interface
103
+ };
104
+
105
+ export const fetchERC20TokenBalance = async (
106
+ ethAddr: string,
107
+ contractAddr: string,
108
+ ): Promise<string> => {
109
+ const res = await fetch<ERC20BalanceResponse>(
110
+ `/contract/${contractAddr}/address/${ethAddr}/balance/erc20`,
111
+ );
112
+
113
+ if (res.data.length) {
114
+ return res.data[0].balance;
115
+ }
116
+
117
+ return "0";
118
+ };
119
+
120
+ export const fetchERC20Transactions = async (ethAddr: string): Promise<ERC20Transfer[]> => {
121
+ const res = await fetch<FetchERC20TransactionsResponse>(
122
+ `/addresses/${ethAddr}/transactions/erc20`,
123
+ );
124
+ return res.txs.sort((a, b) => b.timestamp - a.timestamp);
125
+ };
@@ -0,0 +1 @@
1
+ export * from "./api";
@@ -0,0 +1,20 @@
1
+ import { AccountBridge } from "@ledgerhq/types-live";
2
+ import { patchOperationWithHash } from "@ledgerhq/coin-framework/operation";
3
+ import { getTxToBroadcast } from "../common-logic";
4
+ import { broadcastTx } from "../api";
5
+ import { Transaction } from "../types";
6
+
7
+ export const broadcast: AccountBridge<Transaction>["broadcast"] = async ({ signedOperation }) => {
8
+ // log("debug", "[broadcast] start fn");
9
+ const { operation, signature, rawData } = signedOperation;
10
+ const tx = getTxToBroadcast(operation, signature, rawData!);
11
+
12
+ const resp = await broadcastTx(tx);
13
+ const { hash } = resp;
14
+
15
+ const result = patchOperationWithHash(signedOperation.operation, hash);
16
+
17
+ // log("debug", "[broadcast] finish fn");
18
+
19
+ return result;
20
+ };