@atomiqlabs/chain-solana 13.5.13 → 13.5.14

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 (131) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +73 -73
  3. package/dist/index.d.ts +81 -81
  4. package/dist/index.js +102 -102
  5. package/dist/node/index.d.ts +9 -9
  6. package/dist/node/index.js +13 -13
  7. package/dist/solana/SolanaChainType.d.ts +15 -15
  8. package/dist/solana/SolanaChainType.js +2 -2
  9. package/dist/solana/SolanaChains.d.ts +12 -12
  10. package/dist/solana/SolanaChains.js +45 -45
  11. package/dist/solana/SolanaInitializer.d.ts +94 -94
  12. package/dist/solana/SolanaInitializer.js +174 -174
  13. package/dist/solana/btcrelay/SolanaBtcRelay.d.ts +222 -222
  14. package/dist/solana/btcrelay/SolanaBtcRelay.js +455 -455
  15. package/dist/solana/btcrelay/headers/SolanaBtcHeader.d.ts +84 -84
  16. package/dist/solana/btcrelay/headers/SolanaBtcHeader.js +70 -70
  17. package/dist/solana/btcrelay/headers/SolanaBtcStoredHeader.d.ts +92 -92
  18. package/dist/solana/btcrelay/headers/SolanaBtcStoredHeader.js +109 -109
  19. package/dist/solana/btcrelay/program/programIdl.json +671 -671
  20. package/dist/solana/chain/SolanaAction.d.ts +26 -26
  21. package/dist/solana/chain/SolanaAction.js +87 -87
  22. package/dist/solana/chain/SolanaChainInterface.d.ts +224 -224
  23. package/dist/solana/chain/SolanaChainInterface.js +275 -275
  24. package/dist/solana/chain/SolanaModule.d.ts +14 -14
  25. package/dist/solana/chain/SolanaModule.js +13 -13
  26. package/dist/solana/chain/modules/SolanaAddresses.d.ts +8 -8
  27. package/dist/solana/chain/modules/SolanaAddresses.js +22 -22
  28. package/dist/solana/chain/modules/SolanaBlocks.d.ts +32 -32
  29. package/dist/solana/chain/modules/SolanaBlocks.js +78 -78
  30. package/dist/solana/chain/modules/SolanaEvents.d.ts +68 -68
  31. package/dist/solana/chain/modules/SolanaEvents.js +238 -238
  32. package/dist/solana/chain/modules/SolanaFees.d.ts +189 -189
  33. package/dist/solana/chain/modules/SolanaFees.js +434 -434
  34. package/dist/solana/chain/modules/SolanaSignatures.d.ts +24 -24
  35. package/dist/solana/chain/modules/SolanaSignatures.js +39 -39
  36. package/dist/solana/chain/modules/SolanaSlots.d.ts +33 -33
  37. package/dist/solana/chain/modules/SolanaSlots.js +72 -72
  38. package/dist/solana/chain/modules/SolanaTokens.d.ts +123 -123
  39. package/dist/solana/chain/modules/SolanaTokens.js +242 -242
  40. package/dist/solana/chain/modules/SolanaTransactions.d.ts +149 -149
  41. package/dist/solana/chain/modules/SolanaTransactions.js +445 -445
  42. package/dist/solana/connection/ConnectionWithRetries.d.ts +35 -35
  43. package/dist/solana/connection/ConnectionWithRetries.js +86 -71
  44. package/dist/solana/events/SolanaChainEvents.d.ts +45 -45
  45. package/dist/solana/events/SolanaChainEvents.js +108 -108
  46. package/dist/solana/events/SolanaChainEventsBrowser.d.ts +205 -205
  47. package/dist/solana/events/SolanaChainEventsBrowser.js +404 -404
  48. package/dist/solana/program/SolanaProgramBase.d.ts +73 -73
  49. package/dist/solana/program/SolanaProgramBase.js +54 -54
  50. package/dist/solana/program/SolanaProgramModule.d.ts +8 -8
  51. package/dist/solana/program/SolanaProgramModule.js +11 -11
  52. package/dist/solana/program/modules/SolanaProgramEvents.d.ts +53 -53
  53. package/dist/solana/program/modules/SolanaProgramEvents.js +117 -117
  54. package/dist/solana/swaps/SolanaSwapData.d.ts +333 -333
  55. package/dist/solana/swaps/SolanaSwapData.js +535 -535
  56. package/dist/solana/swaps/SolanaSwapModule.d.ts +11 -11
  57. package/dist/solana/swaps/SolanaSwapModule.js +12 -12
  58. package/dist/solana/swaps/SolanaSwapProgram.d.ts +376 -376
  59. package/dist/solana/swaps/SolanaSwapProgram.js +769 -769
  60. package/dist/solana/swaps/SwapTypeEnum.d.ts +11 -11
  61. package/dist/solana/swaps/SwapTypeEnum.js +43 -43
  62. package/dist/solana/swaps/modules/SolanaDataAccount.d.ts +95 -95
  63. package/dist/solana/swaps/modules/SolanaDataAccount.js +232 -232
  64. package/dist/solana/swaps/modules/SolanaLpVault.d.ts +69 -69
  65. package/dist/solana/swaps/modules/SolanaLpVault.js +171 -171
  66. package/dist/solana/swaps/modules/SwapClaim.d.ts +126 -126
  67. package/dist/solana/swaps/modules/SwapClaim.js +294 -294
  68. package/dist/solana/swaps/modules/SwapInit.d.ts +213 -213
  69. package/dist/solana/swaps/modules/SwapInit.js +658 -658
  70. package/dist/solana/swaps/modules/SwapRefund.d.ts +87 -87
  71. package/dist/solana/swaps/modules/SwapRefund.js +293 -293
  72. package/dist/solana/swaps/programIdl.json +945 -945
  73. package/dist/solana/swaps/programTypes.d.ts +943 -943
  74. package/dist/solana/swaps/programTypes.js +945 -945
  75. package/dist/solana/swaps/v1/programIdl.json +945 -945
  76. package/dist/solana/swaps/v1/programTypes.d.ts +943 -943
  77. package/dist/solana/swaps/v1/programTypes.js +945 -945
  78. package/dist/solana/swaps/v2/programIdl.json +952 -952
  79. package/dist/solana/swaps/v2/programTypes.d.ts +950 -950
  80. package/dist/solana/swaps/v2/programTypes.js +952 -952
  81. package/dist/solana/wallet/SolanaKeypairWallet.d.ts +29 -29
  82. package/dist/solana/wallet/SolanaKeypairWallet.js +50 -50
  83. package/dist/solana/wallet/SolanaSigner.d.ts +30 -30
  84. package/dist/solana/wallet/SolanaSigner.js +30 -30
  85. package/dist/utils/Utils.d.ts +58 -58
  86. package/dist/utils/Utils.js +170 -170
  87. package/node/index.d.ts +1 -1
  88. package/node/index.js +3 -3
  89. package/package.json +46 -46
  90. package/src/index.ts +87 -87
  91. package/src/node/index.ts +9 -9
  92. package/src/solana/SolanaChainType.ts +32 -32
  93. package/src/solana/SolanaChains.ts +46 -46
  94. package/src/solana/SolanaInitializer.ts +278 -278
  95. package/src/solana/btcrelay/SolanaBtcRelay.ts +615 -615
  96. package/src/solana/btcrelay/headers/SolanaBtcHeader.ts +116 -116
  97. package/src/solana/btcrelay/headers/SolanaBtcStoredHeader.ts +148 -148
  98. package/src/solana/btcrelay/program/programIdl.json +670 -670
  99. package/src/solana/chain/SolanaAction.ts +109 -109
  100. package/src/solana/chain/SolanaChainInterface.ts +404 -404
  101. package/src/solana/chain/SolanaModule.ts +20 -20
  102. package/src/solana/chain/modules/SolanaAddresses.ts +20 -20
  103. package/src/solana/chain/modules/SolanaBlocks.ts +89 -89
  104. package/src/solana/chain/modules/SolanaEvents.ts +271 -271
  105. package/src/solana/chain/modules/SolanaFees.ts +522 -522
  106. package/src/solana/chain/modules/SolanaSignatures.ts +39 -39
  107. package/src/solana/chain/modules/SolanaSlots.ts +85 -85
  108. package/src/solana/chain/modules/SolanaTokens.ts +300 -300
  109. package/src/solana/chain/modules/SolanaTransactions.ts +503 -503
  110. package/src/solana/connection/ConnectionWithRetries.ts +113 -96
  111. package/src/solana/events/SolanaChainEvents.ts +127 -127
  112. package/src/solana/events/SolanaChainEventsBrowser.ts +495 -495
  113. package/src/solana/program/SolanaProgramBase.ts +119 -119
  114. package/src/solana/program/SolanaProgramModule.ts +15 -15
  115. package/src/solana/program/modules/SolanaProgramEvents.ts +157 -157
  116. package/src/solana/swaps/SolanaSwapData.ts +735 -735
  117. package/src/solana/swaps/SolanaSwapModule.ts +19 -19
  118. package/src/solana/swaps/SolanaSwapProgram.ts +1074 -1074
  119. package/src/solana/swaps/SwapTypeEnum.ts +30 -30
  120. package/src/solana/swaps/modules/SolanaDataAccount.ts +302 -302
  121. package/src/solana/swaps/modules/SolanaLpVault.ts +208 -208
  122. package/src/solana/swaps/modules/SwapClaim.ts +387 -387
  123. package/src/solana/swaps/modules/SwapInit.ts +785 -785
  124. package/src/solana/swaps/modules/SwapRefund.ts +353 -353
  125. package/src/solana/swaps/v1/programIdl.json +944 -944
  126. package/src/solana/swaps/v1/programTypes.ts +1885 -1885
  127. package/src/solana/swaps/v2/programIdl.json +951 -951
  128. package/src/solana/swaps/v2/programTypes.ts +1899 -1899
  129. package/src/solana/wallet/SolanaKeypairWallet.ts +56 -56
  130. package/src/solana/wallet/SolanaSigner.ts +43 -43
  131. package/src/utils/Utils.ts +194 -194
