@ledgerhq/coin-aptos 3.4.0-nightly.8 → 3.4.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 (299) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +25 -73
  3. package/lib/__tests__/api/craftTransaction.unit.test.d.ts +2 -0
  4. package/lib/__tests__/api/craftTransaction.unit.test.d.ts.map +1 -0
  5. package/lib/__tests__/api/craftTransaction.unit.test.js +177 -0
  6. package/lib/__tests__/api/craftTransaction.unit.test.js.map +1 -0
  7. package/lib/__tests__/api/getBalance.unit.test.d.ts +2 -0
  8. package/lib/__tests__/api/getBalance.unit.test.d.ts.map +1 -0
  9. package/lib/__tests__/api/getBalance.unit.test.js +80 -0
  10. package/lib/__tests__/api/getBalance.unit.test.js.map +1 -0
  11. package/lib/__tests__/api/index.integ.test.d.ts +2 -0
  12. package/lib/__tests__/api/index.integ.test.d.ts.map +1 -0
  13. package/lib/__tests__/api/index.integ.test.js +340 -0
  14. package/lib/__tests__/api/index.integ.test.js.map +1 -0
  15. package/lib/__tests__/api/index.test.d.ts +2 -0
  16. package/lib/__tests__/api/index.test.d.ts.map +1 -0
  17. package/lib/__tests__/api/index.test.js +66 -0
  18. package/lib/__tests__/api/index.test.js.map +1 -0
  19. package/lib/__tests__/bridge/broadcast.test.d.ts +2 -0
  20. package/lib/__tests__/bridge/broadcast.test.d.ts.map +1 -0
  21. package/lib/__tests__/bridge/broadcast.test.js +92 -0
  22. package/lib/__tests__/bridge/broadcast.test.js.map +1 -0
  23. package/lib/__tests__/bridge/deviceTransactionConfig.test.d.ts +2 -0
  24. package/lib/__tests__/bridge/deviceTransactionConfig.test.d.ts.map +1 -0
  25. package/lib/__tests__/bridge/deviceTransactionConfig.test.js +128 -0
  26. package/lib/__tests__/bridge/deviceTransactionConfig.test.js.map +1 -0
  27. package/lib/__tests__/bridge/estimateMaxSpendable.test.d.ts +2 -0
  28. package/lib/__tests__/bridge/estimateMaxSpendable.test.d.ts.map +1 -0
  29. package/lib/__tests__/bridge/estimateMaxSpendable.test.js +75 -0
  30. package/lib/__tests__/bridge/estimateMaxSpendable.test.js.map +1 -0
  31. package/lib/__tests__/bridge/getFeesForTransaction.test.d.ts +2 -0
  32. package/lib/__tests__/bridge/getFeesForTransaction.test.d.ts.map +1 -0
  33. package/lib/__tests__/bridge/getFeesForTransaction.test.js +280 -0
  34. package/lib/__tests__/bridge/getFeesForTransaction.test.js.map +1 -0
  35. package/lib/__tests__/bridge/getTransactionStatus.test.d.ts +2 -0
  36. package/lib/__tests__/bridge/getTransactionStatus.test.d.ts.map +1 -0
  37. package/lib/__tests__/bridge/getTransactionStatus.test.js +453 -0
  38. package/lib/__tests__/bridge/getTransactionStatus.test.js.map +1 -0
  39. package/lib/__tests__/bridge/index.test.d.ts +2 -0
  40. package/lib/__tests__/bridge/index.test.d.ts.map +1 -0
  41. package/lib/__tests__/bridge/index.test.js +110 -0
  42. package/lib/__tests__/bridge/index.test.js.map +1 -0
  43. package/lib/__tests__/bridge/logic.test.d.ts +2 -0
  44. package/lib/__tests__/bridge/logic.test.d.ts.map +1 -0
  45. package/lib/__tests__/bridge/logic.test.js +997 -0
  46. package/lib/__tests__/bridge/logic.test.js.map +1 -0
  47. package/lib/__tests__/bridge/prepareTransaction.test.d.ts +2 -0
  48. package/lib/__tests__/bridge/prepareTransaction.test.d.ts.map +1 -0
  49. package/lib/__tests__/bridge/prepareTransaction.test.js +109 -0
  50. package/lib/__tests__/bridge/prepareTransaction.test.js.map +1 -0
  51. package/lib/__tests__/bridge/serialization.d.ts +2 -0
  52. package/lib/__tests__/bridge/serialization.d.ts.map +1 -0
  53. package/lib/__tests__/bridge/serialization.js +91 -0
  54. package/lib/__tests__/bridge/serialization.js.map +1 -0
  55. package/lib/__tests__/bridge/signOperation.test.d.ts +2 -0
  56. package/lib/__tests__/bridge/signOperation.test.d.ts.map +1 -0
  57. package/lib/__tests__/bridge/signOperation.test.js +299 -0
  58. package/lib/__tests__/bridge/signOperation.test.js.map +1 -0
  59. package/lib/__tests__/bridge/synchronisation.test.d.ts +2 -0
  60. package/lib/__tests__/bridge/synchronisation.test.d.ts.map +1 -0
  61. package/lib/__tests__/bridge/synchronisation.test.js +2226 -0
  62. package/lib/__tests__/bridge/synchronisation.test.js.map +1 -0
  63. package/lib/__tests__/bridge/transaction.test.d.ts +2 -0
  64. package/lib/__tests__/bridge/transaction.test.d.ts.map +1 -0
  65. package/lib/__tests__/bridge/transaction.test.js +221 -0
  66. package/lib/__tests__/bridge/transaction.test.js.map +1 -0
  67. package/lib/__tests__/errors.test.d.ts +2 -0
  68. package/lib/__tests__/errors.test.d.ts.map +1 -0
  69. package/lib/__tests__/errors.test.js +18 -0
  70. package/lib/__tests__/errors.test.js.map +1 -0
  71. package/lib/__tests__/index.test.d.ts +2 -0
  72. package/lib/__tests__/index.test.d.ts.map +1 -0
  73. package/lib/__tests__/index.test.js +27 -0
  74. package/lib/__tests__/index.test.js.map +1 -0
  75. package/lib/__tests__/logic/buildTransaction.test.d.ts +2 -0
  76. package/lib/__tests__/logic/buildTransaction.test.d.ts.map +1 -0
  77. package/lib/__tests__/logic/buildTransaction.test.js +114 -0
  78. package/lib/__tests__/logic/buildTransaction.test.js.map +1 -0
  79. package/lib/__tests__/logic/calculateAmount.unit.test.d.ts +2 -0
  80. package/lib/__tests__/logic/calculateAmount.unit.test.d.ts.map +1 -0
  81. package/lib/__tests__/logic/calculateAmount.unit.test.js +45 -0
  82. package/lib/__tests__/logic/calculateAmount.unit.test.js.map +1 -0
  83. package/lib/__tests__/logic/combine.unit.test.d.ts +2 -0
  84. package/lib/__tests__/logic/combine.unit.test.d.ts.map +1 -0
  85. package/lib/__tests__/logic/combine.unit.test.js +47 -0
  86. package/lib/__tests__/logic/combine.unit.test.js.map +1 -0
  87. package/lib/__tests__/logic/compareAddress.unit.test.d.ts +2 -0
  88. package/lib/__tests__/logic/compareAddress.unit.test.d.ts.map +1 -0
  89. package/lib/__tests__/logic/compareAddress.unit.test.js +26 -0
  90. package/lib/__tests__/logic/compareAddress.unit.test.js.map +1 -0
  91. package/lib/__tests__/logic/createTransaction.test.d.ts +2 -0
  92. package/lib/__tests__/logic/createTransaction.test.d.ts.map +1 -0
  93. package/lib/__tests__/logic/createTransaction.test.js +29 -0
  94. package/lib/__tests__/logic/createTransaction.test.js.map +1 -0
  95. package/lib/__tests__/logic/getBalances.test.d.ts +2 -0
  96. package/lib/__tests__/logic/getBalances.test.d.ts.map +1 -0
  97. package/lib/__tests__/logic/getBalances.test.js +62 -0
  98. package/lib/__tests__/logic/getBalances.test.js.map +1 -0
  99. package/lib/__tests__/logic/getCoinAndAmounts.unit.test.d.ts +2 -0
  100. package/lib/__tests__/logic/getCoinAndAmounts.unit.test.d.ts.map +1 -0
  101. package/lib/__tests__/logic/getCoinAndAmounts.unit.test.js +186 -0
  102. package/lib/__tests__/logic/getCoinAndAmounts.unit.test.js.map +1 -0
  103. package/lib/__tests__/logic/getFunctionAddress.unit.test.d.ts +2 -0
  104. package/lib/__tests__/logic/getFunctionAddress.unit.test.d.ts.map +1 -0
  105. package/lib/__tests__/logic/getFunctionAddress.unit.test.js +29 -0
  106. package/lib/__tests__/logic/getFunctionAddress.unit.test.js.map +1 -0
  107. package/lib/__tests__/logic/getResourceAddress.unit.test.d.ts +2 -0
  108. package/lib/__tests__/logic/getResourceAddress.unit.test.d.ts.map +1 -0
  109. package/lib/__tests__/logic/getResourceAddress.unit.test.js +218 -0
  110. package/lib/__tests__/logic/getResourceAddress.unit.test.js.map +1 -0
  111. package/lib/__tests__/logic/isTestnet.unit.test.d.ts +2 -0
  112. package/lib/__tests__/logic/isTestnet.unit.test.d.ts.map +1 -0
  113. package/lib/__tests__/logic/isTestnet.unit.test.js +12 -0
  114. package/lib/__tests__/logic/isTestnet.unit.test.js.map +1 -0
  115. package/lib/__tests__/logic/normalizeAddress.unit.test.d.ts +2 -0
  116. package/lib/__tests__/logic/normalizeAddress.unit.test.d.ts.map +1 -0
  117. package/lib/__tests__/logic/normalizeAddress.unit.test.js +12 -0
  118. package/lib/__tests__/logic/normalizeAddress.unit.test.js.map +1 -0
  119. package/lib/__tests__/logic/processRecipients.unit.test.d.ts +2 -0
  120. package/lib/__tests__/logic/processRecipients.unit.test.d.ts.map +1 -0
  121. package/lib/__tests__/logic/processRecipients.unit.test.js +79 -0
  122. package/lib/__tests__/logic/processRecipients.unit.test.js.map +1 -0
  123. package/lib/__tests__/logic/staking.test.d.ts +2 -0
  124. package/lib/__tests__/logic/staking.test.d.ts.map +1 -0
  125. package/lib/__tests__/logic/staking.test.js +202 -0
  126. package/lib/__tests__/logic/staking.test.js.map +1 -0
  127. package/lib/__tests__/network/client.test.d.ts +2 -0
  128. package/lib/__tests__/network/client.test.d.ts.map +1 -0
  129. package/lib/__tests__/network/client.test.js +1179 -0
  130. package/lib/__tests__/network/client.test.js.map +1 -0
  131. package/lib/__tests__/network/index.test.d.ts +2 -0
  132. package/lib/__tests__/network/index.test.d.ts.map +1 -0
  133. package/lib/__tests__/network/index.test.js +51 -0
  134. package/lib/__tests__/network/index.test.js.map +1 -0
  135. package/lib/__tests__/network/validators.test.d.ts +2 -0
  136. package/lib/__tests__/network/validators.test.d.ts.map +1 -0
  137. package/lib/__tests__/network/validators.test.js +102 -0
  138. package/lib/__tests__/network/validators.test.js.map +1 -0
  139. package/lib/__tests__/signer/index.test.d.ts +2 -0
  140. package/lib/__tests__/signer/index.test.d.ts.map +1 -0
  141. package/lib/__tests__/signer/index.test.js +26 -0
  142. package/lib/__tests__/signer/index.test.js.map +1 -0
  143. package/lib/__tests__/utils/IconGenerator.test.d.ts +2 -0
  144. package/lib/__tests__/utils/IconGenerator.test.d.ts.map +1 -0
  145. package/lib/__tests__/utils/IconGenerator.test.js +14 -0
  146. package/lib/__tests__/utils/IconGenerator.test.js.map +1 -0
  147. package/lib/__tests__/utils/index.test.d.ts +2 -0
  148. package/lib/__tests__/utils/index.test.d.ts.map +1 -0
  149. package/lib/__tests__/utils/index.test.js +11 -0
  150. package/lib/__tests__/utils/index.test.js.map +1 -0
  151. package/lib-es/__tests__/api/craftTransaction.unit.test.d.ts +2 -0
  152. package/lib-es/__tests__/api/craftTransaction.unit.test.d.ts.map +1 -0
  153. package/lib-es/__tests__/api/craftTransaction.unit.test.js +175 -0
  154. package/lib-es/__tests__/api/craftTransaction.unit.test.js.map +1 -0
  155. package/lib-es/__tests__/api/getBalance.unit.test.d.ts +2 -0
  156. package/lib-es/__tests__/api/getBalance.unit.test.d.ts.map +1 -0
  157. package/lib-es/__tests__/api/getBalance.unit.test.js +78 -0
  158. package/lib-es/__tests__/api/getBalance.unit.test.js.map +1 -0
  159. package/lib-es/__tests__/api/index.integ.test.d.ts +2 -0
  160. package/lib-es/__tests__/api/index.integ.test.d.ts.map +1 -0
  161. package/lib-es/__tests__/api/index.integ.test.js +338 -0
  162. package/lib-es/__tests__/api/index.integ.test.js.map +1 -0
  163. package/lib-es/__tests__/api/index.test.d.ts +2 -0
  164. package/lib-es/__tests__/api/index.test.d.ts.map +1 -0
  165. package/lib-es/__tests__/api/index.test.js +61 -0
  166. package/lib-es/__tests__/api/index.test.js.map +1 -0
  167. package/lib-es/__tests__/bridge/broadcast.test.d.ts +2 -0
  168. package/lib-es/__tests__/bridge/broadcast.test.d.ts.map +1 -0
  169. package/lib-es/__tests__/bridge/broadcast.test.js +87 -0
  170. package/lib-es/__tests__/bridge/broadcast.test.js.map +1 -0
  171. package/lib-es/__tests__/bridge/deviceTransactionConfig.test.d.ts +2 -0
  172. package/lib-es/__tests__/bridge/deviceTransactionConfig.test.d.ts.map +1 -0
  173. package/lib-es/__tests__/bridge/deviceTransactionConfig.test.js +123 -0
  174. package/lib-es/__tests__/bridge/deviceTransactionConfig.test.js.map +1 -0
  175. package/lib-es/__tests__/bridge/estimateMaxSpendable.test.d.ts +2 -0
  176. package/lib-es/__tests__/bridge/estimateMaxSpendable.test.d.ts.map +1 -0
  177. package/lib-es/__tests__/bridge/estimateMaxSpendable.test.js +70 -0
  178. package/lib-es/__tests__/bridge/estimateMaxSpendable.test.js.map +1 -0
  179. package/lib-es/__tests__/bridge/getFeesForTransaction.test.d.ts +2 -0
  180. package/lib-es/__tests__/bridge/getFeesForTransaction.test.d.ts.map +1 -0
  181. package/lib-es/__tests__/bridge/getFeesForTransaction.test.js +252 -0
  182. package/lib-es/__tests__/bridge/getFeesForTransaction.test.js.map +1 -0
  183. package/lib-es/__tests__/bridge/getTransactionStatus.test.d.ts +2 -0
  184. package/lib-es/__tests__/bridge/getTransactionStatus.test.d.ts.map +1 -0
  185. package/lib-es/__tests__/bridge/getTransactionStatus.test.js +448 -0
  186. package/lib-es/__tests__/bridge/getTransactionStatus.test.js.map +1 -0
  187. package/lib-es/__tests__/bridge/index.test.d.ts +2 -0
  188. package/lib-es/__tests__/bridge/index.test.d.ts.map +1 -0
  189. package/lib-es/__tests__/bridge/index.test.js +105 -0
  190. package/lib-es/__tests__/bridge/index.test.js.map +1 -0
  191. package/lib-es/__tests__/bridge/logic.test.d.ts +2 -0
  192. package/lib-es/__tests__/bridge/logic.test.d.ts.map +1 -0
  193. package/lib-es/__tests__/bridge/logic.test.js +992 -0
  194. package/lib-es/__tests__/bridge/logic.test.js.map +1 -0
  195. package/lib-es/__tests__/bridge/prepareTransaction.test.d.ts +2 -0
  196. package/lib-es/__tests__/bridge/prepareTransaction.test.d.ts.map +1 -0
  197. package/lib-es/__tests__/bridge/prepareTransaction.test.js +104 -0
  198. package/lib-es/__tests__/bridge/prepareTransaction.test.js.map +1 -0
  199. package/lib-es/__tests__/bridge/serialization.d.ts +2 -0
  200. package/lib-es/__tests__/bridge/serialization.d.ts.map +1 -0
  201. package/lib-es/__tests__/bridge/serialization.js +86 -0
  202. package/lib-es/__tests__/bridge/serialization.js.map +1 -0
  203. package/lib-es/__tests__/bridge/signOperation.test.d.ts +2 -0
  204. package/lib-es/__tests__/bridge/signOperation.test.d.ts.map +1 -0
  205. package/lib-es/__tests__/bridge/signOperation.test.js +271 -0
  206. package/lib-es/__tests__/bridge/signOperation.test.js.map +1 -0
  207. package/lib-es/__tests__/bridge/synchronisation.test.d.ts +2 -0
  208. package/lib-es/__tests__/bridge/synchronisation.test.d.ts.map +1 -0
  209. package/lib-es/__tests__/bridge/synchronisation.test.js +2221 -0
  210. package/lib-es/__tests__/bridge/synchronisation.test.js.map +1 -0
  211. package/lib-es/__tests__/bridge/transaction.test.d.ts +2 -0
  212. package/lib-es/__tests__/bridge/transaction.test.d.ts.map +1 -0
  213. package/lib-es/__tests__/bridge/transaction.test.js +216 -0
  214. package/lib-es/__tests__/bridge/transaction.test.js.map +1 -0
  215. package/lib-es/__tests__/errors.test.d.ts +2 -0
  216. package/lib-es/__tests__/errors.test.d.ts.map +1 -0
  217. package/lib-es/__tests__/errors.test.js +16 -0
  218. package/lib-es/__tests__/errors.test.js.map +1 -0
  219. package/lib-es/__tests__/index.test.d.ts +2 -0
  220. package/lib-es/__tests__/index.test.d.ts.map +1 -0
  221. package/lib-es/__tests__/index.test.js +25 -0
  222. package/lib-es/__tests__/index.test.js.map +1 -0
  223. package/lib-es/__tests__/logic/buildTransaction.test.d.ts +2 -0
  224. package/lib-es/__tests__/logic/buildTransaction.test.d.ts.map +1 -0
  225. package/lib-es/__tests__/logic/buildTransaction.test.js +109 -0
  226. package/lib-es/__tests__/logic/buildTransaction.test.js.map +1 -0
  227. package/lib-es/__tests__/logic/calculateAmount.unit.test.d.ts +2 -0
  228. package/lib-es/__tests__/logic/calculateAmount.unit.test.d.ts.map +1 -0
  229. package/lib-es/__tests__/logic/calculateAmount.unit.test.js +40 -0
  230. package/lib-es/__tests__/logic/calculateAmount.unit.test.js.map +1 -0
  231. package/lib-es/__tests__/logic/combine.unit.test.d.ts +2 -0
  232. package/lib-es/__tests__/logic/combine.unit.test.d.ts.map +1 -0
  233. package/lib-es/__tests__/logic/combine.unit.test.js +45 -0
  234. package/lib-es/__tests__/logic/combine.unit.test.js.map +1 -0
  235. package/lib-es/__tests__/logic/compareAddress.unit.test.d.ts +2 -0
  236. package/lib-es/__tests__/logic/compareAddress.unit.test.d.ts.map +1 -0
  237. package/lib-es/__tests__/logic/compareAddress.unit.test.js +24 -0
  238. package/lib-es/__tests__/logic/compareAddress.unit.test.js.map +1 -0
  239. package/lib-es/__tests__/logic/createTransaction.test.d.ts +2 -0
  240. package/lib-es/__tests__/logic/createTransaction.test.d.ts.map +1 -0
  241. package/lib-es/__tests__/logic/createTransaction.test.js +24 -0
  242. package/lib-es/__tests__/logic/createTransaction.test.js.map +1 -0
  243. package/lib-es/__tests__/logic/getBalances.test.d.ts +2 -0
  244. package/lib-es/__tests__/logic/getBalances.test.d.ts.map +1 -0
  245. package/lib-es/__tests__/logic/getBalances.test.js +60 -0
  246. package/lib-es/__tests__/logic/getBalances.test.js.map +1 -0
  247. package/lib-es/__tests__/logic/getCoinAndAmounts.unit.test.d.ts +2 -0
  248. package/lib-es/__tests__/logic/getCoinAndAmounts.unit.test.d.ts.map +1 -0
  249. package/lib-es/__tests__/logic/getCoinAndAmounts.unit.test.js +181 -0
  250. package/lib-es/__tests__/logic/getCoinAndAmounts.unit.test.js.map +1 -0
  251. package/lib-es/__tests__/logic/getFunctionAddress.unit.test.d.ts +2 -0
  252. package/lib-es/__tests__/logic/getFunctionAddress.unit.test.d.ts.map +1 -0
  253. package/lib-es/__tests__/logic/getFunctionAddress.unit.test.js +27 -0
  254. package/lib-es/__tests__/logic/getFunctionAddress.unit.test.js.map +1 -0
  255. package/lib-es/__tests__/logic/getResourceAddress.unit.test.d.ts +2 -0
  256. package/lib-es/__tests__/logic/getResourceAddress.unit.test.d.ts.map +1 -0
  257. package/lib-es/__tests__/logic/getResourceAddress.unit.test.js +216 -0
  258. package/lib-es/__tests__/logic/getResourceAddress.unit.test.js.map +1 -0
  259. package/lib-es/__tests__/logic/isTestnet.unit.test.d.ts +2 -0
  260. package/lib-es/__tests__/logic/isTestnet.unit.test.d.ts.map +1 -0
  261. package/lib-es/__tests__/logic/isTestnet.unit.test.js +10 -0
  262. package/lib-es/__tests__/logic/isTestnet.unit.test.js.map +1 -0
  263. package/lib-es/__tests__/logic/normalizeAddress.unit.test.d.ts +2 -0
  264. package/lib-es/__tests__/logic/normalizeAddress.unit.test.d.ts.map +1 -0
  265. package/lib-es/__tests__/logic/normalizeAddress.unit.test.js +10 -0
  266. package/lib-es/__tests__/logic/normalizeAddress.unit.test.js.map +1 -0
  267. package/lib-es/__tests__/logic/processRecipients.unit.test.d.ts +2 -0
  268. package/lib-es/__tests__/logic/processRecipients.unit.test.d.ts.map +1 -0
  269. package/lib-es/__tests__/logic/processRecipients.unit.test.js +74 -0
  270. package/lib-es/__tests__/logic/processRecipients.unit.test.js.map +1 -0
  271. package/lib-es/__tests__/logic/staking.test.d.ts +2 -0
  272. package/lib-es/__tests__/logic/staking.test.d.ts.map +1 -0
  273. package/lib-es/__tests__/logic/staking.test.js +197 -0
  274. package/lib-es/__tests__/logic/staking.test.js.map +1 -0
  275. package/lib-es/__tests__/network/client.test.d.ts +2 -0
  276. package/lib-es/__tests__/network/client.test.d.ts.map +1 -0
  277. package/lib-es/__tests__/network/client.test.js +1174 -0
  278. package/lib-es/__tests__/network/client.test.js.map +1 -0
  279. package/lib-es/__tests__/network/index.test.d.ts +2 -0
  280. package/lib-es/__tests__/network/index.test.d.ts.map +1 -0
  281. package/lib-es/__tests__/network/index.test.js +49 -0
  282. package/lib-es/__tests__/network/index.test.js.map +1 -0
  283. package/lib-es/__tests__/network/validators.test.d.ts +2 -0
  284. package/lib-es/__tests__/network/validators.test.d.ts.map +1 -0
  285. package/lib-es/__tests__/network/validators.test.js +97 -0
  286. package/lib-es/__tests__/network/validators.test.js.map +1 -0
  287. package/lib-es/__tests__/signer/index.test.d.ts +2 -0
  288. package/lib-es/__tests__/signer/index.test.d.ts.map +1 -0
  289. package/lib-es/__tests__/signer/index.test.js +21 -0
  290. package/lib-es/__tests__/signer/index.test.js.map +1 -0
  291. package/lib-es/__tests__/utils/IconGenerator.test.d.ts +2 -0
  292. package/lib-es/__tests__/utils/IconGenerator.test.d.ts.map +1 -0
  293. package/lib-es/__tests__/utils/IconGenerator.test.js +12 -0
  294. package/lib-es/__tests__/utils/IconGenerator.test.js.map +1 -0
  295. package/lib-es/__tests__/utils/index.test.d.ts +2 -0
  296. package/lib-es/__tests__/utils/index.test.d.ts.map +1 -0
  297. package/lib-es/__tests__/utils/index.test.js +9 -0
  298. package/lib-es/__tests__/utils/index.test.js.map +1 -0
  299. package/package.json +10 -10
