@ledgerhq/coin-aptos 1.4.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (439) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/.unimportedrc.json +16 -0
  3. package/CHANGELOG.md +18 -0
  4. package/LICENSE.txt +21 -0
  5. package/jest.config.js +8 -0
  6. package/lib/__tests__/api/index.test.d.ts +2 -0
  7. package/lib/__tests__/api/index.test.d.ts.map +1 -0
  8. package/lib/__tests__/api/index.test.js +447 -0
  9. package/lib/__tests__/api/index.test.js.map +1 -0
  10. package/lib/__tests__/bridge/broadcast.test.d.ts +2 -0
  11. package/lib/__tests__/bridge/broadcast.test.d.ts.map +1 -0
  12. package/lib/__tests__/bridge/broadcast.test.js +98 -0
  13. package/lib/__tests__/bridge/broadcast.test.js.map +1 -0
  14. package/lib/__tests__/bridge/buildTransaction.test.d.ts +2 -0
  15. package/lib/__tests__/bridge/buildTransaction.test.d.ts.map +1 -0
  16. package/lib/__tests__/bridge/buildTransaction.test.js +62 -0
  17. package/lib/__tests__/bridge/buildTransaction.test.js.map +1 -0
  18. package/lib/__tests__/bridge/createTransaction.test.d.ts +2 -0
  19. package/lib/__tests__/bridge/createTransaction.test.d.ts.map +1 -0
  20. package/lib/__tests__/bridge/createTransaction.test.js +38 -0
  21. package/lib/__tests__/bridge/createTransaction.test.js.map +1 -0
  22. package/lib/__tests__/bridge/deviceTransactionConfig.test.d.ts +2 -0
  23. package/lib/__tests__/bridge/deviceTransactionConfig.test.d.ts.map +1 -0
  24. package/lib/__tests__/bridge/deviceTransactionConfig.test.js +43 -0
  25. package/lib/__tests__/bridge/deviceTransactionConfig.test.js.map +1 -0
  26. package/lib/__tests__/bridge/estimateMaxSpendable.test.d.ts +2 -0
  27. package/lib/__tests__/bridge/estimateMaxSpendable.test.d.ts.map +1 -0
  28. package/lib/__tests__/bridge/estimateMaxSpendable.test.js +84 -0
  29. package/lib/__tests__/bridge/estimateMaxSpendable.test.js.map +1 -0
  30. package/lib/__tests__/bridge/getFeesForTransaction.test.d.ts +2 -0
  31. package/lib/__tests__/bridge/getFeesForTransaction.test.d.ts.map +1 -0
  32. package/lib/__tests__/bridge/getFeesForTransaction.test.js +188 -0
  33. package/lib/__tests__/bridge/getFeesForTransaction.test.js.map +1 -0
  34. package/lib/__tests__/bridge/getTransactionStatus.test.d.ts +2 -0
  35. package/lib/__tests__/bridge/getTransactionStatus.test.d.ts.map +1 -0
  36. package/lib/__tests__/bridge/getTransactionStatus.test.js +133 -0
  37. package/lib/__tests__/bridge/getTransactionStatus.test.js.map +1 -0
  38. package/lib/__tests__/bridge/index.test.d.ts +2 -0
  39. package/lib/__tests__/bridge/index.test.d.ts.map +1 -0
  40. package/lib/__tests__/bridge/index.test.js +116 -0
  41. package/lib/__tests__/bridge/index.test.js.map +1 -0
  42. package/lib/__tests__/bridge/logic.test.d.ts +2 -0
  43. package/lib/__tests__/bridge/logic.test.d.ts.map +1 -0
  44. package/lib/__tests__/bridge/logic.test.js +773 -0
  45. package/lib/__tests__/bridge/logic.test.js.map +1 -0
  46. package/lib/__tests__/bridge/prepareTransaction.test.d.ts +2 -0
  47. package/lib/__tests__/bridge/prepareTransaction.test.d.ts.map +1 -0
  48. package/lib/__tests__/bridge/prepareTransaction.test.js +121 -0
  49. package/lib/__tests__/bridge/prepareTransaction.test.js.map +1 -0
  50. package/lib/__tests__/bridge/signOperation.test.d.ts +2 -0
  51. package/lib/__tests__/bridge/signOperation.test.d.ts.map +1 -0
  52. package/lib/__tests__/bridge/signOperation.test.js +185 -0
  53. package/lib/__tests__/bridge/signOperation.test.js.map +1 -0
  54. package/lib/__tests__/bridge/synchronisation.test.d.ts +2 -0
  55. package/lib/__tests__/bridge/synchronisation.test.d.ts.map +1 -0
  56. package/lib/__tests__/bridge/synchronisation.test.js +349 -0
  57. package/lib/__tests__/bridge/synchronisation.test.js.map +1 -0
  58. package/lib/__tests__/bridge/transaction.test.d.ts +2 -0
  59. package/lib/__tests__/bridge/transaction.test.d.ts.map +1 -0
  60. package/lib/__tests__/bridge/transaction.test.js +231 -0
  61. package/lib/__tests__/bridge/transaction.test.js.map +1 -0
  62. package/lib/__tests__/errors.test.d.ts +2 -0
  63. package/lib/__tests__/errors.test.d.ts.map +1 -0
  64. package/lib/__tests__/errors.test.js +18 -0
  65. package/lib/__tests__/errors.test.js.map +1 -0
  66. package/lib/__tests__/index.test.d.ts +2 -0
  67. package/lib/__tests__/index.test.d.ts.map +1 -0
  68. package/lib/__tests__/index.test.js +27 -0
  69. package/lib/__tests__/index.test.js.map +1 -0
  70. package/lib/__tests__/network/index.test.d.ts +2 -0
  71. package/lib/__tests__/network/index.test.d.ts.map +1 -0
  72. package/lib/__tests__/network/index.test.js +57 -0
  73. package/lib/__tests__/network/index.test.js.map +1 -0
  74. package/lib/__tests__/signer/index.test.d.ts +2 -0
  75. package/lib/__tests__/signer/index.test.d.ts.map +1 -0
  76. package/lib/__tests__/signer/index.test.js +37 -0
  77. package/lib/__tests__/signer/index.test.js.map +1 -0
  78. package/lib/api/graphql/queries.d.ts +5 -0
  79. package/lib/api/graphql/queries.d.ts.map +1 -0
  80. package/lib/api/graphql/queries.js +56 -0
  81. package/lib/api/graphql/queries.js.map +1 -0
  82. package/lib/api/graphql/types.d.ts +79 -0
  83. package/lib/api/graphql/types.d.ts.map +1 -0
  84. package/lib/api/graphql/types.js +3 -0
  85. package/lib/api/graphql/types.js.map +1 -0
  86. package/lib/api/index.d.ts +31 -0
  87. package/lib/api/index.d.ts.map +1 -0
  88. package/lib/api/index.js +200 -0
  89. package/lib/api/index.js.map +1 -0
  90. package/lib/bridge/bridge.fixture.d.ts +4 -0
  91. package/lib/bridge/bridge.fixture.d.ts.map +1 -0
  92. package/lib/bridge/bridge.fixture.js +56 -0
  93. package/lib/bridge/bridge.fixture.js.map +1 -0
  94. package/lib/bridge/broadcast.d.ts +7 -0
  95. package/lib/bridge/broadcast.d.ts.map +1 -0
  96. package/lib/bridge/broadcast.js +20 -0
  97. package/lib/bridge/broadcast.js.map +1 -0
  98. package/lib/bridge/buildTransaction.d.ts +7 -0
  99. package/lib/bridge/buildTransaction.d.ts.map +1 -0
  100. package/lib/bridge/buildTransaction.js +28 -0
  101. package/lib/bridge/buildTransaction.js.map +1 -0
  102. package/lib/bridge/createTransaction.d.ts +4 -0
  103. package/lib/bridge/createTransaction.d.ts.map +1 -0
  104. package/lib/bridge/createTransaction.js +20 -0
  105. package/lib/bridge/createTransaction.js.map +1 -0
  106. package/lib/bridge/deviceTransactionConfig.d.ts +11 -0
  107. package/lib/bridge/deviceTransactionConfig.d.ts.map +1 -0
  108. package/lib/bridge/deviceTransactionConfig.js +23 -0
  109. package/lib/bridge/deviceTransactionConfig.js.map +1 -0
  110. package/lib/bridge/estimateMaxSpendable.d.ts +10 -0
  111. package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -0
  112. package/lib/bridge/estimateMaxSpendable.js +30 -0
  113. package/lib/bridge/estimateMaxSpendable.js.map +1 -0
  114. package/lib/bridge/getFeesForTransaction.d.ts +16 -0
  115. package/lib/bridge/getFeesForTransaction.d.ts.map +1 -0
  116. package/lib/bridge/getFeesForTransaction.js +74 -0
  117. package/lib/bridge/getFeesForTransaction.js.map +1 -0
  118. package/lib/bridge/getTransactionStatus.d.ts +5 -0
  119. package/lib/bridge/getTransactionStatus.d.ts.map +1 -0
  120. package/lib/bridge/getTransactionStatus.js +48 -0
  121. package/lib/bridge/getTransactionStatus.js.map +1 -0
  122. package/lib/bridge/index.d.ts +8 -0
  123. package/lib/bridge/index.d.ts.map +1 -0
  124. package/lib/bridge/index.js +54 -0
  125. package/lib/bridge/index.js.map +1 -0
  126. package/lib/bridge/logic.d.ts +24 -0
  127. package/lib/bridge/logic.d.ts.map +1 -0
  128. package/lib/bridge/logic.js +200 -0
  129. package/lib/bridge/logic.js.map +1 -0
  130. package/lib/bridge/prepareTransaction.d.ts +5 -0
  131. package/lib/bridge/prepareTransaction.d.ts.map +1 -0
  132. package/lib/bridge/prepareTransaction.js +44 -0
  133. package/lib/bridge/prepareTransaction.js.map +1 -0
  134. package/lib/bridge/signOperation.d.ts +11 -0
  135. package/lib/bridge/signOperation.d.ts.map +1 -0
  136. package/lib/bridge/signOperation.js +77 -0
  137. package/lib/bridge/signOperation.js.map +1 -0
  138. package/lib/bridge/synchronisation.d.ts +3 -0
  139. package/lib/bridge/synchronisation.d.ts.map +1 -0
  140. package/lib/bridge/synchronisation.js +53 -0
  141. package/lib/bridge/synchronisation.js.map +1 -0
  142. package/lib/bridge/transaction.d.ts +15 -0
  143. package/lib/bridge/transaction.d.ts.map +1 -0
  144. package/lib/bridge/transaction.js +37 -0
  145. package/lib/bridge/transaction.js.map +1 -0
  146. package/lib/constants.d.ts +19 -0
  147. package/lib/constants.d.ts.map +1 -0
  148. package/lib/constants.js +33 -0
  149. package/lib/constants.js.map +1 -0
  150. package/lib/errors.d.ts +10 -0
  151. package/lib/errors.d.ts.map +1 -0
  152. package/lib/errors.js +8 -0
  153. package/lib/errors.js.map +1 -0
  154. package/lib/index.d.ts +3 -0
  155. package/lib/index.d.ts.map +1 -0
  156. package/lib/index.js +21 -0
  157. package/lib/index.js.map +1 -0
  158. package/lib/network/index.d.ts +6 -0
  159. package/lib/network/index.d.ts.map +1 -0
  160. package/lib/network/index.js +39 -0
  161. package/lib/network/index.js.map +1 -0
  162. package/lib/signer/index.d.ts +6 -0
  163. package/lib/signer/index.d.ts.map +1 -0
  164. package/lib/signer/index.js +23 -0
  165. package/lib/signer/index.js.map +1 -0
  166. package/lib/test/bot-specs.d.ts +7 -0
  167. package/lib/test/bot-specs.d.ts.map +1 -0
  168. package/lib/test/bot-specs.js +77 -0
  169. package/lib/test/bot-specs.js.map +1 -0
  170. package/lib/test/bridgeDatasetTest.d.ts +4 -0
  171. package/lib/test/bridgeDatasetTest.d.ts.map +1 -0
  172. package/lib/test/bridgeDatasetTest.js +85 -0
  173. package/lib/test/bridgeDatasetTest.js.map +1 -0
  174. package/lib/test/cli.d.ts +19 -0
  175. package/lib/test/cli.d.ts.map +1 -0
  176. package/lib/test/cli.js +59 -0
  177. package/lib/test/cli.js.map +1 -0
  178. package/lib/test/index.d.ts +4 -0
  179. package/lib/test/index.d.ts.map +1 -0
  180. package/lib/test/index.js +20 -0
  181. package/lib/test/index.js.map +1 -0
  182. package/lib/test/speculos-deviceActions.d.ts +5 -0
  183. package/lib/test/speculos-deviceActions.d.ts.map +1 -0
  184. package/lib/test/speculos-deviceActions.js +46 -0
  185. package/lib/test/speculos-deviceActions.js.map +1 -0
  186. package/lib/types/bridge.d.ts +5 -0
  187. package/lib/types/bridge.d.ts.map +1 -0
  188. package/lib/types/bridge.js +9 -0
  189. package/lib/types/bridge.js.map +1 -0
  190. package/lib/types/index.d.ts +62 -0
  191. package/lib/types/index.d.ts.map +1 -0
  192. package/lib/types/index.js +19 -0
  193. package/lib/types/index.js.map +1 -0
  194. package/lib/types/signer.d.ts +27 -0
  195. package/lib/types/signer.d.ts.map +1 -0
  196. package/lib/types/signer.js +3 -0
  197. package/lib/types/signer.js.map +1 -0
  198. package/lib-es/__tests__/api/index.test.d.ts +2 -0
  199. package/lib-es/__tests__/api/index.test.d.ts.map +1 -0
  200. package/lib-es/__tests__/api/index.test.js +442 -0
  201. package/lib-es/__tests__/api/index.test.js.map +1 -0
  202. package/lib-es/__tests__/bridge/broadcast.test.d.ts +2 -0
  203. package/lib-es/__tests__/bridge/broadcast.test.d.ts.map +1 -0
  204. package/lib-es/__tests__/bridge/broadcast.test.js +93 -0
  205. package/lib-es/__tests__/bridge/broadcast.test.js.map +1 -0
  206. package/lib-es/__tests__/bridge/buildTransaction.test.d.ts +2 -0
  207. package/lib-es/__tests__/bridge/buildTransaction.test.d.ts.map +1 -0
  208. package/lib-es/__tests__/bridge/buildTransaction.test.js +57 -0
  209. package/lib-es/__tests__/bridge/buildTransaction.test.js.map +1 -0
  210. package/lib-es/__tests__/bridge/createTransaction.test.d.ts +2 -0
  211. package/lib-es/__tests__/bridge/createTransaction.test.d.ts.map +1 -0
  212. package/lib-es/__tests__/bridge/createTransaction.test.js +33 -0
  213. package/lib-es/__tests__/bridge/createTransaction.test.js.map +1 -0
  214. package/lib-es/__tests__/bridge/deviceTransactionConfig.test.d.ts +2 -0
  215. package/lib-es/__tests__/bridge/deviceTransactionConfig.test.d.ts.map +1 -0
  216. package/lib-es/__tests__/bridge/deviceTransactionConfig.test.js +18 -0
  217. package/lib-es/__tests__/bridge/deviceTransactionConfig.test.js.map +1 -0
  218. package/lib-es/__tests__/bridge/estimateMaxSpendable.test.d.ts +2 -0
  219. package/lib-es/__tests__/bridge/estimateMaxSpendable.test.d.ts.map +1 -0
  220. package/lib-es/__tests__/bridge/estimateMaxSpendable.test.js +79 -0
  221. package/lib-es/__tests__/bridge/estimateMaxSpendable.test.js.map +1 -0
  222. package/lib-es/__tests__/bridge/getFeesForTransaction.test.d.ts +2 -0
  223. package/lib-es/__tests__/bridge/getFeesForTransaction.test.d.ts.map +1 -0
  224. package/lib-es/__tests__/bridge/getFeesForTransaction.test.js +160 -0
  225. package/lib-es/__tests__/bridge/getFeesForTransaction.test.js.map +1 -0
  226. package/lib-es/__tests__/bridge/getTransactionStatus.test.d.ts +2 -0
  227. package/lib-es/__tests__/bridge/getTransactionStatus.test.d.ts.map +1 -0
  228. package/lib-es/__tests__/bridge/getTransactionStatus.test.js +128 -0
  229. package/lib-es/__tests__/bridge/getTransactionStatus.test.js.map +1 -0
  230. package/lib-es/__tests__/bridge/index.test.d.ts +2 -0
  231. package/lib-es/__tests__/bridge/index.test.d.ts.map +1 -0
  232. package/lib-es/__tests__/bridge/index.test.js +111 -0
  233. package/lib-es/__tests__/bridge/index.test.js.map +1 -0
  234. package/lib-es/__tests__/bridge/logic.test.d.ts +2 -0
  235. package/lib-es/__tests__/bridge/logic.test.d.ts.map +1 -0
  236. package/lib-es/__tests__/bridge/logic.test.js +768 -0
  237. package/lib-es/__tests__/bridge/logic.test.js.map +1 -0
  238. package/lib-es/__tests__/bridge/prepareTransaction.test.d.ts +2 -0
  239. package/lib-es/__tests__/bridge/prepareTransaction.test.d.ts.map +1 -0
  240. package/lib-es/__tests__/bridge/prepareTransaction.test.js +116 -0
  241. package/lib-es/__tests__/bridge/prepareTransaction.test.js.map +1 -0
  242. package/lib-es/__tests__/bridge/signOperation.test.d.ts +2 -0
  243. package/lib-es/__tests__/bridge/signOperation.test.d.ts.map +1 -0
  244. package/lib-es/__tests__/bridge/signOperation.test.js +157 -0
  245. package/lib-es/__tests__/bridge/signOperation.test.js.map +1 -0
  246. package/lib-es/__tests__/bridge/synchronisation.test.d.ts +2 -0
  247. package/lib-es/__tests__/bridge/synchronisation.test.d.ts.map +1 -0
  248. package/lib-es/__tests__/bridge/synchronisation.test.js +347 -0
  249. package/lib-es/__tests__/bridge/synchronisation.test.js.map +1 -0
  250. package/lib-es/__tests__/bridge/transaction.test.d.ts +2 -0
  251. package/lib-es/__tests__/bridge/transaction.test.d.ts.map +1 -0
  252. package/lib-es/__tests__/bridge/transaction.test.js +226 -0
  253. package/lib-es/__tests__/bridge/transaction.test.js.map +1 -0
  254. package/lib-es/__tests__/errors.test.d.ts +2 -0
  255. package/lib-es/__tests__/errors.test.d.ts.map +1 -0
  256. package/lib-es/__tests__/errors.test.js +16 -0
  257. package/lib-es/__tests__/errors.test.js.map +1 -0
  258. package/lib-es/__tests__/index.test.d.ts +2 -0
  259. package/lib-es/__tests__/index.test.d.ts.map +1 -0
  260. package/lib-es/__tests__/index.test.js +25 -0
  261. package/lib-es/__tests__/index.test.js.map +1 -0
  262. package/lib-es/__tests__/network/index.test.d.ts +2 -0
  263. package/lib-es/__tests__/network/index.test.d.ts.map +1 -0
  264. package/lib-es/__tests__/network/index.test.js +55 -0
  265. package/lib-es/__tests__/network/index.test.js.map +1 -0
  266. package/lib-es/__tests__/signer/index.test.d.ts +2 -0
  267. package/lib-es/__tests__/signer/index.test.d.ts.map +1 -0
  268. package/lib-es/__tests__/signer/index.test.js +32 -0
  269. package/lib-es/__tests__/signer/index.test.js.map +1 -0
  270. package/lib-es/api/graphql/queries.d.ts +5 -0
  271. package/lib-es/api/graphql/queries.d.ts.map +1 -0
  272. package/lib-es/api/graphql/queries.js +53 -0
  273. package/lib-es/api/graphql/queries.js.map +1 -0
  274. package/lib-es/api/graphql/types.d.ts +79 -0
  275. package/lib-es/api/graphql/types.d.ts.map +1 -0
  276. package/lib-es/api/graphql/types.js +2 -0
  277. package/lib-es/api/graphql/types.js.map +1 -0
  278. package/lib-es/api/index.d.ts +31 -0
  279. package/lib-es/api/index.d.ts.map +1 -0
  280. package/lib-es/api/index.js +193 -0
  281. package/lib-es/api/index.js.map +1 -0
  282. package/lib-es/bridge/bridge.fixture.d.ts +4 -0
  283. package/lib-es/bridge/bridge.fixture.d.ts.map +1 -0
  284. package/lib-es/bridge/bridge.fixture.js +48 -0
  285. package/lib-es/bridge/bridge.fixture.js.map +1 -0
  286. package/lib-es/bridge/broadcast.d.ts +7 -0
  287. package/lib-es/bridge/broadcast.d.ts.map +1 -0
  288. package/lib-es/bridge/broadcast.js +18 -0
  289. package/lib-es/bridge/broadcast.js.map +1 -0
  290. package/lib-es/bridge/buildTransaction.d.ts +7 -0
  291. package/lib-es/bridge/buildTransaction.d.ts.map +1 -0
  292. package/lib-es/bridge/buildTransaction.js +26 -0
  293. package/lib-es/bridge/buildTransaction.js.map +1 -0
  294. package/lib-es/bridge/createTransaction.d.ts +4 -0
  295. package/lib-es/bridge/createTransaction.d.ts.map +1 -0
  296. package/lib-es/bridge/createTransaction.js +15 -0
  297. package/lib-es/bridge/createTransaction.js.map +1 -0
  298. package/lib-es/bridge/deviceTransactionConfig.d.ts +11 -0
  299. package/lib-es/bridge/deviceTransactionConfig.d.ts.map +1 -0
  300. package/lib-es/bridge/deviceTransactionConfig.js +19 -0
  301. package/lib-es/bridge/deviceTransactionConfig.js.map +1 -0
  302. package/lib-es/bridge/estimateMaxSpendable.d.ts +10 -0
  303. package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -0
  304. package/lib-es/bridge/estimateMaxSpendable.js +28 -0
  305. package/lib-es/bridge/estimateMaxSpendable.js.map +1 -0
  306. package/lib-es/bridge/getFeesForTransaction.d.ts +16 -0
  307. package/lib-es/bridge/getFeesForTransaction.d.ts.map +1 -0
  308. package/lib-es/bridge/getFeesForTransaction.js +66 -0
  309. package/lib-es/bridge/getFeesForTransaction.js.map +1 -0
  310. package/lib-es/bridge/getTransactionStatus.d.ts +5 -0
  311. package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -0
  312. package/lib-es/bridge/getTransactionStatus.js +46 -0
  313. package/lib-es/bridge/getTransactionStatus.js.map +1 -0
  314. package/lib-es/bridge/index.d.ts +8 -0
  315. package/lib-es/bridge/index.d.ts.map +1 -0
  316. package/lib-es/bridge/index.js +47 -0
  317. package/lib-es/bridge/index.js.map +1 -0
  318. package/lib-es/bridge/logic.d.ts +24 -0
  319. package/lib-es/bridge/logic.d.ts.map +1 -0
  320. package/lib-es/bridge/logic.js +183 -0
  321. package/lib-es/bridge/logic.js.map +1 -0
  322. package/lib-es/bridge/prepareTransaction.d.ts +5 -0
  323. package/lib-es/bridge/prepareTransaction.d.ts.map +1 -0
  324. package/lib-es/bridge/prepareTransaction.js +39 -0
  325. package/lib-es/bridge/prepareTransaction.js.map +1 -0
  326. package/lib-es/bridge/signOperation.d.ts +11 -0
  327. package/lib-es/bridge/signOperation.d.ts.map +1 -0
  328. package/lib-es/bridge/signOperation.js +70 -0
  329. package/lib-es/bridge/signOperation.js.map +1 -0
  330. package/lib-es/bridge/synchronisation.d.ts +3 -0
  331. package/lib-es/bridge/synchronisation.d.ts.map +1 -0
  332. package/lib-es/bridge/synchronisation.js +49 -0
  333. package/lib-es/bridge/synchronisation.js.map +1 -0
  334. package/lib-es/bridge/transaction.d.ts +15 -0
  335. package/lib-es/bridge/transaction.d.ts.map +1 -0
  336. package/lib-es/bridge/transaction.js +31 -0
  337. package/lib-es/bridge/transaction.js.map +1 -0
  338. package/lib-es/constants.d.ts +19 -0
  339. package/lib-es/constants.d.ts.map +1 -0
  340. package/lib-es/constants.js +30 -0
  341. package/lib-es/constants.js.map +1 -0
  342. package/lib-es/errors.d.ts +10 -0
  343. package/lib-es/errors.d.ts.map +1 -0
  344. package/lib-es/errors.js +5 -0
  345. package/lib-es/errors.js.map +1 -0
  346. package/lib-es/index.d.ts +3 -0
  347. package/lib-es/index.d.ts.map +1 -0
  348. package/lib-es/index.js +3 -0
  349. package/lib-es/index.js.map +1 -0
  350. package/lib-es/network/index.d.ts +6 -0
  351. package/lib-es/network/index.d.ts.map +1 -0
  352. package/lib-es/network/index.js +35 -0
  353. package/lib-es/network/index.js.map +1 -0
  354. package/lib-es/signer/index.d.ts +6 -0
  355. package/lib-es/signer/index.d.ts.map +1 -0
  356. package/lib-es/signer/index.js +21 -0
  357. package/lib-es/signer/index.js.map +1 -0
  358. package/lib-es/test/bot-specs.d.ts +7 -0
  359. package/lib-es/test/bot-specs.d.ts.map +1 -0
  360. package/lib-es/test/bot-specs.js +72 -0
  361. package/lib-es/test/bot-specs.js.map +1 -0
  362. package/lib-es/test/bridgeDatasetTest.d.ts +4 -0
  363. package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -0
  364. package/lib-es/test/bridgeDatasetTest.js +79 -0
  365. package/lib-es/test/bridgeDatasetTest.js.map +1 -0
  366. package/lib-es/test/cli.d.ts +19 -0
  367. package/lib-es/test/cli.d.ts.map +1 -0
  368. package/lib-es/test/cli.js +53 -0
  369. package/lib-es/test/cli.js.map +1 -0
  370. package/lib-es/test/index.d.ts +4 -0
  371. package/lib-es/test/index.d.ts.map +1 -0
  372. package/lib-es/test/index.js +4 -0
  373. package/lib-es/test/index.js.map +1 -0
  374. package/lib-es/test/speculos-deviceActions.d.ts +5 -0
  375. package/lib-es/test/speculos-deviceActions.d.ts.map +1 -0
  376. package/lib-es/test/speculos-deviceActions.js +43 -0
  377. package/lib-es/test/speculos-deviceActions.js.map +1 -0
  378. package/lib-es/types/bridge.d.ts +5 -0
  379. package/lib-es/types/bridge.d.ts.map +1 -0
  380. package/lib-es/types/bridge.js +6 -0
  381. package/lib-es/types/bridge.js.map +1 -0
  382. package/lib-es/types/index.d.ts +62 -0
  383. package/lib-es/types/index.d.ts.map +1 -0
  384. package/lib-es/types/index.js +3 -0
  385. package/lib-es/types/index.js.map +1 -0
  386. package/lib-es/types/signer.d.ts +27 -0
  387. package/lib-es/types/signer.d.ts.map +1 -0
  388. package/lib-es/types/signer.js +2 -0
  389. package/lib-es/types/signer.js.map +1 -0
  390. package/package.json +124 -0
  391. package/src/__tests__/api/index.test.ts +499 -0
  392. package/src/__tests__/bridge/broadcast.test.ts +98 -0
  393. package/src/__tests__/bridge/buildTransaction.test.ts +61 -0
  394. package/src/__tests__/bridge/createTransaction.test.ts +27 -0
  395. package/src/__tests__/bridge/deviceTransactionConfig.test.ts +19 -0
  396. package/src/__tests__/bridge/estimateMaxSpendable.test.ts +94 -0
  397. package/src/__tests__/bridge/getFeesForTransaction.test.ts +189 -0
  398. package/src/__tests__/bridge/getTransactionStatus.test.ts +155 -0
  399. package/src/__tests__/bridge/index.test.ts +108 -0
  400. package/src/__tests__/bridge/logic.test.ts +876 -0
  401. package/src/__tests__/bridge/prepareTransaction.test.ts +118 -0
  402. package/src/__tests__/bridge/signOperation.test.ts +178 -0
  403. package/src/__tests__/bridge/synchronisation.test.ts +374 -0
  404. package/src/__tests__/bridge/transaction.test.ts +261 -0
  405. package/src/__tests__/errors.test.ts +25 -0
  406. package/src/__tests__/index.test.ts +26 -0
  407. package/src/__tests__/network/index.test.ts +95 -0
  408. package/src/__tests__/signer/index.test.ts +24 -0
  409. package/src/api/graphql/queries.ts +53 -0
  410. package/src/api/graphql/types.ts +85 -0
  411. package/src/api/index.ts +224 -0
  412. package/src/bridge/bridge.fixture.ts +53 -0
  413. package/src/bridge/broadcast.ts +17 -0
  414. package/src/bridge/buildTransaction.ts +29 -0
  415. package/src/bridge/createTransaction.ts +17 -0
  416. package/src/bridge/deviceTransactionConfig.ts +30 -0
  417. package/src/bridge/estimateMaxSpendable.ts +35 -0
  418. package/src/bridge/getFeesForTransaction.ts +87 -0
  419. package/src/bridge/getTransactionStatus.ts +54 -0
  420. package/src/bridge/index.ts +65 -0
  421. package/src/bridge/logic.ts +265 -0
  422. package/src/bridge/prepareTransaction.ts +55 -0
  423. package/src/bridge/signOperation.ts +82 -0
  424. package/src/bridge/synchronisation.ts +50 -0
  425. package/src/bridge/transaction.ts +61 -0
  426. package/src/constants.ts +34 -0
  427. package/src/errors.ts +7 -0
  428. package/src/index.ts +3 -0
  429. package/src/network/index.ts +54 -0
  430. package/src/signer/index.ts +17 -0
  431. package/src/test/bot-specs.ts +86 -0
  432. package/src/test/bridgeDatasetTest.ts +82 -0
  433. package/src/test/cli.ts +80 -0
  434. package/src/test/index.ts +3 -0
  435. package/src/test/speculos-deviceActions.ts +52 -0
  436. package/src/types/bridge.ts +4 -0
  437. package/src/types/index.ts +74 -0
  438. package/src/types/signer.ts +26 -0
  439. package/tsconfig.json +14 -0
