@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,39 +1,16 @@
1
- import { getCryptoCurrencyById, getTokenById } from "@ledgerhq/cryptoassets";
2
1
  import BigNumber from "bignumber.js";
3
- import { ethers } from "ethers";
4
- import ERC20ABI from "../abis/erc20.abi.json";
5
- import * as rpcAPI from "../api/rpc/rpc.common";
6
- import { prepareForSignOperation, prepareTransaction } from "../prepareTransaction";
7
- import { makeAccount, makeTokenAccount } from "../testUtils";
8
- import { Transaction as EvmTransaction, GasOptions } from "../types";
9
-
10
- const currency = getCryptoCurrencyById("ethereum");
11
- const tokenAccount = makeTokenAccount("0xkvn", getTokenById("ethereum/erc20/usd__coin"));
12
- const account = makeAccount("0xkvn", currency, [tokenAccount]);
13
- const transaction: EvmTransaction = {
14
- amount: new BigNumber(100),
15
- useAllAmount: false,
16
- subAccountId: "id",
17
- recipient: "0x6bfD74C0996F269Bcece59191EFf667b3dFD73b9",
18
- feesStrategy: "medium",
19
- family: "evm",
20
- mode: "send",
21
- gasPrice: new BigNumber(0),
22
- gasLimit: new BigNumber(21000),
23
- nonce: 0,
24
- chainId: 1,
25
- };
26
- const tokenTransaction: EvmTransaction = {
27
- ...transaction,
28
- subAccountId: tokenAccount.id,
29
- };
30
- const expectedData = (recipient: string, amount: BigNumber): Buffer =>
31
- Buffer.from(
32
- new ethers.utils.Interface(ERC20ABI)
33
- .encodeFunctionData("transfer", [recipient, amount.toFixed()])
34
- .slice(2),
35
- "hex",
36
- );
2
+ import { prepareForSignOperation, prepareTransaction } from "../../prepareTransaction";
3
+ import * as rpcAPI from "../../api/rpc/rpc.common";
4
+ import {
5
+ account,
6
+ expectedData,
7
+ nftTransaction,
8
+ tokenAccount,
9
+ tokenTransaction,
10
+ transaction,
11
+ } from "../fixtures/prepareTransaction.fixtures";
12
+ import { GasOptions } from "../../types";
13
+ import * as nftAPI from "../../api/nft";
37
14
 