@@ -1,24 +1,24 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { SolanaModule } from "../SolanaModule";
4
- import { Buffer } from "buffer";
5
- import { SolanaSigner } from "../../wallet/SolanaSigner";
6
- export declare class SolanaSignatures extends SolanaModule {
7
- /**
8
- * Produces an ed25519 signature over the sha256 of a specified data Buffer, only works with providers which
9
- * expose their private key (i.e. backend based, not browser wallet based)
10
- *
11
- * @param signer
12
- * @param data data to sign
13
- */
14
- getDataSignature(signer: SolanaSigner, data: Buffer): Promise<string>;
15
- /**
16
- * Checks whether a signature is a valid Ed25519 signature produced by publicKey over a data message (computes
17
- * sha256 hash of the message)
18
- *
19
- * @param data signed data
20
- * @param signature data signature
21
- * @param publicKey public key of the signer
22
- */
23
- isValidDataSignature(data: Buffer, signature: string, publicKey: string): Promise<boolean>;
24
- }
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { SolanaModule } from "../SolanaModule";
4
+ import { Buffer } from "buffer";
5
+ import { SolanaSigner } from "../../wallet/SolanaSigner";
6
+ export declare class SolanaSignatures extends SolanaModule {
7
+ /**
8
+ * Produces an ed25519 signature over the sha256 of a specified data Buffer, only works with providers which
9
+ * expose their private key (i.e. backend based, not browser wallet based)
10
+ *
11
+ * @param signer
12
+ * @param data data to sign
13
+ */
14
+ getDataSignature(signer: SolanaSigner, data: Buffer): Promise<string>;
15
+ /**
16
+ * Checks whether a signature is a valid Ed25519 signature produced by publicKey over a data message (computes
17
+ * sha256 hash of the message)
18
+ *
19
+ * @param data signed data
20
+ * @param signature data signature
21
+ * @param publicKey public key of the signer
22
+ */
23
+ isValidDataSignature(data: Buffer, signature: string, publicKey: string): Promise<boolean>;
24
+ }
@@ -1,39 +1,39 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SolanaSignatures = void 0;
4
- const SolanaModule_1 = require("../SolanaModule");
5
- const tweetnacl_1 = require("tweetnacl");
6
- const web3_js_1 = require("@solana/web3.js");
7
- const buffer_1 = require("buffer");
8
- const sha2_1 = require("@noble/hashes/sha2");
9
- class SolanaSignatures extends SolanaModule_1.SolanaModule {
10
- ///////////////////
11
- //// Data signatures
12
- /**
13
- * Produces an ed25519 signature over the sha256 of a specified data Buffer, only works with providers which
14
- * expose their private key (i.e. backend based, not browser wallet based)
15
- *
16
- * @param signer
17
- * @param data data to sign
18
- */
19
- getDataSignature(signer, data) {
20
- if (signer.keypair == null)
21
- throw new Error("Unsupported");
22
- const buff = (0, sha2_1.sha256)(data);
23
- const signature = tweetnacl_1.sign.detached(buff, signer.keypair.secretKey);
24
- return Promise.resolve(buffer_1.Buffer.from(signature).toString("hex"));
25
- }
26
- /**
27
- * Checks whether a signature is a valid Ed25519 signature produced by publicKey over a data message (computes
28
- * sha256 hash of the message)
29
- *
30
- * @param data signed data
31
- * @param signature data signature
32
- * @param publicKey public key of the signer
33
- */
34
- isValidDataSignature(data, signature, publicKey) {
35
- const hash = (0, sha2_1.sha256)(data);
36
- return Promise.resolve(tweetnacl_1.sign.detached.verify(hash, buffer_1.Buffer.from(signature, "hex"), new web3_js_1.PublicKey(publicKey).toBuffer()));
37
- }
38
- }
39
- exports.SolanaSignatures = SolanaSignatures;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SolanaSignatures = void 0;
4
+ const SolanaModule_1 = require("../SolanaModule");
5
+ const tweetnacl_1 = require("tweetnacl");
6
+ const web3_js_1 = require("@solana/web3.js");
7
+ const buffer_1 = require("buffer");
8
+ const sha2_1 = require("@noble/hashes/sha2");
9
+ class SolanaSignatures extends SolanaModule_1.SolanaModule {
10
+ ///////////////////
11
+ //// Data signatures
12
+ /**
13
+ * Produces an ed25519 signature over the sha256 of a specified data Buffer, only works with providers which
14
+ * expose their private key (i.e. backend based, not browser wallet based)
15
+ *
16
+ * @param signer
17
+ * @param data data to sign
18
+ */
19
+ getDataSignature(signer, data) {
20
+ if (signer.keypair == null)
21
+ throw new Error("Unsupported");
22
+ const buff = (0, sha2_1.sha256)(data);
23
+ const signature = tweetnacl_1.sign.detached(buff, signer.keypair.secretKey);
24
+ return Promise.resolve(buffer_1.Buffer.from(signature).toString("hex"));
25
+ }
26
+ /**
27
+ * Checks whether a signature is a valid Ed25519 signature produced by publicKey over a data message (computes
28
+ * sha256 hash of the message)
29
+ *
30
+ * @param data signed data
31
+ * @param signature data signature
32
+ * @param publicKey public key of the signer
33
+ */
34
+ isValidDataSignature(data, signature, publicKey) {
35
+ const hash = (0, sha2_1.sha256)(data);
36
+ return Promise.resolve(tweetnacl_1.sign.detached.verify(hash, buffer_1.Buffer.from(signature, "hex"), new web3_js_1.PublicKey(publicKey).toBuffer()));
37
+ }
38
+ }
39
+ exports.SolanaSignatures = SolanaSignatures;
@@ -1,33 +1,33 @@
1
- import { SolanaModule } from "../SolanaModule";
2
- import { Commitment } from "@solana/web3.js";
3
- export declare class SolanaSlots extends SolanaModule {
4
- readonly SLOT_CACHE_SLOTS = 12;
5
- readonly SLOT_CACHE_TIME: number;
6
- private slotCache;
7
- /**
8
- * Initiates fetch of a given slot & saves it to cache
9
- *
10
- * @param commitment
11
- * @private
12
- */
13
- private fetchAndSaveSlot;
14
- /**
15
- * Gets the latest slot for a given commitment, with the timestamp of when that slot was actually retrieved from
16
- * the RPC (useful for when slots are cached), does no estimation on the current slot number based on cached value
17
- *
18
- * @param commitment
19
- */
20
- getSlotAndTimestamp(commitment: Commitment): Promise<{
21
- slot: number;
22
- timestamp: number;
23
- }>;
24
- /**
25
- * Gets the slot for a given commitment, uses slot cache & tries to estimate current slot based on the cached
26
- * value, cache has relatively short expiry of just 12 slots (4.8 seconds)
27
- *
28
- * @remarks Doesn't try to extrapolate the slot number for `finalized` commitment level
29
- *
30
- * @param commitment
31
- */
32
- getSlot(commitment: Commitment): Promise<number>;
33
- }
1
+ import { SolanaModule } from "../SolanaModule";
2
+ import { Commitment } from "@solana/web3.js";
3
+ export declare class SolanaSlots extends SolanaModule {
4
+ readonly SLOT_CACHE_SLOTS = 12;
5
+ readonly SLOT_CACHE_TIME: number;
6
+ private slotCache;
7
+ /**
8
+ * Initiates fetch of a given slot & saves it to cache
9
+ *
10
+ * @param commitment
11
+ * @private
12
+ */
13
+ private fetchAndSaveSlot;
14
+ /**
15
+ * Gets the latest slot for a given commitment, with the timestamp of when that slot was actually retrieved from
16
+ * the RPC (useful for when slots are cached), does no estimation on the current slot number based on cached value
17
+ *
18
+ * @param commitment
19
+ */
20
+ getSlotAndTimestamp(commitment: Commitment): Promise<{
21
+ slot: number;
22
+ timestamp: number;
23
+ }>;
24
+ /**
25
+ * Gets the slot for a given commitment, uses slot cache & tries to estimate current slot based on the cached
26
+ * value, cache has relatively short expiry of just 12 slots (4.8 seconds)
27
+ *
28
+ * @remarks Doesn't try to extrapolate the slot number for `finalized` commitment level
29
+ *
30
+ * @param commitment
31
+ */
32
+ getSlot(commitment: Commitment): Promise<number>;
33
+ }
@@ -1,72 +1,72 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SolanaSlots = void 0;
4
- const SolanaModule_1 = require("../SolanaModule");
5
- class SolanaSlots extends SolanaModule_1.SolanaModule {
6
- constructor() {
7
- super(...arguments);
8
- this.SLOT_CACHE_SLOTS = 12;
9
- this.SLOT_CACHE_TIME = this.SLOT_CACHE_SLOTS * this.root._SLOT_TIME;
10
- this.slotCache = {};
11
- }
12
- /**
13
- * Initiates fetch of a given slot & saves it to cache
14
- *
15
- * @param commitment
16
- * @private
17
- */
18
- fetchAndSaveSlot(commitment) {
19
- const slotPromise = this.connection.getSlot(commitment);
20
- const timestamp = Date.now();
21
- this.slotCache[commitment] = {
22
- slot: slotPromise,
23
- timestamp
24
- };
25
- slotPromise.catch(() => {
26
- const slotCache = this.slotCache[commitment];
27
- if (slotCache != null && slotCache.slot === slotPromise)
28
- delete this.slotCache[commitment];
29
- });
30
- return {
31
- slot: slotPromise,
32
- timestamp
33
- };
34
- }
35
- ///////////////////
36
- //// Slots
37
- /**
38
- * Gets the latest slot for a given commitment, with the timestamp of when that slot was actually retrieved from
39
- * the RPC (useful for when slots are cached), does no estimation on the current slot number based on cached value
40
- *
41
- * @param commitment
42
- */
43
- async getSlotAndTimestamp(commitment) {
44
- let cachedSlotData = this.slotCache[commitment];
45
- if (cachedSlotData == null || Date.now() - cachedSlotData.timestamp > this.SLOT_CACHE_TIME) {
46
- cachedSlotData = this.fetchAndSaveSlot(commitment);
47
- }
48
- return {
49
- slot: await cachedSlotData.slot,
50
- timestamp: cachedSlotData.timestamp
51
- };
52
- }
53
- /**
54
- * Gets the slot for a given commitment, uses slot cache & tries to estimate current slot based on the cached
55
- * value, cache has relatively short expiry of just 12 slots (4.8 seconds)
56
- *
57
- * @remarks Doesn't try to extrapolate the slot number for `finalized` commitment level
58
- *
59
- * @param commitment
60
- */
61
- async getSlot(commitment) {
62
- let cachedSlotData = this.slotCache[commitment];
63
- if (cachedSlotData != null && Date.now() - cachedSlotData.timestamp < this.SLOT_CACHE_TIME) {
64
- if (commitment === "finalized")
65
- return await cachedSlotData.slot;
66
- return (await cachedSlotData.slot) + Math.floor((Date.now() - cachedSlotData.timestamp) / this.root._SLOT_TIME);
67
- }
68
- cachedSlotData = this.fetchAndSaveSlot(commitment);
69
- return await cachedSlotData.slot;
70
- }
71
- }
72
- exports.SolanaSlots = SolanaSlots;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SolanaSlots = void 0;
4
+ const SolanaModule_1 = require("../SolanaModule");
5
+ class SolanaSlots extends SolanaModule_1.SolanaModule {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.SLOT_CACHE_SLOTS = 12;
9
+ this.SLOT_CACHE_TIME = this.SLOT_CACHE_SLOTS * this.root._SLOT_TIME;
10
+ this.slotCache = {};
11
+ }
12
+ /**
13
+ * Initiates fetch of a given slot & saves it to cache
14
+ *
15
+ * @param commitment
16
+ * @private
17
+ */
18
+ fetchAndSaveSlot(commitment) {
19
+ const slotPromise = this.connection.getSlot(commitment);
20
+ const timestamp = Date.now();
21
+ this.slotCache[commitment] = {
22
+ slot: slotPromise,
23
+ timestamp
24
+ };
25
+ slotPromise.catch(() => {
26
+ const slotCache = this.slotCache[commitment];
27
+ if (slotCache != null && slotCache.slot === slotPromise)
28
+ delete this.slotCache[commitment];
29
+ });
30
+ return {
31
+ slot: slotPromise,
32
+ timestamp
33
+ };
34
+ }
35
+ ///////////////////
36
+ //// Slots
37
+ /**
38
+ * Gets the latest slot for a given commitment, with the timestamp of when that slot was actually retrieved from
39
+ * the RPC (useful for when slots are cached), does no estimation on the current slot number based on cached value
40
+ *
41
+ * @param commitment
42
+ */
43
+ async getSlotAndTimestamp(commitment) {
44
+ let cachedSlotData = this.slotCache[commitment];
45
+ if (cachedSlotData == null || Date.now() - cachedSlotData.timestamp > this.SLOT_CACHE_TIME) {
46
+ cachedSlotData = this.fetchAndSaveSlot(commitment);
47
+ }
48
+ return {
49
+ slot: await cachedSlotData.slot,
50
+ timestamp: cachedSlotData.timestamp
51
+ };
52
+ }
53
+ /**
54
+ * Gets the slot for a given commitment, uses slot cache & tries to estimate current slot based on the cached
55
+ * value, cache has relatively short expiry of just 12 slots (4.8 seconds)
56
+ *
57
+ * @remarks Doesn't try to extrapolate the slot number for `finalized` commitment level
58
+ *
59
+ * @param commitment
60
+ */
61
+ async getSlot(commitment) {
62
+ let cachedSlotData = this.slotCache[commitment];
63
+ if (cachedSlotData != null && Date.now() - cachedSlotData.timestamp < this.SLOT_CACHE_TIME) {
64
+ if (commitment === "finalized")
65
+ return await cachedSlotData.slot;
66
+ return (await cachedSlotData.slot) + Math.floor((Date.now() - cachedSlotData.timestamp) / this.root._SLOT_TIME);
67
+ }
68
+ cachedSlotData = this.fetchAndSaveSlot(commitment);
69
+ return await cachedSlotData.slot;
70
+ }
71
+ }
72
+ exports.SolanaSlots = SolanaSlots;
@@ -1,123 +1,123 @@
1
- import { SolanaModule } from "../SolanaModule";
2
- import { PublicKey } from "@solana/web3.js";
3
- import { Account } from "@solana/spl-token";
4
- import { SolanaTx } from "./SolanaTransactions";
5
- import { SolanaAction } from "../SolanaAction";
6
- export declare class SolanaTokens extends SolanaModule {
7
- static readonly CUCosts: {
8
- WRAP_SOL: number;
9
- ATA_CLOSE: number;
10
- ATA_INIT: number;
11
- TRANSFER: number;
12
- TRANSFER_SOL: number;
13
- };
14
- InitAta(signer: PublicKey, publicKey: PublicKey, token: PublicKey): SolanaAction;
15
- InitAta(signer: PublicKey, publicKey: PublicKey, token: PublicKey, requiredAta?: PublicKey): SolanaAction | null;
16
- /**
17
- * Action for wrapping SOL to WSOL for a specific public key
18
- *
19
- * @param publicKey public key of the user for which to wrap the SOL
20
- * @param amount amount of SOL in lamports (smallest unit) to wrap
21
- * @param initAta whether we should also initialize the ATA before depositing SOL
22
- */
23
- Wrap(publicKey: PublicKey, amount: bigint, initAta: boolean): SolanaAction;
24
- /**
25
- * Action for unwrapping WSOL to SOL for a specific public key
26
- *
27
- * @param publicKey public key of the user for which to unwrap the sol
28
- */
29
- Unwrap(publicKey: PublicKey): SolanaAction;
30
- static readonly WSOL_ADDRESS: PublicKey;
31
- static readonly SPL_ATA_RENT_EXEMPT = 2039280;
32
- /**
33
- * Action for transferring the native SOL token, uses provider's public key as a sender
34
- *
35
- * @param signer
36
- * @param recipient
37
- * @param amount
38
- * @private
39
- */
40
- private SolTransfer;
41
- /**
42
- * Action for transferring the SPL token, uses provider's public key as a sender
43
- *
44
- * @param signer
45
- * @param recipient
46
- * @param token
47
- * @param amount
48
- * @private
49
- */
50
- private Transfer;
51
- /**
52
- * Creates transactions for sending SOL (the native token)
53
- *
54
- * @param signer
55
- * @param amount amount of the SOL in lamports (smallest unit) to send
56
- * @param recipient recipient's address
57
- * @param feeRate fee rate to use for the transactions
58
- * @private
59
- */
60
- private txsTransferSol;
61
- /**
62
- * Creates transactions for sending the over the tokens
63
- *
64
- * @param signer
65
- * @param token token to send
66
- * @param amount amount of the token to send
67
- * @param recipient recipient's address
68
- * @param feeRate fee rate to use for the transactions
69
- * @private
70
- */
71
- private txsTransferTokens;
72
- /**
73
- * Checks if the provided string is a valid solana token
74
- *
75
- * @param token
76
- */
77
- isValidToken(token: string): boolean;
78
- /**
79
- * Returns the specific ATA or null if it doesn't exist
80
- *
81
- * @param ata
82
- */
83
- getATAOrNull(ata: PublicKey): Promise<Account | null>;
84
- /**
85
- * Checks whether the specific ATA exists, uses tryWithRetries so retries on failure
86
- *
87
- * @param ata
88
- */
89
- ataExists(ata: PublicKey): Promise<boolean>;
90
- /**
91
- * Returns the rent exempt deposit required to initiate the ATA
92
- */
93
- getATARentExemptLamports(): Promise<bigint>;
94
- /**
95
- * Returns the token balance of the public key
96
- *
97
- * @param publicKey
98
- * @param token
99
- */
100
- getTokenBalance(publicKey: PublicKey, token: PublicKey): Promise<{
101
- balance: bigint;
102
- ataExists: boolean;
103
- }>;
104
- /**
105
- * Returns the native currency address, we use WSOL address as placeholder for SOL
106
- */
107
- getNativeCurrencyAddress(): PublicKey;
108
- /**
109
- * Parses string base58 representation of the token address to a PublicKey object
110
- * @param address
111
- */
112
- toTokenAddress(address: string): PublicKey;
113
- /**
114
- * Create transactions for sending a specific token to a destination address
115
- *
116
- * @param signer
117
- * @param token token to use for the transfer
118
- * @param amount amount of token in base units to transfer
119
- * @param dstAddress destination address of the recipient
120
- * @param feeRate fee rate to use for the transaction
121
- */
122
- txsTransfer(signer: PublicKey, token: PublicKey, amount: bigint, dstAddress: PublicKey, feeRate?: string): Promise<SolanaTx[]>;
123
- }
1
+ import { SolanaModule } from "../SolanaModule";
2
+ import { PublicKey } from "@solana/web3.js";
3
+ import { Account } from "@solana/spl-token";
4
+ import { SolanaTx } from "./SolanaTransactions";
5
+ import { SolanaAction } from "../SolanaAction";
6
+ export declare class SolanaTokens extends SolanaModule {
7
+ static readonly CUCosts: {
8
+ WRAP_SOL: number;
9
+ ATA_CLOSE: number;
10
+ ATA_INIT: number;
11
+ TRANSFER: number;
12
+ TRANSFER_SOL: number;
13
+ };
14
+ InitAta(signer: PublicKey, publicKey: PublicKey, token: PublicKey): SolanaAction;
15
+ InitAta(signer: PublicKey, publicKey: PublicKey, token: PublicKey, requiredAta?: PublicKey): SolanaAction | null;
16
+ /**
17
+ * Action for wrapping SOL to WSOL for a specific public key
18
+ *
19
+ * @param publicKey public key of the user for which to wrap the SOL
20
+ * @param amount amount of SOL in lamports (smallest unit) to wrap
21
+ * @param initAta whether we should also initialize the ATA before depositing SOL
22
+ */
23
+ Wrap(publicKey: PublicKey, amount: bigint, initAta: boolean): SolanaAction;
24
+ /**
25
+ * Action for unwrapping WSOL to SOL for a specific public key
26
+ *
27
+ * @param publicKey public key of the user for which to unwrap the sol
28
+ */
29
+ Unwrap(publicKey: PublicKey): SolanaAction;
30
+ static readonly WSOL_ADDRESS: PublicKey;
31
+ static readonly SPL_ATA_RENT_EXEMPT = 2039280;
32
+ /**
33
+ * Action for transferring the native SOL token, uses provider's public key as a sender
34
+ *
35
+ * @param signer
36
+ * @param recipient
37
+ * @param amount
38
+ * @private
39
+ */
40
+ private SolTransfer;
41
+ /**
42
+ * Action for transferring the SPL token, uses provider's public key as a sender
43
+ *
44
+ * @param signer
45
+ * @param recipient
46
+ * @param token
47
+ * @param amount
48
+ * @private
49
+ */
50
+ private Transfer;
51
+ /**
52
+ * Creates transactions for sending SOL (the native token)
53
+ *
54
+ * @param signer
55
+ * @param amount amount of the SOL in lamports (smallest unit) to send
56
+ * @param recipient recipient's address
57
+ * @param feeRate fee rate to use for the transactions
58
+ * @private
59
+ */
60
+ private txsTransferSol;
61
+ /**
62
+ * Creates transactions for sending the over the tokens
63
+ *
64
+ * @param signer
65
+ * @param token token to send
66
+ * @param amount amount of the token to send
67
+ * @param recipient recipient's address
68
+ * @param feeRate fee rate to use for the transactions
69
+ * @private
70
+ */
71
+ private txsTransferTokens;
72
+ /**
73
+ * Checks if the provided string is a valid solana token
74
+ *
75
+ * @param token
76
+ */
77
+ isValidToken(token: string): boolean;
78
+ /**
79
+ * Returns the specific ATA or null if it doesn't exist
80
+ *
81
+ * @param ata
82
+ */
83
+ getATAOrNull(ata: PublicKey): Promise<Account | null>;
84
+ /**
85
+ * Checks whether the specific ATA exists, uses tryWithRetries so retries on failure
86
+ *
87
+ * @param ata
88
+ */
89
+ ataExists(ata: PublicKey): Promise<boolean>;
90
+ /**
91
+ * Returns the rent exempt deposit required to initiate the ATA
92
+ */
93
+ getATARentExemptLamports(): Promise<bigint>;
94
+ /**
95
+ * Returns the token balance of the public key
96
+ *
97
+ * @param publicKey
98
+ * @param token
99
+ */
100
+ getTokenBalance(publicKey: PublicKey, token: PublicKey): Promise<{
101
+ balance: bigint;
102
+ ataExists: boolean;
103
+ }>;
104
+ /**
105
+ * Returns the native currency address, we use WSOL address as placeholder for SOL
106
+ */
107
+ getNativeCurrencyAddress(): PublicKey;
108
+ /**
109
+ * Parses string base58 representation of the token address to a PublicKey object
110
+ * @param address
111
+ */
112
+ toTokenAddress(address: string): PublicKey;
113
+ /**
114
+ * Create transactions for sending a specific token to a destination address
115
+ *
116
+ * @param signer
117
+ * @param token token to use for the transfer
118
+ * @param amount amount of token in base units to transfer
119
+ * @param dstAddress destination address of the recipient
120
+ * @param feeRate fee rate to use for the transaction
121
+ */
122
+ txsTransfer(signer: PublicKey, token: PublicKey, amount: bigint, dstAddress: PublicKey, feeRate?: string): Promise<SolanaTx[]>;
123
+ }