@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,7 +1,9 @@
1
+ /* istanbul ignore file: pure exports, test unecessary */
2
+
1
3
  import { AccountRaw } from "@ledgerhq/types-live";
2
4
 
3
5
  export const ethereum1: AccountRaw = {
4
- id: "js:1:ethereum:0x0E3F0bb9516F01f2C34c25E0957518b8aC9414c5:",
6
+ id: "js:1:ethereum_as_evm_test_only:0x0E3F0bb9516F01f2C34c25E0957518b8aC9414c5:",
5
7
  seedIdentifier: "0x0E3F0bb9516F01f2C34c25E0957518b8aC9414c5",
6
8
  name: "Ethereum legacy xpub6Bem...JyAdpYZy",
7
9
  derivationMode: "",
@@ -11,7 +13,7 @@ export const ethereum1: AccountRaw = {
11
13
  freshAddresses: [],
12
14
  pendingOperations: [],
13
15
  operations: [],
14
- currencyId: "ethereum",
16
+ currencyId: "ethereum_as_evm_test_only",
15
17
  unitMagnitude: 18,
16
18
  balance: "",
17
19
  blockHeight: 0,
@@ -51,6 +51,71 @@ function getDeviceTransactionConfig({
51
51
  },
52
52
  );
53
53
  break;
54
+
55
+ case "erc721":
56
+ fields.push(
57
+ {
58
+ type: "text",
59
+ label: "Type",
60
+ value: `NFT Transfer`,
61
+ },
62
+ {
63
+ type: "text",
64
+ label: "To",
65
+ value: transaction.recipient,
66
+ },
67
+ {
68
+ type: "text",
69
+ label: "Collection Name",
70
+ value: transaction.nft.collectionName,
71
+ },
72
+ {
73
+ type: "address",
74
+ label: "NFT Address",
75
+ address: transaction.nft.contract,
76
+ },
77
+ {
78
+ type: "text",
79
+ label: "NFT ID",
80
+ value: transaction.nft.tokenId,
81
+ },
82
+ );
83
+ break;
84
+
85
+ case "erc1155":
86
+ fields.push(
87
+ {
88
+ type: "text",
89
+ label: "Type",
90
+ value: `NFT Transfer`,
91
+ },
92
+ {
93
+ type: "text",
94
+ label: "To",
95
+ value: transaction.recipient,
96
+ },
97
+ {
98
+ type: "text",
99
+ label: "Collection Name",
100
+ value: transaction.nft.collectionName,
101
+ },
102
+ {
103
+ type: "text",
104
+ label: "Quantity",
105
+ value: transaction.nft.quantity.toFixed(),
106
+ },
107
+ {
108
+ type: "address",
109
+ label: "NFT Address",
110
+ address: transaction.nft.contract,
111
+ },
112
+ {
113
+ type: "text",
114
+ label: "NFT ID",
115
+ value: transaction.nft.tokenId,
116
+ },
117
+ );
118
+ break;
54
119
  }
55
120
 
56
121
  fields.push({
package/src/errors.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { createCustomErrorClass } from "@ledgerhq/errors";
2
2
 
3
+ // Etherscan API
3
4
  export const EtherscanAPIError = createCustomErrorClass("EtherscanAPIError");
5
+
6
+ // Gas
4
7
  export const GasEstimationError = createCustomErrorClass("GasEstimationError");
5
8
  export const InsufficientFunds = createCustomErrorClass("InsufficientFunds");
6
9
 
@@ -9,3 +12,8 @@ export const NoGasTrackerFound = createCustomErrorClass("NoGasTrackerFound");
9
12
  export const GasTrackerDoesNotSupportEIP1559 = createCustomErrorClass(
10
13
  "GasTrackerDoesNotSupportEIP1559",
11
14
  );
15
+
16
+ // Nfts
17
+ export const NotOwnedNft = createCustomErrorClass("NotOwnedNft");
18
+ export const NotEnoughNftOwned = createCustomErrorClass("NotEnoughNftOwned");
19
+ export const QuantityNeedsToBePositive = createCustomErrorClass("QuantityNeedsToBePositive");
@@ -19,6 +19,7 @@ import {
19
19
  EvmTransactionLegacy,
20
20
  Transaction as EvmTransaction,
21
21
  } from "./types";
22
+ import { NotEnoughNftOwned, NotOwnedNft, QuantityNeedsToBePositive } from "./errors";
22
23
 
23
24
  type ValidatedTransactionFields =
24
25
  | "recipient"
@@ -131,6 +132,28 @@ export const validateGas = (
131
132
  return [errors, warnings];
132
133
  };
133
134
 
135
+ export const validateNft = (account: Account, tx: EvmTransaction): Array<ValidationIssues> => {
136
+ if (!tx.nft) return [{}, {}];
137
+
138
+ const errors: ValidationIssues = {};
139
+ const warnings: ValidationIssues = {};
140
+
141
+ const quantityIsPositive = tx.nft.quantity.gt(0);
142
+ const nftFromAccount = account.nfts?.find(
143
+ nft => nft.tokenId === tx.nft.tokenId && nft.contract === tx.nft.contract,
144
+ );
145
+
146
+ if (!nftFromAccount) {
147
+ errors.amount = new NotOwnedNft();
148
+ } else if (!quantityIsPositive) {
149
+ errors.amount = new QuantityNeedsToBePositive();
150
+ } else if (nftFromAccount.amount.lt(tx.nft.quantity)) {
151
+ errors.amount = new NotEnoughNftOwned();
152
+ }
153
+
154
+ return [errors, warnings];
155
+ };
156
+
134
157
  /**
135
158
  * Validate a transaction and get all possibles errors and warnings about it
136
159
  */
@@ -151,16 +174,19 @@ export const getTransactionStatus: AccountBridge<EvmTransaction>["getTransaction
151
174
  const [amountErr, amountWarn] = validateAmount(subAccount || account, tx, totalSpent);
152
175
  // Gas related errors and warnings
153
176
  const [gasErr, gasWarn] = validateGas(account, tx, gasLimit, totalFees);
177
+ const [nftErr, nftWarn] = validateNft(account, tx);
154
178
 
155
179
  const errors: ValidationIssues = {
156
180
  ...recipientErr,
157
181
  ...gasErr,
158
182
  ...amountErr,
183
+ ...nftErr,
159
184
  };
160
185
  const warnings: ValidationIssues = {
161
186
  ...recipientWarn,
162
187
  ...gasWarn,
163
188
  ...amountWarn,
189
+ ...nftWarn,
164
190
  };
165
191
 
166
192
  return {
@@ -0,0 +1,92 @@
1
+ import { ethers } from "ethers";
2
+ import { SignerContext } from "@ledgerhq/coin-framework/signer";
3
+ import { isEIP712Message } from "@ledgerhq/evm-tools/message/EIP712/index";
4
+ import { Account, AnyMessage, DeviceId, TypedEvmMessage } from "@ledgerhq/types-live";
5
+ import { EvmSignature, EvmSigner } from "./signer";
6
+
7
+ export const prepareMessageToSign = ({ message }: { message: string }): TypedEvmMessage => {
8
+ const parsedMessage = (() => {
9
+ try {
10
+ return JSON.parse(message) as Record<string, unknown>;
11
+ } catch (error) {
12
+ return message;
13
+ }
14
+ })();
15
+
16
+ if (isEIP712Message(parsedMessage)) {
17
+ // With the ethers lib, EIP712Domain type should be removed otherwise
18
+ // you'll end up with a "ambiguous primary types" error
19
+ const { EIP712Domain, ...otherTypes } = parsedMessage.types;
20
+
21
+ return {
22
+ standard: "EIP712",
23
+ message: parsedMessage,
24
+ domainHash: ethers.utils._TypedDataEncoder.hashDomain(parsedMessage.domain),
25
+ hashStruct: ethers.utils._TypedDataEncoder.hashStruct(
26
+ parsedMessage.primaryType,
27
+ otherTypes,
28
+ parsedMessage.message,
29
+ ),
30
+ };
31
+ }
32
+
33
+ return {
34
+ standard: "EIP191",
35
+ message,
36
+ };
37
+ };
38
+
39
+ export const signMessage =
40
+ (signerContext: SignerContext<EvmSigner, EvmSignature>) =>
41
+ async (
42
+ deviceId: DeviceId,
43
+ account: Account,
44
+ messageOpts: AnyMessage,
45
+ ): Promise<{
46
+ rsv: { r: string; s: string; v: string | number };
47
+ signature: string;
48
+ }> => {
49
+ if (messageOpts.standard === "EIP191") {
50
+ const { r, s, v } = await signerContext(deviceId, signer => {
51
+ return signer.signPersonalMessage(
52
+ account.freshAddressPath,
53
+ Buffer.from(messageOpts.message).toString("hex"),
54
+ );
55
+ });
56
+
57
+ const signature = ethers.utils.joinSignature({
58
+ r: `0x${r}`,
59
+ s: `0x${s}`,
60
+ v: typeof v === "string" ? parseInt(v, 16) : v,
61
+ });
62
+
63
+ return { rsv: { r, s, v }, signature };
64
+ }
65
+
66
+ if (messageOpts.standard === "EIP712") {
67
+ const { r, s, v } = await signerContext(deviceId, async signer => {
68
+ try {
69
+ return await signer.signEIP712Message(account.freshAddressPath, messageOpts.message);
70
+ } catch (e) {
71
+ if (e instanceof Error && "statusText" in e && e.statusText === "INS_NOT_SUPPORTED") {
72
+ return await signer.signEIP712HashedMessage(
73
+ account.freshAddressPath,
74
+ messageOpts.domainHash,
75
+ messageOpts.hashStruct,
76
+ );
77
+ }
78
+ throw e;
79
+ }
80
+ });
81
+
82
+ const signature = ethers.utils.joinSignature({
83
+ r: `0x${r}`,
84
+ s: `0x${s}`,
85
+ v: typeof v === "string" ? parseInt(v, 16) : v,
86
+ });
87
+
88
+ return { rsv: { r, s, v }, signature };
89
+ }
90
+
91
+ throw new Error("Unsupported message standard");
92
+ };
package/src/logic.ts CHANGED
@@ -1,11 +1,15 @@
1
1
  import { ethers } from "ethers";
2
2
  import BigNumber from "bignumber.js";
3
3
  import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
4
+ import { isNFTActive } from "@ledgerhq/coin-framework/nft/support";
4
5
  import { mergeOps } from "@ledgerhq/coin-framework/bridge/jsHelpers";
5
- import { Account, SubAccount } from "@ledgerhq/types-live";
6
+ import { Account, SubAccount, Operation } from "@ledgerhq/types-live";
7
+ import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
6
8
  import { listTokensForCryptoCurrency } from "@ledgerhq/cryptoassets/tokens";
9
+ import { decodeTokenAccountId } from "@ledgerhq/coin-framework/account/index";
7
10
  import { getOptimismAdditionalFees } from "./api/rpc/rpc.common";
8
11
  import {
12
+ EvmNftTransaction,
9
13
  Transaction as EvmTransaction,
10
14
  EvmTransactionEIP1559,
11
15
  EvmTransactionLegacy,
@@ -128,12 +132,124 @@ export const mergeSubAccounts = (
128
132
  /**
129
133
  * Method creating a hash that will help triggering or not a full synchronization on an account.
130
134
  * As of now, it's checking if a token has been added, removed of changed regarding important properties
135
+ * and if the NFTs are activated/supported on this chain
131
136
  */
132
137
  export const getSyncHash = (currency: CryptoCurrency): string => {
133
138
  const tokens = listTokensForCryptoCurrency(currency);
134
139
  const basicTokensListString = tokens
135
140
  .map(token => token.id + token.contractAddress + token.name + token.ticker + token.delisted)
136
141
  .join("");
142
+ const isNftSupported = isNFTActive(currency);
137
143
 
138
- return ethers.utils.sha256(Buffer.from(basicTokensListString));
144
+ return ethers.utils.sha256(Buffer.from(basicTokensListString + isNftSupported));
139
145
  };
146
+
147
+ /**
148
+ * Helper in charge of linking operations together based on transaction hash.
149
+ * Token operations & NFT operations are the result of a coin operation
150
+ * and if this coin operation is originated by our user we want
151
+ * to link those operations together as main & children ops.
152
+ *
153
+ * A sub operation should always be linked to a coin operation,
154
+ * even if the user isn't at the origin of the sub op.
155
+ * "NONE" coin ops can be added when necessary.
156
+ *
157
+ * ⚠️ If an NFT operation was found without a coin parent op
158
+ * just like if it was not initiated by the synced account
159
+ * and we were to find that coin op during another sync,
160
+ * the NONE operation created would not be removed,
161
+ * creating a duplicate that will cause issues.
162
+ * (Incorrect NFT balance & React key dup)
163
+ */
164
+ export const attachOperations = (
165
+ _coinOperations: Operation[],
166
+ _tokenOperations: Operation[],
167
+ _nftOperations: Operation[],
168
+ ): Operation[] => {
169
+ // Creating deep copies of each Operation[] to prevent mutating the originals
170
+ const coinOperations = _coinOperations.map(op => ({ ...op }));
171
+ const tokenOperations = _tokenOperations.map(op => ({ ...op }));
172
+ const nftOperations = _nftOperations.map(op => ({ ...op }));
173
+
174
+ type OperationWithRequiredChildren = Operation &
175
+ Required<Pick<Operation, "nftOperations" | "subOperations">>;
176
+
177
+ // Helper to create a coin operation with type NONE as a parent of an orphan child operation
178
+ const makeCoinOpForOrphanChildOp = (childOp: Operation): OperationWithRequiredChildren => {
179
+ const type = "NONE";
180
+ const { accountId } = decodeTokenAccountId(childOp.accountId);
181
+ const id = encodeOperationId(accountId, childOp.hash, type);
182
+
183
+ return {
184
+ id,
185
+ hash: childOp.hash,
186
+ type,
187
+ value: new BigNumber(0),
188
+ fee: new BigNumber(0),
189
+ senders: [],
190
+ recipients: [],
191
+ blockHeight: childOp.blockHeight,
192
+ blockHash: childOp.blockHash,
193
+ transactionSequenceNumber: childOp.transactionSequenceNumber,
194
+ subOperations: [],
195
+ nftOperations: [],
196
+ accountId: "",
197
+ date: childOp.date,
198
+ extra: {},
199
+ };
200
+ };
201
+
202
+ // Create a Map of hash => operation
203
+ const coinOperationsByHash: Record<string, OperationWithRequiredChildren[]> = {};
204
+ coinOperations.forEach(op => {
205
+ if (!coinOperationsByHash[op.hash]) {
206
+ coinOperationsByHash[op.hash] = [];
207
+ }
208
+
209
+ // Adding arrays just in case but this is defined
210
+ // by the adapters so it should never be needed
211
+ op.subOperations = [];
212
+ op.nftOperations = [];
213
+ coinOperationsByHash[op.hash].push(op as OperationWithRequiredChildren);
214
+ });
215
+
216
+ // Looping through token operations to potentially copy them as a child operation of a coin operation
217
+ for (const tokenOperation of tokenOperations) {
218
+ let mainOperations = coinOperationsByHash[tokenOperation.hash];
219
+ if (!mainOperations?.length) {
220
+ const noneOperation = makeCoinOpForOrphanChildOp(tokenOperation);
221
+ mainOperations = [noneOperation];
222
+ coinOperations.push(noneOperation);
223
+ }
224
+
225
+ // Ugly loop in loop but in theory, this can only be a 2 elements array maximum in the case of a self send
226
+ for (const mainOperation of mainOperations) {
227
+ mainOperation.subOperations.push(tokenOperation);
228
+ }
229
+ }
230
+
231
+ // Looping through nft operations to potentially copy them as a child operation of a coin operation
232
+ for (const nftOperation of nftOperations) {
233
+ let mainOperations = coinOperationsByHash[nftOperation.hash];
234
+ if (!mainOperations?.length) {
235
+ const noneOperation = makeCoinOpForOrphanChildOp(nftOperation);
236
+ mainOperations = [noneOperation];
237
+ coinOperations.push(noneOperation);
238
+ }
239
+
240
+ // Ugly loop in loop but in theory, this can only be a 2 elements array maximum in the case of a self send
241
+ for (const mainOperation of mainOperations) {
242
+ mainOperation.nftOperations.push(nftOperation);
243
+ }
244
+ }
245
+
246
+ return coinOperations;
247
+ };
248
+
249
+ /**
250
+ * Type guard for NFT transactions
251
+ */
252
+ export const isNftTransaction = (
253
+ transaction: EvmTransaction,
254
+ ): transaction is EvmTransaction & EvmNftTransaction =>
255
+ ["erc1155", "erc721"].includes(transaction.mode);
@@ -0,0 +1,71 @@
1
+ import {
2
+ CurrencyBridge,
3
+ NFTCollectionMetadataResponse,
4
+ NFTMetadataResponse,
5
+ } from "@ledgerhq/types-live";
6
+ import { isNFTActive, metadataCallBatcher } from "@ledgerhq/coin-framework/nft/support";
7
+ import { getCryptoCurrencyById } from "@ledgerhq/coin-framework/currencies/index";
8
+ import NftApi from "./api/nft";
9
+
10
+ type NftResolvers = NonNullable<CurrencyBridge["nftResolvers"]>;
11
+
12
+ export const nftMetadata: NftResolvers["nftMetadata"] = async ({
13
+ contract,
14
+ tokenId,
15
+ currencyId,
16
+ metadata,
17
+ }): Promise<NFTMetadataResponse> => {
18
+ // This is for test/mock purposes
19
+ if (typeof metadata !== "undefined") {
20
+ return {
21
+ status: 200,
22
+ result: {
23
+ contract,
24
+ tokenId,
25
+ ...metadata,
26
+ },
27
+ } as NFTMetadataResponse;
28
+ }
29
+
30
+ const currency = getCryptoCurrencyById(currencyId);
31
+ if (!isNFTActive(currency)) {
32
+ throw new Error("Ethereum Bridge NFT Resolver: Unsupported currency");
33
+ }
34
+
35
+ const response = await metadataCallBatcher(currency, NftApi).loadNft({
36
+ contract,
37
+ tokenId,
38
+ });
39
+
40
+ return response;
41
+ };
42
+
43
+ export const collectionMetadata: NftResolvers["collectionMetadata"] = async ({
44
+ contract,
45
+ currencyId,
46
+ metadata,
47
+ }): Promise<NFTCollectionMetadataResponse> => {
48
+ // This is for test/mock purposes
49
+ if (typeof metadata !== "undefined") {
50
+ return {
51
+ status: 200,
52
+ result: {
53
+ contract,
54
+ ...metadata,
55
+ },
56
+ };
57
+ }
58
+
59
+ const currency = getCryptoCurrencyById(currencyId);
60
+ if (!isNFTActive(currency)) {
61
+ throw new Error("Ethereum Bridge NFT Resolver: Unsupported currency");
62
+ }
63
+
64
+ const response = await metadataCallBatcher(currency, NftApi).loadCollection({
65
+ contract,
66
+ });
67
+
68
+ return response;
69
+ };
70
+
71
+ export default { nftMetadata, collectionMetadata };
package/src/preload.ts CHANGED
@@ -23,8 +23,9 @@ export const fetchERC20Tokens: (
23
23
  });
24
24
  if (dynamicTokens) return dynamicTokens;
25
25
 
26
- // @ts-expect-error FIXME: fix typings
27
- const tokens = tokensByChainId[ethereumLikeInfo?.chainId || ""];
26
+ const tokens = tokensByChainId[
27
+ ethereumLikeInfo?.chainId as keyof typeof tokensByChainId
28
+ ] as ERC20Token[];
28
29
  if (tokens) return tokens;
29
30
 
30
31
  log("warning", `EVM Family: No tokens found in CAL for currency: ${currency.id}`, currency);
@@ -33,7 +34,12 @@ export const fetchERC20Tokens: (
33
34
 
34
35
  export async function preload(currency: CryptoCurrency): Promise<ERC20Token[]> {
35
36
  const erc20 = await fetchERC20Tokens(currency);
36
- addTokens(erc20.map(convertERC20));
37
+ // This weird thing is here to help the "clone" currencies like
38
+ // ethereum_as_evm_test_only & polygon_as_evm_test_only
39
+ // to get tokens despite the different currency_id
40
+ // registered in the CAL for those chain ids
41
+ // We should remove this after the merge
42
+ addTokens(erc20.map(([, ...tokenRest]) => convertERC20([currency.id, ...tokenRest])));
37
43
  return erc20;
38
44
  }
39
45
 
@@ -1,11 +1,13 @@
1
- import { findSubAccountById } from "@ledgerhq/coin-framework/account/index";
2
- import { Account, TokenAccount } from "@ledgerhq/types-live";
1
+ import { isEqual } from "lodash";
3
2
  import BigNumber from "bignumber.js";
4
- import { getFeesEstimation, getGasEstimation, getTransactionCount } from "./api/rpc";
5
- import { validateRecipient } from "./getTransactionStatus";
6
- import { getAdditionalLayer2Fees, getEstimatedFees } from "./logic";
3
+ import { Account, TokenAccount } from "@ledgerhq/types-live";
4
+ import { findSubAccountById } from "@ledgerhq/coin-framework/account/index";
5
+ import { EvmNftTransaction, Transaction as EvmTransaction } from "./types";
7
6
  import { getTransactionData, getTypedTransaction } from "./transaction";
8
- import { Transaction as EvmTransaction } from "./types";
7
+ import { validateRecipient } from "./getTransactionStatus";
8
+ import { getNftCollectionMetadata } from "./api/nft";
9
+ import { getFeesEstimation, getGasEstimation, getTransactionCount } from "./api/rpc";
10
+ import { getAdditionalLayer2Fees, getEstimatedFees, isNftTransaction } from "./logic";
9
11
 
10
12
  /**
11
13
  * Prepare basic coin transactions or smart contract interactions (other than live ERC20 transfers)
@@ -76,8 +78,9 @@ export const prepareTokenTransaction = async (
76
78
  ): Promise<EvmTransaction> => {
77
79
  const [recipientErrors] = validateRecipient(account, typedTransaction);
78
80
  const amount = typedTransaction.useAllAmount ? tokenAccount.balance : typedTransaction.amount;
81
+
79
82
  const data = !Object.keys(recipientErrors).length
80
- ? getTransactionData({ ...typedTransaction, amount })
83
+ ? getTransactionData(account, { ...typedTransaction, amount })
81
84
  : undefined;
82
85
  // As we're interacting with a smart contract,
83
86
  // it's going to be the real recipient for the tx
@@ -99,6 +102,7 @@ export const prepareTokenTransaction = async (
99
102
 
100
103
  // Recipient isn't changed here as it would change on the UI end as well
101
104
  // The change will be handled by the `prepareForSignOperation` method
105
+ // right before the device signature by the signOperation step
102
106
  return {
103
107
  ...typedTransaction,
104
108
  amount,
@@ -108,6 +112,61 @@ export const prepareTokenTransaction = async (
108
112
  };
109
113
  };
110
114
 
115
+ /**
116
+ * Prepare ERC721/ERC1155 transactions.
117
+ * Handling addition of NFT safeTransferFrom data and gas limit
118
+ */
119
+ export const prepareNftTransaction = async (
120
+ account: Account,
121
+ typedTransaction: EvmNftTransaction & EvmTransaction,
122
+ ): Promise<EvmTransaction> => {
123
+ const { currency } = account;
124
+ const [recipientErrors] = validateRecipient(account, typedTransaction);
125
+
126
+ const data = !Object.keys(recipientErrors).length
127
+ ? getTransactionData(account, typedTransaction)
128
+ : undefined;
129
+ // As we're interacting with a smart contract,
130
+ // it's going to be the real recipient for the tx
131
+ const gasLimit = data
132
+ ? await getGasEstimation(account, {
133
+ ...typedTransaction,
134
+ amount: new BigNumber(0), // amount set to 0 as we're interacting with a smart contract
135
+ recipient: typedTransaction.nft.contract, // recipient is then the nft smart contract
136
+ data, // buffer containing the calldata bytecode
137
+ }).catch(() => new BigNumber(0)) // this catch returning 0 should be handled by the `getTransactionStatus` method
138
+ : new BigNumber(0);
139
+ const additionalFees = await getAdditionalLayer2Fees(account.currency, {
140
+ ...typedTransaction,
141
+ amount: new BigNumber(0), // amount set to 0 as we're interacting with a smart contract
142
+ recipient: typedTransaction.nft.contract, // recipient is then the token smart contract
143
+ data, // buffer containing the calldata bytecode
144
+ gasLimit,
145
+ });
146
+
147
+ // Providing the collection name to the transaction for the
148
+ // deviceTransactionConfig step (so purely UI)
149
+ const [collectionMetadata] = await getNftCollectionMetadata(
150
+ [{ contract: typedTransaction.nft.contract }],
151
+ currency?.ethereumLikeInfo?.chainId || 0,
152
+ );
153
+ const nft = {
154
+ ...typedTransaction.nft,
155
+ collectionName: collectionMetadata.result?.tokenName || "",
156
+ };
157
+
158
+ // Recipient isn't changed here as it would change on the UI end as well
159
+ // The change will be handled by the `prepareForSignOperation` method
160
+ // right before the device signature by the signOperation step
161
+ return {
162
+ ...typedTransaction,
163
+ data,
164
+ gasLimit,
165
+ additionalFees,
166
+ nft,
167
+ };
168
+ };
169
+
111
170
  /**
112
171
  * Method called to update a transaction into a state that would make it valid
113
172
  * (E.g. Adding fees, add smart contract data, etc...)
@@ -137,12 +196,20 @@ export const prepareTransaction = async (
137
196
  })();
138
197
 
139
198
  const subAccount = findSubAccountById(account, transaction.subAccountId || "");
140
- const isTokenTransaction = subAccount?.type === "TokenAccount";
141
199
  const typedTransaction = getTypedTransaction(transaction, feeData);
142
200
 
143
- return isTokenTransaction
144
- ? await prepareTokenTransaction(account, subAccount, typedTransaction)
145
- : await prepareCoinTransaction(account, typedTransaction);
201
+ const newTransaction = await (() => {
202
+ if (isNftTransaction(typedTransaction)) {
203
+ return prepareNftTransaction(account, typedTransaction);
204
+ }
205
+ const isTokenTransaction = subAccount?.type === "TokenAccount";
206
+ return isTokenTransaction
207
+ ? prepareTokenTransaction(account, subAccount, typedTransaction)
208
+ : prepareCoinTransaction(account, typedTransaction);
209
+ })();
210
+
211
+ // maintaining reference if the transaction hasn't change
212
+ return isEqual(transaction, newTransaction) ? transaction : newTransaction;
146
213
  };
147
214
 
148
215
  /**
@@ -157,19 +224,30 @@ export const prepareForSignOperation = async (
157
224
  ): Promise<EvmTransaction> => {
158
225
  const nonce = await getTransactionCount(account.currency, account.freshAddress);
159
226
 
160
- const subAccount = findSubAccountById(account, transaction.subAccountId || "");
227
+ if (isNftTransaction(transaction)) {
228
+ return {
229
+ ...transaction,
230
+ amount: new BigNumber(0), // amount set to 0 as we're interacting with a smart contract
231
+ recipient: transaction.nft.contract, // recipient is then the NFT smart contract
232
+ // data as already been added by the `prepareTokenTransaction` method
233
+ nonce,
234
+ };
235
+ }
236
+
237
+ const subAccount = findSubAccountById(account, transaction.subAccountId ?? "");
161
238
  const isTokenTransaction = subAccount?.type === "TokenAccount";
239
+ if (isTokenTransaction) {
240
+ return {
241
+ ...transaction,
242
+ amount: new BigNumber(0), // amount set to 0 as we're interacting with a smart contract
243
+ recipient: subAccount.token.contractAddress, // recipient is then the token smart contract
244
+ // data as already been added by the `prepareTokenTransaction` method
245
+ nonce,
246
+ };
247
+ }
162
248
 
163
- return isTokenTransaction
164
- ? {
165
- ...transaction,
166
- amount: new BigNumber(0), // amount set to 0 as we're interacting with a smart contract
167
- recipient: subAccount.token.contractAddress, // recipient is then the token smart contract
168
- // data as already been added by the `prepareTokenTransaction` method
169
- nonce,
170
- }
171
- : {
172
- ...transaction,
173
- nonce,
174
- };
249
+ return {
250
+ ...transaction,
251
+ nonce,
252
+ };
175
253
  };