@@ -0,0 +1,2226 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const jsHelpers_1 = require("@ledgerhq/coin-framework/bridge/jsHelpers");
7
+ const index_1 = require("@ledgerhq/cryptoassets/index");
8
+ const account_1 = require("@ledgerhq/coin-framework/account");
9
+ const index_2 = require("@ledgerhq/coin-framework/account/index");
10
+ const network_1 = require("../../network");
11
+ const synchronisation_1 = require("../../bridge/synchronisation");
12
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
13
+ const bridge_fixture_1 = require("../../bridge/bridge.fixture");
14
+ const logic_1 = require("../../bridge/logic");
15
+ const live_env_1 = require("@ledgerhq/live-env");
16
+ jest.mock("@ledgerhq/coin-framework/account", () => {
17
+ const originalModule = jest.requireActual("@ledgerhq/coin-framework/account");
18
+ const partialMockedModule = Object.keys(originalModule).reduce((pre, methodName) => {
19
+ pre[methodName] = jest.fn();
20
+ return pre;
21
+ }, {});
22
+ return {
23
+ ...partialMockedModule,
24
+ // mock all except these
25
+ encodeAccountId: originalModule.encodeAccountId,
26
+ decodeAccountId: originalModule.decodeAccountId,
27
+ encodeTokenAccountId: originalModule.encodeTokenAccountId,
28
+ };
29
+ });
30
+ const mockedDecodeTokenAccountId = jest.mocked(account_1.decodeTokenAccountId);
31
+ jest.mock("../../network");
32
+ let mockedAptosAPI;
33
+ jest.mock("@ledgerhq/coin-framework/bridge/jsHelpers");
34
+ jest.mock("invariant", () => jest.fn());
35
+ jest.mock("../../bridge/logic");
36
+ describe("getAccountShape", () => {
37
+ beforeEach(() => {
38
+ mockedAptosAPI = jest.mocked(network_1.AptosAPI);
39
+ });
40
+ afterEach(() => {
41
+ jest.resetAllMocks();
42
+ });
43
+ it("account with xpub", async () => {
44
+ const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
45
+ balance: (0, bignumber_js_1.default)(0),
46
+ transactions: [],
47
+ blockHeight: 0,
48
+ }));
49
+ mockedAptosAPI.mockImplementation(() => ({
50
+ getAccountInfo: mockGetAccountInfo,
51
+ }));
52
+ const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
53
+ jest.mocked(jsHelpers_1.mergeOps).mockReturnValue([]);
54
+ jest.mocked(logic_1.txsToOps).mockReturnValue([[], [], []]);
55
+ const account = await (0, synchronisation_1.getAccountShape)({
56
+ id: "1",
57
+ address: "address",
58
+ currency: (0, index_1.getCryptoCurrencyById)("aptos"),
59
+ derivationMode: "",
60
+ index: 0,
61
+ xpub: "address",
62
+ derivationPath: "",
63
+ deviceId: "1",
64
+ initialAccount: {
65
+ id: "1:1:1:1:aptos",
66
+ xpub: "address",
67
+ seedIdentifier: "1",
68
+ derivationMode: "",
69
+ index: 0,
70
+ freshAddress: "address",
71
+ freshAddressPath: "",
72
+ used: true,
73
+ balance: (0, bignumber_js_1.default)(10),
74
+ spendableBalance: (0, bignumber_js_1.default)(10),
75
+ creationDate: new Date(),
76
+ blockHeight: 0,
77
+ currency: (0, index_1.getCryptoCurrencyById)("aptos"),
78
+ operationsCount: 0,
79
+ operations: [],
80
+ pendingOperations: [],
81
+ lastSyncDate: new Date(),
82
+ balanceHistoryCache: {},
83
+ swapHistory: [],
84
+ },
85
+ }, {});
86
+ expect(account.xpub).toEqual("address");
87
+ expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
88
+ expect(mockGetAccountSpy).toHaveBeenCalledWith("address");
89
+ });
90
+ it("account without xpub", async () => {
91
+ const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
92
+ balance: (0, bignumber_js_1.default)(0),
93
+ transactions: [],
94
+ blockHeight: 0,
95
+ }));
96
+ mockedAptosAPI.mockImplementation(() => ({
97
+ getAccountInfo: mockGetAccountInfo,
98
+ }));
99
+ const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
100
+ jest.mocked(jsHelpers_1.mergeOps).mockReturnValue([]);
101
+ jest.mocked(logic_1.txsToOps).mockReturnValue([[], [], []]);
102
+ const account = await (0, synchronisation_1.getAccountShape)({
103
+ id: "1",
104
+ address: "address",
105
+ currency: (0, index_1.getCryptoCurrencyById)("aptos"),
106
+ derivationMode: "",
107
+ index: 0,
108
+ xpub: "address",
109
+ derivationPath: "",
110
+ deviceId: "1",
111
+ initialAccount: {
112
+ id: "1:1:1:1:aptos",
113
+ seedIdentifier: "1",
114
+ derivationMode: "",
115
+ index: 0,
116
+ freshAddress: "address",
117
+ freshAddressPath: "",
118
+ used: true,
119
+ balance: (0, bignumber_js_1.default)(10),
120
+ spendableBalance: (0, bignumber_js_1.default)(10),
121
+ creationDate: new Date(),
122
+ blockHeight: 0,
123
+ currency: (0, index_1.getCryptoCurrencyById)("aptos"),
124
+ operationsCount: 0,
125
+ operations: [],
126
+ pendingOperations: [],
127
+ lastSyncDate: new Date(),
128
+ balanceHistoryCache: {},
129
+ swapHistory: [],
130
+ },
131
+ }, {});
132
+ expect(account.xpub).toEqual("1");
133
+ expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
134
+ expect(mockGetAccountSpy).toHaveBeenCalledWith("address");
135
+ });
136
+ it("without initialAccount", async () => {
137
+ const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
138
+ balance: (0, bignumber_js_1.default)(0),
139
+ transactions: [],
140
+ blockHeight: 0,
141
+ }));
142
+ mockedAptosAPI.mockImplementation(() => ({
143
+ getAccountInfo: mockGetAccountInfo,
144
+ }));
145
+ const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
146
+ jest.mocked(jsHelpers_1.mergeOps).mockReturnValue([]);
147
+ jest.mocked(logic_1.txsToOps).mockReturnValue([[], [], []]);
148
+ const account = await (0, synchronisation_1.getAccountShape)({
149
+ id: "1",
150
+ address: "address",
151
+ currency: (0, index_1.getCryptoCurrencyById)("aptos"),
152
+ derivationMode: "",
153
+ index: 0,
154
+ xpub: "address",
155
+ derivationPath: "",
156
+ deviceId: "1",
157
+ }, {});
158
+ expect(account.xpub).toEqual("");
159
+ expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
160
+ expect(mockGetAccountSpy).toHaveBeenCalledWith("address");
161
+ });
162
+ it("initialAccount with operations", async () => {
163
+ const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
164
+ balance: (0, bignumber_js_1.default)(0),
165
+ transactions: [],
166
+ blockHeight: 0,
167
+ }));
168
+ mockedAptosAPI.mockImplementation(() => ({
169
+ getAccountInfo: mockGetAccountInfo,
170
+ }));
171
+ const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
172
+ jest.mocked(jsHelpers_1.mergeOps).mockReturnValue([]);
173
+ jest.mocked(logic_1.txsToOps).mockReturnValue([[], [], []]);
174
+ const account = await (0, synchronisation_1.getAccountShape)({
175
+ id: "1",
176
+ address: "address",
177
+ currency: (0, index_1.getCryptoCurrencyById)("aptos"),
178
+ derivationMode: "",
179
+ index: 0,
180
+ xpub: "address",
181
+ derivationPath: "",
182
+ deviceId: "1",
183
+ initialAccount: {
184
+ id: "1:1:1:1:aptos",
185
+ seedIdentifier: "1",
186
+ derivationMode: "",
187
+ index: 0,
188
+ freshAddress: "address",
189
+ freshAddressPath: "",
190
+ used: true,
191
+ balance: (0, bignumber_js_1.default)(10),
192
+ spendableBalance: (0, bignumber_js_1.default)(10),
193
+ creationDate: new Date(),
194
+ blockHeight: 0,
195
+ currency: (0, index_1.getCryptoCurrencyById)("aptos"),
196
+ operationsCount: 0,
197
+ operations: [],
198
+ pendingOperations: [],
199
+ lastSyncDate: new Date(),
200
+ balanceHistoryCache: {},
201
+ swapHistory: [],
202
+ },
203
+ }, {});
204
+ expect(account.xpub).toEqual("1");
205
+ expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
206
+ expect(mockGetAccountSpy).toHaveBeenCalledWith("address");
207
+ });
208
+ it("initialAccount with operations with extra", async () => {
209
+ const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
210
+ balance: (0, bignumber_js_1.default)(0),
211
+ transactions: [],
212
+ blockHeight: 0,
213
+ }));
214
+ mockedAptosAPI.mockImplementation(() => ({
215
+ getAccountInfo: mockGetAccountInfo,
216
+ }));
217
+ const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
218
+ jest.mocked(jsHelpers_1.mergeOps).mockReturnValue([]);
219
+ jest.mocked(logic_1.txsToOps).mockReturnValue([[], [], []]);
220
+ const account = await (0, synchronisation_1.getAccountShape)({
221
+ id: "1",
222
+ address: "address",
223
+ currency: (0, index_1.getCryptoCurrencyById)("aptos"),
224
+ derivationMode: "",
225
+ index: 0,
226
+ xpub: "address",
227
+ derivationPath: "",
228
+ deviceId: "1",
229
+ initialAccount: {
230
+ id: "1:1:1:1:aptos",
231
+ seedIdentifier: "1",
232
+ derivationMode: "",
233
+ index: 0,
234
+ freshAddress: "address",
235
+ freshAddressPath: "",
236
+ used: true,
237
+ balance: (0, bignumber_js_1.default)(10),
238
+ spendableBalance: (0, bignumber_js_1.default)(10),
239
+ creationDate: new Date(),
240
+ blockHeight: 0,
241
+ currency: (0, index_1.getCryptoCurrencyById)("aptos"),
242
+ operationsCount: 0,
243
+ operations: [],
244
+ pendingOperations: [],
245
+ lastSyncDate: new Date(),
246
+ balanceHistoryCache: {},
247
+ swapHistory: [],
248
+ },
249
+ }, {});
250
+ expect(account.xpub).toEqual("1");
251
+ expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
252
+ expect(mockGetAccountSpy).toHaveBeenCalledWith("address");
253
+ });
254
+ it("get publicKey from rest", async () => {
255
+ const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
256
+ balance: (0, bignumber_js_1.default)(0),
257
+ transactions: [],
258
+ blockHeight: 0,
259
+ }));
260
+ mockedAptosAPI.mockImplementation(() => ({
261
+ getAccountInfo: mockGetAccountInfo,
262
+ }));
263
+ const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
264
+ jest.mocked(jsHelpers_1.mergeOps).mockReturnValue([]);
265
+ jest.mocked(logic_1.txsToOps).mockReturnValue([[], [], []]);
266
+ const account = await (0, synchronisation_1.getAccountShape)({
267
+ id: "1",
268
+ address: "address",
269
+ currency: (0, index_1.getCryptoCurrencyById)("aptos"),
270
+ derivationMode: "",
271
+ index: 0,
272
+ xpub: "address",
273
+ derivationPath: "",
274
+ deviceId: "1",
275
+ initialAccount: {
276
+ id: "1:1:1:1:aptos",
277
+ seedIdentifier: "1",
278
+ derivationMode: "",
279
+ index: 0,
280
+ freshAddress: "address",
281
+ freshAddressPath: "",
282
+ used: true,
283
+ balance: (0, bignumber_js_1.default)(10),
284
+ spendableBalance: (0, bignumber_js_1.default)(10),
285
+ creationDate: new Date(),
286
+ blockHeight: 0,
287
+ currency: (0, index_1.getCryptoCurrencyById)("aptos"),
288
+ operationsCount: 0,
289
+ operations: [],
290
+ pendingOperations: [],
291
+ lastSyncDate: new Date(),
292
+ balanceHistoryCache: {},
293
+ swapHistory: [],
294
+ },
295
+ rest: { publicKey: "restPublicKey" },
296
+ }, {});
297
+ expect(account.xpub).toEqual("restPublicKey");
298
+ expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
299
+ expect(mockGetAccountSpy).toHaveBeenCalledWith("address");
300
+ });
301
+ it("initialAccount with operations with subOperations", async () => {
302
+ const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
303
+ balance: (0, bignumber_js_1.default)(68254118),
304
+ transactions: [
305
+ {
306
+ version: "2532591427",
307
+ hash: "0x3f35",
308
+ state_change_hash: "0xb480",
309
+ event_root_hash: "0x3fa1",
310
+ state_checkpoint_hash: null,
311
+ gas_used: "12",
312
+ success: true,
313
+ vm_status: "Executed successfully",
314
+ accumulator_root_hash: "0x319f",
315
+ changes: [
316
+ {
317
+ address: "0x4e5e",
318
+ state_key_hash: "0x3c0c",
319
+ data: {
320
+ type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
321
+ data: {
322
+ coin: {
323
+ value: "4000000",
324
+ },
325
+ deposit_events: {
326
+ counter: "9",
327
+ guid: {
328
+ id: {
329
+ addr: "0x4e5e",
330
+ creation_num: "4",
331
+ },
332
+ },
333
+ },
334
+ frozen: false,
335
+ withdraw_events: {
336
+ counter: "6",
337
+ guid: {
338
+ id: {
339
+ addr: "0x4e5e",
340
+ creation_num: "5",
341
+ },
342
+ },
343
+ },
344
+ },
345
+ },
346
+ type: "write_resource",
347
+ },
348
+ {
349
+ address: "0xa0d8",
350
+ state_key_hash: "0x1709",
351
+ data: {
352
+ type: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
353
+ data: {
354
+ coin: {
355
+ value: "68254118",
356
+ },
357
+ deposit_events: {
358
+ counter: "46",
359
+ guid: {
360
+ id: {
361
+ addr: "0xa0d8",
362
+ creation_num: "2",
363
+ },
364
+ },
365
+ },
366
+ frozen: false,
367
+ withdraw_events: {
368
+ counter: "89",
369
+ guid: {
370
+ id: {
371
+ addr: "0xa0d8",
372
+ creation_num: "3",
373
+ },
374
+ },
375
+ },
376
+ },
377
+ },
378
+ type: "write_resource",
379
+ },
380
+ {
381
+ address: "0xa0d8",
382
+ state_key_hash: "0x5520",
383
+ data: {
384
+ type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
385
+ data: {
386
+ coin: {
387
+ value: "1000000",
388
+ },
389
+ deposit_events: {
390
+ counter: "7",
391
+ guid: {
392
+ id: {
393
+ addr: "0xa0d8",
394
+ creation_num: "10",
395
+ },
396
+ },
397
+ },
398
+ frozen: false,
399
+ withdraw_events: {
400
+ counter: "13",
401
+ guid: {
402
+ id: {
403
+ addr: "0xa0d8",
404
+ creation_num: "11",
405
+ },
406
+ },
407
+ },
408
+ },
409
+ },
410
+ type: "write_resource",
411
+ },
412
+ {
413
+ address: "0xa0d8",
414
+ state_key_hash: "0x6f1e",
415
+ data: {
416
+ type: "0x1::account::Account",
417
+ data: {
418
+ authentication_key: "0xa0d8",
419
+ coin_register_events: {
420
+ counter: "5",
421
+ guid: {
422
+ id: {
423
+ addr: "0xa0d8",
424
+ creation_num: "0",
425
+ },
426
+ },
427
+ },
428
+ guid_creation_num: "12",
429
+ key_rotation_events: {
430
+ counter: "0",
431
+ guid: {
432
+ id: {
433
+ addr: "0xa0d8",
434
+ creation_num: "1",
435
+ },
436
+ },
437
+ },
438
+ rotation_capability_offer: {
439
+ for: {
440
+ vec: [],
441
+ },
442
+ },
443
+ sequence_number: "122",
444
+ signer_capability_offer: {
445
+ for: {
446
+ vec: [],
447
+ },
448
+ },
449
+ },
450
+ },
451
+ type: "write_resource",
452
+ },
453
+ {
454
+ state_key_hash: "0x6e4b",
455
+ handle: "0x1b85",
456
+ key: "0x0619",
457
+ value: "0x1ddaf8da3b1497010000000000000000",
458
+ data: null,
459
+ type: "write_table_item",
460
+ },
461
+ ],
462
+ sender: "0xa0d8",
463
+ sequence_number: "121",
464
+ max_gas_amount: "12",
465
+ gas_unit_price: "100",
466
+ expiration_timestamp_secs: "1743177404",
467
+ payload: {
468
+ function: "0x1::aptos_account::transfer_coins",
469
+ type_arguments: ["0xd111::staked_coin::StakedAptos"],
470
+ arguments: ["0x4e5e", "1500000"],
471
+ type: "entry_function_payload",
472
+ },
473
+ signature: {
474
+ public_key: "0x474d",
475
+ signature: "0x0ad8",
476
+ type: "ed25519_signature",
477
+ },
478
+ events: [
479
+ {
480
+ guid: {
481
+ creation_number: "11",
482
+ account_address: "0xa0d8",
483
+ },
484
+ sequence_number: "12",
485
+ type: "0x1::coin::WithdrawEvent",
486
+ data: {
487
+ amount: "1500000",
488
+ },
489
+ },
490
+ {
491
+ guid: {
492
+ creation_number: "4",
493
+ account_address: "0x4e5e",
494
+ },
495
+ sequence_number: "8",
496
+ type: "0x1::coin::DepositEvent",
497
+ data: {
498
+ amount: "1500000",
499
+ },
500
+ },
501
+ {
502
+ guid: {
503
+ creation_number: "0",
504
+ account_address: "0x0",
505
+ },
506
+ sequence_number: "0",
507
+ type: "0x1::transaction_fee::FeeStatement",
508
+ data: {
509
+ execution_gas_units: "6",
510
+ io_gas_units: "6",
511
+ storage_fee_octas: "0",
512
+ storage_fee_refund_octas: "0",
513
+ total_charge_gas_units: "12",
514
+ },
515
+ },
516
+ ],
517
+ timestamp: "1743177360481259",
518
+ type: "user_transaction",
519
+ block: {
520
+ height: 311948147,
521
+ hash: "0x6d02",
522
+ },
523
+ },
524
+ {
525
+ version: "2532549325",
526
+ hash: "0x9a6b",
527
+ state_change_hash: "0xa424",
528
+ event_root_hash: "0x0321",
529
+ state_checkpoint_hash: null,
530
+ gas_used: "12",
531
+ success: true,
532
+ vm_status: "Executed successfully",
533
+ accumulator_root_hash: "0xede9",
534
+ changes: [
535
+ {
536
+ address: "0x4e5e",
537
+ state_key_hash: "0x3c0c",
538
+ data: {
539
+ type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
540
+ data: {
541
+ coin: {
542
+ value: "2500000",
543
+ },
544
+ deposit_events: {
545
+ counter: "8",
546
+ guid: {
547
+ id: {
548
+ addr: "0x4e5e",
549
+ creation_num: "4",
550
+ },
551
+ },
552
+ },
553
+ frozen: false,
554
+ withdraw_events: {
555
+ counter: "6",
556
+ guid: {
557
+ id: {
558
+ addr: "0x4e5e",
559
+ creation_num: "5",
560
+ },
561
+ },
562
+ },
563
+ },
564
+ },
565
+ type: "write_resource",
566
+ },
567
+ {
568
+ address: "0xa0d8",
569
+ state_key_hash: "0x1709",
570
+ data: {
571
+ type: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
572
+ data: {
573
+ coin: {
574
+ value: "68255318",
575
+ },
576
+ deposit_events: {
577
+ counter: "46",
578
+ guid: {
579
+ id: {
580
+ addr: "0xa0d8",
581
+ creation_num: "2",
582
+ },
583
+ },
584
+ },
585
+ frozen: false,
586
+ withdraw_events: {
587
+ counter: "89",
588
+ guid: {
589
+ id: {
590
+ addr: "0xa0d8",
591
+ creation_num: "3",
592
+ },
593
+ },
594
+ },
595
+ },
596
+ },
597
+ type: "write_resource",
598
+ },
599
+ {
600
+ address: "0xa0d8",
601
+ state_key_hash: "0x5520",
602
+ data: {
603
+ type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
604
+ data: {
605
+ coin: {
606
+ value: "2500000",
607
+ },
608
+ deposit_events: {
609
+ counter: "7",
610
+ guid: {
611
+ id: {
612
+ addr: "0xa0d8",
613
+ creation_num: "10",
614
+ },
615
+ },
616
+ },
617
+ frozen: false,
618
+ withdraw_events: {
619
+ counter: "12",
620
+ guid: {
621
+ id: {
622
+ addr: "0xa0d8",
623
+ creation_num: "11",
624
+ },
625
+ },
626
+ },
627
+ },
628
+ },
629
+ type: "write_resource",
630
+ },
631
+ {
632
+ address: "0xa0d8",
633
+ state_key_hash: "0x6f1e",
634
+ data: {
635
+ type: "0x1::account::Account",
636
+ data: {
637
+ authentication_key: "0xa0d8",
638
+ coin_register_events: {
639
+ counter: "5",
640
+ guid: {
641
+ id: {
642
+ addr: "0xa0d8",
643
+ creation_num: "0",
644
+ },
645
+ },
646
+ },
647
+ guid_creation_num: "12",
648
+ key_rotation_events: {
649
+ counter: "0",
650
+ guid: {
651
+ id: {
652
+ addr: "0xa0d8",
653
+ creation_num: "1",
654
+ },
655
+ },
656
+ },
657
+ rotation_capability_offer: {
658
+ for: {
659
+ vec: [],
660
+ },
661
+ },
662
+ sequence_number: "121",
663
+ signer_capability_offer: {
664
+ for: {
665
+ vec: [],
666
+ },
667
+ },
668
+ },
669
+ },
670
+ type: "write_resource",
671
+ },
672
+ {
673
+ state_key_hash: "0x6e4b",
674
+ handle: "0x1b85",
675
+ key: "0x0619",
676
+ value: "0xe86e0039581497010000000000000000",
677
+ data: null,
678
+ type: "write_table_item",
679
+ },
680
+ ],
681
+ sender: "0xa0d8",
682
+ sequence_number: "120",
683
+ max_gas_amount: "12",
684
+ gas_unit_price: "100",
685
+ expiration_timestamp_secs: "1743176706",
686
+ payload: {
687
+ function: "0x1::aptos_account::transfer_coins",
688
+ type_arguments: ["0xd111::staked_coin::StakedAptos"],
689
+ arguments: ["0x4e5e", "2500000"],
690
+ type: "entry_function_payload",
691
+ },
692
+ signature: {
693
+ public_key: "0x474d",
694
+ signature: "0xb70e",
695
+ type: "ed25519_signature",
696
+ },
697
+ events: [
698
+ {
699
+ guid: {
700
+ creation_number: "11",
701
+ account_address: "0xa0d8",
702
+ },
703
+ sequence_number: "11",
704
+ type: "0x1::coin::WithdrawEvent",
705
+ data: {
706
+ amount: "2500000",
707
+ },
708
+ },
709
+ {
710
+ guid: {
711
+ creation_number: "4",
712
+ account_address: "0x4e5e",
713
+ },
714
+ sequence_number: "7",
715
+ type: "0x1::coin::DepositEvent",
716
+ data: {
717
+ amount: "2500000",
718
+ },
719
+ },
720
+ {
721
+ guid: {
722
+ creation_number: "0",
723
+ account_address: "0x0",
724
+ },
725
+ sequence_number: "0",
726
+ type: "0x1::transaction_fee::FeeStatement",
727
+ data: {
728
+ execution_gas_units: "6",
729
+ io_gas_units: "6",
730
+ storage_fee_octas: "0",
731
+ storage_fee_refund_octas: "0",
732
+ total_charge_gas_units: "12",
733
+ },
734
+ },
735
+ ],
736
+ timestamp: "1743176594693251",
737
+ type: "user_transaction",
738
+ block: {
739
+ height: 311942427,
740
+ hash: "0x8655",
741
+ },
742
+ },
743
+ ],
744
+ blockHeight: 316278241,
745
+ }));
746
+ const TOKEN_CONTRACT_ADDRESS = "0xd111::staked_coin::StakedAptos";
747
+ const mockGetBalances = jest
748
+ .fn()
749
+ .mockResolvedValue([{ contractAddress: TOKEN_CONTRACT_ADDRESS, amount: (0, bignumber_js_1.default)(1234567) }]);
750
+ mockedAptosAPI.mockImplementation(() => ({
751
+ getBalances: mockGetBalances,
752
+ getAccountInfo: mockGetAccountInfo,
753
+ }));
754
+ const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
755
+ mockedDecodeTokenAccountId.mockReturnValue({
756
+ token: {
757
+ type: "TokenCurrency",
758
+ id: "aptos/coin/dstapt_0xd111::staked_coin::stakedaptos",
759
+ contractAddress: "0xd111::staked_coin::StakedAptos",
760
+ parentCurrency: {
761
+ type: "CryptoCurrency",
762
+ id: "aptos",
763
+ coinType: 637,
764
+ name: "Aptos",
765
+ managerAppName: "Aptos",
766
+ ticker: "APT",
767
+ scheme: "aptos",
768
+ color: "#231F20",
769
+ family: "aptos",
770
+ units: [
771
+ {
772
+ name: "APT",
773
+ code: "APT",
774
+ magnitude: 8,
775
+ },
776
+ ],
777
+ explorerViews: [
778
+ {
779
+ address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
780
+ tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
781
+ },
782
+ ],
783
+ },
784
+ name: "dstAPT",
785
+ tokenType: "coin",
786
+ ticker: "dstAPT",
787
+ disableCountervalue: false,
788
+ delisted: false,
789
+ units: [
790
+ {
791
+ name: "dstAPT",
792
+ code: "dstAPT",
793
+ magnitude: 8,
794
+ },
795
+ ],
796
+ },
797
+ accountId: "js:2:aptos:6415:aptos",
798
+ });
799
+ const operations = [
800
+ {
801
+ id: "js:2:aptos:474d:aptos-0x3f35-OUT",
802
+ hash: "0x3f35",
803
+ type: "FEES",
804
+ value: (0, bignumber_js_1.default)(1200),
805
+ fee: (0, bignumber_js_1.default)(1200),
806
+ blockHash: "0x6d02",
807
+ blockHeight: 311948147,
808
+ senders: ["0xa0d8"],
809
+ recipients: ["0x4e5e"],
810
+ accountId: "js:2:aptos:474d:aptos",
811
+ date: new Date("2025-03-28T15:56:00.481Z"),
812
+ extra: {
813
+ version: "2532591427",
814
+ },
815
+ transactionSequenceNumber: 121,
816
+ hasFailed: false,
817
+ },
818
+ {
819
+ id: "js:2:aptos:474d:aptos-0x9a6b-OUT",
820
+ hash: "0x9a6b",
821
+ type: "FEES",
822
+ value: (0, bignumber_js_1.default)(1200),
823
+ fee: (0, bignumber_js_1.default)(1200),
824
+ blockHash: "0x8655",
825
+ blockHeight: 311942427,
826
+ senders: ["0xa0d8"],
827
+ recipients: ["0x4e5e"],
828
+ accountId: "js:2:aptos:474d:aptos",
829
+ date: new Date("2025-03-28T15:43:14.693Z"),
830
+ extra: {
831
+ version: "2532549325",
832
+ },
833
+ transactionSequenceNumber: 120,
834
+ hasFailed: false,
835
+ },
836
+ ];
837
+ const tokenOperations = [
838
+ {
839
+ id: "js:2:aptos:474d:aptos-0x3f35-OUT",
840
+ hash: "0x3f35",
841
+ type: "OUT",
842
+ value: (0, bignumber_js_1.default)(1500000),
843
+ fee: (0, bignumber_js_1.default)(1200),
844
+ blockHash: "0x6d02",
845
+ blockHeight: 311948147,
846
+ senders: ["0xa0d8"],
847
+ recipients: ["0x4e5e"],
848
+ accountId: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
849
+ date: new Date("2025-03-28T15:56:00.481Z"),
850
+ extra: {
851
+ version: "2532591427",
852
+ },
853
+ transactionSequenceNumber: 121,
854
+ hasFailed: false,
855
+ },
856
+ {
857
+ id: "js:2:aptos:474d:aptos-0x9a6b-OUT",
858
+ hash: "0x9a6b",
859
+ type: "OUT",
860
+ value: (0, bignumber_js_1.default)(2500000),
861
+ fee: (0, bignumber_js_1.default)(1200),
862
+ blockHash: "0x8655",
863
+ blockHeight: 311942427,
864
+ senders: ["0xa0d8"],
865
+ recipients: ["0x4e5e"],
866
+ accountId: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
867
+ date: new Date("2025-03-28T15:43:14.693Z"),
868
+ extra: {
869
+ version: "2532549325",
870
+ },
871
+ transactionSequenceNumber: 120,
872
+ hasFailed: false,
873
+ },
874
+ ];
875
+ const stakingOperations = [];
876
+ jest.mocked(jsHelpers_1.mergeOps).mockReturnValue(operations);
877
+ jest.mocked(logic_1.txsToOps).mockReturnValue([operations, tokenOperations, stakingOperations]);
878
+ const info = {
879
+ currency: {
880
+ type: "CryptoCurrency",
881
+ id: "aptos",
882
+ coinType: 637,
883
+ name: "Aptos",
884
+ managerAppName: "Aptos",
885
+ ticker: "APT",
886
+ scheme: "aptos",
887
+ color: "#231F20",
888
+ family: "aptos",
889
+ units: [
890
+ {
891
+ name: "APT",
892
+ code: "APT",
893
+ magnitude: 8,
894
+ },
895
+ ],
896
+ },
897
+ index: 0,
898
+ address: "0xa0d8",
899
+ derivationPath: "44'/637'/0'",
900
+ derivationMode: "aptos",
901
+ initialAccount: {
902
+ type: "Account",
903
+ id: "js:2:aptos:474d:aptos",
904
+ used: true,
905
+ seedIdentifier: "3086",
906
+ derivationMode: "aptos",
907
+ index: 0,
908
+ freshAddress: "0xa0d8",
909
+ freshAddressPath: "44'/637'/0'/0'/0'",
910
+ blockHeight: 316272224,
911
+ creationDate: "2025-01-16T14:17:41.076Z",
912
+ balance: (0, bignumber_js_1.default)(68254118),
913
+ spendableBalance: (0, bignumber_js_1.default)(68254118),
914
+ operations: [],
915
+ operationsCount: 0,
916
+ pendingOperations: [],
917
+ currency: {
918
+ type: "CryptoCurrency",
919
+ id: "aptos",
920
+ coinType: 637,
921
+ name: "Aptos",
922
+ managerAppName: "Aptos",
923
+ ticker: "APT",
924
+ scheme: "aptos",
925
+ color: "#231F20",
926
+ family: "aptos",
927
+ units: [
928
+ {
929
+ name: "APT",
930
+ code: "APT",
931
+ magnitude: 8,
932
+ },
933
+ ],
934
+ },
935
+ lastSyncDate: new Date(),
936
+ swapHistory: [],
937
+ balanceHistoryCache: index_2.emptyHistoryCache,
938
+ xpub: "474d",
939
+ subAccounts: [
940
+ {
941
+ type: "TokenAccount",
942
+ id: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
943
+ parentId: "js:2:aptos:474d:aptos",
944
+ token: {
945
+ type: "TokenCurrency",
946
+ id: "aptos/coin/dstapt_0xd111::staked_coin::stakedaptos",
947
+ contractAddress: "0xd111::staked_coin::StakedAptos",
948
+ parentCurrency: {
949
+ type: "CryptoCurrency",
950
+ id: "aptos",
951
+ coinType: 637,
952
+ name: "Aptos",
953
+ managerAppName: "Aptos",
954
+ ticker: "APT",
955
+ scheme: "aptos",
956
+ color: "#231F20",
957
+ family: "aptos",
958
+ units: [
959
+ {
960
+ name: "APT",
961
+ code: "APT",
962
+ magnitude: 8,
963
+ },
964
+ ],
965
+ },
966
+ name: "dstAPT",
967
+ tokenType: "coin",
968
+ ticker: "dstAPT",
969
+ disableCountervalue: false,
970
+ delisted: false,
971
+ units: [
972
+ {
973
+ name: "dstAPT",
974
+ code: "dstAPT",
975
+ magnitude: 8,
976
+ },
977
+ ],
978
+ },
979
+ balance: (0, bignumber_js_1.default)(5000000),
980
+ spendableBalance: (0, bignumber_js_1.default)(5000000),
981
+ creationDate: "2025-03-11T09:33:46.840Z",
982
+ operations: [],
983
+ operationsCount: 0,
984
+ pendingOperations: [],
985
+ swapHistory: [],
986
+ balanceHistoryCache: index_2.emptyHistoryCache,
987
+ },
988
+ ],
989
+ },
990
+ };
991
+ const result = await (0, synchronisation_1.getAccountShape)(info, {});
992
+ expect(result.operations).toHaveLength(2);
993
+ expect(result.operations?.at(0)?.subOperations).toHaveLength(2);
994
+ expect(result.operations?.at(1)?.subOperations).toHaveLength(2);
995
+ expect(result.subAccounts).toHaveLength(1);
996
+ expect(mockedAptosAPI).toHaveBeenCalledTimes(2);
997
+ expect(mockGetAccountSpy).toHaveBeenCalledWith("0xa0d8");
998
+ });
999
+ });
1000
+ describe("mergeSubAccounts", () => {
1001
+ const initialSubAccount = {
1002
+ type: "TokenAccount",
1003
+ id: "subAccountId",
1004
+ parentId: "accountId",
1005
+ token: {
1006
+ type: "TokenCurrency",
1007
+ id: "aptos/coin/dstapt_0xd111::staked_coin::stakedaptos",
1008
+ contractAddress: "0xd111::staked_coin::StakedAptos",
1009
+ parentCurrency: {
1010
+ type: "CryptoCurrency",
1011
+ id: "aptos",
1012
+ coinType: 637,
1013
+ name: "Aptos",
1014
+ managerAppName: "Aptos",
1015
+ ticker: "APT",
1016
+ scheme: "aptos",
1017
+ color: "#231F20",
1018
+ family: "aptos",
1019
+ units: [
1020
+ {
1021
+ name: "APT",
1022
+ code: "APT",
1023
+ magnitude: 8,
1024
+ },
1025
+ ],
1026
+ explorerViews: [
1027
+ {
1028
+ address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
1029
+ tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
1030
+ },
1031
+ ],
1032
+ },
1033
+ name: "dstAPT",
1034
+ tokenType: "coin",
1035
+ ticker: "dstAPT",
1036
+ disableCountervalue: false,
1037
+ delisted: false,
1038
+ units: [
1039
+ {
1040
+ name: "dstAPT",
1041
+ code: "dstAPT",
1042
+ magnitude: 8,
1043
+ },
1044
+ ],
1045
+ },
1046
+ balance: (0, bignumber_js_1.default)(100),
1047
+ spendableBalance: (0, bignumber_js_1.default)(100),
1048
+ creationDate: new Date(),
1049
+ operationsCount: 0,
1050
+ operations: [],
1051
+ pendingOperations: [],
1052
+ balanceHistoryCache: index_2.emptyHistoryCache,
1053
+ swapHistory: [],
1054
+ };
1055
+ const initialAccount = (0, bridge_fixture_1.createFixtureAccount)({
1056
+ subAccounts: [initialSubAccount],
1057
+ });
1058
+ it("return new subAccount if no old subAccounts", () => {
1059
+ expect((0, synchronisation_1.mergeSubAccounts)(undefined, [initialSubAccount])).toEqual([initialSubAccount]);
1060
+ });
1061
+ it("merge subAccounts properly if initialAccount has the same as new subAccounts", () => {
1062
+ expect((0, synchronisation_1.mergeSubAccounts)(initialAccount, [initialSubAccount])).toEqual([initialSubAccount]);
1063
+ });
1064
+ it("adds new sub account to initialAccount properly", () => {
1065
+ const newSubAccount = {
1066
+ type: "TokenAccount",
1067
+ id: "js:2:aptos:474d:aptos+aptos%2Ffungible~!underscore!~asset%2Fcellana~!underscore!~0x2ebb",
1068
+ parentId: "js:2:aptos:474d:aptos",
1069
+ token: {
1070
+ type: "TokenCurrency",
1071
+ id: "aptos/fungible_asset/cellana_0x2ebb",
1072
+ contractAddress: "0x2ebb",
1073
+ parentCurrency: {
1074
+ type: "CryptoCurrency",
1075
+ id: "aptos",
1076
+ coinType: 637,
1077
+ name: "Aptos",
1078
+ managerAppName: "Aptos",
1079
+ ticker: "APT",
1080
+ scheme: "aptos",
1081
+ color: "#231F20",
1082
+ family: "aptos",
1083
+ units: [
1084
+ {
1085
+ name: "APT",
1086
+ code: "APT",
1087
+ magnitude: 8,
1088
+ },
1089
+ ],
1090
+ explorerViews: [
1091
+ {
1092
+ address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
1093
+ tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
1094
+ },
1095
+ ],
1096
+ },
1097
+ name: "CELLANA",
1098
+ tokenType: "fungible_asset",
1099
+ ticker: "CELL",
1100
+ disableCountervalue: false,
1101
+ delisted: false,
1102
+ units: [
1103
+ {
1104
+ name: "CELLANA",
1105
+ code: "CELL",
1106
+ magnitude: 8,
1107
+ },
1108
+ ],
1109
+ },
1110
+ balance: (0, bignumber_js_1.default)(22980368),
1111
+ spendableBalance: (0, bignumber_js_1.default)(22980368),
1112
+ creationDate: new Date(),
1113
+ operationsCount: 0,
1114
+ operations: [],
1115
+ pendingOperations: [],
1116
+ swapHistory: [],
1117
+ balanceHistoryCache: index_2.emptyHistoryCache,
1118
+ };
1119
+ expect((0, synchronisation_1.mergeSubAccounts)(initialAccount, [newSubAccount])).toEqual([
1120
+ initialSubAccount,
1121
+ newSubAccount,
1122
+ ]);
1123
+ });
1124
+ it("merge subAccounts properly when new subAccounts is different", () => {
1125
+ expect((0, synchronisation_1.mergeSubAccounts)(initialAccount, [{ ...initialSubAccount, balance: (0, bignumber_js_1.default)(150) }])).toEqual([{ ...initialSubAccount, balance: (0, bignumber_js_1.default)(150) }]);
1126
+ });
1127
+ });
1128
+ describe("getSubAccountShape", () => {
1129
+ beforeEach(() => {
1130
+ mockedAptosAPI = jest.mocked(network_1.AptosAPI);
1131
+ });
1132
+ afterEach(() => {
1133
+ jest.resetAllMocks();
1134
+ });
1135
+ const currency = {
1136
+ type: "CryptoCurrency",
1137
+ id: "aptos",
1138
+ coinType: 637,
1139
+ name: "Aptos",
1140
+ managerAppName: "Aptos",
1141
+ ticker: "APT",
1142
+ scheme: "aptos",
1143
+ color: "#231F20",
1144
+ family: "aptos",
1145
+ units: [
1146
+ {
1147
+ name: "APT",
1148
+ code: "APT",
1149
+ magnitude: 8,
1150
+ },
1151
+ ],
1152
+ explorerViews: [
1153
+ {
1154
+ address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
1155
+ tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
1156
+ },
1157
+ ],
1158
+ };
1159
+ const address = "0xa0d8";
1160
+ const parentId = "js:2:aptos:474d:aptos";
1161
+ const token = {
1162
+ type: "TokenCurrency",
1163
+ id: "aptos/coin/dstapt_0xd111::staked_coin::stakedaptos",
1164
+ contractAddress: "0xd111::staked_coin::StakedAptos",
1165
+ parentCurrency: {
1166
+ type: "CryptoCurrency",
1167
+ id: "aptos",
1168
+ coinType: 637,
1169
+ name: "Aptos",
1170
+ managerAppName: "Aptos",
1171
+ ticker: "APT",
1172
+ scheme: "aptos",
1173
+ color: "#231F20",
1174
+ family: "aptos",
1175
+ units: [
1176
+ {
1177
+ name: "APT",
1178
+ code: "APT",
1179
+ magnitude: 8,
1180
+ },
1181
+ ],
1182
+ explorerViews: [
1183
+ {
1184
+ address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
1185
+ tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
1186
+ },
1187
+ ],
1188
+ },
1189
+ name: "dstAPT",
1190
+ tokenType: "coin",
1191
+ ticker: "dstAPT",
1192
+ disableCountervalue: false,
1193
+ delisted: false,
1194
+ units: [
1195
+ {
1196
+ name: "dstAPT",
1197
+ code: "dstAPT",
1198
+ magnitude: 8,
1199
+ },
1200
+ ],
1201
+ };
1202
+ const firstOperationDate = new Date(10);
1203
+ const operations = [
1204
+ {
1205
+ id: "js:2:aptos:474d:aptos-0x2011-IN",
1206
+ hash: "0x2011",
1207
+ type: "IN",
1208
+ value: (0, bignumber_js_1.default)(2000000),
1209
+ fee: (0, bignumber_js_1.default)(1200),
1210
+ blockHash: "0xf29363a5a78d784c702a8ea352ac3e1461092cc2347b305adcace14aa7b15d60",
1211
+ blockHeight: 315151047,
1212
+ senders: ["0x4e5e"],
1213
+ recipients: ["0xa0d8"],
1214
+ accountId: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
1215
+ date: new Date(1000),
1216
+ extra: {
1217
+ version: "2553182323",
1218
+ },
1219
+ transactionSequenceNumber: 32,
1220
+ hasFailed: false,
1221
+ },
1222
+ {
1223
+ id: "js:2:aptos:474d:aptos-0x06a6-IN",
1224
+ hash: "0x06a6",
1225
+ type: "IN",
1226
+ value: (0, bignumber_js_1.default)(2000000),
1227
+ fee: (0, bignumber_js_1.default)(1200),
1228
+ blockHash: "0xbae2",
1229
+ blockHeight: 313836935,
1230
+ senders: ["0x4e5e"],
1231
+ recipients: ["0xa0d8"],
1232
+ accountId: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
1233
+ date: firstOperationDate,
1234
+ extra: {
1235
+ version: "2544815758",
1236
+ },
1237
+ transactionSequenceNumber: 31,
1238
+ hasFailed: false,
1239
+ },
1240
+ ];
1241
+ it("returns the correct information", async () => {
1242
+ const TOKEN_CONTRACT_ADDRESS = "0xd111::staked_coin::StakedAptos";
1243
+ const mockGetBalances = jest
1244
+ .fn()
1245
+ .mockResolvedValue([{ contractAddress: TOKEN_CONTRACT_ADDRESS, amount: (0, bignumber_js_1.default)(1234567) }]);
1246
+ mockedAptosAPI.mockImplementation(() => ({
1247
+ getBalances: mockGetBalances,
1248
+ }));
1249
+ const subAccount = await (0, synchronisation_1.getSubAccountShape)(currency, address, parentId, token, operations);
1250
+ expect(subAccount).toEqual({
1251
+ type: "TokenAccount",
1252
+ id: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
1253
+ parentId,
1254
+ token,
1255
+ balance: (0, bignumber_js_1.default)(1234567),
1256
+ spendableBalance: (0, bignumber_js_1.default)(1234567),
1257
+ creationDate: firstOperationDate,
1258
+ operations,
1259
+ operationsCount: operations.length,
1260
+ pendingOperations: [],
1261
+ balanceHistoryCache: index_2.emptyHistoryCache,
1262
+ swapHistory: [],
1263
+ });
1264
+ expect(mockedAptosAPI).toHaveBeenCalledTimes(1);
1265
+ });
1266
+ });
1267
+ describe("getSubAccounts", () => {
1268
+ beforeEach(() => {
1269
+ mockedAptosAPI = jest.mocked(network_1.AptosAPI);
1270
+ });
1271
+ afterEach(() => {
1272
+ jest.resetAllMocks();
1273
+ });
1274
+ const address = "0x4e5e";
1275
+ const infos = {
1276
+ currency: {
1277
+ type: "CryptoCurrency",
1278
+ id: "aptos",
1279
+ coinType: 637,
1280
+ name: "Aptos",
1281
+ managerAppName: "Aptos",
1282
+ ticker: "APT",
1283
+ scheme: "aptos",
1284
+ color: "#231F20",
1285
+ family: "aptos",
1286
+ units: [
1287
+ {
1288
+ name: "APT",
1289
+ code: "APT",
1290
+ magnitude: 8,
1291
+ },
1292
+ ],
1293
+ explorerViews: [
1294
+ {
1295
+ address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
1296
+ tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
1297
+ },
1298
+ ],
1299
+ },
1300
+ address,
1301
+ index: 1,
1302
+ derivationPath: "44'/637'/0'",
1303
+ derivationMode: "aptos",
1304
+ };
1305
+ const accountId = "js:2:aptos:3282:aptos";
1306
+ const lastTokenOperations = [
1307
+ {
1308
+ id: "js:2:aptos:474d:aptos-0x2011-IN",
1309
+ hash: "0x2011",
1310
+ type: "IN",
1311
+ value: (0, bignumber_js_1.default)(2000000),
1312
+ fee: (0, bignumber_js_1.default)(1200),
1313
+ blockHash: "0xf29363a5a78d784c702a8ea352ac3e1461092cc2347b305adcace14aa7b15d60",
1314
+ blockHeight: 315151047,
1315
+ senders: ["0x4e5e"],
1316
+ recipients: ["0xa0d8"],
1317
+ accountId: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
1318
+ date: new Date(1000),
1319
+ extra: {
1320
+ version: "2553182323",
1321
+ },
1322
+ transactionSequenceNumber: 32,
1323
+ hasFailed: false,
1324
+ },
1325
+ {
1326
+ id: "js:2:aptos:474d:aptos-0x06a6-IN",
1327
+ hash: "0x06a6",
1328
+ type: "IN",
1329
+ value: (0, bignumber_js_1.default)(2000000),
1330
+ fee: (0, bignumber_js_1.default)(1200),
1331
+ blockHash: "0xbae2",
1332
+ blockHeight: 313836935,
1333
+ senders: ["0x4e5e"],
1334
+ recipients: ["0xa0d8"],
1335
+ accountId: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
1336
+ date: new Date(10),
1337
+ extra: {
1338
+ version: "2544815758",
1339
+ },
1340
+ transactionSequenceNumber: 31,
1341
+ hasFailed: false,
1342
+ },
1343
+ ];
1344
+ it("returns the correct information", async () => {
1345
+ const TOKEN_CONTRACT_ADDRESS = "0xd111::staked_coin::StakedAptos";
1346
+ const mockGetBalances = jest
1347
+ .fn()
1348
+ .mockResolvedValue([{ contractAddress: TOKEN_CONTRACT_ADDRESS, amount: (0, bignumber_js_1.default)(1234567) }]);
1349
+ mockedAptosAPI.mockImplementation(() => ({
1350
+ getBalances: mockGetBalances,
1351
+ }));
1352
+ mockedDecodeTokenAccountId.mockReturnValue({
1353
+ token: {
1354
+ type: "TokenCurrency",
1355
+ id: "aptos/coin/dstapt_0xd111::staked_coin::stakedaptos",
1356
+ contractAddress: "0xd111::staked_coin::StakedAptos",
1357
+ parentCurrency: {
1358
+ type: "CryptoCurrency",
1359
+ id: "aptos",
1360
+ coinType: 637,
1361
+ name: "Aptos",
1362
+ managerAppName: "Aptos",
1363
+ ticker: "APT",
1364
+ scheme: "aptos",
1365
+ color: "#231F20",
1366
+ family: "aptos",
1367
+ units: [
1368
+ {
1369
+ name: "APT",
1370
+ code: "APT",
1371
+ magnitude: 8,
1372
+ },
1373
+ ],
1374
+ explorerViews: [
1375
+ {
1376
+ address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
1377
+ tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
1378
+ },
1379
+ ],
1380
+ },
1381
+ name: "dstAPT",
1382
+ tokenType: "coin",
1383
+ ticker: "dstAPT",
1384
+ disableCountervalue: false,
1385
+ delisted: false,
1386
+ units: [
1387
+ {
1388
+ name: "dstAPT",
1389
+ code: "dstAPT",
1390
+ magnitude: 8,
1391
+ },
1392
+ ],
1393
+ },
1394
+ accountId: "js:2:aptos:6415:aptos",
1395
+ });
1396
+ const result = await (0, synchronisation_1.getSubAccounts)(infos, address, accountId, lastTokenOperations);
1397
+ expect(result).toEqual([
1398
+ {
1399
+ type: "TokenAccount",
1400
+ id: "js:2:aptos:3282:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
1401
+ parentId: "js:2:aptos:3282:aptos",
1402
+ token: {
1403
+ type: "TokenCurrency",
1404
+ id: "aptos/coin/dstapt_0xd111::staked_coin::stakedaptos",
1405
+ contractAddress: "0xd111::staked_coin::StakedAptos",
1406
+ parentCurrency: {
1407
+ type: "CryptoCurrency",
1408
+ id: "aptos",
1409
+ coinType: 637,
1410
+ name: "Aptos",
1411
+ managerAppName: "Aptos",
1412
+ ticker: "APT",
1413
+ scheme: "aptos",
1414
+ color: "#231F20",
1415
+ family: "aptos",
1416
+ units: [
1417
+ {
1418
+ name: "APT",
1419
+ code: "APT",
1420
+ magnitude: 8,
1421
+ },
1422
+ ],
1423
+ explorerViews: [
1424
+ {
1425
+ address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
1426
+ tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
1427
+ },
1428
+ ],
1429
+ },
1430
+ name: "dstAPT",
1431
+ tokenType: "coin",
1432
+ ticker: "dstAPT",
1433
+ disableCountervalue: false,
1434
+ delisted: false,
1435
+ units: [
1436
+ {
1437
+ name: "dstAPT",
1438
+ code: "dstAPT",
1439
+ magnitude: 8,
1440
+ },
1441
+ ],
1442
+ },
1443
+ balance: (0, bignumber_js_1.default)(1234567),
1444
+ spendableBalance: (0, bignumber_js_1.default)(1234567),
1445
+ creationDate: new Date(10),
1446
+ operations: [
1447
+ {
1448
+ accountId: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
1449
+ blockHash: "0xf29363a5a78d784c702a8ea352ac3e1461092cc2347b305adcace14aa7b15d60",
1450
+ blockHeight: 315151047,
1451
+ date: new Date(1000),
1452
+ extra: { version: "2553182323" },
1453
+ fee: (0, bignumber_js_1.default)(1200),
1454
+ hasFailed: false,
1455
+ hash: "0x2011",
1456
+ id: "js:2:aptos:474d:aptos-0x2011-IN",
1457
+ recipients: ["0xa0d8"],
1458
+ senders: ["0x4e5e"],
1459
+ transactionSequenceNumber: 32,
1460
+ type: "IN",
1461
+ value: (0, bignumber_js_1.default)(2000000),
1462
+ },
1463
+ {
1464
+ accountId: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
1465
+ blockHash: "0xbae2",
1466
+ blockHeight: 313836935,
1467
+ date: new Date(10),
1468
+ fee: (0, bignumber_js_1.default)(1200),
1469
+ extra: { version: "2544815758" },
1470
+ hasFailed: false,
1471
+ hash: "0x06a6",
1472
+ id: "js:2:aptos:474d:aptos-0x06a6-IN",
1473
+ recipients: ["0xa0d8"],
1474
+ senders: ["0x4e5e"],
1475
+ transactionSequenceNumber: 31,
1476
+ type: "IN",
1477
+ value: (0, bignumber_js_1.default)(2000000),
1478
+ },
1479
+ ],
1480
+ operationsCount: 2,
1481
+ pendingOperations: [],
1482
+ balanceHistoryCache: index_2.emptyHistoryCache,
1483
+ swapHistory: [],
1484
+ },
1485
+ ]);
1486
+ });
1487
+ });
1488
+ describe("getStake", () => {
1489
+ beforeEach(() => {
1490
+ mockedAptosAPI = jest.mocked(network_1.AptosAPI);
1491
+ });
1492
+ afterEach(() => {
1493
+ jest.clearAllMocks();
1494
+ });
1495
+ it("When AptosResource has StakingPositions should validate", async () => {
1496
+ const mockDelegatorBalance = [1000000, 500000, 200000];
1497
+ const validatorAddress = "0xvalidator1";
1498
+ const stakingOperations = [
1499
+ {
1500
+ id: "js:2:aptos:474d:aptos-0x3f35-OUT",
1501
+ hash: "0x3f35",
1502
+ type: "STAKE",
1503
+ value: (0, bignumber_js_1.default)(1200),
1504
+ fee: (0, bignumber_js_1.default)(1200),
1505
+ blockHash: "0x6d02",
1506
+ blockHeight: 311948147,
1507
+ senders: ["0xa0d8"],
1508
+ recipients: [validatorAddress],
1509
+ accountId: "js:2:aptos:474d:aptos",
1510
+ date: new Date("2025-03-28T15:56:00.481Z"),
1511
+ extra: {
1512
+ version: "2532591427",
1513
+ },
1514
+ transactionSequenceNumber: 121,
1515
+ hasFailed: false,
1516
+ },
1517
+ ];
1518
+ const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
1519
+ balance: (0, bignumber_js_1.default)(68254118),
1520
+ transactions: [
1521
+ {
1522
+ version: "2532591427",
1523
+ hash: "0x3f35",
1524
+ state_change_hash: "0xb480",
1525
+ event_root_hash: "0x3fa1",
1526
+ state_checkpoint_hash: null,
1527
+ gas_used: "12",
1528
+ success: true,
1529
+ vm_status: "Executed successfully",
1530
+ accumulator_root_hash: "0x319f",
1531
+ changes: [
1532
+ {
1533
+ address: "0x4e5e",
1534
+ state_key_hash: "0x3c0c",
1535
+ data: {
1536
+ type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
1537
+ data: {
1538
+ coin: {
1539
+ value: "4000000",
1540
+ },
1541
+ deposit_events: {
1542
+ counter: "9",
1543
+ guid: {
1544
+ id: {
1545
+ addr: "0x4e5e",
1546
+ creation_num: "4",
1547
+ },
1548
+ },
1549
+ },
1550
+ frozen: false,
1551
+ withdraw_events: {
1552
+ counter: "6",
1553
+ guid: {
1554
+ id: {
1555
+ addr: "0x4e5e",
1556
+ creation_num: "5",
1557
+ },
1558
+ },
1559
+ },
1560
+ },
1561
+ },
1562
+ type: "write_resource",
1563
+ },
1564
+ {
1565
+ address: "0xa0d8",
1566
+ state_key_hash: "0x1709",
1567
+ data: {
1568
+ type: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
1569
+ data: {
1570
+ coin: {
1571
+ value: "68254118",
1572
+ },
1573
+ deposit_events: {
1574
+ counter: "46",
1575
+ guid: {
1576
+ id: {
1577
+ addr: "0xa0d8",
1578
+ creation_num: "2",
1579
+ },
1580
+ },
1581
+ },
1582
+ frozen: false,
1583
+ withdraw_events: {
1584
+ counter: "89",
1585
+ guid: {
1586
+ id: {
1587
+ addr: "0xa0d8",
1588
+ creation_num: "3",
1589
+ },
1590
+ },
1591
+ },
1592
+ },
1593
+ },
1594
+ type: "write_resource",
1595
+ },
1596
+ {
1597
+ address: "0xa0d8",
1598
+ state_key_hash: "0x5520",
1599
+ data: {
1600
+ type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
1601
+ data: {
1602
+ coin: {
1603
+ value: "1000000",
1604
+ },
1605
+ deposit_events: {
1606
+ counter: "7",
1607
+ guid: {
1608
+ id: {
1609
+ addr: "0xa0d8",
1610
+ creation_num: "10",
1611
+ },
1612
+ },
1613
+ },
1614
+ frozen: false,
1615
+ withdraw_events: {
1616
+ counter: "13",
1617
+ guid: {
1618
+ id: {
1619
+ addr: "0xa0d8",
1620
+ creation_num: "11",
1621
+ },
1622
+ },
1623
+ },
1624
+ },
1625
+ },
1626
+ type: "write_resource",
1627
+ },
1628
+ {
1629
+ address: "0xa0d8",
1630
+ state_key_hash: "0x6f1e",
1631
+ data: {
1632
+ type: "0x1::account::Account",
1633
+ data: {
1634
+ authentication_key: "0xa0d8",
1635
+ coin_register_events: {
1636
+ counter: "5",
1637
+ guid: {
1638
+ id: {
1639
+ addr: "0xa0d8",
1640
+ creation_num: "0",
1641
+ },
1642
+ },
1643
+ },
1644
+ guid_creation_num: "12",
1645
+ key_rotation_events: {
1646
+ counter: "0",
1647
+ guid: {
1648
+ id: {
1649
+ addr: "0xa0d8",
1650
+ creation_num: "1",
1651
+ },
1652
+ },
1653
+ },
1654
+ rotation_capability_offer: {
1655
+ for: {
1656
+ vec: [],
1657
+ },
1658
+ },
1659
+ sequence_number: "122",
1660
+ signer_capability_offer: {
1661
+ for: {
1662
+ vec: [],
1663
+ },
1664
+ },
1665
+ },
1666
+ },
1667
+ type: "write_resource",
1668
+ },
1669
+ {
1670
+ state_key_hash: "0x6e4b",
1671
+ handle: "0x1b85",
1672
+ key: "0x0619",
1673
+ value: "0x1ddaf8da3b1497010000000000000000",
1674
+ data: null,
1675
+ type: "write_table_item",
1676
+ },
1677
+ ],
1678
+ sender: "0xa0d8",
1679
+ sequence_number: "121",
1680
+ max_gas_amount: "12",
1681
+ gas_unit_price: "100",
1682
+ expiration_timestamp_secs: "1743177404",
1683
+ payload: {
1684
+ function: "0x1::aptos_account::transfer_coins",
1685
+ type_arguments: ["0xd111::staked_coin::StakedAptos"],
1686
+ arguments: ["0x4e5e", "1500000"],
1687
+ type: "entry_function_payload",
1688
+ },
1689
+ signature: {
1690
+ public_key: "0x474d",
1691
+ signature: "0x0ad8",
1692
+ type: "ed25519_signature",
1693
+ },
1694
+ events: [
1695
+ {
1696
+ guid: {
1697
+ creation_number: "11",
1698
+ account_address: "0xa0d8",
1699
+ },
1700
+ sequence_number: "12",
1701
+ type: "0x1::coin::WithdrawEvent",
1702
+ data: {
1703
+ amount: "1500000",
1704
+ },
1705
+ },
1706
+ {
1707
+ guid: {
1708
+ creation_number: "4",
1709
+ account_address: "0x4e5e",
1710
+ },
1711
+ sequence_number: "8",
1712
+ type: "0x1::coin::DepositEvent",
1713
+ data: {
1714
+ amount: "1500000",
1715
+ },
1716
+ },
1717
+ {
1718
+ guid: {
1719
+ creation_number: "0",
1720
+ account_address: "0x0",
1721
+ },
1722
+ sequence_number: "0",
1723
+ type: "0x1::transaction_fee::FeeStatement",
1724
+ data: {
1725
+ execution_gas_units: "6",
1726
+ io_gas_units: "6",
1727
+ storage_fee_octas: "0",
1728
+ storage_fee_refund_octas: "0",
1729
+ total_charge_gas_units: "12",
1730
+ },
1731
+ },
1732
+ ],
1733
+ timestamp: "1743177360481259",
1734
+ type: "user_transaction",
1735
+ block: {
1736
+ height: 311948147,
1737
+ hash: "0x6d02",
1738
+ },
1739
+ },
1740
+ {
1741
+ version: "2532549325",
1742
+ hash: "0x9a6b",
1743
+ state_change_hash: "0xa424",
1744
+ event_root_hash: "0x0321",
1745
+ state_checkpoint_hash: null,
1746
+ gas_used: "12",
1747
+ success: true,
1748
+ vm_status: "Executed successfully",
1749
+ accumulator_root_hash: "0xede9",
1750
+ changes: [
1751
+ {
1752
+ address: "0x4e5e",
1753
+ state_key_hash: "0x3c0c",
1754
+ data: {
1755
+ type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
1756
+ data: {
1757
+ coin: {
1758
+ value: "2500000",
1759
+ },
1760
+ deposit_events: {
1761
+ counter: "8",
1762
+ guid: {
1763
+ id: {
1764
+ addr: "0x4e5e",
1765
+ creation_num: "4",
1766
+ },
1767
+ },
1768
+ },
1769
+ frozen: false,
1770
+ withdraw_events: {
1771
+ counter: "6",
1772
+ guid: {
1773
+ id: {
1774
+ addr: "0x4e5e",
1775
+ creation_num: "5",
1776
+ },
1777
+ },
1778
+ },
1779
+ },
1780
+ },
1781
+ type: "write_resource",
1782
+ },
1783
+ {
1784
+ address: "0xa0d8",
1785
+ state_key_hash: "0x1709",
1786
+ data: {
1787
+ type: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
1788
+ data: {
1789
+ coin: {
1790
+ value: "68255318",
1791
+ },
1792
+ deposit_events: {
1793
+ counter: "46",
1794
+ guid: {
1795
+ id: {
1796
+ addr: "0xa0d8",
1797
+ creation_num: "2",
1798
+ },
1799
+ },
1800
+ },
1801
+ frozen: false,
1802
+ withdraw_events: {
1803
+ counter: "89",
1804
+ guid: {
1805
+ id: {
1806
+ addr: "0xa0d8",
1807
+ creation_num: "3",
1808
+ },
1809
+ },
1810
+ },
1811
+ },
1812
+ },
1813
+ type: "write_resource",
1814
+ },
1815
+ {
1816
+ address: "0xa0d8",
1817
+ state_key_hash: "0x5520",
1818
+ data: {
1819
+ type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
1820
+ data: {
1821
+ coin: {
1822
+ value: "2500000",
1823
+ },
1824
+ deposit_events: {
1825
+ counter: "7",
1826
+ guid: {
1827
+ id: {
1828
+ addr: "0xa0d8",
1829
+ creation_num: "10",
1830
+ },
1831
+ },
1832
+ },
1833
+ frozen: false,
1834
+ withdraw_events: {
1835
+ counter: "12",
1836
+ guid: {
1837
+ id: {
1838
+ addr: "0xa0d8",
1839
+ creation_num: "11",
1840
+ },
1841
+ },
1842
+ },
1843
+ },
1844
+ },
1845
+ type: "write_resource",
1846
+ },
1847
+ {
1848
+ address: "0xa0d8",
1849
+ state_key_hash: "0x6f1e",
1850
+ data: {
1851
+ type: "0x1::account::Account",
1852
+ data: {
1853
+ authentication_key: "0xa0d8",
1854
+ coin_register_events: {
1855
+ counter: "5",
1856
+ guid: {
1857
+ id: {
1858
+ addr: "0xa0d8",
1859
+ creation_num: "0",
1860
+ },
1861
+ },
1862
+ },
1863
+ guid_creation_num: "12",
1864
+ key_rotation_events: {
1865
+ counter: "0",
1866
+ guid: {
1867
+ id: {
1868
+ addr: "0xa0d8",
1869
+ creation_num: "1",
1870
+ },
1871
+ },
1872
+ },
1873
+ rotation_capability_offer: {
1874
+ for: {
1875
+ vec: [],
1876
+ },
1877
+ },
1878
+ sequence_number: "121",
1879
+ signer_capability_offer: {
1880
+ for: {
1881
+ vec: [],
1882
+ },
1883
+ },
1884
+ },
1885
+ },
1886
+ type: "write_resource",
1887
+ },
1888
+ {
1889
+ state_key_hash: "0x6e4b",
1890
+ handle: "0x1b85",
1891
+ key: "0x0619",
1892
+ value: "0xe86e0039581497010000000000000000",
1893
+ data: null,
1894
+ type: "write_table_item",
1895
+ },
1896
+ ],
1897
+ sender: "0xa0d8",
1898
+ sequence_number: "120",
1899
+ max_gas_amount: "12",
1900
+ gas_unit_price: "100",
1901
+ expiration_timestamp_secs: "1743176706",
1902
+ payload: {
1903
+ function: "0x1::aptos_account::transfer_coins",
1904
+ type_arguments: ["0xd111::staked_coin::StakedAptos"],
1905
+ arguments: ["0x4e5e", "2500000"],
1906
+ type: "entry_function_payload",
1907
+ },
1908
+ signature: {
1909
+ public_key: "0x474d",
1910
+ signature: "0xb70e",
1911
+ type: "ed25519_signature",
1912
+ },
1913
+ events: [
1914
+ {
1915
+ guid: {
1916
+ creation_number: "11",
1917
+ account_address: "0xa0d8",
1918
+ },
1919
+ sequence_number: "11",
1920
+ type: "0x1::coin::WithdrawEvent",
1921
+ data: {
1922
+ amount: "2500000",
1923
+ },
1924
+ },
1925
+ {
1926
+ guid: {
1927
+ creation_number: "4",
1928
+ account_address: "0x4e5e",
1929
+ },
1930
+ sequence_number: "7",
1931
+ type: "0x1::coin::DepositEvent",
1932
+ data: {
1933
+ amount: "2500000",
1934
+ },
1935
+ },
1936
+ {
1937
+ guid: {
1938
+ creation_number: "0",
1939
+ account_address: "0x0",
1940
+ },
1941
+ sequence_number: "0",
1942
+ type: "0x1::transaction_fee::FeeStatement",
1943
+ data: {
1944
+ execution_gas_units: "6",
1945
+ io_gas_units: "6",
1946
+ storage_fee_octas: "0",
1947
+ storage_fee_refund_octas: "0",
1948
+ total_charge_gas_units: "12",
1949
+ },
1950
+ },
1951
+ ],
1952
+ timestamp: "1743176594693251",
1953
+ type: "user_transaction",
1954
+ block: {
1955
+ height: 311942427,
1956
+ hash: "0x8655",
1957
+ },
1958
+ },
1959
+ ],
1960
+ blockHeight: 316278241,
1961
+ }));
1962
+ const mockGetBalance = jest.fn().mockImplementation(() => (0, bignumber_js_1.default)(5000000));
1963
+ mockedDecodeTokenAccountId.mockReturnValue({
1964
+ token: {
1965
+ type: "TokenCurrency",
1966
+ id: "aptos/coin/dstapt_0xd111::staked_coin::stakedaptos",
1967
+ contractAddress: "0xd111::staked_coin::StakedAptos",
1968
+ parentCurrency: {
1969
+ type: "CryptoCurrency",
1970
+ id: "aptos",
1971
+ coinType: 637,
1972
+ name: "Aptos",
1973
+ managerAppName: "Aptos",
1974
+ ticker: "APT",
1975
+ scheme: "aptos",
1976
+ color: "#231F20",
1977
+ family: "aptos",
1978
+ units: [
1979
+ {
1980
+ name: "APT",
1981
+ code: "APT",
1982
+ magnitude: 8,
1983
+ },
1984
+ ],
1985
+ explorerViews: [
1986
+ {
1987
+ address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
1988
+ tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
1989
+ },
1990
+ ],
1991
+ },
1992
+ name: "dstAPT",
1993
+ tokenType: "coin",
1994
+ ticker: "dstAPT",
1995
+ disableCountervalue: false,
1996
+ delisted: false,
1997
+ units: [
1998
+ {
1999
+ name: "dstAPT",
2000
+ code: "dstAPT",
2001
+ magnitude: 8,
2002
+ },
2003
+ ],
2004
+ },
2005
+ accountId: "js:2:aptos:6415:aptos",
2006
+ });
2007
+ const operations = [
2008
+ {
2009
+ id: "js:2:aptos:474d:aptos-0x3f35-OUT",
2010
+ hash: "0x3f35",
2011
+ type: "FEES",
2012
+ value: (0, bignumber_js_1.default)(1200),
2013
+ fee: (0, bignumber_js_1.default)(1200),
2014
+ blockHash: "0x6d02",
2015
+ blockHeight: 311948147,
2016
+ senders: ["0xa0d8"],
2017
+ recipients: ["0x4e5e"],
2018
+ accountId: "js:2:aptos:474d:aptos",
2019
+ date: new Date("2025-03-28T15:56:00.481Z"),
2020
+ extra: {
2021
+ version: "2532591427",
2022
+ },
2023
+ transactionSequenceNumber: 121,
2024
+ hasFailed: false,
2025
+ },
2026
+ {
2027
+ id: "js:2:aptos:474d:aptos-0x9a6b-OUT",
2028
+ hash: "0x9a6b",
2029
+ type: "FEES",
2030
+ value: (0, bignumber_js_1.default)(1200),
2031
+ fee: (0, bignumber_js_1.default)(1200),
2032
+ blockHash: "0x8655",
2033
+ blockHeight: 311942427,
2034
+ senders: ["0xa0d8"],
2035
+ recipients: ["0x4e5e"],
2036
+ accountId: "js:2:aptos:474d:aptos",
2037
+ date: new Date("2025-03-28T15:43:14.693Z"),
2038
+ extra: {
2039
+ version: "2532549325",
2040
+ },
2041
+ transactionSequenceNumber: 120,
2042
+ hasFailed: false,
2043
+ },
2044
+ ];
2045
+ const tokenOperations = [
2046
+ {
2047
+ id: "js:2:aptos:474d:aptos-0x3f35-OUT",
2048
+ hash: "0x3f35",
2049
+ type: "OUT",
2050
+ value: (0, bignumber_js_1.default)(1500000),
2051
+ fee: (0, bignumber_js_1.default)(1200),
2052
+ blockHash: "0x6d02",
2053
+ blockHeight: 311948147,
2054
+ senders: ["0xa0d8"],
2055
+ recipients: ["0x4e5e"],
2056
+ accountId: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
2057
+ date: new Date("2025-03-28T15:56:00.481Z"),
2058
+ extra: {
2059
+ version: "2532591427",
2060
+ },
2061
+ transactionSequenceNumber: 121,
2062
+ hasFailed: false,
2063
+ },
2064
+ {
2065
+ id: "js:2:aptos:474d:aptos-0x9a6b-OUT",
2066
+ hash: "0x9a6b",
2067
+ type: "OUT",
2068
+ value: (0, bignumber_js_1.default)(2500000),
2069
+ fee: (0, bignumber_js_1.default)(1200),
2070
+ blockHash: "0x8655",
2071
+ blockHeight: 311942427,
2072
+ senders: ["0xa0d8"],
2073
+ recipients: ["0x4e5e"],
2074
+ accountId: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
2075
+ date: new Date("2025-03-28T15:43:14.693Z"),
2076
+ extra: {
2077
+ version: "2532549325",
2078
+ },
2079
+ transactionSequenceNumber: 120,
2080
+ hasFailed: false,
2081
+ },
2082
+ ];
2083
+ const mockedGetDelegatorBalanceInPool = jest.fn().mockResolvedValue([
2084
+ (0, bignumber_js_1.default)(mockDelegatorBalance[0]), // active
2085
+ (0, bignumber_js_1.default)(mockDelegatorBalance[1]), // inactive
2086
+ (0, bignumber_js_1.default)(mockDelegatorBalance[2]), // pending_inactive
2087
+ ]);
2088
+ mockedAptosAPI.mockImplementation(() => ({
2089
+ getAccountInfo: mockGetAccountInfo,
2090
+ getDelegatorBalanceInPool: mockedGetDelegatorBalanceInPool,
2091
+ getBalances: mockGetBalance,
2092
+ }));
2093
+ jest.mocked(jsHelpers_1.mergeOps).mockReturnValue(operations);
2094
+ jest.mocked(logic_1.txsToOps).mockReturnValue([operations, tokenOperations, stakingOperations]);
2095
+ const info = {
2096
+ currency: {
2097
+ type: "CryptoCurrency",
2098
+ id: "aptos",
2099
+ coinType: 637,
2100
+ name: "Aptos",
2101
+ managerAppName: "Aptos",
2102
+ ticker: "APT",
2103
+ scheme: "aptos",
2104
+ color: "#231F20",
2105
+ family: "aptos",
2106
+ units: [
2107
+ {
2108
+ name: "APT",
2109
+ code: "APT",
2110
+ magnitude: 8,
2111
+ },
2112
+ ],
2113
+ },
2114
+ index: 0,
2115
+ address: "0xa0d8",
2116
+ derivationPath: "44'/637'/0'",
2117
+ derivationMode: "aptos",
2118
+ initialAccount: {
2119
+ type: "Account",
2120
+ id: "js:2:aptos:474d:aptos",
2121
+ used: true,
2122
+ seedIdentifier: "3086",
2123
+ derivationMode: "aptos",
2124
+ index: 0,
2125
+ freshAddress: "0xa0d8",
2126
+ freshAddressPath: "44'/637'/0'/0'/0'",
2127
+ blockHeight: 316272224,
2128
+ creationDate: "2025-01-16T14:17:41.076Z",
2129
+ balance: (0, bignumber_js_1.default)(68254118),
2130
+ spendableBalance: (0, bignumber_js_1.default)(68254118),
2131
+ operations: [],
2132
+ operationsCount: 0,
2133
+ pendingOperations: [],
2134
+ currency: {
2135
+ type: "CryptoCurrency",
2136
+ id: "aptos",
2137
+ coinType: 637,
2138
+ name: "Aptos",
2139
+ managerAppName: "Aptos",
2140
+ ticker: "APT",
2141
+ scheme: "aptos",
2142
+ color: "#231F20",
2143
+ family: "aptos",
2144
+ units: [
2145
+ {
2146
+ name: "APT",
2147
+ code: "APT",
2148
+ magnitude: 8,
2149
+ },
2150
+ ],
2151
+ },
2152
+ lastSyncDate: new Date(),
2153
+ swapHistory: [],
2154
+ balanceHistoryCache: index_2.emptyHistoryCache,
2155
+ xpub: "474d",
2156
+ subAccounts: [
2157
+ {
2158
+ type: "TokenAccount",
2159
+ id: "js:2:aptos:474d:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd111%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
2160
+ parentId: "js:2:aptos:474d:aptos",
2161
+ token: {
2162
+ type: "TokenCurrency",
2163
+ id: "aptos/coin/dstapt_0xd111::staked_coin::stakedaptos",
2164
+ contractAddress: "0xd111::staked_coin::StakedAptos",
2165
+ parentCurrency: {
2166
+ type: "CryptoCurrency",
2167
+ id: "aptos",
2168
+ coinType: 637,
2169
+ name: "Aptos",
2170
+ managerAppName: "Aptos",
2171
+ ticker: "APT",
2172
+ scheme: "aptos",
2173
+ color: "#231F20",
2174
+ family: "aptos",
2175
+ units: [
2176
+ {
2177
+ name: "APT",
2178
+ code: "APT",
2179
+ magnitude: 8,
2180
+ },
2181
+ ],
2182
+ },
2183
+ name: "dstAPT",
2184
+ tokenType: "coin",
2185
+ ticker: "dstAPT",
2186
+ disableCountervalue: false,
2187
+ delisted: false,
2188
+ units: [
2189
+ {
2190
+ name: "dstAPT",
2191
+ code: "dstAPT",
2192
+ magnitude: 8,
2193
+ },
2194
+ ],
2195
+ },
2196
+ balance: (0, bignumber_js_1.default)(5000000),
2197
+ spendableBalance: (0, bignumber_js_1.default)(5000000),
2198
+ creationDate: "2025-03-11T09:33:46.840Z",
2199
+ operations: [],
2200
+ operationsCount: 0,
2201
+ pendingOperations: [],
2202
+ swapHistory: [],
2203
+ balanceHistoryCache: index_2.emptyHistoryCache,
2204
+ },
2205
+ ],
2206
+ },
2207
+ };
2208
+ const result = await (0, synchronisation_1.getAccountShape)(info, {});
2209
+ expect(result.aptosResources).toBeDefined();
2210
+ const stakingEnabled = (0, live_env_1.getEnv)("APTOS_ENABLE_STAKING") === true;
2211
+ if (stakingEnabled) {
2212
+ expect(result.aptosResources?.stakingPositions).toHaveLength(1);
2213
+ const position = result.aptosResources?.stakingPositions?.[0];
2214
+ expect(position).toEqual({
2215
+ active: (0, bignumber_js_1.default)(mockDelegatorBalance[0]),
2216
+ inactive: (0, bignumber_js_1.default)(mockDelegatorBalance[1]),
2217
+ pendingInactive: (0, bignumber_js_1.default)(mockDelegatorBalance[2]),
2218
+ validatorId: stakingOperations[0].recipients[0],
2219
+ });
2220
+ expect(result.aptosResources?.activeBalance).toEqual((0, bignumber_js_1.default)(mockDelegatorBalance[0]));
2221
+ expect(result.aptosResources?.inactiveBalance).toEqual((0, bignumber_js_1.default)(mockDelegatorBalance[1]));
2222
+ expect(result.aptosResources?.pendingInactiveBalance).toEqual((0, bignumber_js_1.default)(mockDelegatorBalance[2]));
2223
+ }
2224
+ });
2225
+ });
2226
+ //# sourceMappingURL=synchronisation.test.js.map