@atomiqlabs/chain-solana 12.0.7 → 12.0.9

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.
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SolanaEvents = void 0;
4
4
  const SolanaModule_1 = require("../SolanaModule");
5
5
  const web3_js_1 = require("@solana/web3.js");
6
+ const Utils_1 = require("../../../utils/Utils");
6
7
  class SolanaEvents extends SolanaModule_1.SolanaModule {
7
8
  constructor() {
8
9
  super(...arguments);
@@ -39,6 +40,7 @@ class SolanaEvents extends SolanaModule_1.SolanaModule {
39
40
  * @param commitment
40
41
  */
41
42
  async getTransactionsForAddress(account, options, commitment) {
43
+ const limit = 100;
42
44
  //Try to use getPriorityFeeEstimate api of Helius
43
45
  const response = await this.connection._rpcRequest("getTransactionsForAddress", [
44
46
  account.toString(),
@@ -46,7 +48,7 @@ class SolanaEvents extends SolanaModule_1.SolanaModule {
46
48
  ...options,
47
49
  transactionDetails: "full",
48
50
  sortOrder: "desc",
49
- limit: 100,
51
+ limit,
50
52
  commitment: commitment ?? "confirmed",
51
53
  encoding: "jsonParsed",
52
54
  maxSupportedTransactionVersion: 0
@@ -139,7 +141,7 @@ class SolanaEvents extends SolanaModule_1.SolanaModule {
139
141
  }
140
142
  };
141
143
  }),
142
- paginationToken: response.result.paginationToken
144
+ paginationToken: response.result.data.length < limit ? null : response.result.paginationToken
143
145
  };
144
146
  }
145
147
  async _findInTxsTFA(topicKey, processor, abortSignal, startBlockheight) {
@@ -149,13 +151,13 @@ class SolanaEvents extends SolanaModule_1.SolanaModule {
149
151
  let filters = startBlockheight != null ? {
150
152
  slot: { gte: startBlockheight }
151
153
  } : {};
152
- const tfaResult = await this.getTransactionsForAddress(topicKey, {
154
+ const tfaResult = await (0, Utils_1.tryWithRetries)(() => this.getTransactionsForAddress(topicKey, {
153
155
  paginationToken,
154
156
  filters: {
155
157
  ...filters,
156
158
  status: "succeeded"
157
159
  }
158
- }, "confirmed");
160
+ }, "confirmed"), undefined, undefined, abortSignal);
159
161
  if (tfaResult == null) {
160
162
  //Not supported
161
163
  return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/chain-solana",
3
- "version": "12.0.7",
3
+ "version": "12.0.9",
4
4
  "description": "Solana specific base implementation",
5
5
  "main": "./dist/index.js",
6
6
  "types:": "./dist/index.d.ts",
@@ -2,6 +2,7 @@ import {SolanaModule} from "../SolanaModule";
2
2
  import {ConfirmedSignatureInfo, ParsedTransactionWithMeta, PublicKey} from "@solana/web3.js";
3
3
  import {sign} from "tweetnacl";
4
4
  import {ProgramEvent} from "../../program/modules/SolanaProgramEvents";
5
+ import {tryWithRetries} from "../../../utils/Utils";
5
6
 
6
7
  export class SolanaEvents extends SolanaModule {
7
8
 
@@ -54,6 +55,8 @@ export class SolanaEvents extends SolanaModule {
54
55
  data: ParsedTransactionWithMeta[],
55
56
  paginationToken?: string
56
57
  }> {
58
+ const limit = 100;
59
+
57
60
  //Try to use getPriorityFeeEstimate api of Helius
58
61
  const response = await (this.connection as any)._rpcRequest("getTransactionsForAddress", [
59
62
  account.toString(),
@@ -61,7 +64,7 @@ export class SolanaEvents extends SolanaModule {
61
64
  ...options,
62
65
  transactionDetails: "full",
63
66
  sortOrder: "desc",
64
- limit: 100,
67
+ limit,
65
68
  commitment: commitment ?? "confirmed",
66
69
  encoding: "jsonParsed",
67
70
  maxSupportedTransactionVersion: 0
@@ -153,7 +156,7 @@ export class SolanaEvents extends SolanaModule {
153
156
  }
154
157
  }
155
158
  }),
156
- paginationToken: response.result.paginationToken
159
+ paginationToken: response.result.data.length<limit ? null : response.result.paginationToken
157
160
  };
158
161
  }
159
162
 
@@ -169,13 +172,16 @@ export class SolanaEvents extends SolanaModule {
169
172
  let filters = startBlockheight!=null ? {
170
173
  slot: {gte: startBlockheight}
171
174
  } : {};
172
- const tfaResult = await this.getTransactionsForAddress(topicKey, {
173
- paginationToken,
174
- filters: {
175
- ...filters,
176
- status: "succeeded"
177
- }
178
- }, "confirmed");
175
+ const tfaResult = await tryWithRetries(
176
+ () => this.getTransactionsForAddress(topicKey, {
177
+ paginationToken,
178
+ filters: {
179
+ ...filters,
180
+ status: "succeeded"
181
+ }
182
+ }, "confirmed"),
183
+ undefined, undefined, abortSignal
184
+ );
179
185
 
180
186
  if(tfaResult==null) {
181
187
  //Not supported