@ledgerhq/coin-aptos 3.5.0-nightly.7 → 3.6.0-nightly.20251107095716

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 (50) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +33 -52
  3. package/lib/bridge/logic.d.ts.map +1 -1
  4. package/lib/bridge/logic.js +2 -2
  5. package/lib/bridge/logic.js.map +1 -1
  6. package/lib/bridge/signOperation.js +1 -1
  7. package/lib/bridge/signOperation.js.map +1 -1
  8. package/lib/constants.d.ts +1 -0
  9. package/lib/constants.d.ts.map +1 -1
  10. package/lib/constants.js +2 -1
  11. package/lib/constants.js.map +1 -1
  12. package/lib/network/client.d.ts +1 -0
  13. package/lib/network/client.d.ts.map +1 -1
  14. package/lib/network/client.js +34 -14
  15. package/lib/network/client.js.map +1 -1
  16. package/lib/network/graphql/queries.d.ts.map +1 -1
  17. package/lib/network/graphql/queries.js +8 -3
  18. package/lib/network/graphql/queries.js.map +1 -1
  19. package/lib/network/graphql/types.d.ts +4 -0
  20. package/lib/network/graphql/types.d.ts.map +1 -1
  21. package/lib-es/bridge/logic.d.ts.map +1 -1
  22. package/lib-es/bridge/logic.js +3 -3
  23. package/lib-es/bridge/logic.js.map +1 -1
  24. package/lib-es/bridge/signOperation.js +1 -1
  25. package/lib-es/bridge/signOperation.js.map +1 -1
  26. package/lib-es/constants.d.ts +1 -0
  27. package/lib-es/constants.d.ts.map +1 -1
  28. package/lib-es/constants.js +1 -0
  29. package/lib-es/constants.js.map +1 -1
  30. package/lib-es/network/client.d.ts +1 -0
  31. package/lib-es/network/client.d.ts.map +1 -1
  32. package/lib-es/network/client.js +34 -14
  33. package/lib-es/network/client.js.map +1 -1
  34. package/lib-es/network/graphql/queries.d.ts.map +1 -1
  35. package/lib-es/network/graphql/queries.js +8 -3
  36. package/lib-es/network/graphql/queries.js.map +1 -1
  37. package/lib-es/network/graphql/types.d.ts +4 -0
  38. package/lib-es/network/graphql/types.d.ts.map +1 -1
  39. package/package.json +11 -11
  40. package/src/__tests__/bridge/logic.test.ts +7 -7
  41. package/src/__tests__/bridge/signOperation.test.ts +4 -4
  42. package/src/__tests__/bridge/synchronisation.test.ts +18 -18
  43. package/src/__tests__/logic/processRecipients.unit.test.ts +1 -1
  44. package/src/api/index.ts +1 -1
  45. package/src/bridge/logic.ts +9 -3
  46. package/src/bridge/signOperation.ts +1 -1
  47. package/src/constants.ts +1 -0
  48. package/src/network/client.ts +42 -17
  49. package/src/network/graphql/queries.ts +8 -3
  50. package/src/network/graphql/types.ts +5 -0
@@ -41,6 +41,7 @@ import { GetAccountTransactionsData, GetAccountTransactionsDataGt } from "./grap
41
41
  import type {
42
42
  GetAccountTransactionsDataQuery,
43
43
  GetAccountTransactionsDataGtQueryVariables,
44
+ TransactionVersion,
44
45
  } from "./graphql/types";
