@hawksightco/hawk-sdk 1.3.264 → 1.3.265

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/package.json +1 -1
  2. package/dist/src/addresses.d.ts +0 -37
  3. package/dist/src/addresses.d.ts.map +0 -1
  4. package/dist/src/addresses.js +0 -84
  5. package/dist/src/anchor.d.ts +0 -22
  6. package/dist/src/anchor.d.ts.map +0 -1
  7. package/dist/src/anchor.js +0 -121
  8. package/dist/src/classes/AltStorage.d.ts +0 -29
  9. package/dist/src/classes/AltStorage.d.ts.map +0 -1
  10. package/dist/src/classes/AltStorage.js +0 -58
  11. package/dist/src/classes/Atomicity.d.ts +0 -34
  12. package/dist/src/classes/Atomicity.d.ts.map +0 -1
  13. package/dist/src/classes/Atomicity.js +0 -110
  14. package/dist/src/classes/Client.d.ts +0 -35
  15. package/dist/src/classes/Client.d.ts.map +0 -1
  16. package/dist/src/classes/Client.js +0 -66
  17. package/dist/src/classes/CombineTransactions.d.ts +0 -11
  18. package/dist/src/classes/CombineTransactions.d.ts.map +0 -1
  19. package/dist/src/classes/CombineTransactions.js +0 -58
  20. package/dist/src/classes/CreateTxMetadata.d.ts +0 -100
  21. package/dist/src/classes/CreateTxMetadata.d.ts.map +0 -1
  22. package/dist/src/classes/CreateTxMetadata.js +0 -415
  23. package/dist/src/classes/General.d.ts +0 -87
  24. package/dist/src/classes/General.d.ts.map +0 -1
  25. package/dist/src/classes/General.js +0 -176
  26. package/dist/src/classes/GeneralUtility.d.ts +0 -79
  27. package/dist/src/classes/GeneralUtility.d.ts.map +0 -1
  28. package/dist/src/classes/GeneralUtility.js +0 -121
  29. package/dist/src/classes/HawkAPI.d.ts +0 -122
  30. package/dist/src/classes/HawkAPI.d.ts.map +0 -1
  31. package/dist/src/classes/HawkAPI.js +0 -169
  32. package/dist/src/classes/Health.d.ts +0 -29
  33. package/dist/src/classes/Health.d.ts.map +0 -1
  34. package/dist/src/classes/Health.js +0 -48
  35. package/dist/src/classes/JupiterAlts.d.ts +0 -37
  36. package/dist/src/classes/JupiterAlts.d.ts.map +0 -1
  37. package/dist/src/classes/JupiterAlts.js +0 -114
  38. package/dist/src/classes/JupiterSwap.d.ts +0 -21
  39. package/dist/src/classes/JupiterSwap.d.ts.map +0 -1
  40. package/dist/src/classes/JupiterSwap.js +0 -40
  41. package/dist/src/classes/Logging.d.ts +0 -13
  42. package/dist/src/classes/Logging.d.ts.map +0 -1
  43. package/dist/src/classes/Logging.js +0 -50
  44. package/dist/src/classes/MultiTransaction.d.ts +0 -75
  45. package/dist/src/classes/MultiTransaction.d.ts.map +0 -1
  46. package/dist/src/classes/MultiTransaction.js +0 -296
  47. package/dist/src/classes/RaydiumSDK.d.ts +0 -67
  48. package/dist/src/classes/RaydiumSDK.d.ts.map +0 -1
  49. package/dist/src/classes/RaydiumSDK.js +0 -206
  50. package/dist/src/classes/Search.d.ts +0 -100
  51. package/dist/src/classes/Search.d.ts.map +0 -1
  52. package/dist/src/classes/Search.js +0 -216
  53. package/dist/src/classes/SimpleIxGenerator.d.ts +0 -57
  54. package/dist/src/classes/SimpleIxGenerator.d.ts.map +0 -1
  55. package/dist/src/classes/SimpleIxGenerator.js +0 -62
  56. package/dist/src/classes/SimplePdaGenerator.d.ts +0 -28
  57. package/dist/src/classes/SimplePdaGenerator.d.ts.map +0 -1
  58. package/dist/src/classes/SimplePdaGenerator.js +0 -33
  59. package/dist/src/classes/Transaction.d.ts +0 -229
  60. package/dist/src/classes/Transaction.d.ts.map +0 -1
  61. package/dist/src/classes/Transaction.js +0 -643
  62. package/dist/src/classes/Transaction2.d.ts +0 -107
  63. package/dist/src/classes/Transaction2.d.ts.map +0 -1
  64. package/dist/src/classes/Transaction2.js +0 -249
  65. package/dist/src/classes/Transaction3.d.ts +0 -165
  66. package/dist/src/classes/Transaction3.d.ts.map +0 -1
  67. package/dist/src/classes/Transaction3.js +0 -416
  68. package/dist/src/classes/TransactionBatchExecute.d.ts +0 -163
  69. package/dist/src/classes/TransactionBatchExecute.d.ts.map +0 -1
  70. package/dist/src/classes/TransactionBatchExecute.js +0 -466
  71. package/dist/src/classes/TransactionBatchExecute2.d.ts +0 -99
  72. package/dist/src/classes/TransactionBatchExecute2.d.ts.map +0 -1
  73. package/dist/src/classes/TransactionBatchExecute2.js +0 -357
  74. package/dist/src/classes/Transactions.d.ts +0 -586
  75. package/dist/src/classes/Transactions.d.ts.map +0 -1
  76. package/dist/src/classes/Transactions.js +0 -7658
  77. package/dist/src/classes/TxGenerator.d.ts +0 -350
  78. package/dist/src/classes/TxGenerator.d.ts.map +0 -1
  79. package/dist/src/classes/TxGenerator.js +0 -1957
  80. package/dist/src/classes/TxGeneratorAutomations.d.ts +0 -186
  81. package/dist/src/classes/TxGeneratorAutomations.d.ts.map +0 -1
  82. package/dist/src/classes/TxGeneratorAutomations.js +0 -897
  83. package/dist/src/classes/Util.d.ts +0 -87
  84. package/dist/src/classes/Util.d.ts.map +0 -1
  85. package/dist/src/classes/Util.js +0 -148
  86. package/dist/src/classes/account-cache/AccountCache.d.ts +0 -54
  87. package/dist/src/classes/account-cache/AccountCache.d.ts.map +0 -1
  88. package/dist/src/classes/account-cache/AccountCache.js +0 -143
  89. package/dist/src/classes/account-cache/MintCache.d.ts +0 -33
  90. package/dist/src/classes/account-cache/MintCache.d.ts.map +0 -1
  91. package/dist/src/classes/account-cache/MintCache.js +0 -47
  92. package/dist/src/classes/account-cache/TokenCache.d.ts +0 -33
  93. package/dist/src/classes/account-cache/TokenCache.d.ts.map +0 -1
  94. package/dist/src/classes/account-cache/TokenCache.js +0 -47
  95. package/dist/src/errors.d.ts +0 -13
  96. package/dist/src/errors.d.ts.map +0 -1
  97. package/dist/src/errors.js +0 -96
  98. package/dist/src/functions.d.ts +0 -514
  99. package/dist/src/functions.d.ts.map +0 -1
  100. package/dist/src/functions.js +0 -1636
  101. package/dist/src/hawksight.d.ts +0 -53
  102. package/dist/src/hawksight.d.ts.map +0 -1
  103. package/dist/src/hawksight.js +0 -328
  104. package/dist/src/hsToMeteora.d.ts +0 -31
  105. package/dist/src/hsToMeteora.d.ts.map +0 -1
  106. package/dist/src/hsToMeteora.js +0 -3175
  107. package/dist/src/idl/iyf-extension-idl.d.ts +0 -14583
  108. package/dist/src/idl/iyf-extension-idl.d.ts.map +0 -1
  109. package/dist/src/idl/iyf-extension-idl.js +0 -14578
  110. package/dist/src/idl/iyf-extension-wrapper.d.ts +0 -112
  111. package/dist/src/idl/iyf-extension-wrapper.d.ts.map +0 -1
  112. package/dist/src/idl/iyf-extension-wrapper.js +0 -2
  113. package/dist/src/idl/iyf-main-idl.d.ts +0 -11329
  114. package/dist/src/idl/iyf-main-idl.d.ts.map +0 -1
  115. package/dist/src/idl/iyf-main-idl.js +0 -11324
  116. package/dist/src/idl/iyf-main-wrapper.d.ts +0 -112
  117. package/dist/src/idl/iyf-main-wrapper.d.ts.map +0 -1
  118. package/dist/src/idl/iyf-main-wrapper.js +0 -2
  119. package/dist/src/idl/jupiter-idl.d.ts +0 -3063
  120. package/dist/src/idl/jupiter-idl.d.ts.map +0 -1
  121. package/dist/src/idl/jupiter-idl.js +0 -3061
  122. package/dist/src/idl/meteora-idl.d.ts +0 -7371
  123. package/dist/src/idl/meteora-idl.d.ts.map +0 -1
  124. package/dist/src/idl/meteora-idl.js +0 -7372
  125. package/dist/src/idl/orca-idl.d.ts +0 -3833
  126. package/dist/src/idl/orca-idl.d.ts.map +0 -1
  127. package/dist/src/idl/orca-idl.js +0 -3834
  128. package/dist/src/idl/raydium-idl.d.ts +0 -3054
  129. package/dist/src/idl/raydium-idl.d.ts.map +0 -1
  130. package/dist/src/idl/raydium-idl.js +0 -3055
  131. package/dist/src/index.d.ts +0 -9
  132. package/dist/src/index.d.ts.map +0 -1
  133. package/dist/src/index.js +0 -31
  134. package/dist/src/ixGenerator/IyfExtensionIxGenerator.d.ts +0 -126
  135. package/dist/src/ixGenerator/IyfExtensionIxGenerator.d.ts.map +0 -1
  136. package/dist/src/ixGenerator/IyfExtensionIxGenerator.js +0 -467
  137. package/dist/src/ixGenerator/IyfMainIxGenerator.d.ts +0 -330
  138. package/dist/src/ixGenerator/IyfMainIxGenerator.d.ts.map +0 -1
  139. package/dist/src/ixGenerator/IyfMainIxGenerator.js +0 -1239
  140. package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.d.ts +0 -685
  141. package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.d.ts.map +0 -1
  142. package/dist/src/ixGenerator/MeteoraDlmmIxGenerator.js +0 -3005
  143. package/dist/src/ixGenerator/OrcaIxGenerator.d.ts +0 -119
  144. package/dist/src/ixGenerator/OrcaIxGenerator.d.ts.map +0 -1
  145. package/dist/src/ixGenerator/OrcaIxGenerator.js +0 -438
  146. package/dist/src/ixGenerator/RaydiumIxGenerator.d.ts +0 -99
  147. package/dist/src/ixGenerator/RaydiumIxGenerator.d.ts.map +0 -1
  148. package/dist/src/ixGenerator/RaydiumIxGenerator.js +0 -558
  149. package/dist/src/ixGenerator/UtilIxGenerator.d.ts +0 -20
  150. package/dist/src/ixGenerator/UtilIxGenerator.d.ts.map +0 -1
  151. package/dist/src/ixGenerator/UtilIxGenerator.js +0 -25
  152. package/dist/src/meteora/index.d.ts +0 -2
  153. package/dist/src/meteora/index.d.ts.map +0 -1
  154. package/dist/src/meteora/index.js +0 -17
  155. package/dist/src/meteora/liquidityStrategy.d.ts +0 -408
  156. package/dist/src/meteora/liquidityStrategy.d.ts.map +0 -1
  157. package/dist/src/meteora/liquidityStrategy.js +0 -1325
  158. package/dist/src/meteora.d.ts +0 -669
  159. package/dist/src/meteora.d.ts.map +0 -1
  160. package/dist/src/meteora.js +0 -1932
  161. package/dist/src/orca.d.ts +0 -57
  162. package/dist/src/orca.d.ts.map +0 -1
  163. package/dist/src/orca.js +0 -123
  164. package/dist/src/pdaGenerator/HawksightPdaGenerator.d.ts +0 -29
  165. package/dist/src/pdaGenerator/HawksightPdaGenerator.d.ts.map +0 -1
  166. package/dist/src/pdaGenerator/HawksightPdaGenerator.js +0 -75
  167. package/dist/src/pdaGenerator/MeteoraPdaGenerator.d.ts +0 -76
  168. package/dist/src/pdaGenerator/MeteoraPdaGenerator.d.ts.map +0 -1
  169. package/dist/src/pdaGenerator/MeteoraPdaGenerator.js +0 -166
  170. package/dist/src/pdaGenerator/OrcaPdaGenerator.d.ts +0 -23
  171. package/dist/src/pdaGenerator/OrcaPdaGenerator.d.ts.map +0 -1
  172. package/dist/src/pdaGenerator/OrcaPdaGenerator.js +0 -68
  173. package/dist/src/pdaGenerator/RaydiumPdaGenerator.d.ts +0 -49
  174. package/dist/src/pdaGenerator/RaydiumPdaGenerator.d.ts.map +0 -1
  175. package/dist/src/pdaGenerator/RaydiumPdaGenerator.js +0 -114
  176. package/dist/src/pdaGenerator/UtilPdaGenerator.d.ts +0 -8
  177. package/dist/src/pdaGenerator/UtilPdaGenerator.d.ts.map +0 -1
  178. package/dist/src/pdaGenerator/UtilPdaGenerator.js +0 -51
  179. package/dist/src/types.d.ts +0 -1100
  180. package/dist/src/types.d.ts.map +0 -1
  181. package/dist/src/types.js +0 -95
