@ledgerhq/coin-evm 0.3.0 → 0.4.0-next.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 (582) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/jest.config.js +4 -0
  3. package/lib/__tests__/fixtures/common.fixtures.d.ts +9 -0
  4. package/lib/__tests__/fixtures/common.fixtures.d.ts.map +1 -0
  5. package/lib/{testUtils.js → __tests__/fixtures/common.fixtures.js} +40 -9
  6. package/lib/__tests__/fixtures/common.fixtures.js.map +1 -0
  7. package/lib/__tests__/fixtures/etherscan.fixtures.d.ts +86 -0
  8. package/lib/__tests__/fixtures/etherscan.fixtures.d.ts.map +1 -0
  9. package/lib/__tests__/fixtures/etherscan.fixtures.js +267 -0
  10. package/lib/__tests__/fixtures/etherscan.fixtures.js.map +1 -0
  11. package/lib/__tests__/fixtures/prepareTransaction.fixtures.d.ts +10 -0
  12. package/lib/__tests__/fixtures/prepareTransaction.fixtures.d.ts.map +1 -0
  13. package/lib/__tests__/fixtures/prepareTransaction.fixtures.js +69 -0
  14. package/lib/__tests__/fixtures/prepareTransaction.fixtures.js.map +1 -0
  15. package/lib/__tests__/fixtures/synchronization.fixtures.d.ts +44 -0
  16. package/lib/__tests__/fixtures/synchronization.fixtures.d.ts.map +1 -0
  17. package/lib/__tests__/fixtures/synchronization.fixtures.js +219 -0
  18. package/lib/__tests__/fixtures/synchronization.fixtures.js.map +1 -0
  19. package/lib/__tests__/fixtures/transaction.fixtures.d.ts +47 -0
  20. package/lib/__tests__/fixtures/transaction.fixtures.d.ts.map +1 -0
  21. package/lib/__tests__/fixtures/transaction.fixtures.js +182 -0
  22. package/lib/__tests__/fixtures/transaction.fixtures.js.map +1 -0
  23. package/lib/__tests__/integration/bridge.integration.test.d.ts +7 -0
  24. package/lib/__tests__/integration/bridge.integration.test.d.ts.map +1 -0
  25. package/lib/__tests__/integration/bridge.integration.test.js +74 -0
  26. package/lib/__tests__/integration/bridge.integration.test.js.map +1 -0
  27. package/lib/__tests__/unit/adapters.unit.test.d.ts.map +1 -0
  28. package/lib/__tests__/unit/adapters.unit.test.js +989 -0
  29. package/lib/__tests__/unit/adapters.unit.test.js.map +1 -0
  30. package/lib/__tests__/unit/api/explorer/etherscan.unit.test.d.ts +2 -0
  31. package/lib/__tests__/unit/api/explorer/etherscan.unit.test.d.ts.map +1 -0
  32. package/lib/__tests__/unit/api/explorer/etherscan.unit.test.js +430 -0
  33. package/lib/__tests__/unit/api/explorer/etherscan.unit.test.js.map +1 -0
  34. package/lib/__tests__/unit/api/explorer/index.unit.test.d.ts +2 -0
  35. package/lib/__tests__/unit/api/explorer/index.unit.test.d.ts.map +1 -0
  36. package/lib/__tests__/unit/api/explorer/index.unit.test.js +49 -0
  37. package/lib/__tests__/unit/api/explorer/index.unit.test.js.map +1 -0
  38. package/lib/__tests__/unit/api/gasTracker/index.unit.test.d.ts +2 -0
  39. package/lib/__tests__/unit/api/gasTracker/index.unit.test.d.ts.map +1 -0
  40. package/lib/__tests__/{gasTracker → unit/api/gasTracker}/index.unit.test.js +3 -3
  41. package/lib/__tests__/unit/api/gasTracker/index.unit.test.js.map +1 -0
  42. package/lib/__tests__/unit/api/gasTracker/ledger.unit.test.d.ts.map +1 -0
  43. package/lib/__tests__/{gasTracker → unit/api/gasTracker}/ledger.unit.test.js +2 -2
  44. package/lib/__tests__/unit/api/gasTracker/ledger.unit.test.js.map +1 -0
  45. package/lib/__tests__/unit/api/rpc/rpc.unit.test.d.ts.map +1 -0
  46. package/lib/__tests__/{rpc.unit.test.js → unit/api/rpc/rpc.unit.test.js} +14 -14
  47. package/lib/__tests__/unit/api/rpc/rpc.unit.test.js.map +1 -0
  48. package/lib/__tests__/unit/broadcast.unit.test.d.ts.map +1 -0
  49. package/lib/__tests__/unit/broadcast.unit.test.js +335 -0
  50. package/lib/__tests__/unit/broadcast.unit.test.js.map +1 -0
  51. package/lib/__tests__/unit/buildOptimisticOperation.unit.test.d.ts.map +1 -0
  52. package/lib/__tests__/{buildOptimisticOperation.unit.test.js → unit/buildOptimisticOperation.unit.test.js} +132 -6
  53. package/lib/__tests__/unit/buildOptimisticOperation.unit.test.js.map +1 -0
  54. package/lib/__tests__/unit/createTransaction.unit.test.d.ts.map +1 -0
  55. package/lib/__tests__/{createTransaction.unit.test.js → unit/createTransaction.unit.test.js} +5 -5
  56. package/lib/__tests__/unit/createTransaction.unit.test.js.map +1 -0
  57. package/lib/__tests__/unit/deviceTransactionConfig.unit.test.d.ts.map +1 -0
  58. package/lib/__tests__/{deviceTransactionConfig.unit.test.js → unit/deviceTransactionConfig.unit.test.js} +123 -6
  59. package/lib/__tests__/unit/deviceTransactionConfig.unit.test.js.map +1 -0
  60. package/lib/__tests__/unit/estimateMaxSpendable.unit.test.d.ts.map +1 -0
  61. package/lib/__tests__/{estimateMaxSpendable.unit.test.js → unit/estimateMaxSpendable.unit.test.js} +6 -6
  62. package/lib/__tests__/unit/estimateMaxSpendable.unit.test.js.map +1 -0
  63. package/lib/__tests__/unit/getTransactionStatus.unit.test.d.ts.map +1 -0
  64. package/lib/__tests__/{getTransactionStatus.unit.test.js → unit/getTransactionStatus.unit.test.js} +76 -6
  65. package/lib/__tests__/unit/getTransactionStatus.unit.test.js.map +1 -0
  66. package/lib/__tests__/unit/hw-getAddress.unit.test.d.ts.map +1 -0
  67. package/lib/__tests__/{hw-getAddress.unit.test.js → unit/hw-getAddress.unit.test.js} +5 -1
  68. package/lib/__tests__/unit/hw-getAddress.unit.test.js.map +1 -0
  69. package/lib/__tests__/unit/hw-signMessage.unit.test.d.ts +2 -0
  70. package/lib/__tests__/unit/hw-signMessage.unit.test.d.ts.map +1 -0
  71. package/lib/__tests__/unit/hw-signMessage.unit.test.js +188 -0
  72. package/lib/__tests__/unit/hw-signMessage.unit.test.js.map +1 -0
  73. package/lib/__tests__/unit/logic.unit.test.d.ts.map +1 -0
  74. package/lib/__tests__/{logic.unit.test.js → unit/logic.unit.test.js} +111 -20
  75. package/lib/__tests__/unit/logic.unit.test.js.map +1 -0
  76. package/lib/__tests__/unit/nftResolvers.unit.test.d.ts +2 -0
  77. package/lib/__tests__/unit/nftResolvers.unit.test.d.ts.map +1 -0
  78. package/lib/__tests__/unit/nftResolvers.unit.test.js +163 -0
  79. package/lib/__tests__/unit/nftResolvers.unit.test.js.map +1 -0
  80. package/lib/__tests__/unit/preload.unit.test.d.ts.map +1 -0
  81. package/lib/__tests__/{preload.unit.test.js → unit/preload.unit.test.js} +3 -3
  82. package/lib/__tests__/unit/preload.unit.test.js.map +1 -0
  83. package/lib/__tests__/unit/prepareTransaction.unit.test.d.ts.map +1 -0
  84. package/lib/__tests__/unit/prepareTransaction.unit.test.js +300 -0
  85. package/lib/__tests__/unit/prepareTransaction.unit.test.js.map +1 -0
  86. package/lib/__tests__/unit/signOperation.unit.test.d.ts.map +1 -0
  87. package/lib/__tests__/{signOperation.unit.test.js → unit/signOperation.unit.test.js} +14 -17
  88. package/lib/__tests__/unit/signOperation.unit.test.js.map +1 -0
  89. package/lib/__tests__/unit/synchronization.unit.test.d.ts.map +1 -0
  90. package/lib/__tests__/{synchronization.unit.test.js → unit/synchronization.unit.test.js} +139 -231
  91. package/lib/__tests__/unit/synchronization.unit.test.js.map +1 -0
  92. package/lib/__tests__/unit/transaction.unit.test.d.ts.map +1 -0
  93. package/lib/__tests__/{transaction.unit.test.js → unit/transaction.unit.test.js} +48 -80
  94. package/lib/__tests__/unit/transaction.unit.test.js.map +1 -0
  95. package/lib/abis/erc1155.abi.json +314 -0
  96. package/lib/abis/erc721.abi.json +346 -0
  97. package/lib/adapters.d.ts +18 -7
  98. package/lib/adapters.d.ts.map +1 -1
  99. package/lib/adapters.js +131 -46
  100. package/lib/adapters.js.map +1 -1
  101. package/lib/api/explorer/etherscan.d.ts +39 -11
  102. package/lib/api/explorer/etherscan.d.ts.map +1 -1
  103. package/lib/api/explorer/etherscan.js +151 -9
  104. package/lib/api/explorer/etherscan.js.map +1 -1
  105. package/lib/api/explorer/index.d.ts +7 -16
  106. package/lib/api/explorer/index.d.ts.map +1 -1
  107. package/lib/api/explorer/index.js.map +1 -1
  108. package/lib/api/nft/index.d.ts +24 -0
  109. package/lib/api/nft/index.d.ts.map +1 -0
  110. package/lib/api/nft/index.js +54 -0
  111. package/lib/api/nft/index.js.map +1 -0
  112. package/lib/api/rpc/index.native.d.ts.map +1 -1
  113. package/lib/api/rpc/index.native.js +1 -0
  114. package/lib/api/rpc/index.native.js.map +1 -1
  115. package/lib/api/rpc/rpc.common.d.ts +2 -2
  116. package/lib/api/rpc/rpc.common.d.ts.map +1 -1
  117. package/lib/api/rpc/rpc.common.js +3 -3
  118. package/lib/api/rpc/rpc.common.js.map +1 -1
  119. package/lib/bridge/js.d.ts +1 -1
  120. package/lib/bridge/js.d.ts.map +1 -1
  121. package/lib/bridge/js.js +10 -10
  122. package/lib/bridge/js.js.map +1 -1
  123. package/lib/broadcast.d.ts.map +1 -1
  124. package/lib/broadcast.js +9 -2
  125. package/lib/broadcast.js.map +1 -1
  126. package/lib/buildOptimisticOperation.d.ts +5 -1
  127. package/lib/buildOptimisticOperation.d.ts.map +1 -1
  128. package/lib/buildOptimisticOperation.js +46 -4
  129. package/lib/buildOptimisticOperation.js.map +1 -1
  130. package/lib/cli-transaction.d.ts.map +1 -1
  131. package/lib/cli-transaction.js +1 -0
  132. package/lib/cli-transaction.js.map +1 -1
  133. package/lib/datasets/ethereum1.d.ts.map +1 -1
  134. package/lib/datasets/ethereum1.js +3 -2
  135. package/lib/datasets/ethereum1.js.map +1 -1
  136. package/lib/deviceTransactionConfig.d.ts.map +1 -1
  137. package/lib/deviceTransactionConfig.js +50 -0
  138. package/lib/deviceTransactionConfig.js.map +1 -1
  139. package/lib/errors.d.ts +9 -0
  140. package/lib/errors.d.ts.map +1 -1
  141. package/lib/errors.js +7 -1
  142. package/lib/errors.js.map +1 -1
  143. package/lib/getTransactionStatus.d.ts +1 -0
  144. package/lib/getTransactionStatus.d.ts.map +1 -1
  145. package/lib/getTransactionStatus.js +25 -3
  146. package/lib/getTransactionStatus.js.map +1 -1
  147. package/lib/hw-signMessage.d.ts +15 -0
  148. package/lib/hw-signMessage.d.ts.map +1 -0
  149. package/lib/hw-signMessage.js +86 -0
  150. package/lib/hw-signMessage.js.map +1 -0
  151. package/lib/logic.d.ts +63 -1
  152. package/lib/logic.d.ts.map +1 -1
  153. package/lib/logic.js +98 -2
  154. package/lib/logic.js.map +1 -1
  155. package/lib/nftResolvers.d.ts +19 -0
  156. package/lib/nftResolvers.d.ts.map +1 -0
  157. package/lib/nftResolvers.js +58 -0
  158. package/lib/nftResolvers.js.map +1 -0
  159. package/lib/preload.d.ts.map +1 -1
  160. package/lib/preload.js +7 -3
  161. package/lib/preload.js.map +1 -1
  162. package/lib/prepareTransaction.d.ts +6 -1
  163. package/lib/prepareTransaction.d.ts.map +1 -1
  164. package/lib/prepareTransaction.js +69 -18
  165. package/lib/prepareTransaction.js.map +1 -1
  166. package/lib/signOperation.d.ts +1 -1
  167. package/lib/signOperation.d.ts.map +1 -1
  168. package/lib/signOperation.js +17 -6
  169. package/lib/signOperation.js.map +1 -1
  170. package/lib/signer.d.ts +24 -1
  171. package/lib/signer.d.ts.map +1 -1
  172. package/lib/specs.d.ts +3 -1
  173. package/lib/specs.d.ts.map +1 -1
  174. package/lib/specs.js +3 -3
  175. package/lib/specs.js.map +1 -1
  176. package/lib/speculos-deviceActions.d.ts.map +1 -1
  177. package/lib/speculos-deviceActions.js +2 -1
  178. package/lib/speculos-deviceActions.js.map +1 -1
  179. package/lib/synchronization.d.ts +7 -2
  180. package/lib/synchronization.d.ts.map +1 -1
  181. package/lib/synchronization.js +45 -45
  182. package/lib/synchronization.js.map +1 -1
  183. package/lib/transaction.d.ts +3 -4
  184. package/lib/transaction.d.ts.map +1 -1
  185. package/lib/transaction.js +58 -12
  186. package/lib/transaction.js.map +1 -1
  187. package/lib/types.d.ts +85 -10
  188. package/lib/types.d.ts.map +1 -1
  189. package/lib-es/__tests__/fixtures/common.fixtures.d.ts +9 -0
  190. package/lib-es/__tests__/fixtures/common.fixtures.d.ts.map +1 -0
  191. package/lib-es/{testUtils.js → __tests__/fixtures/common.fixtures.js} +36 -8
  192. package/lib-es/__tests__/fixtures/common.fixtures.js.map +1 -0
  193. package/lib-es/__tests__/fixtures/etherscan.fixtures.d.ts +86 -0
  194. package/lib-es/__tests__/fixtures/etherscan.fixtures.d.ts.map +1 -0
  195. package/lib-es/__tests__/fixtures/etherscan.fixtures.js +264 -0
  196. package/lib-es/__tests__/fixtures/etherscan.fixtures.js.map +1 -0
  197. package/lib-es/__tests__/fixtures/prepareTransaction.fixtures.d.ts +10 -0
  198. package/lib-es/__tests__/fixtures/prepareTransaction.fixtures.d.ts.map +1 -0
  199. package/lib-es/__tests__/fixtures/prepareTransaction.fixtures.js +62 -0
  200. package/lib-es/__tests__/fixtures/prepareTransaction.fixtures.js.map +1 -0
  201. package/lib-es/__tests__/fixtures/synchronization.fixtures.d.ts +44 -0
  202. package/lib-es/__tests__/fixtures/synchronization.fixtures.d.ts.map +1 -0
  203. package/lib-es/__tests__/fixtures/synchronization.fixtures.js +190 -0
  204. package/lib-es/__tests__/fixtures/synchronization.fixtures.js.map +1 -0
  205. package/lib-es/__tests__/fixtures/transaction.fixtures.d.ts +47 -0
  206. package/lib-es/__tests__/fixtures/transaction.fixtures.d.ts.map +1 -0
  207. package/lib-es/__tests__/fixtures/transaction.fixtures.js +176 -0
  208. package/lib-es/__tests__/fixtures/transaction.fixtures.js.map +1 -0
  209. package/lib-es/__tests__/integration/bridge.integration.test.d.ts +7 -0
  210. package/lib-es/__tests__/integration/bridge.integration.test.d.ts.map +1 -0
  211. package/lib-es/__tests__/integration/bridge.integration.test.js +71 -0
  212. package/lib-es/__tests__/integration/bridge.integration.test.js.map +1 -0
  213. package/lib-es/__tests__/unit/adapters.unit.test.d.ts.map +1 -0
  214. package/lib-es/__tests__/unit/adapters.unit.test.js +984 -0
  215. package/lib-es/__tests__/unit/adapters.unit.test.js.map +1 -0
  216. package/lib-es/__tests__/unit/api/explorer/etherscan.unit.test.d.ts +2 -0
  217. package/lib-es/__tests__/unit/api/explorer/etherscan.unit.test.d.ts.map +1 -0
  218. package/lib-es/__tests__/unit/api/explorer/etherscan.unit.test.js +402 -0
  219. package/lib-es/__tests__/unit/api/explorer/etherscan.unit.test.js.map +1 -0
  220. package/lib-es/__tests__/unit/api/explorer/index.unit.test.d.ts.map +1 -0
  221. package/lib-es/__tests__/unit/api/explorer/index.unit.test.js +44 -0
  222. package/lib-es/__tests__/unit/api/explorer/index.unit.test.js.map +1 -0
  223. package/lib-es/__tests__/unit/api/gasTracker/index.unit.test.d.ts.map +1 -0
  224. package/lib-es/__tests__/{gasTracker → unit/api/gasTracker}/index.unit.test.js +3 -3
  225. package/lib-es/__tests__/unit/api/gasTracker/index.unit.test.js.map +1 -0
  226. package/lib-es/__tests__/unit/api/gasTracker/ledger.unit.test.d.ts.map +1 -0
  227. package/lib-es/__tests__/{gasTracker → unit/api/gasTracker}/ledger.unit.test.js +2 -2
  228. package/lib-es/__tests__/unit/api/gasTracker/ledger.unit.test.js.map +1 -0
  229. package/lib-es/__tests__/unit/api/rpc/rpc.unit.test.d.ts.map +1 -0
  230. package/lib-es/__tests__/{rpc.unit.test.js → unit/api/rpc/rpc.unit.test.js} +13 -13
  231. package/lib-es/__tests__/unit/api/rpc/rpc.unit.test.js.map +1 -0
  232. package/lib-es/__tests__/unit/broadcast.unit.test.d.ts.map +1 -0
  233. package/lib-es/__tests__/unit/broadcast.unit.test.js +307 -0
  234. package/lib-es/__tests__/unit/broadcast.unit.test.js.map +1 -0
  235. package/lib-es/__tests__/unit/buildOptimisticOperation.unit.test.d.ts.map +1 -0
  236. package/lib-es/__tests__/{buildOptimisticOperation.unit.test.js → unit/buildOptimisticOperation.unit.test.js} +130 -4
  237. package/lib-es/__tests__/unit/buildOptimisticOperation.unit.test.js.map +1 -0
  238. package/lib-es/__tests__/unit/createTransaction.unit.test.d.ts.map +1 -0
  239. package/lib-es/__tests__/{createTransaction.unit.test.js → unit/createTransaction.unit.test.js} +3 -3
  240. package/lib-es/__tests__/unit/createTransaction.unit.test.js.map +1 -0
  241. package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.d.ts.map +1 -0
  242. package/lib-es/__tests__/{deviceTransactionConfig.unit.test.js → unit/deviceTransactionConfig.unit.test.js} +121 -4
  243. package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.js.map +1 -0
  244. package/lib-es/__tests__/unit/estimateMaxSpendable.unit.test.d.ts.map +1 -0
  245. package/lib-es/__tests__/{estimateMaxSpendable.unit.test.js → unit/estimateMaxSpendable.unit.test.js} +4 -4
  246. package/lib-es/__tests__/unit/estimateMaxSpendable.unit.test.js.map +1 -0
  247. package/lib-es/__tests__/unit/getTransactionStatus.unit.test.d.ts.map +1 -0
  248. package/lib-es/__tests__/{getTransactionStatus.unit.test.js → unit/getTransactionStatus.unit.test.js} +74 -4
  249. package/lib-es/__tests__/unit/getTransactionStatus.unit.test.js.map +1 -0
  250. package/lib-es/__tests__/unit/hw-getAddress.unit.test.d.ts.map +1 -0
  251. package/lib-es/__tests__/{hw-getAddress.unit.test.js → unit/hw-getAddress.unit.test.js} +5 -1
  252. package/lib-es/__tests__/unit/hw-getAddress.unit.test.js.map +1 -0
  253. package/lib-es/__tests__/unit/hw-signMessage.unit.test.d.ts +2 -0
  254. package/lib-es/__tests__/unit/hw-signMessage.unit.test.d.ts.map +1 -0
  255. package/lib-es/__tests__/unit/hw-signMessage.unit.test.js +186 -0
  256. package/lib-es/__tests__/unit/hw-signMessage.unit.test.js.map +1 -0
  257. package/lib-es/__tests__/unit/logic.unit.test.d.ts.map +1 -0
  258. package/lib-es/__tests__/{logic.unit.test.js → unit/logic.unit.test.js} +97 -6
  259. package/lib-es/__tests__/unit/logic.unit.test.js.map +1 -0
  260. package/lib-es/__tests__/unit/nftResolvers.unit.test.d.ts +2 -0
  261. package/lib-es/__tests__/unit/nftResolvers.unit.test.d.ts.map +1 -0
  262. package/lib-es/__tests__/unit/nftResolvers.unit.test.js +158 -0
  263. package/lib-es/__tests__/unit/nftResolvers.unit.test.js.map +1 -0
  264. package/lib-es/__tests__/unit/preload.unit.test.d.ts.map +1 -0
  265. package/lib-es/__tests__/{preload.unit.test.js → unit/preload.unit.test.js} +3 -3
  266. package/lib-es/__tests__/unit/preload.unit.test.js.map +1 -0
  267. package/lib-es/__tests__/unit/prepareTransaction.unit.test.d.ts.map +1 -0
  268. package/lib-es/__tests__/{prepareTransaction.unit.test.js → unit/prepareTransaction.unit.test.js} +134 -82
  269. package/lib-es/__tests__/unit/prepareTransaction.unit.test.js.map +1 -0
  270. package/lib-es/__tests__/unit/signOperation.unit.test.d.ts.map +1 -0
  271. package/lib-es/__tests__/{signOperation.unit.test.js → unit/signOperation.unit.test.js} +13 -16
  272. package/lib-es/__tests__/unit/signOperation.unit.test.js.map +1 -0
  273. package/lib-es/__tests__/unit/synchronization.unit.test.d.ts.map +1 -0
  274. package/lib-es/__tests__/{synchronization.unit.test.js → unit/synchronization.unit.test.js} +115 -207
  275. package/lib-es/__tests__/unit/synchronization.unit.test.js.map +1 -0
  276. package/lib-es/__tests__/unit/transaction.unit.test.d.ts.map +1 -0
  277. package/lib-es/__tests__/{transaction.unit.test.js → unit/transaction.unit.test.js} +40 -72
  278. package/lib-es/__tests__/unit/transaction.unit.test.js.map +1 -0
  279. package/lib-es/abis/erc1155.abi.json +314 -0
  280. package/lib-es/abis/erc721.abi.json +346 -0
  281. package/lib-es/adapters.d.ts +18 -7
  282. package/lib-es/adapters.d.ts.map +1 -1
  283. package/lib-es/adapters.js +127 -44
  284. package/lib-es/adapters.js.map +1 -1
  285. package/lib-es/api/explorer/etherscan.d.ts +39 -11
  286. package/lib-es/api/explorer/etherscan.d.ts.map +1 -1
  287. package/lib-es/api/explorer/etherscan.js +146 -10
  288. package/lib-es/api/explorer/etherscan.js.map +1 -1
  289. package/lib-es/api/explorer/index.d.ts +7 -16
  290. package/lib-es/api/explorer/index.d.ts.map +1 -1
  291. package/lib-es/api/explorer/index.js.map +1 -1
  292. package/lib-es/api/nft/index.d.ts +24 -0
  293. package/lib-es/api/nft/index.d.ts.map +1 -0
  294. package/lib-es/api/nft/index.js +46 -0
  295. package/lib-es/api/nft/index.js.map +1 -0
  296. package/lib-es/api/rpc/index.native.d.ts.map +1 -1
  297. package/lib-es/api/rpc/index.native.js +1 -0
  298. package/lib-es/api/rpc/index.native.js.map +1 -1
  299. package/lib-es/api/rpc/rpc.common.d.ts +2 -2
  300. package/lib-es/api/rpc/rpc.common.d.ts.map +1 -1
  301. package/lib-es/api/rpc/rpc.common.js +3 -3
  302. package/lib-es/api/rpc/rpc.common.js.map +1 -1
  303. package/lib-es/bridge/js.d.ts +1 -1
  304. package/lib-es/bridge/js.d.ts.map +1 -1
  305. package/lib-es/bridge/js.js +10 -10
  306. package/lib-es/bridge/js.js.map +1 -1
  307. package/lib-es/broadcast.d.ts.map +1 -1
  308. package/lib-es/broadcast.js +9 -2
  309. package/lib-es/broadcast.js.map +1 -1
  310. package/lib-es/buildOptimisticOperation.d.ts +5 -1
  311. package/lib-es/buildOptimisticOperation.d.ts.map +1 -1
  312. package/lib-es/buildOptimisticOperation.js +45 -4
  313. package/lib-es/buildOptimisticOperation.js.map +1 -1
  314. package/lib-es/cli-transaction.d.ts.map +1 -1
  315. package/lib-es/cli-transaction.js +1 -0
  316. package/lib-es/cli-transaction.js.map +1 -1
  317. package/lib-es/datasets/ethereum1.d.ts.map +1 -1
  318. package/lib-es/datasets/ethereum1.js +3 -2
  319. package/lib-es/datasets/ethereum1.js.map +1 -1
  320. package/lib-es/deviceTransactionConfig.d.ts.map +1 -1
  321. package/lib-es/deviceTransactionConfig.js +50 -0
  322. package/lib-es/deviceTransactionConfig.js.map +1 -1
  323. package/lib-es/errors.d.ts +9 -0
  324. package/lib-es/errors.d.ts.map +1 -1
  325. package/lib-es/errors.js +6 -0
  326. package/lib-es/errors.js.map +1 -1
  327. package/lib-es/getTransactionStatus.d.ts +1 -0
  328. package/lib-es/getTransactionStatus.d.ts.map +1 -1
  329. package/lib-es/getTransactionStatus.js +23 -2
  330. package/lib-es/getTransactionStatus.js.map +1 -1
  331. package/lib-es/hw-signMessage.d.ts +15 -0
  332. package/lib-es/hw-signMessage.d.ts.map +1 -0
  333. package/lib-es/hw-signMessage.js +81 -0
  334. package/lib-es/hw-signMessage.js.map +1 -0
  335. package/lib-es/logic.d.ts +63 -1
  336. package/lib-es/logic.d.ts.map +1 -1
  337. package/lib-es/logic.js +95 -1
  338. package/lib-es/logic.js.map +1 -1
  339. package/lib-es/nftResolvers.d.ts +19 -0
  340. package/lib-es/nftResolvers.d.ts.map +1 -0
  341. package/lib-es/nftResolvers.js +50 -0
  342. package/lib-es/nftResolvers.js.map +1 -0
  343. package/lib-es/preload.d.ts.map +1 -1
  344. package/lib-es/preload.js +7 -3
  345. package/lib-es/preload.js.map +1 -1
  346. package/lib-es/prepareTransaction.d.ts +6 -1
  347. package/lib-es/prepareTransaction.d.ts.map +1 -1
  348. package/lib-es/prepareTransaction.js +68 -18
  349. package/lib-es/prepareTransaction.js.map +1 -1
  350. package/lib-es/signOperation.d.ts +1 -1
  351. package/lib-es/signOperation.d.ts.map +1 -1
  352. package/lib-es/signOperation.js +17 -6
  353. package/lib-es/signOperation.js.map +1 -1
  354. package/lib-es/signer.d.ts +24 -1
  355. package/lib-es/signer.d.ts.map +1 -1
  356. package/lib-es/specs.d.ts +3 -1
  357. package/lib-es/specs.d.ts.map +1 -1
  358. package/lib-es/specs.js +3 -3
  359. package/lib-es/specs.js.map +1 -1
  360. package/lib-es/speculos-deviceActions.d.ts.map +1 -1
  361. package/lib-es/speculos-deviceActions.js +2 -1
  362. package/lib-es/speculos-deviceActions.js.map +1 -1
  363. package/lib-es/synchronization.d.ts +7 -2
  364. package/lib-es/synchronization.d.ts.map +1 -1
  365. package/lib-es/synchronization.js +46 -46
  366. package/lib-es/synchronization.js.map +1 -1
  367. package/lib-es/transaction.d.ts +3 -4
  368. package/lib-es/transaction.d.ts.map +1 -1
  369. package/lib-es/transaction.js +58 -12
  370. package/lib-es/transaction.js.map +1 -1
  371. package/lib-es/types.d.ts +85 -10
  372. package/lib-es/types.d.ts.map +1 -1
  373. package/package.json +13 -12
  374. package/src/{testUtils.ts → __tests__/fixtures/common.fixtures.ts} +78 -11
  375. package/src/__tests__/fixtures/etherscan.fixtures.ts +266 -0
  376. package/src/__tests__/fixtures/prepareTransaction.fixtures.ts +86 -0
  377. package/src/__tests__/fixtures/synchronization.fixtures.ts +229 -0
  378. package/src/__tests__/fixtures/transaction.fixtures.ts +229 -0
  379. package/src/__tests__/integration/bridge.integration.test.ts +74 -0
  380. package/src/__tests__/unit/adapters.unit.test.ts +1076 -0
  381. package/src/__tests__/unit/api/explorer/etherscan.unit.test.ts +563 -0
  382. package/src/__tests__/unit/api/explorer/index.unit.test.ts +36 -0
  383. package/src/__tests__/{gasTracker → unit/api/gasTracker}/index.unit.test.ts +3 -3
  384. package/src/__tests__/{gasTracker → unit/api/gasTracker}/ledger.unit.test.ts +3 -3
  385. package/src/__tests__/{rpc.unit.test.ts → unit/api/rpc/rpc.unit.test.ts} +17 -14
  386. package/src/__tests__/unit/broadcast.unit.test.ts +332 -0
  387. package/src/__tests__/{buildOptimisticOperation.unit.test.ts → unit/buildOptimisticOperation.unit.test.ts} +144 -5
  388. package/src/__tests__/{createTransaction.unit.test.ts → unit/createTransaction.unit.test.ts} +4 -4
  389. package/src/__tests__/{deviceTransactionConfig.unit.test.ts → unit/deviceTransactionConfig.unit.test.ts} +130 -5
  390. package/src/__tests__/{estimateMaxSpendable.unit.test.ts → unit/estimateMaxSpendable.unit.test.ts} +5 -5
  391. package/src/__tests__/{getTransactionStatus.unit.test.ts → unit/getTransactionStatus.unit.test.ts} +121 -5
  392. package/src/__tests__/{hw-getAddress.unit.test.ts → unit/hw-getAddress.unit.test.ts} +6 -2
  393. package/src/__tests__/unit/hw-signMessage.unit.test.ts +192 -0
  394. package/src/__tests__/{logic.unit.test.ts → unit/logic.unit.test.ts} +143 -8
  395. package/src/__tests__/unit/nftResolvers.unit.test.ts +179 -0
  396. package/src/__tests__/{preload.unit.test.ts → unit/preload.unit.test.ts} +4 -4
  397. package/src/__tests__/{prepareTransaction.unit.test.ts → unit/prepareTransaction.unit.test.ts} +284 -109
  398. package/src/__tests__/{signOperation.unit.test.ts → unit/signOperation.unit.test.ts} +18 -20
  399. package/src/__tests__/{synchronization.unit.test.ts → unit/synchronization.unit.test.ts} +202 -280
  400. package/src/__tests__/unit/transaction.unit.test.ts +198 -0
  401. package/src/abis/erc1155.abi.json +314 -0
  402. package/src/abis/erc20.abi.json +4 -12
  403. package/src/abis/erc721.abi.json +346 -0
  404. package/src/adapters.ts +177 -64
  405. package/src/api/explorer/etherscan.ts +265 -49
  406. package/src/api/explorer/index.ts +24 -10
  407. package/src/api/nft/index.ts +49 -0
  408. package/src/api/rpc/index.native.ts +2 -0
  409. package/src/api/rpc/rpc.common.ts +3 -3
  410. package/src/bridge/js.ts +13 -16
  411. package/src/broadcast.ts +29 -2
  412. package/src/buildOptimisticOperation.ts +71 -6
  413. package/src/cli-transaction.ts +2 -0
  414. package/src/datasets/ethereum1.ts +4 -2
  415. package/src/deviceTransactionConfig.ts +65 -0
  416. package/src/errors.ts +8 -0
  417. package/src/getTransactionStatus.ts +26 -0
  418. package/src/hw-signMessage.ts +92 -0
  419. package/src/logic.ts +118 -2
  420. package/src/nftResolvers.ts +71 -0
  421. package/src/preload.ts +9 -3
  422. package/src/prepareTransaction.ts +102 -24
  423. package/src/signOperation.ts +21 -8
  424. package/src/signer.ts +44 -1
  425. package/src/specs.ts +11 -6
  426. package/src/speculos-deviceActions.ts +3 -1
  427. package/src/synchronization.ts +73 -59
  428. package/src/transaction.ts +68 -15
  429. package/src/types.ts +108 -10
  430. package/.eslintrc.js +0 -22
  431. package/lib/__tests__/adapters.unit.test.d.ts.map +0 -1
  432. package/lib/__tests__/adapters.unit.test.js +0 -455
  433. package/lib/__tests__/adapters.unit.test.js.map +0 -1
  434. package/lib/__tests__/broadcast.unit.test.d.ts.map +0 -1
  435. package/lib/__tests__/broadcast.unit.test.js +0 -181
  436. package/lib/__tests__/broadcast.unit.test.js.map +0 -1
  437. package/lib/__tests__/buildOptimisticOperation.unit.test.d.ts.map +0 -1
  438. package/lib/__tests__/buildOptimisticOperation.unit.test.js.map +0 -1
  439. package/lib/__tests__/createTransaction.unit.test.d.ts.map +0 -1
  440. package/lib/__tests__/createTransaction.unit.test.js.map +0 -1
  441. package/lib/__tests__/deviceTransactionConfig.unit.test.d.ts.map +0 -1
  442. package/lib/__tests__/deviceTransactionConfig.unit.test.js.map +0 -1
  443. package/lib/__tests__/estimateMaxSpendable.unit.test.d.ts.map +0 -1
  444. package/lib/__tests__/estimateMaxSpendable.unit.test.js.map +0 -1
  445. package/lib/__tests__/gasTracker/index.unit.test.d.ts.map +0 -1
  446. package/lib/__tests__/gasTracker/index.unit.test.js.map +0 -1
  447. package/lib/__tests__/gasTracker/ledger.unit.test.d.ts.map +0 -1
  448. package/lib/__tests__/gasTracker/ledger.unit.test.js.map +0 -1
  449. package/lib/__tests__/getTransactionStatus.unit.test.d.ts.map +0 -1
  450. package/lib/__tests__/getTransactionStatus.unit.test.js.map +0 -1
  451. package/lib/__tests__/hw-getAddress.unit.test.d.ts.map +0 -1
  452. package/lib/__tests__/hw-getAddress.unit.test.js.map +0 -1
  453. package/lib/__tests__/logic.unit.test.d.ts.map +0 -1
  454. package/lib/__tests__/logic.unit.test.js.map +0 -1
  455. package/lib/__tests__/preload.unit.test.d.ts.map +0 -1
  456. package/lib/__tests__/preload.unit.test.js.map +0 -1
  457. package/lib/__tests__/prepareTransaction.unit.test.d.ts.map +0 -1
  458. package/lib/__tests__/prepareTransaction.unit.test.js +0 -248
  459. package/lib/__tests__/prepareTransaction.unit.test.js.map +0 -1
  460. package/lib/__tests__/rpc.unit.test.d.ts.map +0 -1
  461. package/lib/__tests__/rpc.unit.test.js.map +0 -1
  462. package/lib/__tests__/signOperation.unit.test.d.ts.map +0 -1
  463. package/lib/__tests__/signOperation.unit.test.js.map +0 -1
  464. package/lib/__tests__/synchronization.unit.test.d.ts.map +0 -1
  465. package/lib/__tests__/synchronization.unit.test.js.map +0 -1
  466. package/lib/__tests__/transaction.unit.test.d.ts.map +0 -1
  467. package/lib/__tests__/transaction.unit.test.js.map +0 -1
  468. package/lib/bridge.integration.test.d.ts +0 -14
  469. package/lib/bridge.integration.test.d.ts.map +0 -1
  470. package/lib/bridge.integration.test.js +0 -85
  471. package/lib/bridge.integration.test.js.map +0 -1
  472. package/lib/datasets/ethereum.scanAccounts.1.d.ts +0 -7
  473. package/lib/datasets/ethereum.scanAccounts.1.d.ts.map +0 -1
  474. package/lib/datasets/ethereum.scanAccounts.1.js +0 -51
  475. package/lib/datasets/ethereum.scanAccounts.1.js.map +0 -1
  476. package/lib/datasets/ethereum2.d.ts +0 -3
  477. package/lib/datasets/ethereum2.d.ts.map +0 -1
  478. package/lib/datasets/ethereum2.js +0 -22
  479. package/lib/datasets/ethereum2.js.map +0 -1
  480. package/lib/datasets/ethereum_classic.d.ts +0 -5
  481. package/lib/datasets/ethereum_classic.d.ts.map +0 -1
  482. package/lib/datasets/ethereum_classic.js +0 -69
  483. package/lib/datasets/ethereum_classic.js.map +0 -1
  484. package/lib/testUtils.d.ts +0 -6
  485. package/lib/testUtils.d.ts.map +0 -1
  486. package/lib/testUtils.js.map +0 -1
  487. package/lib-es/__tests__/adapters.unit.test.d.ts.map +0 -1
  488. package/lib-es/__tests__/adapters.unit.test.js +0 -450
  489. package/lib-es/__tests__/adapters.unit.test.js.map +0 -1
  490. package/lib-es/__tests__/broadcast.unit.test.d.ts.map +0 -1
  491. package/lib-es/__tests__/broadcast.unit.test.js +0 -153
  492. package/lib-es/__tests__/broadcast.unit.test.js.map +0 -1
  493. package/lib-es/__tests__/buildOptimisticOperation.unit.test.d.ts.map +0 -1
  494. package/lib-es/__tests__/buildOptimisticOperation.unit.test.js.map +0 -1
  495. package/lib-es/__tests__/createTransaction.unit.test.d.ts.map +0 -1
  496. package/lib-es/__tests__/createTransaction.unit.test.js.map +0 -1
  497. package/lib-es/__tests__/deviceTransactionConfig.unit.test.d.ts.map +0 -1
  498. package/lib-es/__tests__/deviceTransactionConfig.unit.test.js.map +0 -1
  499. package/lib-es/__tests__/estimateMaxSpendable.unit.test.d.ts.map +0 -1
  500. package/lib-es/__tests__/estimateMaxSpendable.unit.test.js.map +0 -1
  501. package/lib-es/__tests__/gasTracker/index.unit.test.d.ts.map +0 -1
  502. package/lib-es/__tests__/gasTracker/index.unit.test.js.map +0 -1
  503. package/lib-es/__tests__/gasTracker/ledger.unit.test.d.ts.map +0 -1
  504. package/lib-es/__tests__/gasTracker/ledger.unit.test.js.map +0 -1
  505. package/lib-es/__tests__/getTransactionStatus.unit.test.d.ts.map +0 -1
  506. package/lib-es/__tests__/getTransactionStatus.unit.test.js.map +0 -1
  507. package/lib-es/__tests__/hw-getAddress.unit.test.d.ts.map +0 -1
  508. package/lib-es/__tests__/hw-getAddress.unit.test.js.map +0 -1
  509. package/lib-es/__tests__/logic.unit.test.d.ts.map +0 -1
  510. package/lib-es/__tests__/logic.unit.test.js.map +0 -1
  511. package/lib-es/__tests__/preload.unit.test.d.ts.map +0 -1
  512. package/lib-es/__tests__/preload.unit.test.js.map +0 -1
  513. package/lib-es/__tests__/prepareTransaction.unit.test.d.ts.map +0 -1
  514. package/lib-es/__tests__/prepareTransaction.unit.test.js.map +0 -1
  515. package/lib-es/__tests__/rpc.unit.test.d.ts.map +0 -1
  516. package/lib-es/__tests__/rpc.unit.test.js.map +0 -1
  517. package/lib-es/__tests__/signOperation.unit.test.d.ts.map +0 -1
  518. package/lib-es/__tests__/signOperation.unit.test.js.map +0 -1
  519. package/lib-es/__tests__/synchronization.unit.test.d.ts.map +0 -1
  520. package/lib-es/__tests__/synchronization.unit.test.js.map +0 -1
  521. package/lib-es/__tests__/transaction.unit.test.d.ts.map +0 -1
  522. package/lib-es/__tests__/transaction.unit.test.js.map +0 -1
  523. package/lib-es/bridge.integration.test.d.ts +0 -14
  524. package/lib-es/bridge.integration.test.d.ts.map +0 -1
  525. package/lib-es/bridge.integration.test.js +0 -79
  526. package/lib-es/bridge.integration.test.js.map +0 -1
  527. package/lib-es/datasets/ethereum.scanAccounts.1.d.ts +0 -7
  528. package/lib-es/datasets/ethereum.scanAccounts.1.d.ts.map +0 -1
  529. package/lib-es/datasets/ethereum.scanAccounts.1.js +0 -49
  530. package/lib-es/datasets/ethereum.scanAccounts.1.js.map +0 -1
  531. package/lib-es/datasets/ethereum2.d.ts +0 -3
  532. package/lib-es/datasets/ethereum2.d.ts.map +0 -1
  533. package/lib-es/datasets/ethereum2.js +0 -19
  534. package/lib-es/datasets/ethereum2.js.map +0 -1
  535. package/lib-es/datasets/ethereum_classic.d.ts +0 -5
  536. package/lib-es/datasets/ethereum_classic.d.ts.map +0 -1
  537. package/lib-es/datasets/ethereum_classic.js +0 -67
  538. package/lib-es/datasets/ethereum_classic.js.map +0 -1
  539. package/lib-es/testUtils.d.ts +0 -6
  540. package/lib-es/testUtils.d.ts.map +0 -1
  541. package/lib-es/testUtils.js.map +0 -1
  542. package/src/__tests__/adapters.unit.test.ts +0 -497
  543. package/src/__tests__/broadcast.unit.test.ts +0 -163
  544. package/src/__tests__/transaction.unit.test.ts +0 -188
  545. package/src/bridge.integration.test.ts +0 -86
  546. package/src/datasets/ethereum.scanAccounts.1.ts +0 -48
  547. package/src/datasets/ethereum2.ts +0 -20
  548. package/src/datasets/ethereum_classic.ts +0 -68
  549. /package/lib/__tests__/{adapters.unit.test.d.ts → unit/adapters.unit.test.d.ts} +0 -0
  550. /package/lib/__tests__/{gasTracker → unit/api/gasTracker}/ledger.unit.test.d.ts +0 -0
  551. /package/lib/__tests__/{rpc.unit.test.d.ts → unit/api/rpc/rpc.unit.test.d.ts} +0 -0
  552. /package/lib/__tests__/{broadcast.unit.test.d.ts → unit/broadcast.unit.test.d.ts} +0 -0
  553. /package/lib/__tests__/{buildOptimisticOperation.unit.test.d.ts → unit/buildOptimisticOperation.unit.test.d.ts} +0 -0
  554. /package/lib/__tests__/{createTransaction.unit.test.d.ts → unit/createTransaction.unit.test.d.ts} +0 -0
  555. /package/lib/__tests__/{deviceTransactionConfig.unit.test.d.ts → unit/deviceTransactionConfig.unit.test.d.ts} +0 -0
  556. /package/lib/__tests__/{estimateMaxSpendable.unit.test.d.ts → unit/estimateMaxSpendable.unit.test.d.ts} +0 -0
  557. /package/lib/__tests__/{getTransactionStatus.unit.test.d.ts → unit/getTransactionStatus.unit.test.d.ts} +0 -0
  558. /package/lib/__tests__/{hw-getAddress.unit.test.d.ts → unit/hw-getAddress.unit.test.d.ts} +0 -0
  559. /package/lib/__tests__/{logic.unit.test.d.ts → unit/logic.unit.test.d.ts} +0 -0
  560. /package/lib/__tests__/{preload.unit.test.d.ts → unit/preload.unit.test.d.ts} +0 -0
  561. /package/lib/__tests__/{prepareTransaction.unit.test.d.ts → unit/prepareTransaction.unit.test.d.ts} +0 -0
  562. /package/lib/__tests__/{signOperation.unit.test.d.ts → unit/signOperation.unit.test.d.ts} +0 -0
  563. /package/lib/__tests__/{synchronization.unit.test.d.ts → unit/synchronization.unit.test.d.ts} +0 -0
  564. /package/lib/__tests__/{transaction.unit.test.d.ts → unit/transaction.unit.test.d.ts} +0 -0
  565. /package/lib-es/__tests__/{adapters.unit.test.d.ts → unit/adapters.unit.test.d.ts} +0 -0
  566. /package/lib-es/__tests__/{gasTracker → unit/api/explorer}/index.unit.test.d.ts +0 -0
  567. /package/{lib/__tests__ → lib-es/__tests__/unit/api}/gasTracker/index.unit.test.d.ts +0 -0
  568. /package/lib-es/__tests__/{gasTracker → unit/api/gasTracker}/ledger.unit.test.d.ts +0 -0
  569. /package/lib-es/__tests__/{rpc.unit.test.d.ts → unit/api/rpc/rpc.unit.test.d.ts} +0 -0
  570. /package/lib-es/__tests__/{broadcast.unit.test.d.ts → unit/broadcast.unit.test.d.ts} +0 -0
  571. /package/lib-es/__tests__/{buildOptimisticOperation.unit.test.d.ts → unit/buildOptimisticOperation.unit.test.d.ts} +0 -0
  572. /package/lib-es/__tests__/{createTransaction.unit.test.d.ts → unit/createTransaction.unit.test.d.ts} +0 -0
  573. /package/lib-es/__tests__/{deviceTransactionConfig.unit.test.d.ts → unit/deviceTransactionConfig.unit.test.d.ts} +0 -0
  574. /package/lib-es/__tests__/{estimateMaxSpendable.unit.test.d.ts → unit/estimateMaxSpendable.unit.test.d.ts} +0 -0
  575. /package/lib-es/__tests__/{getTransactionStatus.unit.test.d.ts → unit/getTransactionStatus.unit.test.d.ts} +0 -0
  576. /package/lib-es/__tests__/{hw-getAddress.unit.test.d.ts → unit/hw-getAddress.unit.test.d.ts} +0 -0
  577. /package/lib-es/__tests__/{logic.unit.test.d.ts → unit/logic.unit.test.d.ts} +0 -0
  578. /package/lib-es/__tests__/{preload.unit.test.d.ts → unit/preload.unit.test.d.ts} +0 -0
  579. /package/lib-es/__tests__/{prepareTransaction.unit.test.d.ts → unit/prepareTransaction.unit.test.d.ts} +0 -0
  580. /package/lib-es/__tests__/{signOperation.unit.test.d.ts → unit/signOperation.unit.test.d.ts} +0 -0
  581. /package/lib-es/__tests__/{synchronization.unit.test.d.ts → unit/synchronization.unit.test.d.ts} +0 -0
  582. /package/lib-es/__tests__/{transaction.unit.test.d.ts → unit/transaction.unit.test.d.ts} +0 -0
