@atomiqlabs/chain-solana 7.3.8 → 8.0.0-beta.0

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 (57) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/solana/SolanaChains.d.ts +14 -0
  4. package/dist/solana/SolanaChains.js +18 -0
  5. package/dist/solana/SolanaInitializer.d.ts +18 -0
  6. package/dist/solana/SolanaInitializer.js +59 -0
  7. package/dist/solana/base/SolanaAction.js +25 -38
  8. package/dist/solana/base/modules/SolanaBlocks.js +18 -29
  9. package/dist/solana/base/modules/SolanaEvents.js +15 -26
  10. package/dist/solana/base/modules/SolanaFees.d.ts +4 -5
  11. package/dist/solana/base/modules/SolanaFees.js +168 -182
  12. package/dist/solana/base/modules/SolanaSlots.js +16 -29
  13. package/dist/solana/base/modules/SolanaTokens.d.ts +6 -7
  14. package/dist/solana/base/modules/SolanaTokens.js +63 -84
  15. package/dist/solana/base/modules/SolanaTransactions.d.ts +2 -2
  16. package/dist/solana/base/modules/SolanaTransactions.js +143 -165
  17. package/dist/solana/btcrelay/SolanaBtcRelay.d.ts +2 -3
  18. package/dist/solana/btcrelay/SolanaBtcRelay.js +185 -221
  19. package/dist/solana/events/SolanaChainEvents.js +113 -138
  20. package/dist/solana/events/SolanaChainEventsBrowser.js +56 -65
  21. package/dist/solana/program/modules/SolanaProgramEvents.js +13 -24
  22. package/dist/solana/swaps/SolanaSwapData.d.ts +15 -11
  23. package/dist/solana/swaps/SolanaSwapData.js +29 -13
  24. package/dist/solana/swaps/SolanaSwapProgram.d.ts +40 -41
  25. package/dist/solana/swaps/SolanaSwapProgram.js +212 -221
  26. package/dist/solana/swaps/modules/SolanaDataAccount.d.ts +2 -3
  27. package/dist/solana/swaps/modules/SolanaDataAccount.js +117 -141
  28. package/dist/solana/swaps/modules/SolanaLpVault.d.ts +4 -5
  29. package/dist/solana/swaps/modules/SolanaLpVault.js +87 -110
  30. package/dist/solana/swaps/modules/SwapClaim.d.ts +4 -4
  31. package/dist/solana/swaps/modules/SwapClaim.js +122 -134
  32. package/dist/solana/swaps/modules/SwapInit.d.ts +2 -3
  33. package/dist/solana/swaps/modules/SwapInit.js +254 -285
  34. package/dist/solana/swaps/modules/SwapRefund.d.ts +2 -3
  35. package/dist/solana/swaps/modules/SwapRefund.js +103 -113
  36. package/dist/utils/Utils.d.ts +10 -0
  37. package/dist/utils/Utils.js +62 -35
  38. package/package.json +9 -6
  39. package/src/index.ts +1 -0
  40. package/src/solana/SolanaChains.ts +16 -0
  41. package/src/solana/SolanaInitializer.ts +98 -0
  42. package/src/solana/base/SolanaBase.ts +1 -2
  43. package/src/solana/base/modules/SolanaEvents.ts +0 -1
  44. package/src/solana/base/modules/SolanaFees.ts +35 -31
  45. package/src/solana/base/modules/SolanaTokens.ts +26 -27
  46. package/src/solana/base/modules/SolanaTransactions.ts +33 -28
  47. package/src/solana/btcrelay/SolanaBtcRelay.ts +6 -10
  48. package/src/solana/events/SolanaChainEventsBrowser.ts +14 -10
  49. package/src/solana/program/modules/SolanaProgramEvents.ts +1 -1
  50. package/src/solana/swaps/SolanaSwapData.ts +38 -19
  51. package/src/solana/swaps/SolanaSwapProgram.ts +133 -105
  52. package/src/solana/swaps/modules/SolanaDataAccount.ts +4 -6
  53. package/src/solana/swaps/modules/SolanaLpVault.ts +18 -18
  54. package/src/solana/swaps/modules/SwapClaim.ts +14 -17
  55. package/src/solana/swaps/modules/SwapInit.ts +35 -38
  56. package/src/solana/swaps/modules/SwapRefund.ts +20 -23
  57. package/src/utils/Utils.ts +35 -0
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.SolanaTransactions = void 0;
13
4
  const web3_js_1 = require("@solana/web3.js");
