@atomiqlabs/chain-solana 12.0.9 → 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.
|
@@ -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
|
-
|
|
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
|
|
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
|
|
255
|
+
return 15000n + this.root.Fees.getPriorityFee(computeBudget, feeRate);
|
|
246
256
|
}
|
|
247
257
|
}
|
|
248
258
|
exports.SwapRefund = SwapRefund;
|
package/package.json
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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
|
|
321
|
+
return 15000n + this.root.Fees.getPriorityFee(computeBudget, feeRate);
|
|
311
322
|
}
|
|
312
323
|
|
|
313
324
|
}
|