38
15
  describe("EVM Family", () => {
39
16
  describe("prepareTransaction.ts", () => {
@@ -46,6 +23,23 @@ describe("EVM Family", () => {
46
23
  maxFeePerGas: new BigNumber(1),
47
24
  maxPriorityFeePerGas: new BigNumber(1),
48
25
  }));
26
+ jest.spyOn(nftAPI, "getNftCollectionMetadata").mockImplementation(async input => {
27
+ if (
28
+ input[0]?.contract === "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D" &&
29
+ input.length === 1
30
+ ) {
31
+ return [
32
+ {
33
+ status: 200,
34
+ result: {
35
+ contract: "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
36
+ tokenName: "Bored Ape",
37
+ },
38
+ },
39
+ ];
40
+ }
41
+ return [];
42
+ });
49
43
  });
50
44
 
51
45
  afterEach(() => {
@@ -53,6 +47,13 @@ describe("EVM Family", () => {
53
47
  });
54
48
 
55
49
  describe("prepareTransaction", () => {
50
+ it("should preserve the reference when no change is detected on the transaction", async () => {
51
+ const tx = await prepareTransaction(account, { ...transaction });
52
+ const tx2 = await prepareTransaction(account, tx);
53
+
54
+ expect(tx).toBe(tx2);
55
+ });
56
+
56
57
  describe("Coins", () => {
57
58
  it("should have a gasLimit = 0 when recipient has an error", async () => {
58
59
  jest.spyOn(rpcAPI, "getGasEstimation").mockImplementation(async () => {
@@ -97,10 +98,11 @@ describe("EVM Family", () => {
97
98
  });
98
99
 
99
100
  it("should return an EIP1559 coin transaction", async () => {
100
- const tx = await prepareTransaction(account, transaction);
101
+ const tx = await prepareTransaction(account, { ...transaction });
101
102
 
102
103
  expect(tx).toEqual({
103
104
  ...transaction,
105
+ gasPrice: undefined,
104
106
  maxFeePerGas: new BigNumber(1),
105
107
  maxPriorityFeePerGas: new BigNumber(1),
106
108
  type: 2,
@@ -114,11 +116,13 @@ describe("EVM Family", () => {
114
116
  maxPriorityFeePerGas: null,
115
117
  }));
116
118
 
117
- const tx = await prepareTransaction(account, transaction);
119
+ const tx = await prepareTransaction(account, { ...transaction });
118
120
 
119
121
  expect(tx).toEqual({
120
122
  ...transaction,
121
123
  gasPrice: new BigNumber(1),
124
+ maxFeePerGas: undefined,
125
+ maxPriorityFeePerGas: undefined,
122
126
  type: 0,
123
127
  });
124
128
  });
@@ -133,12 +137,15 @@ describe("EVM Family", () => {
133
137
  useAllAmount: true,
134
138
  };
135
139
 
136
- const tx = await prepareTransaction(accountWithBalance, transactionWithUseAllAmount);
140
+ const tx = await prepareTransaction(accountWithBalance, {
141
+ ...transactionWithUseAllAmount,
142
+ });
137
143
  const estimatedFees = new BigNumber(21000); // 21000 gasLimit * 1 maxFeePerGas
138
144
 
139
145
  expect(tx).toEqual({
140
146
  ...transactionWithUseAllAmount,
141
147
  amount: accountWithBalance.balance.minus(estimatedFees),
148
+ gasPrice: undefined,
142
149
  maxFeePerGas: new BigNumber(1),
143
150
  maxPriorityFeePerGas: new BigNumber(1),
144
151
  type: 2,
@@ -162,6 +169,7 @@ describe("EVM Family", () => {
162
169
  expect(tx).toEqual({
163
170
  ...transaction,
164
171
  data: Buffer.from("Sm4rTC0ntr4ct", "hex"),
172
+ gasPrice: undefined,
165
173
  maxFeePerGas: new BigNumber(1),
166
174
  maxPriorityFeePerGas: new BigNumber(1),
167
175
  gasLimit: new BigNumber(12),
@@ -210,7 +218,7 @@ describe("EVM Family", () => {
210
218
  maxPriorityFeePerGas: new BigNumber(1),
211
219
  gasPrice: undefined,
212
220
  gasLimit: new BigNumber(0),
213
- data: expectedData(tokenTransaction.recipient, new BigNumber(0)),
221
+ data: expectedData(account, tx, "erc20"),
214
222
  type: 2,
215
223
  });
216
224
  });
@@ -241,7 +249,7 @@ describe("EVM Family", () => {
241
249
  amount: tokenAccountWithBalance.balance,
242
250
  useAllAmount: true,
243
251
  subAccountId: tokenAccountWithBalance.id,
244
- data: expectedData(tokenTransaction.recipient, tokenAccountWithBalance.balance),
252
+ data: expectedData(account, tx, "erc20"),
245
253
  maxFeePerGas: new BigNumber(1),
246
254
  maxPriorityFeePerGas: new BigNumber(1),
247
255
  gasPrice: undefined,
@@ -264,7 +272,7 @@ describe("EVM Family", () => {
264
272
  subAccounts: [tokenAccountWithBalance],
265
273
  };
266
274
 
267
- await prepareTransaction(account2, {
275
+ const tx = await prepareTransaction(account2, {
268
276
  ...tokenTransaction,
269
277
  useAllAmount: true,
270
278
  subAccountId: tokenAccountWithBalance.id,
@@ -275,7 +283,7 @@ describe("EVM Family", () => {
275
283
  expect.objectContaining({
276
284
  recipient: tokenAccount.token.contractAddress,
277
285
  amount: new BigNumber(0),
278
- data: expectedData(tokenTransaction.recipient, tokenAccountWithBalance.balance),
286
+ data: expectedData(account, tx, "erc20"),
279
287
  }),
280
288
  );
281
289
  });
@@ -289,11 +297,14 @@ describe("EVM Family", () => {
289
297
  ...account,
290
298
  subAccounts: [tokenAccountWithBalance],
291
299
  };
292
- const tx = await prepareTransaction(account2, tokenTransaction);
300
+ const tx = await prepareTransaction(account2, {
301
+ ...tokenTransaction,
302
+ });
293
303
 
294
304
  expect(tx).toEqual({
295
305
  ...tokenTransaction,
296
- data: expectedData(tokenTransaction.recipient, tokenTransaction.amount),
306
+ data: expectedData(account, tokenTransaction, "erc20"),
307
+ gasPrice: undefined,
297
308
  maxFeePerGas: new BigNumber(1),
298
309
  maxPriorityFeePerGas: new BigNumber(1),
299
310
  type: 2,
@@ -315,107 +326,262 @@ describe("EVM Family", () => {
315
326
  ...account,
316
327
  subAccounts: [tokenAccountWithBalance],
317
328
  };
318
- const tx = await prepareTransaction(account2, tokenTransaction);
329
+ const tx = await prepareTransaction(account2, {
330
+ ...tokenTransaction,
331
+ });
319
332
 
320
333
  expect(tx).toEqual({
321
334
  ...tokenTransaction,
322
- data: expectedData(tokenTransaction.recipient, tokenTransaction.amount),
335
+ data: expectedData(account, tokenTransaction, "erc20"),
336
+ maxFeePerGas: undefined,
337
+ maxPriorityFeePerGas: undefined,
323
338
  gasPrice: new BigNumber(1),
324
339
  type: 0,
325
340
  });
326
341
  });
327
342
  });
328
343
 
329
- describe("When feesStrategy provided", () => {
330
- it("should call getFeesEstimation once", async () => {
331
- const tx = await prepareTransaction(account, {
332
- ...transaction,
333
- feesStrategy: undefined,
344
+ describe("Gas", () => {
345
+ describe("When feesStrategy provided", () => {
346
+ it("should call getFeesEstimation once", async () => {
347
+ const tx = await prepareTransaction(account, {
348
+ ...transaction,
349
+ feesStrategy: undefined,
350
+ });
351
+
352
+ expect(rpcAPI.getFeesEstimation).toBeCalledTimes(1);
353
+
354
+ expect(tx).toEqual({
355
+ ...transaction,
356
+ feesStrategy: undefined,
357
+ additionalFees: undefined,
358
+ gasPrice: undefined,
359
+ maxFeePerGas: new BigNumber(1),
360
+ maxPriorityFeePerGas: new BigNumber(1),
361
+ type: 2,
362
+ });
334
363
  });
364
+ });
335
365
 
336
- expect(rpcAPI.getFeesEstimation).toBeCalledTimes(1);
366
+ describe("When custom feesStrategy provided", () => {
367
+ it("should use transaction provided data for fees", async () => {
368
+ const tx = await prepareTransaction(account, {
369
+ ...transaction,
370
+ feesStrategy: "custom",
371
+ });
372
+
373
+ expect(rpcAPI.getFeesEstimation).toBeCalledTimes(0);
374
+
375
+ expect(tx).toEqual({
376
+ ...transaction,
377
+ additionalFees: undefined,
378
+ feesStrategy: "custom",
379
+ gasPrice: new BigNumber(0),
380
+ type: 0,
381
+ });
382
+ });
383
+ });
337
384
 
338
- expect(tx).toEqual({
339
- ...transaction,
340
- feesStrategy: undefined,
341
- additionalFees: undefined,
342
- maxFeePerGas: new BigNumber(1),
343
- maxPriorityFeePerGas: new BigNumber(1),
344
- type: 2,
385
+ describe("When gasOptions provided", () => {
386
+ it("should call getFeesEstimation once", async () => {
387
+ const tx = await prepareTransaction(account, {
388
+ ...transaction,
389
+ gasOptions: undefined,
390
+ });
391
+
392
+ expect(rpcAPI.getFeesEstimation).toBeCalledTimes(1);
393
+
394
+ expect(tx).toEqual({
395
+ ...transaction,
396
+ gasPrice: undefined,
397
+ maxFeePerGas: new BigNumber(1),
398
+ maxPriorityFeePerGas: new BigNumber(1),
399
+ type: 2,
400
+ });
401
+ });
402
+
403
+ it("should use gasOptions values for fee data", async () => {
404
+ const gasOptions: GasOptions = {
405
+ slow: {
406
+ maxFeePerGas: new BigNumber(10),
407
+ maxPriorityFeePerGas: new BigNumber(1),
408
+ gasPrice: null,
409
+ },
410
+ medium: {
411
+ maxFeePerGas: new BigNumber(20),
412
+ maxPriorityFeePerGas: new BigNumber(2),
413
+ gasPrice: null,
414
+ },
415
+ fast: {
416
+ maxFeePerGas: new BigNumber(30),
417
+ maxPriorityFeePerGas: new BigNumber(3),
418
+ gasPrice: null,
419
+ },
420
+ };
421
+ const tx = await prepareTransaction(account, {
422
+ ...transaction,
423
+ gasOptions,
424
+ });
425
+
426
+ expect(rpcAPI.getFeesEstimation).toBeCalledTimes(0);
427
+
428
+ expect(tx).toEqual({
429
+ ...transaction,
430
+ additionalFees: undefined,
431
+ gasPrice: undefined,
432
+ gasOptions,
433
+ maxFeePerGas: new BigNumber(20),
434
+ maxPriorityFeePerGas: new BigNumber(2),
435
+ type: 2,
436
+ });
345
437
  });
346
438
  });
347
439
  });
348
440
 
349
- describe("When custom feesStrategy provided", () => {
350
- it("should use transaction provided data for fees", async () => {
351
- const tx = await prepareTransaction(account, {
352
- ...transaction,
353
- feesStrategy: "custom",
441
+ describe("Nfts", () => {
442
+ it("should have a gasLimit = 0 and no data when recipient has an error", async () => {
443
+ jest.spyOn(rpcAPI, "getGasEstimation").mockImplementation(async () => {
444
+ throw new Error();
354
445
  });
355
446
 
356
- expect(rpcAPI.getFeesEstimation).toBeCalledTimes(0);
447
+ const tx = await prepareTransaction(account, {
448
+ ...nftTransaction,
449
+ recipient: "notValid",
450
+ });
357
451
 
358
452
  expect(tx).toEqual({
359
- ...transaction,
360
- additionalFees: undefined,
361
- feesStrategy: "custom",
362
- gasPrice: new BigNumber(0),
363
- type: 0,
453
+ ...nftTransaction,
454
+ nft: {
455
+ ...nftTransaction.nft,
456
+ collectionName: "Bored Ape",
457
+ },
458
+ recipient: "notValid",
459
+ maxFeePerGas: new BigNumber(1),
460
+ maxPriorityFeePerGas: new BigNumber(1),
461
+ gasPrice: undefined,
462
+ gasLimit: new BigNumber(0),
463
+ data: undefined,
464
+ type: 2,
364
465
  });
365
466
  });
366
- });
367
467
 
368
- describe("When gasOptions provided", () => {
369
- it("should call getFeesEstimation once", async () => {
370
- const tx = await prepareTransaction(account, {
371
- ...transaction,
372
- gasOptions: undefined,
468
+ it("should have a gasLimit = 0 when amount has an error", async () => {
469
+ jest.spyOn(rpcAPI, "getGasEstimation").mockImplementation(async () => {
470
+ throw new Error();
373
471
  });
374
472
 
375
- expect(rpcAPI.getFeesEstimation).toBeCalledTimes(1);
473
+ const tx = await prepareTransaction(account, {
474
+ ...nftTransaction,
475
+ amount: new BigNumber(0),
476
+ });
376
477
 
377
478
  expect(tx).toEqual({
378
- ...transaction,
479
+ ...nftTransaction,
480
+ nft: {
481
+ ...nftTransaction.nft,
482
+ collectionName: "Bored Ape",
483
+ },
484
+ amount: new BigNumber(0),
379
485
  maxFeePerGas: new BigNumber(1),
380
486
  maxPriorityFeePerGas: new BigNumber(1),
487
+ gasPrice: undefined,
488
+ gasLimit: new BigNumber(0),
489
+ data: expectedData(account, nftTransaction, "erc721"),
381
490
  type: 2,
382
491
  });
383
492
  });
384
- });
385
493
 
386
- describe("When gasOptions provided", () => {
387
- const gasOptions: GasOptions = {
388
- slow: {
389
- maxFeePerGas: new BigNumber(10),
390
- maxPriorityFeePerGas: new BigNumber(1),
391
- gasPrice: null,
392
- },
393
- medium: {
394
- maxFeePerGas: new BigNumber(20),
395
- maxPriorityFeePerGas: new BigNumber(2),
396
- gasPrice: null,
397
- },
398
- fast: {
399
- maxFeePerGas: new BigNumber(30),
400
- maxPriorityFeePerGas: new BigNumber(3),
401
- gasPrice: null,
402
- },
403
- };
404
- it("should use gasOptions values for fee data", async () => {
405
- const tx = await prepareTransaction(account, {
406
- ...transaction,
407
- gasOptions,
494
+ describe("ERC721", () => {
495
+ it("should return an EIP1559 erc721 nft transaction", async () => {
496
+ const tx = await prepareTransaction(account, {
497
+ ...nftTransaction,
498
+ });
499
+
500
+ expect(tx).toEqual({
501
+ ...nftTransaction,
502
+ data: expectedData(account, tx, "erc721"),
503
+ nft: {
504
+ ...nftTransaction.nft,
505
+ collectionName: "Bored Ape",
506
+ },
507
+ gasPrice: undefined,
508
+ maxFeePerGas: new BigNumber(1),
509
+ maxPriorityFeePerGas: new BigNumber(1),
510
+ type: 2,
511
+ });
408
512
  });
409
513
 
410
- expect(rpcAPI.getFeesEstimation).toBeCalledTimes(0);
514
+ it("should return a legacy erc721 nft transaction", async () => {
515
+ jest.spyOn(rpcAPI, "getFeesEstimation").mockImplementationOnce(async () => ({
516
+ gasPrice: new BigNumber(1),
517
+ maxFeePerGas: null,
518
+ maxPriorityFeePerGas: null,
519
+ }));
520
+ const tx = await prepareTransaction(account, {
521
+ ...nftTransaction,
522
+ });
523
+
524
+ expect(tx).toEqual({
525
+ ...nftTransaction,
526
+ data: expectedData(account, tx, "erc721"),
527
+ nft: {
528
+ ...nftTransaction.nft,
529
+ collectionName: "Bored Ape",
530
+ },
531
+ maxFeePerGas: undefined,
532
+ maxPriorityFeePerGas: undefined,
533
+ gasPrice: new BigNumber(1),
534
+ type: 0,
535
+ });
536
+ });
537
+ });
411
538
 
412
- expect(tx).toEqual({
413
- ...transaction,
414
- gasOptions,
415
- additionalFees: undefined,
416
- maxFeePerGas: new BigNumber(20),
417
- maxPriorityFeePerGas: new BigNumber(2),
418
- type: 2,
539
+ describe("ERC1155", () => {
540
+ it("should return an EIP1559 erc1155 nft transaction", async () => {
541
+ const tx = await prepareTransaction(account, {
542
+ ...nftTransaction,
543
+ mode: "erc1155",
544
+ });
545
+
546
+ expect(tx).toEqual({
547
+ ...nftTransaction,
548
+ mode: "erc1155",
549
+ data: expectedData(account, tx, "erc1155"),
550
+ nft: {
551
+ ...nftTransaction.nft,
552
+ collectionName: "Bored Ape",
553
+ },
554
+ gasPrice: undefined,
555
+ maxFeePerGas: new BigNumber(1),
556
+ maxPriorityFeePerGas: new BigNumber(1),
557
+ type: 2,
558
+ });
559
+ });
560
+
561
+ it("should return a legacy erc1155 nft transaction", async () => {
562
+ jest.spyOn(rpcAPI, "getFeesEstimation").mockImplementationOnce(async () => ({
563
+ gasPrice: new BigNumber(1),
564
+ maxFeePerGas: null,
565
+ maxPriorityFeePerGas: null,
566
+ }));
567
+ const tx = await prepareTransaction(account, {
568
+ ...nftTransaction,
569
+ mode: "erc1155",
570
+ });
571
+
572
+ expect(tx).toEqual({
573
+ ...nftTransaction,
574
+ mode: "erc1155",
575
+ data: expectedData(account, tx, "erc1155"),
576
+ nft: {
577
+ ...nftTransaction.nft,
578
+ collectionName: "Bored Ape",
579
+ },
580
+ maxFeePerGas: undefined,
581
+ maxPriorityFeePerGas: undefined,
582
+ gasPrice: new BigNumber(1),
583
+ type: 0,
584
+ });
419
585
  });
420
586
  });
421
587
  });
@@ -444,6 +610,15 @@ describe("EVM Family", () => {
444
610
  nonce: 10,
445
611
  });
446
612
  });
613
+
614
+ it("should update an NFT transaction with the correct recipient", async () => {
615
+ expect(await prepareForSignOperation(account, nftTransaction)).toEqual({
616
+ ...nftTransaction,
617
+ amount: new BigNumber(0),
618
+ recipient: nftTransaction.nft.contract,
619
+ nonce: 10,
620
+ });
621
+ });
447
622
  });
448
623
  });
449
624
  });
@@ -1,14 +1,14 @@
1
- import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
2
- import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
3
- import { Account } from "@ledgerhq/types-live";
4
1
  import BigNumber from "bignumber.js";
5
- import { buildSignOperation, applyEIP155 } from "../signOperation";
6
- import { Transaction as EvmTransaction } from "../types";
7
- import * as rpcAPI from "../api/rpc/rpc.common";
8
- import { getEstimatedFees } from "../logic";
9
- import { makeAccount } from "../testUtils";
10
- import { EvmAddress, EvmSignature, EvmSigner } from "../signer";
2
+ import { Account } from "@ledgerhq/types-live";
3
+ import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
11
4
  import { SignerContext } from "@ledgerhq/coin-framework/signer";
5
+ import { getCryptoCurrencyById, listCryptoCurrencies } from "@ledgerhq/cryptoassets";
6
+ import { buildSignOperation, applyEIP155 } from "../../signOperation";
7
+ import { EvmAddress, EvmSignature, EvmSigner } from "../../signer";
8
+ import { Transaction as EvmTransaction } from "../../types";
9
+ import { makeAccount } from "../fixtures/common.fixtures";
10
+ import * as rpcAPI from "../../api/rpc/rpc.common";
11
+ import { getEstimatedFees } from "../../logic";
12
12
 
13
13
  const currency: CryptoCurrency = {
14
14
  ...getCryptoCurrencyById("ethereum"),
@@ -44,6 +44,7 @@ const mockSignerContext: SignerContext<EvmSigner, EvmAddress | EvmSignature> = (
44
44
  fn: (signer: EvmSigner) => Promise<EvmAddress | EvmSignature>,
45
45
  ) => {
46
46
  return fn({
47
+ setLoadConfig: jest.fn(),
47
48
  getAddress: jest.fn(),
48
49
  signTransaction: () =>
49
50
  Promise.resolve({
@@ -51,6 +52,9 @@ const mockSignerContext: SignerContext<EvmSigner, EvmAddress | EvmSignature> = (
51
52
  s: "abc",
52
53
  v: "27",
53
54
  }),
55
+ signEIP712HashedMessage: jest.fn(),
56
+ signEIP712Message: jest.fn(),
57
+ signPersonalMessage: jest.fn(),
54
58
  });
55
59
  };
56
60
 
@@ -119,17 +123,11 @@ describe("EVM Family", () => {
119
123
  });
120
124
 
121
125
  describe("applyEIP155", () => {
122
- const chainIds = [
123
- 1, //ethereum
124
- 5, // goerli
125
- 10, // optimism
126
- 14, // flare
127
- 19, // songbird
128
- 56, // bsc
129
- 137, // polygon
130
- 250, // fantom
131
- 1284, // moonbeam
132
- ];
126
+ const chainIds = listCryptoCurrencies(true)
127
+ .filter(c => c.family === "evm")
128
+ .map(c => c.ethereumLikeInfo!.chainId)
129
+ .sort((a, b) => a - b);
130
+
133
131
  const possibleHexV = [
134
132
  "00", // 0 - ethereum + testnets should always retrun 0/1 from hw-app-eth
135
133
  "01", // 1