@hawksightco/hawk-sdk 1.3.265 → 1.3.267

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 (181) hide show
  1. package/dist/addresses.d.ts +37 -0
  2. package/dist/addresses.d.ts.map +1 -0
  3. package/dist/addresses.js +84 -0
  4. package/dist/anchor.d.ts +22 -0
  5. package/dist/anchor.d.ts.map +1 -0
  6. package/dist/anchor.js +121 -0
  7. package/dist/classes/AltStorage.d.ts +29 -0
  8. package/dist/classes/AltStorage.d.ts.map +1 -0
  9. package/dist/classes/AltStorage.js +58 -0
  10. package/dist/classes/Atomicity.d.ts +34 -0
  11. package/dist/classes/Atomicity.d.ts.map +1 -0
  12. package/dist/classes/Atomicity.js +110 -0
  13. package/dist/classes/Client.d.ts +35 -0
  14. package/dist/classes/Client.d.ts.map +1 -0
  15. package/dist/classes/Client.js +66 -0
  16. package/dist/classes/CombineTransactions.d.ts +11 -0
  17. package/dist/classes/CombineTransactions.d.ts.map +1 -0
  18. package/dist/classes/CombineTransactions.js +58 -0
  19. package/dist/classes/CreateTxMetadata.d.ts +100 -0
  20. package/dist/classes/CreateTxMetadata.d.ts.map +1 -0
  21. package/dist/classes/CreateTxMetadata.js +415 -0
  22. package/dist/classes/General.d.ts +87 -0
  23. package/dist/classes/General.d.ts.map +1 -0
  24. package/dist/classes/General.js +176 -0
  25. package/dist/classes/GeneralUtility.d.ts +79 -0
  26. package/dist/classes/GeneralUtility.d.ts.map +1 -0
  27. package/dist/classes/GeneralUtility.js +121 -0
  28. package/dist/classes/HawkAPI.d.ts +122 -0
  29. package/dist/classes/HawkAPI.d.ts.map +1 -0
  30. package/dist/classes/HawkAPI.js +169 -0
  31. package/dist/classes/Health.d.ts +29 -0
  32. package/dist/classes/Health.d.ts.map +1 -0
  33. package/dist/classes/Health.js +48 -0
  34. package/dist/classes/JupiterAlts.d.ts +37 -0
  35. package/dist/classes/JupiterAlts.d.ts.map +1 -0
  36. package/dist/classes/JupiterAlts.js +114 -0
  37. package/dist/classes/JupiterSwap.d.ts +21 -0
  38. package/dist/classes/JupiterSwap.d.ts.map +1 -0
  39. package/dist/classes/JupiterSwap.js +40 -0
  40. package/dist/classes/Logging.d.ts +13 -0
  41. package/dist/classes/Logging.d.ts.map +1 -0
  42. package/dist/classes/Logging.js +50 -0
  43. package/dist/classes/MultiTransaction.d.ts +75 -0
  44. package/dist/classes/MultiTransaction.d.ts.map +1 -0
  45. package/dist/classes/MultiTransaction.js +296 -0
  46. package/dist/classes/RaydiumSDK.d.ts +67 -0
  47. package/dist/classes/RaydiumSDK.d.ts.map +1 -0
  48. package/dist/classes/RaydiumSDK.js +206 -0
  49. package/dist/classes/Search.d.ts +100 -0
  50. package/dist/classes/Search.d.ts.map +1 -0
  51. package/dist/classes/Search.js +216 -0
  52. package/dist/classes/SimpleIxGenerator.d.ts +57 -0
  53. package/dist/classes/SimpleIxGenerator.d.ts.map +1 -0
  54. package/dist/classes/SimpleIxGenerator.js +62 -0
  55. package/dist/classes/SimplePdaGenerator.d.ts +28 -0
  56. package/dist/classes/SimplePdaGenerator.d.ts.map +1 -0
  57. package/dist/classes/SimplePdaGenerator.js +33 -0
  58. package/dist/classes/Transaction.d.ts +229 -0
  59. package/dist/classes/Transaction.d.ts.map +1 -0
  60. package/dist/classes/Transaction.js +643 -0
  61. package/dist/classes/Transaction2.d.ts +107 -0
  62. package/dist/classes/Transaction2.d.ts.map +1 -0
  63. package/dist/classes/Transaction2.js +249 -0
  64. package/dist/classes/Transaction3.d.ts +165 -0
  65. package/dist/classes/Transaction3.d.ts.map +1 -0
  66. package/dist/classes/Transaction3.js +416 -0
  67. package/dist/classes/TransactionBatchExecute.d.ts +163 -0
  68. package/dist/classes/TransactionBatchExecute.d.ts.map +1 -0
  69. package/dist/classes/TransactionBatchExecute.js +466 -0
  70. package/dist/classes/TransactionBatchExecute2.d.ts +99 -0
  71. package/dist/classes/TransactionBatchExecute2.d.ts.map +1 -0
  72. package/dist/classes/TransactionBatchExecute2.js +357 -0
  73. package/dist/classes/Transactions.d.ts +586 -0
  74. package/dist/classes/Transactions.d.ts.map +1 -0
  75. package/dist/classes/Transactions.js +7667 -0
  76. package/dist/classes/TxGenerator.d.ts +350 -0
  77. package/dist/classes/TxGenerator.d.ts.map +1 -0
  78. package/dist/classes/TxGenerator.js +1957 -0
  79. package/dist/classes/TxGeneratorAutomations.d.ts +186 -0
  80. package/dist/classes/TxGeneratorAutomations.d.ts.map +1 -0
  81. package/dist/classes/TxGeneratorAutomations.js +897 -0
  82. package/dist/classes/Util.d.ts +87 -0
  83. package/dist/classes/Util.d.ts.map +1 -0
  84. package/dist/classes/Util.js +148 -0
  85. package/dist/classes/account-cache/AccountCache.d.ts +54 -0
  86. package/dist/classes/account-cache/AccountCache.d.ts.map +1 -0
  87. package/dist/classes/account-cache/AccountCache.js +143 -0
  88. package/dist/classes/account-cache/MintCache.d.ts +33 -0
  89. package/dist/classes/account-cache/MintCache.d.ts.map +1 -0
  90. package/dist/classes/account-cache/MintCache.js +47 -0
  91. package/dist/classes/account-cache/TokenCache.d.ts +33 -0
  92. package/dist/classes/account-cache/TokenCache.d.ts.map +1 -0
  93. package/dist/classes/account-cache/TokenCache.js +47 -0
  94. package/dist/errors.d.ts +13 -0
  95. package/dist/errors.d.ts.map +1 -0
  96. package/dist/errors.js +96 -0
  97. package/dist/functions.d.ts +514 -0
  98. package/dist/functions.d.ts.map +1 -0
  99. package/dist/functions.js +1636 -0
  100. package/dist/hawksight.d.ts +53 -0
  101. package/dist/hawksight.d.ts.map +1 -0
  102. package/dist/hawksight.js +328 -0
  103. package/dist/hsToMeteora.d.ts +31 -0
  104. package/dist/hsToMeteora.d.ts.map +1 -0
  105. package/dist/hsToMeteora.js +3175 -0
  106. package/dist/idl/iyf-extension-idl.d.ts +14583 -0
  107. package/dist/idl/iyf-extension-idl.d.ts.map +1 -0
  108. package/dist/idl/iyf-extension-idl.js +14578 -0
  109. package/dist/idl/iyf-extension-wrapper.d.ts +112 -0
  110. package/dist/idl/iyf-extension-wrapper.d.ts.map +1 -0
  111. package/dist/idl/iyf-extension-wrapper.js +2 -0
  112. package/dist/idl/iyf-main-idl.d.ts +12078 -0
  113. package/dist/idl/iyf-main-idl.d.ts.map +1 -0
  114. package/dist/idl/iyf-main-idl.js +12073 -0
  115. package/dist/idl/iyf-main-wrapper.d.ts +112 -0
  116. package/dist/idl/iyf-main-wrapper.d.ts.map +1 -0
  117. package/dist/idl/iyf-main-wrapper.js +2 -0
  118. package/dist/idl/jupiter-idl.d.ts +3063 -0
  119. package/dist/idl/jupiter-idl.d.ts.map +1 -0
  120. package/dist/idl/jupiter-idl.js +3061 -0
  121. package/dist/idl/meteora-idl.d.ts +7371 -0
  122. package/dist/idl/meteora-idl.d.ts.map +1 -0
  123. package/dist/idl/meteora-idl.js +7372 -0
  124. package/dist/idl/orca-idl.d.ts +3833 -0
  125. package/dist/idl/orca-idl.d.ts.map +1 -0
  126. package/dist/idl/orca-idl.js +3834 -0
  127. package/dist/idl/raydium-idl.d.ts +3054 -0
  128. package/dist/idl/raydium-idl.d.ts.map +1 -0
  129. package/dist/idl/raydium-idl.js +3055 -0
  130. package/dist/index.d.ts +9 -0
  131. package/dist/index.d.ts.map +1 -0
  132. package/dist/index.js +31 -0
  133. package/dist/ixGenerator/IyfExtensionIxGenerator.d.ts +126 -0
  134. package/dist/ixGenerator/IyfExtensionIxGenerator.d.ts.map +1 -0
  135. package/dist/ixGenerator/IyfExtensionIxGenerator.js +467 -0
  136. package/dist/ixGenerator/IyfMainIxGenerator.d.ts +330 -0
  137. package/dist/ixGenerator/IyfMainIxGenerator.d.ts.map +1 -0
  138. package/dist/ixGenerator/IyfMainIxGenerator.js +1239 -0
  139. package/dist/ixGenerator/MeteoraDlmmIxGenerator.d.ts +685 -0
  140. package/dist/ixGenerator/MeteoraDlmmIxGenerator.d.ts.map +1 -0
  141. package/dist/ixGenerator/MeteoraDlmmIxGenerator.js +3008 -0
  142. package/dist/ixGenerator/OrcaIxGenerator.d.ts +119 -0
  143. package/dist/ixGenerator/OrcaIxGenerator.d.ts.map +1 -0
  144. package/dist/ixGenerator/OrcaIxGenerator.js +438 -0
  145. package/dist/ixGenerator/RaydiumIxGenerator.d.ts +99 -0
  146. package/dist/ixGenerator/RaydiumIxGenerator.d.ts.map +1 -0
  147. package/dist/ixGenerator/RaydiumIxGenerator.js +558 -0
  148. package/dist/ixGenerator/UtilIxGenerator.d.ts +20 -0
  149. package/dist/ixGenerator/UtilIxGenerator.d.ts.map +1 -0
  150. package/dist/ixGenerator/UtilIxGenerator.js +25 -0
  151. package/dist/meteora/index.d.ts +2 -0
  152. package/dist/meteora/index.d.ts.map +1 -0
  153. package/dist/meteora/index.js +17 -0
  154. package/dist/meteora/liquidityStrategy.d.ts +408 -0
  155. package/dist/meteora/liquidityStrategy.d.ts.map +1 -0
  156. package/dist/meteora/liquidityStrategy.js +1325 -0
  157. package/dist/meteora.d.ts +669 -0
  158. package/dist/meteora.d.ts.map +1 -0
  159. package/dist/meteora.js +1932 -0
  160. package/dist/orca.d.ts +57 -0
  161. package/dist/orca.d.ts.map +1 -0
  162. package/dist/orca.js +123 -0
  163. package/dist/pdaGenerator/HawksightPdaGenerator.d.ts +29 -0
  164. package/dist/pdaGenerator/HawksightPdaGenerator.d.ts.map +1 -0
  165. package/dist/pdaGenerator/HawksightPdaGenerator.js +75 -0
  166. package/dist/pdaGenerator/MeteoraPdaGenerator.d.ts +76 -0
  167. package/dist/pdaGenerator/MeteoraPdaGenerator.d.ts.map +1 -0
  168. package/dist/pdaGenerator/MeteoraPdaGenerator.js +166 -0
  169. package/dist/pdaGenerator/OrcaPdaGenerator.d.ts +23 -0
  170. package/dist/pdaGenerator/OrcaPdaGenerator.d.ts.map +1 -0
  171. package/dist/pdaGenerator/OrcaPdaGenerator.js +68 -0
  172. package/dist/pdaGenerator/RaydiumPdaGenerator.d.ts +49 -0
  173. package/dist/pdaGenerator/RaydiumPdaGenerator.d.ts.map +1 -0
  174. package/dist/pdaGenerator/RaydiumPdaGenerator.js +114 -0
  175. package/dist/pdaGenerator/UtilPdaGenerator.d.ts +8 -0
  176. package/dist/pdaGenerator/UtilPdaGenerator.d.ts.map +1 -0
  177. package/dist/pdaGenerator/UtilPdaGenerator.js +51 -0
  178. package/dist/types.d.ts +1104 -0
  179. package/dist/types.d.ts.map +1 -0
  180. package/dist/types.js +95 -0
  181. package/package.json +6 -5
