@ledgerhq/coin-vechain 2.2.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (396) hide show
  1. package/.eslintrc.js +20 -0
  2. package/.turbo/turbo-build.log +4 -0
  3. package/.unimportedrc.json +74 -0
  4. package/CHANGELOG.md +1186 -0
  5. package/LICENSE.txt +21 -0
  6. package/jest.config.js +8 -0
  7. package/lib/account.d.ts +7 -0
  8. package/lib/account.d.ts.map +1 -0
  9. package/lib/account.js +19 -0
  10. package/lib/account.js.map +1 -0
  11. package/lib/bridge/broadcast.d.ts +8 -0
  12. package/lib/bridge/broadcast.d.ts.map +1 -0
  13. package/lib/bridge/broadcast.js +27 -0
  14. package/lib/bridge/broadcast.js.map +1 -0
  15. package/lib/bridge/buildOptimisticOperatioin.d.ts +4 -0
  16. package/lib/bridge/buildOptimisticOperatioin.d.ts.map +1 -0
  17. package/lib/bridge/buildOptimisticOperatioin.js +56 -0
  18. package/lib/bridge/buildOptimisticOperatioin.js.map +1 -0
  19. package/lib/bridge/createTransaction.d.ts +9 -0
  20. package/lib/bridge/createTransaction.d.ts.map +1 -0
  21. package/lib/bridge/createTransaction.js +36 -0
  22. package/lib/bridge/createTransaction.js.map +1 -0
  23. package/lib/bridge/estimateMaxSpendable.d.ts +4 -0
  24. package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -0
  25. package/lib/bridge/estimateMaxSpendable.js +29 -0
  26. package/lib/bridge/estimateMaxSpendable.js.map +1 -0
  27. package/lib/bridge/getTransactionStatus.d.ts +5 -0
  28. package/lib/bridge/getTransactionStatus.d.ts.map +1 -0
  29. package/lib/bridge/getTransactionStatus.js +76 -0
  30. package/lib/bridge/getTransactionStatus.js.map +1 -0
  31. package/lib/bridge/index.d.ts +10 -0
  32. package/lib/bridge/index.d.ts.map +1 -0
  33. package/lib/bridge/index.js +64 -0
  34. package/lib/bridge/index.js.map +1 -0
  35. package/lib/bridge/prepareTransaction.d.ts +10 -0
  36. package/lib/bridge/prepareTransaction.d.ts.map +1 -0
  37. package/lib/bridge/prepareTransaction.js +38 -0
  38. package/lib/bridge/prepareTransaction.js.map +1 -0
  39. package/lib/bridge/signOperation.d.ts +8 -0
  40. package/lib/bridge/signOperation.d.ts.map +1 -0
  41. package/lib/bridge/signOperation.js +43 -0
  42. package/lib/bridge/signOperation.js.map +1 -0
  43. package/lib/bridge/synchronisation.d.ts +4 -0
  44. package/lib/bridge/synchronisation.d.ts.map +1 -0
  45. package/lib/bridge/synchronisation.js +84 -0
  46. package/lib/bridge/synchronisation.js.map +1 -0
  47. package/lib/bridge/transaction.d.ts +17 -0
  48. package/lib/bridge/transaction.d.ts.map +1 -0
  49. package/lib/bridge/transaction.js +56 -0
  50. package/lib/bridge/transaction.js.map +1 -0
  51. package/lib/common-logic/address-utils.d.ts +2 -0
  52. package/lib/common-logic/address-utils.d.ts.map +1 -0
  53. package/lib/common-logic/address-utils.js +19 -0
  54. package/lib/common-logic/address-utils.js.map +1 -0
  55. package/lib/common-logic/hex-utils.d.ts +8 -0
  56. package/lib/common-logic/hex-utils.d.ts.map +1 -0
  57. package/lib/common-logic/hex-utils.js +52 -0
  58. package/lib/common-logic/hex-utils.js.map +1 -0
  59. package/lib/common-logic/index.d.ts +7 -0
  60. package/lib/common-logic/index.d.ts.map +1 -0
  61. package/lib/common-logic/index.js +23 -0
  62. package/lib/common-logic/index.js.map +1 -0
  63. package/lib/common-logic/logic.d.ts +5 -0
  64. package/lib/common-logic/logic.d.ts.map +1 -0
  65. package/lib/common-logic/logic.js +46 -0
  66. package/lib/common-logic/logic.js.map +1 -0
  67. package/lib/common-logic/mapping-utils.d.ts +5 -0
  68. package/lib/common-logic/mapping-utils.d.ts.map +1 -0
  69. package/lib/common-logic/mapping-utils.js +61 -0
  70. package/lib/common-logic/mapping-utils.js.map +1 -0
  71. package/lib/common-logic/pad-address.d.ts +2 -0
  72. package/lib/common-logic/pad-address.d.ts.map +1 -0
  73. package/lib/common-logic/pad-address.js +13 -0
  74. package/lib/common-logic/pad-address.js.map +1 -0
  75. package/lib/common-logic/transaction-utils.d.ts +30 -0
  76. package/lib/common-logic/transaction-utils.d.ts.map +1 -0
  77. package/lib/common-logic/transaction-utils.js +164 -0
  78. package/lib/common-logic/transaction-utils.js.map +1 -0
  79. package/lib/config.d.ts +5 -0
  80. package/lib/config.d.ts.map +1 -0
  81. package/lib/config.js +17 -0
  82. package/lib/config.js.map +1 -0
  83. package/lib/contracts/abis/VIP180.d.ts +17 -0
  84. package/lib/contracts/abis/VIP180.d.ts.map +1 -0
  85. package/lib/contracts/abis/VIP180.js +265 -0
  86. package/lib/contracts/abis/VIP180.js.map +1 -0
  87. package/lib/contracts/abis/params.d.ts +8 -0
  88. package/lib/contracts/abis/params.d.ts.map +1 -0
  89. package/lib/contracts/abis/params.js +69 -0
  90. package/lib/contracts/abis/params.js.map +1 -0
  91. package/lib/contracts/constants.d.ts +6 -0
  92. package/lib/contracts/constants.d.ts.map +1 -0
  93. package/lib/contracts/constants.js +10 -0
  94. package/lib/contracts/constants.js.map +1 -0
  95. package/lib/datasets/index.d.ts +3 -0
  96. package/lib/datasets/index.d.ts.map +1 -0
  97. package/lib/datasets/index.js +23 -0
  98. package/lib/datasets/index.js.map +1 -0
  99. package/lib/datasets/vechain.d.ts +5 -0
  100. package/lib/datasets/vechain.d.ts.map +1 -0
  101. package/lib/datasets/vechain.js +91 -0
  102. package/lib/datasets/vechain.js.map +1 -0
  103. package/lib/datasets/vechain.scanAccounts.1.d.ts +6 -0
  104. package/lib/datasets/vechain.scanAccounts.1.d.ts.map +1 -0
  105. package/lib/datasets/vechain.scanAccounts.1.js +16 -0
  106. package/lib/datasets/vechain.scanAccounts.1.js.map +1 -0
  107. package/lib/errors.d.ts +10 -0
  108. package/lib/errors.d.ts.map +1 -0
  109. package/lib/errors.js +8 -0
  110. package/lib/errors.js.map +1 -0
  111. package/lib/index.d.ts +2 -0
  112. package/lib/index.d.ts.map +1 -0
  113. package/lib/index.js +6 -0
  114. package/lib/index.js.map +1 -0
  115. package/lib/mock.d.ts +9 -0
  116. package/lib/mock.d.ts.map +1 -0
  117. package/lib/mock.js +13 -0
  118. package/lib/mock.js.map +1 -0
  119. package/lib/network/index.d.ts +3 -0
  120. package/lib/network/index.d.ts.map +1 -0
  121. package/lib/network/index.js +22 -0
  122. package/lib/network/index.js.map +1 -0
  123. package/lib/network/sdk.d.ts +47 -0
  124. package/lib/network/sdk.d.ts.map +1 -0
  125. package/lib/network/sdk.js +164 -0
  126. package/lib/network/sdk.js.map +1 -0
  127. package/lib/signer/getAddress.d.ts +6 -0
  128. package/lib/signer/getAddress.d.ts.map +1 -0
  129. package/lib/signer/getAddress.js +32 -0
  130. package/lib/signer/getAddress.js.map +1 -0
  131. package/lib/signer/index.d.ts +4 -0
  132. package/lib/signer/index.d.ts.map +1 -0
  133. package/lib/signer/index.js +23 -0
  134. package/lib/signer/index.js.map +1 -0
  135. package/lib/signer/signMessage.d.ts +4 -0
  136. package/lib/signer/signMessage.d.ts.map +1 -0
  137. package/lib/signer/signMessage.js +31 -0
  138. package/lib/signer/signMessage.js.map +1 -0
  139. package/lib/test/bot-deviceActions.d.ts +7 -0
  140. package/lib/test/bot-deviceActions.d.ts.map +1 -0
  141. package/lib/test/bot-deviceActions.js +23 -0
  142. package/lib/test/bot-deviceActions.js.map +1 -0
  143. package/lib/test/bot-specs.d.ts +8 -0
  144. package/lib/test/bot-specs.d.ts.map +1 -0
  145. package/lib/test/bot-specs.js +161 -0
  146. package/lib/test/bot-specs.js.map +1 -0
  147. package/lib/test/bridgeDatasetTest.d.ts +4 -0
  148. package/lib/test/bridgeDatasetTest.d.ts.map +1 -0
  149. package/lib/test/bridgeDatasetTest.js +252 -0
  150. package/lib/test/bridgeDatasetTest.js.map +1 -0
  151. package/lib/test/cli.d.ts +17 -0
  152. package/lib/test/cli.d.ts.map +1 -0
  153. package/lib/test/cli.js +51 -0
  154. package/lib/test/cli.js.map +1 -0
  155. package/lib/test/index.d.ts +6 -0
  156. package/lib/test/index.d.ts.map +1 -0
  157. package/lib/test/index.js +26 -0
  158. package/lib/test/index.js.map +1 -0
  159. package/lib/types/bridge.d.ts +25 -0
  160. package/lib/types/bridge.d.ts.map +1 -0
  161. package/lib/types/bridge.js +3 -0
  162. package/lib/types/bridge.js.map +1 -0
  163. package/lib/types/constants.d.ts +6 -0
  164. package/lib/types/constants.d.ts.map +1 -0
  165. package/lib/types/constants.js +9 -0
  166. package/lib/types/constants.js.map +1 -0
  167. package/lib/types/index.d.ts +5 -0
  168. package/lib/types/index.d.ts.map +1 -0
  169. package/lib/types/index.js +21 -0
  170. package/lib/types/index.js.map +1 -0
  171. package/lib/types/network.d.ts +71 -0
  172. package/lib/types/network.d.ts.map +1 -0
  173. package/lib/types/network.js +3 -0
  174. package/lib/types/network.js.map +1 -0
  175. package/lib/types/signer.d.ts +12 -0
  176. package/lib/types/signer.d.ts.map +1 -0
  177. package/lib/types/signer.js +3 -0
  178. package/lib/types/signer.js.map +1 -0
  179. package/lib-es/account.d.ts +7 -0
  180. package/lib-es/account.d.ts.map +1 -0
  181. package/lib-es/account.js +17 -0
  182. package/lib-es/account.js.map +1 -0
  183. package/lib-es/bridge/broadcast.d.ts +8 -0
  184. package/lib-es/bridge/broadcast.d.ts.map +1 -0
  185. package/lib-es/bridge/broadcast.js +23 -0
  186. package/lib-es/bridge/broadcast.js.map +1 -0
  187. package/lib-es/bridge/buildOptimisticOperatioin.d.ts +4 -0
  188. package/lib-es/bridge/buildOptimisticOperatioin.d.ts.map +1 -0
  189. package/lib-es/bridge/buildOptimisticOperatioin.js +49 -0
  190. package/lib-es/bridge/buildOptimisticOperatioin.js.map +1 -0
  191. package/lib-es/bridge/createTransaction.d.ts +9 -0
  192. package/lib-es/bridge/createTransaction.d.ts.map +1 -0
  193. package/lib-es/bridge/createTransaction.js +29 -0
  194. package/lib-es/bridge/createTransaction.js.map +1 -0
  195. package/lib-es/bridge/estimateMaxSpendable.d.ts +4 -0
  196. package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -0
  197. package/lib-es/bridge/estimateMaxSpendable.js +22 -0
  198. package/lib-es/bridge/estimateMaxSpendable.js.map +1 -0
  199. package/lib-es/bridge/getTransactionStatus.d.ts +5 -0
  200. package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -0
  201. package/lib-es/bridge/getTransactionStatus.js +69 -0
  202. package/lib-es/bridge/getTransactionStatus.js.map +1 -0
  203. package/lib-es/bridge/index.d.ts +10 -0
  204. package/lib-es/bridge/index.d.ts.map +1 -0
  205. package/lib-es/bridge/index.js +55 -0
  206. package/lib-es/bridge/index.js.map +1 -0
  207. package/lib-es/bridge/prepareTransaction.d.ts +10 -0
  208. package/lib-es/bridge/prepareTransaction.d.ts.map +1 -0
  209. package/lib-es/bridge/prepareTransaction.js +34 -0
  210. package/lib-es/bridge/prepareTransaction.js.map +1 -0
  211. package/lib-es/bridge/signOperation.d.ts +8 -0
  212. package/lib-es/bridge/signOperation.d.ts.map +1 -0
  213. package/lib-es/bridge/signOperation.js +39 -0
  214. package/lib-es/bridge/signOperation.js.map +1 -0
  215. package/lib-es/bridge/synchronisation.d.ts +4 -0
  216. package/lib-es/bridge/synchronisation.d.ts.map +1 -0
  217. package/lib-es/bridge/synchronisation.js +77 -0
  218. package/lib-es/bridge/synchronisation.js.map +1 -0
  219. package/lib-es/bridge/transaction.d.ts +17 -0
  220. package/lib-es/bridge/transaction.d.ts.map +1 -0
  221. package/lib-es/bridge/transaction.js +48 -0
  222. package/lib-es/bridge/transaction.js.map +1 -0
  223. package/lib-es/common-logic/address-utils.d.ts +2 -0
  224. package/lib-es/common-logic/address-utils.d.ts.map +1 -0
  225. package/lib-es/common-logic/address-utils.js +12 -0
  226. package/lib-es/common-logic/address-utils.js.map +1 -0
  227. package/lib-es/common-logic/hex-utils.d.ts +8 -0
  228. package/lib-es/common-logic/hex-utils.d.ts.map +1 -0
  229. package/lib-es/common-logic/hex-utils.js +50 -0
  230. package/lib-es/common-logic/hex-utils.js.map +1 -0
  231. package/lib-es/common-logic/index.d.ts +7 -0
  232. package/lib-es/common-logic/index.d.ts.map +1 -0
  233. package/lib-es/common-logic/index.js +7 -0
  234. package/lib-es/common-logic/index.js.map +1 -0
  235. package/lib-es/common-logic/logic.d.ts +5 -0
  236. package/lib-es/common-logic/logic.d.ts.map +1 -0
  237. package/lib-es/common-logic/logic.js +38 -0
  238. package/lib-es/common-logic/logic.js.map +1 -0
  239. package/lib-es/common-logic/mapping-utils.d.ts +5 -0
  240. package/lib-es/common-logic/mapping-utils.d.ts.map +1 -0
  241. package/lib-es/common-logic/mapping-utils.js +53 -0
  242. package/lib-es/common-logic/mapping-utils.js.map +1 -0
  243. package/lib-es/common-logic/pad-address.d.ts +2 -0
  244. package/lib-es/common-logic/pad-address.d.ts.map +1 -0
  245. package/lib-es/common-logic/pad-address.js +9 -0
  246. package/lib-es/common-logic/pad-address.js.map +1 -0
  247. package/lib-es/common-logic/transaction-utils.d.ts +30 -0
  248. package/lib-es/common-logic/transaction-utils.d.ts.map +1 -0
  249. package/lib-es/common-logic/transaction-utils.js +153 -0
  250. package/lib-es/common-logic/transaction-utils.js.map +1 -0
  251. package/lib-es/config.d.ts +5 -0
  252. package/lib-es/config.d.ts.map +1 -0
  253. package/lib-es/config.js +12 -0
  254. package/lib-es/config.js.map +1 -0
  255. package/lib-es/contracts/abis/VIP180.d.ts +17 -0
  256. package/lib-es/contracts/abis/VIP180.d.ts.map +1 -0
  257. package/lib-es/contracts/abis/VIP180.js +263 -0
  258. package/lib-es/contracts/abis/VIP180.js.map +1 -0
  259. package/lib-es/contracts/abis/params.d.ts +8 -0
  260. package/lib-es/contracts/abis/params.d.ts.map +1 -0
  261. package/lib-es/contracts/abis/params.js +67 -0
  262. package/lib-es/contracts/abis/params.js.map +1 -0
  263. package/lib-es/contracts/constants.d.ts +6 -0
  264. package/lib-es/contracts/constants.d.ts.map +1 -0
  265. package/lib-es/contracts/constants.js +7 -0
  266. package/lib-es/contracts/constants.js.map +1 -0
  267. package/lib-es/datasets/index.d.ts +3 -0
  268. package/lib-es/datasets/index.d.ts.map +1 -0
  269. package/lib-es/datasets/index.js +3 -0
  270. package/lib-es/datasets/index.js.map +1 -0
  271. package/lib-es/datasets/vechain.d.ts +5 -0
  272. package/lib-es/datasets/vechain.d.ts.map +1 -0
  273. package/lib-es/datasets/vechain.js +88 -0
  274. package/lib-es/datasets/vechain.js.map +1 -0
  275. package/lib-es/datasets/vechain.scanAccounts.1.d.ts +6 -0
  276. package/lib-es/datasets/vechain.scanAccounts.1.d.ts.map +1 -0
  277. package/lib-es/datasets/vechain.scanAccounts.1.js +14 -0
  278. package/lib-es/datasets/vechain.scanAccounts.1.js.map +1 -0
  279. package/lib-es/errors.d.ts +10 -0
  280. package/lib-es/errors.d.ts.map +1 -0
  281. package/lib-es/errors.js +5 -0
  282. package/lib-es/errors.js.map +1 -0
  283. package/lib-es/index.d.ts +2 -0
  284. package/lib-es/index.d.ts.map +1 -0
  285. package/lib-es/index.js +2 -0
  286. package/lib-es/index.js.map +1 -0
  287. package/lib-es/mock.d.ts +9 -0
  288. package/lib-es/mock.d.ts.map +1 -0
  289. package/lib-es/mock.js +11 -0
  290. package/lib-es/mock.js.map +1 -0
  291. package/lib-es/network/index.d.ts +3 -0
  292. package/lib-es/network/index.d.ts.map +1 -0
  293. package/lib-es/network/index.js +3 -0
  294. package/lib-es/network/index.js.map +1 -0
  295. package/lib-es/network/sdk.d.ts +47 -0
  296. package/lib-es/network/sdk.d.ts.map +1 -0
  297. package/lib-es/network/sdk.js +150 -0
  298. package/lib-es/network/sdk.js.map +1 -0
  299. package/lib-es/signer/getAddress.d.ts +6 -0
  300. package/lib-es/signer/getAddress.d.ts.map +1 -0
  301. package/lib-es/signer/getAddress.js +27 -0
  302. package/lib-es/signer/getAddress.js.map +1 -0
  303. package/lib-es/signer/index.d.ts +4 -0
  304. package/lib-es/signer/index.d.ts.map +1 -0
  305. package/lib-es/signer/index.js +4 -0
  306. package/lib-es/signer/index.js.map +1 -0
  307. package/lib-es/signer/signMessage.d.ts +4 -0
  308. package/lib-es/signer/signMessage.d.ts.map +1 -0
  309. package/lib-es/signer/signMessage.js +27 -0
  310. package/lib-es/signer/signMessage.js.map +1 -0
  311. package/lib-es/test/bot-deviceActions.d.ts +7 -0
  312. package/lib-es/test/bot-deviceActions.d.ts.map +1 -0
  313. package/lib-es/test/bot-deviceActions.js +21 -0
  314. package/lib-es/test/bot-deviceActions.js.map +1 -0
  315. package/lib-es/test/bot-specs.d.ts +8 -0
  316. package/lib-es/test/bot-specs.d.ts.map +1 -0
  317. package/lib-es/test/bot-specs.js +156 -0
  318. package/lib-es/test/bot-specs.js.map +1 -0
  319. package/lib-es/test/bridgeDatasetTest.d.ts +4 -0
  320. package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -0
  321. package/lib-es/test/bridgeDatasetTest.js +246 -0
  322. package/lib-es/test/bridgeDatasetTest.js.map +1 -0
  323. package/lib-es/test/cli.d.ts +17 -0
  324. package/lib-es/test/cli.d.ts.map +1 -0
  325. package/lib-es/test/cli.js +45 -0
  326. package/lib-es/test/cli.js.map +1 -0
  327. package/lib-es/test/index.d.ts +6 -0
  328. package/lib-es/test/index.d.ts.map +1 -0
  329. package/lib-es/test/index.js +6 -0
  330. package/lib-es/test/index.js.map +1 -0
  331. package/lib-es/types/bridge.d.ts +25 -0
  332. package/lib-es/types/bridge.d.ts.map +1 -0
  333. package/lib-es/types/bridge.js +2 -0
  334. package/lib-es/types/bridge.js.map +1 -0
  335. package/lib-es/types/constants.d.ts +6 -0
  336. package/lib-es/types/constants.d.ts.map +1 -0
  337. package/lib-es/types/constants.js +6 -0
  338. package/lib-es/types/constants.js.map +1 -0
  339. package/lib-es/types/index.d.ts +5 -0
  340. package/lib-es/types/index.d.ts.map +1 -0
  341. package/lib-es/types/index.js +5 -0
  342. package/lib-es/types/index.js.map +1 -0
  343. package/lib-es/types/network.d.ts +71 -0
  344. package/lib-es/types/network.d.ts.map +1 -0
  345. package/lib-es/types/network.js +2 -0
  346. package/lib-es/types/network.js.map +1 -0
  347. package/lib-es/types/signer.d.ts +12 -0
  348. package/lib-es/types/signer.d.ts.map +1 -0
  349. package/lib-es/types/signer.js +2 -0
  350. package/lib-es/types/signer.js.map +1 -0
  351. package/package.json +120 -0
  352. package/src/__snapshots__/bridge.integration.test.ts.snap +146 -0
  353. package/src/account.ts +22 -0
  354. package/src/bridge/broadcast.ts +23 -0
  355. package/src/bridge/buildOptimisticOperatioin.ts +46 -0
  356. package/src/bridge/createTransaction.ts +31 -0
  357. package/src/bridge/estimateMaxSpendable.ts +18 -0
  358. package/src/bridge/getTransactionStatus.ts +76 -0
  359. package/src/bridge/index.ts +63 -0
  360. package/src/bridge/prepareTransaction.ts +41 -0
  361. package/src/bridge/signOperation.ts +53 -0
  362. package/src/bridge/synchronisation.ts +86 -0
  363. package/src/bridge/transaction.ts +79 -0
  364. package/src/common-logic/address-utils.ts +11 -0
  365. package/src/common-logic/hex-utils.ts +53 -0
  366. package/src/common-logic/index.ts +6 -0
  367. package/src/common-logic/logic.ts +44 -0
  368. package/src/common-logic/mapping-utils.ts +67 -0
  369. package/src/common-logic/pad-address.ts +8 -0
  370. package/src/common-logic/transaction-utils.ts +190 -0
  371. package/src/config.ts +18 -0
  372. package/src/contracts/abis/VIP180.ts +265 -0
  373. package/src/contracts/abis/params.ts +70 -0
  374. package/src/contracts/constants.ts +11 -0
  375. package/src/datasets/index.ts +2 -0
  376. package/src/datasets/vechain.scanAccounts.1.ts +13 -0
  377. package/src/datasets/vechain.ts +92 -0
  378. package/src/errors.ts +7 -0
  379. package/src/index.ts +1 -0
  380. package/src/mock.ts +14 -0
  381. package/src/network/index.ts +2 -0
  382. package/src/network/sdk.ts +177 -0
  383. package/src/signer/getAddress.ts +25 -0
  384. package/src/signer/index.ts +4 -0
  385. package/src/signer/signMessage.ts +22 -0
  386. package/src/test/bot-deviceActions.ts +24 -0
  387. package/src/test/bot-specs.ts +210 -0
  388. package/src/test/bridgeDatasetTest.ts +262 -0
  389. package/src/test/cli.ts +86 -0
  390. package/src/test/index.ts +6 -0
  391. package/src/types/bridge.ts +35 -0
  392. package/src/types/constants.ts +5 -0
  393. package/src/types/index.ts +4 -0
  394. package/src/types/network.ts +81 -0
  395. package/src/types/signer.ts +10 -0
  396. package/tsconfig.json +13 -0
