@ledgerhq/coin-evm 0.2.1 → 0.2.2-nightly.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 (462) hide show
  1. package/.eslintrc.js +11 -46
  2. package/.turbo/turbo-build.log +1 -1
  3. package/CHANGELOG.md +29 -1
  4. package/lib/__tests__/adapters.unit.test.d.ts +2 -0
  5. package/lib/__tests__/adapters.unit.test.d.ts.map +1 -0
  6. package/lib/__tests__/adapters.unit.test.js +455 -0
  7. package/lib/__tests__/adapters.unit.test.js.map +1 -0
  8. package/lib/__tests__/broadcast.unit.test.d.ts +2 -0
  9. package/lib/__tests__/broadcast.unit.test.d.ts.map +1 -0
  10. package/lib/__tests__/broadcast.unit.test.js +181 -0
  11. package/lib/__tests__/broadcast.unit.test.js.map +1 -0
  12. package/lib/__tests__/buildOptimisticOperation.unit.test.d.ts +2 -0
  13. package/lib/__tests__/buildOptimisticOperation.unit.test.d.ts.map +1 -0
  14. package/lib/__tests__/buildOptimisticOperation.unit.test.js +166 -0
  15. package/lib/__tests__/buildOptimisticOperation.unit.test.js.map +1 -0
  16. package/lib/__tests__/createTransaction.unit.test.d.ts +2 -0
  17. package/lib/__tests__/createTransaction.unit.test.d.ts.map +1 -0
  18. package/lib/__tests__/createTransaction.unit.test.js +50 -0
  19. package/lib/__tests__/createTransaction.unit.test.js.map +1 -0
  20. package/lib/__tests__/deviceTransactionConfig.unit.test.d.ts +2 -0
  21. package/lib/__tests__/deviceTransactionConfig.unit.test.d.ts.map +1 -0
  22. package/lib/__tests__/deviceTransactionConfig.unit.test.js +231 -0
  23. package/lib/__tests__/deviceTransactionConfig.unit.test.js.map +1 -0
  24. package/lib/__tests__/estimateMaxSpendable.unit.test.d.ts +2 -0
  25. package/lib/__tests__/estimateMaxSpendable.unit.test.d.ts.map +1 -0
  26. package/lib/__tests__/estimateMaxSpendable.unit.test.js +145 -0
  27. package/lib/__tests__/estimateMaxSpendable.unit.test.js.map +1 -0
  28. package/lib/__tests__/gasTracker/index.unit.test.d.ts +2 -0
  29. package/lib/__tests__/gasTracker/index.unit.test.d.ts.map +1 -0
  30. package/lib/__tests__/gasTracker/index.unit.test.js +35 -0
  31. package/lib/__tests__/gasTracker/index.unit.test.js.map +1 -0
  32. package/lib/__tests__/gasTracker/ledger.unit.test.d.ts +2 -0
  33. package/lib/__tests__/gasTracker/ledger.unit.test.d.ts.map +1 -0
  34. package/lib/__tests__/gasTracker/ledger.unit.test.js +110 -0
  35. package/lib/__tests__/gasTracker/ledger.unit.test.js.map +1 -0
  36. package/lib/__tests__/getTransactionStatus.unit.test.d.ts +2 -0
  37. package/lib/__tests__/getTransactionStatus.unit.test.d.ts.map +1 -0
  38. package/lib/__tests__/getTransactionStatus.unit.test.js +216 -0
  39. package/lib/__tests__/getTransactionStatus.unit.test.js.map +1 -0
  40. package/lib/__tests__/hw-getAddress.unit.test.d.ts +2 -0
  41. package/lib/__tests__/hw-getAddress.unit.test.d.ts.map +1 -0
  42. package/lib/__tests__/hw-getAddress.unit.test.js +47 -0
  43. package/lib/__tests__/hw-getAddress.unit.test.js.map +1 -0
  44. package/lib/__tests__/logic.unit.test.d.ts +2 -0
  45. package/lib/__tests__/logic.unit.test.d.ts.map +1 -0
  46. package/lib/__tests__/logic.unit.test.js +296 -0
  47. package/lib/__tests__/logic.unit.test.js.map +1 -0
  48. package/lib/__tests__/preload.unit.test.d.ts +2 -0
  49. package/lib/__tests__/preload.unit.test.d.ts.map +1 -0
  50. package/lib/__tests__/preload.unit.test.js +149 -0
  51. package/lib/__tests__/preload.unit.test.js.map +1 -0
  52. package/lib/__tests__/prepareTransaction.unit.test.d.ts +2 -0
  53. package/lib/__tests__/prepareTransaction.unit.test.d.ts.map +1 -0
  54. package/lib/__tests__/prepareTransaction.unit.test.js +248 -0
  55. package/lib/__tests__/prepareTransaction.unit.test.js.map +1 -0
  56. package/lib/__tests__/rpc.unit.test.d.ts +2 -0
  57. package/lib/__tests__/rpc.unit.test.d.ts.map +1 -0
  58. package/lib/__tests__/rpc.unit.test.js +444 -0
  59. package/lib/__tests__/rpc.unit.test.js.map +1 -0
  60. package/lib/__tests__/signOperation.unit.test.d.ts +2 -0
  61. package/lib/__tests__/signOperation.unit.test.d.ts.map +1 -0
  62. package/lib/__tests__/signOperation.unit.test.js +160 -0
  63. package/lib/__tests__/signOperation.unit.test.js.map +1 -0
  64. package/lib/__tests__/synchronization.unit.test.d.ts +2 -0
  65. package/lib/__tests__/synchronization.unit.test.d.ts.map +1 -0
  66. package/lib/__tests__/synchronization.unit.test.js +499 -0
  67. package/lib/__tests__/synchronization.unit.test.js.map +1 -0
  68. package/lib/__tests__/transaction.unit.test.d.ts +2 -0
  69. package/lib/__tests__/transaction.unit.test.d.ts.map +1 -0
  70. package/lib/__tests__/transaction.unit.test.js +201 -0
  71. package/lib/__tests__/transaction.unit.test.js.map +1 -0
  72. package/lib/abis/erc20.abi.json +222 -0
  73. package/lib/abis/optimismGasPriceOracle.abi.json +252 -0
  74. package/lib/adapters.d.ts +21 -0
  75. package/lib/adapters.d.ts.map +1 -0
  76. package/lib/adapters.js +118 -0
  77. package/lib/adapters.js.map +1 -0
  78. package/lib/api/explorer/etherscan.d.ts +24 -0
  79. package/lib/api/explorer/etherscan.d.ts.map +1 -0
  80. package/lib/api/explorer/etherscan.js +90 -0
  81. package/lib/api/explorer/etherscan.js.map +1 -0
  82. package/lib/api/explorer/index.d.ts +26 -0
  83. package/lib/api/explorer/index.d.ts.map +1 -0
  84. package/lib/api/explorer/index.js +23 -0
  85. package/lib/api/explorer/index.js.map +1 -0
  86. package/lib/api/gasTracker/index.d.ts +13 -0
  87. package/lib/api/gasTracker/index.d.ts.map +1 -0
  88. package/lib/api/gasTracker/index.js +21 -0
  89. package/lib/api/gasTracker/index.js.map +1 -0
  90. package/lib/api/gasTracker/ledger.d.ts +9 -0
  91. package/lib/api/gasTracker/ledger.d.ts.map +1 -0
  92. package/lib/api/gasTracker/ledger.js +90 -0
  93. package/lib/api/gasTracker/ledger.js.map +1 -0
  94. package/lib/api/rpc/index.d.ts +3 -0
  95. package/lib/api/rpc/index.d.ts.map +1 -0
  96. package/lib/api/rpc/index.js +32 -0
  97. package/lib/api/rpc/index.js.map +1 -0
  98. package/lib/api/rpc/rpc.common.d.ts +93 -0
  99. package/lib/api/rpc/rpc.common.d.ts.map +1 -0
  100. package/lib/api/rpc/rpc.common.js +284 -0
  101. package/lib/api/rpc/rpc.common.js.map +1 -0
  102. package/lib/api/rpc/rpc.native.d.ts +6 -0
  103. package/lib/api/rpc/rpc.native.d.ts.map +1 -0
  104. package/lib/api/rpc/rpc.native.js +35 -0
  105. package/lib/api/rpc/rpc.native.js.map +1 -0
  106. package/lib/bridge/js.d.ts +11 -0
  107. package/lib/bridge/js.d.ts.map +1 -0
  108. package/lib/bridge/js.js +58 -0
  109. package/lib/bridge/js.js.map +1 -0
  110. package/lib/bridge.integration.test.d.ts +14 -0
  111. package/lib/bridge.integration.test.d.ts.map +1 -0
  112. package/lib/bridge.integration.test.js +85 -0
  113. package/lib/bridge.integration.test.js.map +1 -0
  114. package/lib/broadcast.d.ts +8 -0
  115. package/lib/broadcast.d.ts.map +1 -0
  116. package/lib/broadcast.js +25 -0
  117. package/lib/broadcast.js.map +1 -0
  118. package/lib/buildOptimisticOperation.d.ts +16 -0
  119. package/lib/buildOptimisticOperation.d.ts.map +1 -0
  120. package/lib/buildOptimisticOperation.js +80 -0
  121. package/lib/buildOptimisticOperation.js.map +1 -0
  122. package/lib/cli-transaction.d.ts +2 -0
  123. package/lib/cli-transaction.d.ts.map +1 -0
  124. package/lib/cli-transaction.js +9 -0
  125. package/lib/cli-transaction.js.map +1 -0
  126. package/lib/createTransaction.d.ts +9 -0
  127. package/lib/createTransaction.d.ts.map +1 -0
  128. package/lib/createTransaction.js +32 -0
  129. package/lib/createTransaction.js.map +1 -0
  130. package/lib/datasets/ethereum.scanAccounts.1.d.ts +7 -0
  131. package/lib/datasets/ethereum.scanAccounts.1.d.ts.map +1 -0
  132. package/lib/datasets/ethereum.scanAccounts.1.js +51 -0
  133. package/lib/datasets/ethereum.scanAccounts.1.js.map +1 -0
  134. package/lib/datasets/ethereum1.d.ts +3 -0
  135. package/lib/datasets/ethereum1.d.ts.map +1 -0
  136. package/lib/datasets/ethereum1.js +22 -0
  137. package/lib/datasets/ethereum1.js.map +1 -0
  138. package/lib/datasets/ethereum2.d.ts +3 -0
  139. package/lib/datasets/ethereum2.d.ts.map +1 -0
  140. package/lib/datasets/ethereum2.js +22 -0
  141. package/lib/datasets/ethereum2.js.map +1 -0
  142. package/lib/datasets/ethereum_classic.d.ts +5 -0
  143. package/lib/datasets/ethereum_classic.d.ts.map +1 -0
  144. package/lib/datasets/ethereum_classic.js +69 -0
  145. package/lib/datasets/ethereum_classic.js.map +1 -0
  146. package/lib/deviceTransactionConfig.d.ts +15 -0
  147. package/lib/deviceTransactionConfig.d.ts.map +1 -0
  148. package/lib/deviceTransactionConfig.js +44 -0
  149. package/lib/deviceTransactionConfig.js.map +1 -0
  150. package/lib/errors.d.ts +16 -0
  151. package/lib/errors.d.ts.map +1 -0
  152. package/lib/errors.js +11 -0
  153. package/lib/errors.js.map +1 -0
  154. package/lib/estimateMaxSpendable.d.ts +4 -0
  155. package/lib/estimateMaxSpendable.d.ts.map +1 -0
  156. package/lib/estimateMaxSpendable.js +23 -0
  157. package/lib/estimateMaxSpendable.js.map +1 -0
  158. package/lib/getTransactionStatus.d.ts +23 -0
  159. package/lib/getTransactionStatus.d.ts.map +1 -0
  160. package/lib/getTransactionStatus.js +132 -0
  161. package/lib/getTransactionStatus.js.map +1 -0
  162. package/lib/hw-getAddress.d.ts +6 -0
  163. package/lib/hw-getAddress.d.ts.map +1 -0
  164. package/lib/hw-getAddress.js +28 -0
  165. package/lib/hw-getAddress.js.map +1 -0
  166. package/lib/logic.d.ts +31 -0
  167. package/lib/logic.d.ts.map +1 -0
  168. package/lib/logic.js +131 -0
  169. package/lib/logic.js.map +1 -0
  170. package/lib/preload.d.ts +6 -0
  171. package/lib/preload.d.ts.map +1 -0
  172. package/lib/preload.js +58 -0
  173. package/lib/preload.js.map +1 -0
  174. package/lib/prepareTransaction.d.ts +26 -0
  175. package/lib/prepareTransaction.d.ts.map +1 -0
  176. package/lib/prepareTransaction.js +128 -0
  177. package/lib/prepareTransaction.js.map +1 -0
  178. package/lib/signOperation.d.ts +18 -0
  179. package/lib/signOperation.d.ts.map +1 -0
  180. package/lib/signOperation.js +88 -0
  181. package/lib/signOperation.js.map +1 -0
  182. package/lib/signer.d.ts +27 -0
  183. package/lib/signer.d.ts.map +1 -0
  184. package/lib/signer.js +3 -0
  185. package/lib/signer.js.map +1 -0
  186. package/lib/specs.d.ts +3 -0
  187. package/lib/specs.d.ts.map +1 -0
  188. package/lib/specs.js +238 -0
  189. package/lib/specs.js.map +1 -0
  190. package/lib/speculos-deviceActions.d.ts +8 -0
  191. package/lib/speculos-deviceActions.d.ts.map +1 -0
  192. package/lib/speculos-deviceActions.js +66 -0
  193. package/lib/speculos-deviceActions.js.map +1 -0
  194. package/lib/synchronization.d.ts +27 -0
  195. package/lib/synchronization.d.ts.map +1 -0
  196. package/lib/synchronization.js +220 -0
  197. package/lib/synchronization.js.map +1 -0
  198. package/lib/testUtils.d.ts +6 -0
  199. package/lib/testUtils.d.ts.map +1 -0
  200. package/lib/testUtils.js +111 -0
  201. package/lib/testUtils.js.map +1 -0
  202. package/lib/transaction.d.ts +43 -0
  203. package/lib/transaction.d.ts.map +1 -0
  204. package/lib/transaction.js +124 -0
  205. package/lib/transaction.js.map +1 -0
  206. package/lib/types.d.ts +111 -0
  207. package/lib/types.d.ts.map +1 -0
  208. package/lib/types.js +3 -0
  209. package/lib/types.js.map +1 -0
  210. package/lib-es/__tests__/adapters.unit.test.d.ts +2 -0
  211. package/lib-es/__tests__/adapters.unit.test.d.ts.map +1 -0
  212. package/lib-es/__tests__/adapters.unit.test.js +450 -0
  213. package/lib-es/__tests__/adapters.unit.test.js.map +1 -0
  214. package/lib-es/__tests__/broadcast.unit.test.d.ts +2 -0
  215. package/lib-es/__tests__/broadcast.unit.test.d.ts.map +1 -0
  216. package/lib-es/__tests__/broadcast.unit.test.js +153 -0
  217. package/lib-es/__tests__/broadcast.unit.test.js.map +1 -0
  218. package/lib-es/__tests__/buildOptimisticOperation.unit.test.d.ts +2 -0
  219. package/lib-es/__tests__/buildOptimisticOperation.unit.test.d.ts.map +1 -0
  220. package/lib-es/__tests__/buildOptimisticOperation.unit.test.js +161 -0
  221. package/lib-es/__tests__/buildOptimisticOperation.unit.test.js.map +1 -0
  222. package/lib-es/__tests__/createTransaction.unit.test.d.ts +2 -0
  223. package/lib-es/__tests__/createTransaction.unit.test.d.ts.map +1 -0
  224. package/lib-es/__tests__/createTransaction.unit.test.js +45 -0
  225. package/lib-es/__tests__/createTransaction.unit.test.js.map +1 -0
  226. package/lib-es/__tests__/deviceTransactionConfig.unit.test.d.ts +2 -0
  227. package/lib-es/__tests__/deviceTransactionConfig.unit.test.d.ts.map +1 -0
  228. package/lib-es/__tests__/deviceTransactionConfig.unit.test.js +226 -0
  229. package/lib-es/__tests__/deviceTransactionConfig.unit.test.js.map +1 -0
  230. package/lib-es/__tests__/estimateMaxSpendable.unit.test.d.ts +2 -0
  231. package/lib-es/__tests__/estimateMaxSpendable.unit.test.d.ts.map +1 -0
  232. package/lib-es/__tests__/estimateMaxSpendable.unit.test.js +117 -0
  233. package/lib-es/__tests__/estimateMaxSpendable.unit.test.js.map +1 -0
  234. package/lib-es/__tests__/gasTracker/index.unit.test.d.ts +2 -0
  235. package/lib-es/__tests__/gasTracker/index.unit.test.d.ts.map +1 -0
  236. package/lib-es/__tests__/gasTracker/index.unit.test.js +33 -0
  237. package/lib-es/__tests__/gasTracker/index.unit.test.js.map +1 -0
  238. package/lib-es/__tests__/gasTracker/ledger.unit.test.d.ts +2 -0
  239. package/lib-es/__tests__/gasTracker/ledger.unit.test.d.ts.map +1 -0
  240. package/lib-es/__tests__/gasTracker/ledger.unit.test.js +105 -0
  241. package/lib-es/__tests__/gasTracker/ledger.unit.test.js.map +1 -0
  242. package/lib-es/__tests__/getTransactionStatus.unit.test.d.ts +2 -0
  243. package/lib-es/__tests__/getTransactionStatus.unit.test.d.ts.map +1 -0
  244. package/lib-es/__tests__/getTransactionStatus.unit.test.js +211 -0
  245. package/lib-es/__tests__/getTransactionStatus.unit.test.js.map +1 -0
  246. package/lib-es/__tests__/hw-getAddress.unit.test.d.ts +2 -0
  247. package/lib-es/__tests__/hw-getAddress.unit.test.d.ts.map +1 -0
  248. package/lib-es/__tests__/hw-getAddress.unit.test.js +42 -0
  249. package/lib-es/__tests__/hw-getAddress.unit.test.js.map +1 -0
  250. package/lib-es/__tests__/logic.unit.test.d.ts +2 -0
  251. package/lib-es/__tests__/logic.unit.test.d.ts.map +1 -0
  252. package/lib-es/__tests__/logic.unit.test.js +268 -0
  253. package/lib-es/__tests__/logic.unit.test.js.map +1 -0
  254. package/lib-es/__tests__/preload.unit.test.d.ts +2 -0
  255. package/lib-es/__tests__/preload.unit.test.d.ts.map +1 -0
  256. package/lib-es/__tests__/preload.unit.test.js +121 -0
  257. package/lib-es/__tests__/preload.unit.test.js.map +1 -0
  258. package/lib-es/__tests__/prepareTransaction.unit.test.d.ts +2 -0
  259. package/lib-es/__tests__/prepareTransaction.unit.test.d.ts.map +1 -0
  260. package/lib-es/__tests__/prepareTransaction.unit.test.js +220 -0
  261. package/lib-es/__tests__/prepareTransaction.unit.test.js.map +1 -0
  262. package/lib-es/__tests__/rpc.unit.test.d.ts +2 -0
  263. package/lib-es/__tests__/rpc.unit.test.d.ts.map +1 -0
  264. package/lib-es/__tests__/rpc.unit.test.js +416 -0
  265. package/lib-es/__tests__/rpc.unit.test.js.map +1 -0
  266. package/lib-es/__tests__/signOperation.unit.test.d.ts +2 -0
  267. package/lib-es/__tests__/signOperation.unit.test.d.ts.map +1 -0
  268. package/lib-es/__tests__/signOperation.unit.test.js +132 -0
  269. package/lib-es/__tests__/signOperation.unit.test.js.map +1 -0
  270. package/lib-es/__tests__/synchronization.unit.test.d.ts +2 -0
  271. package/lib-es/__tests__/synchronization.unit.test.d.ts.map +1 -0
  272. package/lib-es/__tests__/synchronization.unit.test.js +471 -0
  273. package/lib-es/__tests__/synchronization.unit.test.js.map +1 -0
  274. package/lib-es/__tests__/transaction.unit.test.d.ts +2 -0
  275. package/lib-es/__tests__/transaction.unit.test.d.ts.map +1 -0
  276. package/lib-es/__tests__/transaction.unit.test.js +173 -0
  277. package/lib-es/__tests__/transaction.unit.test.js.map +1 -0
  278. package/lib-es/abis/erc20.abi.json +222 -0
  279. package/lib-es/abis/optimismGasPriceOracle.abi.json +252 -0
  280. package/lib-es/adapters.d.ts +21 -0
  281. package/lib-es/adapters.d.ts.map +1 -0
  282. package/lib-es/adapters.js +109 -0
  283. package/lib-es/adapters.js.map +1 -0
  284. package/lib-es/api/explorer/etherscan.d.ts +24 -0
  285. package/lib-es/api/explorer/etherscan.d.ts.map +1 -0
  286. package/lib-es/api/explorer/etherscan.js +84 -0
  287. package/lib-es/api/explorer/etherscan.js.map +1 -0
  288. package/lib-es/api/explorer/index.d.ts +26 -0
  289. package/lib-es/api/explorer/index.d.ts.map +1 -0
  290. package/lib-es/api/explorer/index.js +16 -0
  291. package/lib-es/api/explorer/index.js.map +1 -0
  292. package/lib-es/api/gasTracker/index.d.ts +13 -0
  293. package/lib-es/api/gasTracker/index.d.ts.map +1 -0
  294. package/lib-es/api/gasTracker/index.js +17 -0
  295. package/lib-es/api/gasTracker/index.js.map +1 -0
  296. package/lib-es/api/gasTracker/ledger.d.ts +9 -0
  297. package/lib-es/api/gasTracker/ledger.d.ts.map +1 -0
  298. package/lib-es/api/gasTracker/ledger.js +83 -0
  299. package/lib-es/api/gasTracker/ledger.js.map +1 -0
  300. package/lib-es/api/rpc/index.d.ts +3 -0
  301. package/lib-es/api/rpc/index.d.ts.map +1 -0
  302. package/lib-es/api/rpc/index.js +4 -0
  303. package/lib-es/api/rpc/index.js.map +1 -0
  304. package/lib-es/api/rpc/rpc.common.d.ts +93 -0
  305. package/lib-es/api/rpc/rpc.common.d.ts.map +1 -0
  306. package/lib-es/api/rpc/rpc.common.js +267 -0
  307. package/lib-es/api/rpc/rpc.common.js.map +1 -0
  308. package/lib-es/api/rpc/rpc.native.d.ts +6 -0
  309. package/lib-es/api/rpc/rpc.native.d.ts.map +1 -0
  310. package/lib-es/api/rpc/rpc.native.js +7 -0
  311. package/lib-es/api/rpc/rpc.native.js.map +1 -0
  312. package/lib-es/bridge/js.d.ts +11 -0
  313. package/lib-es/bridge/js.d.ts.map +1 -0
  314. package/lib-es/bridge/js.js +49 -0
  315. package/lib-es/bridge/js.js.map +1 -0
  316. package/lib-es/bridge.integration.test.d.ts +14 -0
  317. package/lib-es/bridge.integration.test.d.ts.map +1 -0
  318. package/lib-es/bridge.integration.test.js +79 -0
  319. package/lib-es/bridge.integration.test.js.map +1 -0
  320. package/lib-es/broadcast.d.ts +8 -0
  321. package/lib-es/broadcast.d.ts.map +1 -0
  322. package/lib-es/broadcast.js +21 -0
  323. package/lib-es/broadcast.js.map +1 -0
  324. package/lib-es/buildOptimisticOperation.d.ts +16 -0
  325. package/lib-es/buildOptimisticOperation.d.ts.map +1 -0
  326. package/lib-es/buildOptimisticOperation.js +71 -0
  327. package/lib-es/buildOptimisticOperation.js.map +1 -0
  328. package/lib-es/cli-transaction.d.ts +2 -0
  329. package/lib-es/cli-transaction.d.ts.map +1 -0
  330. package/lib-es/cli-transaction.js +6 -0
  331. package/lib-es/cli-transaction.js.map +1 -0
  332. package/lib-es/createTransaction.d.ts +9 -0
  333. package/lib-es/createTransaction.d.ts.map +1 -0
  334. package/lib-es/createTransaction.js +25 -0
  335. package/lib-es/createTransaction.js.map +1 -0
  336. package/lib-es/datasets/ethereum.scanAccounts.1.d.ts +7 -0
  337. package/lib-es/datasets/ethereum.scanAccounts.1.d.ts.map +1 -0
  338. package/lib-es/datasets/ethereum.scanAccounts.1.js +49 -0
  339. package/lib-es/datasets/ethereum.scanAccounts.1.js.map +1 -0
  340. package/lib-es/datasets/ethereum1.d.ts +3 -0
  341. package/lib-es/datasets/ethereum1.d.ts.map +1 -0
  342. package/lib-es/datasets/ethereum1.js +19 -0
  343. package/lib-es/datasets/ethereum1.js.map +1 -0
  344. package/lib-es/datasets/ethereum2.d.ts +3 -0
  345. package/lib-es/datasets/ethereum2.d.ts.map +1 -0
  346. package/lib-es/datasets/ethereum2.js +19 -0
  347. package/lib-es/datasets/ethereum2.js.map +1 -0
  348. package/lib-es/datasets/ethereum_classic.d.ts +5 -0
  349. package/lib-es/datasets/ethereum_classic.d.ts.map +1 -0
  350. package/lib-es/datasets/ethereum_classic.js +67 -0
  351. package/lib-es/datasets/ethereum_classic.js.map +1 -0
  352. package/lib-es/deviceTransactionConfig.d.ts +15 -0
  353. package/lib-es/deviceTransactionConfig.d.ts.map +1 -0
  354. package/lib-es/deviceTransactionConfig.js +42 -0
  355. package/lib-es/deviceTransactionConfig.js.map +1 -0
  356. package/lib-es/errors.d.ts +16 -0
  357. package/lib-es/errors.d.ts.map +1 -0
  358. package/lib-es/errors.js +8 -0
  359. package/lib-es/errors.js.map +1 -0
  360. package/lib-es/estimateMaxSpendable.d.ts +4 -0
  361. package/lib-es/estimateMaxSpendable.d.ts.map +1 -0
  362. package/lib-es/estimateMaxSpendable.js +19 -0
  363. package/lib-es/estimateMaxSpendable.js.map +1 -0
  364. package/lib-es/getTransactionStatus.d.ts +23 -0
  365. package/lib-es/getTransactionStatus.d.ts.map +1 -0
  366. package/lib-es/getTransactionStatus.js +125 -0
  367. package/lib-es/getTransactionStatus.js.map +1 -0
  368. package/lib-es/hw-getAddress.d.ts +6 -0
  369. package/lib-es/hw-getAddress.d.ts.map +1 -0
  370. package/lib-es/hw-getAddress.js +23 -0
  371. package/lib-es/hw-getAddress.js.map +1 -0
  372. package/lib-es/logic.d.ts +31 -0
  373. package/lib-es/logic.d.ts.map +1 -0
  374. package/lib-es/logic.js +119 -0
  375. package/lib-es/logic.js.map +1 -0
  376. package/lib-es/preload.d.ts +6 -0
  377. package/lib-es/preload.d.ts.map +1 -0
  378. package/lib-es/preload.js +49 -0
  379. package/lib-es/preload.js.map +1 -0
  380. package/lib-es/prepareTransaction.d.ts +26 -0
  381. package/lib-es/prepareTransaction.d.ts.map +1 -0
  382. package/lib-es/prepareTransaction.js +118 -0
  383. package/lib-es/prepareTransaction.js.map +1 -0
  384. package/lib-es/signOperation.d.ts +18 -0
  385. package/lib-es/signOperation.d.ts.map +1 -0
  386. package/lib-es/signOperation.js +83 -0
  387. package/lib-es/signOperation.js.map +1 -0
  388. package/lib-es/signer.d.ts +27 -0
  389. package/lib-es/signer.d.ts.map +1 -0
  390. package/lib-es/signer.js +2 -0
  391. package/lib-es/signer.js.map +1 -0
  392. package/lib-es/specs.d.ts +3 -0
  393. package/lib-es/specs.d.ts.map +1 -0
  394. package/lib-es/specs.js +233 -0
  395. package/lib-es/specs.js.map +1 -0
  396. package/lib-es/speculos-deviceActions.d.ts +8 -0
  397. package/lib-es/speculos-deviceActions.d.ts.map +1 -0
  398. package/lib-es/speculos-deviceActions.js +63 -0
  399. package/lib-es/speculos-deviceActions.js.map +1 -0
  400. package/lib-es/synchronization.d.ts +27 -0
  401. package/lib-es/synchronization.d.ts.map +1 -0
  402. package/lib-es/synchronization.js +212 -0
  403. package/lib-es/synchronization.js.map +1 -0
  404. package/lib-es/testUtils.d.ts +6 -0
  405. package/lib-es/testUtils.d.ts.map +1 -0
  406. package/lib-es/testUtils.js +102 -0
  407. package/lib-es/testUtils.js.map +1 -0
  408. package/lib-es/transaction.d.ts +43 -0
  409. package/lib-es/transaction.d.ts.map +1 -0
  410. package/lib-es/transaction.js +112 -0
  411. package/lib-es/transaction.js.map +1 -0
  412. package/lib-es/types.d.ts +111 -0
  413. package/lib-es/types.d.ts.map +1 -0
  414. package/lib-es/types.js +2 -0
  415. package/lib-es/types.js.map +1 -0
  416. package/package.json +8 -23
  417. package/src/__tests__/adapters.unit.test.ts +22 -52
  418. package/src/__tests__/broadcast.unit.test.ts +9 -27
  419. package/src/__tests__/buildOptimisticOperation.unit.test.ts +4 -4
  420. package/src/__tests__/deviceTransactionConfig.unit.test.ts +7 -7
  421. package/src/__tests__/estimateMaxSpendable.unit.test.ts +2 -4
  422. package/src/__tests__/gasTracker/index.unit.test.ts +36 -0
  423. package/src/__tests__/gasTracker/ledger.unit.test.ts +108 -0
  424. package/src/__tests__/getTransactionStatus.unit.test.ts +35 -40
  425. package/src/__tests__/hw-getAddress.unit.test.ts +15 -2
  426. package/src/__tests__/logic.unit.test.ts +25 -72
  427. package/src/__tests__/preload.unit.test.ts +3 -9
  428. package/src/__tests__/prepareTransaction.unit.test.ts +131 -76
  429. package/src/__tests__/rpc.unit.test.ts +46 -80
  430. package/src/__tests__/signOperation.unit.test.ts +27 -25
  431. package/src/__tests__/synchronization.unit.test.ts +101 -153
  432. package/src/__tests__/transaction.unit.test.ts +6 -14
  433. package/src/adapters.ts +8 -18
  434. package/src/api/{etherscan.ts → explorer/etherscan.ts} +14 -29
  435. package/src/api/explorer/index.ts +34 -0
  436. package/src/api/gasTracker/index.ts +31 -0
  437. package/src/api/gasTracker/ledger.ts +103 -0
  438. package/src/api/{rpc.common.ts → rpc/rpc.common.ts} +41 -64
  439. package/src/bridge/js.ts +15 -22
  440. package/src/bridge.integration.test.ts +3 -10
  441. package/src/broadcast.ts +3 -7
  442. package/src/buildOptimisticOperation.ts +7 -17
  443. package/src/cli-transaction.ts +1 -7
  444. package/src/createTransaction.ts +14 -15
  445. package/src/deviceTransactionConfig.ts +1 -1
  446. package/src/errors.ts +6 -0
  447. package/src/estimateMaxSpendable.ts +14 -11
  448. package/src/getTransactionStatus.ts +41 -52
  449. package/src/hw-getAddress.ts +18 -19
  450. package/src/logic.ts +5 -15
  451. package/src/preload.ts +6 -16
  452. package/src/prepareTransaction.ts +30 -31
  453. package/src/signOperation.ts +57 -69
  454. package/src/signer.ts +35 -0
  455. package/src/specs.ts +27 -52
  456. package/src/speculos-deviceActions.ts +56 -65
  457. package/src/synchronization.ts +21 -60
  458. package/src/testUtils.ts +5 -19
  459. package/src/transaction.ts +6 -10
  460. package/src/types.ts +6 -0
  461. /package/src/api/{rpc.ts → rpc/index.ts} +0 -0
  462. /package/src/api/{rpc.native.ts → rpc/rpc.native.ts} +0 -0
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getTransactionStatus = exports.validateGas = exports.validateAmount = exports.validateRecipient = void 0;
13
+ const errors_1 = require("@ledgerhq/errors");
14
+ const ethers_1 = require("ethers");
15
+ const index_1 = require("@ledgerhq/coin-framework/account/index");
16
+ const logic_1 = require("./logic");
17
+ // This regex will not work with Starknet since addresses are 65 caracters long after the 0x
18
+ const ethAddressRegEx = /^(0x)?[0-9a-fA-F]{40}$/;
19
+ /**
20
+ * Validate an address for a transaction
21
+ */
22
+ const validateRecipient = (account, tx) => {
23
+ const errors = {};
24
+ const warnings = {};
25
+ if (tx.recipient) {
26
+ // Check if recipient is matching the format of a valid eth address or not
27
+ const isRecipientMatchingEthFormat = tx.recipient.match(ethAddressRegEx);
28
+ if (!isRecipientMatchingEthFormat) {
29
+ errors.recipient = new errors_1.InvalidAddress("", {
30
+ currency: account.currency,
31
+ });
32
+ }
33
+ else {
34
+ // Check if address is respecting EIP-55
35
+ try {
36
+ const recipientChecksumed = ethers_1.ethers.utils.getAddress(tx.recipient);
37
+ if (tx.recipient !== recipientChecksumed) {
38
+ // this case can happen if the user is entering an ICAP address.
39
+ throw new Error();
40
+ }
41
+ }
42
+ catch (e) {
43
+ // either getAddress throws for a bad checksum or we throw manually if the recipient isn't the same.
44
+ warnings.recipient = new errors_1.ETHAddressNonEIP(); // "Auto-verification not available: carefully verify the address"
45
+ }
46
+ }
47
+ }
48
+ else {
49
+ errors.recipient = new errors_1.RecipientRequired(); // ""
50
+ }
51
+ return [errors, warnings];
52
+ };
53
+ exports.validateRecipient = validateRecipient;
54
+ /**
55
+ * Validate the amount of a transaction for an account
56
+ */
57
+ const validateAmount = (account, transaction, totalSpent) => {
58
+ const errors = {};
59
+ const warnings = {};
60
+ const isTokenTransaction = (account === null || account === void 0 ? void 0 : account.type) === "TokenAccount";
61
+ const isSmartContractInteraction = isTokenTransaction || transaction.data; // if the transaction is a smart contract interaction, it's normal that transaction has no amount
62
+ const transactionHasFees = (0, logic_1.legacyTransactionHasFees)(transaction) ||
63
+ (0, logic_1.eip1559TransactionHasFees)(transaction);
64
+ const canHaveZeroAmount = isSmartContractInteraction && transactionHasFees;
65
+ // if no amount or 0
66
+ if ((!transaction.amount || transaction.amount.isZero()) && !canHaveZeroAmount) {
67
+ errors.amount = new errors_1.AmountRequired(); // "Amount required"
68
+ }
69
+ else if (totalSpent.isGreaterThan(account.balance)) {
70
+ // if not enough to make the transaction
71
+ errors.amount = new errors_1.NotEnoughBalance(); // "Sorry, insufficient funds"
72
+ }
73
+ return [errors, warnings];
74
+ };
75
+ exports.validateAmount = validateAmount;
76
+ /**
77
+ * Validate gas properties of a transaction, depending on its type and the account emitter
78
+ */
79
+ const validateGas = (account, tx, gasLimit, estimatedFees) => {
80
+ const errors = {};
81
+ const warnings = {};
82
+ if (
83
+ // if fees are not set or wrongly set
84
+ !((0, logic_1.legacyTransactionHasFees)(tx) ||
85
+ (0, logic_1.eip1559TransactionHasFees)(tx))) {
86
+ errors.gasPrice = new errors_1.FeeNotLoaded(); // "Could not load fee rates. Please set manual fees"
87
+ }
88
+ else if (gasLimit.isZero()) {
89
+ errors.gasLimit = new errors_1.FeeNotLoaded(); // "Could not load fee rates. Please set manual fees"
90
+ }
91
+ else if (gasLimit.isLessThan(21000)) {
92
+ // minimum gas for a tx is 21000
93
+ errors.gasLimit = new errors_1.GasLessThanEstimate(); // "This may be too low. Please increase"
94
+ }
95
+ else if (tx.recipient && estimatedFees.gt(account.balance)) {
96
+ errors.gasPrice = new errors_1.NotEnoughGas(); // "The parent account balance is insufficient for network fees"
97
+ }
98
+ else if (tx.maxPriorityFeePerGas && tx.maxPriorityFeePerGas.isZero()) {
99
+ errors.maxPriorityFee = new errors_1.PriorityFeeTooLow();
100
+ }
101
+ return [errors, warnings];
102
+ };
103
+ exports.validateGas = validateGas;
104
+ /**
105
+ * Validate a transaction and get all possibles errors and warnings about it
106
+ */
107
+ const getTransactionStatus = (account, tx) => __awaiter(void 0, void 0, void 0, function* () {
108
+ const subAccount = (0, index_1.findSubAccountById)(account, tx.subAccountId || "");
109
+ const isTokenTransaction = (subAccount === null || subAccount === void 0 ? void 0 : subAccount.type) === "TokenAccount";
110
+ const { gasLimit, additionalFees, amount } = tx;
111
+ const estimatedFees = (0, logic_1.getEstimatedFees)(tx);
112
+ const totalFees = estimatedFees.plus(additionalFees || 0);
113
+ const totalSpent = isTokenTransaction ? tx.amount : tx.amount.plus(totalFees);
114
+ // Recipient related errors and warnings
115
+ const [recipientErr, recipientWarn] = (0, exports.validateRecipient)(account, tx);
116
+ // Amount related errors and warnings
117
+ const [amountErr, amountWarn] = (0, exports.validateAmount)(subAccount || account, tx, totalSpent);
118
+ // Gas related errors and warnings
119
+ const [gasErr, gasWarn] = (0, exports.validateGas)(account, tx, gasLimit, totalFees);
120
+ const errors = Object.assign(Object.assign(Object.assign({}, recipientErr), gasErr), amountErr);
121
+ const warnings = Object.assign(Object.assign(Object.assign({}, recipientWarn), gasWarn), amountWarn);
122
+ return {
123
+ errors,
124
+ warnings,
125
+ estimatedFees,
126
+ amount,
127
+ totalSpent,
128
+ };
129
+ });
130
+ exports.getTransactionStatus = getTransactionStatus;
131
+ exports.default = exports.getTransactionStatus;
132
+ //# sourceMappingURL=getTransactionStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTransactionStatus.js","sourceRoot":"","sources":["../src/getTransactionStatus.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAU0B;AAC1B,mCAAgC;AAGhC,kEAA4E;AAC5E,mCAAgG;AAehG,4FAA4F;AAC5F,MAAM,eAAe,GAAG,wBAAwB,CAAC;AAEjD;;GAEG;AACI,MAAM,iBAAiB,GAAG,CAC/B,OAAgB,EAChB,EAAkB,EACO,EAAE;IAC3B,MAAM,MAAM,GAAqB,EAAE,CAAC;IACpC,MAAM,QAAQ,GAAqB,EAAE,CAAC;IAEtC,IAAI,EAAE,CAAC,SAAS,EAAE;QAChB,0EAA0E;QAC1E,MAAM,4BAA4B,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAEzE,IAAI,CAAC,4BAA4B,EAAE;YACjC,MAAM,CAAC,SAAS,GAAG,IAAI,uBAAc,CAAC,EAAE,EAAE;gBACxC,QAAQ,EAAE,OAAO,CAAC,QAAQ;aAC3B,CAAC,CAAC;SACJ;aAAM;YACL,wCAAwC;YACxC,IAAI;gBACF,MAAM,mBAAmB,GAAG,eAAM,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;gBAClE,IAAI,EAAE,CAAC,SAAS,KAAK,mBAAmB,EAAE;oBACxC,gEAAgE;oBAChE,MAAM,IAAI,KAAK,EAAE,CAAC;iBACnB;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,oGAAoG;gBACpG,QAAQ,CAAC,SAAS,GAAG,IAAI,yBAAgB,EAAE,CAAC,CAAC,kEAAkE;aAChH;SACF;KACF;SAAM;QACL,MAAM,CAAC,SAAS,GAAG,IAAI,0BAAiB,EAAE,CAAC,CAAC,KAAK;KAClD;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IAChD,MAAM,aAAa,GAAG,IAAA,wBAAgB,EAAC,EAAE,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,CAAC,cAAc,IAAI,CAAC,CAAC,CAAC;IAC1D,MAAM,UAAU,GAAG,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAE9E,wCAAwC;IACxC,MAAM,CAAC,YAAY,EAAE,aAAa,CAAC,GAAG,IAAA,yBAAiB,EAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACrE,qCAAqC;IACrC,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,IAAA,sBAAc,EAAC,UAAU,IAAI,OAAO,EAAE,EAAE,EAAE,UAAU,CAAC,CAAC;IACtF,kCAAkC;IAClC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAA,mBAAW,EAAC,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAExE,MAAM,MAAM,iDACP,YAAY,GACZ,MAAM,GACN,SAAS,CACb,CAAC;IACF,MAAM,QAAQ,iDACT,aAAa,GACb,OAAO,GACP,UAAU,CACd,CAAC;IAEF,OAAO;QACL,MAAM;QACN,QAAQ;QACR,aAAa;QACb,MAAM;QACN,UAAU;KACX,CAAC;AACJ,CAAC,CAAA,CAAC;AApCW,QAAA,oBAAoB,wBAoC/B;AAEF,kBAAe,4BAAoB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { GetAddressFn } from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
2
+ import { SignerContext } from "@ledgerhq/coin-framework/signer";
3
+ import { EvmAddress, EvmSignature, EvmSigner } from "./signer";
4
+ declare const resolver: (signerContext: SignerContext<EvmSigner, EvmAddress | EvmSignature>) => GetAddressFn;
5
+ export default resolver;
6
+ //# sourceMappingURL=hw-getAddress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hw-getAddress.d.ts","sourceRoot":"","sources":["../src/hw-getAddress.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mDAAmD,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE/D,QAAA,MAAM,QAAQ,kBACG,cAAc,SAAS,EAAE,UAAU,GAAG,YAAY,CAAC,KACjE,YAYF,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const eip55_1 = __importDefault(require("eip55"));
16
+ const resolver = (signerContext) => {
17
+ return (deviceId, { path, verify }) => __awaiter(void 0, void 0, void 0, function* () {
18
+ const { address, publicKey, chainCode } = (yield signerContext(deviceId, signer => signer.getAddress(path, verify, false)));
19
+ return {
20
+ address: eip55_1.default.encode(address),
21
+ publicKey,
22
+ chainCode,
23
+ path,
24
+ };
25
+ });
26
+ };
27
+ exports.default = resolver;
28
+ //# sourceMappingURL=hw-getAddress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hw-getAddress.js","sourceRoot":"","sources":["../src/hw-getAddress.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,kDAA0B;AAM1B,MAAM,QAAQ,GAAG,CACf,aAAkE,EACpD,EAAE;IAChB,OAAO,CAAO,QAAgB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAqB,EAAE,EAAE;QACrE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,CAChF,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CACvC,CAAe,CAAC;QACjB,OAAO;YACL,OAAO,EAAE,eAAK,CAAC,MAAM,CAAC,OAAO,CAAC;YAC9B,SAAS;YACT,SAAS;YACT,IAAI;SACL,CAAC;IACJ,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,QAAQ,CAAC"}
package/lib/logic.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ import BigNumber from "bignumber.js";
2
+ import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
3
+ import { Account, SubAccount } from "@ledgerhq/types-live";
4
+ import { Transaction as EvmTransaction, EvmTransactionEIP1559, EvmTransactionLegacy } from "./types";
5
+ /**
6
+ * Helper to check if a legacy transaction has the right fee property
7
+ */
8
+ export declare const legacyTransactionHasFees: (tx: EvmTransactionLegacy) => boolean;
9
+ /**
10
+ * Helper to check if a legacy transaction has the right fee property
11
+ */
12
+ export declare const eip1559TransactionHasFees: (tx: EvmTransactionEIP1559) => boolean;
13
+ /**
14
+ * Helper to get total fee value for a tx depending on its type
15
+ */
16
+ export declare const getEstimatedFees: (tx: EvmTransaction) => BigNumber;
17
+ /**
18
+ * Helper returning the potential additional fees necessary for layer twos
19
+ * to settle the transaction on layer 1.
20
+ */
21
+ export declare const getAdditionalLayer2Fees: (currency: CryptoCurrency, transaction: EvmTransaction) => Promise<BigNumber | undefined>;
22
+ /**
23
+ * In charge of smartly merging sub accounts while maintaining references as much as possible
24
+ */
25
+ export declare const mergeSubAccounts: (initialAccount: Account | undefined, newSubAccounts: Partial<SubAccount>[]) => Array<Partial<SubAccount> | SubAccount>;
26
+ /**
27
+ * Method creating a hash that will help triggering or not a full synchronization on an account.
28
+ * As of now, it's checking if a token has been added, removed of changed regarding important properties
29
+ */
30
+ export declare const getSyncHash: (currency: CryptoCurrency) => string;
31
+ //# sourceMappingURL=logic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logic.d.ts","sourceRoot":"","sources":["../src/logic.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,EACL,WAAW,IAAI,cAAc,EAC7B,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,eAAO,MAAM,wBAAwB,OAAQ,oBAAoB,KAAG,OACjB,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,yBAAyB,OAAQ,qBAAqB,KAAG,OACA,CAAC;AAEvE;;GAEG;AACH,eAAO,MAAM,gBAAgB,OAAQ,cAAc,KAAG,SAKrD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,aACxB,cAAc,eACX,cAAc,KAC1B,QAAQ,SAAS,GAAG,SAAS,CAU/B,CAAC;AAcF;;GAEG;AACH,eAAO,MAAM,gBAAgB,mBACX,OAAO,GAAG,SAAS,kBACnB,QAAQ,UAAU,CAAC,EAAE,KACpC,MAAM,QAAQ,UAAU,CAAC,GAAG,UAAU,CAqDxC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,aAAc,cAAc,KAAG,MAOtD,CAAC"}
package/lib/logic.js ADDED
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getSyncHash = exports.mergeSubAccounts = exports.getAdditionalLayer2Fees = exports.getEstimatedFees = exports.eip1559TransactionHasFees = exports.legacyTransactionHasFees = void 0;
16
+ const ethers_1 = require("ethers");
17
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
18
+ const jsHelpers_1 = require("@ledgerhq/coin-framework/bridge/jsHelpers");
19
+ const tokens_1 = require("@ledgerhq/cryptoassets/tokens");
20
+ const rpc_common_1 = require("./api/rpc/rpc.common");
21
+ /**
22
+ * Helper to check if a legacy transaction has the right fee property
23
+ */
24
+ const legacyTransactionHasFees = (tx) => Boolean((!tx.type || tx.type < 2) && tx.gasPrice);
25
+ exports.legacyTransactionHasFees = legacyTransactionHasFees;
26
+ /**
27
+ * Helper to check if a legacy transaction has the right fee property
28
+ */
29
+ const eip1559TransactionHasFees = (tx) => Boolean(tx.type === 2 && tx.maxFeePerGas && tx.maxPriorityFeePerGas);
30
+ exports.eip1559TransactionHasFees = eip1559TransactionHasFees;
31
+ /**
32
+ * Helper to get total fee value for a tx depending on its type
33
+ */
34
+ const getEstimatedFees = (tx) => {
35
+ var _a, _b;
36
+ if (tx.type !== 2) {
37
+ return ((_a = tx.gasPrice) === null || _a === void 0 ? void 0 : _a.multipliedBy(tx.gasLimit)) || new bignumber_js_1.default(0);
38
+ }
39
+ return ((_b = tx.maxFeePerGas) === null || _b === void 0 ? void 0 : _b.multipliedBy(tx.gasLimit)) || new bignumber_js_1.default(0);
40
+ };
41
+ exports.getEstimatedFees = getEstimatedFees;
42
+ /**
43
+ * Helper returning the potential additional fees necessary for layer twos
44
+ * to settle the transaction on layer 1.
45
+ */
46
+ const getAdditionalLayer2Fees = (currency, transaction) => __awaiter(void 0, void 0, void 0, function* () {
47
+ switch (currency.id) {
48
+ case "optimism":
49
+ case "optimism_goerli": {
50
+ const additionalFees = yield (0, rpc_common_1.getOptimismAdditionalFees)(currency, transaction);
51
+ return additionalFees;
52
+ }
53
+ default:
54
+ return;
55
+ }
56
+ });
57
+ exports.getAdditionalLayer2Fees = getAdditionalLayer2Fees;
58
+ /**
59
+ * List of properties of a sub account that can be updated when 2 "identical" accounts are found
60
+ */
61
+ const updatableSubAccountProperties = [
62
+ { name: "balance", isOps: false },
63
+ { name: "spendableBalance", isOps: false },
64
+ { name: "balanceHistoryCache", isOps: false },
65
+ { name: "swapHistory", isOps: false },
66
+ { name: "operations", isOps: true },
67
+ { name: "pendingOperations", isOps: true },
68
+ ];
69
+ /**
70
+ * In charge of smartly merging sub accounts while maintaining references as much as possible
71
+ */
72
+ const mergeSubAccounts = (initialAccount, newSubAccounts) => {
73
+ var _a, _b;
74
+ const oldSubAccounts = initialAccount === null || initialAccount === void 0 ? void 0 : initialAccount.subAccounts;
75
+ if (!oldSubAccounts) {
76
+ return newSubAccounts;
77
+ }
78
+ // Creating a map of already existing sub accounts by id
79
+ const oldSubAccountsById = {};
80
+ for (const oldSubAccount of oldSubAccounts) {
81
+ oldSubAccountsById[oldSubAccount.id] = oldSubAccount;
82
+ }
83
+ // Looping on new sub accounts to compare them with already existing ones
84
+ // Already existing will be updated if necessary (see `updatableSubAccountProperties`)
85
+ // Fresh new sub accounts will be added/pushed after already existing
86
+ const newSubAccountsToAdd = [];
87
+ for (const newSubAccount of newSubAccounts) {
88
+ const duplicatedAccount = oldSubAccountsById[newSubAccount.id];
89
+ // If this sub account was not already in the initialAccount
90
+ if (!duplicatedAccount) {
91
+ // We'll add it later
92
+ newSubAccountsToAdd.push(newSubAccount);
93
+ continue;
94
+ }
95
+ const updates = {};
96
+ for (const { name, isOps } of updatableSubAccountProperties) {
97
+ if (!isOps) {
98
+ // @ts-expect-error FIXME: fix typings
99
+ if (newSubAccount[name] !== duplicatedAccount[name]) {
100
+ // @ts-expect-error FIXME: fix typings
101
+ updates[name] = newSubAccount[name];
102
+ }
103
+ }
104
+ else {
105
+ // @ts-expect-error FIXME: fix typings
106
+ updates[name] = (0, jsHelpers_1.mergeOps)(duplicatedAccount[name], newSubAccount[name]);
107
+ }
108
+ }
109
+ // Updating the operationsCount in case the mergeOps changed it
110
+ updates.operationsCount =
111
+ ((_a = updates.operations) === null || _a === void 0 ? void 0 : _a.length) || ((_b = duplicatedAccount === null || duplicatedAccount === void 0 ? void 0 : duplicatedAccount.operations) === null || _b === void 0 ? void 0 : _b.length) || 0;
112
+ // Modifying the Map with the updated sub account with a new ref
113
+ oldSubAccountsById[newSubAccount.id] = Object.assign(Object.assign({}, duplicatedAccount), updates);
114
+ }
115
+ const updatedSubAccounts = Object.values(oldSubAccountsById);
116
+ return [...updatedSubAccounts, ...newSubAccountsToAdd];
117
+ };
118
+ exports.mergeSubAccounts = mergeSubAccounts;
119
+ /**
120
+ * Method creating a hash that will help triggering or not a full synchronization on an account.
121
+ * As of now, it's checking if a token has been added, removed of changed regarding important properties
122
+ */
123
+ const getSyncHash = (currency) => {
124
+ const tokens = (0, tokens_1.listTokensForCryptoCurrency)(currency);
125
+ const basicTokensListString = tokens
126
+ .map(token => token.id + token.contractAddress + token.name + token.ticker + token.delisted)
127
+ .join("");
128
+ return ethers_1.ethers.utils.sha256(Buffer.from(basicTokensListString));
129
+ };
130
+ exports.getSyncHash = getSyncHash;
131
+ //# sourceMappingURL=logic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logic.js","sourceRoot":"","sources":["../src/logic.ts"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G,KAAK,CAAC,QAAQ,CAAC;SAC3F,IAAI,CAAC,EAAE,CAAC,CAAC;IAEZ,OAAO,eAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC;AACjE,CAAC,CAAC;AAPW,QAAA,WAAW,eAOtB"}
@@ -0,0 +1,6 @@
1
+ import { ERC20Token } from "@ledgerhq/cryptoassets/types";
2
+ import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
3
+ export declare const fetchERC20Tokens: (currency: CryptoCurrency) => Promise<ERC20Token[]>;
4
+ export declare function preload(currency: CryptoCurrency): Promise<ERC20Token[]>;
5
+ export declare function hydrate(value: ERC20Token[] | null | undefined): void;
6
+ //# sourceMappingURL=preload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preload.d.ts","sourceRoot":"","sources":["../src/preload.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAM9D,eAAO,MAAM,gBAAgB,EAAE,CAC7B,QAAQ,EAAE,cAAc,KACrB,OAAO,CAAC,UAAU,EAAE,CAqBxB,CAAC;AAEF,wBAAsB,OAAO,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAI7E;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAIpE"}
package/lib/preload.js ADDED
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.hydrate = exports.preload = exports.fetchERC20Tokens = void 0;
16
+ const logs_1 = require("@ledgerhq/logs");
17
+ const tokens_1 = require("@ledgerhq/cryptoassets/tokens");
18
+ const index_1 = require("@ledgerhq/cryptoassets/data/evm/index");
19
+ const network_1 = __importDefault(require("@ledgerhq/live-network/network"));
20
+ const live_env_1 = require("@ledgerhq/live-env");
21
+ const fetchERC20Tokens = (currency) => __awaiter(void 0, void 0, void 0, function* () {
22
+ const { ethereumLikeInfo } = currency;
23
+ const url = `${(0, live_env_1.getEnv)("DYNAMIC_CAL_BASE_URL")}/evm/${(ethereumLikeInfo === null || ethereumLikeInfo === void 0 ? void 0 : ethereumLikeInfo.chainId) || 0}/erc20.json`;
24
+ const dynamicTokens = yield (0, network_1.default)({
25
+ method: "GET",
26
+ url,
27
+ })
28
+ .then(({ data }) => (data.length ? data : null))
29
+ .catch(e => {
30
+ (0, logs_1.log)("error", "EVM Family: Couldn't fetch dynamic CAL tokens from " + url, e);
31
+ return null;
32
+ });
33
+ if (dynamicTokens)
34
+ return dynamicTokens;
35
+ // @ts-expect-error FIXME: fix typings
36
+ const tokens = index_1.tokens[(ethereumLikeInfo === null || ethereumLikeInfo === void 0 ? void 0 : ethereumLikeInfo.chainId) || ""];
37
+ if (tokens)
38
+ return tokens;
39
+ (0, logs_1.log)("warning", `EVM Family: No tokens found in CAL for currency: ${currency.id}`, currency);
40
+ return [];
41
+ });
42
+ exports.fetchERC20Tokens = fetchERC20Tokens;
43
+ function preload(currency) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ const erc20 = yield (0, exports.fetchERC20Tokens)(currency);
46
+ (0, tokens_1.addTokens)(erc20.map(tokens_1.convertERC20));
47
+ return erc20;
48
+ });
49
+ }
50
+ exports.preload = preload;
51
+ function hydrate(value) {
52
+ if (!Array.isArray(value))
53
+ return;
54
+ (0, tokens_1.addTokens)(value.map(tokens_1.convertERC20));
55
+ (0, logs_1.log)("evm/preload", "hydrate " + value.length + " tokens");
56
+ }
57
+ exports.hydrate = hydrate;
58
+ //# sourceMappingURL=preload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preload.js","sourceRoot":"","sources":["../src/preload.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,yCAAqC;AAGrC,0DAAwE;AACxE,iEAAkF;AAClF,6EAAqD;AACrD,iDAA4C;AAErC,MAAM,gBAAgB,GAEA,CAAM,QAAQ,EAAC,EAAE;IAC5C,MAAM,EAAE,gBAAgB,EAAE,GAAG,QAAQ,CAAC;IAEtC,MAAM,GAAG,GAAG,GAAG,IAAA,iBAAM,EAAC,sBAAsB,CAAC,QAAQ,CAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,OAAO,KAAI,CAAC,aAAa,CAAC;IACjG,MAAM,aAAa,GAAwB,MAAM,IAAA,iBAAO,EAAC;QACvD,MAAM,EAAE,KAAK;QACb,GAAG;KACJ,CAAC;SACC,IAAI,CAAC,CAAC,EAAE,IAAI,EAA0B,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;SACvE,KAAK,CAAC,CAAC,CAAC,EAAE;QACT,IAAA,UAAG,EAAC,OAAO,EAAE,qDAAqD,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;QAC7E,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IACL,IAAI,aAAa;QAAE,OAAO,aAAa,CAAC;IAExC,sCAAsC;IACtC,MAAM,MAAM,GAAG,cAAe,CAAC,CAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,OAAO,KAAI,EAAE,CAAC,CAAC;IAChE,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAE1B,IAAA,UAAG,EAAC,SAAS,EAAE,oDAAoD,QAAQ,CAAC,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC5F,OAAO,EAAE,CAAC;AACZ,CAAC,CAAA,CAAC;AAvBW,QAAA,gBAAgB,oBAuB3B;AAEF,SAAsB,OAAO,CAAC,QAAwB;;QACpD,MAAM,KAAK,GAAG,MAAM,IAAA,wBAAgB,EAAC,QAAQ,CAAC,CAAC;QAC/C,IAAA,kBAAS,EAAC,KAAK,CAAC,GAAG,CAAC,qBAAY,CAAC,CAAC,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;CAAA;AAJD,0BAIC;AAED,SAAgB,OAAO,CAAC,KAAsC;IAC5D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO;IAClC,IAAA,kBAAS,EAAC,KAAK,CAAC,GAAG,CAAC,qBAAY,CAAC,CAAC,CAAC;IACnC,IAAA,UAAG,EAAC,aAAa,EAAE,UAAU,GAAG,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAC5D,CAAC;AAJD,0BAIC"}
@@ -0,0 +1,26 @@
1
+ import { Account, TokenAccount } from "@ledgerhq/types-live";
2
+ import { Transaction as EvmTransaction } from "./types";
3
+ /**
4
+ * Prepare basic coin transactions or smart contract interactions (other than live ERC20 transfers)
5
+ * Should be used for transactions coming from the wallet API
6
+ * Handling addition of gas limit
7
+ */
8
+ export declare const prepareCoinTransaction: (account: Account, typedTransaction: EvmTransaction) => Promise<EvmTransaction>;
9
+ /**
10
+ * Prepare ERC20 transactions.
11
+ * Handling addition of ERC20 transfer data and gas limit
12
+ */
13
+ export declare const prepareTokenTransaction: (account: Account, tokenAccount: TokenAccount, typedTransaction: EvmTransaction) => Promise<EvmTransaction>;
14
+ /**
15
+ * Method called to update a transaction into a state that would make it valid
16
+ * (E.g. Adding fees, add smart contract data, etc...)
17
+ */
18
+ export declare const prepareTransaction: (account: Account, transaction: EvmTransaction) => Promise<EvmTransaction>;
19
+ /**
20
+ * Prepare the transaction for the signOperation step.
21
+ * For now, used to changed the recipient for TokenAccount transfers
22
+ * with the smart contract address as recipient and add the nonce
23
+ * (which would change as well in the UI if it was done before that step)
24
+ */
25
+ export declare const prepareForSignOperation: (account: Account, transaction: EvmTransaction) => Promise<EvmTransaction>;
26
+ //# sourceMappingURL=prepareTransaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepareTransaction.d.ts","sourceRoot":"","sources":["../src/prepareTransaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAM7D,OAAO,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,SAAS,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,YACxB,OAAO,oBACE,cAAc,KAC/B,QAAQ,cAAc,CAgDxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,YACzB,OAAO,gBACF,YAAY,oBACR,cAAc,KAC/B,QAAQ,cAAc,CAiCxB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,YACpB,OAAO,eACH,cAAc,KAC1B,QAAQ,cAAc,CA4BxB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,YACzB,OAAO,eACH,cAAc,KAC1B,QAAQ,cAAc,CAkBxB,CAAC"}
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.prepareForSignOperation = exports.prepareTransaction = exports.prepareTokenTransaction = exports.prepareCoinTransaction = void 0;
16
+ const index_1 = require("@ledgerhq/coin-framework/account/index");
17
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
18
+ const rpc_1 = require("./api/rpc");
19
+ const getTransactionStatus_1 = require("./getTransactionStatus");
20
+ const logic_1 = require("./logic");
21
+ const transaction_1 = require("./transaction");
22
+ /**
23
+ * Prepare basic coin transactions or smart contract interactions (other than live ERC20 transfers)
24
+ * Should be used for transactions coming from the wallet API
25
+ * Handling addition of gas limit
26
+ */
27
+ const prepareCoinTransaction = (account, typedTransaction) => __awaiter(void 0, void 0, void 0, function* () {
28
+ // A `useAllAmount` transaction is a specific case of the live, and because we're in the
29
+ // context of a coinTransaction, no smart contract should be involed
30
+ if (typedTransaction.useAllAmount) {
31
+ // Since a gas estimation is done by simulating the transaction, we can't know in advanced how much
32
+ // we should put in the simulation.
33
+ // But as a coin transaction (no smart contract) should always consumme the same amount of gas, no matter
34
+ // the amount of coin transfered, we can infer the gasLimit with any amount.
35
+ const gasLimit = yield (0, rpc_1.getGasEstimation)(account, Object.assign(Object.assign({}, typedTransaction), { amount: new bignumber_js_1.default(0) }));
36
+ const draftTransaction = Object.assign(Object.assign({}, typedTransaction), { gasLimit });
37
+ const estimatedFees = (0, logic_1.getEstimatedFees)(draftTransaction);
38
+ const additionalFees = yield (0, logic_1.getAdditionalLayer2Fees)(account.currency, draftTransaction);
39
+ const amount = bignumber_js_1.default.max(account.balance.minus(estimatedFees).minus(additionalFees || 0), 0);
40
+ return Object.assign(Object.assign({}, draftTransaction), { amount,
41
+ additionalFees });
42
+ }
43
+ const gasLimit = yield (0, rpc_1.getGasEstimation)(account, typedTransaction).catch(
44
+ // in case of a smart contract interaction, the gas estimation
45
+ // (which is transaction simulation by the node) can fail.
46
+ // E.g. A DApp is creating an invalid transaction, swaping more Tokens than the user actually have -> fail
47
+ // This value of 0 should be catched by `getTransactionStatus`
48
+ // and displayed in the UI as `set the gas manually`
49
+ () => new bignumber_js_1.default(0));
50
+ const additionalFees = yield (0, logic_1.getAdditionalLayer2Fees)(account.currency, Object.assign(Object.assign({}, typedTransaction), { gasLimit }));
51
+ return Object.assign(Object.assign({}, typedTransaction), { gasLimit,
52
+ additionalFees });
53
+ });
54
+ exports.prepareCoinTransaction = prepareCoinTransaction;
55
+ /**
56
+ * Prepare ERC20 transactions.
57
+ * Handling addition of ERC20 transfer data and gas limit
58
+ */
59
+ const prepareTokenTransaction = (account, tokenAccount, typedTransaction) => __awaiter(void 0, void 0, void 0, function* () {
60
+ const [recipientErrors] = (0, getTransactionStatus_1.validateRecipient)(account, typedTransaction);
61
+ const amount = typedTransaction.useAllAmount ? tokenAccount.balance : typedTransaction.amount;
62
+ const data = !Object.keys(recipientErrors).length
63
+ ? (0, transaction_1.getTransactionData)(Object.assign(Object.assign({}, typedTransaction), { amount }))
64
+ : undefined;
65
+ // As we're interacting with a smart contract,
66
+ // it's going to be the real recipient for the tx
67
+ const gasLimit = data
68
+ ? yield (0, rpc_1.getGasEstimation)(account, Object.assign(Object.assign({}, typedTransaction), { amount: new bignumber_js_1.default(0), recipient: tokenAccount.token.contractAddress, // recipient is then the token smart contract
69
+ data })).catch(() => new bignumber_js_1.default(0)) // this catch returning 0 should be handled by the `getTransactionStatus` method
70
+ : new bignumber_js_1.default(0);
71
+ const additionalFees = yield (0, logic_1.getAdditionalLayer2Fees)(account.currency, Object.assign(Object.assign({}, typedTransaction), { amount: new bignumber_js_1.default(0), recipient: tokenAccount.token.contractAddress, // recipient is then the token smart contract
72
+ data,
73
+ gasLimit }));
74
+ // Recipient isn't changed here as it would change on the UI end as well
75
+ // The change will be handled by the `prepareForSignOperation` method
76
+ return Object.assign(Object.assign({}, typedTransaction), { amount,
77
+ data,
78
+ gasLimit,
79
+ additionalFees });
80
+ });
81
+ exports.prepareTokenTransaction = prepareTokenTransaction;
82
+ /**
83
+ * Method called to update a transaction into a state that would make it valid
84
+ * (E.g. Adding fees, add smart contract data, etc...)
85
+ */
86
+ const prepareTransaction = (account, transaction) => __awaiter(void 0, void 0, void 0, function* () {
87
+ const { currency } = account;
88
+ // Get the current network status fees
89
+ const feeData = yield (() => __awaiter(void 0, void 0, void 0, function* () {
90
+ var _a, _b, _c, _d;
91
+ if (transaction.feesStrategy === "custom") {
92
+ return {
93
+ gasPrice: (_a = transaction.gasPrice) !== null && _a !== void 0 ? _a : null,
94
+ maxFeePerGas: (_b = transaction.maxFeePerGas) !== null && _b !== void 0 ? _b : null,
95
+ maxPriorityFeePerGas: (_c = transaction.maxPriorityFeePerGas) !== null && _c !== void 0 ? _c : null,
96
+ };
97
+ }
98
+ if (!transaction.feesStrategy) {
99
+ return (0, rpc_1.getFeesEstimation)(currency);
100
+ }
101
+ const gasOption = (_d = transaction.gasOptions) === null || _d === void 0 ? void 0 : _d[transaction.feesStrategy];
102
+ return gasOption !== null && gasOption !== void 0 ? gasOption : (0, rpc_1.getFeesEstimation)(currency);
103
+ }))();
104
+ const subAccount = (0, index_1.findSubAccountById)(account, transaction.subAccountId || "");
105
+ const isTokenTransaction = (subAccount === null || subAccount === void 0 ? void 0 : subAccount.type) === "TokenAccount";
106
+ const typedTransaction = (0, transaction_1.getTypedTransaction)(transaction, feeData);
107
+ return isTokenTransaction
108
+ ? yield (0, exports.prepareTokenTransaction)(account, subAccount, typedTransaction)
109
+ : yield (0, exports.prepareCoinTransaction)(account, typedTransaction);
110
+ });
111
+ exports.prepareTransaction = prepareTransaction;
112
+ /**
113
+ * Prepare the transaction for the signOperation step.
114
+ * For now, used to changed the recipient for TokenAccount transfers
115
+ * with the smart contract address as recipient and add the nonce
116
+ * (which would change as well in the UI if it was done before that step)
117
+ */
118
+ const prepareForSignOperation = (account, transaction) => __awaiter(void 0, void 0, void 0, function* () {
119
+ const nonce = yield (0, rpc_1.getTransactionCount)(account.currency, account.freshAddress);
120
+ const subAccount = (0, index_1.findSubAccountById)(account, transaction.subAccountId || "");
121
+ const isTokenTransaction = (subAccount === null || subAccount === void 0 ? void 0 : subAccount.type) === "TokenAccount";
122
+ return isTokenTransaction
123
+ ? Object.assign(Object.assign({}, transaction), { amount: new bignumber_js_1.default(0), recipient: subAccount.token.contractAddress, // recipient is then the token smart contract
124
+ // data as already been added by the `prepareTokenTransaction` method
125
+ nonce }) : Object.assign(Object.assign({}, transaction), { nonce });
126
+ });
127
+ exports.prepareForSignOperation = prepareForSignOperation;
128
+ //# sourceMappingURL=prepareTransaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepareTransaction.js","sourceRoot":"","sources":["../src/prepareTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kEAA4E;AAE5E,gEAAqC;AACrC,mCAAqF;AACrF,iEAA2D;AAC3D,mCAAoE;AACpE,+CAAwE;AAGxE;;;;GAIG;AACI,MAAM,sBAAsB,GAAG,CACpC,OAAgB,EAChB,gBAAgC,EACP,EAAE;IAC3B,wFAAwF;IACxF,oEAAoE;IACpE,IAAI,gBAAgB,CAAC,YAAY,EAAE;QACjC,mGAAmG;QACnG,mCAAmC;QACnC,yGAAyG;QACzG,4EAA4E;QAC5E,MAAM,QAAQ,GAAG,MAAM,IAAA,sBAAgB,EAAC,OAAO,kCAC1C,gBAAgB,KACnB,MAAM,EAAE,IAAI,sBAAS,CAAC,CAAC,CAAC,IACxB,CAAC;QACH,MAAM,gBAAgB,mCACjB,gBAAgB,KACnB,QAAQ,GACT,CAAC;QACF,MAAM,aAAa,GAAG,IAAA,wBAAgB,EAAC,gBAAgB,CAAC,CAAC;QACzD,MAAM,cAAc,GAAG,MAAM,IAAA,+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MAAM,EAAE,IAAI,sBAAS,CAAC,CAAC,CAAC,EACxB,SAAS,EAAE,UAAU,CAAC,KAAK,CAAC,eAAe,EAAE,6CAA6C;YAC1F,qEAAqE;YACrE,KAAK,IAET,CAAC,iCACM,WAAW,KACd,KAAK,GACN,CAAC;AACR,CAAC,CAAA,CAAC;AArBW,QAAA,uBAAuB,2BAqBlC"}
@@ -0,0 +1,18 @@
1
+ import { SignOperationFnSignature } from "@ledgerhq/types-live";
2
+ import { SignerContext } from "@ledgerhq/coin-framework/signer";
3
+ import { Transaction } from "./types";
4
+ import { EvmAddress, EvmSignature, EvmSigner } from "./signer";
5
+ /**
6
+ * Transforms the ECDSA signature paremeter v hexadecimal string received
7
+ * from the nano into an EIP155 compatible number.
8
+ *
9
+ * Reminder EIP155 transforms v this way:
10
+ * v = chainId * 2 + 35
11
+ * (+ parity 1 or 0)
12
+ */
13
+ export declare const applyEIP155: (vAsHex: string, chainId: number) => number;
14
+ /**
15
+ * Sign Transaction with Ledger hardware
16
+ */
17
+ export declare const buildSignOperation: (signerContext: SignerContext<EvmSigner, EvmAddress | EvmSignature>) => SignOperationFnSignature<Transaction>;
18
+ //# sourceMappingURL=signOperation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signOperation.d.ts","sourceRoot":"","sources":["../src/signOperation.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,wBAAwB,EAGzB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAIhE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE/D;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,WAAY,MAAM,WAAW,MAAM,KAAG,MAgB7D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,kBAEZ,cAAc,SAAS,EAAE,UAAU,GAAG,YAAY,CAAC,KACjE,yBAAyB,WAAW,CAkEnC,CAAC"}