45
46
  import {
46
47
  BlockInfo,
@@ -297,31 +298,55 @@ export class AptosAPI {
297
298
  return [newOperations, ""];
298
299
  }
299
300
 
300
- private async fetchTransactions(address: string, gt?: string) {
301
- if (!address) {
302
- return [];
303
- }
301
+ private async getAllTransactions(address: string, gt?: string): Promise<TransactionVersion[]> {
302
+ let allTransactions: TransactionVersion[] = [];
303
+ let offset = 0;
304
304
 
305
305
  let query = GetAccountTransactionsData;
306
306
  if (gt) {
307
307
  query = GetAccountTransactionsDataGt;
308
308
  }
309
309
 
310
- const queryResponse = await this.apolloClient.query<
311
- GetAccountTransactionsDataQuery,
312
- GetAccountTransactionsDataGtQueryVariables
313
- >({
314
- query,
315
- variables: {
316
- address,
317
- limit: 1000,
318
- gt,
319
- },
320
- fetchPolicy: "network-only",
321
- });
310
+ const condition = true;
311
+
312
+ while (condition) {
313
+ try {
314
+ const queryResponse = await this.apolloClient.query<
315
+ GetAccountTransactionsDataQuery,
316
+ GetAccountTransactionsDataGtQueryVariables
317
+ >({
318
+ query,
319
+ variables: {
320
+ address,
321
+ limit: 100,
322
+ gt,
323
+ offset,
324
+ },
325
+ fetchPolicy: "network-only",
326
+ });
327
+ offset += 100;
328
+
329
+ allTransactions = allTransactions.concat(queryResponse.data.account_transactions);
330
+
331
+ if (queryResponse.data.account_transactions.length < 100) {
332
+ break;
333
+ }
334
+ } catch (error: any) {
335
+ throw new Error(error);
336
+ }
337
+ }
338
+
339
+ return allTransactions;
340
+ }
341
+
342
+ private async fetchTransactions(address: string, gt?: string) {
343
+ if (!address) {
344
+ return [];
345
+ }
322
346
 
347
+ const transactions = await this.getAllTransactions(address, gt);
323
348
  return Promise.all(
324
- queryResponse.data.account_transactions
349
+ transactions
325
350
  .slice()
326
351
  .sort((a, b) => b.transaction_version - a.transaction_version)
327
352
  .map(({ transaction_version }) => {
@@ -1,8 +1,12 @@
1
1
  import { gql } from "@apollo/client";
2
2
 
3
3
  export const GetAccountTransactionsData = gql`
4
- query GetAccountTransactionsData($address: String, $limit: Int) {
5
- account_transactions(where: { account_address: { _eq: $address } }, limit: $limit) {
4
+ query GetAccountTransactionsData($address: String, $limit: Int, $offset: Int) {
5
+ account_transactions(
6
+ where: { account_address: { _eq: $address } }
7
+ limit: $limit
8
+ offset: $offset
9
+ ) {
6
10
  transaction_version
7
11
  __typename
8
12
  }
@@ -10,10 +14,11 @@ export const GetAccountTransactionsData = gql`
10
14
  `;
11
15
 
12
16
  export const GetAccountTransactionsDataGt = gql`
13
- query GetAccountTransactionsDataGt($address: String, $limit: Int, $gt: bigint) {
17
+ query GetAccountTransactionsDataGt($address: String, $limit: Int, $gt: bigint, $offset: Int) {
14
18
  account_transactions(
15
19
  where: { account_address: { _eq: $address }, transaction_version: { _gt: $gt } }
16
20
  limit: $limit
21
+ offset: $offset
17
22
  ) {
18
23
  transaction_version
19
24
  __typename
@@ -24,6 +24,7 @@ export type GetAccountTransactionsDataQuery = {
24
24
  export type GetAccountTransactionsDataGtQueryVariables = Exact<{
25
25
  address?: InputMaybe<Scalars["String"]>;
26
26
  limit?: InputMaybe<Scalars["Int"]>;
27
+ offset?: InputMaybe<Scalars["Int"]>;
27
28
  gt?: InputMaybe<Scalars["bigint"]>;
28
29
  }>;
29
30
 
@@ -82,3 +83,7 @@ export interface CurrentDelegatorBalance {
82
83
  current_pool_balance: CurrentPoolBalance;
83
84
  staking_pool_metadata: StakingPoolMetadata;
84
85
  }
86
+
87
+ export type TransactionVersion = {
88
+ transaction_version: number;
89
+ };