@ledgerhq/coin-vechain 2.9.1-nightly.1 → 2.10.0-nightly.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (475) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.unimportedrc.json +16 -4
  3. package/CHANGELOG.md +14 -0
  4. package/lib/bridge/broadcast.d.ts.map +1 -1
  5. package/lib/bridge/broadcast.js +2 -3
  6. package/lib/bridge/broadcast.js.map +1 -1
  7. package/lib/bridge/broadcast.test.d.ts +2 -0
  8. package/lib/bridge/broadcast.test.d.ts.map +1 -0
  9. package/lib/bridge/broadcast.test.js +188 -0
  10. package/lib/bridge/broadcast.test.js.map +1 -0
  11. package/lib/bridge/buildOptimisticOperatioin.test.d.ts +2 -0
  12. package/lib/bridge/buildOptimisticOperatioin.test.d.ts.map +1 -0
  13. package/lib/bridge/buildOptimisticOperatioin.test.js +286 -0
  14. package/lib/bridge/buildOptimisticOperatioin.test.js.map +1 -0
  15. package/lib/bridge/createTransaction.d.ts.map +1 -1
  16. package/lib/bridge/createTransaction.js +2 -1
  17. package/lib/bridge/createTransaction.js.map +1 -1
  18. package/lib/bridge/createTransaction.test.d.ts +2 -0
  19. package/lib/bridge/createTransaction.test.d.ts.map +1 -0
  20. package/lib/bridge/createTransaction.test.js +167 -0
  21. package/lib/bridge/createTransaction.test.js.map +1 -0
  22. package/lib/bridge/estimateMaxSpendable.test.d.ts +2 -0
  23. package/lib/bridge/estimateMaxSpendable.test.d.ts.map +1 -0
  24. package/lib/bridge/estimateMaxSpendable.test.js +269 -0
  25. package/lib/bridge/estimateMaxSpendable.test.js.map +1 -0
  26. package/lib/bridge/getTransactionStatus.d.ts.map +1 -1
  27. package/lib/bridge/getTransactionStatus.js +3 -1
  28. package/lib/bridge/getTransactionStatus.js.map +1 -1
  29. package/lib/bridge/getTransactionStatus.test.d.ts +2 -0
  30. package/lib/bridge/getTransactionStatus.test.d.ts.map +1 -0
  31. package/lib/bridge/getTransactionStatus.test.js +282 -0
  32. package/lib/bridge/getTransactionStatus.test.js.map +1 -0
  33. package/lib/bridge/helpers.test.d.ts +2 -0
  34. package/lib/bridge/helpers.test.d.ts.map +1 -0
  35. package/lib/bridge/helpers.test.js +298 -0
  36. package/lib/bridge/helpers.test.js.map +1 -0
  37. package/lib/bridge/prepareTransaction.d.ts.map +1 -1
  38. package/lib/bridge/prepareTransaction.js +10 -3
  39. package/lib/bridge/prepareTransaction.js.map +1 -1
  40. package/lib/bridge/prepareTransaction.test.d.ts +2 -0
  41. package/lib/bridge/prepareTransaction.test.d.ts.map +1 -0
  42. package/lib/bridge/prepareTransaction.test.js +277 -0
  43. package/lib/bridge/prepareTransaction.test.js.map +1 -0
  44. package/lib/bridge/signOperation.d.ts.map +1 -1
  45. package/lib/bridge/signOperation.js +3 -3
  46. package/lib/bridge/signOperation.js.map +1 -1
  47. package/lib/bridge/signOperation.test.d.ts +2 -0
  48. package/lib/bridge/signOperation.test.d.ts.map +1 -0
  49. package/lib/bridge/signOperation.test.js +295 -0
  50. package/lib/bridge/signOperation.test.js.map +1 -0
  51. package/lib/bridge/synchronisation.d.ts.map +1 -1
  52. package/lib/bridge/synchronisation.js +2 -2
  53. package/lib/bridge/synchronisation.js.map +1 -1
  54. package/lib/bridge/transaction.test.d.ts +2 -0
  55. package/lib/bridge/transaction.test.d.ts.map +1 -0
  56. package/lib/bridge/transaction.test.js +353 -0
  57. package/lib/bridge/transaction.test.js.map +1 -0
  58. package/lib/common-logic/calculateClauses.d.ts +5 -0
  59. package/lib/common-logic/calculateClauses.d.ts.map +1 -0
  60. package/lib/common-logic/{logic.js → calculateClauses.js} +7 -10
  61. package/lib/common-logic/calculateClauses.js.map +1 -0
  62. package/lib/common-logic/calculateClauses.test.d.ts +2 -0
  63. package/lib/common-logic/calculateClauses.test.d.ts.map +1 -0
  64. package/lib/common-logic/calculateClauses.test.js +156 -0
  65. package/lib/common-logic/calculateClauses.test.js.map +1 -0
  66. package/lib/common-logic/calculateGasFees.d.ts +9 -0
  67. package/lib/common-logic/calculateGasFees.d.ts.map +1 -0
  68. package/lib/common-logic/calculateGasFees.js +39 -0
  69. package/lib/common-logic/calculateGasFees.js.map +1 -0
  70. package/lib/common-logic/calculateGasFees.test.d.ts +2 -0
  71. package/lib/common-logic/calculateGasFees.test.d.ts.map +1 -0
  72. package/lib/common-logic/calculateGasFees.test.js +279 -0
  73. package/lib/common-logic/calculateGasFees.test.js.map +1 -0
  74. package/lib/common-logic/calculateTransactionInfo.d.ts +10 -0
  75. package/lib/common-logic/calculateTransactionInfo.d.ts.map +1 -0
  76. package/lib/common-logic/calculateTransactionInfo.js +81 -0
  77. package/lib/common-logic/calculateTransactionInfo.js.map +1 -0
  78. package/lib/common-logic/calculateTransactionInfo.test.d.ts +2 -0
  79. package/lib/common-logic/calculateTransactionInfo.test.d.ts.map +1 -0
  80. package/lib/common-logic/calculateTransactionInfo.test.js +314 -0
  81. package/lib/common-logic/calculateTransactionInfo.test.js.map +1 -0
  82. package/lib/common-logic/estimateGas.d.ts +10 -0
  83. package/lib/common-logic/estimateGas.d.ts.map +1 -0
  84. package/lib/common-logic/estimateGas.js +17 -0
  85. package/lib/common-logic/estimateGas.js.map +1 -0
  86. package/lib/common-logic/estimateGas.test.d.ts +2 -0
  87. package/lib/common-logic/estimateGas.test.d.ts.map +1 -0
  88. package/lib/common-logic/estimateGas.test.js +129 -0
  89. package/lib/common-logic/estimateGas.test.js.map +1 -0
  90. package/lib/common-logic/fixPrefixCase.d.ts +2 -0
  91. package/lib/common-logic/fixPrefixCase.d.ts.map +1 -0
  92. package/lib/common-logic/fixPrefixCase.js +9 -0
  93. package/lib/common-logic/fixPrefixCase.js.map +1 -0
  94. package/lib/common-logic/fixPrefixCase.test.d.ts +2 -0
  95. package/lib/common-logic/fixPrefixCase.test.d.ts.map +1 -0
  96. package/lib/common-logic/fixPrefixCase.test.js +46 -0
  97. package/lib/common-logic/fixPrefixCase.test.js.map +1 -0
  98. package/lib/common-logic/generateNonce.d.ts +6 -0
  99. package/lib/common-logic/generateNonce.d.ts.map +1 -0
  100. package/lib/common-logic/generateNonce.js +13 -0
  101. package/lib/common-logic/generateNonce.js.map +1 -0
  102. package/lib/common-logic/generateNonce.test.d.ts +2 -0
  103. package/lib/common-logic/generateNonce.test.d.ts.map +1 -0
  104. package/lib/common-logic/generateNonce.test.js +59 -0
  105. package/lib/common-logic/generateNonce.test.js.map +1 -0
  106. package/lib/common-logic/getThorClient.d.ts +7 -0
  107. package/lib/common-logic/getThorClient.d.ts.map +1 -0
  108. package/lib/common-logic/getThorClient.js +14 -0
  109. package/lib/common-logic/getThorClient.js.map +1 -0
  110. package/lib/common-logic/getThorClient.test.d.ts +2 -0
  111. package/lib/common-logic/getThorClient.test.d.ts.map +1 -0
  112. package/lib/common-logic/getThorClient.test.js +53 -0
  113. package/lib/common-logic/getThorClient.test.js.map +1 -0
  114. package/lib/common-logic/index.d.ts +8 -6
  115. package/lib/common-logic/index.d.ts.map +1 -1
  116. package/lib/common-logic/index.js +8 -6
  117. package/lib/common-logic/index.js.map +1 -1
  118. package/lib/common-logic/{mapping-utils.d.ts → mapTransfersToOperations.d.ts} +2 -2
  119. package/lib/common-logic/mapTransfersToOperations.d.ts.map +1 -0
  120. package/lib/common-logic/{mapping-utils.js → mapTransfersToOperations.js} +26 -19
  121. package/lib/common-logic/mapTransfersToOperations.js.map +1 -0
  122. package/lib/common-logic/mapTransfersToOperations.test.d.ts +2 -0
  123. package/lib/common-logic/mapTransfersToOperations.test.d.ts.map +1 -0
  124. package/lib/common-logic/mapTransfersToOperations.test.js +274 -0
  125. package/lib/common-logic/mapTransfersToOperations.test.js.map +1 -0
  126. package/lib/common-logic/{pad-address.d.ts → padAddress.d.ts} +1 -1
  127. package/lib/common-logic/padAddress.d.ts.map +1 -0
  128. package/lib/common-logic/{pad-address.js → padAddress.js} +1 -1
  129. package/lib/common-logic/padAddress.js.map +1 -0
  130. package/lib/common-logic/padAddress.test.d.ts +2 -0
  131. package/lib/common-logic/padAddress.test.d.ts.map +1 -0
  132. package/lib/common-logic/padAddress.test.js +59 -0
  133. package/lib/common-logic/padAddress.test.js.map +1 -0
  134. package/lib/common-logic/parseAddress.d.ts +7 -0
  135. package/lib/common-logic/parseAddress.d.ts.map +1 -0
  136. package/lib/common-logic/parseAddress.js +15 -0
  137. package/lib/common-logic/parseAddress.js.map +1 -0
  138. package/lib/common-logic/parseAddress.test.d.ts +2 -0
  139. package/lib/common-logic/parseAddress.test.d.ts.map +1 -0
  140. package/lib/common-logic/parseAddress.test.js +97 -0
  141. package/lib/common-logic/parseAddress.test.js.map +1 -0
  142. package/lib/constants/env.d.ts +2 -0
  143. package/lib/constants/env.d.ts.map +1 -0
  144. package/lib/constants/env.js +6 -0
  145. package/lib/constants/env.js.map +1 -0
  146. package/lib/constants/index.d.ts +2 -0
  147. package/lib/constants/index.d.ts.map +1 -0
  148. package/lib/constants/index.js +18 -0
  149. package/lib/constants/index.js.map +1 -0
  150. package/lib/network/sdk.d.ts +3 -10
  151. package/lib/network/sdk.d.ts.map +1 -1
  152. package/lib/network/sdk.js +15 -30
  153. package/lib/network/sdk.js.map +1 -1
  154. package/lib/signer/getAddress.test.d.ts +2 -0
  155. package/lib/signer/getAddress.test.d.ts.map +1 -0
  156. package/lib/signer/getAddress.test.js +357 -0
  157. package/lib/signer/getAddress.test.js.map +1 -0
  158. package/lib/signer/signMessage.d.ts.map +1 -1
  159. package/lib/signer/signMessage.js +3 -3
  160. package/lib/signer/signMessage.js.map +1 -1
  161. package/lib/signer/signMessage.test.d.ts +2 -0
  162. package/lib/signer/signMessage.test.d.ts.map +1 -0
  163. package/lib/signer/signMessage.test.js +242 -0
  164. package/lib/signer/signMessage.test.js.map +1 -0
  165. package/lib/test/bridgeDatasetTest.d.ts.map +1 -1
  166. package/lib/test/bridgeDatasetTest.js +79 -53
  167. package/lib/test/bridgeDatasetTest.js.map +1 -1
  168. package/lib/test/cli.d.ts.map +1 -1
  169. package/lib/test/cli.js +5 -4
  170. package/lib/test/cli.js.map +1 -1
  171. package/lib/types/bridge.d.ts +11 -3
  172. package/lib/types/bridge.d.ts.map +1 -1
  173. package/lib/types/bridge.js +3 -0
  174. package/lib/types/bridge.js.map +1 -1
  175. package/lib/types/constants.d.ts +0 -3
  176. package/lib/types/constants.d.ts.map +1 -1
  177. package/lib/types/constants.js +1 -4
  178. package/lib/types/constants.js.map +1 -1
  179. package/lib/types/signer.d.ts +0 -2
  180. package/lib/types/signer.d.ts.map +1 -1
  181. package/lib-es/bridge/broadcast.d.ts.map +1 -1
  182. package/lib-es/bridge/broadcast.js +2 -3
  183. package/lib-es/bridge/broadcast.js.map +1 -1
  184. package/lib-es/bridge/broadcast.test.d.ts +2 -0
  185. package/lib-es/bridge/broadcast.test.d.ts.map +1 -0
  186. package/lib-es/bridge/broadcast.test.js +183 -0
  187. package/lib-es/bridge/broadcast.test.js.map +1 -0
  188. package/lib-es/bridge/buildOptimisticOperatioin.test.d.ts +2 -0
  189. package/lib-es/bridge/buildOptimisticOperatioin.test.d.ts.map +1 -0
  190. package/lib-es/bridge/buildOptimisticOperatioin.test.js +281 -0
  191. package/lib-es/bridge/buildOptimisticOperatioin.test.js.map +1 -0
  192. package/lib-es/bridge/createTransaction.d.ts.map +1 -1
  193. package/lib-es/bridge/createTransaction.js +3 -2
  194. package/lib-es/bridge/createTransaction.js.map +1 -1
  195. package/lib-es/bridge/createTransaction.test.d.ts +2 -0
  196. package/lib-es/bridge/createTransaction.test.d.ts.map +1 -0
  197. package/lib-es/bridge/createTransaction.test.js +162 -0
  198. package/lib-es/bridge/createTransaction.test.js.map +1 -0
  199. package/lib-es/bridge/estimateMaxSpendable.test.d.ts +2 -0
  200. package/lib-es/bridge/estimateMaxSpendable.test.d.ts.map +1 -0
  201. package/lib-es/bridge/estimateMaxSpendable.test.js +264 -0
  202. package/lib-es/bridge/estimateMaxSpendable.test.js.map +1 -0
  203. package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -1
  204. package/lib-es/bridge/getTransactionStatus.js +4 -2
  205. package/lib-es/bridge/getTransactionStatus.js.map +1 -1
  206. package/lib-es/bridge/getTransactionStatus.test.d.ts +2 -0
  207. package/lib-es/bridge/getTransactionStatus.test.d.ts.map +1 -0
  208. package/lib-es/bridge/getTransactionStatus.test.js +277 -0
  209. package/lib-es/bridge/getTransactionStatus.test.js.map +1 -0
  210. package/lib-es/bridge/helpers.test.d.ts +2 -0
  211. package/lib-es/bridge/helpers.test.d.ts.map +1 -0
  212. package/lib-es/bridge/helpers.test.js +293 -0
  213. package/lib-es/bridge/helpers.test.js.map +1 -0
  214. package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
  215. package/lib-es/bridge/prepareTransaction.js +11 -4
  216. package/lib-es/bridge/prepareTransaction.js.map +1 -1
  217. package/lib-es/bridge/prepareTransaction.test.d.ts +2 -0
  218. package/lib-es/bridge/prepareTransaction.test.d.ts.map +1 -0
  219. package/lib-es/bridge/prepareTransaction.test.js +272 -0
  220. package/lib-es/bridge/prepareTransaction.test.js.map +1 -0
  221. package/lib-es/bridge/signOperation.d.ts.map +1 -1
  222. package/lib-es/bridge/signOperation.js +3 -3
  223. package/lib-es/bridge/signOperation.js.map +1 -1
  224. package/lib-es/bridge/signOperation.test.d.ts +2 -0
  225. package/lib-es/bridge/signOperation.test.d.ts.map +1 -0
  226. package/lib-es/bridge/signOperation.test.js +290 -0
  227. package/lib-es/bridge/signOperation.test.js.map +1 -0
  228. package/lib-es/bridge/synchronisation.d.ts.map +1 -1
  229. package/lib-es/bridge/synchronisation.js +1 -1
  230. package/lib-es/bridge/synchronisation.js.map +1 -1
  231. package/lib-es/bridge/transaction.test.d.ts +2 -0
  232. package/lib-es/bridge/transaction.test.d.ts.map +1 -0
  233. package/lib-es/bridge/transaction.test.js +347 -0
  234. package/lib-es/bridge/transaction.test.js.map +1 -0
  235. package/lib-es/common-logic/calculateClauses.d.ts +5 -0
  236. package/lib-es/common-logic/calculateClauses.d.ts.map +1 -0
  237. package/lib-es/common-logic/{logic.js → calculateClauses.js} +6 -6
  238. package/lib-es/common-logic/calculateClauses.js.map +1 -0
  239. package/lib-es/common-logic/calculateClauses.test.d.ts +2 -0
  240. package/lib-es/common-logic/calculateClauses.test.d.ts.map +1 -0
  241. package/lib-es/common-logic/calculateClauses.test.js +151 -0
  242. package/lib-es/common-logic/calculateClauses.test.js.map +1 -0
  243. package/lib-es/common-logic/calculateGasFees.d.ts +9 -0
  244. package/lib-es/common-logic/calculateGasFees.d.ts.map +1 -0
  245. package/lib-es/common-logic/calculateGasFees.js +32 -0
  246. package/lib-es/common-logic/calculateGasFees.js.map +1 -0
  247. package/lib-es/common-logic/calculateGasFees.test.d.ts +2 -0
  248. package/lib-es/common-logic/calculateGasFees.test.d.ts.map +1 -0
  249. package/lib-es/common-logic/calculateGasFees.test.js +274 -0
  250. package/lib-es/common-logic/calculateGasFees.test.js.map +1 -0
  251. package/lib-es/common-logic/calculateTransactionInfo.d.ts +10 -0
  252. package/lib-es/common-logic/calculateTransactionInfo.d.ts.map +1 -0
  253. package/lib-es/common-logic/calculateTransactionInfo.js +74 -0
  254. package/lib-es/common-logic/calculateTransactionInfo.js.map +1 -0
  255. package/lib-es/common-logic/calculateTransactionInfo.test.d.ts +2 -0
  256. package/lib-es/common-logic/calculateTransactionInfo.test.d.ts.map +1 -0
  257. package/lib-es/common-logic/calculateTransactionInfo.test.js +309 -0
  258. package/lib-es/common-logic/calculateTransactionInfo.test.js.map +1 -0
  259. package/lib-es/common-logic/estimateGas.d.ts +10 -0
  260. package/lib-es/common-logic/estimateGas.d.ts.map +1 -0
  261. package/lib-es/common-logic/estimateGas.js +13 -0
  262. package/lib-es/common-logic/estimateGas.js.map +1 -0
  263. package/lib-es/common-logic/estimateGas.test.d.ts +2 -0
  264. package/lib-es/common-logic/estimateGas.test.d.ts.map +1 -0
  265. package/lib-es/common-logic/estimateGas.test.js +127 -0
  266. package/lib-es/common-logic/estimateGas.test.js.map +1 -0
  267. package/lib-es/common-logic/fixPrefixCase.d.ts +2 -0
  268. package/lib-es/common-logic/fixPrefixCase.d.ts.map +1 -0
  269. package/lib-es/common-logic/fixPrefixCase.js +5 -0
  270. package/lib-es/common-logic/fixPrefixCase.js.map +1 -0
  271. package/lib-es/common-logic/fixPrefixCase.test.d.ts +2 -0
  272. package/lib-es/common-logic/fixPrefixCase.test.d.ts.map +1 -0
  273. package/lib-es/common-logic/fixPrefixCase.test.js +44 -0
  274. package/lib-es/common-logic/fixPrefixCase.test.js.map +1 -0
  275. package/lib-es/common-logic/generateNonce.d.ts +6 -0
  276. package/lib-es/common-logic/generateNonce.d.ts.map +1 -0
  277. package/lib-es/common-logic/generateNonce.js +9 -0
  278. package/lib-es/common-logic/generateNonce.js.map +1 -0
  279. package/lib-es/common-logic/generateNonce.test.d.ts +2 -0
  280. package/lib-es/common-logic/generateNonce.test.d.ts.map +1 -0
  281. package/lib-es/common-logic/generateNonce.test.js +57 -0
  282. package/lib-es/common-logic/generateNonce.test.js.map +1 -0
  283. package/lib-es/common-logic/getThorClient.d.ts +7 -0
  284. package/lib-es/common-logic/getThorClient.d.ts.map +1 -0
  285. package/lib-es/common-logic/getThorClient.js +10 -0
  286. package/lib-es/common-logic/getThorClient.js.map +1 -0
  287. package/lib-es/common-logic/getThorClient.test.d.ts +2 -0
  288. package/lib-es/common-logic/getThorClient.test.d.ts.map +1 -0
  289. package/lib-es/common-logic/getThorClient.test.js +51 -0
  290. package/lib-es/common-logic/getThorClient.test.js.map +1 -0
  291. package/lib-es/common-logic/index.d.ts +8 -6
  292. package/lib-es/common-logic/index.d.ts.map +1 -1
  293. package/lib-es/common-logic/index.js +8 -6
  294. package/lib-es/common-logic/index.js.map +1 -1
  295. package/lib-es/common-logic/{mapping-utils.d.ts → mapTransfersToOperations.d.ts} +2 -2
  296. package/lib-es/common-logic/mapTransfersToOperations.d.ts.map +1 -0
  297. package/lib-es/common-logic/mapTransfersToOperations.js +51 -0
  298. package/lib-es/common-logic/mapTransfersToOperations.js.map +1 -0
  299. package/lib-es/common-logic/mapTransfersToOperations.test.d.ts +2 -0
  300. package/lib-es/common-logic/mapTransfersToOperations.test.d.ts.map +1 -0
  301. package/lib-es/common-logic/mapTransfersToOperations.test.js +269 -0
  302. package/lib-es/common-logic/mapTransfersToOperations.test.js.map +1 -0
  303. package/lib-es/common-logic/{pad-address.d.ts → padAddress.d.ts} +1 -1
  304. package/lib-es/common-logic/padAddress.d.ts.map +1 -0
  305. package/lib-es/common-logic/{pad-address.js → padAddress.js} +1 -1
  306. package/lib-es/common-logic/padAddress.js.map +1 -0
  307. package/lib-es/common-logic/padAddress.test.d.ts +2 -0
  308. package/lib-es/common-logic/padAddress.test.d.ts.map +1 -0
  309. package/lib-es/common-logic/padAddress.test.js +57 -0
  310. package/lib-es/common-logic/padAddress.test.js.map +1 -0
  311. package/lib-es/common-logic/parseAddress.d.ts +7 -0
  312. package/lib-es/common-logic/parseAddress.d.ts.map +1 -0
  313. package/lib-es/common-logic/parseAddress.js +11 -0
  314. package/lib-es/common-logic/parseAddress.js.map +1 -0
  315. package/lib-es/common-logic/parseAddress.test.d.ts +2 -0
  316. package/lib-es/common-logic/parseAddress.test.d.ts.map +1 -0
  317. package/lib-es/common-logic/parseAddress.test.js +95 -0
  318. package/lib-es/common-logic/parseAddress.test.js.map +1 -0
  319. package/lib-es/constants/env.d.ts +2 -0
  320. package/lib-es/constants/env.d.ts.map +1 -0
  321. package/lib-es/constants/env.js +3 -0
  322. package/lib-es/constants/env.js.map +1 -0
  323. package/lib-es/constants/index.d.ts +2 -0
  324. package/lib-es/constants/index.d.ts.map +1 -0
  325. package/lib-es/constants/index.js +2 -0
  326. package/lib-es/constants/index.js.map +1 -0
  327. package/lib-es/network/sdk.d.ts +3 -10
  328. package/lib-es/network/sdk.d.ts.map +1 -1
  329. package/lib-es/network/sdk.js +5 -19
  330. package/lib-es/network/sdk.js.map +1 -1
  331. package/lib-es/signer/getAddress.test.d.ts +2 -0
  332. package/lib-es/signer/getAddress.test.d.ts.map +1 -0
  333. package/lib-es/signer/getAddress.test.js +352 -0
  334. package/lib-es/signer/getAddress.test.js.map +1 -0
  335. package/lib-es/signer/signMessage.d.ts.map +1 -1
  336. package/lib-es/signer/signMessage.js +3 -3
  337. package/lib-es/signer/signMessage.js.map +1 -1
  338. package/lib-es/signer/signMessage.test.d.ts +2 -0
  339. package/lib-es/signer/signMessage.test.d.ts.map +1 -0
  340. package/lib-es/signer/signMessage.test.js +240 -0
  341. package/lib-es/signer/signMessage.test.js.map +1 -0
  342. package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -1
  343. package/lib-es/test/bridgeDatasetTest.js +80 -54
  344. package/lib-es/test/bridgeDatasetTest.js.map +1 -1
  345. package/lib-es/test/cli.d.ts.map +1 -1
  346. package/lib-es/test/cli.js +4 -3
  347. package/lib-es/test/cli.js.map +1 -1
  348. package/lib-es/types/bridge.d.ts +11 -3
  349. package/lib-es/types/bridge.d.ts.map +1 -1
  350. package/lib-es/types/bridge.js +6 -1
  351. package/lib-es/types/bridge.js.map +1 -1
  352. package/lib-es/types/constants.d.ts +0 -3
  353. package/lib-es/types/constants.d.ts.map +1 -1
  354. package/lib-es/types/constants.js +0 -3
  355. package/lib-es/types/constants.js.map +1 -1
  356. package/lib-es/types/signer.d.ts +0 -2
  357. package/lib-es/types/signer.d.ts.map +1 -1
  358. package/package.json +8 -7
  359. package/src/bridge/broadcast.test.ts +236 -0
  360. package/src/bridge/broadcast.ts +4 -5
  361. package/src/bridge/buildOptimisticOperatioin.test.ts +364 -0
  362. package/src/bridge/createTransaction.test.ts +201 -0
  363. package/src/bridge/createTransaction.ts +3 -2
  364. package/src/bridge/estimateMaxSpendable.test.ts +319 -0
  365. package/src/bridge/getTransactionStatus.test.ts +353 -0
  366. package/src/bridge/getTransactionStatus.ts +4 -2
  367. package/src/bridge/helpers.test.ts +356 -0
  368. package/src/bridge/prepareTransaction.test.ts +345 -0
  369. package/src/bridge/prepareTransaction.ts +20 -10
  370. package/src/bridge/signOperation.test.ts +354 -0
  371. package/src/bridge/signOperation.ts +6 -3
  372. package/src/bridge/synchronisation.ts +1 -1
  373. package/src/bridge/transaction.test.ts +440 -0
  374. package/src/common-logic/calculateClauses.test.ts +186 -0
  375. package/src/common-logic/calculateClauses.ts +44 -0
  376. package/src/common-logic/calculateGasFees.test.ts +363 -0
  377. package/src/common-logic/calculateGasFees.ts +45 -0
  378. package/src/common-logic/calculateTransactionInfo.test.ts +396 -0
  379. package/src/common-logic/calculateTransactionInfo.ts +96 -0
  380. package/src/common-logic/estimateGas.test.ts +162 -0
  381. package/src/common-logic/estimateGas.ts +18 -0
  382. package/src/common-logic/fixPrefixCase.test.ts +51 -0
  383. package/src/common-logic/fixPrefixCase.ts +5 -0
  384. package/src/common-logic/generateNonce.test.ts +72 -0
  385. package/src/common-logic/generateNonce.ts +9 -0
  386. package/src/common-logic/getThorClient.test.ts +66 -0
  387. package/src/common-logic/getThorClient.ts +10 -0
  388. package/src/common-logic/index.ts +8 -6
  389. package/src/common-logic/mapTransfersToOperations.test.ts +342 -0
  390. package/src/common-logic/mapTransfersToOperations.ts +77 -0
  391. package/src/common-logic/padAddress.test.ts +65 -0
  392. package/src/common-logic/parseAddress.test.ts +130 -0
  393. package/src/common-logic/parseAddress.ts +11 -0
  394. package/src/constants/env.ts +3 -0
  395. package/src/constants/index.ts +1 -0
  396. package/src/network/sdk.ts +22 -30
  397. package/src/signer/getAddress.test.ts +454 -0
  398. package/src/signer/signMessage.test.ts +329 -0
  399. package/src/signer/signMessage.ts +4 -5
  400. package/src/test/bridgeDatasetTest.ts +86 -58
  401. package/src/test/cli.ts +4 -3
  402. package/src/types/bridge.ts +16 -3
  403. package/src/types/constants.ts +0 -3
  404. package/lib/common-logic/address-utils.d.ts +0 -2
  405. package/lib/common-logic/address-utils.d.ts.map +0 -1
  406. package/lib/common-logic/address-utils.js +0 -19
  407. package/lib/common-logic/address-utils.js.map +0 -1
  408. package/lib/common-logic/hex-utils.d.ts +0 -8
  409. package/lib/common-logic/hex-utils.d.ts.map +0 -1
  410. package/lib/common-logic/hex-utils.js +0 -52
  411. package/lib/common-logic/hex-utils.js.map +0 -1
  412. package/lib/common-logic/logic.d.ts +0 -5
  413. package/lib/common-logic/logic.d.ts.map +0 -1
  414. package/lib/common-logic/logic.js.map +0 -1
  415. package/lib/common-logic/mapping-utils.d.ts.map +0 -1
  416. package/lib/common-logic/mapping-utils.js.map +0 -1
  417. package/lib/common-logic/pad-address.d.ts.map +0 -1
  418. package/lib/common-logic/pad-address.js.map +0 -1
  419. package/lib/common-logic/transaction-utils.d.ts +0 -30
  420. package/lib/common-logic/transaction-utils.d.ts.map +0 -1
  421. package/lib/common-logic/transaction-utils.js +0 -161
  422. package/lib/common-logic/transaction-utils.js.map +0 -1
  423. package/lib/contracts/abis/VIP180.d.ts +0 -17
  424. package/lib/contracts/abis/VIP180.d.ts.map +0 -1
  425. package/lib/contracts/abis/VIP180.js +0 -265
  426. package/lib/contracts/abis/VIP180.js.map +0 -1
  427. package/lib/contracts/abis/params.d.ts +0 -8
  428. package/lib/contracts/abis/params.d.ts.map +0 -1
  429. package/lib/contracts/abis/params.js +0 -69
  430. package/lib/contracts/abis/params.js.map +0 -1
  431. package/lib/contracts/constants.d.ts +0 -6
  432. package/lib/contracts/constants.d.ts.map +0 -1
  433. package/lib/contracts/constants.js +0 -10
  434. package/lib/contracts/constants.js.map +0 -1
  435. package/lib-es/common-logic/address-utils.d.ts +0 -2
  436. package/lib-es/common-logic/address-utils.d.ts.map +0 -1
  437. package/lib-es/common-logic/address-utils.js +0 -12
  438. package/lib-es/common-logic/address-utils.js.map +0 -1
  439. package/lib-es/common-logic/hex-utils.d.ts +0 -8
  440. package/lib-es/common-logic/hex-utils.d.ts.map +0 -1
  441. package/lib-es/common-logic/hex-utils.js +0 -50
  442. package/lib-es/common-logic/hex-utils.js.map +0 -1
  443. package/lib-es/common-logic/logic.d.ts +0 -5
  444. package/lib-es/common-logic/logic.d.ts.map +0 -1
  445. package/lib-es/common-logic/logic.js.map +0 -1
  446. package/lib-es/common-logic/mapping-utils.d.ts.map +0 -1
  447. package/lib-es/common-logic/mapping-utils.js +0 -44
  448. package/lib-es/common-logic/mapping-utils.js.map +0 -1
  449. package/lib-es/common-logic/pad-address.d.ts.map +0 -1
  450. package/lib-es/common-logic/pad-address.js.map +0 -1
  451. package/lib-es/common-logic/transaction-utils.d.ts +0 -30
  452. package/lib-es/common-logic/transaction-utils.d.ts.map +0 -1
  453. package/lib-es/common-logic/transaction-utils.js +0 -150
  454. package/lib-es/common-logic/transaction-utils.js.map +0 -1
  455. package/lib-es/contracts/abis/VIP180.d.ts +0 -17
  456. package/lib-es/contracts/abis/VIP180.d.ts.map +0 -1
  457. package/lib-es/contracts/abis/VIP180.js +0 -263
  458. package/lib-es/contracts/abis/VIP180.js.map +0 -1
  459. package/lib-es/contracts/abis/params.d.ts +0 -8
  460. package/lib-es/contracts/abis/params.d.ts.map +0 -1
  461. package/lib-es/contracts/abis/params.js +0 -67
  462. package/lib-es/contracts/abis/params.js.map +0 -1
  463. package/lib-es/contracts/constants.d.ts +0 -6
  464. package/lib-es/contracts/constants.d.ts.map +0 -1
  465. package/lib-es/contracts/constants.js +0 -7
  466. package/lib-es/contracts/constants.js.map +0 -1
  467. package/src/common-logic/address-utils.ts +0 -11
  468. package/src/common-logic/hex-utils.ts +0 -53
  469. package/src/common-logic/logic.ts +0 -44
  470. package/src/common-logic/mapping-utils.ts +0 -67
  471. package/src/common-logic/transaction-utils.ts +0 -190
  472. package/src/contracts/abis/VIP180.ts +0 -265
  473. package/src/contracts/abis/params.ts +0 -70
  474. package/src/contracts/constants.ts +0 -11
  475. /package/src/common-logic/{pad-address.ts → padAddress.ts} +0 -0
