@ledgerhq/coin-aptos 2.0.0-nightly.5 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.unimportedrc.json +18 -6
  3. package/CHANGELOG.md +152 -34
  4. package/jest.config.js +2 -1
  5. package/jest.integ.config.js +8 -0
  6. package/lib/__tests__/api/index.integ.test.d.ts +2 -0
  7. package/lib/__tests__/api/index.integ.test.d.ts.map +1 -0
  8. package/lib/__tests__/api/index.integ.test.js +52 -0
  9. package/lib/__tests__/api/index.integ.test.js.map +1 -0
  10. package/lib/__tests__/api/index.test.js +48 -404
  11. package/lib/__tests__/api/index.test.js.map +1 -1
  12. package/lib/__tests__/bridge/broadcast.test.js +5 -5
  13. package/lib/__tests__/bridge/broadcast.test.js.map +1 -1
  14. package/lib/__tests__/bridge/buildTransaction.test.js +60 -5
  15. package/lib/__tests__/bridge/buildTransaction.test.js.map +1 -1
  16. package/lib/__tests__/bridge/createTransaction.test.js +1 -1
  17. package/lib/__tests__/bridge/createTransaction.test.js.map +1 -1
  18. package/lib/__tests__/bridge/getFeesForTransaction.test.js +115 -14
  19. package/lib/__tests__/bridge/getFeesForTransaction.test.js.map +1 -1
  20. package/lib/__tests__/bridge/getTransactionStatus.test.js +175 -37
  21. package/lib/__tests__/bridge/getTransactionStatus.test.js.map +1 -1
  22. package/lib/__tests__/bridge/logic.test.js +889 -115
  23. package/lib/__tests__/bridge/logic.test.js.map +1 -1
  24. package/lib/__tests__/bridge/prepareTransaction.test.js +3 -3
  25. package/lib/__tests__/bridge/prepareTransaction.test.js.map +1 -1
  26. package/lib/__tests__/bridge/signOperation.test.js +131 -4
  27. package/lib/__tests__/bridge/signOperation.test.js.map +1 -1
  28. package/lib/__tests__/bridge/synchronisation.test.js +1215 -68
  29. package/lib/__tests__/bridge/synchronisation.test.js.map +1 -1
  30. package/lib/__tests__/network/client.test.d.ts +2 -0
  31. package/lib/__tests__/network/client.test.d.ts.map +1 -0
  32. package/lib/__tests__/network/client.test.js +520 -0
  33. package/lib/__tests__/network/client.test.js.map +1 -0
  34. package/lib/api/index.d.ts +4 -30
  35. package/lib/api/index.d.ts.map +1 -1
  36. package/lib/api/index.js +24 -170
  37. package/lib/api/index.js.map +1 -1
  38. package/lib/bridge/bridge.fixture.d.ts +2 -0
  39. package/lib/bridge/bridge.fixture.d.ts.map +1 -1
  40. package/lib/bridge/bridge.fixture.js +85 -13
  41. package/lib/bridge/bridge.fixture.js.map +1 -1
  42. package/lib/bridge/broadcast.d.ts +3 -2
  43. package/lib/bridge/broadcast.d.ts.map +1 -1
  44. package/lib/bridge/broadcast.js +4 -3
  45. package/lib/bridge/broadcast.js.map +1 -1
  46. package/lib/bridge/buildTransaction.d.ts +1 -1
  47. package/lib/bridge/buildTransaction.d.ts.map +1 -1
  48. package/lib/bridge/buildTransaction.js +29 -3
  49. package/lib/bridge/buildTransaction.js.map +1 -1
  50. package/lib/bridge/createTransaction.js +3 -3
  51. package/lib/bridge/createTransaction.js.map +1 -1
  52. package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -1
  53. package/lib/bridge/estimateMaxSpendable.js +6 -5
  54. package/lib/bridge/estimateMaxSpendable.js.map +1 -1
  55. package/lib/bridge/getFeesForTransaction.d.ts +1 -1
  56. package/lib/bridge/getFeesForTransaction.d.ts.map +1 -1
  57. package/lib/bridge/getFeesForTransaction.js +19 -13
  58. package/lib/bridge/getFeesForTransaction.js.map +1 -1
  59. package/lib/bridge/getTransactionStatus.d.ts.map +1 -1
  60. package/lib/bridge/getTransactionStatus.js +28 -14
  61. package/lib/bridge/getTransactionStatus.js.map +1 -1
  62. package/lib/bridge/index.d.ts +1 -1
  63. package/lib/bridge/index.d.ts.map +1 -1
  64. package/lib/bridge/logic.d.ts +13 -11
  65. package/lib/bridge/logic.d.ts.map +1 -1
  66. package/lib/bridge/logic.js +152 -57
  67. package/lib/bridge/logic.js.map +1 -1
  68. package/lib/bridge/prepareTransaction.d.ts.map +1 -1
  69. package/lib/bridge/prepareTransaction.js +5 -4
  70. package/lib/bridge/prepareTransaction.js.map +1 -1
  71. package/lib/bridge/signOperation.d.ts.map +1 -1
  72. package/lib/bridge/signOperation.js +20 -6
  73. package/lib/bridge/signOperation.js.map +1 -1
  74. package/lib/bridge/synchronisation.d.ts +15 -0
  75. package/lib/bridge/synchronisation.d.ts.map +1 -1
  76. package/lib/bridge/synchronisation.js +129 -6
  77. package/lib/bridge/synchronisation.js.map +1 -1
  78. package/lib/config.d.ts +13 -0
  79. package/lib/config.d.ts.map +1 -0
  80. package/lib/config.js +9 -0
  81. package/lib/config.js.map +1 -0
  82. package/lib/constants.d.ts +9 -1
  83. package/lib/constants.d.ts.map +1 -1
  84. package/lib/constants.js +13 -2
  85. package/lib/constants.js.map +1 -1
  86. package/lib/network/client.d.ts +36 -0
  87. package/lib/network/client.d.ts.map +1 -0
  88. package/lib/network/client.js +247 -0
  89. package/lib/network/client.js.map +1 -0
  90. package/lib/network/graphql/queries.d.ts.map +1 -0
  91. package/lib/{api → network}/graphql/queries.js +6 -6
  92. package/lib/network/graphql/queries.js.map +1 -0
  93. package/lib/{api → network}/graphql/types.d.ts +9 -9
  94. package/lib/network/graphql/types.d.ts.map +1 -0
  95. package/lib/{api → network}/graphql/types.js.map +1 -1
  96. package/lib/network/index.d.ts +2 -1
  97. package/lib/network/index.d.ts.map +1 -1
  98. package/lib/network/index.js +15 -0
  99. package/lib/network/index.js.map +1 -1
  100. package/lib/test/bot-specs.d.ts.map +1 -1
  101. package/lib/test/bot-specs.js +40 -1
  102. package/lib/test/bot-specs.js.map +1 -1
  103. package/lib/test/bridgeDatasetTest.d.ts.map +1 -1
  104. package/lib/test/bridgeDatasetTest.js +44 -62
  105. package/lib/test/bridgeDatasetTest.js.map +1 -1
  106. package/lib/test/speculos-deviceActions.d.ts +1 -0
  107. package/lib/test/speculos-deviceActions.d.ts.map +1 -1
  108. package/lib/test/speculos-deviceActions.js +37 -5
  109. package/lib/test/speculos-deviceActions.js.map +1 -1
  110. package/lib/types/assets.d.ts +12 -0
  111. package/lib/types/assets.d.ts.map +1 -0
  112. package/lib/types/assets.js +3 -0
  113. package/lib/types/assets.js.map +1 -0
  114. package/lib/types/index.d.ts +18 -7
  115. package/lib/types/index.d.ts.map +1 -1
  116. package/lib-es/__tests__/api/index.integ.test.d.ts +2 -0
  117. package/lib-es/__tests__/api/index.integ.test.d.ts.map +1 -0
  118. package/lib-es/__tests__/api/index.integ.test.js +50 -0
  119. package/lib-es/__tests__/api/index.integ.test.js.map +1 -0
  120. package/lib-es/__tests__/api/index.test.js +52 -408
  121. package/lib-es/__tests__/api/index.test.js.map +1 -1
  122. package/lib-es/__tests__/bridge/broadcast.test.js +2 -2
  123. package/lib-es/__tests__/bridge/broadcast.test.js.map +1 -1
  124. package/lib-es/__tests__/bridge/buildTransaction.test.js +60 -5
  125. package/lib-es/__tests__/bridge/buildTransaction.test.js.map +1 -1
  126. package/lib-es/__tests__/bridge/createTransaction.test.js +1 -1
  127. package/lib-es/__tests__/bridge/createTransaction.test.js.map +1 -1
  128. package/lib-es/__tests__/bridge/getFeesForTransaction.test.js +112 -11
  129. package/lib-es/__tests__/bridge/getFeesForTransaction.test.js.map +1 -1
  130. package/lib-es/__tests__/bridge/getTransactionStatus.test.js +177 -39
  131. package/lib-es/__tests__/bridge/getTransactionStatus.test.js.map +1 -1
  132. package/lib-es/__tests__/bridge/logic.test.js +891 -117
  133. package/lib-es/__tests__/bridge/logic.test.js.map +1 -1
  134. package/lib-es/__tests__/bridge/prepareTransaction.test.js +2 -2
  135. package/lib-es/__tests__/bridge/prepareTransaction.test.js.map +1 -1
  136. package/lib-es/__tests__/bridge/signOperation.test.js +131 -4
  137. package/lib-es/__tests__/bridge/signOperation.test.js.map +1 -1
  138. package/lib-es/__tests__/bridge/synchronisation.test.js +1213 -69
  139. package/lib-es/__tests__/bridge/synchronisation.test.js.map +1 -1
  140. package/lib-es/__tests__/network/client.test.d.ts +2 -0
  141. package/lib-es/__tests__/network/client.test.d.ts.map +1 -0
  142. package/lib-es/__tests__/network/client.test.js +515 -0
  143. package/lib-es/__tests__/network/client.test.js.map +1 -0
  144. package/lib-es/api/index.d.ts +4 -30
  145. package/lib-es/api/index.d.ts.map +1 -1
  146. package/lib-es/api/index.js +22 -168
  147. package/lib-es/api/index.js.map +1 -1
  148. package/lib-es/bridge/bridge.fixture.d.ts +2 -0
  149. package/lib-es/bridge/bridge.fixture.d.ts.map +1 -1
  150. package/lib-es/bridge/bridge.fixture.js +82 -12
  151. package/lib-es/bridge/bridge.fixture.js.map +1 -1
  152. package/lib-es/bridge/broadcast.d.ts +3 -2
  153. package/lib-es/bridge/broadcast.d.ts.map +1 -1
  154. package/lib-es/bridge/broadcast.js +4 -3
  155. package/lib-es/bridge/broadcast.js.map +1 -1
  156. package/lib-es/bridge/buildTransaction.d.ts +1 -1
  157. package/lib-es/bridge/buildTransaction.d.ts.map +1 -1
  158. package/lib-es/bridge/buildTransaction.js +30 -4
  159. package/lib-es/bridge/buildTransaction.js.map +1 -1
  160. package/lib-es/bridge/createTransaction.js +1 -1
  161. package/lib-es/bridge/createTransaction.js.map +1 -1
  162. package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -1
  163. package/lib-es/bridge/estimateMaxSpendable.js +4 -3
  164. package/lib-es/bridge/estimateMaxSpendable.js.map +1 -1
  165. package/lib-es/bridge/getFeesForTransaction.d.ts +1 -1
  166. package/lib-es/bridge/getFeesForTransaction.d.ts.map +1 -1
  167. package/lib-es/bridge/getFeesForTransaction.js +14 -8
  168. package/lib-es/bridge/getFeesForTransaction.js.map +1 -1
  169. package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -1
  170. package/lib-es/bridge/getTransactionStatus.js +28 -14
  171. package/lib-es/bridge/getTransactionStatus.js.map +1 -1
  172. package/lib-es/bridge/index.d.ts +1 -1
  173. package/lib-es/bridge/index.d.ts.map +1 -1
  174. package/lib-es/bridge/logic.d.ts +13 -11
  175. package/lib-es/bridge/logic.d.ts.map +1 -1
  176. package/lib-es/bridge/logic.js +146 -55
  177. package/lib-es/bridge/logic.js.map +1 -1
  178. package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
  179. package/lib-es/bridge/prepareTransaction.js +5 -4
  180. package/lib-es/bridge/prepareTransaction.js.map +1 -1
  181. package/lib-es/bridge/signOperation.d.ts.map +1 -1
  182. package/lib-es/bridge/signOperation.js +18 -4
  183. package/lib-es/bridge/signOperation.js.map +1 -1
  184. package/lib-es/bridge/synchronisation.d.ts +15 -0
  185. package/lib-es/bridge/synchronisation.d.ts.map +1 -1
  186. package/lib-es/bridge/synchronisation.js +124 -4
  187. package/lib-es/bridge/synchronisation.js.map +1 -1
  188. package/lib-es/config.d.ts +13 -0
  189. package/lib-es/config.d.ts.map +1 -0
  190. package/lib-es/config.js +4 -0
  191. package/lib-es/config.js.map +1 -0
  192. package/lib-es/constants.d.ts +9 -1
  193. package/lib-es/constants.d.ts.map +1 -1
  194. package/lib-es/constants.js +9 -1
  195. package/lib-es/constants.js.map +1 -1
  196. package/lib-es/network/client.d.ts +36 -0
  197. package/lib-es/network/client.d.ts.map +1 -0
  198. package/lib-es/network/client.js +240 -0
  199. package/lib-es/network/client.js.map +1 -0
  200. package/lib-es/network/graphql/queries.d.ts.map +1 -0
  201. package/lib-es/{api → network}/graphql/queries.js +6 -6
  202. package/lib-es/network/graphql/queries.js.map +1 -0
  203. package/lib-es/{api → network}/graphql/types.d.ts +9 -9
  204. package/lib-es/network/graphql/types.d.ts.map +1 -0
  205. package/lib-es/{api → network}/graphql/types.js.map +1 -1
  206. package/lib-es/network/index.d.ts +2 -1
  207. package/lib-es/network/index.d.ts.map +1 -1
  208. package/lib-es/network/index.js +1 -0
  209. package/lib-es/network/index.js.map +1 -1
  210. package/lib-es/test/bot-specs.d.ts.map +1 -1
  211. package/lib-es/test/bot-specs.js +41 -2
  212. package/lib-es/test/bot-specs.js.map +1 -1
  213. package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -1
  214. package/lib-es/test/bridgeDatasetTest.js +44 -59
  215. package/lib-es/test/bridgeDatasetTest.js.map +1 -1
  216. package/lib-es/test/speculos-deviceActions.d.ts +1 -0
  217. package/lib-es/test/speculos-deviceActions.d.ts.map +1 -1
  218. package/lib-es/test/speculos-deviceActions.js +36 -4
  219. package/lib-es/test/speculos-deviceActions.js.map +1 -1
  220. package/lib-es/types/assets.d.ts +12 -0
  221. package/lib-es/types/assets.d.ts.map +1 -0
  222. package/lib-es/types/assets.js +2 -0
  223. package/lib-es/types/assets.js.map +1 -0
  224. package/lib-es/types/index.d.ts +18 -7
  225. package/lib-es/types/index.d.ts.map +1 -1
  226. package/package.json +12 -9
  227. package/src/__tests__/api/index.integ.test.ts +58 -0
  228. package/src/__tests__/api/index.test.ts +60 -477
  229. package/src/__tests__/bridge/broadcast.test.ts +2 -2
  230. package/src/__tests__/bridge/buildTransaction.test.ts +87 -5
  231. package/src/__tests__/bridge/createTransaction.test.ts +1 -1
  232. package/src/__tests__/bridge/getFeesForTransaction.test.ts +146 -11
  233. package/src/__tests__/bridge/getTransactionStatus.test.ts +217 -38
  234. package/src/__tests__/bridge/logic.test.ts +922 -118
  235. package/src/__tests__/bridge/prepareTransaction.test.ts +2 -2
  236. package/src/__tests__/bridge/signOperation.test.ts +147 -5
  237. package/src/__tests__/bridge/synchronisation.test.ts +1265 -71
  238. package/src/__tests__/network/client.test.ts +618 -0
  239. package/src/api/index.ts +31 -223
  240. package/src/bridge/bridge.fixture.ts +91 -12
  241. package/src/bridge/broadcast.ts +7 -7
  242. package/src/bridge/buildTransaction.ts +40 -7
  243. package/src/bridge/createTransaction.ts +1 -1
  244. package/src/bridge/estimateMaxSpendable.ts +4 -3
  245. package/src/bridge/getFeesForTransaction.ts +16 -10
  246. package/src/bridge/getTransactionStatus.ts +35 -13
  247. package/src/bridge/index.ts +1 -1
  248. package/src/bridge/logic.ts +202 -67
  249. package/src/bridge/prepareTransaction.ts +7 -4
  250. package/src/bridge/signOperation.ts +20 -4
  251. package/src/bridge/synchronisation.ts +171 -4
  252. package/src/config.ts +19 -0
  253. package/src/constants.ts +17 -1
  254. package/src/network/client.ts +315 -0
  255. package/src/{api → network}/graphql/queries.ts +6 -6
  256. package/src/{api → network}/graphql/types.ts +9 -9
  257. package/src/network/index.ts +2 -1
  258. package/src/test/bot-specs.ts +63 -3
  259. package/src/test/bridgeDatasetTest.ts +46 -59
  260. package/src/test/speculos-deviceActions.ts +40 -4
  261. package/src/types/assets.ts +15 -0
  262. package/src/types/index.ts +15 -1
  263. package/lib/api/graphql/queries.d.ts.map +0 -1
  264. package/lib/api/graphql/queries.js.map +0 -1
  265. package/lib/api/graphql/types.d.ts.map +0 -1
  266. package/lib-es/api/graphql/queries.d.ts.map +0 -1
  267. package/lib-es/api/graphql/queries.js.map +0 -1
  268. package/lib-es/api/graphql/types.d.ts.map +0 -1
  269. /package/lib/{api → network}/graphql/queries.d.ts +0 -0
  270. /package/lib/{api → network}/graphql/types.js +0 -0
  271. /package/lib-es/{api → network}/graphql/queries.d.ts +0 -0
  272. /package/lib-es/{api → network}/graphql/types.js +0 -0