@@ -0,0 +1,265 @@
1
+ import { abi } from "thor-devkit";
2
+
3
+ /**
4
+ * EVENTS
5
+ */
6
+ const ApprovalEvent: abi.Event.Definition = {
7
+ anonymous: false,
8
+ inputs: [
9
+ {
10
+ indexed: true,
11
+ internalType: "address",
12
+ name: "owner",
13
+ type: "address",
14
+ },
15
+ {
16
+ indexed: true,
17
+ internalType: "address",
18
+ name: "spender",
19
+ type: "address",
20
+ },
21
+ {
22
+ indexed: false,
23
+ internalType: "uint256",
24
+ name: "value",
25
+ type: "uint256",
26
+ },
27
+ ],
28
+ name: "Approval",
29
+ type: "event",
30
+ };
31
+ const TransferEvent: abi.Event.Definition = {
32
+ anonymous: false,
33
+ inputs: [
34
+ {
35
+ indexed: true,
36
+ internalType: "address",
37
+ name: "from",
38
+ type: "address",
39
+ },
40
+ {
41
+ indexed: true,
42
+ internalType: "address",
43
+ name: "to",
44
+ type: "address",
45
+ },
46
+ {
47
+ indexed: false,
48
+ internalType: "uint256",
49
+ name: "value",
50
+ type: "uint256",
51
+ },
52
+ ],
53
+ name: "Transfer",
54
+ type: "event",
55
+ };
56
+
57
+ /**
58
+ * FUNCTIONS
59
+ */
60
+ const allowance: abi.Function.Definition = {
61
+ inputs: [
62
+ {
63
+ internalType: "address",
64
+ name: "owner",
65
+ type: "address",
66
+ },
67
+ {
68
+ internalType: "address",
69
+ name: "spender",
70
+ type: "address",
71
+ },
72
+ ],
73
+ name: "allowance",
74
+ outputs: [
75
+ {
76
+ internalType: "uint256",
77
+ name: "",
78
+ type: "uint256",
79
+ },
80
+ ],
81
+ stateMutability: "view",
82
+ type: "function",
83
+ };
84
+ const approve: abi.Function.Definition = {
85
+ inputs: [
86
+ {
87
+ internalType: "address",
88
+ name: "spender",
89
+ type: "address",
90
+ },
91
+ {
92
+ internalType: "uint256",
93
+ name: "amount",
94
+ type: "uint256",
95
+ },
96
+ ],
97
+ name: "approve",
98
+ outputs: [
99
+ {
100
+ internalType: "bool",
101
+ name: "",
102
+ type: "bool",
103
+ },
104
+ ],
105
+ stateMutability: "nonpayable",
106
+ type: "function",
107
+ };
108
+ const balanceOf: abi.Function.Definition = {
109
+ inputs: [
110
+ {
111
+ internalType: "address",
112
+ name: "account",
113
+ type: "address",
114
+ },
115
+ ],
116
+ name: "balanceOf",
117
+ outputs: [
118
+ {
119
+ internalType: "uint256",
120
+ name: "",
121
+ type: "uint256",
122
+ },
123
+ ],
124
+ stateMutability: "view",
125
+ type: "function",
126
+ };
127
+ const decimals: abi.Function.Definition = {
128
+ inputs: [],
129
+ name: "decimals",
130
+ outputs: [
131
+ {
132
+ internalType: "uint8",
133
+ name: "",
134
+ type: "uint8",
135
+ },
136
+ ],
137
+ stateMutability: "view",
138
+ type: "function",
139
+ };
140
+ const name: abi.Function.Definition = {
141
+ inputs: [],
142
+ name: "name",
143
+ outputs: [
144
+ {
145
+ internalType: "string",
146
+ name: "",
147
+ type: "string",
148
+ },
149
+ ],
150
+ stateMutability: "view",
151
+ type: "function",
152
+ };
153
+ const supportsInterface: abi.Function.Definition = {
154
+ inputs: [
155
+ {
156
+ internalType: "bytes4",
157
+ name: "interfaceId",
158
+ type: "bytes4",
159
+ },
160
+ ],
161
+ name: "supportsInterface",
162
+ outputs: [
163
+ {
164
+ internalType: "bool",
165
+ name: "",
166
+ type: "bool",
167
+ },
168
+ ],
169
+ stateMutability: "view",
170
+ type: "function",
171
+ };
172
+ const symbol: abi.Function.Definition = {
173
+ inputs: [],
174
+ name: "symbol",
175
+ outputs: [
176
+ {
177
+ internalType: "string",
178
+ name: "",
179
+ type: "string",
180
+ },
181
+ ],
182
+ stateMutability: "view",
183
+ type: "function",
184
+ };
185
+ const totalSupply: abi.Function.Definition = {
186
+ inputs: [],
187
+ name: "totalSupply",
188
+ outputs: [
189
+ {
190
+ internalType: "uint256",
191
+ name: "",
192
+ type: "uint256",
193
+ },
194
+ ],
195
+ stateMutability: "view",
196
+ type: "function",
197
+ };
198
+ const transfer: abi.Function.Definition = {
199
+ inputs: [
200
+ {
201
+ internalType: "address",
202
+ name: "to",
203
+ type: "address",
204
+ },
205
+ {
206
+ internalType: "uint256",
207
+ name: "amount",
208
+ type: "uint256",
209
+ },
210
+ ],
211
+ name: "transfer",
212
+ outputs: [
213
+ {
214
+ internalType: "bool",
215
+ name: "",
216
+ type: "bool",
217
+ },
218
+ ],
219
+ stateMutability: "nonpayable",
220
+ type: "function",
221
+ };
222
+ const transferFrom: abi.Function.Definition = {
223
+ inputs: [
224
+ {
225
+ internalType: "address",
226
+ name: "from",
227
+ type: "address",
228
+ },
229
+ {
230
+ internalType: "address",
231
+ name: "to",
232
+ type: "address",
233
+ },
234
+ {
235
+ internalType: "uint256",
236
+ name: "amount",
237
+ type: "uint256",
238
+ },
239
+ ],
240
+ name: "transferFrom",
241
+ outputs: [
242
+ {
243
+ internalType: "bool",
244
+ name: "",
245
+ type: "bool",
246
+ },
247
+ ],
248
+ stateMutability: "nonpayable",
249
+ type: "function",
250
+ };
251
+
252
+ export default {
253
+ ApprovalEvent: new abi.Event(ApprovalEvent),
254
+ TransferEvent: new abi.Event(TransferEvent),
255
+ allowance: new abi.Function(allowance),
256
+ approve: new abi.Function(approve),
257
+ balanceOf: new abi.Function(balanceOf),
258
+ decimals: new abi.Function(decimals),
259
+ name: new abi.Function(name),
260
+ supportsInterface: new abi.Function(supportsInterface),
261
+ symbol: new abi.Function(symbol),
262
+ totalSupply: new abi.Function(totalSupply),
263
+ transfer: new abi.Function(transfer),
264
+ transferFrom: new abi.Function(transferFrom),
265
+ };
@@ -0,0 +1,70 @@
1
+ import { abi } from "thor-devkit";
2
+
3
+ /**
4
+ * FUNCTIONS
5
+ */
6
+ const set: abi.Function.Definition = {
7
+ constant: false,
8
+ inputs: [
9
+ {
10
+ name: "_key",
11
+ type: "bytes32",
12
+ },
13
+ {
14
+ name: "_value",
15
+ type: "uint256",
16
+ },
17
+ ],
18
+ name: "set",
19
+ outputs: [],
20
+ payable: false,
21
+ stateMutability: "nonpayable",
22
+ type: "function",
23
+ };
24
+
25
+ const get: abi.Function.Definition = {
26
+ constant: true,
27
+ inputs: [
28
+ {
29
+ name: "_key",
30
+ type: "bytes32",
31
+ },
32
+ ],
33
+ name: "get",
34
+ outputs: [
35
+ {
36
+ name: "",
37
+ type: "uint256",
38
+ },
39
+ ],
40
+ payable: false,
41
+ stateMutability: "view",
42
+ type: "function",
43
+ };
44
+
45
+ /**
46
+ * EVENTS
47
+ */
48
+ const Set: abi.Event.Definition = {
49
+ anonymous: false,
50
+ inputs: [
51
+ {
52
+ indexed: true,
53
+ name: "key",
54
+ type: "bytes32",
55
+ },
56
+ {
57
+ indexed: false,
58
+ name: "value",
59
+ type: "uint256",
60
+ },
61
+ ],
62
+ name: "Set",
63
+ type: "event",
64
+ };
65
+
66
+ export default {
67
+ set: new abi.Function(set),
68
+ get: new abi.Function(get),
69
+ Set: new abi.Event(Set),
70
+ };
@@ -0,0 +1,11 @@
1
+ export const TransferEventSignature =
2
+ "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef";
3
+
4
+ export const VTHO_ADDRESS = "0x0000000000000000000000000000456e65726779";
5
+
6
+ // params.sol - builtin contract (https://www.vechain.org/whitepaper/#bit_v48i3)
7
+ export const PARAMS_ADDRESS = "0x0000000000000000000000000000506172616d73";
8
+ export const REWARD_RATIO_KEY =
9
+ "0x00000000000000000000000000000000000000007265776172642d726174696f";
10
+ export const BASE_GAS_PRICE_KEY =
11
+ "0x000000000000000000000000000000000000626173652d6761732d7072696365";
@@ -0,0 +1,2 @@
1
+ export * from "./vechain.scanAccounts.1";
2
+ export { vechain1, vechain2, vechain3 } from "./vechain";
@@ -0,0 +1,13 @@
1
+ export default [
2
+ {
3
+ name: "vechain seed 1",
4
+ apdus: `
5
+ => e002000015058000002c80000332800000000000000000000000
6
+ <= 4104de5a8f11cc426ff5617aeffd397c5dd77b58424662f368f2cd539a8c42fd2e7d0c6245c9c3a4306f70d7f292e95642651a6832d66fd9823fa6a0af575113e94e28306665363638383534386630433330333933326242313937423041393630333466316437346462619000
7
+ => e002000015058000002c80000332800000000000000000000001
8
+ <= 4104c1295d6d253841866b1cf8adbb63004d74849370d6301c839c7f57fa764b2eab0ae8fd4ea092a0ee3c2ca3bc61542b4becae04b5e1ed91e698a4a4d620a512dd28303239363142393242384432304134656131326631663143654641373444643742343335354138369000
9
+ => e002000015058000002c80000332800000000000000000000002
10
+ <= 41047ff6eb07f97f5db006f9777d96a44bcb4cd35bf149ff9ed63d9b5fba32e167caa272a2b648e826aa4b9e7c88871d69096424c59634bc260e28fc1c1a3d5f204728466243383635334330623834326464333333363143453839333842323465343037646434383338439000
11
+ `,
12
+ },
13
+ ];
@@ -0,0 +1,92 @@
1
+ import { AccountRaw } from "@ledgerhq/types-live";
2
+
3
+ // NOTE: account information is fetched from the blockchain so this is just integration for those information
4
+ // so you you should not rely on that, here the important part are ids and index
5
+
6
+ export const vechain1: AccountRaw = {
7
+ id: "js:2:vechain:0x0fe6688548f0C303932bB197B0A96034f1d74dba:vechain",
8
+ seedIdentifier: "0x0fe6688548f0C303932bB197B0A96034f1d74dba",
9
+ name: "Vechain 1",
10
+ derivationMode: "vechain",
11
+ index: 0,
12
+ freshAddress: "0x0fe6688548f0C303932bB197B0A96034f1d74dba",
13
+ freshAddressPath: "44'/818'/0'/0/0",
14
+ blockHeight: 15156315,
15
+ operations: [],
16
+ pendingOperations: [],
17
+ currencyId: "vechain",
18
+ feesCurrencyId: "vechain/vip180/vtho",
19
+ lastSyncDate: "2023-04-21T14:22:48.395Z",
20
+ balance: "10000000000000000000",
21
+ subAccounts: [
22
+ {
23
+ type: "TokenAccountRaw",
24
+ id: "js:2:vechain:0x0fe6688548f0C303932bB197B0A96034f1d74dba:vechain+vechain%2Fvip180%2Fvtho",
25
+ parentId: "js:2:vechain:0x0fe6688548f0C303932bB197B0A96034f1d74dba:vechain",
26
+ tokenId: "vechain/vip180/vtho",
27
+ balance: "10000000000000000000",
28
+ operations: [],
29
+ pendingOperations: [],
30
+ },
31
+ ],
32
+ swapHistory: [],
33
+ };
34
+
35
+ export const vechain2: AccountRaw = {
36
+ id: "js:2:vechain:0x02961B92B8D20A4ea12f1f1CeFA74Dd7B4355A86:vechain",
37
+ seedIdentifier: "0x02961B92B8D20A4ea12f1f1CeFA74Dd7B4355A86",
38
+ name: "Vechain 2",
39
+ derivationMode: "vechain",
40
+ index: 1,
41
+ freshAddress: "0x02961B92B8D20A4ea12f1f1CeFA74Dd7B4355A86",
42
+ freshAddressPath: "44'/818'/0'/0/1",
43
+ blockHeight: 15156315,
44
+ operations: [],
45
+ pendingOperations: [],
46
+ currencyId: "vechain",
47
+ feesCurrencyId: "vechain/vip180/vtho",
48
+ lastSyncDate: "2023-04-21T14:22:48.395Z",
49
+ balance: "10000000000000000000",
50
+ subAccounts: [
51
+ {
52
+ type: "TokenAccountRaw",
53
+ id: "js:2:vechain:0x02961B92B8D20A4ea12f1f1CeFA74Dd7B4355A86:vechain+vechain%2Fvip180%2Fvtho",
54
+ parentId: "js:2:vechain:0x02961B92B8D20A4ea12f1f1CeFA74Dd7B4355A86:vechain",
55
+ tokenId: "vechain/vip180/vtho",
56
+ balance: "0",
57
+ operations: [],
58
+ pendingOperations: [],
59
+ },
60
+ ],
61
+ swapHistory: [],
62
+ };
63
+
64
+ // account with vtho but no vet
65
+ export const vechain3: AccountRaw = {
66
+ id: "js:2:vechain:0xC0dFC490f8fba6A573C55a68dd9023f999ccaDA0:vechain",
67
+ seedIdentifier: "0xC0dFC490f8fba6A573C55a68dd9023f999ccaDA0",
68
+ name: "Vechain 3",
69
+ derivationMode: "vechain",
70
+ index: 1,
71
+ freshAddress: "0xC0dFC490f8fba6A573C55a68dd9023f999ccaDA0",
72
+ freshAddressPath: "44'/818'/0'/0/0",
73
+ blockHeight: 15156315,
74
+ operations: [],
75
+ pendingOperations: [],
76
+ currencyId: "vechain",
77
+ feesCurrencyId: "vechain/vip180/vtho",
78
+ lastSyncDate: "2023-11-13T13:55:32.004Z",
79
+ balance: "0",
80
+ subAccounts: [
81
+ {
82
+ type: "TokenAccountRaw",
83
+ id: "js:2:vechain:0xC0dFC490f8fba6A573C55a68dd9023f999ccaDA0:vechain+vechain%2Fvip180%2Fvtho",
84
+ parentId: "js:2:vechain:0xC0dFC490f8fba6A573C55a68dd9023f999ccaDA0:vechain",
85
+ tokenId: "vechain/vip180/vtho",
86
+ balance: "1000000000000000",
87
+ operations: [],
88
+ pendingOperations: [],
89
+ },
90
+ ],
91
+ swapHistory: [],
92
+ };
package/src/errors.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { createCustomErrorClass } from "@ledgerhq/errors";
2
+
3
+ export const NotEnoughVTHO = createCustomErrorClass("NotEnoughVTHO");
4
+ export const MustBeVechain = createCustomErrorClass("MustBeVechain");
5
+ export const ImpossibleToCalculateAmountAndFees = createCustomErrorClass(
6
+ "ImpossibleToCalculateAmountAndFees",
7
+ );
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { createBridges } from "./bridge/index";
package/src/mock.ts ADDED
@@ -0,0 +1,14 @@
1
+ import type { Account } from "@ledgerhq/types-live";
2
+
3
+ function postSyncAccount(account: Account): Account {
4
+ return account;
5
+ }
6
+
7
+ function postScanAccount(account: Account): Account {
8
+ return account;
9
+ }
10
+
11
+ export default {
12
+ postSyncAccount,
13
+ postScanAccount,
14
+ };
@@ -0,0 +1,2 @@
1
+ export { getAccount, getOperations } from "./sdk";
2
+ export * from "./sdk";
@@ -0,0 +1,177 @@
1
+ import BigNumber from "bignumber.js";
2
+ import network from "@ledgerhq/live-network/network";
3
+ import { AccountResponse, VetTxsQuery, TokenTxsQuery, Query, QueryResponse } from "../types";
4
+ import type { Operation } from "@ledgerhq/types-live";
5
+ import {
6
+ mapVetTransfersToOperations,
7
+ mapTokenTransfersToOperations,
8
+ padAddress,
9
+ } from "../common-logic";
10
+ import { TransferEventSignature } from "../contracts/constants";
11
+ import { Transaction } from "thor-devkit";
12
+ import { HEX_PREFIX } from "../types";
13
+ import { getEnv } from "@ledgerhq/live-env";
14
+
15
+ const BASE_URL = getEnv("API_VECHAIN_THOREST");
16
+
17
+ export const getAccount = async (address: string): Promise<AccountResponse> => {
18
+ const { data } = await network({
19
+ method: "GET",
20
+ url: `${BASE_URL}/accounts/${address}`,
21
+ });
22
+
23
+ return data;
24
+ };
25
+
26
+ export const getLastBlockHeight = async (): Promise<number> => {
27
+ const { data } = await network({
28
+ method: "GET",
29
+ url: `${BASE_URL}/blocks/best`,
30
+ });
31
+
32
+ return data.number;
33
+ };
34
+
35
+ /**
36
+ * Get VET operations
37
+ * @param accountId
38
+ * @param addr
39
+ * @param startAt
40
+ * @returns an array of operations
41
+ */
42
+ export const getOperations = async (
43
+ accountId: string,
44
+ addr: string,
45
+ startAt: number,
46
+ ): Promise<Operation[]> => {
47
+ const query: VetTxsQuery = {
48
+ range: {
49
+ unit: "block",
50
+ from: startAt,
51
+ },
52
+ criteriaSet: [{ sender: addr }, { recipient: addr }],
53
+ order: "desc",
54
+ };
55
+
56
+ const { data } = await network({
57
+ method: "POST",
58
+ url: `${BASE_URL}/logs/transfer`,
59
+ data: JSON.stringify(query),
60
+ });
61
+
62
+ const operations: Operation[] = await mapVetTransfersToOperations(data, accountId, addr);
63
+
64
+ return operations;
65
+ };
66
+
67
+ /**
68
+ * Get operations for a fungible token
69
+ * @param accountId
70
+ * @param addr
71
+ * @param tokenAddr - The token address (The VTHO token address is available from constants.ts)
72
+ * @param startAt
73
+ * @returns an array of operations
74
+ */
75
+ export const getTokenOperations = async (
76
+ accountId: string,
77
+ addr: string,
78
+ tokenAddr: string,
79
+ startAt: number,
80
+ ): Promise<Operation[]> => {
81
+ const paddedAddress = padAddress(addr);
82
+
83
+ const query: TokenTxsQuery = {
84
+ range: {
85
+ unit: "block",
86
+ from: startAt,
87
+ },
88
+ criteriaSet: [
89
+ {
90
+ address: tokenAddr,
91
+ topic0: TransferEventSignature,
92
+ topic1: paddedAddress,
93
+ },
94
+ {
95
+ address: tokenAddr,
96
+ topic0: TransferEventSignature,
97
+ topic2: paddedAddress,
98
+ },
99
+ ],
100
+ order: "desc",
101
+ };
102
+
103
+ const { data } = await network({
104
+ method: "POST",
105
+ url: `${BASE_URL}/logs/event`,
106
+ data: JSON.stringify(query),
107
+ });
108
+
109
+ const operations = await mapTokenTransfersToOperations(data, accountId, addr);
110
+ return operations;
111
+ };
112
+
113
+ /**
114
+ * Submit a transaction and return the ID
115
+ * @param tx - The transaction to submit
116
+ * @returns transaction ID
117
+ */
118
+ export const submit = async (tx: Transaction): Promise<string> => {
119
+ const encodedRawTx = {
120
+ raw: `${HEX_PREFIX}${tx.encode().toString("hex")}`,
121
+ };
122
+
123
+ const { data } = await network({
124
+ method: "POST",
125
+ url: `${BASE_URL}/transactions`,
126
+ data: encodedRawTx,
127
+ });
128
+
129
+ // Expect a transaction ID
130
+ if (!data.id) throw Error("Expected an ID to be returned");
131
+
132
+ return data.id;
133
+ };
134
+
135
+ /**
136
+ * Query the blockchain
137
+ * @param queryData - The query data
138
+ * @returns a result of the query
139
+ */
140
+ export const query = async (queryData: Query[]): Promise<QueryResponse[]> => {
141
+ const { data } = await network({
142
+ method: "POST",
143
+ url: `${BASE_URL}/accounts/*`,
144
+ data: { clauses: queryData },
145
+ });
146
+
147
+ return data;
148
+ };
149
+
150
+ /**
151
+ * Get the block ref to use in a transaction
152
+ * @returns the block ref of head
153
+ */
154
+ export const getBlockRef = async (): Promise<string> => {
155
+ const { data } = await network({
156
+ method: "GET",
157
+ url: `${BASE_URL}/blocks/best`,
158
+ });
159
+
160
+ return data.id.slice(0, 18);
161
+ };
162
+
163
+ /**
164
+ * Get fees paid for the transaction
165
+ * @param transactionId - the id of the transaction
166
+ * @return the fee paid in VTHO or 0
167
+ */
168
+ export const getFees = async (transactionID: string): Promise<BigNumber> => {
169
+ const { data } = await network({
170
+ method: "GET",
171
+ url: `${BASE_URL}/transactions/${transactionID}/receipt`,
172
+ params: { id: transactionID },
173
+ });
174
+
175
+ if (!data || !data.paid) return new BigNumber(0);
176
+ return new BigNumber(data.paid);
177
+ };
@@ -0,0 +1,25 @@
1
+ import { SignerContext } from "@ledgerhq/coin-framework/signer";
2
+ import eip55 from "eip55";
3
+ import { VechainSigner } from "../types";
4
+ import { GetAddressFn } from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
5
+ import { GetAddressOptions } from "@ledgerhq/coin-framework/derivation";
6
+
7
+ const resolver = (signerContext: SignerContext<VechainSigner>): GetAddressFn => {
8
+ return async (deviceId: string, { path, verify }: GetAddressOptions) => {
9
+ const sig = await signerContext(deviceId, async signer => {
10
+ return await signer.getAddress(path, verify, false); // Note: Do we need to check askChainCode or false?
11
+ });
12
+
13
+ if (!sig.address || !sig.publicKey.length)
14
+ throw Error(`[vechain] Response is empty ${sig.address} ${sig.publicKey}`);
15
+
16
+ const address = eip55.encode(sig.address);
17
+ return {
18
+ address,
19
+ publicKey: sig.publicKey,
20
+ path,
21
+ };
22
+ };
23
+ };
24
+
25
+ export default resolver;
@@ -0,0 +1,4 @@
1
+ import resolver from "./getAddress";
2
+
3
+ export * from "./signMessage";
4
+ export default resolver;