@atomiqlabs/chain-solana 12.0.9 → 12.0.12

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.
@@ -303,6 +303,7 @@ class SolanaSwapProgram extends SolanaProgramBase_1.SolanaProgramBase {
303
303
  latestBlockheight = tx.slot;
304
304
  events.push({ event, tx });
305
305
  }, undefined, undefined, startBlockheight);
306
+ this.logger.debug(`getHistoricalSwaps(): Found ${events.length} atomiq related events!`);
306
307
  const swapsOpened = {};
307
308
  const resultingSwaps = {};
308
309
  events.reverse();
@@ -320,7 +321,7 @@ class SolanaSwapProgram extends SolanaProgramBase_1.SolanaProgramBase {
320
321
  }
321
322
  const initIx = instructions.find(ix => ix != null && (ix.name === "offererInitializePayIn" || ix.name === "offererInitialize"));
322
323
  if (initIx == null) {
323
- this.logger.warn(`getHistoricalSwaps(): Skipping tx ${txSignature} because cannot init instruction not found!`);
324
+ this.logger.warn(`getHistoricalSwaps(): Skipping tx ${txSignature} because init instruction not found!`);
324
325
  continue;
325
326
  }
326
327
  swapsOpened[escrowHash] = {
@@ -365,6 +366,8 @@ class SolanaSwapProgram extends SolanaProgramBase_1.SolanaProgramBase {
365
366
  };
366
367
  }
367
368
  }
369
+ this.logger.debug(`getHistoricalSwaps(): Found ${Object.keys(resultingSwaps).length} settled swaps!`);
370
+ this.logger.debug(`getHistoricalSwaps(): Found ${Object.keys(swapsOpened).length} unsettled swaps!`);
368
371
  for (let escrowHash in swapsOpened) {
369
372
  const foundSwapData = swapsOpened[escrowHash];
370
373
  const isExpired = await this.isExpired(signer, foundSwapData.data);
@@ -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.9",
3
+ "version": "12.0.12",
4
4
  "description": "Solana specific base implementation",
5
5
  "main": "./dist/index.js",
6
6
  "types:": "./dist/index.d.ts",
@@ -403,6 +403,8 @@ export class SolanaSwapProgram
403
403
  events.push({event, tx});
404
404
  }, undefined, undefined, startBlockheight);
405
405
 
406
+ this.logger.debug(`getHistoricalSwaps(): Found ${events.length} atomiq related events!`);
407
+
406
408
  const swapsOpened: {[escrowHash: string]: {
407
409
  data: SolanaSwapData,
408
410
  getInitTxId: () => Promise<string>,
@@ -444,7 +446,7 @@ export class SolanaSwapProgram
444
446
  ix => ix!=null && (ix.name === "offererInitializePayIn" || ix.name === "offererInitialize")
445
447
  ) as InitInstruction;
446
448
  if(initIx == null) {
447
- this.logger.warn(`getHistoricalSwaps(): Skipping tx ${txSignature} because cannot init instruction not found!`);
449
+ this.logger.warn(`getHistoricalSwaps(): Skipping tx ${txSignature} because init instruction not found!`);
448
450
  continue;
449
451
  }
450
452
 
@@ -493,6 +495,9 @@ export class SolanaSwapProgram
493
495
  }
494
496
  }
495
497
 
498
+ this.logger.debug(`getHistoricalSwaps(): Found ${Object.keys(resultingSwaps).length} settled swaps!`);
499
+ this.logger.debug(`getHistoricalSwaps(): Found ${Object.keys(swapsOpened).length} unsettled swaps!`);
500
+
496
501
  for(let escrowHash in swapsOpened) {
497
502
  const foundSwapData = swapsOpened[escrowHash];
498
503
  const isExpired = await this.isExpired(signer, foundSwapData.data);
@@ -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
  }