@@ -25,20 +16,18 @@ class SolanaTransactions extends SolanaModule_1.SolanaModule {
25
16
  * @param options
26
17
  * @private
27
18
  */
28
- sendRawTransaction(data, options) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- let result = null;
31
- options !== null && options !== void 0 ? options : (options = {});
32
- options.maxRetries = 0;
33
- if (this.cbkSendTransaction != null)
34
- result = yield this.cbkSendTransaction(data, options);
35
- if (result == null)
36
- result = yield this.root.Fees.submitTx(data, options);
37
- if (result == null)
38
- result = yield this.connection.sendRawTransaction(data, options);
39
- // this.logger.debug("sendRawTransaction(): tx sent, signature: "+result);
40
- return result;
41
- });
19
+ async sendRawTransaction(data, options) {
20
+ let result = null;
21
+ options ?? (options = {});
22
+ options.maxRetries = 0;
23
+ if (this.cbkSendTransaction != null)
24
+ result = await this.cbkSendTransaction(data, options);
25
+ if (result == null)
26
+ result = await this.root.Fees.submitTx(data, options);
27
+ if (result == null)
28
+ result = await this.connection.sendRawTransaction(data, options);
29
+ // this.logger.debug("sendRawTransaction(): tx sent, signature: "+result);
30
+ return result;
42
31
  }
43
32
  /**
44
33
  * Waits for the transaction to confirm by periodically checking the transaction status over HTTP, also
@@ -53,12 +42,11 @@ class SolanaTransactions extends SolanaModule_1.SolanaModule {
53
42
  const rawTx = solanaTx.tx.serialize();
54
43
  const signature = bs58.encode(solanaTx.tx.signature);
55
44
  return new Promise((resolve, reject) => {
56
- var _a;
57
45
  let watchdogInterval;
58
- watchdogInterval = setInterval(() => __awaiter(this, void 0, void 0, function* () {
59
- const result = yield this.sendRawTransaction(rawTx, { skipPreflight: true }).catch(e => this.logger.error("txConfirmationAndResendWatchdog(): transaction re-sent error: ", e));
46
+ watchdogInterval = setInterval(async () => {
47
+ const result = await this.sendRawTransaction(rawTx, { skipPreflight: true }).catch(e => this.logger.error("txConfirmationAndResendWatchdog(): transaction re-sent error: ", e));
60
48
  this.logger.debug("txConfirmationAndResendWatchdog(): transaction re-sent: " + result);
61
- const status = yield this.getTxIdStatus(signature, finality).catch(e => this.logger.error("txConfirmationAndResendWatchdog(): get tx id status error: ", e));
49
+ const status = await this.getTxIdStatus(signature, finality).catch(e => this.logger.error("txConfirmationAndResendWatchdog(): get tx id status error: ", e));
62
50
  if (status == null || status === "not_found")
63
51
  return;
64
52
  if (status === "success") {
@@ -68,7 +56,7 @@ class SolanaTransactions extends SolanaModule_1.SolanaModule {
68
56
  if (status === "reverted")
69
57
  reject(new Error("Transaction reverted!"));
70
58
  clearInterval(watchdogInterval);
71
- }), ((_a = this.retryPolicy) === null || _a === void 0 ? void 0 : _a.transactionResendInterval) || 3000);
59
+ }, this.retryPolicy?.transactionResendInterval || 3000);
72
60
  if (abortSignal != null)
73
61
  abortSignal.addEventListener("abort", () => {
74
62
  clearInterval(watchdogInterval);
@@ -86,40 +74,38 @@ class SolanaTransactions extends SolanaModule_1.SolanaModule {
86
74
  * @param abortSignal signal to abort waiting for tx confirmation
87
75
  * @private
88
76
  */
