@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
@@ -4,8 +4,8 @@ import type { GetAccountShape } from "@ledgerhq/coin-framework/bridge/jsHelpers"
4
4
  import { mergeOps } from "@ledgerhq/coin-framework/bridge/jsHelpers";
5
5
  import { AptosAPI } from "../network";
6
6
  import { txsToOps } from "./logic";
7
- import type { AptosAccount } from "../types";
8
- import { Account, Operation, TokenAccount } from "@ledgerhq/types-live";
7
+ import type { AptosAccount, AptosStakingPosition } from "../types";
8
+ import { Operation, TokenAccount } from "@ledgerhq/types-live";
9
9
  import { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
10
10
  import {
11
11
  decodeTokenAccountId,
@@ -14,6 +14,7 @@ import {
14
14
  } from "@ledgerhq/coin-framework/account/index";
15
15
  import { AccountShapeInfo } from "@ledgerhq/coin-framework/bridge/jsHelpers";
16
16
  import BigNumber from "bignumber.js";
17
+ import { getEnv } from "@ledgerhq/live-env";
17
18
 
18
19
  /**
19
20
  * List of properties of a sub account that can be updated when 2 "identical" accounts are found
@@ -29,7 +30,7 @@ const updatableSubAccountProperties: { name: string; isOps: boolean }[] = [
29
30
  * In charge of smartly merging sub accounts while maintaining references as much as possible
30
31
  */
31
32
  export const mergeSubAccounts = (
32
- initialAccount: Account | undefined,
33
+ initialAccount: AptosAccount | undefined,
33
34
  newSubAccounts: TokenAccount[],
34
35
  ): Array<TokenAccount> => {
35
36
  const oldSubAccounts: Array<TokenAccount> | undefined = initialAccount?.subAccounts;
@@ -127,7 +128,7 @@ export const getSubAccountShape = async (
127
128
  * Getting all token related operations in order to provide TokenAccounts
128
129
  */
129
130
  export const getSubAccounts = async (
130
- infos: AccountShapeInfo<Account>,
131
+ infos: AccountShapeInfo<AptosAccount>,
131
132
  address: string,
132
133
  accountId: string,
133
134
  lastTokenOperations: Operation[],
@@ -158,7 +159,9 @@ export const getSubAccounts = async (
158
159
  return Promise.all(subAccountsPromises);
159
160
  };
160
161
 
161
- export const getAccountShape: GetAccountShape = async info => {
162
+ export const getAccountShape: GetAccountShape<AptosAccount> = async (
163
+ info: AccountShapeInfo<AptosAccount>,
164
+ ) => {
162
165
  const { address, initialAccount, currency, derivationMode, rest } = info;
163
166
 
164
167
  const publicKey =
@@ -183,11 +186,11 @@ export const getAccountShape: GetAccountShape = async info => {
183
186
  const aptosClient = new AptosAPI(currency.id);
184
187
  const { balance, transactions, blockHeight } = await aptosClient.getAccountInfo(address);
185
188
 
186
- const [newOperations, tokenOperations]: [Operation[], Operation[]] = txsToOps(
187
- info,
188
- accountId,
189
- transactions,
190
- );
189
+ const [newOperations, tokenOperations, stakingOperations]: [
190
+ Operation[],
191
+ Operation[],
192
+ Operation[],
193
+ ] = txsToOps(info, accountId, transactions);
191
194
  const operations = mergeOps(oldOperations, newOperations);
192
195
 
193
196
  const newSubAccounts = await getSubAccounts(info, address, accountId, tokenOperations);
@@ -196,24 +199,78 @@ export const getAccountShape: GetAccountShape = async info => {
196
199
  ? newSubAccounts
197
200
  : mergeSubAccounts(initialAccount, newSubAccounts);
198
201
 
199
- operations.forEach(op => {
202
+ operations?.forEach(op => {
200
203
  const subOperations = inferSubOperations(op.hash, subAccounts);
201
204
  op.subOperations =
202
205
  subOperations.length === 1 ? subOperations : subOperations.filter(op => !!op.blockHash);
203
206
  });
204
207
 
208
+ const stakingPositions: AptosStakingPosition[] = [];
209
+ let activeBalance = BigNumber(0);
210
+ let inactiveBalance = BigNumber(0);
211
+ let pendingInactiveBalance = BigNumber(0);
212
+
213
+ if (getEnv("APTOS_ENABLE_STAKING") === true) {
214
+ const stakingPoolAddresses = getStakingPoolAddresses(stakingOperations);
215
+ for (const stakingPoolAddress of stakingPoolAddresses) {
216
+ const [active_string, inactive_string, pending_inactive_string] =
217
+ await aptosClient.getDelegatorBalanceInPool(stakingPoolAddress, address);
218
+
219
+ const active = BigNumber(active_string);
220
+ const inactive = BigNumber(inactive_string);
221
+ const pendingInactive = BigNumber(pending_inactive_string);
222
+
223
+ stakingPositions.push({
224
+ active,
225
+ inactive,
226
+ pendingInactive,
227
+ validatorId: stakingPoolAddress,
228
+ });
229
+
230
+ activeBalance = activeBalance.plus(active);
231
+ inactiveBalance = inactiveBalance.plus(inactive);
232
+ pendingInactiveBalance = pendingInactiveBalance.plus(pendingInactive);
233
+ }
234
+ }
235
+
236
+ const aptosResources = {
237
+ activeBalance,
238
+ inactiveBalance,
239
+ pendingInactiveBalance,
240
+ stakingPositions,
241
+ };
242
+
205
243
  const shape: Partial<AptosAccount> = {
206
244
  type: "Account",
207
245
  id: accountId,
208
246
  xpub,
209
- balance: balance,
247
+ balance: balance
248
+ .plus(aptosResources.activeBalance)
249
+ .plus(aptosResources.pendingInactiveBalance)
250
+ .plus(aptosResources.inactiveBalance),
210
251
  spendableBalance: balance,
211
252
  operations,
212
253
  operationsCount: operations.length,
213
254
  blockHeight,
214
255
  lastSyncDate: new Date(),
215
256
  subAccounts,
257
+ aptosResources,
216
258
  };
217
259
 
218
260
  return shape;
219
261
  };
262
+
263
+ export const getStakingPoolAddresses = (stakingOperations: Operation[]): string[] => {
264
+ const stakingPoolsAddrs: string[] = [];
265
+
266
+ for (const op of stakingOperations) {
267
+ if (!op.recipients.length) continue;
268
+
269
+ const poolAddress = op.recipients[0];
270
+ if (poolAddress === "0x1") continue;
271
+
272
+ if (!stakingPoolsAddrs.includes(poolAddress)) stakingPoolsAddrs.push(poolAddress);
273
+ }
274
+
275
+ return stakingPoolsAddrs;
276
+ };
package/src/constants.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import type { MoveStructId } from "@aptos-labs/ts-sdk";
2
2
  import BigNumber from "bignumber.js";
3
3
 
4
- export const ESTIMATE_GAS_MUL = new BigNumber(1.0); // define buffer for gas estimation change here, if needed
4
+ export const ESTIMATE_GAS_MUL = new BigNumber(1.1); // define buffer for gas estimation change here, if needed
5
+ export const ESTIMATE_GAS_MUL_FOR_STAKING = new BigNumber(3); // gas multiplier for staking operations
5
6
 
6
7
  export const LOAD_LIMIT = 10;
7
8
 
@@ -13,6 +14,10 @@ export enum TX_STATUS {
13
14
 
14
15
  export const WRITE_RESOURCE = "write_resource";
15
16
 
17
+ export const APTOS_NON_HARDENED_DERIVATION_PATH_REGEX = /^44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/;
18
+ export const APTOS_NON_HARDENED_DERIVATION_PATH = "44'/637'/0'/0/0";
19
+ export const APTOS_HARDENED_DERIVATION_PATH = "44'/637'/0'/0'/0'";
20
+
16
21
  export const COIN_TRANSFER_TYPES: MoveStructId[] = [
17
22
  "0x1::aptos_account::transfer",
18
23
  "0x1::aptos_account::transfer_coins",
@@ -28,9 +33,45 @@ export const BATCH_TRANSFER_TYPES: MoveStructId[] = [
28
33
 
29
34
  export const DELEGATION_POOL_TYPES: MoveStructId[] = [
30
35
  "0x1::delegation_pool::add_stake",
36
+ "0x1::delegation_pool::reactivate_stake",
37
+ "0x1::delegation_pool::unlock",
31
38
  "0x1::delegation_pool::withdraw",
32
39
  ];
33
40
 
41
+ export const ADD_STAKE_EVENTS = [
42
+ "0x1::stake::AddStake",
43
+ "0x1::stake::AddStakeEvent",
44
+ "0x1::delegation_pool::AddStake",
45
+ "0x1::delegation_pool::AddStakeEvent",
46
+ ];
47
+
48
+ export const REACTIVATE_STAKE_EVENTS = [
49
+ "0x1::stake::ReactivateStake",
50
+ "0x1::stake::ReactivateStakeEvent",
51
+ "0x1::delegation_pool::ReactivateStake",
52
+ "0x1::delegation_pool::ReactivateStakeEvent",
53
+ ];
54
+
55
+ export const UNLOCK_STAKE_EVENTS = [
56
+ "0x1::stake::UnlockStake",
57
+ "0x1::stake::UnlockStakeEvent",
58
+ "0x1::delegation_pool::UnlockStake",
59
+ "0x1::delegation_pool::UnlockStakeEvent",
60
+ ];
61
+
62
+ export const WITHDRAW_STAKE_EVENTS = [
63
+ "0x1::stake::WithdrawStake",
64
+ "0x1::stake::WithdrawStakeEvent",
65
+ "0x1::delegation_pool::WithdrawStake",
66
+ "0x1::delegation_pool::WithdrawStakeEvent",
67
+ ];
68
+
69
+ export const STAKING_EVENTS = ADD_STAKE_EVENTS.concat(
70
+ REACTIVATE_STAKE_EVENTS,
71
+ UNLOCK_STAKE_EVENTS,
72
+ WITHDRAW_STAKE_EVENTS,
73
+ );
74
+
34
75
  export const APTOS_ASSET_ID: MoveStructId = "0x1::aptos_coin::AptosCoin";
35
76
 
36
77
  export const APTOS_COIN_CHANGE: MoveStructId = `0x1::coin::CoinStore<${APTOS_ASSET_ID}>`;
@@ -39,12 +80,33 @@ export const APTOS_FUNGIBLE_STORE: MoveStructId = "0x1::fungible_asset::Fungible
39
80
 
40
81
  export const APTOS_OBJECT_CORE: MoveStructId = "0x1::object::ObjectCore";
41
82
 
42
- export enum DIRECTION {
83
+ export enum OP_TYPE {
43
84
  IN = "IN",
44
85
  OUT = "OUT",
86
+ STAKE = "STAKE",
87
+ UNSTAKE = "UNSTAKE",
88
+ WITHDRAW = "WITHDRAW",
45
89
  UNKNOWN = "UNKNOWN",
46
90
  }
47
91
 
92
+ export const SUPPORTED_TOKEN_TYPES = ["coin", "fungible_asset"];
93
+
94
+ export const STAKING_TX_MODES = ["stake", "unstake", "restake", "withdraw"];
95
+
96
+ export const APTOS_PRECISION = 8;
97
+ export const APTOS_MINIMUM_RESTAKE = BigNumber(1);
98
+ export const APTOS_MINIMUM_RESTAKE_IN_OCTAS = APTOS_MINIMUM_RESTAKE.shiftedBy(APTOS_PRECISION);
99
+ export const APTOS_DELEGATION_RESERVE = BigNumber(0.05);
100
+ export const APTOS_DELEGATION_RESERVE_IN_OCTAS =
101
+ APTOS_DELEGATION_RESERVE.shiftedBy(APTOS_PRECISION);
102
+ export const MIN_COINS_ON_SHARES_POOL = BigNumber(11);
103
+ export const MIN_COINS_ON_SHARES_POOL_IN_OCTAS =
104
+ MIN_COINS_ON_SHARES_POOL.shiftedBy(APTOS_PRECISION);
105
+ export const MIN_AMOUNT_TO_UNSTAKE = BigNumber(10);
106
+ export const MIN_AMOUNT_TO_UNSTAKE_IN_OCTAS = MIN_AMOUNT_TO_UNSTAKE.shiftedBy(APTOS_PRECISION);
107
+
108
+ export const APTOS_EXPLORER_ACCOUNT_URL = "https://explorer.aptoslabs.com/account";
109
+
48
110
  export enum TOKEN_TYPE {
49
111
  COIN = "coin",
50
112
  FUNGIBLE_ASSET = "fungible_asset",
package/src/index.ts CHANGED
@@ -1,3 +1 @@
1
- export * from "./types";
2
-
3
1
  export { createBridges } from "./bridge/index";
@@ -5,7 +5,6 @@ import { APTOS_ASSET_ID, TOKEN_TYPE } from "../constants";
5
5
  import type { AptosAPI } from "../network";
6
6
  import { normalizeTransactionOptions } from "./normalizeTransactionOptions";
7
7
  import type { Transaction } from "../types";
8
- import type BigNumber from "bignumber.js";
9
8
 
10
9
  const buildTransaction = async (
11
10
  account: Account,
@@ -20,10 +19,9 @@ const buildTransaction = async (
20
19
  const payloadTokenType = (subAccount?.token?.tokenType as TOKEN_TYPE) ?? tokenType;
21
20
 
22
21
  const txPayload = getPayload({
23
- amount: transaction.amount,
24
- recipient: transaction.recipient,
25
- contractAddress: payloadContracAddress,
22
+ transaction,
26
23
  tokenType: payloadTokenType,
24
+ contractAddress: payloadContracAddress,
27
25
  });
28
26
 
29
27
  const txOptions = normalizeTransactionOptions(transaction.options);
@@ -33,33 +31,60 @@ const buildTransaction = async (
33
31
  return tx;
34
32
  };
35
33
 
36
- const getPayload = (args: {
37
- amount: BigNumber;
38
- recipient: string;
39
- contractAddress?: string | undefined;
40
- tokenType?: string;
34
+ const getPayload = ({
35
+ transaction,
36
+ tokenType,
37
+ contractAddress,
38
+ }: {
39
+ transaction: Transaction;
40
+ tokenType: TOKEN_TYPE;
41
+ contractAddress: string | undefined;
41
42
  }): InputEntryFunctionData => {
42
- if (args.tokenType !== undefined && !isTokenType(args.tokenType)) {
43
- throw new Error(`Token type ${args.tokenType} not supported`);
44
- }
43
+ const { amount, recipient, mode } = transaction;
45
44
 
46
- if (args.tokenType === TOKEN_TYPE.FUNGIBLE_ASSET) {
47
- return {
48
- function: "0x1::primary_fungible_store::transfer",
49
- typeArguments: ["0x1::fungible_asset::Metadata"],
50
- functionArguments: [args.contractAddress, args.recipient, args.amount.toString()],
51
- };
52
- }
45
+ switch (mode) {
46
+ case "stake":
47
+ return {
48
+ function: "0x1::delegation_pool::add_stake",
49
+ typeArguments: [],
50
+ functionArguments: [recipient, amount.toString()],
51
+ };
52
+ case "unstake":
53
+ return {
54
+ function: "0x1::delegation_pool::unlock",
55
+ typeArguments: [],
56
+ functionArguments: [recipient, amount.toString()],
57
+ };
58
+ case "restake":
59
+ return {
60
+ function: "0x1::delegation_pool::reactivate_stake",
61
+ typeArguments: [],
62
+ functionArguments: [recipient, amount.toString()],
63
+ };
64
+ case "withdraw":
65
+ return {
66
+ function: "0x1::delegation_pool::withdraw",
67
+ typeArguments: [],
68
+ functionArguments: [recipient, amount.toString()],
69
+ };
70
+ case "send":
71
+ if (tokenType !== undefined && !isTokenType(tokenType)) {
72
+ throw new Error(`Token type ${tokenType} not supported`);
73
+ }
53
74
 
54
- let address = args.contractAddress ?? "";
55
- if (address === "") {
56
- address = APTOS_ASSET_ID;
75
+ if (tokenType === TOKEN_TYPE.FUNGIBLE_ASSET) {
76
+ return {
77
+ function: "0x1::primary_fungible_store::transfer",
78
+ typeArguments: ["0x1::fungible_asset::Metadata"],
79
+ functionArguments: [contractAddress, recipient, amount.toString()],
80
+ };
81
+ }
57
82
  }
58
83
 
59
84
  return {
60
85
  function: "0x1::aptos_account::transfer_coins",
61
- typeArguments: [address],
62
- functionArguments: [args.recipient, args.amount.toString()],
86
+ typeArguments: [contractAddress ?? APTOS_ASSET_ID],
87
+ functionArguments: [recipient, amount.toString()],
63
88
  };
64
89
  };
65
90
 
@@ -1,5 +1,15 @@
1
1
  import BigNumber from "bignumber.js";
2
- import { APTOS_ASSET_ID, APTOS_FUNGIBLE_STORE, APTOS_OBJECT_CORE } from "../constants";
2
+ import {
3
+ ADD_STAKE_EVENTS,
4
+ APTOS_ASSET_ID,
5
+ APTOS_FUNGIBLE_STORE,
6
+ APTOS_OBJECT_CORE,
7
+ OP_TYPE,
8
+ REACTIVATE_STAKE_EVENTS,
9
+ STAKING_EVENTS,
10
+ UNLOCK_STAKE_EVENTS,
11
+ WITHDRAW_STAKE_EVENTS,
12
+ } from "../constants";
3
13
  import {
4
14
  AptosFungibleoObjectCoreResourceData,
5
15
  AptosFungibleStoreResourceData,
@@ -94,48 +104,88 @@ export function getEventFAAddress(
94
104
  export function getCoinAndAmounts(
95
105
  tx: AptosTransaction,
96
106
  address: string,
97
- ): { coin_id: string | null; amount_in: BigNumber; amount_out: BigNumber } {
107
+ ): {
108
+ coin_id: string | null;
109
+ amount_in: BigNumber;
110
+ amount_out: BigNumber;
111
+ type: OP_TYPE;
112
+ } {
98
113
  let coin_id: string | null = null;
99
114
  let amount_in = BigNumber(0);
100
115
  let amount_out = BigNumber(0);
101
-
102
- // collect all events related to the address and calculate the overall amounts
103
- tx.events.forEach(event => {
104
- switch (event.type) {
105
- case "0x1::coin::WithdrawEvent":
106
- if (compareAddress(event.guid.account_address, address)) {
107
- coin_id = getResourceAddress(tx, event, "withdraw_events", getEventCoinAddress);
108
- amount_out = amount_out.plus(event.data.amount);
109
- }
110
- break;
111
- case "0x1::coin::DepositEvent":
112
- if (compareAddress(event.guid.account_address, address)) {
113
- coin_id = getResourceAddress(tx, event, "deposit_events", getEventCoinAddress);
114
- amount_in = amount_in.plus(event.data.amount);
115
- }
116
- break;
117
- case "0x1::fungible_asset::Withdraw":
118
- if (checkFAOwner(tx, event, address)) {
119
- coin_id = getResourceAddress(tx, event, "withdraw_events", getEventFAAddress);
120
- amount_out = amount_out.plus(event.data.amount);
121
- }
122
- break;
123
- case "0x1::fungible_asset::Deposit":
124
- if (checkFAOwner(tx, event, address)) {
125
- coin_id = getResourceAddress(tx, event, "deposit_events", getEventFAAddress);
126
- amount_in = amount_in.plus(event.data.amount);
127
- }
128
- break;
129
- case "0x1::transaction_fee::FeeStatement":
130
- if (tx.sender === address) {
131
- coin_id ??= APTOS_ASSET_ID;
132
- if (coin_id === APTOS_ASSET_ID) {
133
- const fees = BigNumber(tx.gas_unit_price).times(BigNumber(tx.gas_used));
134
- amount_out = amount_out.plus(fees);
135
- }
116
+ let type = OP_TYPE.UNKNOWN;
117
+
118
+ // Check if it is a staking transaction
119
+ const stakingTx = !!tx.events.find(event => STAKING_EVENTS.includes(event.type));
120
+
121
+ // Collect all events related to the address and calculate the overall amounts
122
+ if (stakingTx) {
123
+ tx.events.forEach(event => {
124
+ if (ADD_STAKE_EVENTS.includes(event.type) && tx.sender === address && amount_out.isZero()) {
125
+ coin_id = APTOS_ASSET_ID;
126
+ type = OP_TYPE.STAKE;
127
+ amount_out = amount_out.plus(event.data.amount_added || event.data.amount);
128
+ } else if (
129
+ REACTIVATE_STAKE_EVENTS.includes(event.type) &&
130
+ tx.sender === address &&
131
+ amount_out.isZero()
132
+ ) {
133
+ coin_id = APTOS_ASSET_ID;
134
+ type = OP_TYPE.STAKE;
135
+ amount_out = amount_out.plus(event.data.amount_reactivated || event.data.amount);
136
+ } else if (
137
+ UNLOCK_STAKE_EVENTS.includes(event.type) &&
138
+ tx.sender === address &&
139
+ amount_in.isZero()
140
+ ) {
141
+ coin_id = APTOS_ASSET_ID;
142
+ type = OP_TYPE.UNSTAKE;
143
+ amount_in = amount_in.plus(event.data.amount_unlocked || event.data.amount);
144
+ } else if (
145
+ WITHDRAW_STAKE_EVENTS.includes(event.type) &&
146
+ tx.sender === address &&
147
+ amount_in.isZero()
148
+ ) {
149
+ coin_id = APTOS_ASSET_ID;
150
+ type = OP_TYPE.WITHDRAW;
151
+ amount_in = amount_in.plus(event.data.amount_withdrawn || event.data.amount);
152
+ }
153
+ });
154
+ } else {
155
+ tx.events.forEach(event => {
156
+ if (
157
+ event.type === "0x1::coin::WithdrawEvent" &&
158
+ compareAddress(event.guid.account_address, address)
159
+ ) {
160
+ coin_id = getResourceAddress(tx, event, "withdraw_events", getEventCoinAddress);
161
+ amount_out = amount_out.plus(event.data.amount);
162
+ } else if (
163
+ event.type === "0x1::coin::DepositEvent" &&
164
+ compareAddress(event.guid.account_address, address)
165
+ ) {
166
+ coin_id = getResourceAddress(tx, event, "deposit_events", getEventCoinAddress);
167
+ amount_in = amount_in.plus(event.data.amount);
168
+ } else if (
169
+ event.type === "0x1::fungible_asset::Withdraw" &&
170
+ checkFAOwner(tx, event, address)
171
+ ) {
172
+ coin_id = getResourceAddress(tx, event, "withdraw_events", getEventFAAddress);
173
+ amount_out = amount_out.plus(event.data.amount);
174
+ } else if (
175
+ event.type === "0x1::fungible_asset::Deposit" &&
176
+ checkFAOwner(tx, event, address)
177
+ ) {
178
+ coin_id = getResourceAddress(tx, event, "deposit_events", getEventFAAddress);
179
+ amount_in = amount_in.plus(event.data.amount);
180
+ } else if (event.type === "0x1::transaction_fee::FeeStatement" && tx.sender === address) {
181
+ coin_id ??= APTOS_ASSET_ID;
182
+ if (coin_id === APTOS_ASSET_ID) {
183
+ const fees = BigNumber(tx.gas_unit_price).times(BigNumber(tx.gas_used));
184
+ amount_out = amount_out.plus(fees);
136
185
  }
137
- break;
138
- }
139
- });
140
- return { coin_id, amount_in, amount_out };
186
+ }
187
+ });
188
+ }
189
+
190
+ return { coin_id, amount_in, amount_out, type };
141
191
  }
@@ -0,0 +1,105 @@
1
+ import BigNumber from "bignumber.js";
2
+ import { Unit } from "@ledgerhq/types-cryptoassets";
3
+ import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies/formatCurrencyUnit";
4
+ import {
5
+ AptosAccount,
6
+ AptosMappedStakingPosition,
7
+ AptosStakingPosition,
8
+ AptosValidator,
9
+ } from "../types";
10
+ import { MIN_COINS_ON_SHARES_POOL_IN_OCTAS } from "../constants";
11
+ import { getMaxSendBalance } from "../bridge/logic";
12
+
13
+ export const mapStakingPositions = (
14
+ stakingPositions: AptosStakingPosition[],
15
+ validators: AptosValidator[],
16
+ unit: Unit,
17
+ ): AptosMappedStakingPosition[] => {
18
+ return stakingPositions.map(sp => {
19
+ const rank = validators.findIndex(v => v.address === sp.validatorId);
20
+ const validator = validators[rank] ?? sp;
21
+ const formatConfig = {
22
+ disableRounding: false,
23
+ alwaysShowSign: false,
24
+ showCode: true,
25
+ };
26
+
27
+ return {
28
+ ...sp,
29
+ formattedAmount: formatCurrencyUnit(unit, sp.active, formatConfig),
30
+ formattedPending: formatCurrencyUnit(unit, sp.pendingInactive, formatConfig),
31
+ formattedAvailable: formatCurrencyUnit(unit, sp.inactive, formatConfig),
32
+ rank,
33
+ validator,
34
+ };
35
+ });
36
+ };
37
+
38
+ export const canStake = (account: AptosAccount): boolean => {
39
+ return getMaxSendBalance(account) > MIN_COINS_ON_SHARES_POOL_IN_OCTAS;
40
+ };
41
+
42
+ export const canUnstake = (
43
+ stakingPosition: AptosMappedStakingPosition | AptosStakingPosition,
44
+ ): boolean => {
45
+ return stakingPosition.active.gt(0);
46
+ };
47
+
48
+ export const canWithdraw = (
49
+ stakingPosition: AptosMappedStakingPosition | AptosStakingPosition,
50
+ ): boolean => {
51
+ return stakingPosition.inactive.gt(0);
52
+ };
53
+
54
+ export const canRestake = (
55
+ stakingPosition: AptosMappedStakingPosition | AptosStakingPosition,
56
+ ): boolean => {
57
+ return stakingPosition.pendingInactive.gt(0);
58
+ };
59
+
60
+ export const getStakingPosition = (account: AptosAccount, validatorAddress: string) =>
61
+ (account.aptosResources?.stakingPositions ?? []).find(
62
+ stakingPosition => stakingPosition.validatorId === validatorAddress,
63
+ );
64
+
65
+ export const getDelegationOpMaxAmount = (
66
+ account: AptosAccount,
67
+ validatorAddress: string,
68
+ mode: string,
69
+ ): BigNumber => {
70
+ let maxAmount: BigNumber | undefined;
71
+
72
+ const stakingPosition = getStakingPosition(account, validatorAddress);
73
+
74
+ switch (mode) {
75
+ case "unstake":
76
+ maxAmount = stakingPosition?.active;
77
+ break;
78
+ case "withdraw":
79
+ maxAmount = stakingPosition?.inactive;
80
+ break;
81
+ case "restake":
82
+ maxAmount = stakingPosition?.pendingInactive;
83
+ }
84
+
85
+ if (maxAmount === undefined || maxAmount.lt(0)) {
86
+ return new BigNumber(0);
87
+ }
88
+
89
+ return maxAmount;
90
+ };
91
+
92
+ export const formatUnlockTime = (epochSecs: string): string => {
93
+ const unlockTime = parseInt(epochSecs, 10) * 1000; // Convert to ms
94
+ const now = Date.now();
95
+ const diffMs = unlockTime - now;
96
+
97
+ if (diffMs <= 0) return "Unlocked";
98
+
99
+ const totalMinutes = Math.floor(diffMs / (1000 * 60));
100
+ const days = Math.floor(totalMinutes / (60 * 24));
101
+ const hours = Math.floor((totalMinutes % (60 * 24)) / 60);
102
+ const minutes = totalMinutes % 60;
103
+
104
+ return `${days}d ${hours}h ${minutes}m`;
105
+ };
@@ -3,7 +3,7 @@ import { Operation } from "@ledgerhq/coin-framework/api/types";
3
3
  import { AptosAsset } from "../types/assets";
4
4
  import BigNumber from "bignumber.js";
5
5
  import { EntryFunctionPayloadResponse, InputEntryFunctionData } from "@aptos-labs/ts-sdk";
6
- import { APTOS_ASSET_ID, DIRECTION } from "../constants";
6
+ import { APTOS_ASSET_ID, OP_TYPE } from "../constants";
7
7
  import { compareAddress, getCoinAndAmounts } from "./getCoinAndAmounts";
8
8
  import { calculateAmount } from "./calculateAmount";
9
9
  import { processRecipients } from "./processRecipients";
@@ -18,12 +18,12 @@ export const convertFunctionPayloadResponseToInputEntryFunctionData = (
18
18
  functionArguments: payload.arguments,
19
19
  });
20
20
 
21
- const detectType = (address: string, tx: AptosTransaction, value: BigNumber): DIRECTION => {
22
- let type = compareAddress(tx.sender, address) ? DIRECTION.OUT : DIRECTION.IN;
21
+ const detectType = (address: string, tx: AptosTransaction, value: BigNumber): OP_TYPE => {
22
+ let type = compareAddress(tx.sender, address) ? OP_TYPE.OUT : OP_TYPE.IN;
23
23
 
24
24
  if (!value) {
25
25
  // skip transaction that result no Aptos change
26
- type = DIRECTION.UNKNOWN;
26
+ type = OP_TYPE.UNKNOWN;
27
27
  }
28
28
 
29
29
  return type;
@@ -88,7 +88,7 @@ export function transactionsToOperations(
88
88
 
89
89
  processRecipients(payload, address, op, function_address);
90
90
 
91
- if (op.type !== DIRECTION.UNKNOWN && coin_id !== null) {
91
+ if (op.type !== OP_TYPE.UNKNOWN && coin_id !== null) {
92
92
  if (coin_id === APTOS_ASSET_ID) {
93
93
  acc.push(op);
94
94
  return acc;