@atomiqlabs/chain-solana 10.0.0-dev.3 → 11.0.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 (114) hide show
  1. package/LICENSE +201 -201
  2. package/dist/index.d.ts +29 -29
  3. package/dist/index.js +45 -45
  4. package/dist/solana/SolanaChainType.d.ts +10 -10
  5. package/dist/solana/SolanaChainType.js +2 -2
  6. package/dist/solana/SolanaChains.d.ts +20 -20
  7. package/dist/solana/SolanaChains.js +25 -25
  8. package/dist/solana/SolanaInitializer.d.ts +18 -18
  9. package/dist/solana/SolanaInitializer.js +63 -63
  10. package/dist/solana/btcrelay/SolanaBtcRelay.d.ts +228 -228
  11. package/dist/solana/btcrelay/SolanaBtcRelay.js +441 -441
  12. package/dist/solana/btcrelay/headers/SolanaBtcHeader.d.ts +29 -29
  13. package/dist/solana/btcrelay/headers/SolanaBtcHeader.js +34 -34
  14. package/dist/solana/btcrelay/headers/SolanaBtcStoredHeader.d.ts +46 -46
  15. package/dist/solana/btcrelay/headers/SolanaBtcStoredHeader.js +78 -78
  16. package/dist/solana/btcrelay/program/programIdl.json +671 -671
  17. package/dist/solana/chain/SolanaAction.d.ts +26 -26
  18. package/dist/solana/chain/SolanaAction.js +86 -86
  19. package/dist/solana/chain/SolanaChainInterface.d.ts +58 -58
  20. package/dist/solana/chain/SolanaChainInterface.js +112 -112
  21. package/dist/solana/chain/SolanaModule.d.ts +14 -14
  22. package/dist/solana/chain/SolanaModule.js +13 -13
  23. package/dist/solana/chain/modules/SolanaAddresses.d.ts +8 -8
  24. package/dist/solana/chain/modules/SolanaAddresses.js +22 -22
  25. package/dist/solana/chain/modules/SolanaBlocks.d.ts +28 -28
  26. package/dist/solana/chain/modules/SolanaBlocks.js +72 -72
  27. package/dist/solana/chain/modules/SolanaEvents.d.ts +25 -25
  28. package/dist/solana/chain/modules/SolanaEvents.js +58 -58
  29. package/dist/solana/chain/modules/SolanaFees.d.ts +121 -121
  30. package/dist/solana/chain/modules/SolanaFees.js +379 -379
  31. package/dist/solana/chain/modules/SolanaSignatures.d.ts +23 -23
  32. package/dist/solana/chain/modules/SolanaSignatures.js +39 -39
  33. package/dist/solana/chain/modules/SolanaSlots.d.ts +31 -31
  34. package/dist/solana/chain/modules/SolanaSlots.js +68 -68
  35. package/dist/solana/chain/modules/SolanaTokens.d.ts +136 -136
  36. package/dist/solana/chain/modules/SolanaTokens.js +248 -248
  37. package/dist/solana/chain/modules/SolanaTransactions.d.ts +124 -124
  38. package/dist/solana/chain/modules/SolanaTransactions.js +332 -332
  39. package/dist/solana/events/SolanaChainEvents.d.ts +88 -88
  40. package/dist/solana/events/SolanaChainEvents.js +256 -256
  41. package/dist/solana/events/SolanaChainEventsBrowser.d.ts +85 -85
  42. package/dist/solana/events/SolanaChainEventsBrowser.js +194 -194
  43. package/dist/solana/program/SolanaProgramBase.d.ts +40 -40
  44. package/dist/solana/program/SolanaProgramBase.js +43 -43
  45. package/dist/solana/program/SolanaProgramModule.d.ts +8 -8
  46. package/dist/solana/program/SolanaProgramModule.js +11 -11
  47. package/dist/solana/program/modules/SolanaProgramEvents.d.ts +59 -59
  48. package/dist/solana/program/modules/SolanaProgramEvents.js +103 -103
  49. package/dist/solana/swaps/SolanaSwapData.d.ts +59 -59
  50. package/dist/solana/swaps/SolanaSwapData.js +267 -267
  51. package/dist/solana/swaps/SolanaSwapModule.d.ts +10 -10
  52. package/dist/solana/swaps/SolanaSwapModule.js +11 -11
  53. package/dist/solana/swaps/SolanaSwapProgram.d.ts +202 -202
  54. package/dist/solana/swaps/SolanaSwapProgram.js +470 -463
  55. package/dist/solana/swaps/SwapTypeEnum.d.ts +11 -11
  56. package/dist/solana/swaps/SwapTypeEnum.js +42 -42
  57. package/dist/solana/swaps/modules/SolanaDataAccount.d.ts +94 -94
  58. package/dist/solana/swaps/modules/SolanaDataAccount.js +231 -231
  59. package/dist/solana/swaps/modules/SolanaLpVault.d.ts +71 -71
  60. package/dist/solana/swaps/modules/SolanaLpVault.js +173 -173
  61. package/dist/solana/swaps/modules/SwapClaim.d.ts +129 -129
  62. package/dist/solana/swaps/modules/SwapClaim.js +291 -291
  63. package/dist/solana/swaps/modules/SwapInit.d.ts +217 -217
  64. package/dist/solana/swaps/modules/SwapInit.js +519 -519
  65. package/dist/solana/swaps/modules/SwapRefund.d.ts +82 -82
  66. package/dist/solana/swaps/modules/SwapRefund.js +252 -252
  67. package/dist/solana/swaps/programIdl.json +945 -945
  68. package/dist/solana/swaps/programTypes.d.ts +943 -943
  69. package/dist/solana/swaps/programTypes.js +945 -945
  70. package/dist/solana/wallet/SolanaKeypairWallet.d.ts +9 -9
  71. package/dist/solana/wallet/SolanaKeypairWallet.js +33 -33
  72. package/dist/solana/wallet/SolanaSigner.d.ts +10 -10
  73. package/dist/solana/wallet/SolanaSigner.js +16 -16
  74. package/dist/utils/Utils.d.ts +53 -53
  75. package/dist/utils/Utils.js +170 -170
  76. package/package.json +41 -41
  77. package/src/index.ts +36 -36
  78. package/src/solana/SolanaChainType.ts +25 -25
  79. package/src/solana/SolanaChains.ts +23 -23
  80. package/src/solana/SolanaInitializer.ts +102 -102
  81. package/src/solana/btcrelay/SolanaBtcRelay.ts +589 -588
  82. package/src/solana/btcrelay/headers/SolanaBtcHeader.ts +57 -57
  83. package/src/solana/btcrelay/headers/SolanaBtcStoredHeader.ts +102 -102
  84. package/src/solana/btcrelay/program/programIdl.json +670 -670
  85. package/src/solana/chain/SolanaAction.ts +108 -108
  86. package/src/solana/chain/SolanaChainInterface.ts +174 -174
  87. package/src/solana/chain/SolanaModule.ts +20 -20
  88. package/src/solana/chain/modules/SolanaAddresses.ts +20 -20
  89. package/src/solana/chain/modules/SolanaBlocks.ts +78 -78
  90. package/src/solana/chain/modules/SolanaEvents.ts +56 -56
  91. package/src/solana/chain/modules/SolanaFees.ts +450 -450
  92. package/src/solana/chain/modules/SolanaSignatures.ts +39 -39
  93. package/src/solana/chain/modules/SolanaSlots.ts +82 -82
  94. package/src/solana/chain/modules/SolanaTokens.ts +307 -307
  95. package/src/solana/chain/modules/SolanaTransactions.ts +370 -370
  96. package/src/solana/events/SolanaChainEvents.ts +299 -299
  97. package/src/solana/events/SolanaChainEventsBrowser.ts +256 -256
  98. package/src/solana/program/SolanaProgramBase.ts +79 -79
  99. package/src/solana/program/SolanaProgramModule.ts +15 -15
  100. package/src/solana/program/modules/SolanaProgramEvents.ts +140 -140
  101. package/src/solana/swaps/SolanaSwapData.ts +379 -379
  102. package/src/solana/swaps/SolanaSwapModule.ts +16 -16
  103. package/src/solana/swaps/SolanaSwapProgram.ts +697 -692
  104. package/src/solana/swaps/SwapTypeEnum.ts +29 -29
  105. package/src/solana/swaps/modules/SolanaDataAccount.ts +307 -307
  106. package/src/solana/swaps/modules/SolanaLpVault.ts +215 -215
  107. package/src/solana/swaps/modules/SwapClaim.ts +389 -389
  108. package/src/solana/swaps/modules/SwapInit.ts +663 -663
  109. package/src/solana/swaps/modules/SwapRefund.ts +312 -312
  110. package/src/solana/swaps/programIdl.json +944 -944
  111. package/src/solana/swaps/programTypes.ts +1885 -1885
  112. package/src/solana/wallet/SolanaKeypairWallet.ts +36 -36
  113. package/src/solana/wallet/SolanaSigner.ts +23 -23
  114. package/src/utils/Utils.ts +180 -180
