@ledgerhq/coin-aptos 2.5.1 → 2.5.2-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 (315) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.unimportedrc.json +5 -8
  3. package/CHANGELOG.md +18 -0
  4. package/lib/__tests__/bridge/deviceTransactionConfig.test.js +115 -30
  5. package/lib/__tests__/bridge/deviceTransactionConfig.test.js.map +1 -1
  6. package/lib/__tests__/bridge/getFeesForTransaction.test.js +10 -10
  7. package/lib/__tests__/bridge/getFeesForTransaction.test.js.map +1 -1
  8. package/lib/__tests__/bridge/getTransactionStatus.test.js +193 -2
  9. package/lib/__tests__/bridge/getTransactionStatus.test.js.map +1 -1
  10. package/lib/__tests__/bridge/index.test.js +4 -1
  11. package/lib/__tests__/bridge/index.test.js.map +1 -1
  12. package/lib/__tests__/bridge/logic.test.js +9 -9
  13. package/lib/__tests__/bridge/logic.test.js.map +1 -1
  14. package/lib/__tests__/bridge/prepareTransaction.test.js +1 -0
  15. package/lib/__tests__/bridge/prepareTransaction.test.js.map +1 -1
  16. package/lib/__tests__/bridge/serialization.d.ts +2 -0
  17. package/lib/__tests__/bridge/serialization.d.ts.map +1 -0
  18. package/lib/__tests__/bridge/serialization.js +91 -0
  19. package/lib/__tests__/bridge/serialization.js.map +1 -0
  20. package/lib/__tests__/bridge/synchronisation.test.js +763 -23
  21. package/lib/__tests__/bridge/synchronisation.test.js.map +1 -1
  22. package/lib/__tests__/logic/staking.test.d.ts +2 -0
  23. package/lib/__tests__/logic/staking.test.d.ts.map +1 -0
  24. package/lib/__tests__/logic/staking.test.js +202 -0
  25. package/lib/__tests__/logic/staking.test.js.map +1 -0
  26. package/lib/__tests__/network/client.test.js +3 -3
  27. package/lib/__tests__/network/validators.test.d.ts +2 -0
  28. package/lib/__tests__/network/validators.test.d.ts.map +1 -0
  29. package/lib/__tests__/network/validators.test.js +98 -0
  30. package/lib/__tests__/network/validators.test.js.map +1 -0
  31. package/lib/__tests__/utils/IconGenerator.test.d.ts +2 -0
  32. package/lib/__tests__/utils/IconGenerator.test.d.ts.map +1 -0
  33. package/lib/__tests__/utils/IconGenerator.test.js +14 -0
  34. package/lib/__tests__/utils/IconGenerator.test.js.map +1 -0
  35. package/lib/__tests__/utils/index.test.d.ts +2 -0
  36. package/lib/__tests__/utils/index.test.d.ts.map +1 -0
  37. package/lib/__tests__/utils/index.test.js +11 -0
  38. package/lib/__tests__/utils/index.test.js.map +1 -0
  39. package/lib/bridge/bridge.fixture.d.ts.map +1 -1
  40. package/lib/bridge/bridge.fixture.js +12 -0
  41. package/lib/bridge/bridge.fixture.js.map +1 -1
  42. package/lib/bridge/deviceTransactionConfig.d.ts +7 -8
  43. package/lib/bridge/deviceTransactionConfig.d.ts.map +1 -1
  44. package/lib/bridge/deviceTransactionConfig.js +83 -16
  45. package/lib/bridge/deviceTransactionConfig.js.map +1 -1
  46. package/lib/bridge/estimateMaxSpendable.d.ts +4 -4
  47. package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -1
  48. package/lib/bridge/estimateMaxSpendable.js +1 -1
  49. package/lib/bridge/estimateMaxSpendable.js.map +1 -1
  50. package/lib/bridge/getFeesForTransaction.d.ts.map +1 -1
  51. package/lib/bridge/getFeesForTransaction.js +8 -4
  52. package/lib/bridge/getFeesForTransaction.js.map +1 -1
  53. package/lib/bridge/getTransactionStatus.d.ts +2 -3
  54. package/lib/bridge/getTransactionStatus.d.ts.map +1 -1
  55. package/lib/bridge/getTransactionStatus.js +139 -25
  56. package/lib/bridge/getTransactionStatus.js.map +1 -1
  57. package/lib/bridge/index.d.ts +3 -3
  58. package/lib/bridge/index.d.ts.map +1 -1
  59. package/lib/bridge/index.js +9 -2
  60. package/lib/bridge/index.js.map +1 -1
  61. package/lib/bridge/logic.d.ts +3 -3
  62. package/lib/bridge/logic.d.ts.map +1 -1
  63. package/lib/bridge/logic.js +23 -9
  64. package/lib/bridge/logic.js.map +1 -1
  65. package/lib/bridge/prepareTransaction.d.ts +2 -3
  66. package/lib/bridge/prepareTransaction.d.ts.map +1 -1
  67. package/lib/bridge/prepareTransaction.js +46 -10
  68. package/lib/bridge/prepareTransaction.js.map +1 -1
  69. package/lib/bridge/serialization.d.ts +7 -0
  70. package/lib/bridge/serialization.d.ts.map +1 -0
  71. package/lib/bridge/serialization.js +51 -0
  72. package/lib/bridge/serialization.js.map +1 -0
  73. package/lib/bridge/signOperation.d.ts.map +1 -1
  74. package/lib/bridge/signOperation.js +17 -5
  75. package/lib/bridge/signOperation.js.map +1 -1
  76. package/lib/bridge/synchronisation.d.ts +6 -4
  77. package/lib/bridge/synchronisation.d.ts.map +1 -1
  78. package/lib/bridge/synchronisation.js +51 -4
  79. package/lib/bridge/synchronisation.js.map +1 -1
  80. package/lib/constants.d.ts +25 -1
  81. package/lib/constants.d.ts.map +1 -1
  82. package/lib/constants.js +54 -8
  83. package/lib/constants.js.map +1 -1
  84. package/lib/index.d.ts +0 -1
  85. package/lib/index.d.ts.map +1 -1
  86. package/lib/index.js +0 -15
  87. package/lib/index.js.map +1 -1
  88. package/lib/logic/buildTransaction.d.ts.map +1 -1
  89. package/lib/logic/buildTransaction.js +42 -19
  90. package/lib/logic/buildTransaction.js.map +1 -1
  91. package/lib/logic/getCoinAndAmounts.d.ts +2 -0
  92. package/lib/logic/getCoinAndAmounts.d.ts.map +1 -1
  93. package/lib/logic/getCoinAndAmounts.js +65 -38
  94. package/lib/logic/getCoinAndAmounts.js.map +1 -1
  95. package/lib/logic/staking.d.ts +12 -0
  96. package/lib/logic/staking.d.ts.map +1 -0
  97. package/lib/logic/staking.js +81 -0
  98. package/lib/logic/staking.js.map +1 -0
  99. package/lib/logic/transactionsToOperations.js +3 -3
  100. package/lib/logic/transactionsToOperations.js.map +1 -1
  101. package/lib/network/client.d.ts +4 -1
  102. package/lib/network/client.d.ts.map +1 -1
  103. package/lib/network/client.js +32 -1
  104. package/lib/network/client.js.map +1 -1
  105. package/lib/network/graphql/queries.d.ts +2 -0
  106. package/lib/network/graphql/queries.d.ts.map +1 -1
  107. package/lib/network/graphql/queries.js +42 -2
  108. package/lib/network/graphql/queries.js.map +1 -1
  109. package/lib/network/graphql/types.d.ts +57 -6
  110. package/lib/network/graphql/types.d.ts.map +1 -1
  111. package/lib/network/index.d.ts.map +1 -1
  112. package/lib/network/index.js.map +1 -1
  113. package/lib/network/validators.d.ts +3 -0
  114. package/lib/network/validators.d.ts.map +1 -0
  115. package/lib/network/validators.js +42 -0
  116. package/lib/network/validators.js.map +1 -0
  117. package/lib/preload-data.d.ts +7 -0
  118. package/lib/preload-data.d.ts.map +1 -0
  119. package/lib/preload-data.js +42 -0
  120. package/lib/preload-data.js.map +1 -0
  121. package/lib/preload.d.ts +6 -0
  122. package/lib/preload.d.ts.map +1 -0
  123. package/lib/preload.js +21 -0
  124. package/lib/preload.js.map +1 -0
  125. package/lib/test/bridgeDatasetTest.d.ts.map +1 -1
  126. package/lib/test/bridgeDatasetTest.js +1 -0
  127. package/lib/test/bridgeDatasetTest.js.map +1 -1
  128. package/lib/types/index.d.ts +92 -8
  129. package/lib/types/index.d.ts.map +1 -1
  130. package/lib/types/index.js.map +1 -1
  131. package/lib/utils/IconGenerator.d.ts +12 -0
  132. package/lib/utils/IconGenerator.d.ts.map +1 -0
  133. package/lib/utils/IconGenerator.js +138 -0
  134. package/lib/utils/IconGenerator.js.map +1 -0
  135. package/lib/utils/index.d.ts +3 -0
  136. package/lib/utils/index.d.ts.map +1 -0
  137. package/lib/utils/index.js +31 -0
  138. package/lib/utils/index.js.map +1 -0
  139. package/lib-es/__tests__/bridge/deviceTransactionConfig.test.js +113 -8
  140. package/lib-es/__tests__/bridge/deviceTransactionConfig.test.js.map +1 -1
  141. package/lib-es/__tests__/bridge/getFeesForTransaction.test.js +10 -10
  142. package/lib-es/__tests__/bridge/getFeesForTransaction.test.js.map +1 -1
  143. package/lib-es/__tests__/bridge/getTransactionStatus.test.js +194 -3
  144. package/lib-es/__tests__/bridge/getTransactionStatus.test.js.map +1 -1
  145. package/lib-es/__tests__/bridge/index.test.js +4 -1
  146. package/lib-es/__tests__/bridge/index.test.js.map +1 -1
  147. package/lib-es/__tests__/bridge/logic.test.js +10 -10
  148. package/lib-es/__tests__/bridge/logic.test.js.map +1 -1
  149. package/lib-es/__tests__/bridge/prepareTransaction.test.js +1 -0
  150. package/lib-es/__tests__/bridge/prepareTransaction.test.js.map +1 -1
  151. package/lib-es/__tests__/bridge/serialization.d.ts +2 -0
  152. package/lib-es/__tests__/bridge/serialization.d.ts.map +1 -0
  153. package/lib-es/__tests__/bridge/serialization.js +86 -0
  154. package/lib-es/__tests__/bridge/serialization.js.map +1 -0
  155. package/lib-es/__tests__/bridge/synchronisation.test.js +763 -23
  156. package/lib-es/__tests__/bridge/synchronisation.test.js.map +1 -1
  157. package/lib-es/__tests__/logic/staking.test.d.ts +2 -0
  158. package/lib-es/__tests__/logic/staking.test.d.ts.map +1 -0
  159. package/lib-es/__tests__/logic/staking.test.js +197 -0
  160. package/lib-es/__tests__/logic/staking.test.js.map +1 -0
  161. package/lib-es/__tests__/network/client.test.js +3 -3
  162. package/lib-es/__tests__/network/validators.test.d.ts +2 -0
  163. package/lib-es/__tests__/network/validators.test.d.ts.map +1 -0
  164. package/lib-es/__tests__/network/validators.test.js +93 -0
  165. package/lib-es/__tests__/network/validators.test.js.map +1 -0
  166. package/lib-es/__tests__/utils/IconGenerator.test.d.ts +2 -0
  167. package/lib-es/__tests__/utils/IconGenerator.test.d.ts.map +1 -0
  168. package/lib-es/__tests__/utils/IconGenerator.test.js +12 -0
  169. package/lib-es/__tests__/utils/IconGenerator.test.js.map +1 -0
  170. package/lib-es/__tests__/utils/index.test.d.ts +2 -0
  171. package/lib-es/__tests__/utils/index.test.d.ts.map +1 -0
  172. package/lib-es/__tests__/utils/index.test.js +9 -0
  173. package/lib-es/__tests__/utils/index.test.js.map +1 -0
  174. package/lib-es/bridge/bridge.fixture.d.ts.map +1 -1
  175. package/lib-es/bridge/bridge.fixture.js +12 -0
  176. package/lib-es/bridge/bridge.fixture.js.map +1 -1
  177. package/lib-es/bridge/deviceTransactionConfig.d.ts +7 -8
  178. package/lib-es/bridge/deviceTransactionConfig.d.ts.map +1 -1
  179. package/lib-es/bridge/deviceTransactionConfig.js +83 -14
  180. package/lib-es/bridge/deviceTransactionConfig.js.map +1 -1
  181. package/lib-es/bridge/estimateMaxSpendable.d.ts +4 -4
  182. package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -1
  183. package/lib-es/bridge/estimateMaxSpendable.js +1 -1
  184. package/lib-es/bridge/estimateMaxSpendable.js.map +1 -1
  185. package/lib-es/bridge/getFeesForTransaction.d.ts.map +1 -1
  186. package/lib-es/bridge/getFeesForTransaction.js +9 -5
  187. package/lib-es/bridge/getFeesForTransaction.js.map +1 -1
  188. package/lib-es/bridge/getTransactionStatus.d.ts +2 -3
  189. package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -1
  190. package/lib-es/bridge/getTransactionStatus.js +140 -26
  191. package/lib-es/bridge/getTransactionStatus.js.map +1 -1
  192. package/lib-es/bridge/index.d.ts +3 -3
  193. package/lib-es/bridge/index.d.ts.map +1 -1
  194. package/lib-es/bridge/index.js +9 -2
  195. package/lib-es/bridge/index.js.map +1 -1
  196. package/lib-es/bridge/logic.d.ts +3 -3
  197. package/lib-es/bridge/logic.d.ts.map +1 -1
  198. package/lib-es/bridge/logic.js +23 -9
  199. package/lib-es/bridge/logic.js.map +1 -1
  200. package/lib-es/bridge/prepareTransaction.d.ts +2 -3
  201. package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
  202. package/lib-es/bridge/prepareTransaction.js +46 -10
  203. package/lib-es/bridge/prepareTransaction.js.map +1 -1
  204. package/lib-es/bridge/serialization.d.ts +7 -0
  205. package/lib-es/bridge/serialization.d.ts.map +1 -0
  206. package/lib-es/bridge/serialization.js +41 -0
  207. package/lib-es/bridge/serialization.js.map +1 -0
  208. package/lib-es/bridge/signOperation.d.ts.map +1 -1
  209. package/lib-es/bridge/signOperation.js +17 -5
  210. package/lib-es/bridge/signOperation.js.map +1 -1
  211. package/lib-es/bridge/synchronisation.d.ts +6 -4
  212. package/lib-es/bridge/synchronisation.d.ts.map +1 -1
  213. package/lib-es/bridge/synchronisation.js +49 -3
  214. package/lib-es/bridge/synchronisation.js.map +1 -1
  215. package/lib-es/constants.d.ts +25 -1
  216. package/lib-es/constants.d.ts.map +1 -1
  217. package/lib-es/constants.js +53 -7
  218. package/lib-es/constants.js.map +1 -1
  219. package/lib-es/index.d.ts +0 -1
  220. package/lib-es/index.d.ts.map +1 -1
  221. package/lib-es/index.js +0 -1
  222. package/lib-es/index.js.map +1 -1
  223. package/lib-es/logic/buildTransaction.d.ts.map +1 -1
  224. package/lib-es/logic/buildTransaction.js +42 -19
  225. package/lib-es/logic/buildTransaction.js.map +1 -1
  226. package/lib-es/logic/getCoinAndAmounts.d.ts +2 -0
  227. package/lib-es/logic/getCoinAndAmounts.d.ts.map +1 -1
  228. package/lib-es/logic/getCoinAndAmounts.js +66 -39
  229. package/lib-es/logic/getCoinAndAmounts.js.map +1 -1
  230. package/lib-es/logic/staking.d.ts +12 -0
  231. package/lib-es/logic/staking.d.ts.map +1 -0
  232. package/lib-es/logic/staking.js +67 -0
  233. package/lib-es/logic/staking.js.map +1 -0
  234. package/lib-es/logic/transactionsToOperations.js +4 -4
  235. package/lib-es/logic/transactionsToOperations.js.map +1 -1
  236. package/lib-es/network/client.d.ts +4 -1
  237. package/lib-es/network/client.d.ts.map +1 -1
  238. package/lib-es/network/client.js +32 -1
  239. package/lib-es/network/client.js.map +1 -1
  240. package/lib-es/network/graphql/queries.d.ts +2 -0
  241. package/lib-es/network/graphql/queries.d.ts.map +1 -1
  242. package/lib-es/network/graphql/queries.js +41 -1
  243. package/lib-es/network/graphql/queries.js.map +1 -1
  244. package/lib-es/network/graphql/types.d.ts +57 -6
  245. package/lib-es/network/graphql/types.d.ts.map +1 -1
  246. package/lib-es/network/index.d.ts.map +1 -1
  247. package/lib-es/network/index.js.map +1 -1
  248. package/lib-es/network/validators.d.ts +3 -0
  249. package/lib-es/network/validators.d.ts.map +1 -0
  250. package/lib-es/network/validators.js +35 -0
  251. package/lib-es/network/validators.js.map +1 -0
  252. package/lib-es/preload-data.d.ts +7 -0
  253. package/lib-es/preload-data.d.ts.map +1 -0
  254. package/lib-es/preload-data.js +36 -0
  255. package/lib-es/preload-data.js.map +1 -0
  256. package/lib-es/preload.d.ts +6 -0
  257. package/lib-es/preload.d.ts.map +1 -0
  258. package/lib-es/preload.js +16 -0
  259. package/lib-es/preload.js.map +1 -0
  260. package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -1
  261. package/lib-es/test/bridgeDatasetTest.js +1 -0
  262. package/lib-es/test/bridgeDatasetTest.js.map +1 -1
  263. package/lib-es/types/index.d.ts +92 -8
  264. package/lib-es/types/index.d.ts.map +1 -1
  265. package/lib-es/types/index.js.map +1 -1
  266. package/lib-es/utils/IconGenerator.d.ts +12 -0
  267. package/lib-es/utils/IconGenerator.d.ts.map +1 -0
  268. package/lib-es/utils/IconGenerator.js +134 -0
  269. package/lib-es/utils/IconGenerator.js.map +1 -0
  270. package/lib-es/utils/index.d.ts +3 -0
  271. package/lib-es/utils/index.d.ts.map +1 -0
  272. package/lib-es/utils/index.js +13 -0
  273. package/lib-es/utils/index.js.map +1 -0
  274. package/package.json +14 -9
  275. package/src/__tests__/bridge/deviceTransactionConfig.test.ts +120 -8
  276. package/src/__tests__/bridge/getFeesForTransaction.test.ts +10 -10
  277. package/src/__tests__/bridge/getTransactionStatus.test.ts +247 -3
  278. package/src/__tests__/bridge/index.test.ts +5 -1
  279. package/src/__tests__/bridge/logic.test.ts +10 -10
  280. package/src/__tests__/bridge/prepareTransaction.test.ts +4 -4
  281. package/src/__tests__/bridge/serialization.ts +103 -0
  282. package/src/__tests__/bridge/synchronisation.test.ts +798 -32
  283. package/src/__tests__/logic/staking.test.ts +221 -0
  284. package/src/__tests__/network/client.test.ts +3 -3
  285. package/src/__tests__/network/validators.test.ts +105 -0
  286. package/src/__tests__/utils/IconGenerator.test.ts +13 -0
  287. package/src/__tests__/utils/index.test.ts +11 -0
  288. package/src/bridge/bridge.fixture.ts +12 -0
  289. package/src/bridge/deviceTransactionConfig.ts +90 -21
  290. package/src/bridge/estimateMaxSpendable.ts +5 -5
  291. package/src/bridge/getFeesForTransaction.ts +17 -5
  292. package/src/bridge/getTransactionStatus.ts +208 -32
  293. package/src/bridge/index.ts +14 -5
  294. package/src/bridge/logic.ts +28 -12
  295. package/src/bridge/prepareTransaction.ts +72 -24
  296. package/src/bridge/serialization.ts +52 -0
  297. package/src/bridge/signOperation.ts +20 -7
  298. package/src/bridge/synchronisation.ts +69 -12
  299. package/src/constants.ts +64 -2
  300. package/src/index.ts +0 -2
  301. package/src/logic/buildTransaction.ts +49 -24
  302. package/src/logic/getCoinAndAmounts.ts +91 -41
  303. package/src/logic/staking.ts +105 -0
  304. package/src/logic/transactionsToOperations.ts +5 -5
  305. package/src/network/client.ts +44 -4
  306. package/src/network/graphql/queries.ts +46 -1
  307. package/src/network/graphql/types.ts +63 -6
  308. package/src/network/index.ts +1 -0
  309. package/src/network/validators.ts +48 -0
  310. package/src/preload-data.ts +43 -0
  311. package/src/preload.ts +23 -0
  312. package/src/test/bridgeDatasetTest.ts +1 -0
  313. package/src/types/index.ts +106 -8
  314. package/src/utils/IconGenerator.ts +166 -0
  315. package/src/utils/index.ts +16 -0