@@ -0,0 +1,118 @@
1
+ import prepareTransaction from "../../bridge/prepareTransaction";
2
+ import { AptosAPI } from "../../api";
3
+ import { getEstimatedGas } from "../../bridge/getFeesForTransaction";
4
+ import { getMaxSendBalance } from "../../bridge/logic";
5
+ import BigNumber from "bignumber.js";
6
+ import type { Account } from "@ledgerhq/types-live";
7
+ import type { Transaction } from "../../types";
8
+
9
+ jest.mock("../../api");
10
+ jest.mock("../../bridge/getFeesForTransaction");
11
+ jest.mock("../../bridge/logic");
12
+
13
+ describe("Aptos prepareTransaction", () => {
14
+ describe("prepareTransaction", () => {
15
+ let account: Account;
16
+ let transaction: Transaction;
17
+
18
+ beforeEach(() => {
19
+ account = {
20
+ id: "test-account-id",
21
+ name: "Test Account",
22
+ currency: {
23
+ id: "aptos",
24
+ name: "Aptos",
25
+ ticker: "APT",
26
+ units: [{ name: "Aptos", code: "APT", magnitude: 6 }],
27
+ },
28
+ spendableBalance: new BigNumber(1000),
29
+ balance: new BigNumber(1000),
30
+ blockHeight: 0,
31
+ operations: [],
32
+ pendingOperations: [],
33
+ unit: { code: "APT", name: "Aptos", magnitude: 6 },
34
+ lastSyncDate: new Date(),
35
+ subAccounts: [],
36
+ } as unknown as Account;
37
+
38
+ transaction = {
39
+ amount: new BigNumber(0),
40
+ recipient: "",
41
+ useAllAmount: false,
42
+ fees: new BigNumber(0),
43
+ } as Transaction;
44
+ });
45
+
46
+ it("should return the transaction if recipient is not set", async () => {
47
+ const result = await prepareTransaction(account, transaction);
48
+ expect(result).toEqual(transaction);
49
+ });
50
+
51
+ it("should return the transaction with zero fees if amount is zero and useAllAmount is false", async () => {
52
+ transaction.recipient = "test-recipient";
53
+ const result = await prepareTransaction(account, transaction);
54
+ expect(result.fees?.isZero()).toBe(true);
55
+ });
56
+
57
+ it("should set the amount to max sendable balance if useAllAmount is true", async () => {
58
+ transaction.recipient = "test-recipient";
59
+ transaction.useAllAmount = true;
60
+ (getMaxSendBalance as jest.Mock).mockReturnValue(new BigNumber(900));
61
+ (getEstimatedGas as jest.Mock).mockResolvedValue({
62
+ fees: new BigNumber(2000),
63
+ estimate: { maxGasAmount: new BigNumber(200), gasUnitPrice: new BigNumber(10) },
64
+ errors: {},
65
+ });
66
+
67
+ const result = await prepareTransaction(account, transaction);
68
+ expect(result.amount.isEqualTo(new BigNumber(900))).toBe(true);
69
+ expect(result.fees?.isEqualTo(new BigNumber(2000))).toBe(true);
70
+ expect(new BigNumber(result.options.maxGasAmount).isEqualTo(new BigNumber(200))).toBe(true);
71
+ expect(result.errors).toEqual({});
72
+ });
73
+
74
+ it("should call getEstimatedGas and set the transaction fees, estimate, and errors", async () => {
75
+ transaction.recipient = "test-recipient";
76
+ transaction.amount = new BigNumber(100);
77
+ (getEstimatedGas as jest.Mock).mockResolvedValue({
78
+ fees: new BigNumber(10),
79
+ estimate: { maxGasAmount: new BigNumber(200) },
80
+ errors: {},
81
+ });
82
+
83
+ const result = await prepareTransaction(account, transaction);
84
+ expect(getEstimatedGas).toHaveBeenCalledWith(account, transaction, expect.any(AptosAPI));
85
+ expect(result.fees?.isEqualTo(new BigNumber(10))).toBe(true);
86
+ expect(new BigNumber(result.options.maxGasAmount).isEqualTo(new BigNumber(200))).toBe(true);
87
+ expect(result.errors).toEqual({});
88
+ });
89
+
90
+ it("should return the transaction with updated fees and estimate if recipient is set and amount is not zero", async () => {
91
+ transaction.recipient = "test-recipient";
92
+ transaction.amount = new BigNumber(100);
93
+ (getEstimatedGas as jest.Mock).mockResolvedValue({
94
+ fees: new BigNumber(2000),
95
+ estimate: { maxGasAmount: new BigNumber(200), gasUnitPrice: new BigNumber(10) },
96
+ errors: {},
97
+ });
98
+
99
+ const result = await prepareTransaction(account, transaction);
100
+ expect(result.fees?.isEqualTo(new BigNumber(2000))).toBe(true);
101
+ expect(new BigNumber(result.options.maxGasAmount).isEqualTo(new BigNumber(200))).toBe(true);
102
+ expect(result.errors).toEqual({});
103
+ });
104
+
105
+ it("should set maxGasAmount in options", async () => {
106
+ transaction.recipient = "test-recipient";
107
+ transaction.amount = new BigNumber(100);
108
+ (getEstimatedGas as jest.Mock).mockResolvedValue({
109
+ fees: new BigNumber(2000),
110
+ estimate: { maxGasAmount: new BigNumber(200), gasUnitPrice: new BigNumber(10) },
111
+ errors: {},
112
+ });
113
+
114
+ const result = await prepareTransaction(account, transaction);
115
+ expect(new BigNumber(result.options.maxGasAmount).isEqualTo(new BigNumber(200))).toBe(true);
116
+ });
117
+ });
118
+ });
@@ -0,0 +1,178 @@
1
+ import BigNumber from "bignumber.js";
2
+ import { Observable } from "rxjs";
3
+ import { SignerContext } from "@ledgerhq/coin-framework/lib/signer";
4
+ import { createFixtureAccount, createFixtureTransaction } from "../../bridge/bridge.fixture";
5
+ import buildSignOperation, { getAddress } from "../../bridge/signOperation";
6
+ import { AptosSigner } from "../../types";
7
+ import { signTransaction } from "../../network";
8
+
9
+ jest.mock("../../api", () => {
10
+ return {
11
+ AptosAPI: function () {
12
+ return {
13
+ generateTransaction: jest.fn(() => "tx"),
14
+ };
15
+ },
16
+ };
17
+ });
18
+
19
+ jest.mock("../../bridge/buildTransaction", () => {
20
+ return function () {
21
+ return {
22
+ sequence_number: "789",
23
+ };
24
+ };
25
+ });
26
+
27
+ jest.mock("../../network");
28
+ let mockedSignTransaction: jest.Mocked<any>;
29
+
30
+ describe("getAddress", () => {
31
+ it("should return address and derivationPath", () => {
32
+ const account = createFixtureAccount();
33
+ expect(getAddress(account)).toEqual({ address: "address", derivationPath: "derivation_path" });
34
+ });
35
+ });
36
+
37
+ describe("buildSignOperation", () => {
38
+ beforeEach(() => {
39
+ mockedSignTransaction = jest.mocked(signTransaction);
40
+ });
41
+ afterEach(() => jest.clearAllMocks());
42
+
43
+ it("should thrown an error", async () => {
44
+ mockedSignTransaction.mockImplementation(() => {
45
+ throw new Error("observable-catch-error");
46
+ });
47
+
48
+ const account = createFixtureAccount();
49
+ const transaction = createFixtureTransaction();
50
+
51
+ account.id = "js:2:aptos:0x000:";
52
+ transaction.mode = "send";
53
+
54
+ const observable = await buildSignOperation({} as unknown as SignerContext<AptosSigner>)({
55
+ account,
56
+ deviceId: "1",
57
+ transaction,
58
+ });
59
+
60
+ observable.subscribe({
61
+ error: err => {
62
+ expect(err.message).toBe("observable-catch-error");
63
+ },
64
+ });
65
+ });
66
+
67
+ it("should return 3 operations", async () => {
68
+ mockedSignTransaction.mockReturnValue("signedTx");
69
+
70
+ const date = new Date("2020-01-01");
71
+ jest.useFakeTimers().setSystemTime(date);
72
+
73
+ const account = createFixtureAccount();
74
+ const transaction = createFixtureTransaction();
75
+
76
+ account.id = "js:2:aptos:0x000:";
77
+ transaction.mode = "send";
78
+
79
+ const observable = await buildSignOperation({} as unknown as SignerContext<AptosSigner>)({
80
+ account,
81
+ deviceId: "1",
82
+ transaction,
83
+ });
84
+
85
+ expect(observable).toBeInstanceOf(Observable);
86
+
87
+ const expectedValues = [
88
+ { type: "device-signature-requested" },
89
+ { type: "device-signature-granted" },
90
+ {
91
+ type: "signed",
92
+ signedOperation: {
93
+ operation: {
94
+ id: "js:2:aptos:0x000:--OUT",
95
+ hash: "",
96
+ type: "OUT",
97
+ value: new BigNumber(0),
98
+ fee: new BigNumber(0),
99
+ extra: {},
100
+ blockHash: null,
101
+ blockHeight: null,
102
+ senders: [account.freshAddress],
103
+ recipients: [transaction.recipient],
104
+ accountId: "js:2:aptos:0x000:",
105
+ date,
106
+ transactionSequenceNumber: 789,
107
+ },
108
+ signature: "7369676e65645478",
109
+ },
110
+ },
111
+ ];
112
+
113
+ let i = 0;
114
+
115
+ observable.forEach(signOperationEvent => {
116
+ expect(signOperationEvent).toEqual(expectedValues[i]);
117
+ i++;
118
+ });
119
+ });
120
+
121
+ it("should return 3 operations with all amount", async () => {
122
+ mockedSignTransaction.mockReturnValue("signedTx");
123
+
124
+ const date = new Date("2020-01-01");
125
+ jest.useFakeTimers().setSystemTime(date);
126
+
127
+ const account = createFixtureAccount();
128
+ const transaction = createFixtureTransaction();
129
+
130
+ account.balance = new BigNumber(40);
131
+ transaction.fees = new BigNumber(30);
132
+ transaction.useAllAmount = true;
133
+
134
+ account.id = "js:2:aptos:0x000:";
135
+ transaction.mode = "send";
136
+
137
+ const observable = await buildSignOperation({} as unknown as SignerContext<AptosSigner>)({
138
+ account,
139
+ deviceId: "1",
140
+ transaction,
141
+ });
142
+
143
+ expect(observable).toBeInstanceOf(Observable);
144
+
145
+ const expectedValues = [
146
+ { type: "device-signature-requested" },
147
+ { type: "device-signature-granted" },
148
+ {
149
+ type: "signed",
150
+ signedOperation: {
151
+ operation: {
152
+ id: "js:2:aptos:0x000:--OUT",
153
+ hash: "",
154
+ type: "OUT",
155
+ value: new BigNumber(10),
156
+ fee: transaction.fees,
157
+ extra: {},
158
+ blockHash: null,
159
+ blockHeight: null,
160
+ senders: [account.freshAddress],
161
+ recipients: [transaction.recipient],
162
+ accountId: "js:2:aptos:0x000:",
163
+ date,
164
+ transactionSequenceNumber: 789,
165
+ },
166
+ signature: "7369676e65645478",
167
+ },
168
+ },
169
+ ];
170
+
171
+ let i = 0;
172
+
173
+ observable.forEach(signOperationEvent => {
174
+ expect(signOperationEvent).toEqual(expectedValues[i]);
175
+ i++;
176
+ });
177
+ });
178
+ });
@@ -0,0 +1,374 @@
1
+ import { AccountShapeInfo } from "@ledgerhq/coin-framework/bridge/jsHelpers";
2
+ import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/index";
3
+ import { Account, SyncConfig } from "@ledgerhq/types-live";
4
+ import { encodeAccountId } from "@ledgerhq/coin-framework/account";
5
+ import { mergeOps } from "@ledgerhq/coin-framework/bridge/jsHelpers";
6
+ import { AptosAPI } from "../../api";
7
+ import { getAccountShape } from "../../bridge/synchronisation";
8
+
9
+ jest.mock("@ledgerhq/coin-framework/account", () => {
10
+ const originalModule = jest.requireActual("@ledgerhq/coin-framework/account");
11
+ const partialMockedModule = Object.keys(originalModule).reduce(
12
+ (pre: { [key: string]: jest.Mock }, methodName) => {
13
+ pre[methodName] = jest.fn();
14
+ return pre;
15
+ },
16
+ {} as { [key: string]: jest.Mock },
17
+ );
18
+ return {
19
+ ...partialMockedModule,
20
+ // mock all except these
21
+ decodeAccountId: originalModule.decodeAccountId,
22
+ };
23
+ });
24
+
25
+ const mockedEncodeAccountId = jest.mocked(encodeAccountId);
26
+
27
+ jest.mock("../../api");
28
+ let mockedAptosAPI: jest.Mocked<any>;
29
+
30
+ jest.mock("@ledgerhq/coin-framework/bridge/jsHelpers");
31
+ jest.mock("invariant", () => jest.fn());
32
+
33
+ describe("getAccountShape", () => {
34
+ beforeEach(() => {
35
+ mockedAptosAPI = jest.mocked(AptosAPI);
36
+ jest.mocked(mergeOps).mockReturnValue([]);
37
+ });
38
+
39
+ afterEach(() => {
40
+ jest.resetAllMocks();
41
+ });
42
+
43
+ it("account with xpub", async () => {
44
+ const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
45
+ balance: BigInt(0),
46
+ transactions: [],
47
+ blockHeight: 0,
48
+ }));
49
+ mockedAptosAPI.mockImplementation(() => ({
50
+ getAccountInfo: mockGetAccountInfo,
51
+ }));
52
+ const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
53
+
54
+ const account = await getAccountShape(
55
+ {
56
+ id: "1",
57
+ address: "address",
58
+ currency: getCryptoCurrencyById("aptos"),
59
+ derivationMode: "",
60
+ index: 0,
61
+ xpub: "address",
62
+ derivationPath: "",
63
+ deviceId: "1",
64
+ initialAccount: {
65
+ id: "1:1:1:1:1",
66
+ xpub: "address",
67
+ seedIdentifier: "1",
68
+ derivationMode: "",
69
+ index: 0,
70
+ freshAddress: "address",
71
+ freshAddressPath: "",
72
+ used: true,
73
+ balance: BigInt(10),
74
+ spendableBalance: BigInt(10),
75
+ creationDate: new Date(),
76
+ blockHeight: 0,
77
+ currency: getCryptoCurrencyById("aptos"),
78
+ operationsCount: 0,
79
+ operations: [],
80
+ pendingOperations: [],
81
+ lastSyncDate: new Date(),
82
+ balanceHistoryCache: {},
83
+ swapHistory: [],
84
+ },
85
+ } as unknown as AccountShapeInfo<Account>,
86
+ {} as SyncConfig,
87
+ );
88
+
89
+ expect(account.xpub).toEqual("address");
90
+ expect(mockedEncodeAccountId).toHaveBeenCalledTimes(1);
91
+ expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
92
+ expect(mockGetAccountSpy).toHaveBeenCalledWith("address", undefined);
93
+ });
94
+
95
+ it("account without xpub", async () => {
96
+ const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
97
+ balance: BigInt(0),
98
+ transactions: [],
99
+ blockHeight: 0,
100
+ }));
101
+ mockedAptosAPI.mockImplementation(() => ({
102
+ getAccountInfo: mockGetAccountInfo,
103
+ }));
104
+ const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
105
+
106
+ const account = await getAccountShape(
107
+ {
108
+ id: "1",
109
+ address: "address",
110
+ currency: getCryptoCurrencyById("aptos"),
111
+ derivationMode: "",
112
+ index: 0,
113
+ xpub: "address",
114
+ derivationPath: "",
115
+ deviceId: "1",
116
+ initialAccount: {
117
+ id: "1:1:1:1:1",
118
+ seedIdentifier: "1",
119
+ derivationMode: "",
120
+ index: 0,
121
+ freshAddress: "address",
122
+ freshAddressPath: "",
123
+ used: true,
124
+ balance: BigInt(10),
125
+ spendableBalance: BigInt(10),
126
+ creationDate: new Date(),
127
+ blockHeight: 0,
128
+ currency: getCryptoCurrencyById("aptos"),
129
+ operationsCount: 0,
130
+ operations: [],
131
+ pendingOperations: [],
132
+ lastSyncDate: new Date(),
133
+ balanceHistoryCache: {},
134
+ swapHistory: [],
135
+ },
136
+ } as unknown as AccountShapeInfo<Account>,
137
+ {} as SyncConfig,
138
+ );
139
+
140
+ expect(account.xpub).toEqual("1");
141
+ expect(mockedEncodeAccountId).toHaveBeenCalledTimes(1);
142
+ expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
143
+ expect(mockGetAccountSpy).toHaveBeenCalledWith("address", undefined);
144
+ });
145
+
146
+ it("without initialAccount", async () => {
147
+ const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
148
+ balance: BigInt(0),
149
+ transactions: [],
150
+ blockHeight: 0,
151
+ }));
152
+ mockedAptosAPI.mockImplementation(() => ({
153
+ getAccountInfo: mockGetAccountInfo,
154
+ }));
155
+ const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
156
+
157
+ const account = await getAccountShape(
158
+ {
159
+ id: "1",
160
+ address: "address",
161
+ currency: getCryptoCurrencyById("aptos"),
162
+ derivationMode: "",
163
+ index: 0,
164
+ xpub: "address",
165
+ derivationPath: "",
166
+ deviceId: "1",
167
+ } as unknown as AccountShapeInfo<Account>,
168
+ {} as SyncConfig,
169
+ );
170
+
171
+ expect(account.xpub).toEqual("");
172
+ expect(mockedEncodeAccountId).toHaveBeenCalledTimes(1);
173
+ expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
174
+ expect(mockGetAccountSpy).toHaveBeenCalledWith("address", undefined);
175
+ });
176
+
177
+ it("initialAccount with operations", async () => {
178
+ const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
179
+ balance: BigInt(0),
180
+ transactions: [],
181
+ blockHeight: 0,
182
+ }));
183
+ mockedAptosAPI.mockImplementation(() => ({
184
+ getAccountInfo: mockGetAccountInfo,
185
+ }));
186
+ const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
187
+
188
+ const account = await getAccountShape(
189
+ {
190
+ id: "1",
191
+ address: "address",
192
+ currency: getCryptoCurrencyById("aptos"),
193
+ derivationMode: "",
194
+ index: 0,
195
+ xpub: "address",
196
+ derivationPath: "",
197
+ deviceId: "1",
198
+ initialAccount: {
199
+ id: "1:1:1:1:1",
200
+ seedIdentifier: "1",
201
+ derivationMode: "",
202
+ index: 0,
203
+ freshAddress: "address",
204
+ freshAddressPath: "",
205
+ used: true,
206
+ balance: BigInt(10),
207
+ spendableBalance: BigInt(10),
208
+ creationDate: new Date(),
209
+ blockHeight: 0,
210
+ currency: getCryptoCurrencyById("aptos"),
211
+ t: 1,
212
+ operations: [
213
+ {
214
+ id: "1",
215
+ hash: "hash",
216
+ type: "OUT",
217
+ value: BigInt(10),
218
+ fee: BigInt(0),
219
+ blockHeight: 0,
220
+ blockHash: "blockHash",
221
+ accountId: "1",
222
+ senders: ["sender"],
223
+ recipients: ["recipient"],
224
+ date: new Date(),
225
+ },
226
+ ],
227
+ pendingOperations: [],
228
+ lastSyncDate: new Date(),
229
+ balanceHistoryCache: {},
230
+ swapHistory: [],
231
+ },
232
+ } as unknown as AccountShapeInfo<Account>,
233
+ {} as SyncConfig,
234
+ );
235
+
236
+ expect(account.xpub).toEqual("1");
237
+ expect(mockedEncodeAccountId).toHaveBeenCalledTimes(1);
238
+ expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
239
+ expect(mockGetAccountSpy).toHaveBeenCalledWith("address", undefined);
240
+ });
241
+
242
+ it("initialAccount with operations with extra", async () => {
243
+ const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
244
+ balance: BigInt(0),
245
+ transactions: [],
246
+ blockHeight: 0,
247
+ }));
248
+ mockedAptosAPI.mockImplementation(() => ({
249
+ getAccountInfo: mockGetAccountInfo,
250
+ }));
251
+ const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
252
+
253
+ const account = await getAccountShape(
254
+ {
255
+ id: "1",
256
+ address: "address",
257
+ currency: getCryptoCurrencyById("aptos"),
258
+ derivationMode: "",
259
+ index: 0,
260
+ xpub: "address",
261
+ derivationPath: "",
262
+ deviceId: "1",
263
+ initialAccount: {
264
+ id: "1:1:1:1:1",
265
+ seedIdentifier: "1",
266
+ derivationMode: "",
267
+ index: 0,
268
+ freshAddress: "address",
269
+ freshAddressPath: "",
270
+ used: true,
271
+ balance: BigInt(10),
272
+ spendableBalance: BigInt(10),
273
+ creationDate: new Date(),
274
+ blockHeight: 0,
275
+ currency: getCryptoCurrencyById("aptos"),
276
+ t: 1,
277
+ operations: [
278
+ {
279
+ id: "1",
280
+ hash: "hash",
281
+ type: "OUT",
282
+ value: BigInt(10),
283
+ fee: BigInt(0),
284
+ blockHeight: 0,
285
+ blockHash: "blockHash",
286
+ accountId: "1",
287
+ senders: ["sender"],
288
+ recipients: ["recipient"],
289
+ date: new Date(),
290
+ extra: { version: 1 },
291
+ },
292
+ ],
293
+ pendingOperations: [],
294
+ lastSyncDate: new Date(),
295
+ balanceHistoryCache: {},
296
+ swapHistory: [],
297
+ },
298
+ } as unknown as AccountShapeInfo<Account>,
299
+ {} as SyncConfig,
300
+ );
301
+
302
+ expect(account.xpub).toEqual("1");
303
+ expect(mockedEncodeAccountId).toHaveBeenCalledTimes(1);
304
+ expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
305
+ expect(mockGetAccountSpy).toHaveBeenCalledWith("address", 1);
306
+ });
307
+
308
+ it("get publicKey from rest", async () => {
309
+ const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
310
+ balance: BigInt(0),
311
+ transactions: [],
312
+ blockHeight: 0,
313
+ }));
314
+ mockedAptosAPI.mockImplementation(() => ({
315
+ getAccountInfo: mockGetAccountInfo,
316
+ }));
317
+ const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
318
+
319
+ const account = await getAccountShape(
320
+ {
321
+ id: "1",
322
+ address: "address",
323
+ currency: getCryptoCurrencyById("aptos"),
324
+ derivationMode: "",
325
+ index: 0,
326
+ xpub: "address",
327
+ derivationPath: "",
328
+ deviceId: "1",
329
+ initialAccount: {
330
+ id: "1:1:1:1:1",
331
+ seedIdentifier: "1",
332
+ derivationMode: "",
333
+ index: 0,
334
+ freshAddress: "address",
335
+ freshAddressPath: "",
336
+ used: true,
337
+ balance: BigInt(10),
338
+ spendableBalance: BigInt(10),
339
+ creationDate: new Date(),
340
+ blockHeight: 0,
341
+ currency: getCryptoCurrencyById("aptos"),
342
+ t: 1,
343
+ operations: [
344
+ {
345
+ id: "1",
346
+ hash: "hash",
347
+ type: "OUT",
348
+ value: BigInt(10),
349
+ fee: BigInt(0),
350
+ blockHeight: 0,
351
+ blockHash: "blockHash",
352
+ accountId: "1",
353
+ senders: ["sender"],
354
+ recipients: ["recipient"],
355
+ date: new Date(),
356
+ extra: { version: 1 },
357
+ },
358
+ ],
359
+ pendingOperations: [],
360
+ lastSyncDate: new Date(),
361
+ balanceHistoryCache: {},
362
+ swapHistory: [],
363
+ },
364
+ rest: { publicKey: "restPublicKey" },
365
+ } as unknown as AccountShapeInfo<Account>,
366
+ {} as SyncConfig,
367
+ );
368
+
369
+ expect(account.xpub).toEqual("restPublicKey");
370
+ expect(mockedEncodeAccountId).toHaveBeenCalledTimes(1);
371
+ expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
372
+ expect(mockGetAccountSpy).toHaveBeenCalledWith("address", 1);
373
+ });
374
+ });