package/src/constants.ts CHANGED
@@ -1,4 +1,9 @@
1
1
  import { MoveStructId } from "@aptos-labs/ts-sdk";
2
+ import BigNumber from "bignumber.js";
3
+
4
+ export const DEFAULT_GAS = new BigNumber(200);
5
+ export const DEFAULT_GAS_PRICE = new BigNumber(100);
6
+ export const ESTIMATE_GAS_MUL = new BigNumber(1.0); // define buffer for gas estimation change here, if needed
2
7
 
3
8
  export const LOAD_LIMIT = 10;
4
9
 
@@ -10,25 +15,36 @@ export enum TX_STATUS {
10
15
 
11
16
  export const WRITE_RESOURCE = "write_resource";
12
17
 
13
- export const TRANSFER_TYPES: MoveStructId[] = [
18
+ export const COIN_TRANSFER_TYPES: MoveStructId[] = [
14
19
  "0x1::aptos_account::transfer",
15
20
  "0x1::aptos_account::transfer_coins",
16
21
  "0x1::coin::transfer",
17
22
  ];
23
+
24
+ export const FA_TRANSFER_TYPES: MoveStructId[] = ["0x1::primary_fungible_store::transfer"];
25
+
18
26
  export const BATCH_TRANSFER_TYPES: MoveStructId[] = [
19
27
  "0x1::aptos_account::batch_transfer",
20
28
  "0x1::aptos_account::batch_transfer_coins",
21
29
  ];
30
+
22
31
  export const DELEGATION_POOL_TYPES: MoveStructId[] = [
23
32
  "0x1::delegation_pool::add_stake",
24
33
  "0x1::delegation_pool::withdraw",
25
34
  ];
26
35
 
27
36
  export const APTOS_ASSET_ID: MoveStructId = "0x1::aptos_coin::AptosCoin";
37
+
28
38
  export const APTOS_COIN_CHANGE: MoveStructId = `0x1::coin::CoinStore<${APTOS_ASSET_ID}>`;
29
39
 
40
+ export const APTOS_FUNGIBLE_STORE: MoveStructId = "0x1::fungible_asset::FungibleStore";
41
+
42
+ export const APTOS_OBJECT_CORE: MoveStructId = "0x1::object::ObjectCore";
43
+
30
44
  export enum DIRECTION {
31
45
  IN = "IN",
32
46
  OUT = "OUT",
33
47
  UNKNOWN = "UNKNOWN",
34
48
  }
49
+
50
+ export const SUPPORTED_TOKEN_TYPES = ["coin", "fungible_asset"];
@@ -0,0 +1,315 @@
1
+ import { ApolloClient, InMemoryCache } from "@apollo/client";
2
+
3
+ import {
4
+ AccountData,
5
+ Aptos,
6
+ AptosApiType,
7
+ AptosConfig,
8
+ Ed25519PublicKey,
9
+ GasEstimation,
10
+ InputEntryFunctionData,
11
+ InputGenerateTransactionOptions,
12
+ MimeType,
13
+ post,
14
+ RawTransaction,
15
+ SimpleTransaction,
16
+ TransactionResponse,
17
+ UserTransactionResponse,
18
+ PostRequestOptions,
19
+ Block,
20
+ AptosSettings,
21
+ MoveFunctionId,
22
+ } from "@aptos-labs/ts-sdk";
23
+ import { getEnv } from "@ledgerhq/live-env";
24
+ import network from "@ledgerhq/live-network";
25
+ import BigNumber from "bignumber.js";
26
+ import isUndefined from "lodash/isUndefined";
27
+ import { APTOS_ASSET_ID, DEFAULT_GAS, DEFAULT_GAS_PRICE, ESTIMATE_GAS_MUL } from "../constants";
28
+ import { isTestnet } from "../bridge/logic";
29
+ import type { AptosTransaction, TransactionOptions } from "../types";
30
+ import { GetAccountTransactionsData, GetAccountTransactionsDataGt } from "./graphql/queries";
31
+ import {
32
+ GetAccountTransactionsDataQuery,
33
+ GetAccountTransactionsDataGtQueryVariables,
34
+ } from "./graphql/types";
35
+ import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
36
+ import { BlockInfo, FeeEstimation, TransactionIntent } from "@ledgerhq/coin-framework/api/types";
37
+ import { AptosAsset, AptosExtra, AptosFeeParameters, AptosSender } from "../types/assets";
38
+ import { log } from "@ledgerhq/logs";
39
+
40
+ const getApiEndpoint = (currencyId: string) =>
41
+ isTestnet(currencyId) ? getEnv("APTOS_TESTNET_API_ENDPOINT") : getEnv("APTOS_API_ENDPOINT");
42
+ const getIndexerEndpoint = (currencyId: string) =>
43
+ isTestnet(currencyId)
44
+ ? getEnv("APTOS_TESTNET_INDEXER_ENDPOINT")
45
+ : getEnv("APTOS_INDEXER_ENDPOINT");
46
+
47
+ export class AptosAPI {
48
+ private readonly aptosConfig: AptosConfig;
49
+ private readonly aptosClient: Aptos;
50
+ private readonly apolloClient: ApolloClient<object>;
51
+
52
+ constructor(currencyIdOrSettings: AptosSettings | string) {
53
+ if (typeof currencyIdOrSettings === "string") {
54
+ this.aptosConfig = new AptosConfig({
55
+ fullnode: getApiEndpoint(currencyIdOrSettings),
56
+ indexer: getIndexerEndpoint(currencyIdOrSettings),
57
+ });
58
+ } else {
59
+ this.aptosConfig = new AptosConfig(currencyIdOrSettings);
60
+ }
61
+
62
+ this.aptosClient = new Aptos(this.aptosConfig);
63
+ this.apolloClient = new ApolloClient({
64
+ uri: this.aptosConfig.indexer ?? "",
65
+ cache: new InMemoryCache(),
66
+ headers: {
67
+ "x-client": "ledger-live",
68
+ },
69
+ });
70
+ }
71
+
72
+ async getAccount(address: string): Promise<AccountData> {
73
+ return this.aptosClient.getAccountInfo({ accountAddress: address });
74
+ }
75
+
76
+ async getAccountInfo(address: string, startAt?: string) {
77
+ const [balance, transactions, blockHeight] = await Promise.all([
78
+ this.getCoinBalance(address, APTOS_ASSET_ID),
79
+ this.fetchTransactions(address, startAt),
80
+ this.getHeight(),
81
+ ]);
82
+
83
+ return {
84
+ balance,
85
+ transactions,
86
+ blockHeight,
87
+ };
88
+ }
89
+
90
+ async estimateGasPrice(): Promise<GasEstimation> {
91
+ return this.aptosClient.getGasPriceEstimation();
92
+ }
93
+
94
+ async generateTransaction(
95
+ address: string,
96
+ payload: InputEntryFunctionData,
97
+ options: TransactionOptions,
98
+ ): Promise<RawTransaction> {
99
+ const opts: Partial<InputGenerateTransactionOptions> = {};
100
+ if (!isUndefined(options.maxGasAmount)) {
101
+ opts.maxGasAmount = Number(options.maxGasAmount);
102
+ }
103
+
104
+ if (!isUndefined(options.gasUnitPrice)) {
105
+ opts.gasUnitPrice = Number(options.gasUnitPrice);
106
+ }
107
+
108
+ try {
109
+ const { ledger_timestamp } = await this.aptosClient.getLedgerInfo();
110
+ opts.expireTimestamp = Number(Math.ceil(+ledger_timestamp / 1_000_000 + 2 * 60)); // in milliseconds
111
+ } catch {
112
+ // skip
113
+ }
114
+
115
+ return this.aptosClient.transaction.build
116
+ .simple({
117
+ sender: address,
118
+ data: payload,
119
+ options: opts,
120
+ })
121
+ .then(t => t.rawTransaction)
122
+ .catch(error => {
123
+ throw error;
124
+ });
125
+ }
126
+
127
+ async simulateTransaction(
128
+ address: Ed25519PublicKey,
129
+ tx: RawTransaction,
130
+ options = {
131
+ estimateGasUnitPrice: true,
132
+ estimateMaxGasAmount: true,
133
+ estimatePrioritizedGasUnitPrice: false,
134
+ },
135
+ ): Promise<UserTransactionResponse[]> {
136
+ return this.aptosClient.transaction.simulate.simple({
137
+ signerPublicKey: address,
138
+ transaction: { rawTransaction: tx } as SimpleTransaction,
139
+ options,
140
+ });
141
+ }
142
+
143
+ async broadcast(signature: string): Promise<string> {
144
+ const txBytes = Uint8Array.from(Buffer.from(signature, "hex"));
145
+ const pendingTx = await post<PostRequestOptions, TransactionResponse>({
146
+ contentType: MimeType.BCS_SIGNED_TRANSACTION,
147
+ aptosConfig: this.aptosClient.config,
148
+ body: txBytes,
149
+ path: "transactions",
150
+ type: AptosApiType.FULLNODE,
151
+ originMethod: "",
152
+ });
153
+ return pendingTx.data.hash;
154
+ }
155
+
156
+ async getBalance(address: string, token: TokenCurrency): Promise<BigNumber> {
157
+ if (token.tokenType === "coin") {
158
+ return await this.getCoinBalance(address, token.contractAddress);
159
+ } else {
160
+ return await this.getFABalance(address, token.contractAddress);
161
+ }
162
+ }
163
+
164
+ async getLastBlock(): Promise<BlockInfo> {
165
+ const { block_height } = await this.aptosClient.getLedgerInfo();
166
+ const block = await this.aptosClient.getBlockByHeight({ blockHeight: Number(block_height) });
167
+ return {
168
+ height: Number(block.block_height),
169
+ hash: block.block_hash,
170
+ time: new Date(Number(block.block_timestamp)),
171
+ };
172
+ }
173
+
174
+ async getCoinBalance(address: string, contract_address: string): Promise<BigNumber> {
175
+ try {
176
+ const [balanceStr] = await this.aptosClient.view<[string]>({
177
+ payload: {
178
+ function: "0x1::coin::balance",
179
+ typeArguments: [contract_address],
180
+ functionArguments: [address],
181
+ },
182
+ });
183
+ const balance = parseInt(balanceStr, 10);
184
+ return new BigNumber(balance);
185
+ } catch (error) {
186
+ log("error", "getCoinBalance", {
187
+ error,
188
+ });
189
+ return new BigNumber(0);
190
+ }
191
+ }
192
+
193
+ async getFABalance(address: string, contract_address: string): Promise<BigNumber> {
194
+ try {
195
+ const [balanceStr] = await this.aptosClient.view<[string]>({
196
+ payload: {
197
+ function: "0x1::primary_fungible_store::balance",
198
+ typeArguments: ["0x1::object::ObjectCore"],
199
+ functionArguments: [address, contract_address],
200
+ },
201
+ });
202
+ const balance = parseInt(balanceStr, 10);
203
+ return new BigNumber(balance);
204
+ } catch (error) {
205
+ log("error", "getFABalance", {
206
+ error,
207
+ });
208
+ return new BigNumber(0);
209
+ }
210
+ }
211
+
212
+ async estimateFees(
213
+ transactionIntent: TransactionIntent<AptosAsset, AptosExtra, AptosSender>,
214
+ ): Promise<FeeEstimation<AptosFeeParameters>> {
215
+ const publicKeyEd = new Ed25519PublicKey(transactionIntent.sender.xpub);
216
+ const fn: MoveFunctionId = "0x1::aptos_account::transfer_coins";
217
+
218
+ const txPayload: InputEntryFunctionData = {
219
+ function: fn,
220
+ typeArguments: [APTOS_ASSET_ID],
221
+ functionArguments: [transactionIntent.recipient, transactionIntent.amount],
222
+ };
223
+
224
+ const txOptions: TransactionOptions = {
225
+ maxGasAmount: DEFAULT_GAS.toString(),
226
+ gasUnitPrice: DEFAULT_GAS_PRICE.toString(),
227
+ };
228
+
229
+ const tx = await this.generateTransaction(
230
+ transactionIntent.sender.freshAddress,
231
+ txPayload,
232
+ txOptions,
233
+ );
234
+
235
+ const simulation = await this.simulateTransaction(publicKeyEd, tx);
236
+ const completedTx = simulation[0];
237
+
238
+ const gasLimit = new BigNumber(completedTx.gas_used).multipliedBy(ESTIMATE_GAS_MUL);
239
+ const gasPrice = new BigNumber(completedTx.gas_unit_price);
240
+
241
+ const expectedGas = gasPrice.multipliedBy(gasLimit);
242
+
243
+ return {
244
+ value: BigInt(expectedGas.toString()),
245
+ parameters: {
246
+ gasLimit: BigInt(gasLimit.toString()),
247
+ gasPrice: BigInt(gasPrice.toString()),
248
+ },
249
+ };
250
+ }
251
+
252
+ private async fetchTransactions(address: string, gt?: string) {
253
+ if (!address) {
254
+ return [];
255
+ }
256
+
257
+ let query = GetAccountTransactionsData;
258
+ if (gt) {
259
+ query = GetAccountTransactionsDataGt;
260
+ }
261
+
262
+ const queryResponse = await this.apolloClient.query<
263
+ GetAccountTransactionsDataQuery,
264
+ GetAccountTransactionsDataGtQueryVariables
265
+ >({
266
+ query,
267
+ variables: {
268
+ address,
269
+ limit: 1000,
270
+ gt,
271
+ },
272
+ fetchPolicy: "network-only",
273
+ });
274
+
275
+ return Promise.all(
276
+ queryResponse.data.account_transactions.map(({ transaction_version }) => {
277
+ return this.richItemByVersion(transaction_version);
278
+ }),
279
+ );
280
+ }
281
+
282
+ private async richItemByVersion(version: number): Promise<AptosTransaction | null> {
283
+ try {
284
+ const tx: TransactionResponse = await this.aptosClient.getTransactionByVersion({
285
+ ledgerVersion: version,
286
+ });
287
+ const block = await this.getBlock(version);
288
+ return {
289
+ ...tx,
290
+ block,
291
+ } as AptosTransaction;
292
+ } catch (error) {
293
+ log("error", "richItemByVersion", {
294
+ error,
295
+ });
296
+ return null;
297
+ }
298
+ }
299
+
300
+ private async getHeight(): Promise<number> {
301
+ const { data } = await network<Block>({
302
+ method: "GET",
303
+ url: this.aptosConfig.fullnode ?? "",
304
+ });
305
+ return parseInt(data.block_height);
306
+ }
307
+
308
+ private async getBlock(version: number) {
309
+ const block = await this.aptosClient.getBlockByVersion({ ledgerVersion: version });
310
+ return {
311
+ height: parseInt(block.block_height),
312
+ hash: block.block_hash,
313
+ };
314
+ }
315
+ }
@@ -18,8 +18,8 @@ export const GetDelegatedStakingActivities = gql`
18
18
  `;
19
19
  export const GetAccountTransactionsData = gql`
20
20
  query GetAccountTransactionsData($address: String, $limit: Int) {
21
- address_version_from_move_resources(
22
- where: { address: { _eq: $address } }
21
+ account_transactions(
22
+ where: { account_address: { _eq: $address } }
23
23
  order_by: { transaction_version: desc }
24
24
  limit: $limit
25
25
  ) {
@@ -30,8 +30,8 @@ export const GetAccountTransactionsData = gql`
30
30
  `;
31
31
  export const GetAccountTransactionsDataGt = gql`
32
32
  query GetAccountTransactionsDataGt($address: String, $limit: Int, $gt: bigint) {
33
- address_version_from_move_resources(
34
- where: { address: { _eq: $address }, transaction_version: { _gt: $gt } }
33
+ account_transactions(
34
+ where: { account_address: { _eq: $address }, transaction_version: { _gt: $gt } }
35
35
  order_by: { transaction_version: desc }
36
36
  limit: $limit
37
37
  ) {
@@ -42,8 +42,8 @@ export const GetAccountTransactionsDataGt = gql`
42
42
  `;
43
43
  export const GetAccountTransactionsDataLt = gql`
44
44
  query GetAccountTransactionsDataLt($address: String, $limit: Int, $lt: bigint) {
45
- address_version_from_move_resources(
46
- where: { address: { _eq: $address }, transaction_version: { _lt: $lt } }
45
+ account_transactions(
46
+ where: { account_address: { _eq: $address }, transaction_version: { _lt: $lt } }
47
47
  order_by: { transaction_version: desc }
48
48
  limit: $limit
49
49
  ) {
@@ -22,9 +22,9 @@ export type GetAccountTransactionsDataQueryVariables = Exact<{
22
22
 
23
23
  export type GetAccountTransactionsDataQuery = {
24
24
  __typename?: "query_root";
25
- address_version_from_move_resources: Array<{
26
- __typename: "address_version_from_move_resources";
27
- transaction_version?: any | null;
25
+ account_transactions: Array<{
26
+ __typename?: "account_transactions";
27
+ transaction_version: number;
28
28
  }>;
29
29
  };
30
30
 
@@ -36,9 +36,9 @@ export type GetAccountTransactionsDataGtQueryVariables = Exact<{
36
36
 
37
37
  export type GetAccountTransactionsDataGtQuery = {
38
38
  __typename?: "query_root";
39
- address_version_from_move_resources: Array<{
40
- __typename: "address_version_from_move_resources";
41
- transaction_version?: any | null;
39
+ account_transactions: Array<{
40
+ __typename?: "account_transactions";
41
+ transaction_version: number;
42
42
  }>;
43
43
  };
44
44
 
@@ -50,9 +50,9 @@ export type GetAccountTransactionsDataLtQueryVariables = Exact<{
50
50
 
51
51
  export type GetAccountTransactionsDataLtQuery = {
52
52
  __typename?: "query_root";
53
- address_version_from_move_resources: Array<{
54
- __typename: "address_version_from_move_resources";
55
- transaction_version?: any | null;
53
+ account_transactions: Array<{
54
+ __typename?: "account_transactions";
55
+ transaction_version: number;
56
56
  }>;
57
57
  };
58
58
 
@@ -9,10 +9,11 @@ import {
9
9
  RawTransaction,
10
10
  SimpleTransaction,
11
11
  } from "@aptos-labs/ts-sdk";
12
- import { SignerContext } from "@ledgerhq/coin-framework/lib/signer";
12
+ import { SignerContext } from "@ledgerhq/coin-framework/signer";
13
13
  import { Account } from "@ledgerhq/types-live";
14
14
  import { AptosSigner } from "../types";
15
15
  import { sha3_256 as sha3Hash } from "@noble/hashes/sha3";
16
+ export * from "./client";
16
17
 
17
18
  export async function signTransaction(
18
19
  signerContext: SignerContext<AptosSigner>,
@@ -5,8 +5,9 @@ import BigNumber from "bignumber.js";
5
5
  import type { Transaction } from "../types";
6
6
  import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
7
7
  import { genericTestDestination, pickSiblings, botTest } from "@ledgerhq/coin-framework/bot/specs";
8
- import type { AppSpec } from "@ledgerhq/coin-framework/bot/types";
9
- import { acceptTransaction } from "./speculos-deviceActions";
8
+ import type { AppSpec, TransactionTestInput } from "@ledgerhq/coin-framework/bot/types";
9
+ import { acceptTokenTransaction, acceptTransaction } from "./speculos-deviceActions";
10
+ import { Account, TokenAccount } from "@ledgerhq/types-live";
10
11
 
11
12
  const MIN_SAFE = new BigNumber(0.0001);
12
13
  const maxAccount = 6;
@@ -19,7 +20,7 @@ const aptosSpecs: AppSpec<Transaction> = {
19
20
  appName: "Aptos",
20
21
  },
21
22
  genericDeviceAction: acceptTransaction,
22
- testTimeout: 6 * 60 * 1000,
23
+ testTimeout: 2 * 60 * 1000,
23
24
  minViableAmount: MIN_SAFE,
24
25
  transactionCheck: ({ maxSpendable }) => {
25
26
  invariant(maxSpendable.gt(MIN_SAFE), "balance is too low");
@@ -84,9 +85,68 @@ const aptosSpecs: AppSpec<Transaction> = {
84
85
  );
85
86
  },
86
87
  },
88
+ {
89
+ name: "Send ~50% of token amount",
90
+ feature: "tokens",
91
+ maxRun: 1,
92
+ deviceAction: acceptTokenTransaction,
93
+ transaction: ({ account, bridge, siblings, maxSpendable }) => {
94
+ invariant(maxSpendable.gt(MIN_SAFE), "Balance is too low");
95
+
96
+ const senderTokenAcc = findTokenSubAccountWithBalance(account);
97
+ invariant(senderTokenAcc, "Sender token account with available balance not found");
98
+
99
+ const sibling = pickSiblings(siblings, maxAccount);
100
+
101
+ const recipientTokenAcc = findTokenSubAccountWithBalance(sibling);
102
+ invariant(recipientTokenAcc, "Receiver token account with available balance not found");
103
+
104
+ const amount = senderTokenAcc.spendableBalance.div(2).integerValue();
105
+ const recipient = sibling.freshAddress;
106
+ const transaction = bridge.createTransaction(account);
107
+ const subAccountId = senderTokenAcc.id;
108
+
109
+ return {
110
+ transaction,
111
+ updates: [{ subAccountId }, { recipient }, { amount }],
112
+ };
113
+ },
114
+ test: input => {
115
+ expectTokenAccountCorrectBalanceChange(input);
116
+ },
117
+ },
87
118
  ],
88
119
  };
89
120
 
121
+ function findTokenSubAccountWithBalance(account: Account) {
122
+ return account.subAccounts?.find(acc => acc.type === "TokenAccount" && acc.balance.gt(0)) as
123
+ | TokenAccount
124
+ | undefined;
125
+ }
126
+
127
+ function expectTokenAccountCorrectBalanceChange({
128
+ account,
129
+ accountBeforeTransaction,
130
+ status,
131
+ transaction,
132
+ }: TransactionTestInput<Transaction>) {
133
+ const tokenAccId = transaction.subAccountId;
134
+ if (!tokenAccId) throw new Error("Wrong subAccountId");
135
+
136
+ const tokenAccAfterTx = account.subAccounts?.find(acc => acc.id === tokenAccId);
137
+ const tokenAccBeforeTx = accountBeforeTransaction.subAccounts?.find(acc => acc.id === tokenAccId);
138
+
139
+ if (!tokenAccAfterTx || !tokenAccBeforeTx) {
140
+ throw new Error("Token sub accounts not found!");
141
+ }
142
+
143
+ botTest("Token balance decreased with operation", () =>
144
+ expect(tokenAccAfterTx.balance.toString()).toBe(
145
+ tokenAccBeforeTx.balance.minus(status.amount).toString(),
146
+ ),
147
+ );
148
+ }
149
+
90
150
  export default {
91
151
  aptosSpecs,
92
152
  };
@@ -1,6 +1,4 @@
1
1
  import { CurrenciesData, DatasetTest } from "@ledgerhq/types-live";
2
- import BigNumber from "bignumber.js";
3
- import { fromTransactionRaw } from "../bridge/transaction";
4
2
  import { Transaction } from "../types";
5
3
 
6
4
  const aptos: CurrenciesData<Transaction> = {
@@ -21,86 +19,75 @@ const aptos: CurrenciesData<Transaction> = {
21
19
  ],
22
20
  accounts: [
23
21
  {
22
+ FIXME_tests: ["balance is sum of ops"],
24
23
  raw: {
25
- id: "js:2:aptos:d1a8c6a1cdd52dd40c7ea61ee4571fb51fcae440a594c1eca18636928f1d3956:",
24
+ id: "js:2:aptos:d1a8c6a1cdd52dd40c7ea61ee4571fb51fcae440a594c1eca18636928f1d3956:aptos",
26
25
  seedIdentifier: "d6816f4f22f867b56cf9304b776f452a16d107835d73ee8a33c4ced210300583",
27
26
  used: true,
28
- derivationMode: "",
27
+ derivationMode: "aptos",
29
28
  index: 0,
30
29
  freshAddress: "0x445fa0013887abd1a0c14acdec6e48090e0ad3fed3e08202aac15ca14f3be26b",
31
30
  freshAddressPath: "44'/637'/0'/0'/0'",
32
- blockHeight: 286066372,
31
+ blockHeight: 302459501,
33
32
  creationDate: "2024-12-18T12:26:31.070Z",
34
- operationsCount: 5,
33
+ operationsCount: 6,
35
34
  operations: [],
36
35
  pendingOperations: [],
37
36
  currencyId: "aptos",
38
- lastSyncDate: "2025-02-04T14:00:46.693Z",
39
- balance: "30100",
40
- spendableBalance: "30100",
37
+ lastSyncDate: "2025-03-12T10:42:53.570Z",
38
+ balance: "19949100",
39
+ spendableBalance: "19949100",
41
40
  balanceHistoryCache: {
42
41
  HOUR: {
43
42
  balances: [
44
- 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
45
- 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
46
- 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
47
- 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
48
- 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
49
- 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
50
- 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
51
- 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
52
- 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
53
- 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
54
- 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
55
- 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
56
- 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
57
- 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
58
- 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
59
- 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
60
- 30100,
43
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
44
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
45
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
46
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
47
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
48
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
49
+ 0, 19949100, 19949100, 19949100, 19949100, 19949100, 19949100, 19949100, 19949100,
50
+ 19949100, 19949100, 19949100, 19949100, 19949100, 19949100, 19949100, 19949100,
51
+ 19949100, 19949100,
61
52
  ],
62
- latestDate: 1738677600000,
53
+ latestDate: 1741773600000,
63
54
  },
64
55
  DAY: {
65
56
  balances: [
66
- 0, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
67
- 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
68
- 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
69
- 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100, 30100,
57
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
58
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
59
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
60
+ 19949100,
70
61
  ],
71
- latestDate: 1738627200000,
72
- },
73
- WEEK: {
74
- balances: [0, 30100, 30100, 30100, 30100, 30100, 30100, 30100],
75
- latestDate: 1738454400000,
62
+ latestDate: 1741737600000,
76
63
  },
64
+ WEEK: { balances: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], latestDate: 1741478400000 },
77
65
  },
78
66
  xpub: "d1a8c6a1cdd52dd40c7ea61ee4571fb51fcae440a594c1eca18636928f1d3956",
67
+ subAccounts: [
68
+ {
69
+ type: "TokenAccountRaw",
70
+ id: "js:2:aptos:d1a8c6a1cdd52dd40c7ea61ee4571fb51fcae440a594c1eca18636928f1d3956:aptos+aptos%2Fcoin%2Fdstapt~!underscore!~0xd11107bdf0d6d7040c6c0bfbdecb6545191fdf13e8d8d259952f53e1713f61b5%3A%3Astaked~!underscore!~coin%3A%3Astakedaptos",
71
+ parentId:
72
+ "js:2:aptos:d1a8c6a1cdd52dd40c7ea61ee4571fb51fcae440a594c1eca18636928f1d3956:aptos",
73
+ tokenId:
74
+ "aptos/coin/dstapt_0xd11107bdf0d6d7040c6c0bfbdecb6545191fdf13e8d8d259952f53e1713f61b5::staked_coin::stakedaptos",
75
+ balance: "30000000",
76
+ spendableBalance: "30000000",
77
+ balanceHistoryCache: {
78
+ HOUR: { latestDate: null, balances: [] },
79
+ DAY: { latestDate: null, balances: [] },
80
+ WEEK: { latestDate: null, balances: [] },
81
+ },
82
+ creationDate: "2025-03-12T10:42:53.570Z",
83
+ operationsCount: 2,
84
+ operations: [],
85
+ pendingOperations: [],
86
+ swapHistory: [],
87
+ },
88
+ ],
79
89
  swapHistory: [],
80
90
  },
81
- transactions: [
82
- {
83
- name: "NO_NAME",
84
- transaction: fromTransactionRaw({
85
- amount: "1000",
86
- recipient: "0xd20fa44192f94ba086ab16bfdf57e43ff118ada69b4c66fa9b9a9223cbc068c1",
87
- useAllAmount: false,
88
- subAccountId: null,
89
- family: "aptos",
90
- mode: "send",
91
- fees: "900",
92
- options: '{"maxGasAmount":"9","gasUnitPrice":"100"}',
93
- errors: "{}",
94
- }),
95
- expectedStatus: () =>
96
- // you can use account and transaction for smart logic. drop the =>fn otherwise
97
- ({
98
- errors: {},
99
- warnings: {},
100
- amount: BigNumber("1000"),
101
- }),
102
- },
103
- ],
104
91
  },
105
92
  ],
106
93
  };