@@ -1,466 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
45
- exports.TransactionBatchExecute = void 0;
46
- const web3 = __importStar(require("@solana/web3.js"));
47
- const Logging_1 = require("./Logging");
48
- /**
49
- * Executes transactions in batches
50
- */
51
- class TransactionBatchExecute {
52
- /**
53
- * Creates an instance of TransactionExecute class
54
- *
55
- * @param lookupTableAddresses Address lookup table addresses to be used by batch of transactions
56
- * @param instructions Array of instructions to be batched into transactions
57
- * @param payer Payer that will pay for the batch of transactions
58
- * @param connection Connection to mainnet
59
- * @param signers Required signers to fulfill the transactions
60
- */
61
- constructor(lookupTableAddresses, instructions, payer, connection, signers = [], jupiterAlts) {
62
- this.lookupTableAddresses = lookupTableAddresses;
63
- this.instructions = instructions;
64
- this.payer = payer;
65
- this.connection = connection;
66
- this.signers = signers;
67
- this.jupiterAlts = jupiterAlts;
68
- this.MAX_SIZE = 1232;
69
- /**
70
- * Downloaded address lookup table accounts
71
- */
72
- this.alts = [];
73
- /**
74
- * Map of public keys to address lookup table
75
- */
76
- this.pubkeyToAlt = {};
77
- }
78
- ;
79
- /**
80
- * Download all jupiter alts (overridable)
81
- */
82
- jupiterDownloadAlts() {
83
- return __awaiter(this, void 0, void 0, function* () {
84
- if (this.jupiterAlts) {
85
- yield this.jupiterAlts.downloadAlts();
86
- }
87
- else {
88
- throw new Error('Unexpected error: jupiterDownloadAlts not implemented!');
89
- }
90
- });
91
- }
92
- /**
93
- * Find alt by pubkeys (overridable)
94
- */
95
- jupiterFindAltByPubkeys(pubkeys) {
96
- return __awaiter(this, void 0, void 0, function* () {
97
- if (this.jupiterAlts) {
98
- return this.jupiterAlts.findAltByPubkeys(pubkeys);
99
- }
100
- else {
101
- throw new Error('Unexpected error: jupiterFindAltByPubkeys not implemented!');
102
- }
103
- });
104
- }
105
- /**
106
- * Downoad address lookup table from given cluster
107
- */
108
- downloadAlts() {
109
- return __awaiter(this, void 0, void 0, function* () {
110
- // Public keys across all instructions
111
- const pubkeys = this.getPubkeyFromInstruction();
112
- // Download jupiter alts first
113
- yield this.jupiterDownloadAlts();
114
- // Then find alts from pubkeys
115
- const jupAlts = yield this.jupiterFindAltByPubkeys(pubkeys);
116
- // Then append jupiter alts in the lookup table address
117
- this.lookupTableAddresses.push(...jupAlts);
118
- // Then make sure lookup table addresses are unique
119
- this.filterLookupTables();
120
- // Get list of lookup tables to download
121
- const lookupTableAddresses = this.getListOfAltsToDownload();
122
- // Download if address lookup table does not match with downloaded alts
123
- yield this.downloadAlts2(lookupTableAddresses);
124
- // Map public key to alt
125
- const s0 = new Date().getTime() / 1000;
126
- this.mapPubkeyToAlt(pubkeys);
127
- (0, Logging_1.Log)(`TransactionBatchExecute::downloadAlts(): this.mapPubkeyToAlt benchmark: ${(new Date().getTime() / 1000) - s0}`);
128
- });
129
- }
130
- /**
131
- * Downoad address lookup table from given cluster
132
- */
133
- downloadAlts2(lookupTableAddresses) {
134
- return __awaiter(this, void 0, void 0, function* () {
135
- for (const lookupTable of lookupTableAddresses) {
136
- const alt = yield this.connection.getAddressLookupTable(lookupTable);
137
- if (alt.value === null) {
138
- throw new Error(`Address lookup table: ${lookupTable} does not exist on the blockchain.`);
139
- }
140
- this.alts.push(alt.value);
141
- }
142
- });
143
- }
144
- /**
145
- * Map public key to alt
146
- *
147
- * @param pubkeys
148
- */
149
- mapPubkeyToAlt(pubkeys) {
150
- const addressesInAlt = [];
151
- const map = {};
152
- for (const alt of this.alts) {
153
- const addresses = alt.state.addresses.map(p => p.toString());
154
- addressesInAlt.push(...addresses);
155
- map[alt.key.toString()] = [alt, addresses];
156
- }
157
- for (const pubkey of pubkeys) {
158
- // If pubkey is not in alt, then skip
159
- const inAlt = addressesInAlt.includes(pubkey.toString());
160
- if (!inAlt)
161
- continue;
162
- // Find the alt where public key is included
163
- for (const key in map) {
164
- if (map[key][1].includes(pubkey.toString())) {
165
- this.pubkeyToAlt[pubkey.toString()] = map[key][0];
166
- break;
167
- }
168
- }
169
- }
170
- }
171
- /**
172
- * Get list of lookup tables to download
173
- */
174
- getListOfAltsToDownload() {
175
- const alts = this.alts.map(alt => alt.key.toBase58());
176
- const toDownload = [];
177
- for (const alt of this.lookupTableAddresses) {
178
- if (!alts.includes(alt.toBase58())) {
179
- toDownload.push(alt);
180
- }
181
- }
182
- return toDownload;
183
- }
184
- /**
185
- * Filter lookup tables
186
- */
187
- filterLookupTables() {
188
- const map = {};
189
- for (const alt of this.lookupTableAddresses) {
190
- map[alt.toBase58()] = 1;
191
- }
192
- const filtered = [];
193
- for (const alt in map) {
194
- filtered.push(new web3.PublicKey(alt));
195
- }
196
- this.lookupTableAddresses = filtered;
197
- }
198
- /**
199
- * Get public keys from instruction
200
- * @returns
201
- */
202
- getPubkeyFromInstruction() {
203
- const pubkeys = [];
204
- this.instructions.map(ix => {
205
- pubkeys.push(...ix.keys.map(meta => meta.pubkey));
206
- });
207
- return pubkeys;
208
- }
209
- /**
210
- * Override signers (in case that signers are set to empty array)
211
- *
212
- * @param signers
213
- */
214
- setSigners(signers) {
215
- this.signers = signers;
216
- }
217
- /**
218
- * Find missing signers
219
- */
220
- findMissingSigners() {
221
- const requiredSigners = this.findRequiredSigningPubkeys();
222
- if (requiredSigners.length > this.signers.length) {
223
- return requiredSigners;
224
- }
225
- const missingSigners = [];
226
- for (const requiredSigner of requiredSigners) {
227
- const match = this.signers.find(v => v.publicKey.toBase58() === requiredSigner.toBase58());
228
- if (!!match)
229
- continue;
230
- missingSigners.push(requiredSigner);
231
- }
232
- return missingSigners;
233
- }
234
- /**
235
- * Returns list of public keys that are required to sign the batch of transaction
236
- */
237
- findRequiredSigningPubkeys() {
238
- return this.findRequiredSignersFromIxs(this.instructions);
239
- }
240
- /**
241
- * Generate dummy signers needed for simulation
242
- *
243
- * @returns
244
- */
245
- generateDummySigners() {
246
- const requiredSigners = this.findRequiredSigningPubkeys();
247
- const dummySigners = {};
248
- for (const signer of requiredSigners) {
249
- dummySigners[signer.toString()] = web3.Keypair.generate();
250
- }
251
- return dummySigners;
252
- }
253
- /**
254
- * Generate instruction that has modified signers for simulation purposes
255
- */
256
- generateSimulationIxs() {
257
- const dummySigners = this.generateDummySigners();
258
- let simulationIxs = this.instructions;
259
- for (const pubkey in dummySigners) {
260
- simulationIxs = simulationIxs.map(ix => {
261
- const keys = ix.keys.map(meta => {
262
- if (meta.pubkey.toString() === pubkey && meta.isSigner) {
263
- return Object.assign(Object.assign({}, meta), { pubkey: dummySigners[pubkey].publicKey });
264
- }
265
- return meta;
266
- });
267
- return Object.assign(Object.assign({}, ix), { keys });
268
- });
269
- }
270
- return [simulationIxs, dummySigners];
271
- }
272
- /**
273
- * Builds a batch of executable transaction instructions
274
- */
275
- buildBatch() {
276
- return __awaiter(this, void 0, void 0, function* () {
277
- // Download address lookup table from given cluster
278
- yield this.downloadAlts();
279
- // Generate dummy instructions for batch calculation
280
- const [simulationIxs, dummySigners] = this.generateSimulationIxs();
281
- // Split simulation ixs
282
- const dummyBatches = yield this.splitToTransactions(simulationIxs, dummySigners);
283
- // Batch of actual instructions
284
- const batch = [];
285
- let index = 0;
286
- for (const dummyIxs of dummyBatches) {
287
- const currentBatch = [];
288
- for (const dummyIx of dummyIxs) {
289
- currentBatch.push(this.instructions[index++]);
290
- }
291
- batch.push(currentBatch);
292
- }
293
- return batch;
294
- });
295
- }
296
- /**
297
- * Build versioned transactions from given batches of transactions
298
- *
299
- * @param batches
300
- * @returns
301
- */
302
- buildV0Transactions(batches) {
303
- return __awaiter(this, void 0, void 0, function* () {
304
- const latestBlockhash = yield this.connection.getLatestBlockhash();
305
- const signedVersionedTxs = [];
306
- for (const batch of batches) {
307
- const alts = this.findRequiredAltsForBatch(batch);
308
- const messageV0 = new web3.TransactionMessage({
309
- payerKey: this.payer.publicKey,
310
- instructions: batch,
311
- recentBlockhash: latestBlockhash.blockhash,
312
- }).compileToV0Message(alts);
313
- const versionedTx = new web3.VersionedTransaction(messageV0);
314
- const signers = this.findSigningKeypairFromIxs(batch);
315
- versionedTx.sign(signers);
316
- signedVersionedTxs.push(versionedTx);
317
- }
318
- return signedVersionedTxs;
319
- });
320
- }
321
- /**
322
- * Split transactions
323
- *
324
- * @param simulationIxs
325
- * @param dummySigners
326
- * @returns
327
- */
328
- splitToTransactions(simulationIxs, dummySigners) {
329
- return __awaiter(this, void 0, void 0, function* () {
330
- // Fetch latest blockhash required to calculate transaction size
331
- const latestBlockhash = yield this.connection.getLatestBlockhash();
332
- // Run simulation
333
- let batch = [];
334
- let result = [];
335
- for (const ix of simulationIxs) {
336
- // Include dummy ix to transaction
337
- batch.push(ix);
338
- // Calculate transaction size
339
- const txSize = this.calculateTransactionSize(latestBlockhash, batch, dummySigners);
340
- if (txSize > this.MAX_SIZE) {
341
- batch.pop();
342
- result.push(batch);
343
- batch = [ix];
344
- }
345
- }
346
- if (batch.length > 0 && simulationIxs.length !== 0) {
347
- result.push(batch);
348
- }
349
- return result;
350
- });
351
- }
352
- /**
353
- * Calculate transaction size
354
- *
355
- * @param batch
356
- */
357
- calculateTransactionSize(latestBlockhash, batch, dummySigners) {
358
- const alts = this.findRequiredAltsForBatch(batch);
359
- const messageV0 = new web3.TransactionMessage({
360
- payerKey: this.payer.publicKey,
361
- instructions: batch,
362
- recentBlockhash: latestBlockhash.blockhash,
363
- }).compileToV0Message(alts);
364
- const versionedTx = new web3.VersionedTransaction(messageV0);
365
- const signers = this.findRequiredSignersFromBatch(batch, dummySigners);
366
- versionedTx.sign(signers);
367
- const bytes = versionedTx.serialize();
368
- return bytes.length;
369
- }
370
- /**
371
- * Find required signers from instructions
372
- *
373
- * @param ixs
374
- * @param dummySigners
375
- */
376
- findRequiredSignersFromIxs(ixs) {
377
- const signers = [];
378
- signers.push(this.payer.publicKey);
379
- for (const instruction of ixs) {
380
- const _signers = instruction.keys
381
- .filter(meta => meta.isSigner)
382
- .map(meta => meta.pubkey);
383
- if (_signers.length > 0) {
384
- signers.push(..._signers);
385
- }
386
- }
387
- const uniqueSigners = {};
388
- for (const signer of signers) {
389
- uniqueSigners[signer.toBase58()] = signer;
390
- }
391
- const result = [];
392
- for (const id in uniqueSigners) {
393
- result.push(uniqueSigners[id]);
394
- }
395
- return result;
396
- }
397
- /**
398
- * Find required signers from batch
399
- *
400
- * @param ixs
401
- * @param dummySigners
402
- */
403
- findRequiredSignersFromBatch(batch, dummySigners) {
404
- const signers = this.findRequiredSignersFromIxs(batch);
405
- const result = [];
406
- for (const key in dummySigners) {
407
- const dummySigner = signers.find(signer => signer.toBase58() === dummySigners[key].publicKey.toBase58());
408
- if (dummySigner === undefined) {
409
- throw new Error('Unexpected error: Dummy signer not found (it should never happen)');
410
- }
411
- result.push(dummySigners[key]);
412
- }
413
- return result;
414
- }
415
- /**
416
- * Find signing keypairs from signers defined in instruction
417
- *
418
- * @param batch
419
- * @returns
420
- */
421
- findSigningKeypairFromIxs(batch) {
422
- const signers = this.findRequiredSignersFromIxs(batch);
423
- const result = [];
424
- for (const signer of signers) {
425
- const keypair = this.signers.find(keypair => keypair.publicKey.toBase58() === signer.toBase58());
426
- if (keypair === undefined) {
427
- throw new Error(`Keypair ${signer} cannot be found in $this.signers array. Perhaps you forgot to add it?`);
428
- }
429
- result.push(keypair);
430
- }
431
- return result;
432
- }
433
- /**
434
- * Find required address lookup table addresses for given batch of instructions
435
- *
436
- * @param batch
437
- */
438
- findRequiredAltsForBatch(batch) {
439
- const uniquePubkeys = {};
440
- batch.map(ix => {
441
- const pubkeys = ix.keys.map(meta => meta.pubkey);
442
- for (const pubkey of pubkeys) {
443
- uniquePubkeys[pubkey.toBase58()] = 1;
444
- }
445
- });
446
- const pubkeys = [];
447
- for (const pubkey in uniquePubkeys) {
448
- pubkeys.push(new web3.PublicKey(pubkey));
449
- }
450
- const alts = {};
451
- for (const alt of this.alts) {
452
- for (const pubkey of pubkeys) {
453
- const match = alt.state.addresses.find(address => pubkey.toBase58() === address.toBase58());
454
- if (!!match) {
455
- alts[alt.key.toString()] = alt;
456
- }
457
- }
458
- }
459
- const result = [];
460
- for (const key in alts) {
461
- result.push(alts[key]);
462
- }
463
- return result;
464
- }
465
- }
466
- exports.TransactionBatchExecute = TransactionBatchExecute;
@@ -1,99 +0,0 @@
1
- import * as web3 from '@solana/web3.js';
2
- import { TransactionBatchExecute, DummySigners } from './TransactionBatchExecute';
3
- import { CreateTxMetadata } from './CreateTxMetadata';
4
- import { InsertNonceAtOpt } from '../types';
5
- import { GeneralUtility } from './GeneralUtility';
6
- import { MultiTransaction } from './MultiTransaction';
7
- /**
8
- * Executes transactions in batches
9
- */
10
- export declare class TransactionBatchExecute2 extends TransactionBatchExecute {
11
- protected lookupTableAddresses: web3.PublicKey[];
12
- protected instructions: web3.TransactionInstruction[];
13
- protected connection: web3.Connection;
14
- protected createTxMetadataInstance: CreateTxMetadata;
15
- protected latestBlockhash: web3.BlockhashWithExpiryBlockHeight;
16
- protected payerKey: web3.PublicKey;
17
- private _insertNonceAt;
18
- /**
19
- * Creates an instance of TransactionExecute class
20
- *
21
- * @param lookupTableAddresses Address lookup table addresses to be used by batch of transactions
22
- * @param instructions Array of instructions to be batched into transactions
23
- * @param payer Payer that will pay for the batch of transactions
24
- * @param connection Connection to mainnet
25
- */
26
- constructor(lookupTableAddresses: web3.PublicKey[], instructions: web3.TransactionInstruction[], connection: web3.Connection, createTxMetadataInstance: CreateTxMetadata, latestBlockhash: web3.BlockhashWithExpiryBlockHeight, payerKey: web3.PublicKey);
27
- /**
28
- * Find alt by pubkeys (overridable)
29
- *
30
- * @param pubkeys
31
- */
32
- static jupiterFindAltByPubkeysFn: (pubkeys: web3.PublicKey[]) => Promise<web3.PublicKey[]>;
33
- /**
34
- * Download all jupiter alts (overridable)
35
- */
36
- protected jupiterDownloadAlts(): Promise<void>;
37
- /**
38
- * Find alt by pubkeys (overridable)
39
- */
40
- protected jupiterFindAltByPubkeys(pubkeys: web3.PublicKey[]): Promise<web3.PublicKey[]>;
41
- /**
42
- * Downoad address lookup table from given cluster
43
- */
44
- protected downloadAlts2(lookupTableAddresses: web3.PublicKey[]): Promise<void>;
45
- /**
46
- * Option to include nonce advance instruction
47
- *
48
- * @param opt
49
- */
50
- insertNonceAt(opt: InsertNonceAtOpt): void;
51
- /**
52
- * Builds a batch of executable transaction instructions
53
- */
54
- buildBatch(): Promise<web3.TransactionInstruction[][]>;
55
- /**
56
- * Builds a batch of executable transaction instructions
57
- */
58
- buildBatchWithAlts(description: string, generalUtility: GeneralUtility): Promise<MultiTransaction>;
59
- /**
60
- * Split transactions
61
- *
62
- * @param simulationIxs
63
- * @param dummySigners
64
- * @returns
65
- */
66
- protected splitToTransactions(simulationIxs: web3.TransactionInstruction[], dummySigners: DummySigners): Promise<web3.TransactionInstruction[][]>;
67
- /**
68
- * Generate nonde advance instruction (dummy instruction)
69
- */
70
- private generateNonceAdvanceIx;
71
- private getEstimateSize;
72
- /**
73
- * Find required signers from instructions
74
- *
75
- * @param ixs
76
- * @param dummySigners
77
- */
78
- protected findRequiredSignersFromIxs(ixs: web3.TransactionInstruction[]): web3.PublicKey[];
79
- /**
80
- * Calculate transaction size
81
- *
82
- * @param batch
83
- */
84
- protected calculateTransactionSize(latestBlockhash: web3.BlockhashWithExpiryBlockHeight, batch: web3.TransactionInstruction[], dummySigners: DummySigners): number;
85
- /**
86
- * Find required address lookup table addresses for given batch of instructions
87
- *
88
- * @param batch
89
- */
90
- findRequiredAltsForBatch2(batch: web3.TransactionInstruction[]): web3.AddressLookupTableAccount[];
91
- /**
92
- * Find required signers from batch
93
- *
94
- * @param ixs
95
- * @param dummySigners
96
- */
97
- private findRequiredSignersFromBatch2;
98
- }
99
- //# sourceMappingURL=TransactionBatchExecute2.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TransactionBatchExecute2.d.ts","sourceRoot":"","sources":["../../../src/classes/TransactionBatchExecute2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,uBAAuB;IAajE,SAAS,CAAC,oBAAoB,EAAE,IAAI,CAAC,SAAS,EAAE;IAChD,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,sBAAsB,EAAE;IACrD,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU;IACrC,SAAS,CAAC,wBAAwB,EAAE,gBAAgB;IACpD,SAAS,CAAC,eAAe,EAAE,IAAI,CAAC,8BAA8B;IAC9D,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS;IAhBpC,OAAO,CAAC,cAAc,CAAwB;IAE9C;;;;;;;OAOG;gBAES,oBAAoB,EAAE,IAAI,CAAC,SAAS,EAAE,EACtC,YAAY,EAAE,IAAI,CAAC,sBAAsB,EAAE,EAC3C,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,wBAAwB,EAAE,gBAAgB,EAC1C,eAAe,EAAE,IAAI,CAAC,8BAA8B,EACpD,QAAQ,EAAE,IAAI,CAAC,SAAS;IAWpC;;;;OAIG;IACH,MAAM,CAAC,yBAAyB,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAEzF;IAED;;OAEG;cACa,mBAAmB;IAEnC;;OAEG;cACa,uBAAuB,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;IAI7F;;OAEG;cACa,aAAa,CAAC,oBAAoB,EAAE,IAAI,CAAC,SAAS,EAAE;IAMpE;;;;OAIG;IACH,aAAa,CAAC,GAAG,EAAE,gBAAgB;IAInC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,EAAE,CAAC;IAmC5D;;OAEG;IACG,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAqCxG;;;;;;OAMG;cACa,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,sBAAsB,EAAE,EAAE,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,EAAE,CAAC;IAgDvJ;;OAEG;YACW,sBAAsB;IAWpC,OAAO,CAAC,eAAe;IAqBvB;;;;;OAKG;IACH,SAAS,CAAC,0BAA0B,CAAC,GAAG,EAAE,IAAI,CAAC,sBAAsB,EAAE,GAAG,IAAI,CAAC,SAAS,EAAE;IAsB1F;;;;OAIG;IACH,SAAS,CAAC,wBAAwB,CAAC,eAAe,EAAE,IAAI,CAAC,8BAA8B,EAAE,KAAK,EAAE,IAAI,CAAC,sBAAsB,EAAE,EAAE,YAAY,EAAE,YAAY,GAAG,MAAM;IAclK;;;;OAIG;IACI,yBAAyB,CAAC,KAAK,EAAE,IAAI,CAAC,sBAAsB,EAAE,GAAG,IAAI,CAAC,yBAAyB,EAAE;IAmBxG;;;;;OAKG;IACH,OAAO,CAAC,6BAA6B;CAStC"}