@@ -0,0 +1,329 @@
1
+ import { signMessage } from "./signMessage";
2
+ import { VechainSDKTransaction, VechainSigner } from "../types";
3
+ import { SignerContext } from "@ledgerhq/coin-framework/signer";
4
+
5
+ // Mock dependencies
6
+ jest.mock("../types", () => ({
7
+ ...jest.requireActual("../types"),
8
+ VechainSDKTransaction: {
9
+ of: jest.fn(),
10
+ },
11
+ }));
12
+
13
+ const mockedVechainSDKTransaction = jest.mocked(VechainSDKTransaction);
14
+
15
+ describe("signMessage", () => {
16
+ const mockDeviceId = "mock-device-id";
17
+ const mockPath = "44'/818'/0'/0/0";
18
+
19
+ const mockSigner: VechainSigner = {
20
+ getAddress: jest.fn(),
21
+ signTransaction: jest.fn(),
22
+ };
23
+
24
+ const mockSignerContext: SignerContext<VechainSigner> = jest.fn();
25
+
26
+ const mockTransactionObject = {
27
+ chainTag: 74,
28
+ blockRef: "0x00000000000b2bce",
29
+ expiration: 18,
30
+ clauses: [
31
+ {
32
+ to: "0x456789012345678901234567890123456789abcd",
33
+ value: "1000000000000000000",
34
+ data: "0x",
35
+ },
36
+ ],
37
+ maxFeePerGas: 10000000000000,
38
+ maxPriorityFeePerGas: 1000000000000,
39
+ gas: 21000,
40
+ dependsOn: null,
41
+ nonce: "0x12345678",
42
+ };
43
+
44
+ const mockUnsignedTransaction = {
45
+ encoded: Buffer.from("mockencodedtransaction", "hex"),
46
+ };
47
+
48
+ beforeEach(() => {
49
+ jest.clearAllMocks();
50
+ mockedVechainSDKTransaction.of.mockReturnValue(mockUnsignedTransaction as any);
51
+ (mockSigner.signTransaction as jest.Mock).mockResolvedValue(Buffer.from("signature123", "hex"));
52
+ (mockSignerContext as jest.Mock).mockImplementation((deviceId, callback) =>
53
+ callback(mockSigner),
54
+ );
55
+ });
56
+
57
+ describe("message parsing", () => {
58
+ it("should parse valid JSON message", async () => {
59
+ const message = JSON.stringify(mockTransactionObject);
60
+ const signMessageFn = signMessage(mockSignerContext);
61
+
62
+ const result = await signMessageFn(mockDeviceId, mockPath, message, "");
63
+
64
+ // JSON parsing is handled internally by the function
65
+ expect(mockedVechainSDKTransaction.of).toHaveBeenCalledWith(mockTransactionObject);
66
+ expect(result).toBe("");
67
+ });
68
+
69
+ it("should parse valid JSON rawMessage when message is empty", async () => {
70
+ const rawMessage = JSON.stringify(mockTransactionObject);
71
+ const signMessageFn = signMessage(mockSignerContext);
72
+
73
+ const result = await signMessageFn(mockDeviceId, mockPath, "", rawMessage);
74
+
75
+ expect(mockedVechainSDKTransaction.of).toHaveBeenCalledWith(mockTransactionObject);
76
+ expect(result).toBe("");
77
+ });
78
+
79
+ it("should prefer message over rawMessage when both are provided", async () => {
80
+ const message = JSON.stringify(mockTransactionObject);
81
+ const differentRawMessage = JSON.stringify({ different: "object" });
82
+ const signMessageFn = signMessage(mockSignerContext);
83
+
84
+ await signMessageFn(mockDeviceId, mockPath, message, differentRawMessage);
85
+
86
+ expect(mockedVechainSDKTransaction.of).toHaveBeenCalledWith(mockTransactionObject);
87
+ });
88
+
89
+ it("should throw error for invalid JSON message", async () => {
90
+ const invalidMessage = "invalid json {";
91
+ const signMessageFn = signMessage(mockSignerContext);
92
+
93
+ await expect(signMessageFn(mockDeviceId, mockPath, invalidMessage, "")).rejects.toThrow(
94
+ "Message is not a valid JSON object",
95
+ );
96
+ });
97
+
98
+ it("should throw error for invalid JSON rawMessage", async () => {
99
+ const invalidRawMessage = "invalid json {";
100
+ const signMessageFn = signMessage(mockSignerContext);
101
+
102
+ await expect(signMessageFn(mockDeviceId, mockPath, "", invalidRawMessage)).rejects.toThrow(
103
+ "Message is not a valid JSON object",
104
+ );
105
+ });
106
+
107
+ it("should throw error when both message and rawMessage are empty", async () => {
108
+ const signMessageFn = signMessage(mockSignerContext);
109
+
110
+ await expect(signMessageFn(mockDeviceId, mockPath, "", "")).rejects.toThrow(
111
+ "Message is not a valid JSON object",
112
+ );
113
+ });
114
+ });
115
+
116
+ describe("transaction creation", () => {
117
+ it("should create VechainSDKTransaction from parsed object", async () => {
118
+ const message = JSON.stringify(mockTransactionObject);
119
+ const signMessageFn = signMessage(mockSignerContext);
120
+
121
+ await signMessageFn(mockDeviceId, mockPath, message, "");
122
+
123
+ expect(mockedVechainSDKTransaction.of).toHaveBeenCalledWith(mockTransactionObject);
124
+ });
125
+
126
+ it("should handle VechainSDKTransaction creation errors", async () => {
127
+ const message = JSON.stringify(mockTransactionObject);
128
+ const signMessageFn = signMessage(mockSignerContext);
129
+
130
+ mockedVechainSDKTransaction.of.mockImplementation(() => {
131
+ throw new Error("Invalid transaction");
132
+ });
133
+
134
+ await expect(signMessageFn(mockDeviceId, mockPath, message, "")).rejects.toThrow(
135
+ "Message is not a valid JSON object",
136
+ );
137
+ });
138
+
139
+ it("should handle different transaction structures", async () => {
140
+ const tokenTransaction = {
141
+ ...mockTransactionObject,
142
+ clauses: [
143
+ {
144
+ to: "0x0000000000000000000000000000456e65726779",
145
+ value: "0",
146
+ data: "0xa9059cbb000000000000000000000000456789012345678901234567890123456789abcd0000000000000000000000000000000000000000000000000de0b6b3a7640000",
147
+ },
148
+ ],
149
+ };
150
+
151
+ const message = JSON.stringify(tokenTransaction);
152
+ const signMessageFn = signMessage(mockSignerContext);
153
+
154
+ await signMessageFn(mockDeviceId, mockPath, message, "");
155
+
156
+ expect(mockedVechainSDKTransaction.of).toHaveBeenCalledWith(tokenTransaction);
157
+ });
158
+ });
159
+
160
+ describe("signing process", () => {
161
+ it("should call signer with correct parameters", async () => {
162
+ const message = JSON.stringify(mockTransactionObject);
163
+ const signMessageFn = signMessage(mockSignerContext);
164
+
165
+ await signMessageFn(mockDeviceId, mockPath, message, "");
166
+
167
+ expect(mockSignerContext).toHaveBeenCalledWith(mockDeviceId, expect.any(Function));
168
+ expect(mockSigner.signTransaction).toHaveBeenCalledWith(
169
+ mockPath,
170
+ mockUnsignedTransaction.encoded.toString("hex"),
171
+ );
172
+ });
173
+
174
+ it("should convert encoded transaction to hex string", async () => {
175
+ const customEncoded = Buffer.from("customtransaction", "utf8");
176
+ const customUnsigned = { encoded: customEncoded };
177
+ mockedVechainSDKTransaction.of.mockReturnValue(customUnsigned as any);
178
+
179
+ const message = JSON.stringify(mockTransactionObject);
180
+ const signMessageFn = signMessage(mockSignerContext);
181
+
182
+ await signMessageFn(mockDeviceId, mockPath, message, "");
183
+
184
+ expect(mockSigner.signTransaction).toHaveBeenCalledWith(
185
+ mockPath,
186
+ customEncoded.toString("hex"),
187
+ );
188
+ });
189
+
190
+ it("should return signature as hex string", async () => {
191
+ const signatureBuffer = Buffer.from([0x12, 0x34, 0x56, 0x78]);
192
+ (mockSigner.signTransaction as jest.Mock).mockResolvedValue(signatureBuffer);
193
+
194
+ const message = JSON.stringify(mockTransactionObject);
195
+ const signMessageFn = signMessage(mockSignerContext);
196
+
197
+ const result = await signMessageFn(mockDeviceId, mockPath, message, "");
198
+
199
+ expect(result).toBe("12345678");
200
+ });
201
+
202
+ it("should handle signer errors", async () => {
203
+ const signerError = new Error("Hardware wallet error");
204
+ (mockSigner.signTransaction as jest.Mock).mockRejectedValue(signerError);
205
+
206
+ const message = JSON.stringify(mockTransactionObject);
207
+ const signMessageFn = signMessage(mockSignerContext);
208
+
209
+ await expect(signMessageFn(mockDeviceId, mockPath, message, "")).rejects.toThrow(
210
+ "Hardware wallet error",
211
+ );
212
+ });
213
+
214
+ it("should handle signerContext errors", async () => {
215
+ const contextError = new Error("Signer context failed");
216
+ (mockSignerContext as jest.Mock).mockRejectedValue(contextError);
217
+
218
+ const message = JSON.stringify(mockTransactionObject);
219
+ const signMessageFn = signMessage(mockSignerContext);
220
+
221
+ await expect(signMessageFn(mockDeviceId, mockPath, message, "")).rejects.toThrow(
222
+ "Signer context failed",
223
+ );
224
+ });
225
+ });
226
+
227
+ describe("different input scenarios", () => {
228
+ it("should handle different device IDs", async () => {
229
+ const deviceIds = ["device1", "device2", "device3"];
230
+ const message = JSON.stringify(mockTransactionObject);
231
+ const signMessageFn = signMessage(mockSignerContext);
232
+
233
+ for (const deviceId of deviceIds) {
234
+ await signMessageFn(deviceId, mockPath, message, "");
235
+ expect(mockSignerContext).toHaveBeenCalledWith(deviceId, expect.any(Function));
236
+ }
237
+ });
238
+
239
+ it("should handle different derivation paths", async () => {
240
+ const paths = ["44'/818'/0'/0/0", "44'/818'/1'/0/0", "44'/818'/0'/0/1"];
241
+ const message = JSON.stringify(mockTransactionObject);
242
+ const signMessageFn = signMessage(mockSignerContext);
243
+
244
+ for (const path of paths) {
245
+ await signMessageFn(mockDeviceId, path, message, "");
246
+ expect(mockSigner.signTransaction).toHaveBeenCalledWith(path, expect.any(String));
247
+ }
248
+ });
249
+
250
+ it("should handle complex transaction objects", async () => {
251
+ const complexTransaction = {
252
+ ...mockTransactionObject,
253
+ clauses: [
254
+ {
255
+ to: "0x456789012345678901234567890123456789abcd",
256
+ value: "1000000000000000000",
257
+ data: "0x",
258
+ },
259
+ {
260
+ to: "0x0000000000000000000000000000456e65726779",
261
+ value: "0",
262
+ data: "0xa9059cbb",
263
+ },
264
+ ],
265
+ dependsOn: "0xprevious123",
266
+ gas: 50000,
267
+ };
268
+
269
+ const message = JSON.stringify(complexTransaction);
270
+ const signMessageFn = signMessage(mockSignerContext);
271
+
272
+ await signMessageFn(mockDeviceId, mockPath, message, "");
273
+
274
+ expect(mockedVechainSDKTransaction.of).toHaveBeenCalledWith(complexTransaction);
275
+ });
276
+
277
+ it("should handle minimal transaction objects", async () => {
278
+ const minimalTransaction = {
279
+ chainTag: 74,
280
+ blockRef: "0x0000000000000000",
281
+ expiration: 18,
282
+ clauses: [],
283
+ maxFeePerGas: 0,
284
+ maxPriorityFeePerGas: 0,
285
+ gas: 0,
286
+ dependsOn: null,
287
+ nonce: "0x00000000",
288
+ };
289
+
290
+ const message = JSON.stringify(minimalTransaction);
291
+ const signMessageFn = signMessage(mockSignerContext);
292
+
293
+ await signMessageFn(mockDeviceId, mockPath, message, "");
294
+
295
+ expect(mockedVechainSDKTransaction.of).toHaveBeenCalledWith(minimalTransaction);
296
+ });
297
+ });
298
+
299
+ describe("signature formatting", () => {
300
+ it("should handle different signature lengths", async () => {
301
+ const signatures = [
302
+ Buffer.from("12", "hex"),
303
+ Buffer.from("1234567890abcdef", "hex"),
304
+ Buffer.from("ff".repeat(32), "hex"),
305
+ ];
306
+
307
+ const message = JSON.stringify(mockTransactionObject);
308
+ const signMessageFn = signMessage(mockSignerContext);
309
+
310
+ for (const signature of signatures) {
311
+ (mockSigner.signTransaction as jest.Mock).mockResolvedValueOnce(signature);
312
+ const result = await signMessageFn(mockDeviceId, mockPath, message, "");
313
+ expect(result).toBe(signature.toString("hex"));
314
+ }
315
+ });
316
+
317
+ it("should handle empty signature buffer", async () => {
318
+ const emptySignature = Buffer.alloc(0);
319
+ (mockSigner.signTransaction as jest.Mock).mockResolvedValue(emptySignature);
320
+
321
+ const message = JSON.stringify(mockTransactionObject);
322
+ const signMessageFn = signMessage(mockSignerContext);
323
+
324
+ const result = await signMessageFn(mockDeviceId, mockPath, message, "");
325
+
326
+ expect(result).toBe("");
327
+ });
328
+ });
329
+ });
@@ -1,21 +1,20 @@
1
- import { Transaction as ThorTransaction } from "thor-devkit";
2
1
  import { SignerContext } from "@ledgerhq/coin-framework/signer";