@@ -7,6 +7,7 @@ import { getAccountShape, mergeSubAccounts, getSubAccountShape, getSubAccounts,
7
7
  import BigNumber from "bignumber.js";
8
8
  import { createFixtureAccount } from "../../bridge/bridge.fixture";
9
9
  import { txsToOps } from "../../bridge/logic";
10
+ import { getEnv } from "@ledgerhq/live-env";
10
11
  jest.mock("@ledgerhq/coin-framework/account", () => {
11
12
  const originalModule = jest.requireActual("@ledgerhq/coin-framework/account");
12
13
  const partialMockedModule = Object.keys(originalModule).reduce((pre, methodName) => {
@@ -36,7 +37,7 @@ describe("getAccountShape", () => {
36
37
  });
37
38
  it("account with xpub", async () => {
38
39
  const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
39
- balance: BigInt(0),
40
+ balance: BigNumber(0),
40
41
  transactions: [],
41
42
  blockHeight: 0,
42
43
  }));
@@ -45,7 +46,7 @@ describe("getAccountShape", () => {
45
46
  }));
46
47
  const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
47
48
  jest.mocked(mergeOps).mockReturnValue([]);
48
- jest.mocked(txsToOps).mockReturnValue([[], []]);
49
+ jest.mocked(txsToOps).mockReturnValue([[], [], []]);
49
50
  const account = await getAccountShape({
50
51
  id: "1",
51
52
  address: "address",
@@ -64,8 +65,8 @@ describe("getAccountShape", () => {
64
65
  freshAddress: "address",
65
66
  freshAddressPath: "",
66
67
  used: true,
67
- balance: BigInt(10),
68
- spendableBalance: BigInt(10),
68
+ balance: BigNumber(10),
69
+ spendableBalance: BigNumber(10),
69
70
  creationDate: new Date(),
70
71
  blockHeight: 0,
71
72
  currency: getCryptoCurrencyById("aptos"),
@@ -83,7 +84,7 @@ describe("getAccountShape", () => {
83
84
  });
84
85
  it("account without xpub", async () => {
85
86
  const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
86
- balance: BigInt(0),
87
+ balance: BigNumber(0),
87
88
  transactions: [],
88
89
  blockHeight: 0,
89
90
  }));
@@ -92,7 +93,7 @@ describe("getAccountShape", () => {
92
93
  }));
93
94
  const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
94
95
  jest.mocked(mergeOps).mockReturnValue([]);
95
- jest.mocked(txsToOps).mockReturnValue([[], []]);
96
+ jest.mocked(txsToOps).mockReturnValue([[], [], []]);
96
97
  const account = await getAccountShape({
97
98
  id: "1",
98
99
  address: "address",
@@ -110,8 +111,8 @@ describe("getAccountShape", () => {
110
111
  freshAddress: "address",
111
112
  freshAddressPath: "",
112
113
  used: true,
113
- balance: BigInt(10),
114
- spendableBalance: BigInt(10),
114
+ balance: BigNumber(10),
115
+ spendableBalance: BigNumber(10),
115
116
  creationDate: new Date(),
116
117
  blockHeight: 0,
117
118
  currency: getCryptoCurrencyById("aptos"),
@@ -129,7 +130,7 @@ describe("getAccountShape", () => {
129
130
  });
130
131
  it("without initialAccount", async () => {
131
132
  const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
132
- balance: BigInt(0),
133
+ balance: BigNumber(0),
133
134
  transactions: [],
134
135
  blockHeight: 0,
135
136
  }));
@@ -138,7 +139,7 @@ describe("getAccountShape", () => {
138
139
  }));
139
140
  const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
140
141
  jest.mocked(mergeOps).mockReturnValue([]);
141
- jest.mocked(txsToOps).mockReturnValue([[], []]);
142
+ jest.mocked(txsToOps).mockReturnValue([[], [], []]);
142
143
  const account = await getAccountShape({
143
144
  id: "1",
144
145
  address: "address",
@@ -155,7 +156,7 @@ describe("getAccountShape", () => {
155
156
  });
156
157
  it("initialAccount with operations", async () => {
157
158
  const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
158
- balance: BigInt(0),
159
+ balance: BigNumber(0),
159
160
  transactions: [],
160
161
  blockHeight: 0,
161
162
  }));
@@ -164,7 +165,7 @@ describe("getAccountShape", () => {
164
165
  }));
165
166
  const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
166
167
  jest.mocked(mergeOps).mockReturnValue([]);
167
- jest.mocked(txsToOps).mockReturnValue([[], []]);
168
+ jest.mocked(txsToOps).mockReturnValue([[], [], []]);
168
169
  const account = await getAccountShape({
169
170
  id: "1",
170
171
  address: "address",
@@ -182,8 +183,8 @@ describe("getAccountShape", () => {
182
183
  freshAddress: "address",
183
184
  freshAddressPath: "",
184
185
  used: true,
185
- balance: BigInt(10),
186
- spendableBalance: BigInt(10),
186
+ balance: BigNumber(10),
187
+ spendableBalance: BigNumber(10),
187
188
  creationDate: new Date(),
188
189
  blockHeight: 0,
189
190
  currency: getCryptoCurrencyById("aptos"),
@@ -201,7 +202,7 @@ describe("getAccountShape", () => {
201
202
  });
202
203
  it("initialAccount with operations with extra", async () => {
203
204
  const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
204
- balance: BigInt(0),
205
+ balance: BigNumber(0),
205
206
  transactions: [],
206
207
  blockHeight: 0,
207
208
  }));
@@ -210,7 +211,7 @@ describe("getAccountShape", () => {
210
211
  }));
211
212
  const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
212
213
  jest.mocked(mergeOps).mockReturnValue([]);
213
- jest.mocked(txsToOps).mockReturnValue([[], []]);
214
+ jest.mocked(txsToOps).mockReturnValue([[], [], []]);
214
215
  const account = await getAccountShape({
215
216
  id: "1",
216
217
  address: "address",
@@ -228,8 +229,8 @@ describe("getAccountShape", () => {
228
229
  freshAddress: "address",
229
230
  freshAddressPath: "",
230
231
  used: true,
231
- balance: BigInt(10),
232
- spendableBalance: BigInt(10),
232
+ balance: BigNumber(10),
233
+ spendableBalance: BigNumber(10),
233
234
  creationDate: new Date(),
234
235
  blockHeight: 0,
235
236
  currency: getCryptoCurrencyById("aptos"),
@@ -247,7 +248,7 @@ describe("getAccountShape", () => {
247
248
  });
248
249
  it("get publicKey from rest", async () => {
249
250
  const mockGetAccountInfo = jest.fn().mockImplementation(async () => ({
250
- balance: BigInt(0),
251
+ balance: BigNumber(0),
251
252
  transactions: [],
252
253
  blockHeight: 0,
253
254
  }));
@@ -256,7 +257,7 @@ describe("getAccountShape", () => {
256
257
  }));
257
258
  const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
258
259
  jest.mocked(mergeOps).mockReturnValue([]);
259
- jest.mocked(txsToOps).mockReturnValue([[], []]);
260
+ jest.mocked(txsToOps).mockReturnValue([[], [], []]);
260
261
  const account = await getAccountShape({
261
262
  id: "1",
262
263
  address: "address",
@@ -274,8 +275,8 @@ describe("getAccountShape", () => {
274
275
  freshAddress: "address",
275
276
  freshAddressPath: "",
276
277
  used: true,
277
- balance: BigInt(10),
278
- spendableBalance: BigInt(10),
278
+ balance: BigNumber(10),
279
+ spendableBalance: BigNumber(10),
279
280
  creationDate: new Date(),
280
281
  blockHeight: 0,
281
282
  currency: getCryptoCurrencyById("aptos"),
@@ -866,8 +867,9 @@ describe("getAccountShape", () => {
866
867
  hasFailed: false,
867
868
  },
868
869
  ];
870
+ const stakingOperations = [];
869
871
  jest.mocked(mergeOps).mockReturnValue(operations);
870
- jest.mocked(txsToOps).mockReturnValue([operations, tokenOperations]);
872
+ jest.mocked(txsToOps).mockReturnValue([operations, tokenOperations, stakingOperations]);
871
873
  const info = {
872
874
  currency: {
873
875
  type: "CryptoCurrency",
@@ -1478,4 +1480,742 @@ describe("getSubAccounts", () => {
1478
1480
  ]);
1479
1481
  });
1480
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
+ });
1481
2221
  //# sourceMappingURL=synchronisation.test.js.map