@@ -1,22 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SolanaAddresses = void 0;
4
- const web3_js_1 = require("@solana/web3.js");
5
- class SolanaAddresses {
6
- ///////////////////
7
- //// Address utils
8
- /**
9
- * Checks whether an address is a valid Solana address (base58 encoded ed25519 public key)
10
- *
11
- * @param address
12
- */
13
- static isValidAddress(address) {
14
- try {
15
- return web3_js_1.PublicKey.isOnCurve(address);
16
- }
17
- catch (e) {
18
- return false;
19
- }
20
- }
21
- }
22
- exports.SolanaAddresses = SolanaAddresses;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SolanaAddresses = void 0;
4
+ const web3_js_1 = require("@solana/web3.js");
5
+ class SolanaAddresses {
6
+ ///////////////////
7
+ //// Address utils
8
+ /**
9
+ * Checks whether an address is a valid Solana address (base58 encoded ed25519 public key)
10
+ *
11
+ * @param address
12
+ */
13
+ static isValidAddress(address) {
14
+ try {
15
+ return web3_js_1.PublicKey.isOnCurve(address);
16
+ }
17
+ catch (e) {
18
+ return false;
19
+ }
20
+ }
21
+ }
22
+ exports.SolanaAddresses = SolanaAddresses;
@@ -1,28 +1,28 @@
1
- import { SolanaModule } from "../SolanaModule";
2
- import { Commitment, ParsedAccountsModeBlockResponse } from "@solana/web3.js";
3
- export declare class SolanaBlocks extends SolanaModule {
4
- private blockCache;
5
- /**
6
- * Initiates a fetch of the block at specified slot & saves the fetch promise into a block cache
7
- *
8
- * @param slot
9
- * @private
10
- */
11
- private fetchAndSaveParsedBlock;
12
- /**
13
- * Tries to find the latest existing block for a given commitment, skipping blocks that are not available, runs a
14
- * search backwards from the latest slot for the given commitment and fails after 10 tries
15
- *
16
- * @param commitment
17
- */
18
- findLatestParsedBlock(commitment: Commitment): Promise<{
19
- block: ParsedAccountsModeBlockResponse;
20
- slot: number;
21
- }>;
22
- /**
23
- * Gets parsed block for a given slot, uses block cache if the block was already fetched before
24
- *
25
- * @param slot
26
- */
27
- getParsedBlock(slot: number): Promise<ParsedAccountsModeBlockResponse>;
28
- }
1
+ import { SolanaModule } from "../SolanaModule";
2
+ import { Commitment, ParsedAccountsModeBlockResponse } from "@solana/web3.js";
3
+ export declare class SolanaBlocks extends SolanaModule {
4
+ private blockCache;
5
+ /**
6
+ * Initiates a fetch of the block at specified slot & saves the fetch promise into a block cache
7
+ *
8
+ * @param slot
9
+ * @private
10
+ */
11
+ private fetchAndSaveParsedBlock;
12
+ /**
13
+ * Tries to find the latest existing block for a given commitment, skipping blocks that are not available, runs a
14
+ * search backwards from the latest slot for the given commitment and fails after 10 tries
15
+ *
16
+ * @param commitment
17
+ */
18
+ findLatestParsedBlock(commitment: Commitment): Promise<{
19
+ block: ParsedAccountsModeBlockResponse;
20
+ slot: number;
21
+ }>;
22
+ /**
23
+ * Gets parsed block for a given slot, uses block cache if the block was already fetched before
24
+ *
25
+ * @param slot
26
+ */
27
+ getParsedBlock(slot: number): Promise<ParsedAccountsModeBlockResponse>;
28
+ }
@@ -1,72 +1,72 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SolanaBlocks = void 0;
4
- const SolanaModule_1 = require("../SolanaModule");
5
- class SolanaBlocks extends SolanaModule_1.SolanaModule {
6
- constructor() {
7
- super(...arguments);
8
- this.blockCache = new Map();
9
- }
10
- /**
11
- * Initiates a fetch of the block at specified slot & saves the fetch promise into a block cache
12
- *
13
- * @param slot
14
- * @private
15
- */
16
- fetchAndSaveParsedBlock(slot) {
17
- const blockCacheData = this.connection.getParsedBlock(slot, {
18
- transactionDetails: "none",
19
- commitment: "confirmed",
20
- rewards: false
21
- });
22
- this.blockCache.set(slot, blockCacheData);
23
- blockCacheData.catch(e => {
24
- if (this.blockCache.get(slot) == blockCacheData)
25
- this.blockCache.delete(slot);
26
- throw e;
27
- });
28
- return blockCacheData;
29
- }
30
- ///////////////////
31
- //// Blocks
32
- /**
33
- * Tries to find the latest existing block for a given commitment, skipping blocks that are not available, runs a
34
- * search backwards from the latest slot for the given commitment and fails after 10 tries
35
- *
36
- * @param commitment
37
- */
38
- async findLatestParsedBlock(commitment) {
39
- let slot = await this.root.Slots.getSlot(commitment);
40
- for (let i = 0; i < 10; i++) {
41
- const block = await this.getParsedBlock(slot).catch(e => {
42
- if (e.toString().startsWith("SolanaJSONRPCError: failed to get block: Block not available for slot")) {
43
- return null;
44
- }
45
- throw e;
46
- });
47
- if (block != null) {
48
- this.logger.debug("findLatestParsedBlock(): Found valid block, slot: " + slot +
49
- " blockhash: " + block.blockhash + " tries: " + i);
50
- return {
51
- block,
52
- slot
53
- };
54
- }
55
- slot--;
56
- }
57
- throw new Error("Ran out of tries trying to find a parsedBlock");
58
- }
59
- /**
60
- * Gets parsed block for a given slot, uses block cache if the block was already fetched before
61
- *
62
- * @param slot
63
- */
64
- getParsedBlock(slot) {
65
- let blockCacheData = this.blockCache.get(slot);
66
- if (blockCacheData == null) {
67
- blockCacheData = this.fetchAndSaveParsedBlock(slot);
68
- }
69
- return blockCacheData;
70
- }
71
- }
72
- exports.SolanaBlocks = SolanaBlocks;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SolanaBlocks = void 0;
4
+ const SolanaModule_1 = require("../SolanaModule");
5
+ class SolanaBlocks extends SolanaModule_1.SolanaModule {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.blockCache = new Map();
9
+ }
10
+ /**
11
+ * Initiates a fetch of the block at specified slot & saves the fetch promise into a block cache
12
+ *
13
+ * @param slot
14
+ * @private
15
+ */
16
+ fetchAndSaveParsedBlock(slot) {
17
+ const blockCacheData = this.connection.getParsedBlock(slot, {
18
+ transactionDetails: "none",
19
+ commitment: "confirmed",
20
+ rewards: false
21
+ });
22
+ this.blockCache.set(slot, blockCacheData);
23
+ blockCacheData.catch(e => {
24
+ if (this.blockCache.get(slot) == blockCacheData)
25
+ this.blockCache.delete(slot);
26
+ throw e;
27
+ });
28
+ return blockCacheData;
29
+ }
30
+ ///////////////////
31
+ //// Blocks
32
+ /**
33
+ * Tries to find the latest existing block for a given commitment, skipping blocks that are not available, runs a
34
+ * search backwards from the latest slot for the given commitment and fails after 10 tries
35
+ *
36
+ * @param commitment
37
+ */
38
+ async findLatestParsedBlock(commitment) {
39
+ let slot = await this.root.Slots.getSlot(commitment);
40
+ for (let i = 0; i < 10; i++) {
41
+ const block = await this.getParsedBlock(slot).catch(e => {
42
+ if (e.toString().startsWith("SolanaJSONRPCError: failed to get block: Block not available for slot")) {
43
+ return null;
44
+ }
45
+ throw e;
46
+ });
47
+ if (block != null) {
48
+ this.logger.debug("findLatestParsedBlock(): Found valid block, slot: " + slot +
49
+ " blockhash: " + block.blockhash + " tries: " + i);
50
+ return {
51
+ block,
52
+ slot
53
+ };
54
+ }
55
+ slot--;
56
+ }
57
+ throw new Error("Ran out of tries trying to find a parsedBlock");
58
+ }
59
+ /**
60
+ * Gets parsed block for a given slot, uses block cache if the block was already fetched before
61
+ *
62
+ * @param slot
63
+ */
64
+ getParsedBlock(slot) {
65
+ let blockCacheData = this.blockCache.get(slot);
66
+ if (blockCacheData == null) {
67
+ blockCacheData = this.fetchAndSaveParsedBlock(slot);
68
+ }
69
+ return blockCacheData;
70
+ }
71
+ }
72
+ exports.SolanaBlocks = SolanaBlocks;
@@ -1,25 +1,25 @@
1
- import { SolanaModule } from "../SolanaModule";
2
- import { ConfirmedSignatureInfo, PublicKey } from "@solana/web3.js";
3
- export declare class SolanaEvents extends SolanaModule {
4
- readonly LOG_FETCH_LIMIT = 500;
5
- /**
6
- * Gets the signatures for a given topicKey public key, if lastProcessedSignature is specified, it fetches only
7
- * the signatures before this signature
8
- *
9
- * @param topicKey
10
- * @param logFetchLimit
11
- * @param lastProcessedSignature
12
- * @private
13
- */
14
- private getSignatures;
15
- /**
16
- * Runs a search backwards in time, processing transaction signatures for a specific topic public key
17
- *
18
- * @param topicKey
19
- * @param processor called for every batch of returned signatures, should return a value if the correct signature
20
- * was found, or null if the search should continue
21
- * @param abortSignal
22
- * @param logFetchLimit
23
- */
24
- findInSignatures<T>(topicKey: PublicKey, processor: (signatures: ConfirmedSignatureInfo[]) => Promise<T>, abortSignal?: AbortSignal, logFetchLimit?: number): Promise<T>;
25
- }
1
+ import { SolanaModule } from "../SolanaModule";
2
+ import { ConfirmedSignatureInfo, PublicKey } from "@solana/web3.js";
3
+ export declare class SolanaEvents extends SolanaModule {
4
+ readonly LOG_FETCH_LIMIT = 500;
5
+ /**
6
+ * Gets the signatures for a given topicKey public key, if lastProcessedSignature is specified, it fetches only
7
+ * the signatures before this signature
8
+ *
9
+ * @param topicKey
10
+ * @param logFetchLimit
11
+ * @param lastProcessedSignature
12
+ * @private
13
+ */
14
+ private getSignatures;
15
+ /**
16
+ * Runs a search backwards in time, processing transaction signatures for a specific topic public key
17
+ *
18
+ * @param topicKey
19
+ * @param processor called for every batch of returned signatures, should return a value if the correct signature
20
+ * was found, or null if the search should continue
21
+ * @param abortSignal
22
+ * @param logFetchLimit
23
+ */
24
+ findInSignatures<T>(topicKey: PublicKey, processor: (signatures: ConfirmedSignatureInfo[]) => Promise<T>, abortSignal?: AbortSignal, logFetchLimit?: number): Promise<T>;
25
+ }
@@ -1,58 +1,58 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SolanaEvents = void 0;
4
- const SolanaModule_1 = require("../SolanaModule");
5
- class SolanaEvents extends SolanaModule_1.SolanaModule {
6
- constructor() {
7
- super(...arguments);
8
- this.LOG_FETCH_LIMIT = 500;
9
- }
10
- /**
11
- * Gets the signatures for a given topicKey public key, if lastProcessedSignature is specified, it fetches only
12
- * the signatures before this signature
13
- *
14
- * @param topicKey
15
- * @param logFetchLimit
16
- * @param lastProcessedSignature
17
- * @private
18
- */
19
- getSignatures(topicKey, logFetchLimit, lastProcessedSignature) {
20
- if (lastProcessedSignature == null) {
21
- return this.connection.getSignaturesForAddress(topicKey, {
22
- limit: logFetchLimit,
23
- }, "confirmed");
24
- }
25
- else {
26
- return this.connection.getSignaturesForAddress(topicKey, {
27
- before: lastProcessedSignature,
28
- limit: logFetchLimit
29
- }, "confirmed");
30
- }
31
- }
32
- /**
33
- * Runs a search backwards in time, processing transaction signatures for a specific topic public key
34
- *
35
- * @param topicKey
36
- * @param processor called for every batch of returned signatures, should return a value if the correct signature
37
- * was found, or null if the search should continue
38
- * @param abortSignal
39
- * @param logFetchLimit
40
- */
41
- async findInSignatures(topicKey, processor, abortSignal, logFetchLimit) {
42
- if (logFetchLimit == null || logFetchLimit > this.LOG_FETCH_LIMIT)
43
- logFetchLimit = this.LOG_FETCH_LIMIT;
44
- let signatures = null;
45
- while (signatures == null || signatures.length > 0) {
46
- signatures = await this.getSignatures(topicKey, logFetchLimit, signatures != null ? signatures[signatures.length - 1].signature : null);
47
- if (abortSignal != null)
48
- abortSignal.throwIfAborted();
49
- const result = await processor(signatures);
50
- if (result != null)
51
- return result;
52
- if (signatures.length < logFetchLimit)
53
- break;
54
- }
55
- return null;
56
- }
57
- }
58
- exports.SolanaEvents = SolanaEvents;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SolanaEvents = void 0;
4
+ const SolanaModule_1 = require("../SolanaModule");
5
+ class SolanaEvents extends SolanaModule_1.SolanaModule {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.LOG_FETCH_LIMIT = 500;
9
+ }
10
+ /**
11
+ * Gets the signatures for a given topicKey public key, if lastProcessedSignature is specified, it fetches only
12
+ * the signatures before this signature
13
+ *
14
+ * @param topicKey
15
+ * @param logFetchLimit
16
+ * @param lastProcessedSignature
17
+ * @private
18
+ */
19
+ getSignatures(topicKey, logFetchLimit, lastProcessedSignature) {
20
+ if (lastProcessedSignature == null) {
21
+ return this.connection.getSignaturesForAddress(topicKey, {
22
+ limit: logFetchLimit,
23
+ }, "confirmed");
24
+ }
25
+ else {
26
+ return this.connection.getSignaturesForAddress(topicKey, {
27
+ before: lastProcessedSignature,
28
+ limit: logFetchLimit
29
+ }, "confirmed");
30
+ }
31
+ }
32
+ /**
33
+ * Runs a search backwards in time, processing transaction signatures for a specific topic public key
34
+ *
35
+ * @param topicKey
36
+ * @param processor called for every batch of returned signatures, should return a value if the correct signature
37
+ * was found, or null if the search should continue
38
+ * @param abortSignal
39
+ * @param logFetchLimit
40
+ */
41
+ async findInSignatures(topicKey, processor, abortSignal, logFetchLimit) {
42
+ if (logFetchLimit == null || logFetchLimit > this.LOG_FETCH_LIMIT)
43
+ logFetchLimit = this.LOG_FETCH_LIMIT;
44
+ let signatures = null;
45
+ while (signatures == null || signatures.length > 0) {
46
+ signatures = await this.getSignatures(topicKey, logFetchLimit, signatures != null ? signatures[signatures.length - 1].signature : null);
47
+ if (abortSignal != null)
48
+ abortSignal.throwIfAborted();
49
+ const result = await processor(signatures);
50
+ if (result != null)
51
+ return result;
52
+ if (signatures.length < logFetchLimit)
53
+ break;
54
+ }
55
+ return null;
56
+ }
57
+ }
58
+ exports.SolanaEvents = SolanaEvents;
@@ -1,121 +1,121 @@
1
- /// <reference types="node" />
2
- import { Connection, PublicKey, SendOptions, Transaction } from "@solana/web3.js";
3
- export type FeeBribeData = {
4
- address: string;
5
- endpoint: string;
6
- getBribeFee?: (original: bigint) => bigint;
7
- };
8
- export declare class SolanaFees {
9
- private readonly connection;
10
- private readonly maxFeeMicroLamports;
11
- private readonly numSamples;
12
- private readonly period;
13
- private useHeliusApi;
14
- private heliusApiSupported;
15
- private readonly heliusFeeLevel;
16
- private readonly bribeData?;
17
- private readonly getStaticFee?;
18
- private readonly logger;
19
- private blockFeeCache;
20
- constructor(connection: Connection, maxFeeMicroLamports?: number, numSamples?: number, period?: number, useHeliusApi?: "yes" | "no" | "auto", heliusFeeLevel?: "min" | "low" | "medium" | "high" | "veryHigh" | "unsafeMax", getStaticFee?: (feeRate: bigint) => bigint, bribeData?: FeeBribeData);
21
- /**
22
- * Returns solana block with transactionDetails="signatures"
23
- *
24
- * @param slot
25
- * @private
26
- */
27
- private getBlockWithSignature;
28
- /**
29
- * Returns fee estimate from Helius API - only works with Helius RPC, return null for all other RPC providers
30
- *
31
- * @param mutableAccounts
32
- * @private
33
- */
34
- private getPriorityFeeEstimate;
35
- /**
36
- * Sends the transaction over Jito
37
- *
38
- * @param tx
39
- * @param options
40
- * @private
41
- * @returns {Promise<string>} transaction signature
42
- */
43
- private sendJitoTx;
44
- /**
45
- * Checks whether the transaction should be sent over Jito, returns the fee paid to Jito in case the transaction
46
- * should be sent over Jito, returns null if the transaction shouldn't be sent over Jito
47
- *
48
- * @param parsedTx
49
- * @private
50
- */
51
- private getJitoTxFee;
52
- /**
53
- * Gets the mean microLamports/CU fee rate for the block at a specific slot
54
- *
55
- * @param slot
56
- * @private
57
- */
58
- private getBlockMeanFeeRate;
59
- /**
60
- * Manually gets global fee rate by sampling random blocks over the last period
61
- *
62
- * @private
63
- * @returns {Promise<BN>} sampled mean microLamports/CU fee over the last period
64
- */
65
- private _getGlobalFeeRate;
66
- /**
67
- * Gets the combined microLamports/CU fee rate (from localized & global fee market)
68
- *
69
- * @param mutableAccounts
70
- * @private
71
- */
72
- private _getFeeRate;
73
- /**
74
- * Gets global fee rate, with caching
75
- *
76
- * @returns {Promise<BN>} global fee rate microLamports/CU
77
- */
78
- getGlobalFeeRate(): Promise<bigint>;
79
- /**
80
- * Gets the combined microLamports/CU fee rate (from localized & global fee market), cached & adjusted as for
81
- * when bribe and/or static fee should be included, format: <uLamports/CU>;<static fee lamport>[;<bribe address>]
82
- *
83
- * @param mutableAccounts
84
- * @private
85
- */
86
- getFeeRate(mutableAccounts: PublicKey[]): Promise<string>;
87
- /**
88
- * Calculates the total priority fee paid for a given compute budget at a given fee rate
89
- *
90
- * @param computeUnits
91
- * @param feeRate
92
- * @param includeStaticFee whether the include the static/base part of the fee rate
93
- */
94
- getPriorityFee(computeUnits: number, feeRate: string, includeStaticFee?: boolean): bigint;
95
- /**
96
- * Applies fee rate to a transaction at the beginning of the transaction (has to be called after
97
- * feePayer is set for the tx), specifically adds the setComputeUnitLimit & setComputeUnitPrice instruction
98
- *
99
- * @param tx
100
- * @param computeBudget
101
- * @param feeRate
102
- */
103
- applyFeeRateBegin(tx: Transaction, computeBudget: number, feeRate: string): boolean;
104
- /**
105
- * Applies fee rate to the end of the transaction (has to be called after feePayer is set for the tx),
106
- * specifically adds the bribe SystemProgram.transfer instruction
107
- *
108
- * @param tx
109
- * @param computeBudget
110
- * @param feeRate
111
- */
112
- applyFeeRateEnd(tx: Transaction, computeBudget: number, feeRate: string): boolean;
113
- /**
114
- * Checks if the transaction should be submitted over Jito and if yes submits it
115
- *
116
- * @param tx
117
- * @param options
118
- * @returns {Promise<string | null>} null if the transaction was not sent over Jito, tx signature when tx was sent over Jito
119
- */
120
- submitTx(tx: Buffer, options?: SendOptions): Promise<string | null>;
121
- }
1
+ /// <reference types="node" />
2
+ import { Connection, PublicKey, SendOptions, Transaction } from "@solana/web3.js";
3
+ export type FeeBribeData = {
4
+ address: string;
5
+ endpoint: string;
6
+ getBribeFee?: (original: bigint) => bigint;
7
+ };
8
+ export declare class SolanaFees {
9
+ private readonly connection;
10
+ private readonly maxFeeMicroLamports;
11
+ private readonly numSamples;
12
+ private readonly period;
13
+ private useHeliusApi;
14
+ private heliusApiSupported;
15
+ private readonly heliusFeeLevel;
16
+ private readonly bribeData?;
17
+ private readonly getStaticFee?;
18
+ private readonly logger;
19
+ private blockFeeCache;
20
+ constructor(connection: Connection, maxFeeMicroLamports?: number, numSamples?: number, period?: number, useHeliusApi?: "yes" | "no" | "auto", heliusFeeLevel?: "min" | "low" | "medium" | "high" | "veryHigh" | "unsafeMax", getStaticFee?: (feeRate: bigint) => bigint, bribeData?: FeeBribeData);
21
+ /**
22
+ * Returns solana block with transactionDetails="signatures"
23
+ *
24
+ * @param slot
25
+ * @private
26
+ */
27
+ private getBlockWithSignature;
28
+ /**
29
+ * Returns fee estimate from Helius API - only works with Helius RPC, return null for all other RPC providers
30
+ *
31
+ * @param mutableAccounts
32
+ * @private
33
+ */
34
+ private getPriorityFeeEstimate;
35
+ /**
36
+ * Sends the transaction over Jito
37
+ *
38
+ * @param tx
39
+ * @param options
40
+ * @private
41
+ * @returns {Promise<string>} transaction signature
42
+ */
43
+ private sendJitoTx;
44
+ /**
45
+ * Checks whether the transaction should be sent over Jito, returns the fee paid to Jito in case the transaction
46
+ * should be sent over Jito, returns null if the transaction shouldn't be sent over Jito
47
+ *
48
+ * @param parsedTx
49
+ * @private
50
+ */
51
+ private getJitoTxFee;
52
+ /**
53
+ * Gets the mean microLamports/CU fee rate for the block at a specific slot
54
+ *
55
+ * @param slot
56
+ * @private
57
+ */
58
+ private getBlockMeanFeeRate;
59
+ /**
60
+ * Manually gets global fee rate by sampling random blocks over the last period
61
+ *
62
+ * @private
63
+ * @returns {Promise<BN>} sampled mean microLamports/CU fee over the last period
64
+ */
65
+ private _getGlobalFeeRate;
66
+ /**
67
+ * Gets the combined microLamports/CU fee rate (from localized & global fee market)
68
+ *
69
+ * @param mutableAccounts
70
+ * @private
71
+ */
72
+ private _getFeeRate;
73
+ /**
74
+ * Gets global fee rate, with caching
75
+ *
76
+ * @returns {Promise<BN>} global fee rate microLamports/CU
77
+ */
78
+ getGlobalFeeRate(): Promise<bigint>;
79
+ /**
80
+ * Gets the combined microLamports/CU fee rate (from localized & global fee market), cached & adjusted as for
81
+ * when bribe and/or static fee should be included, format: <uLamports/CU>;<static fee lamport>[;<bribe address>]
82
+ *
83
+ * @param mutableAccounts
84
+ * @private
85
+ */
86
+ getFeeRate(mutableAccounts: PublicKey[]): Promise<string>;
87
+ /**
88
+ * Calculates the total priority fee paid for a given compute budget at a given fee rate
89
+ *
90
+ * @param computeUnits
91
+ * @param feeRate
92
+ * @param includeStaticFee whether the include the static/base part of the fee rate
93
+ */
94
+ getPriorityFee(computeUnits: number, feeRate: string, includeStaticFee?: boolean): bigint;
95
+ /**
96
+ * Applies fee rate to a transaction at the beginning of the transaction (has to be called after
97
+ * feePayer is set for the tx), specifically adds the setComputeUnitLimit & setComputeUnitPrice instruction
98
+ *
99
+ * @param tx
100
+ * @param computeBudget
101
+ * @param feeRate
102
+ */
103
+ applyFeeRateBegin(tx: Transaction, computeBudget: number, feeRate: string): boolean;
104
+ /**
105
+ * Applies fee rate to the end of the transaction (has to be called after feePayer is set for the tx),
106
+ * specifically adds the bribe SystemProgram.transfer instruction
107
+ *
108
+ * @param tx
109
+ * @param computeBudget
110
+ * @param feeRate
111
+ */
112
+ applyFeeRateEnd(tx: Transaction, computeBudget: number, feeRate: string): boolean;
113
+ /**
114
+ * Checks if the transaction should be submitted over Jito and if yes submits it
115
+ *
116
+ * @param tx
117
+ * @param options
118
+ * @returns {Promise<string | null>} null if the transaction was not sent over Jito, tx signature when tx was sent over Jito
119
+ */
120
+ submitTx(tx: Buffer, options?: SendOptions): Promise<string | null>;
121
+ }