@atomiqlabs/chain-solana 12.0.8 → 12.0.11

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);
@@ -150,13 +151,13 @@ class SolanaEvents extends SolanaModule_1.SolanaModule {
150
151
  let filters = startBlockheight != null ? {
151
152
  slot: { gte: startBlockheight }
152
153
  } : {};
153
- const tfaResult = await this.getTransactionsForAddress(topicKey, {
154
+ const tfaResult = await (0, Utils_1.tryWithRetries)(() => this.getTransactionsForAddress(topicKey, {
154
155
  paginationToken,
155
156
  filters: {
156
157
  ...filters,
157
158
  status: "succeeded"
158
159
  }
159
- }, "confirmed");
160
+ }, "confirmed"), undefined, undefined, abortSignal);
160
161
  if (tfaResult == null) {
161
162
  //Not supported
162
163
  return undefined;
@@ -199,7 +199,17 @@ class SwapRefund extends SolanaSwapModule_1.SolanaSwapModule {
199
199
  this.logger.debug("txsRefundWithAuthorization(): creating claim transaction, swap: " + swapData.getClaimHash() +
200
200
  " initializingAta: " + shouldInitAta + " unwrapping: " + shouldUnwrap +
201
201
  " auth expiry: " + timeout + " signature: " + signature);
202
- return [await action.tx(feeRate)];
202
+ //Push a random keypair to the TX signer such that pesky Phantom
203
+ // doesn't fuck up the instructions order!
204
+ const tx = await action.tx(feeRate);
205
+ const signer = web3_js_1.Keypair.generate();
206
+ tx.tx.instructions.find(val => val.programId.equals(this.program.program.programId)).keys.push({
207
+ pubkey: signer.publicKey,
208
+ isSigner: true,
209
+ isWritable: false
210
+ });
211
+ (tx.signers ?? (tx.signers = [])).push(signer);
212
+ return [tx];
203
213
  }
204
214
  getRefundFeeRate(swapData) {
205
215
  const accounts = [];
@@ -239,10 +249,10 @@ class SwapRefund extends SolanaSwapModule_1.SolanaSwapModule {
239
249
  */
240
250
  async getRawRefundFee(swapData, feeRate) {
241
251
  if (swapData == null)
242
- return 10000n;
252
+ return 15000n;
243
253
  feeRate = feeRate || await this.getRefundFeeRate(swapData);
244
254
  const computeBudget = swapData.payIn ? SwapRefund.CUCosts.REFUND_PAY_OUT : SwapRefund.CUCosts.REFUND;
245
- return 10000n + this.root.Fees.getPriorityFee(computeBudget, feeRate);
255
+ return 15000n + this.root.Fees.getPriorityFee(computeBudget, feeRate);
246
256
  }
247
257
  }
248
258
  exports.SwapRefund = SwapRefund;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/chain-solana",
3
- "version": "12.0.8",
3
+ "version": "12.0.11",
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
 
@@ -171,13 +172,16 @@ export class SolanaEvents extends SolanaModule {
171
172
  let filters = startBlockheight!=null ? {
172
173
  slot: {gte: startBlockheight}
173
174
  } : {};
174
- const tfaResult = await this.getTransactionsForAddress(topicKey, {
175
- paginationToken,
176
- filters: {
177
- ...filters,
178
- status: "succeeded"
179
- }
180
- }, "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
+ );
181
185
 
182
186
  if(tfaResult==null) {
183
187
  //Not supported
@@ -5,7 +5,7 @@ import {sign} from "tweetnacl";
5
5
  import {SignatureVerificationError, SwapDataVerificationError} from "@atomiqlabs/base";
6
6
  import {SolanaTx} from "../../chain/modules/SolanaTransactions";
7
7
  import {
8
- Ed25519Program,
8
+ Ed25519Program, Keypair,
9
9
  PublicKey,
10
10
  SYSVAR_INSTRUCTIONS_PUBKEY
11
11
  } from "@solana/web3.js";
@@ -265,7 +265,18 @@ export class SwapRefund extends SolanaSwapModule {
265
265
  " initializingAta: "+shouldInitAta+" unwrapping: "+shouldUnwrap+
266
266
  " auth expiry: "+timeout+" signature: "+signature);
267
267
 
268
- return [await action.tx(feeRate)];
268
+ //Push a random keypair to the TX signer such that pesky Phantom
269
+ // doesn't fuck up the instructions order!
270
+ const tx = await action.tx(feeRate);
271
+ const signer = Keypair.generate();
272
+ tx.tx.instructions.find(val => val.programId.equals(this.program.program.programId)).keys.push({
273
+ pubkey: signer.publicKey,
274
+ isSigner: true,
275
+ isWritable: false
276
+ });
277
+ (tx.signers ??= []).push(signer);
278
+
279
+ return [tx];
269
280
  }
270
281
 
271
282
  public getRefundFeeRate(swapData: SolanaSwapData): Promise<string> {
@@ -301,13 +312,13 @@ export class SwapRefund extends SolanaSwapModule {
301
312
  * Get the estimated solana transaction fee of the refund transaction
302
313
  */
303
314
  async getRawRefundFee(swapData: SolanaSwapData, feeRate?: string): Promise<bigint> {
304
- if(swapData==null) return 10000n;
315
+ if(swapData==null) return 15000n;
305
316
 
306
317
  feeRate = feeRate || await this.getRefundFeeRate(swapData);
307
318
 
308
319
  const computeBudget = swapData.payIn ? SwapRefund.CUCosts.REFUND_PAY_OUT : SwapRefund.CUCosts.REFUND;
309
320
 
310
- return 10000n + this.root.Fees.getPriorityFee(computeBudget, feeRate);
321
+ return 15000n + this.root.Fees.getPriorityFee(computeBudget, feeRate);
311
322
  }
312
323
 
313
324
  }