@@ -0,0 +1,357 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ var _a;
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ exports.TransactionBatchExecute2 = void 0;
47
+ const web3 = __importStar(require("@solana/web3.js"));
48
+ const TransactionBatchExecute_1 = require("./TransactionBatchExecute");
49
+ const MultiTransaction_1 = require("./MultiTransaction");
50
+ const functions_1 = require("../functions");
51
+ /**
52
+ * Executes transactions in batches
53
+ */
54
+ class TransactionBatchExecute2 extends TransactionBatchExecute_1.TransactionBatchExecute {
55
+ /**
56
+ * Creates an instance of TransactionExecute class
57
+ *
58
+ * @param lookupTableAddresses Address lookup table addresses to be used by batch of transactions
59
+ * @param instructions Array of instructions to be batched into transactions
60
+ * @param payer Payer that will pay for the batch of transactions
61
+ * @param connection Connection to mainnet
62
+ */
63
+ constructor(lookupTableAddresses, instructions, connection, createTxMetadataInstance, latestBlockhash, payerKey) {
64
+ super(lookupTableAddresses, instructions, new web3.Keypair(), // unused
65
+ connection, []);
66
+ this.lookupTableAddresses = lookupTableAddresses;
67
+ this.instructions = instructions;
68
+ this.connection = connection;
69
+ this.createTxMetadataInstance = createTxMetadataInstance;
70
+ this.latestBlockhash = latestBlockhash;
71
+ this.payerKey = payerKey;
72
+ this._insertNonceAt = {};
73
+ }
74
+ ;
75
+ /**
76
+ * Download all jupiter alts (overridable)
77
+ */
78
+ jupiterDownloadAlts() {
79
+ return __awaiter(this, void 0, void 0, function* () { });
80
+ }
81
+ /**
82
+ * Find alt by pubkeys (overridable)
83
+ */
84
+ jupiterFindAltByPubkeys(pubkeys) {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ return yield _a.jupiterFindAltByPubkeysFn(pubkeys);
87
+ });
88
+ }
89
+ /**
90
+ * Downoad address lookup table from given cluster
91
+ */
92
+ downloadAlts2(lookupTableAddresses) {
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ const pubkeyStr = lookupTableAddresses.map(pubkey => pubkey.toString());
95
+ const alts = yield this.createTxMetadataInstance.stringToAlt(pubkeyStr);
96
+ this.alts.push(...alts);
97
+ });
98
+ }
99
+ /**
100
+ * Option to include nonce advance instruction
101
+ *
102
+ * @param opt
103
+ */
104
+ insertNonceAt(opt) {
105
+ this._insertNonceAt = opt;
106
+ }
107
+ /**
108
+ * Builds a batch of executable transaction instructions
109
+ */
110
+ buildBatch() {
111
+ return __awaiter(this, void 0, void 0, function* () {
112
+ // Download address lookup table from given cluster
113
+ yield this.downloadAlts();
114
+ // Generate dummy instructions for batch calculation
115
+ const [simulationIxs, dummySigners] = this.generateSimulationIxs();
116
+ // Split simulation ixs
117
+ const dummyBatches = yield this.splitToTransactions(simulationIxs, dummySigners);
118
+ // Batch of actual instructions
119
+ const batch = [];
120
+ let index = 0;
121
+ let i = 0;
122
+ const lastIndex = dummyBatches.length - 1;
123
+ for (const dummyIxs of dummyBatches) {
124
+ const isLastIndex = i == lastIndex;
125
+ const currentBatch = [];
126
+ for (const ix of dummyIxs) {
127
+ // If program id is compute budget, ignore
128
+ if (ix.programId.equals(web3.ComputeBudgetProgram.programId))
129
+ continue;
130
+ // Otherwise, include in batch
131
+ currentBatch.push(this.instructions[index++]);
132
+ }
133
+ if (isLastIndex && this._insertNonceAt.onlyEndOfTx) {
134
+ currentBatch.push(yield this.generateNonceAdvanceIx(i));
135
+ }
136
+ batch.push(currentBatch);
137
+ i++;
138
+ }
139
+ return batch;
140
+ });
141
+ }
142
+ /**
143
+ * Builds a batch of executable transaction instructions
144
+ */
145
+ buildBatchWithAlts(description, generalUtility) {
146
+ return __awaiter(this, void 0, void 0, function* () {
147
+ // Download address lookup table from given cluster
148
+ yield this.downloadAlts();
149
+ // Generate dummy instructions for batch calculation
150
+ const [simulationIxs, dummySigners] = this.generateSimulationIxs();
151
+ // Split simulation ixs
152
+ const dummyBatches = yield this.splitToTransactions(simulationIxs, dummySigners);
153
+ // Batch of actual instructions
154
+ const batch = new MultiTransaction_1.MultiTransaction(description, generalUtility, this.latestBlockhash, this.payerKey);
155
+ let index = 0;
156
+ let i = 0;
157
+ const lastIndex = dummyBatches.length - 1;
158
+ for (const dummyIxs of dummyBatches) {
159
+ const isLastIndex = i == lastIndex;
160
+ const currentBatch = [];
161
+ for (const ix of dummyIxs) {
162
+ // If program id is compute budget, ignore
163
+ if (ix.programId.equals(web3.ComputeBudgetProgram.programId))
164
+ continue;
165
+ // Otherwise, include in batch
166
+ currentBatch.push(this.instructions[index++]);
167
+ }
168
+ if (lastIndex !== 0 && isLastIndex && this._insertNonceAt.onlyEndOfTx) {
169
+ currentBatch.push(yield this.generateNonceAdvanceIx(i));
170
+ }
171
+ const alts = this.findRequiredAltsForBatch2(currentBatch);
172
+ batch.push(alts, currentBatch);
173
+ i++;
174
+ }
175
+ return batch;
176
+ });
177
+ }
178
+ /**
179
+ * Split transactions
180
+ *
181
+ * @param simulationIxs
182
+ * @param dummySigners
183
+ * @returns
184
+ */
185
+ splitToTransactions(simulationIxs, dummySigners) {
186
+ return __awaiter(this, void 0, void 0, function* () {
187
+ // Create dummy priority fee instructions for the transaction (to account for total tx size)
188
+ const preIxs = [
189
+ web3.ComputeBudgetProgram.setComputeUnitLimit({
190
+ units: 1400000, // dummy value
191
+ }),
192
+ web3.ComputeBudgetProgram.setComputeUnitPrice({
193
+ microLamports: 1000000, // dummy value
194
+ }),
195
+ ];
196
+ // Run simulation
197
+ let batch = [];
198
+ let result = [];
199
+ for (const ix of simulationIxs) {
200
+ // Include dummy ix to transaction
201
+ batch.push(ix);
202
+ // Calculate transaction size
203
+ try {
204
+ const estimateTxSize = this.getEstimateSize([...preIxs, ...batch]);
205
+ if (estimateTxSize < this.MAX_SIZE)
206
+ continue;
207
+ // Generate dummy nonce advance (anticipation)
208
+ const nonceAdvance = this._insertNonceAt.onlyEndOfTx ? [yield this.generateNonceAdvanceIx(result.length)] : [];
209
+ const txSize = this.calculateTransactionSize(this.latestBlockhash, [...preIxs, ...nonceAdvance, ...batch], dummySigners);
210
+ if (txSize > this.MAX_SIZE) {
211
+ batch.pop();
212
+ result.push([...preIxs, ...batch]);
213
+ batch = [ix];
214
+ }
215
+ }
216
+ catch (_b) {
217
+ batch.pop();
218
+ result.push([...preIxs, ...batch]);
219
+ batch = [ix];
220
+ }
221
+ }
222
+ if (batch.length > 0 && simulationIxs.length !== 0) {
223
+ result.push([...preIxs, ...batch]);
224
+ }
225
+ return result;
226
+ });
227
+ }
228
+ /**
229
+ * Generate nonde advance instruction (dummy instruction)
230
+ */
231
+ generateNonceAdvanceIx(index) {
232
+ return __awaiter(this, void 0, void 0, function* () {
233
+ const noncePubkey = yield (0, functions_1.generateNonceAddressFromIndex)(this.payerKey, index);
234
+ // Generate dummy nonce ix
235
+ return web3.SystemProgram.nonceAdvance({
236
+ /** Nonce account */
237
+ noncePubkey,
238
+ /** Public key of the nonce authority */
239
+ authorizedPubkey: this.payerKey,
240
+ });
241
+ });
242
+ }
243
+ getEstimateSize(ixs) {
244
+ let length = 0;
245
+ const alts = {};
246
+ ixs.map(ix => {
247
+ length += ix.data.length + ix.programId.toBuffer().length;
248
+ ix.keys.map(meta => {
249
+ const alt = this.pubkeyToAlt[meta.pubkey.toString()];
250
+ if (!!alt) {
251
+ alts[alt.key.toString()] = alt;
252
+ length += 3;
253
+ }
254
+ else {
255
+ length += 34;
256
+ }
257
+ });
258
+ });
259
+ for (const _ in alts) {
260
+ length += 32;
261
+ }
262
+ return length;
263
+ }
264
+ /**
265
+ * Find required signers from instructions
266
+ *
267
+ * @param ixs
268
+ * @param dummySigners
269
+ */
270
+ findRequiredSignersFromIxs(ixs) {
271
+ const signers = [];
272
+ signers.push(this.payerKey);
273
+ for (const instruction of ixs) {
274
+ const _signers = instruction.keys
275
+ .filter(meta => meta.isSigner)
276
+ .map(meta => meta.pubkey);
277
+ if (_signers.length > 0) {
278
+ signers.push(..._signers);
279
+ }
280
+ }
281
+ const uniqueSigners = {};
282
+ for (const signer of signers) {
283
+ uniqueSigners[signer.toBase58()] = signer;
284
+ }
285
+ const result = [];
286
+ for (const id in uniqueSigners) {
287
+ result.push(uniqueSigners[id]);
288
+ }
289
+ return result;
290
+ }
291
+ /**
292
+ * Calculate transaction size
293
+ *
294
+ * @param batch
295
+ */
296
+ calculateTransactionSize(latestBlockhash, batch, dummySigners) {
297
+ const alts = this.findRequiredAltsForBatch2(batch);
298
+ const messageV0 = new web3.TransactionMessage({
299
+ payerKey: dummySigners[this.payerKey.toString()].publicKey,
300
+ instructions: batch,
301
+ recentBlockhash: latestBlockhash.blockhash,
302
+ }).compileToV0Message(alts);
303
+ const versionedTx = new web3.VersionedTransaction(messageV0);
304
+ const signers = this.findRequiredSignersFromBatch2(batch, dummySigners);
305
+ versionedTx.sign(signers);
306
+ const bytes = versionedTx.serialize();
307
+ return bytes.length;
308
+ }
309
+ /**
310
+ * Find required address lookup table addresses for given batch of instructions
311
+ *
312
+ * @param batch
313
+ */
314
+ findRequiredAltsForBatch2(batch) {
315
+ const pubkeys = [];
316
+ batch.map(ix => {
317
+ pubkeys.push(...ix.keys.map(meta => meta.pubkey));
318
+ });
319
+ const alts = {};
320
+ for (const pubkey of pubkeys) {
321
+ const alt = this.pubkeyToAlt[pubkey.toString()];
322
+ if (!!alt) {
323
+ alts[alt.key.toString()] = alt;
324
+ }
325
+ }
326
+ const result = [];
327
+ for (const key in alts) {
328
+ result.push(alts[key]);
329
+ }
330
+ return result;
331
+ }
332
+ /**
333
+ * Find required signers from batch
334
+ *
335
+ * @param ixs
336
+ * @param dummySigners
337
+ */
338
+ findRequiredSignersFromBatch2(batch, dummySigners) {
339
+ const signers = this.findRequiredSignersFromIxs(batch);
340
+ const result = [];
341
+ for (const signer of signers) {
342
+ const key = signer.toString();
343
+ result.push(dummySigners[key]);
344
+ }
345
+ return result;
346
+ }
347
+ }
348
+ exports.TransactionBatchExecute2 = TransactionBatchExecute2;
349
+ _a = TransactionBatchExecute2;
350
+ /**
351
+ * Find alt by pubkeys (overridable)
352
+ *
353
+ * @param pubkeys
354
+ */
355
+ TransactionBatchExecute2.jupiterFindAltByPubkeysFn = () => __awaiter(void 0, void 0, void 0, function* () {
356
+ return [];
357
+ });