@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,170 +1,170 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toBigInt = exports.toBN = exports.toEscrowHash = exports.fromClaimHash = exports.toClaimHash = exports.SolanaTxUtils = exports.tryWithRetries = exports.getLogger = exports.onceAsync = exports.timeoutPromise = void 0;
4
- const web3_js_1 = require("@solana/web3.js");
5
- const BN = require("bn.js");
6
- const buffer_1 = require("buffer");
7
- const sha2_1 = require("@noble/hashes/sha2");
8
- function timeoutPromise(timeoutMillis, abortSignal) {
9
- return new Promise((resolve, reject) => {
10
- const timeout = setTimeout(resolve, timeoutMillis);
11
- if (abortSignal != null)
12
- abortSignal.addEventListener("abort", () => {
13
- clearTimeout(timeout);
14
- reject(new Error("Aborted"));
15
- });
16
- });
17
- }
18
- exports.timeoutPromise = timeoutPromise;
19
- function onceAsync(executor) {
20
- let promise;
21
- return () => {
22
- if (promise == null) {
23
- promise = executor();
24
- return promise;
25
- }
26
- else {
27
- return promise.catch(() => promise = executor());
28
- }
29
- };
30
- }
31
- exports.onceAsync = onceAsync;
32
- function getLogger(prefix) {
33
- return {
34
- debug: (msg, ...args) => global.atomiqLogLevel >= 3 && console.debug(prefix + msg, ...args),
35
- info: (msg, ...args) => global.atomiqLogLevel >= 2 && console.info(prefix + msg, ...args),
36
- warn: (msg, ...args) => (global.atomiqLogLevel == null || global.atomiqLogLevel >= 1) && console.warn(prefix + msg, ...args),
37
- error: (msg, ...args) => (global.atomiqLogLevel == null || global.atomiqLogLevel >= 0) && console.error(prefix + msg, ...args)
38
- };
39
- }
40
- exports.getLogger = getLogger;
41
- const logger = getLogger("Utils: ");
42
- async function tryWithRetries(func, retryPolicy, errorAllowed, abortSignal) {
43
- retryPolicy = retryPolicy || {};
44
- retryPolicy.maxRetries = retryPolicy.maxRetries || 5;
45
- retryPolicy.delay = retryPolicy.delay || 500;
46
- retryPolicy.exponential = retryPolicy.exponential == null ? true : retryPolicy.exponential;
47
- let err = null;
48
- for (let i = 0; i < retryPolicy.maxRetries; i++) {
49
- try {
50
- const resp = await func();
51
- return resp;
52
- }
53
- catch (e) {
54
- if (errorAllowed != null && errorAllowed(e))
55
- throw e;
56
- err = e;
57
- logger.error("tryWithRetries(): error on try number: " + i, e);
58
- }
59
- if (abortSignal != null && abortSignal.aborted)
60
- throw new Error("Aborted");
61
- if (i !== retryPolicy.maxRetries - 1) {
62
- await timeoutPromise(retryPolicy.exponential ? retryPolicy.delay * Math.pow(2, i) : retryPolicy.delay, abortSignal);
63
- }
64
- }
65
- throw err;
66
- }
67
- exports.tryWithRetries = tryWithRetries;
68
- class SolanaTxUtils {
69
- /**
70
- * Compact u16 array header size
71
- * @param n elements in the compact array
72
- * @returns size in bytes of array header
73
- */
74
- static compactHeader(n) {
75
- return (n <= SolanaTxUtils.LOW_VALUE ? 1 : n <= SolanaTxUtils.HIGH_VALUE ? 2 : 3);
76
- }
77
- /**
78
- * Compact u16 array size
79
- * @param n elements in the compact array
80
- * @param size bytes per each element
81
- * @returns size in bytes of array
82
- */
83
- static compactArraySize(n, size) {
84
- return SolanaTxUtils.compactHeader(n) + n * size;
85
- }
86
- /**
87
- * Returns # number of non-compute budget related instructions
88
- *
89
- * @param tx
90
- */
91
- static getNonComputeBudgetIxs(tx) {
92
- let counter = 0;
93
- for (let ix of tx.instructions) {
94
- if (!ix.programId.equals(web3_js_1.ComputeBudgetProgram.programId))
95
- counter++;
96
- }
97
- return counter;
98
- }
99
- /**
100
- * @param tx a solana transaction
101
- * @param feePayer the publicKey of the signer
102
- * @returns size in bytes of the transaction
103
- */
104
- static getTxSize(tx, feePayer) {
105
- const feePayerPk = [feePayer.toBase58()];
106
- const signers = new Set(feePayerPk);
107
- const accounts = new Set(feePayerPk);
108
- const ixsSize = tx.instructions.reduce((acc, ix) => {
109
- ix.keys.forEach(({ pubkey, isSigner }) => {
110
- const pk = pubkey.toBase58();
111
- if (isSigner)
112
- signers.add(pk);
113
- accounts.add(pk);
114
- });
115
- accounts.add(ix.programId.toBase58());
116
- const nIndexes = ix.keys.length;
117
- const opaqueData = ix.data.length;
118
- return (acc +
119
- 1 + // PID index
120
- SolanaTxUtils.compactArraySize(nIndexes, 1) +
121
- SolanaTxUtils.compactArraySize(opaqueData, 1));
122
- }, 0);
123
- return (SolanaTxUtils.compactArraySize(signers.size, 64) + // signatures
124
- 3 + // header
125
- SolanaTxUtils.compactArraySize(accounts.size, 32) + // accounts
126
- 32 + // blockhash
127
- SolanaTxUtils.compactHeader(tx.instructions.length) + // instructions
128
- ixsSize);
129
- }
130
- ;
131
- }
132
- exports.SolanaTxUtils = SolanaTxUtils;
133
- // COMPACT ARRAY
134
- SolanaTxUtils.LOW_VALUE = 127; // 0x7f
135
- SolanaTxUtils.HIGH_VALUE = 16383; // 0x3fff
136
- function toClaimHash(paymentHash, nonce, confirmations) {
137
- return paymentHash +
138
- nonce.toString(16).padStart(16, "0") +
139
- confirmations.toString(16).padStart(4, "0");
140
- }
141
- exports.toClaimHash = toClaimHash;
142
- function fromClaimHash(claimHash) {
143
- if (claimHash.length !== 84)
144
- throw new Error("Claim hash invalid length: " + claimHash.length);
145
- return {
146
- paymentHash: claimHash.slice(0, 64),
147
- nonce: new BN(claimHash.slice(64, 80), "hex"),
148
- confirmations: parseInt(claimHash.slice(80, 84), 16)
149
- };
150
- }
151
- exports.fromClaimHash = fromClaimHash;
152
- function toEscrowHash(paymentHash, sequence) {
153
- return buffer_1.Buffer.from((0, sha2_1.sha256)(buffer_1.Buffer.concat([
154
- buffer_1.Buffer.from(paymentHash, "hex"),
155
- sequence.toArrayLike(buffer_1.Buffer, "be", 8)
156
- ]))).toString("hex");
157
- }
158
- exports.toEscrowHash = toEscrowHash;
159
- function toBN(value) {
160
- if (value == null)
161
- return null;
162
- return new BN(value.toString(10));
163
- }
164
- exports.toBN = toBN;
165
- function toBigInt(value) {
166
- if (value == null)
167
- return null;
168
- return BigInt(value.toString(10));
169
- }
170
- exports.toBigInt = toBigInt;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toBigInt = exports.toBN = exports.toEscrowHash = exports.fromClaimHash = exports.toClaimHash = exports.SolanaTxUtils = exports.tryWithRetries = exports.getLogger = exports.onceAsync = exports.timeoutPromise = void 0;
4
+ const web3_js_1 = require("@solana/web3.js");
5
+ const BN = require("bn.js");
6
+ const buffer_1 = require("buffer");
7
+ const sha2_1 = require("@noble/hashes/sha2");
8
+ function timeoutPromise(timeoutMillis, abortSignal) {
9
+ return new Promise((resolve, reject) => {
10
+ const timeout = setTimeout(resolve, timeoutMillis);
11
+ if (abortSignal != null)
12
+ abortSignal.addEventListener("abort", () => {
13
+ clearTimeout(timeout);
14
+ reject(new Error("Aborted"));
15
+ });
16
+ });
17
+ }
18
+ exports.timeoutPromise = timeoutPromise;
19
+ function onceAsync(executor) {
20
+ let promise;
21
+ return () => {
22
+ if (promise == null) {
23
+ promise = executor();
24
+ return promise;
25
+ }
26
+ else {
27
+ return promise.catch(() => promise = executor());
28
+ }
29
+ };
30
+ }
31
+ exports.onceAsync = onceAsync;
32
+ function getLogger(prefix) {
33
+ return {
34
+ debug: (msg, ...args) => global.atomiqLogLevel >= 3 && console.debug(prefix + msg, ...args),
35
+ info: (msg, ...args) => global.atomiqLogLevel >= 2 && console.info(prefix + msg, ...args),
36
+ warn: (msg, ...args) => (global.atomiqLogLevel == null || global.atomiqLogLevel >= 1) && console.warn(prefix + msg, ...args),
37
+ error: (msg, ...args) => (global.atomiqLogLevel == null || global.atomiqLogLevel >= 0) && console.error(prefix + msg, ...args)
38
+ };
39
+ }
40
+ exports.getLogger = getLogger;
41
+ const logger = getLogger("Utils: ");
42
+ async function tryWithRetries(func, retryPolicy, errorAllowed, abortSignal) {
43
+ retryPolicy = retryPolicy || {};
44
+ retryPolicy.maxRetries = retryPolicy.maxRetries || 5;
45
+ retryPolicy.delay = retryPolicy.delay || 500;
46
+ retryPolicy.exponential = retryPolicy.exponential == null ? true : retryPolicy.exponential;
47
+ let err = null;
48
+ for (let i = 0; i < retryPolicy.maxRetries; i++) {
49
+ try {
50
+ const resp = await func();
51
+ return resp;
52
+ }
53
+ catch (e) {
54
+ if (errorAllowed != null && errorAllowed(e))
55
+ throw e;
56
+ err = e;
57
+ logger.error("tryWithRetries(): error on try number: " + i, e);
58
+ }
59
+ if (abortSignal != null && abortSignal.aborted)
60
+ throw new Error("Aborted");
61
+ if (i !== retryPolicy.maxRetries - 1) {
62
+ await timeoutPromise(retryPolicy.exponential ? retryPolicy.delay * Math.pow(2, i) : retryPolicy.delay, abortSignal);
63
+ }
64
+ }
65
+ throw err;
66
+ }
67
+ exports.tryWithRetries = tryWithRetries;
68
+ class SolanaTxUtils {
69
+ /**
70
+ * Compact u16 array header size
71
+ * @param n elements in the compact array
72
+ * @returns size in bytes of array header
73
+ */
74
+ static compactHeader(n) {
75
+ return (n <= SolanaTxUtils.LOW_VALUE ? 1 : n <= SolanaTxUtils.HIGH_VALUE ? 2 : 3);
76
+ }
77
+ /**
78
+ * Compact u16 array size
79
+ * @param n elements in the compact array
80
+ * @param size bytes per each element
81
+ * @returns size in bytes of array
82
+ */
83
+ static compactArraySize(n, size) {
84
+ return SolanaTxUtils.compactHeader(n) + n * size;
85
+ }
86
+ /**
87
+ * Returns # number of non-compute budget related instructions
88
+ *
89
+ * @param tx
90
+ */
91
+ static getNonComputeBudgetIxs(tx) {
92
+ let counter = 0;
93
+ for (let ix of tx.instructions) {
94
+ if (!ix.programId.equals(web3_js_1.ComputeBudgetProgram.programId))
95
+ counter++;
96
+ }
97
+ return counter;
98
+ }
99
+ /**
100
+ * @param tx a solana transaction
101
+ * @param feePayer the publicKey of the signer
102
+ * @returns size in bytes of the transaction
103
+ */
104
+ static getTxSize(tx, feePayer) {
105
+ const feePayerPk = [feePayer.toBase58()];
106
+ const signers = new Set(feePayerPk);
107
+ const accounts = new Set(feePayerPk);
108
+ const ixsSize = tx.instructions.reduce((acc, ix) => {
109
+ ix.keys.forEach(({ pubkey, isSigner }) => {
110
+ const pk = pubkey.toBase58();
111
+ if (isSigner)
112
+ signers.add(pk);
113
+ accounts.add(pk);
114
+ });
115
+ accounts.add(ix.programId.toBase58());
116
+ const nIndexes = ix.keys.length;
117
+ const opaqueData = ix.data.length;
118
+ return (acc +
119
+ 1 + // PID index
120
+ SolanaTxUtils.compactArraySize(nIndexes, 1) +
121
+ SolanaTxUtils.compactArraySize(opaqueData, 1));
122
+ }, 0);
123
+ return (SolanaTxUtils.compactArraySize(signers.size, 64) + // signatures
124
+ 3 + // header
125
+ SolanaTxUtils.compactArraySize(accounts.size, 32) + // accounts
126
+ 32 + // blockhash
127
+ SolanaTxUtils.compactHeader(tx.instructions.length) + // instructions
128
+ ixsSize);
129
+ }
130
+ ;
131
+ }
132
+ exports.SolanaTxUtils = SolanaTxUtils;
133
+ // COMPACT ARRAY
134
+ SolanaTxUtils.LOW_VALUE = 127; // 0x7f
135
+ SolanaTxUtils.HIGH_VALUE = 16383; // 0x3fff
136
+ function toClaimHash(paymentHash, nonce, confirmations) {
137
+ return paymentHash +
138
+ nonce.toString(16).padStart(16, "0") +
139
+ confirmations.toString(16).padStart(4, "0");
140
+ }
141
+ exports.toClaimHash = toClaimHash;
142
+ function fromClaimHash(claimHash) {
143
+ if (claimHash.length !== 84)
144
+ throw new Error("Claim hash invalid length: " + claimHash.length);
145
+ return {
146
+ paymentHash: claimHash.slice(0, 64),
147
+ nonce: new BN(claimHash.slice(64, 80), "hex"),
148
+ confirmations: parseInt(claimHash.slice(80, 84), 16)
149
+ };
150
+ }
151
+ exports.fromClaimHash = fromClaimHash;
152
+ function toEscrowHash(paymentHash, sequence) {
153
+ return buffer_1.Buffer.from((0, sha2_1.sha256)(buffer_1.Buffer.concat([
154
+ buffer_1.Buffer.from(paymentHash, "hex"),
155
+ sequence.toArrayLike(buffer_1.Buffer, "be", 8)
156
+ ]))).toString("hex");
157
+ }
158
+ exports.toEscrowHash = toEscrowHash;
159
+ function toBN(value) {
160
+ if (value == null)
161
+ return null;
162
+ return new BN(value.toString(10));
163
+ }
164
+ exports.toBN = toBN;
165
+ function toBigInt(value) {
166
+ if (value == null)
167
+ return null;
168
+ return BigInt(value.toString(10));
169
+ }
170
+ exports.toBigInt = toBigInt;
package/node/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "../dist/node";
1
+ export * from "../dist/node";
package/node/index.js CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";
2
-
3
- module.exports = require("../dist/node");
1
+ "use strict";
2
+
3
+ module.exports = require("../dist/node");
package/package.json CHANGED
@@ -1,46 +1,46 @@
1
- {
2
- "name": "@atomiqlabs/chain-solana",
3
- "version": "13.5.13",
4
- "description": "Solana specific base implementation",
5
- "main": "./dist/index.js",
6
- "types:": "./dist/index.d.ts",
7
- "scripts": {
8
- "build": "npx -y -p typescript@4.9 tsc",
9
- "test": "echo \"Error: no test specified\" && exit 1",
10
- "build:ts4": "npx -p typescript@4.9 tsc --noEmit",
11
- "build:ts5": "npx -p typescript@5 tsc --noEmit"
12
- },
13
- "files": [
14
- "/dist",
15
- "/src",
16
- "/node"
17
- ],
18
- "keywords": [
19
- "Solana",
20
- "Bitcoin",
21
- "Cross-chain",
22
- "Cryptocurrency",
23
- "Bridge",
24
- "Trustless"
25
- ],
26
- "author": "adambor",
27
- "license": "ISC",
28
- "dependencies": {
29
- "@atomiqlabs/base": "^13.5.2",
30
- "@coral-xyz/anchor": "0.29.0",
31
- "@noble/hashes": "^1.7.1",
32
- "@solana/spl-token": "0.4.14",
33
- "bn.js": "5.2.3",
34
- "bs58": "^4.0.1",
35
- "buffer": "6.0.3",
36
- "tweetnacl": "1.0.3"
37
- },
38
- "peerDependencies": {
39
- "@solana/web3.js": "^1.95.2"
40
- },
41
- "devDependencies": {
42
- "@types/bn.js": "5.1.6",
43
- "@types/node": "^25.0.9",
44
- "typescript": "^5.9.3"
45
- }
46
- }
1
+ {
2
+ "name": "@atomiqlabs/chain-solana",
3
+ "version": "13.5.14",
4
+ "description": "Solana specific base implementation",
5
+ "main": "./dist/index.js",
6
+ "types:": "./dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "npx -y -p typescript@4.9 tsc",
9
+ "test": "echo \"Error: no test specified\" && exit 1",
10
+ "build:ts4": "npx -p typescript@4.9 tsc --noEmit",
11
+ "build:ts5": "npx -p typescript@5 tsc --noEmit"
12
+ },
13
+ "files": [
14
+ "/dist",
15
+ "/src",
16
+ "/node"
17
+ ],
18
+ "keywords": [
19
+ "Solana",
20
+ "Bitcoin",
21
+ "Cross-chain",
22
+ "Cryptocurrency",
23
+ "Bridge",
24
+ "Trustless"
25
+ ],
26
+ "author": "adambor",
27
+ "license": "ISC",
28
+ "dependencies": {
29
+ "@atomiqlabs/base": "^13.5.2",
30
+ "@coral-xyz/anchor": "0.29.0",
31
+ "@noble/hashes": "^1.7.1",
32
+ "@solana/spl-token": "0.4.14",
33
+ "bn.js": "5.2.3",
34
+ "bs58": "^4.0.1",
35
+ "buffer": "6.0.3",
36
+ "tweetnacl": "1.0.3"
37
+ },
38
+ "peerDependencies": {
39
+ "@solana/web3.js": "^1.95.2"
40
+ },
41
+ "devDependencies": {
42
+ "@types/bn.js": "5.1.6",
43
+ "@types/node": "^25.0.9",
44
+ "typescript": "^5.9.3"
45
+ }
46
+ }
package/src/index.ts CHANGED
@@ -1,87 +1,87 @@
1
- /**
2
- * # @atomiqlabs/chain-solana
3
- *
4
- * `@atomiqlabs/chain-solana` is the Solana integration package for the Atomiq protocol.
5
- *
6
- * Within the Atomiq stack, this library provides the Solana-side building blocks used for Bitcoin-aware swaps on Solana. It includes:
7
- *
8
- * - the `SolanaInitializer` used to register Solana support in the Atomiq SDK
9
- * - the `SolanaChainInterface` used to talk to Solana RPCs
10
- * - Solana BTC relay and swap program wrappers
11
- * - signer and wallet helpers for Solana integrations
12
- * - connection retry and chain event utilities
13
- *
14
- * This package is intended for direct protocol integrations and for higher-level Atomiq SDK layers that need Solana chain support.
15
- *
16
- * ## Installation
17
- *
18
- * Install the package with its `@solana/web3.js` peer dependency:
19
- *
20
- * ```bash
21
- * npm install @atomiqlabs/chain-solana @solana/web3.js
22
- * ```
23
- *
24
- * ## Supported Chains
25
- *
26
- * This package exports a single Solana initializer:
27
- *
28
- * - Solana via `SolanaInitializer`
29
- *
30
- * Canonical deployments currently defined in this package:
31
- *
32
- * | Chain | Canonical deployments included |
33
- * | --- | --- |
34
- * | Solana | `MAINNET`, `TESTNET` |
35
- *
36
- * In this package, the selected Bitcoin network determines which canonical Solana program addresses are used by default. `BitcoinNetwork.TESTNET4` is not wired to a Solana deployment here yet.
37
- *
38
- * The Solana implementation doesn't support the UTXO-controlled vault (SPV vault) contract, hence it can only process legacy HTLC & PrTLC based swaps.
39
- *
40
- * ## SDK Example
41
- *
42
- * Initialize the Atomiq SDK with Solana network support:
43
- *
44
- * ```ts
45
- * import {SolanaInitializerV2} from "@atomiqlabs/chain-solana";
46
- * import {BitcoinNetwork, SwapperFactory, TypedSwapper} from "@atomiqlabs/sdk";
47
- *
48
- * // Define chains that you want to support here
49
- * const chains = [SolanaInitializerV2] as const;
50
- * type SupportedChains = typeof chains;
51
- *
52
- * const Factory = new SwapperFactory<SupportedChains>(chains);
53
- *
54
- * const swapper: TypedSwapper<SupportedChains> = Factory.newSwapper({
55
- * chains: {
56
- * SOLANA: {
57
- * rpcUrl: solanaRpc // You can also pass a web3.js Connection object here
58
- * }
59
- * },
60
- * bitcoinNetwork: BitcoinNetwork.MAINNET // or BitcoinNetwork.TESTNET
61
- * });
62
- * ```
63
- *
64
- * If you use the lower-level initializer directly, you can also provide a custom storage backend for temporary Solana data accounts used when submitting large Bitcoin proof payloads.
65
- *
66
- * @packageDocumentation
67
- */
68
- export {SolanaBtcHeader} from "./solana/btcrelay/headers/SolanaBtcHeader";
69
- export {SolanaBtcStoredHeader} from "./solana/btcrelay/headers/SolanaBtcStoredHeader";
70
- export * from "./solana/btcrelay/SolanaBtcRelay";
71
-
72
- export * from "./solana/chain/SolanaChainInterface";
73
- export * from "./solana/chain/modules/SolanaFees";
74
- export {SolanaTx, SignedSolanaTx} from "./solana/chain/modules/SolanaTransactions";
75
-
76
- export {ConnectionWithRetries} from "./solana/connection/ConnectionWithRetries";
77
-
78
- export {SolanaChainEventsBrowser, SolanaEventListenerState} from "./solana/events/SolanaChainEventsBrowser";
79
-
80
- export * from "./solana/swaps/SolanaSwapProgram";
81
- export {SolanaSwapData} from "./solana/swaps/SolanaSwapData";
82
-
83
- export * from "./solana/wallet/SolanaKeypairWallet";
84
- export * from "./solana/wallet/SolanaSigner";
85
-
86
- export * from "./solana/SolanaChainType";
87
- export * from "./solana/SolanaInitializer";
1
+ /**
2
+ * # @atomiqlabs/chain-solana
3
+ *
4
+ * `@atomiqlabs/chain-solana` is the Solana integration package for the Atomiq protocol.
5
+ *
6
+ * Within the Atomiq stack, this library provides the Solana-side building blocks used for Bitcoin-aware swaps on Solana. It includes:
7
+ *
8
+ * - the `SolanaInitializer` used to register Solana support in the Atomiq SDK
9
+ * - the `SolanaChainInterface` used to talk to Solana RPCs
10
+ * - Solana BTC relay and swap program wrappers
11
+ * - signer and wallet helpers for Solana integrations
12
+ * - connection retry and chain event utilities
13
+ *
14
+ * This package is intended for direct protocol integrations and for higher-level Atomiq SDK layers that need Solana chain support.
15
+ *
16
+ * ## Installation
17
+ *
18
+ * Install the package with its `@solana/web3.js` peer dependency:
19
+ *
20
+ * ```bash
21
+ * npm install @atomiqlabs/chain-solana @solana/web3.js
22
+ * ```
23
+ *
24
+ * ## Supported Chains
25
+ *
26
+ * This package exports a single Solana initializer:
27
+ *
28
+ * - Solana via `SolanaInitializer`
29
+ *
30
+ * Canonical deployments currently defined in this package:
31
+ *
32
+ * | Chain | Canonical deployments included |
33
+ * | --- | --- |
34
+ * | Solana | `MAINNET`, `TESTNET` |
35
+ *
36
+ * In this package, the selected Bitcoin network determines which canonical Solana program addresses are used by default. `BitcoinNetwork.TESTNET4` is not wired to a Solana deployment here yet.
37
+ *
38
+ * The Solana implementation doesn't support the UTXO-controlled vault (SPV vault) contract, hence it can only process legacy HTLC & PrTLC based swaps.
39
+ *
40
+ * ## SDK Example
41
+ *
42
+ * Initialize the Atomiq SDK with Solana network support:
43
+ *
44
+ * ```ts
45
+ * import {SolanaInitializerV2} from "@atomiqlabs/chain-solana";
46
+ * import {BitcoinNetwork, SwapperFactory, TypedSwapper} from "@atomiqlabs/sdk";
47
+ *
48
+ * // Define chains that you want to support here
49
+ * const chains = [SolanaInitializerV2] as const;
50
+ * type SupportedChains = typeof chains;
51
+ *
52
+ * const Factory = new SwapperFactory<SupportedChains>(chains);
53
+ *
54
+ * const swapper: TypedSwapper<SupportedChains> = Factory.newSwapper({
55
+ * chains: {
56
+ * SOLANA: {
57
+ * rpcUrl: solanaRpc // You can also pass a web3.js Connection object here
58
+ * }
59
+ * },
60
+ * bitcoinNetwork: BitcoinNetwork.MAINNET // or BitcoinNetwork.TESTNET
61
+ * });
62
+ * ```
63
+ *
64
+ * If you use the lower-level initializer directly, you can also provide a custom storage backend for temporary Solana data accounts used when submitting large Bitcoin proof payloads.
65
+ *
66
+ * @packageDocumentation
67
+ */
68
+ export {SolanaBtcHeader} from "./solana/btcrelay/headers/SolanaBtcHeader";
69
+ export {SolanaBtcStoredHeader} from "./solana/btcrelay/headers/SolanaBtcStoredHeader";
70
+ export * from "./solana/btcrelay/SolanaBtcRelay";
71
+
72
+ export * from "./solana/chain/SolanaChainInterface";
73
+ export * from "./solana/chain/modules/SolanaFees";
74
+ export {SolanaTx, SignedSolanaTx} from "./solana/chain/modules/SolanaTransactions";
75
+
76
+ export {ConnectionWithRetries} from "./solana/connection/ConnectionWithRetries";
77
+
78
+ export {SolanaChainEventsBrowser, SolanaEventListenerState} from "./solana/events/SolanaChainEventsBrowser";
79
+
80
+ export * from "./solana/swaps/SolanaSwapProgram";
81
+ export {SolanaSwapData} from "./solana/swaps/SolanaSwapData";
82
+
83
+ export * from "./solana/wallet/SolanaKeypairWallet";
84
+ export * from "./solana/wallet/SolanaSigner";
85
+
86
+ export * from "./solana/SolanaChainType";
87
+ export * from "./solana/SolanaInitializer";
package/src/node/index.ts CHANGED
@@ -1,9 +1,9 @@
1
- /**
2
- * Node.js-only entrypoint for filesystem-backed Solana helpers.
3
- *
4
- * Import from `@atomiqlabs/chain-solana/node` when you need runtime features
5
- * that depend on Node's `fs` module.
6
- *
7
- * @packageDocumentation
8
- */
9
- export {SolanaChainEvents} from "../solana/events/SolanaChainEvents";
1
+ /**
2
+ * Node.js-only entrypoint for filesystem-backed Solana helpers.
3
+ *
4
+ * Import from `@atomiqlabs/chain-solana/node` when you need runtime features
5
+ * that depend on Node's `fs` module.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ export {SolanaChainEvents} from "../solana/events/SolanaChainEvents";