89
- txConfirmFromWebsocket(solanaTx, finality, abortSignal) {
90
- return __awaiter(this, void 0, void 0, function* () {
91
- const signature = bs58.encode(solanaTx.tx.signature);
92
- let result;
93
- try {
94
- result = yield this.connection.confirmTransaction({
95
- signature: signature,
96
- blockhash: solanaTx.tx.recentBlockhash,
97
- lastValidBlockHeight: solanaTx.tx.lastValidBlockHeight,
98
- abortSignal
99
- }, finality);
100
- this.logger.info("txConfirmFromWebsocket(): transaction confirmed from WS, signature: " + signature);
77
+ async txConfirmFromWebsocket(solanaTx, finality, abortSignal) {
78
+ const signature = bs58.encode(solanaTx.tx.signature);
79
+ let result;
80
+ try {
81
+ result = await this.connection.confirmTransaction({
82
+ signature: signature,
83
+ blockhash: solanaTx.tx.recentBlockhash,
84
+ lastValidBlockHeight: solanaTx.tx.lastValidBlockHeight,
85
+ abortSignal
86
+ }, finality);
87
+ this.logger.info("txConfirmFromWebsocket(): transaction confirmed from WS, signature: " + signature);
88
+ }
89
+ catch (err) {
90
+ if (abortSignal != null && abortSignal.aborted)
91
+ throw err;
92
+ this.logger.debug("txConfirmFromWebsocket(): transaction rejected from WS, running ultimate check, expiry blockheight: " + solanaTx.tx.lastValidBlockHeight + " signature: " + signature + " error: " + err);
93
+ const status = await (0, Utils_1.tryWithRetries)(() => this.getTxIdStatus(signature, finality));
94
+ this.logger.info("txConfirmFromWebsocket(): transaction status: " + status + " signature: " + signature);
95
+ if (status === "success")
96
+ return signature;
97
+ if (status === "reverted")
98
+ throw new Error("Transaction reverted!");
99
+ if (err instanceof web3_js_1.TransactionExpiredBlockheightExceededError || err.toString().startsWith("TransactionExpiredBlockheightExceededError")) {
100
+ throw new Error("Transaction expired before confirmation, please try again!");
101
101
  }
102
- catch (err) {
103
- if (abortSignal != null && abortSignal.aborted)
104
- throw err;
105
- this.logger.debug("txConfirmFromWebsocket(): transaction rejected from WS, running ultimate check, expiry blockheight: " + solanaTx.tx.lastValidBlockHeight + " signature: " + signature + " error: " + err);
106
- const status = yield (0, Utils_1.tryWithRetries)(() => this.getTxIdStatus(signature, finality));
107
- this.logger.info("txConfirmFromWebsocket(): transaction status: " + status + " signature: " + signature);
108
- if (status === "success")
109
- return signature;
110
- if (status === "reverted")
111
- throw new Error("Transaction reverted!");
112
- if (err instanceof web3_js_1.TransactionExpiredBlockheightExceededError || err.toString().startsWith("TransactionExpiredBlockheightExceededError")) {
113
- throw new Error("Transaction expired before confirmation, please try again!");
114
- }
115
- else {
116
- throw err;
117
- }
102
+ else {
103
+ throw err;
118
104
  }
119
- if (result.value.err != null)
120
- throw new Error("Transaction reverted!");
121
- return signature;
122
- });
105
+ }
106
+ if (result.value.err != null)
107
+ throw new Error("Transaction reverted!");
108
+ return signature;
123
109
  }
124
110
  /**
125
111
  * Waits for transaction confirmation using WS subscription and occasional HTTP polling, also re-sends
@@ -130,27 +116,25 @@ class SolanaTransactions extends SolanaModule_1.SolanaModule {
130
116
  * @param finality wait for specific finality
131
117
  * @private
132
118
  */
133
- confirmTransaction(solanaTx, abortSignal, finality) {
134
- return __awaiter(this, void 0, void 0, function* () {
135
- const abortController = new AbortController();
136
- if (abortSignal != null)
137
- abortSignal.addEventListener("abort", () => {
138
- abortController.abort();
139
- });
140
- let txSignature;
141
- try {
142
- txSignature = yield Promise.race([
143
- this.txConfirmationAndResendWatchdog(solanaTx, finality, abortController.signal),
144
- this.txConfirmFromWebsocket(solanaTx, finality, abortController.signal)
145
- ]);
146
- }
147
- catch (e) {
148
- abortController.abort(e);
149
- throw e;
150
- }
151
- // this.logger.info("confirmTransaction(): transaction confirmed, signature: "+txSignature);
152
- abortController.abort();
153
- });
119
+ async confirmTransaction(solanaTx, abortSignal, finality) {
120
+ const abortController = new AbortController();
121
+ if (abortSignal != null)
122
+ abortSignal.addEventListener("abort", () => {
123
+ abortController.abort();
124
+ });
125
+ let txSignature;
126
+ try {
127
+ txSignature = await Promise.race([
128
+ this.txConfirmationAndResendWatchdog(solanaTx, finality, abortController.signal),
129
+ this.txConfirmFromWebsocket(solanaTx, finality, abortController.signal)
130
+ ]);
131
+ }
132
+ catch (e) {
133
+ abortController.abort(e);
134
+ throw e;
135
+ }
136
+ // this.logger.info("confirmTransaction(): transaction confirmed, signature: "+txSignature);
137
+ abortController.abort();
154
138
  }
155
139
  /**
156
140
  * Prepares solana transactions, assigns recentBlockhash if needed, applies Phantom hotfix,
@@ -160,34 +144,32 @@ class SolanaTransactions extends SolanaModule_1.SolanaModule {
160
144
  * @param txs
161
145
  * @private
162
146
  */
163
- prepareTransactions(signer, txs) {
164
- return __awaiter(this, void 0, void 0, function* () {
165
- let latestBlockData = null;
166
- for (let tx of txs) {
167
- if (tx.tx.recentBlockhash == null) {
168
- if (latestBlockData == null) {
169
- latestBlockData = yield (0, Utils_1.tryWithRetries)(() => this.connection.getLatestBlockhash("confirmed"), this.retryPolicy);
170
- this.logger.debug("prepareTransactions(): fetched latest block data for transactions," +
171
- " blockhash: " + latestBlockData.blockhash + " expiry blockheight: " + latestBlockData.lastValidBlockHeight);
172
- }
173
- tx.tx.recentBlockhash = latestBlockData.blockhash;
174
- tx.tx.lastValidBlockHeight = latestBlockData.lastValidBlockHeight;
175
- }
176
- //This is a hotfix for Phantom adding compute unit price instruction on the first position & breaking
177
- // required instructions order (e.g. btc relay verify needs to be 0th instruction in a tx)
178
- if (signer.keypair == null && tx.tx.signatures.length === 0) {
179
- const foundIx = tx.tx.instructions.find(ix => ix.programId.equals(web3_js_1.ComputeBudgetProgram.programId) && web3_js_1.ComputeBudgetInstruction.decodeInstructionType(ix) === "SetComputeUnitPrice");
180
- if (foundIx == null)
181
- tx.tx.instructions.splice(tx.tx.instructions.length - 1, 0, web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 1 }));
147
+ async prepareTransactions(signer, txs) {
148
+ let latestBlockData = null;
149
+ for (let tx of txs) {
150
+ if (tx.tx.recentBlockhash == null) {
151
+ if (latestBlockData == null) {
152
+ latestBlockData = await (0, Utils_1.tryWithRetries)(() => this.connection.getLatestBlockhash("confirmed"), this.retryPolicy);
153
+ this.logger.debug("prepareTransactions(): fetched latest block data for transactions," +
154
+ " blockhash: " + latestBlockData.blockhash + " expiry blockheight: " + latestBlockData.lastValidBlockHeight);
182
155
  }
183
- tx.tx.feePayer = signer.getPublicKey();
184
- if (this.cbkBeforeTxSigned != null)
185
- yield this.cbkBeforeTxSigned(tx);
186
- if (tx.signers != null && tx.signers.length > 0)
187
- for (let signer of tx.signers)
188
- tx.tx.sign(signer);
156
+ tx.tx.recentBlockhash = latestBlockData.blockhash;
157
+ tx.tx.lastValidBlockHeight = latestBlockData.lastValidBlockHeight;
189
158
  }
190
- });
159
+ //This is a hotfix for Phantom adding compute unit price instruction on the first position & breaking
160
+ // required instructions order (e.g. btc relay verify needs to be 0th instruction in a tx)
161
+ if (signer.keypair == null && tx.tx.signatures.length === 0) {
162
+ const foundIx = tx.tx.instructions.find(ix => ix.programId.equals(web3_js_1.ComputeBudgetProgram.programId) && web3_js_1.ComputeBudgetInstruction.decodeInstructionType(ix) === "SetComputeUnitPrice");
163
+ if (foundIx == null)
164
+ tx.tx.instructions.splice(tx.tx.instructions.length - 1, 0, web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 1 }));
165
+ }
166
+ tx.tx.feePayer = signer.getPublicKey();
167
+ if (this.cbkBeforeTxSigned != null)
168
+ await this.cbkBeforeTxSigned(tx);
169
+ if (tx.signers != null && tx.signers.length > 0)
170
+ for (let signer of tx.signers)
171
+ tx.tx.sign(signer);
172
+ }
191
173
  }
192
174
  /**
193
175
  * Sends out a signed transaction to the RPC
@@ -197,17 +179,15 @@ class SolanaTransactions extends SolanaModule_1.SolanaModule {
197
179
  * @param onBeforePublish a callback called before every transaction is published
198
180
  * @private
199
181
  */
200
- sendSignedTransaction(solTx, options, onBeforePublish) {
201
- return __awaiter(this, void 0, void 0, function* () {
202
- if (onBeforePublish != null)
203
- yield onBeforePublish(bs58.encode(solTx.tx.signature), yield this.serializeTx(solTx));
204
- const serializedTx = solTx.tx.serialize();
205
- this.logger.debug("sendSignedTransaction(): sending transaction: " + serializedTx.toString("hex") +
206
- " signature: " + bs58.encode(solTx.tx.signature));
207
- const txResult = yield (0, Utils_1.tryWithRetries)(() => this.sendRawTransaction(serializedTx, options), this.retryPolicy);
208
- this.logger.info("sendSignedTransaction(): tx sent, signature: " + txResult);
209
- return txResult;
210
- });
182
+ async sendSignedTransaction(solTx, options, onBeforePublish) {
183
+ if (onBeforePublish != null)
184
+ await onBeforePublish(bs58.encode(solTx.tx.signature), await this.serializeTx(solTx));
185
+ const serializedTx = solTx.tx.serialize();
186
+ this.logger.debug("sendSignedTransaction(): sending transaction: " + serializedTx.toString("hex") +
187
+ " signature: " + bs58.encode(solTx.tx.signature));
188
+ const txResult = await (0, Utils_1.tryWithRetries)(() => this.sendRawTransaction(serializedTx, options), this.retryPolicy);
189
+ this.logger.info("sendSignedTransaction(): tx sent, signature: " + txResult);
190
+ return txResult;
211
191
  }
212
192
  /**
213
193
  * Prepares (adds recent blockhash if required, applies Phantom hotfix),
@@ -215,7 +195,7 @@ class SolanaTransactions extends SolanaModule_1.SolanaModule {
215
195
  * optionally waits for confirmation of a batch of solana transactions
216
196
  *
217
197
  * @param signer
218
- * @param txs transactions to send
198
+ * @param _txs
219
199
  * @param waitForConfirmation whether to wait for transaction confirmations (this also makes sure the transactions
220
200
  * are re-sent at regular intervals)
221
201
  * @param abortSignal abort signal to abort waiting for transaction confirmations
@@ -223,47 +203,49 @@ class SolanaTransactions extends SolanaModule_1.SolanaModule {
223
203
  * are executed in order)
224
204
  * @param onBeforePublish a callback called before every transaction is published
225
205
  */
226
- sendAndConfirm(signer, txs, waitForConfirmation, abortSignal, parallel, onBeforePublish) {
227
- return __awaiter(this, void 0, void 0, function* () {
228
- yield this.prepareTransactions(signer, txs);
229
- const signedTxs = yield signer.wallet.signAllTransactions(txs.map(e => e.tx));
206
+ async sendAndConfirm(signer, _txs, waitForConfirmation, abortSignal, parallel, onBeforePublish) {
207
+ const options = {
208
+ skipPreflight: true
209
+ };
210
+ this.logger.debug("sendAndConfirm(): sending transactions, count: " + _txs.length +
211
+ " waitForConfirmation: " + waitForConfirmation + " parallel: " + parallel);
212
+ const signatures = [];
213
+ for (let e = 0; e < _txs.length; e += 50) {
214
+ const txs = _txs.slice(e, e + 50);
215
+ await this.prepareTransactions(signer, txs);
216
+ const signedTxs = await signer.wallet.signAllTransactions(txs.map(e => e.tx));
230
217
  signedTxs.forEach((tx, index) => {
231
218
  const solTx = txs[index];
232
219
  tx.lastValidBlockHeight = solTx.tx.lastValidBlockHeight;
233
220
  solTx.tx = tx;
234
221
  });
235
- const options = {
236
- skipPreflight: true
237
- };
238
- this.logger.debug("sendAndConfirm(): sending transactions, count: " + txs.length +
239
- " waitForConfirmation: " + waitForConfirmation + " parallel: " + parallel);
240
- const signatures = [];
222
+ this.logger.debug("sendAndConfirm(): sending transaction batch (" + e + ".." + (e + 50) + "), count: " + txs.length);
241
223
  if (parallel) {
242
224
  const promises = [];
243
225
  for (let solTx of txs) {
244
- const signature = yield this.sendSignedTransaction(solTx, options, onBeforePublish);
226
+ const signature = await this.sendSignedTransaction(solTx, options, onBeforePublish);
245
227
  if (waitForConfirmation)
246
228
  promises.push(this.confirmTransaction(solTx, abortSignal, "confirmed"));
247
229
  signatures.push(signature);
248
230
  }
249
231
  if (promises.length > 0)
250
- yield Promise.all(promises);
232
+ await Promise.all(promises);
251
233
  }
252
234
  else {
253
235
  for (let i = 0; i < txs.length; i++) {
254
236
  const solTx = txs[i];
255
- const signature = yield this.sendSignedTransaction(solTx, options, onBeforePublish);
237
+ const signature = await this.sendSignedTransaction(solTx, options, onBeforePublish);
256
238
  const confirmPromise = this.confirmTransaction(solTx, abortSignal, "confirmed");
257
239
  //Don't await the last promise when !waitForConfirmation
258
- if (i < txs.length - 1 || waitForConfirmation)
259
- yield confirmPromise;
240
+ if (i < txs.length - 1 || e + 50 < _txs.length || waitForConfirmation)
241
+ await confirmPromise;
260
242
  signatures.push(signature);
261
243
  }
262
244
  }
263
- this.logger.info("sendAndConfirm(): sent transactions, count: " + txs.length +
264
- " waitForConfirmation: " + waitForConfirmation + " parallel: " + parallel);
265
- return signatures;
266
- });
245
+ }
246
+ this.logger.info("sendAndConfirm(): sent transactions, count: " + _txs.length +
247
+ " waitForConfirmation: " + waitForConfirmation + " parallel: " + parallel);
248
+ return signatures;
267
249
  }
268
250
  /**
269
251
  * Serializes the solana transaction, saves the transaction, signers & last valid blockheight
@@ -298,23 +280,21 @@ class SolanaTransactions extends SolanaModule_1.SolanaModule {
298
280
  *
299
281
  * @param tx
300
282
  */
301
- getTxStatus(tx) {
302
- return __awaiter(this, void 0, void 0, function* () {
303
- const parsedTx = yield this.deserializeTx(tx);
304
- const txReceipt = yield this.connection.getTransaction(bs58.encode(parsedTx.tx.signature), {
305
- commitment: "confirmed",
306
- maxSupportedTransactionVersion: 0
307
- });
308
- if (txReceipt == null) {
309
- const currentBlockheight = yield this.connection.getBlockHeight("processed");
310
- if (currentBlockheight > parsedTx.tx.lastValidBlockHeight)
311
- return "not_found";
312
- return "pending";
313
- }
314
- if (txReceipt.meta.err)
315
- return "reverted";
316
- return "success";
283
+ async getTxStatus(tx) {
284
+ const parsedTx = await this.deserializeTx(tx);
285
+ const txReceipt = await this.connection.getTransaction(bs58.encode(parsedTx.tx.signature), {
286
+ commitment: "confirmed",
287
+ maxSupportedTransactionVersion: 0
317
288
  });
289
+ if (txReceipt == null) {
290
+ const currentBlockheight = await this.connection.getBlockHeight("processed");
291
+ if (currentBlockheight > parsedTx.tx.lastValidBlockHeight)
292
+ return "not_found";
293
+ return "pending";
294
+ }
295
+ if (txReceipt.meta.err)
296
+ return "reverted";
297
+ return "success";
318
298
  }
319
299
  /**
320
300
  * Gets the status of the solana transaction with a specific txId, this cannot report whether the transaction is
@@ -323,18 +303,16 @@ class SolanaTransactions extends SolanaModule_1.SolanaModule {
323
303
  * @param txId
324
304
  * @param finality
325
305
  */
326
- getTxIdStatus(txId, finality) {
327
- return __awaiter(this, void 0, void 0, function* () {
328
- const txReceipt = yield this.connection.getTransaction(txId, {
329
- commitment: finality || "confirmed",
330
- maxSupportedTransactionVersion: 0
331
- });
332
- if (txReceipt == null)
333
- return "not_found";
334
- if (txReceipt.meta.err)
335
- return "reverted";
336
- return "success";
306
+ async getTxIdStatus(txId, finality) {
307
+ const txReceipt = await this.connection.getTransaction(txId, {
308
+ commitment: finality || "confirmed",
309
+ maxSupportedTransactionVersion: 0
337
310
  });
311
+ if (txReceipt == null)
312
+ return "not_found";
313
+ if (txReceipt.meta.err)
314
+ return "reverted";
315
+ return "success";
338
316
  }
339
317
  onBeforeTxSigned(callback) {
340
318
  this.cbkBeforeTxSigned = callback;
@@ -3,7 +3,6 @@ import { Connection, PublicKey, Signer, Transaction } from "@solana/web3.js";
3
3
  import { SolanaBtcStoredHeader } from "./headers/SolanaBtcStoredHeader";
4
4
  import { BitcoinRpc, BtcBlock, BtcRelay } from "@atomiqlabs/base";
5
5
  import { SolanaProgramBase } from "../program/SolanaProgramBase";
6
- import * as BN from "bn.js";
7
6
  import { SolanaAction } from "../base/SolanaAction";
8
7
  import { Buffer } from "buffer";
9
8
  import { SolanaFees } from "../base/modules/SolanaFees";
@@ -211,13 +210,13 @@ export declare class SolanaBtcRelay<B extends BtcBlock> extends SolanaProgramBas
211
210
  * @param requiredBlockheight
212
211
  * @param feeRate
213
212
  */
214
- estimateSynchronizeFee(requiredBlockheight: number, feeRate?: string): Promise<BN>;
213
+ estimateSynchronizeFee(requiredBlockheight: number, feeRate?: string): Promise<bigint>;
215
214
  /**
216
215
  * Returns fee required (in SOL) to synchronize a single block to btc relay
217
216
  *
218
217
  * @param feeRate
219
218
  */
220
- getFeePerBlock(feeRate?: string): Promise<BN>;
219
+ getFeePerBlock(feeRate?: string): Promise<bigint>;
221
220
  /**
222
221
  * Gets fee rate required for submitting blockheaders to the main chain
223
222
  */