@@ -1,16 +1,27 @@
1
1
  import { delay } from "@ledgerhq/live-promise";
2
2
  import { Operation } from "@ledgerhq/types-live";
3
3
  import axios, { AxiosRequestConfig } from "axios";
4
- import { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
5
4
  import { makeLRUCache } from "@ledgerhq/live-network/cache";
6
- import { EtherscanERC20Event, EtherscanOperation } from "../../types";
5
+ import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
6
+ import { isNFTActive } from "@ledgerhq/coin-framework/nft/support";
7
7
  import { EtherscanAPIError } from "../../errors";
8
- import { etherscanERC20EventToOperation, etherscanOperationToOperation } from "../../adapters";
8
+ import {
9
+ etherscanOperationToOperations,
10
+ etherscanERC20EventToOperations,
11
+ etherscanERC721EventToOperations,
12
+ etherscanERC1155EventToOperations,
13
+ } from "../../adapters";
14
+ import {
15
+ EtherscanERC1155Event,
16
+ EtherscanERC20Event,
17
+ EtherscanERC721Event,
18
+ EtherscanOperation,
19
+ } from "../../types";
9
20
 
10
21
  export const ETHERSCAN_TIMEOUT = 5000; // 5 seconds between 2 calls
11
22
  export const DEFAULT_RETRIES_API = 8;
12
23
 
13
- async function fetchWithRetries<T>(
24
+ export async function fetchWithRetries<T>(
14
25
  params: AxiosRequestConfig,
15
26
  retries = DEFAULT_RETRIES_API,
16
27
  ): Promise<T> {
@@ -43,67 +54,272 @@ async function fetchWithRetries<T>(
43
54
  /**
44
55
  * Get all the last "normal" transactions (no tokens / NFTs)
45
56
  */
46
- export const getLastCoinOperations = makeLRUCache<
47
- [currency: CryptoCurrency, address: string, accountId: string, fromBlock: number],
48
- Operation[]
49
- >(
50
- async (currency, address, accountId, fromBlock) => {
51
- const apiDomain = currency.ethereumLikeInfo?.explorer?.uri;
52
- if (!apiDomain) {
53
- return [];
54
- }
57
+ export const getLastCoinOperations = async (
58
+ currency: CryptoCurrency,
59
+ address: string,
60
+ accountId: string,
61
+ fromBlock: number,
62
+ toBlock?: number,
63
+ ): Promise<Operation[]> => {
64
+ const apiDomain = currency.ethereumLikeInfo?.explorer?.uri;
65
+ if (!apiDomain) {
66
+ return [];
67
+ }
55
68
 
56
- let url = `${apiDomain}/api?module=account&action=txlist&address=${address}&tag=latest&page=1&sort=desc`;
57
- if (fromBlock) {
58
- url += `&startBlock=${fromBlock}`;
59
- }
69
+ let url = `${apiDomain}/api?module=account&action=txlist&address=${address}&tag=latest&page=1&sort=desc`;
70
+ if (fromBlock) {
71
+ url += `&startBlock=${fromBlock}`;
72
+ }
73
+ if (toBlock) {
74
+ url += `&endBlock=${toBlock}`;
75
+ }
60
76
 
61
- const ops = await fetchWithRetries<EtherscanOperation[]>({
62
- method: "GET",
63
- url,
64
- });
77
+ const ops = await fetchWithRetries<EtherscanOperation[]>({
78
+ method: "GET",
79
+ url,
80
+ });
65
81
 
66
- return ops
67
- .map(tx => etherscanOperationToOperation(accountId, tx))
68
- .filter(Boolean) as Operation[];
69
- },
70
- (currency, address, accountId, fromBlock) => accountId + fromBlock,
71
- { ttl: 5 * 1000 },
72
- );
82
+ return ops.map(tx => etherscanOperationToOperations(accountId, tx)).flat();
83
+ };
73
84
 
74
85
  /**
75
86
  * Get all the last ERC20 transactions
76
87
  */
77
- export const getLastTokenOperations = makeLRUCache<
78
- [currency: CryptoCurrency, address: string, accountId: string, fromBlock: number],
79
- { tokenCurrency: TokenCurrency; operation: Operation }[]
80
- >(
81
- async (currency, address, accountId, fromBlock) => {
82
- const apiDomain = currency.ethereumLikeInfo?.explorer?.uri;
83
- if (!apiDomain) {
84
- return [];
88
+ export const getLastTokenOperations = async (
89
+ currency: CryptoCurrency,
90
+ address: string,
91
+ accountId: string,
92
+ fromBlock: number,
93
+ toBlock?: number,
94
+ ): Promise<Operation[]> => {
95
+ const apiDomain = currency.ethereumLikeInfo?.explorer?.uri;
96
+ if (!apiDomain) {
97
+ return [];
98
+ }
99
+
100
+ let url = `${apiDomain}/api?module=account&action=tokentx&address=${address}&tag=latest&page=1&sort=desc`;
101
+ if (fromBlock) {
102
+ url += `&startBlock=${fromBlock}`;
103
+ }
104
+ if (toBlock) {
105
+ url += `&endBlock=${toBlock}`;
106
+ }
107
+
108
+ const ops = await fetchWithRetries<EtherscanERC20Event[]>({
109
+ method: "GET",
110
+ url,
111
+ });
112
+
113
+ // Why this thing ?
114
+ // Multiple events can be fired by the same transactions and
115
+ // those transfer events can go from anyone to anyone, which
116
+ // means that multiple events could be sent to or from the
117
+ // same address during the same transaction.
118
+ //
119
+ // To make sure every event (transformed into an operation here)
120
+ // has a unique id, we're groupping them by transaction hash
121
+ // and using the index for each event fired.
122
+ const opsByHash: Record<string, EtherscanERC20Event[]> = {};
123
+ for (const op of ops) {
124
+ if (!opsByHash[op.hash]) {
125
+ opsByHash[op.hash] = [];
126
+ }
127
+ opsByHash[op.hash].push(op);
128
+ }
129
+
130
+ return Object.values(opsByHash)
131
+ .map(events =>
132
+ events.map((event, index) => etherscanERC20EventToOperations(accountId, event, index)),
133
+ )
134
+ .flat(2);
135
+ };
136
+
137
+ /**
138
+ * Get all the last ERC721 transactions
139
+ */
140
+ export const getLastERC721Operations = async (
141
+ currency: CryptoCurrency,
142
+ address: string,
143
+ accountId: string,
144
+ fromBlock: number,
145
+ toBlock?: number,
146
+ ): Promise<Operation[]> => {
147
+ const apiDomain = currency.ethereumLikeInfo?.explorer?.uri;
148
+ if (!apiDomain) {
149
+ return [];
150
+ }
151
+
152
+ let url = `${apiDomain}/api?module=account&action=tokennfttx&address=${address}&tag=latest&page=1&sort=desc`;
153
+ if (fromBlock) {
154
+ url += `&startBlock=${fromBlock}`;
155
+ }
156
+ if (toBlock) {
157
+ url += `&endBlock=${toBlock}`;
158
+ }
159
+
160
+ const ops = await fetchWithRetries<EtherscanERC721Event[]>({
161
+ method: "GET",
162
+ url,
163
+ });
164
+
165
+ // Why this thing ?
166
+ // Multiple events can be fired by the same transactions and
167
+ // those transfer events can go from anyone to anyone, which
168
+ // means that multiple events could be sent to or from the
169
+ // same address during the same transaction.
170
+ //
171
+ // To make sure every event (transformed into an operation here)
172
+ // has a unique id, we're groupping them by transaction hash
173
+ // and using the index for each event fired.
174
+ const opsByHash: Record<string, EtherscanERC721Event[]> = {};
175
+ for (const op of ops) {
176
+ if (!opsByHash[op.hash]) {
177
+ opsByHash[op.hash] = [];
85
178
  }
179
+ opsByHash[op.hash].push(op);
180
+ }
181
+
182
+ return Object.values(opsByHash)
183
+ .map(events =>
184
+ events.map((event, index) => etherscanERC721EventToOperations(accountId, event, index)),
185
+ )
186
+ .flat(2);
187
+ };
188
+
189
+ /**
190
+ * Get all the last ERC71155 transactions
191
+ */
192
+ export const getLastERC1155Operations = async (
193
+ currency: CryptoCurrency,
194
+ address: string,
195
+ accountId: string,
196
+ fromBlock: number,
197
+ toBlock?: number,
198
+ ): Promise<Operation[]> => {
199
+ const apiDomain = currency.ethereumLikeInfo?.explorer?.uri;
200
+ if (!apiDomain) {
201
+ return [];
202
+ }
86
203
 
87
- let url = `${apiDomain}/api?module=account&action=tokentx&address=${address}&tag=latest&page=1&sort=desc`;
88
- if (fromBlock) {
89
- url += `&startBlock=${fromBlock}`;
204
+ let url = `${apiDomain}/api?module=account&action=token1155tx&address=${address}&tag=latest&page=1&sort=desc`;
205
+ if (fromBlock) {
206
+ url += `&startBlock=${fromBlock}`;
207
+ }
208
+ if (toBlock) {
209
+ url += `&endBlock=${toBlock}`;
210
+ }
211
+
212
+ const ops = await fetchWithRetries<EtherscanERC1155Event[]>({
213
+ method: "GET",
214
+ url,
215
+ });
216
+
217
+ // Why this thing ?
218
+ // Multiple events can be fired by the same transactions and
219
+ // those transfer events can go from anyone to anyone, which
220
+ // means that multiple events could be sent to or from the
221
+ // same address during the same transaction.
222
+ //
223
+ // To make sure every event (transformed into an operation here)
224
+ // has a unique id, we're groupping them by transaction hash
225
+ // and using the index for each event fired.
226
+ const opsByHash: Record<string, EtherscanERC1155Event[]> = {};
227
+ for (const op of ops) {
228
+ if (!opsByHash[op.hash]) {
229
+ opsByHash[op.hash] = [];
90
230
  }
231
+ opsByHash[op.hash].push(op);
232
+ }
233
+
234
+ return Object.values(opsByHash)
235
+ .map(events =>
236
+ events.map((event, index) => etherscanERC1155EventToOperations(accountId, event, index)),
237
+ )
238
+ .flat(2);
239
+ };
240
+
241
+ /**
242
+ * Get all NFT related operations (ERC721 + ERC1155)
243
+ */
244
+ export const getLastNftOperations = async (
245
+ currency: CryptoCurrency,
246
+ address: string,
247
+ accountId: string,
248
+ fromBlock: number,
249
+ toBlock?: number,
250
+ ): Promise<Operation[]> => {
251
+ const erc721Ops = await getLastERC721Operations(currency, address, accountId, fromBlock, toBlock);
252
+ const erc1155Ops = await getLastERC1155Operations(
253
+ currency,
254
+ address,
255
+ accountId,
256
+ fromBlock,
257
+ toBlock,
258
+ );
259
+
260
+ return [...erc721Ops, ...erc1155Ops].sort(
261
+ // sorting DESC order
262
+ (a, b) => b.date.getTime() - a.date.getTime(),
263
+ );
264
+ };
265
+
266
+ /**
267
+ * Wrapper around all operation types' requests
268
+ *
269
+ * ⚠ The lack of parallelization is on purpose,
270
+ * do not use a Promise.all here, it would
271
+ * break because of the rate limits
272
+ */
273
+ export const getLastOperations = makeLRUCache<
274
+ [
275
+ currency: CryptoCurrency,
276
+ address: string,
277
+ accountId: string,
278
+ fromBlock: number,
279
+ toBlock?: number,
280
+ ],
281
+ {
282
+ lastCoinOperations: Operation[];
283
+ lastTokenOperations: Operation[];
284
+ lastNftOperations: Operation[];
285
+ }
286
+ >(
287
+ async (currency, address, accountId, fromBlock, toBlock) => {
288
+ const lastCoinOperations = await getLastCoinOperations(
289
+ currency,
290
+ address,
291
+ accountId,
292
+ fromBlock,
293
+ toBlock,
294
+ );
295
+
296
+ const lastTokenOperations = await getLastTokenOperations(
297
+ currency,
298
+ address,
299
+ accountId,
300
+ fromBlock,
301
+ toBlock,
302
+ );
91
303
 
92
- const ops = await fetchWithRetries<EtherscanERC20Event[]>({
93
- method: "GET",
94
- url,
95
- });
304
+ const lastNftOperations = isNFTActive(currency)
305
+ ? await getLastNftOperations(currency, address, accountId, fromBlock, toBlock)
306
+ : [];
96
307
 
97
- return ops.map(event => etherscanERC20EventToOperation(accountId, event)).filter(Boolean) as {
98
- tokenCurrency: TokenCurrency;
99
- operation: Operation;
100
- }[];
308
+ return {
309
+ lastCoinOperations,
310
+ lastTokenOperations,
311
+ lastNftOperations,
312
+ };
101
313
  },
102
- (currency, address, accountId, fromBlock) => accountId + fromBlock,
103
- { ttl: 5 * 1000 },
314
+ (currency, address, accountId, fromBlock, toBlock) => accountId + fromBlock + toBlock,
315
+ { ttl: ETHERSCAN_TIMEOUT },
104
316
  );
105
317
 
106
318
  export default {
107
319
  getLastCoinOperations,
108
320
  getLastTokenOperations,
321
+ getLastERC721Operations,
322
+ getLastERC1155Operations,
323
+ getLastNftOperations,
324
+ getLastOperations,
109
325
  };
@@ -1,20 +1,34 @@
1
1
  import { CacheRes } from "@ledgerhq/live-network/cache";
2
- import { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
2
+ import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
3
3
  import { Operation } from "@ledgerhq/types-live";
4
4
  import etherscanLikeApi from "./etherscan";
5
5
 
6
+ type ExplorerBasicRequest = (
7
+ currency: CryptoCurrency,
8
+ address: string,
9
+ accountId: string,
10
+ fromBlock: number,
11
+ toBlock?: number,
12
+ ) => Promise<Operation[]>;
13
+
6
14
  type ExplorerApi = {
7
- getLastCoinOperations: CacheRes<
8
- [currency: CryptoCurrency, address: string, accountId: string, fromBlock: number],
9
- Operation[]
10
- >;
11
- getLastTokenOperations: CacheRes<
12
- [currency: CryptoCurrency, address: string, accountId: string, fromBlock: number],
15
+ getLastOperations: CacheRes<
16
+ Parameters<ExplorerBasicRequest>,
13
17
  {
14
- tokenCurrency: TokenCurrency;
15
- operation: Operation;
16
- }[]
18
+ lastCoinOperations: Operation[];
19
+ lastTokenOperations: Operation[];
20
+ lastNftOperations: Operation[];
21
+ }
17
22
  >;
23
+ // For now every other exported function should be considered as internal
24
+ // methods as they're unecessary to the synchronization it self.
25
+ // This can be updated with new sync requirements.
26
+ // & { [key in
27
+ // | "getLastCoinOperations"
28
+ // | "getLastTokenOperations"
29
+ // | "getLastERC721Operations"
30
+ // | "getLastERC1155Operations"
31
+ // | "getLastNftOperations"]: ExplorerBasicRequest; }
18
32
  };
19
33
 
20
34
  /**
@@ -0,0 +1,49 @@
1
+ import { getEnv } from "@ledgerhq/live-env";
2
+ import network from "@ledgerhq/live-network/network";
3
+ import { NFTCollectionMetadataResponse, NFTMetadataResponse } from "@ledgerhq/types-live";
4
+ import { CollectionMetadataInput, NftMetadataInput } from "@ledgerhq/coin-framework/nft/types";
5
+
6
+ /**
7
+ * Batched request of nft metadata on the "ethereum" protocol
8
+ *
9
+ * ⚠️ ethereum protocol doesn't mean ethereum chain, you can see this
10
+ * as the evm protocol instead, and you can specify a chainId
11
+ * to request the metadata on any evm chain supported
12
+ */
13
+ export const getNftMetadata = async (
14
+ input: NftMetadataInput[],
15
+ chainId: number,
16
+ ): Promise<NFTMetadataResponse[]> => {
17
+ const { data }: { data: NFTMetadataResponse[] } = await network({
18
+ method: "POST",
19
+ url: `${getEnv("NFT_ETH_METADATA_SERVICE")}/v1/ethereum/${chainId}/contracts/tokens/infos`,
20
+ data: input,
21
+ });
22
+
23
+ return data;
24
+ };
25
+
26
+ /**
27
+ * Batched request of nft collection metadata on the "ethereum" protocol
28
+ *
29
+ * ⚠️ ethereum protocol doesn't mean ethereum chain, you can see this
30
+ * as the evm protocol instead, and you can specify a chainId
31
+ * to request the metadata on any evm chain supported
32
+ */
33
+ export const getNftCollectionMetadata = async (
34
+ input: CollectionMetadataInput[],
35
+ chainId: number,
36
+ ): Promise<NFTCollectionMetadataResponse[]> => {
37
+ const { data }: { data: NFTCollectionMetadataResponse[] } = await network({
38
+ method: "POST",
39
+ url: `${getEnv("NFT_ETH_METADATA_SERVICE")}/v1/ethereum/${chainId}/contracts/infos`,
40
+ data: input,
41
+ });
42
+
43
+ return data;
44
+ };
45
+
46
+ export default {
47
+ getNftMetadata,
48
+ getNftCollectionMetadata,
49
+ };
@@ -1,3 +1,5 @@
1
+ /* istanbul ignore file: pure exports, test unecessary */
2
+
1
3
  /** ⚠️ keep this order of import. @see https://docs.ethers.io/v5/cookbook/react-native/#cookbook-reactnative ⚠️ */
2
4
  import "react-native-get-random-values";
3
5
  import "@ethersproject/shims";
@@ -13,8 +13,8 @@ import { transactionToEthersTransaction } from "../../adapters";
13
13
  import { getSerializedTransaction } from "../../transaction";
14
14
  import ERC20Abi from "../../abis/erc20.abi.json";
15
15
 
16
- export const RPC_TIMEOUT = 5000; // wait 5 sec after a fail
17
- export const DEFAULT_RETRIES_RPC_METHODS = 3;
16
+ export const RPC_TIMEOUT = process.env.NODE_ENV === "test" ? 100 : 5000; // wait 5 sec after a fail
17
+ export const DEFAULT_RETRIES_RPC_METHODS = process.env.NODE_ENV === "test" ? 1 : 3;
18
18
 
19
19
  /**
20
20
  * Cache for RPC providers to avoid recreating the connection on every usage of `withApi`
@@ -119,7 +119,7 @@ export const getTokenBalance = (
119
119
  */
120
120
  export const getTransactionCount = (currency: CryptoCurrency, addr: string): Promise<number> =>
121
121
  withApi(currency, async api => {
122
- return api.getTransactionCount(addr);
122
+ return api.getTransactionCount(addr, "pending");
123
123
  });
124
124
 
125
125
  /**
package/src/bridge/js.ts CHANGED
@@ -1,28 +1,24 @@
1
- import getAddressWrapper from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
1
+ /* istanbul ignore file: pure exports, bridge tested by live-common with bridge.integration.test.ts */
2
2
  import {
3
+ defaultUpdateTransaction,
3
4
  makeAccountBridgeReceive,
4
5
  makeScanAccounts,
5
6
  } from "@ledgerhq/coin-framework/bridge/jsHelpers";
6
7
  import { SignerContext } from "@ledgerhq/coin-framework/signer";
7
8
  import type { AccountBridge, CurrencyBridge } from "@ledgerhq/types-live";
8
- import { broadcast } from "../broadcast";
9
- import { createTransaction } from "../createTransaction";
9
+ import getAddressWrapper from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
10
+ import type { Transaction as EvmTransaction, Transaction } from "../types";
11
+ import { EvmAddress, EvmSignature, EvmSigner } from "../signer";
10
12
  import { estimateMaxSpendable } from "../estimateMaxSpendable";
11
13
  import { getTransactionStatus } from "../getTransactionStatus";
12
- import resolver from "../hw-getAddress";
13
- import { hydrate, preload } from "../preload";
14
+ import { getAccountShape, sync } from "../synchronization";
14
15
  import { prepareTransaction } from "../prepareTransaction";
16
+ import { createTransaction } from "../createTransaction";
15
17
  import { buildSignOperation } from "../signOperation";
16
- import { getAccountShape, sync } from "../synchronization";
17
- import { EvmAddress, EvmSignature, EvmSigner } from "../signer";
18
- import type { Transaction as EvmTransaction, Transaction } from "../types";
19
-
20
- const updateTransaction: AccountBridge<EvmTransaction>["updateTransaction"] = (
21
- transaction,
22
- patch,
23
- ) => {
24
- return { ...transaction, ...patch } as EvmTransaction;
25
- };
18
+ import { hydrate, preload } from "../preload";
19
+ import nftResolvers from "../nftResolvers";
20
+ import { broadcast } from "../broadcast";
21
+ import resolver from "../hw-getAddress";
26
22
 
27
23
  export function buildCurrencyBridge(
28
24
  signerContext: SignerContext<EvmSigner, EvmAddress | EvmSignature>,
@@ -38,6 +34,7 @@ export function buildCurrencyBridge(
38
34
  preload,
39
35
  hydrate,
40
36
  scanAccounts,
37
+ nftResolvers,
41
38
  };
42
39
  }
43
40
 
@@ -51,7 +48,7 @@ export function buildAccountBridge(
51
48
 
52
49
  return {
53
50
  createTransaction,
54
- updateTransaction,
51
+ updateTransaction: defaultUpdateTransaction<EvmTransaction>,
55
52
  prepareTransaction,
56
53
  getTransactionStatus,
57
54
  sync,
package/src/broadcast.ts CHANGED
@@ -1,7 +1,12 @@
1
- import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
1
+ import {
2
+ encodeERC1155OperationId,
3
+ encodeERC721OperationId,
4
+ } from "@ledgerhq/coin-framework/nft/nftOperationId";
5
+ import { encodeNftId } from "@ledgerhq/coin-framework/nft/nftId";
2
6
  import type { AccountBridge, Operation } from "@ledgerhq/types-live";
3
- import { broadcastTransaction } from "./api/rpc";
7
+ import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
4
8
  import { Transaction as EvmTransaction } from "./types";
9
+ import { broadcastTransaction } from "./api/rpc";
5
10
 
6
11
  /**
7
12
  * Broadcast a transaction and update the operation linked
@@ -30,6 +35,28 @@ export const broadcast: AccountBridge<EvmTransaction>["broadcast"] = async ({
30
35
  blockHash: txResponse.blockHash,
31
36
  date: new Date(txResponse.timestamp ? txResponse.timestamp * 1000 : Date.now()),
32
37
  })) || [],
38
+ nftOperations:
39
+ operation.nftOperations?.map(nftOp => {
40
+ const nftId = encodeNftId(
41
+ nftOp.accountId,
42
+ nftOp.contract || "",
43
+ nftOp.tokenId || "",
44
+ account.currency.id,
45
+ );
46
+
47
+ return {
48
+ ...nftOp,
49
+ id:
50
+ nftOp.standard === "ERC721"
51
+ ? encodeERC721OperationId(nftId, txResponse.hash, nftOp.type, 0)
52
+ : encodeERC1155OperationId(nftId, txResponse.hash, nftOp.type, 0),
53
+ hash: txResponse.hash,
54
+ blockNumber: txResponse.blockNumber,
55
+ blockHeight: txResponse.blockNumber,
56
+ blockHash: txResponse.blockHash,
57
+ date: new Date(txResponse.timestamp ? txResponse.timestamp * 1000 : Date.now()),
58
+ };
59
+ }) || [],
33
60
  } as Operation;
34
61
  };
35
62
 
@@ -1,10 +1,15 @@
1
- import { findSubAccountById } from "@ledgerhq/coin-framework/account/index";
2
- import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
3
- import { Account, Operation, OperationType, TokenAccount } from "@ledgerhq/types-live";
4
- import BigNumber from "bignumber.js";
5
1
  import eip55 from "eip55";
6
- import { getEstimatedFees } from "./logic";
7
- import { Transaction as EvmTransaction } from "./types";
2
+ import BigNumber from "bignumber.js";
3
+ import { Account, Operation, OperationType, TokenAccount } from "@ledgerhq/types-live";
4
+ import {
5
+ encodeERC1155OperationId,
6
+ encodeERC721OperationId,
7
+ } from "@ledgerhq/coin-framework/nft/nftOperationId";
8
+ import { encodeNftId } from "@ledgerhq/coin-framework/nft/nftId";
9
+ import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
10
+ import { findSubAccountById } from "@ledgerhq/coin-framework/account/index";
11
+ import { EvmNftTransaction, Transaction as EvmTransaction } from "./types";
12
+ import { getEstimatedFees, isNftTransaction } from "./logic";
8
13
 
9
14
  /**
10
15
  * Build an optimistic operation for the coin of the integration (e.g. Ether for Ethereum)
@@ -85,6 +90,62 @@ export const buildOptimisticTokenOperation = (
85
90
  return operation;
86
91
  };
87
92
 
93
+ /**
94
+ * Build an optimistic operation for an ERC721 or ERC1155 transaction
95
+ */
96
+ export const buildOptimisticNftOperation = (
97
+ account: Account,
98
+ transaction: EvmNftTransaction & EvmTransaction,
99
+ ): Operation => {
100
+ const type = "NFT_OUT";
101
+ const estimatedFees = getEstimatedFees(transaction);
102
+ const { nft } = transaction;
103
+ const value = nft.quantity;
104
+
105
+ const coinOperation = buildOptimisticCoinOperation(
106
+ account,
107
+ {
108
+ ...transaction,
109
+ recipient: nft.contract,
110
+ amount: new BigNumber(0),
111
+ },
112
+ "FEES",
113
+ );
114
+
115
+ const nftId = encodeNftId(account.id, nft.contract, nft.tokenId, account.currency.id);
116
+ const nftOpId =
117
+ transaction.mode === "erc721"
118
+ ? encodeERC721OperationId(nftId, "", type, 0)
119
+ : encodeERC1155OperationId(nftId, "", type, 0);
120
+
121
+ // keys marked with a <-- will be updated by the broadcast method
122
+ const operation: Operation = {
123
+ ...coinOperation,
124
+ nftOperations: [
125
+ {
126
+ id: nftOpId, // <--
127
+ hash: "", // <--
128
+ type,
129
+ value,
130
+ fee: estimatedFees,
131
+ blockHash: null, // <--
132
+ blockHeight: null, // <--
133
+ senders: [eip55.encode(account.freshAddress)],
134
+ recipients: [eip55.encode(transaction.recipient)],
135
+ accountId: account.id,
136
+ transactionSequenceNumber: transaction.nonce,
137
+ date: new Date(), // <--
138
+ extra: {},
139
+ contract: nft.contract,
140
+ standard: transaction.mode.toUpperCase(),
141
+ tokenId: nft.tokenId,
142
+ },
143
+ ],
144
+ };
145
+
146
+ return operation;
147
+ };
148
+
88
149
  /**
89
150
  * Create a temporary operation to use until it's confirmed by the blockchain
90
151
  */
@@ -92,6 +153,10 @@ export const buildOptimisticOperation = (
92
153
  account: Account,
93
154
  transaction: EvmTransaction,
94
155
  ): Operation => {
156
+ if (isNftTransaction(transaction)) {
157
+ return buildOptimisticNftOperation(account, transaction);
158
+ }
159
+
95
160
  const subAccount = findSubAccountById(account, transaction?.subAccountId || "");
96
161
  const isTokenTransaction = subAccount?.type === "TokenAccount";
97
162
 
@@ -1,3 +1,5 @@
1
+ /* istanbul ignore file: untested because empty */
2
+
1
3
  // Needed by sync-families-dispatch script
2
4
  // libs/ledger-live-common/scripts/sync-families-dispatch.mjs
3
5
  export default function makeCliTools() {