@ledgerhq/coin-aptos 3.4.0 → 3.5.0-nightly.1

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