3
- import { VechainSigner } from "../types";
2
+ import { VechainSDKTransaction, VechainSigner } from "../types";
4
3
 
5
4
  export const signMessage =
6
5
  (signerContext: SignerContext<VechainSigner>) =>
7
6
  async (deviceId: string, path: string, message: string, rawMessage: string) => {
8
7
  let messageObj;
9
- let unsigned: ThorTransaction;
8
+ let unsigned: VechainSDKTransaction;
10
9
  try {
11
10
  if (message) messageObj = JSON.parse(message);
12
11
  else messageObj = JSON.parse(rawMessage);
13
- unsigned = new ThorTransaction(messageObj);
12
+ unsigned = VechainSDKTransaction.of(messageObj);
14
13
  } catch (e) {
15
14
  throw new Error("Message is not a valid JSON object");
16
15
  }
17
16
  const result = await signerContext(deviceId, signer =>
18
- signer.signTransaction(path, unsigned.encode().toString("hex")),
17
+ signer.signTransaction(path, Buffer.from(unsigned.encoded).toString("hex")),
19
18
  );
20
19
 
21
20
  return result.toString("hex");
@@ -1,14 +1,18 @@
1
1
  import BigNumber from "bignumber.js";
2
- import type { AccountRaw, CurrenciesData, DatasetTest } from "@ledgerhq/types-live";
2
+ import type {
3
+ AccountRaw,
4
+ CurrenciesData,
5
+ DatasetTest,
6
+ TransactionStatusCommon,
7
+ } from "@ledgerhq/types-live";
3
8
  import type { Transaction } from "../types";
4
9
  import { fromTransactionRaw } from "../bridge/transaction";
5
- import { DEFAULT_GAS_COEFFICIENT, MAINNET_CHAIN_TAG } from "../types";
10
+ import { MAINNET_CHAIN_TAG } from "../types";
6
11
  import { vechain1, vechain3 } from "../datasets";
7
12
  import { generateNonce } from "../common-logic";
8
13
 
9
14
  import vechainScanAccounts1 from "../datasets/vechain.scanAccounts.1";
10
15
  import { AmountRequired, NotEnoughBalance } from "@ledgerhq/errors";
11
- import VIP180 from "../contracts/abis/VIP180";
12
16
  import { CryptoCurrencyId } from "@ledgerhq/types-cryptoassets";
13
17
  import { NotEnoughVTHO } from "../errors";
14
18
  import {
@@ -16,6 +20,7 @@ import {
16
20
  setSupportedCurrencies,
17
21
  } from "@ledgerhq/coin-framework/currencies/index";
18
22
  import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
23
+ import { ABIContract, VIP180_ABI } from "@vechain/sdk-core";
19
24
 
20
25
  const listSupported = listSupportedCurrencies();
21
26
  listSupported.push(getCryptoCurrencyById("vechain"));
@@ -36,7 +41,7 @@ const vechain: CurrenciesData<Transaction> = {
36
41
  family: "vechain",
37
42
  estimatedFees: "210000000000000000",
38
43
  recipient: "0xcf130b42ae31c4931298b4b1c0f1d974b8732957",
39
- amount: "1000000000000000000",
44
+ amount: (1e18).toString(), // 1 VET
40
45
  body: {
41
46
  chainTag: MAINNET_CHAIN_TAG,
42
47
  blockRef: "0x00634a0c856ec1db",
@@ -44,22 +49,26 @@ const vechain: CurrenciesData<Transaction> = {
44
49
  clauses: [
45
50
  {
46
51
  to: "0xcf130b42ae31c4931298b4b1c0f1d974b8732957",
47
- value: "1000000000000000000",
52
+ value: (1e18).toString(), // 1 VET
48
53
  data: "0x",
49
54
  },
50
55
  ],
51
- gasPriceCoef: DEFAULT_GAS_COEFFICIENT,
52
56
  gas: "0",
57
+ maxFeePerGas: 0,
58
+ maxPriorityFeePerGas: 0,
53
59
  dependsOn: null,
54
60
  nonce: generateNonce(),
55
61
  },
56
62
  }),
57
- expectedStatus: {
58
- amount: new BigNumber("1000000000000000000"),
59
- estimatedFees: new BigNumber("210000000000000000"),
60
- totalSpent: new BigNumber("1000000000000000000"),
61
- errors: {},
62
- warnings: {},
63
+ expectedStatus: (_account, _, status): Partial<TransactionStatusCommon> => {
64
+ const estimatedFees = status.estimatedFees;
65
+ return {
66
+ amount: new BigNumber(1e18), // 1 VET
67
+ estimatedFees, // fees are calculated during preparation and therefore cannot be guessed without mocks
68
+ totalSpent: new BigNumber(1e18),
69
+ errors: {},
70
+ warnings: {},
71
+ };
63
72
  },
64
73
  },
65
74
  {
@@ -70,7 +79,7 @@ const vechain: CurrenciesData<Transaction> = {
70
79
  "js:2:vechain:0x0fe6688548f0C303932bB197B0A96034f1d74dba:vechain+vechain%2Fvip180%2Fvtho",
71
80
  estimatedFees: "515180000000000000",
72
81
  recipient: "0xcf130b42ae31c4931298b4b1c0f1d974b8732957",
73
- amount: "1000000000000000000",
82
+ amount: (1e19).toString(), // 10 VTHO
74
83
  body: {
75
84
  chainTag: MAINNET_CHAIN_TAG,
76
85
  blockRef: "0x00634a0c856ec1db",
@@ -79,24 +88,30 @@ const vechain: CurrenciesData<Transaction> = {
79
88
  {
80
89
  to: "0x0000000000000000000000000000456e65726779",
81
90
  value: 0,
82
- data: VIP180.transfer.encode(
83
- "0xcf130b42ae31c4931298b4b1c0f1d974b8732957",
84
- "9000000000000000000",
85
- ),
91
+ data: ABIContract.ofAbi(VIP180_ABI)
92
+ .encodeFunctionInput("transfer", [
93
+ "0xcf130b42ae31c4931298b4b1c0f1d974b8732957",
94
+ "9000000000000000000",
95
+ ])
96
+ .toString(),
86
97
  },
87
98
  ],
88
- gasPriceCoef: DEFAULT_GAS_COEFFICIENT,
89
99
  gas: "0",
100
+ maxFeePerGas: 0,
101
+ maxPriorityFeePerGas: 0,
90
102
  dependsOn: null,
91
103
  nonce: generateNonce(),
92
104
  },
93
105
  }),
94
- expectedStatus: {
95
- amount: new BigNumber("1000000000000000000"),
96
- estimatedFees: new BigNumber("515180000000000000"),
97
- totalSpent: new BigNumber("1515180000000000000"),
98
- errors: {},
99
- warnings: {},
106
+ expectedStatus: (_account, _, status): Partial<TransactionStatusCommon> => {
107
+ const estimatedFees = status.estimatedFees;
108
+ return {
109
+ amount: new BigNumber(1e19), // 10 VTHO
110
+ estimatedFees, // fees are calculated during preparation and therefore cannot be guessed without mocks
111
+ totalSpent: new BigNumber(1e19).plus(estimatedFees), // fees are calculated during preparation and therefore cannot be guessed without mocks
112
+ errors: {},
113
+ warnings: {},
114
+ };
100
115
  },
101
116
  },
102
117
  {
@@ -111,8 +126,9 @@ const vechain: CurrenciesData<Transaction> = {
111
126
  blockRef: "0x00634a0c856ec1db",
112
127
  expiration: 18,
113
128
  clauses: [{ to: "", value: 0, data: "0x" }],
114
- gasPriceCoef: DEFAULT_GAS_COEFFICIENT,
115
129
  gas: "0",
130
+ maxFeePerGas: 0,
131
+ maxPriorityFeePerGas: 0,
116
132
  dependsOn: null,
117
133
  nonce: generateNonce(),
118
134
  },
@@ -130,7 +146,7 @@ const vechain: CurrenciesData<Transaction> = {
130
146
  family: "vechain",
131
147
  estimatedFees: "210000000000000000",
132
148
  recipient: "0xcf130b42ae31c4931298b4b1c0f1d974b8732957",
133
- amount: "20000000000000000000",
149
+ amount: (2e19).toString(), // 20 VET
134
150
  body: {
135
151
  chainTag: MAINNET_CHAIN_TAG,
136
152
  blockRef: "0x00634a0c856ec1db",
@@ -138,24 +154,28 @@ const vechain: CurrenciesData<Transaction> = {
138
154
  clauses: [
139
155
  {
140
156
  to: "0xcf130b42ae31c4931298b4b1c0f1d974b8732957",
141
- value: "20000000000000000000",
157
+ value: (2e19).toString(), // 20 VET
142
158
  data: "0x",
143
159
  },
144
160
  ],
145
- gasPriceCoef: DEFAULT_GAS_COEFFICIENT,
146
161
  gas: "0",
162
+ maxFeePerGas: 0,
163
+ maxPriorityFeePerGas: 0,
147
164
  dependsOn: null,
148
165
  nonce: generateNonce(),
149
166
  },
150
167
  }),
151
- expectedStatus: {
152
- amount: new BigNumber("20000000000000000000"),
153
- errors: {
154
- amount: new NotEnoughBalance(),
155
- },
156
- warnings: {},
157
- totalSpent: new BigNumber("20000000000000000000"),
158
- estimatedFees: new BigNumber("210000000000000000"),
168
+ expectedStatus: (_account, _, status): Partial<TransactionStatusCommon> => {
169
+ const estimatedFees = status.estimatedFees;
170
+ return {
171
+ amount: new BigNumber(2e19), // 20 VET
172
+ errors: {
173
+ amount: new NotEnoughBalance(),
174
+ },
175
+ warnings: {},
176
+ totalSpent: new BigNumber(2e19),
177
+ estimatedFees, // fees are calculated during preparation and therefore cannot be guessed without mocks
178
+ };
159
179
  },
160
180
  },
161
181
  {
@@ -166,7 +186,7 @@ const vechain: CurrenciesData<Transaction> = {
166
186
  "js:2:vechain:0x0fe6688548f0C303932bB197B0A96034f1d74dba:vechain+vechain%2Fvip180%2Fvtho",
167
187
  estimatedFees: "515820000000000000",
168
188
  recipient: "0xcf130b42ae31c4931298b4b1c0f1d974b8732957",
169
- amount: "20000000000000000000",
189
+ amount: (2e19).toString(), // 20 VTHO
170
190
  body: {
171
191
  chainTag: MAINNET_CHAIN_TAG,
172
192
  blockRef: "0x00634a0c856ec1db",
@@ -174,24 +194,28 @@ const vechain: CurrenciesData<Transaction> = {
174
194
  clauses: [
175
195
  {
176
196
  to: "0xcf130b42ae31c4931298b4b1c0f1d974b8732957",
177
- value: "20000000000000000000",
197
+ value: (2e19).toString(), // 20 VTHO
178
198
  data: "0x",
179
199
  },
180
200
  ],
181
- gasPriceCoef: DEFAULT_GAS_COEFFICIENT,
182
201
  gas: "0",
202
+ maxFeePerGas: 0,
203
+ maxPriorityFeePerGas: 0,
183
204
  dependsOn: null,
184
205
  nonce: generateNonce(),
185
206
  },
186
207
  }),
187
- expectedStatus: {
188
- amount: new BigNumber("20000000000000000000"),
189
- errors: {
190
- amount: new NotEnoughBalance(),
191
- },
192
- warnings: {},
193
- totalSpent: new BigNumber("20515820000000000000"),
194
- estimatedFees: new BigNumber("515820000000000000"),
208
+ expectedStatus: (_account, _, status): Partial<TransactionStatusCommon> => {
209
+ const estimatedFees = status.estimatedFees;
210
+ return {
211
+ amount: new BigNumber(2e19), // 20 VTHO
212
+ errors: {
213
+ amount: new NotEnoughBalance(),
214
+ },
215
+ warnings: {},
216
+ totalSpent: new BigNumber(2e19).plus(estimatedFees),
217
+ estimatedFees, // fees are calculated during preparation and therefore cannot be guessed without mocks
218
+ };
195
219
  },
196
220
  },
197
221
  ],
@@ -211,7 +235,7 @@ const vechain: CurrenciesData<Transaction> = {
211
235
  family: "vechain",
212
236
  estimatedFees: "210000000000000000",
213
237
  recipient: "0xcf130b42ae31c4931298b4b1c0f1d974b8732957",
214
- amount: "1000000000000000000",
238
+ amount: (1e18).toString(), // 1 VET
215
239
  body: {
216
240
  chainTag: MAINNET_CHAIN_TAG,
217
241
  blockRef: "0x00634a0c856ec1db",
@@ -219,24 +243,28 @@ const vechain: CurrenciesData<Transaction> = {
219
243
  clauses: [
220
244
  {
221
245
  to: "0xcf130b42ae31c4931298b4b1c0f1d974b8732957",
222
- value: "1000000000000000000",
246
+ value: (1e18).toString(),
223
247
  data: "0x",
224
248
  },
225
249
  ],
226
- gasPriceCoef: DEFAULT_GAS_COEFFICIENT,
227
250
  gas: "0",
251
+ maxFeePerGas: 0,
252
+ maxPriorityFeePerGas: 0,
228
253
  dependsOn: null,
229
254
  nonce: generateNonce(),
230
255
  },
231
256
  }),
232
- expectedStatus: {
233
- amount: new BigNumber("1000000000000000000"),
234
- estimatedFees: new BigNumber("210000000000000000"),
235
- totalSpent: new BigNumber("1000000000000000000"),
236
- errors: {
237
- amount: new NotEnoughVTHO(),
238
- },
239
- warnings: {},
257
+ expectedStatus: (_account, _, status): Partial<TransactionStatusCommon> => {
258
+ const estimatedFees = status.estimatedFees;
259
+ return {
260
+ amount: new BigNumber(1e18), // 1 VET
261
+ estimatedFees, // fees are calculated during preparation and therefore cannot be guessed without mocks
262
+ totalSpent: new BigNumber(1e18),
263
+ errors: {
264
+ amount: new NotEnoughVTHO(),
265
+ },
266
+ warnings: {},
267
+ };
240
268
  },
241
269
  },
242
270
  ],
package/src/test/cli.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  import flatMap from "lodash/flatMap";
2
2
  import { Transaction, Transaction as VechainTransaction } from "../types";
3
3
  import type { Account, AccountLike } from "@ledgerhq/types-live";
4
- import { VTHO_ADDRESS } from "../contracts/constants";
5
- import VIP180 from "../contracts/abis/VIP180";
6
4
  import { MustBeVechain } from "../errors";
5
+ import { ABIContract, VIP180_ABI, VTHO_ADDRESS } from "@vechain/sdk-core";
7
6
 
8
7
  type CliTools = {
9
8
  options: Array<{
@@ -63,7 +62,9 @@ function inferTransactions(
63
62
  clauses.push({
64
63
  value: 0,
65
64
  to: VTHO_ADDRESS,
66
- data: VIP180.transfer.encode(transaction.recipient, transaction.amount.toFixed()),
65
+ data: ABIContract.ofAbi(VIP180_ABI)
66
+ .encodeFunctionInput("transfer", [transaction.recipient, transaction.amount.toFixed()])
67
+ .toString(),
67
68
  });
68
69
  } else {
69
70
  throw new MustBeVechain();