@hawksightco/hawk-sdk 0.0.13 → 0.0.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.
- package/package.json +1 -1
- package/dist/src/classes/Client.d.ts +0 -35
- package/dist/src/classes/Client.d.ts.map +0 -1
- package/dist/src/classes/Client.js +0 -56
- package/dist/src/classes/General.d.ts +0 -68
- package/dist/src/classes/General.d.ts.map +0 -1
- package/dist/src/classes/General.js +0 -133
- package/dist/src/classes/GeneralUtility.d.ts +0 -34
- package/dist/src/classes/GeneralUtility.d.ts.map +0 -1
- package/dist/src/classes/GeneralUtility.js +0 -52
- package/dist/src/classes/HawkAPI.d.ts +0 -36
- package/dist/src/classes/HawkAPI.d.ts.map +0 -1
- package/dist/src/classes/HawkAPI.js +0 -36
- package/dist/src/classes/Health.d.ts +0 -29
- package/dist/src/classes/Health.d.ts.map +0 -1
- package/dist/src/classes/Health.js +0 -48
- package/dist/src/classes/Transaction.d.ts +0 -87
- package/dist/src/classes/Transaction.d.ts.map +0 -1
- package/dist/src/classes/Transaction.js +0 -250
- package/dist/src/classes/TxGenerator.d.ts +0 -131
- package/dist/src/classes/TxGenerator.d.ts.map +0 -1
- package/dist/src/classes/TxGenerator.js +0 -242
- package/dist/src/classes/TxGeneratorAutomations.d.ts +0 -70
- package/dist/src/classes/TxGeneratorAutomations.d.ts.map +0 -1
- package/dist/src/classes/TxGeneratorAutomations.js +0 -121
- package/dist/src/classes/Util.d.ts +0 -65
- package/dist/src/classes/Util.d.ts.map +0 -1
- package/dist/src/classes/Util.js +0 -115
- package/dist/src/functions.d.ts +0 -44
- package/dist/src/functions.d.ts.map +0 -1
- package/dist/src/functions.js +0 -129
- package/dist/src/index.d.ts +0 -3
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -20
- package/dist/src/types.d.ts +0 -268
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -17
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.d.ts","sourceRoot":"","sources":["../../../src/classes/Transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAGrF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;GAGG;AACH,qBAAa,WAAW;IAiCpB,QAAQ,CAAC,kBAAkB,EAAE,2BAA2B;IACxD,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS;IACjC,OAAO,CAAC,gBAAgB;IACxB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,yBAAyB,EAAE;IAlCjD,2FAA2F;IAC3F,OAAO,CAAC,UAAU,CAA0B;IAC5C,IAAI,SAAS,IAAI,IAAI,CAAC,kBAAkB,CAA2B;IAEnE,+DAA+D;IAC/D,OAAO,CAAC,qBAAqB,CAA4B;IACzD,IAAI,oBAAoB,IAAI,IAAI,CAAC,oBAAoB,CAAuC;IAE5F,+EAA+E;IAC/E,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAElD,oFAAoF;IACpF,OAAO,CAAC,oBAAoB,CAAc;IAC1C,IAAI,mBAAmB,IAAI,MAAM,CAAsC;IAEvE,6CAA6C;IAC7C,IAAI,eAAe,IAAI,MAAM,CAAkC;IAE/D,yEAAyE;IACzE,OAAO,CAAC,aAAa,CAAgC;IACrD,IAAI,YAAY,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAA+B;IAEhF;;;;;;;OAOG;gBAEQ,kBAAkB,EAAE,2BAA2B,EAC/C,QAAQ,EAAE,IAAI,CAAC,SAAS,EACzB,gBAAgB,EAAE,MAAM,EACvB,IAAI,EAAE,IAAI,CAAC,yBAAyB,EAAE;IAkCjD;;;;;;OAMG;IACH,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,UAAU,GAAE,OAAe,GAAG,IAAI;IAqB/D;;;;OAIG;IACH,yBAAyB,IAAI,OAAO;IAIpC;;OAEG;IACG,gBAAgB,CACpB,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,aAAa,EAAE,MAAM,CAAC,0CAA0C,EAChE,gBAAgB,EAAE,MAAM,EACxB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC;IA+BzC;;;;;OAKG;IACG,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,4BAA4B,CAAC;IA+B7F;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAWxB;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAS1B;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAQpC;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAQpC;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAW7B"}
|
|
@@ -1,250 +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 (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.Transaction = void 0;
|
|
36
|
-
const web3 = __importStar(require("@solana/web3.js"));
|
|
37
|
-
const functions_1 = require("../functions");
|
|
38
|
-
const bn_js_1 = require("bn.js");
|
|
39
|
-
/**
|
|
40
|
-
* Represents a transaction object in Solana using the web3.js library.
|
|
41
|
-
* This class encapsulates the logic for creating, signing, and verifying signatures of transactions.
|
|
42
|
-
*/
|
|
43
|
-
class Transaction {
|
|
44
|
-
get txMessage() { return this._txMessage; }
|
|
45
|
-
get versionedTransaction() { return this._versionedTransaction; }
|
|
46
|
-
get priorityFeeEstimate() { return this._priorityFeeEstimate; }
|
|
47
|
-
/** The blockhash of a recent ledger entry */
|
|
48
|
-
get recentBlockhash() { return this._recentBlockhash; }
|
|
49
|
-
get instructions() { return this._instructions; }
|
|
50
|
-
/**
|
|
51
|
-
* Constructs a new Transaction object.
|
|
52
|
-
*
|
|
53
|
-
* @param payerKey PublicKey of the transaction payer
|
|
54
|
-
* @param instructions Array of TransactionInstruction to be executed in this transaction
|
|
55
|
-
* @param recentBlockhash The blockhash of a recent ledger entry
|
|
56
|
-
* @param alts Address lookup tables that optimize account address storage
|
|
57
|
-
*/
|
|
58
|
-
constructor(txMetadataResponse, payerKey, _recentBlockhash, alts) {
|
|
59
|
-
// // Construct compute instructions
|
|
60
|
-
// const computeIxs = txMetadataResponse.computeBudgetInstructions.map(ix => {
|
|
61
|
-
// return new web3.TransactionInstruction({
|
|
62
|
-
// keys: ix.accounts.map(meta => {
|
|
63
|
-
// return { pubkey: new web3.PublicKey(meta.pubkey), isSigner: meta.isSigner, isWritable: meta.isWritable };
|
|
64
|
-
// }),
|
|
65
|
-
// programId: new web3.PublicKey(ix.programId),
|
|
66
|
-
// data: Buffer.from(ix.data, 'base64'),
|
|
67
|
-
// });
|
|
68
|
-
// });
|
|
69
|
-
this.txMetadataResponse = txMetadataResponse;
|
|
70
|
-
this.payerKey = payerKey;
|
|
71
|
-
this._recentBlockhash = _recentBlockhash;
|
|
72
|
-
this.alts = alts;
|
|
73
|
-
/** Estimated fee in SOL for priority fee when addPriorityFee() method is called. */
|
|
74
|
-
this._priorityFeeEstimate = "";
|
|
75
|
-
// Construct main instructions
|
|
76
|
-
const mainIxs = txMetadataResponse.mainInstructions.map(ix => {
|
|
77
|
-
return new web3.TransactionInstruction({
|
|
78
|
-
keys: ix.accounts.map(meta => {
|
|
79
|
-
return { pubkey: new web3.PublicKey(meta.pubkey), isSigner: meta.isSigner, isWritable: meta.isWritable };
|
|
80
|
-
}),
|
|
81
|
-
programId: new web3.PublicKey(ix.programId),
|
|
82
|
-
data: Buffer.from(ix.data, 'base64'),
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
this._instructions = [...mainIxs];
|
|
86
|
-
const [txMessage, versionedTransaction] = this.buildTransaction(_recentBlockhash);
|
|
87
|
-
this._txMessage = txMessage;
|
|
88
|
-
this._versionedTransaction = versionedTransaction;
|
|
89
|
-
this.requiredSigners = this.getRequiredSigners();
|
|
90
|
-
if (typeof this.requiredSigners[payerKey.toString()] !== 'boolean') {
|
|
91
|
-
throw new Error(`Warning: The payer ${payerKey} is not one of the required signers of this transaction.`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
;
|
|
95
|
-
/**
|
|
96
|
-
* Signs the transaction with provided signers.
|
|
97
|
-
*
|
|
98
|
-
* @param signers Array of Signer objects whose private keys will be used to sign the transaction.
|
|
99
|
-
* @param idempotent Boolean indicating whether signing should be idempotent (default is false).
|
|
100
|
-
* @throws Error if a signer is not required or has already signed the transaction when not idempotent.
|
|
101
|
-
*/
|
|
102
|
-
sign(signers, idempotent = false) {
|
|
103
|
-
// First validate all signers
|
|
104
|
-
signers.forEach(signer => {
|
|
105
|
-
const key = signer.publicKey.toString();
|
|
106
|
-
if (typeof this.requiredSigners[key] !== 'boolean') {
|
|
107
|
-
throw new Error(`Key ${key} is not a required signer!`);
|
|
108
|
-
}
|
|
109
|
-
if (!idempotent && this.requiredSigners[key]) {
|
|
110
|
-
throw new Error(`Key ${key} has already been signed by required signer!`);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
// If all signers are valid and the process is idempotent or they haven't signed yet, update and sign
|
|
114
|
-
signers.forEach(signer => {
|
|
115
|
-
const key = signer.publicKey.toString();
|
|
116
|
-
this.requiredSigners[key] = true;
|
|
117
|
-
});
|
|
118
|
-
this.versionedTransaction.sign(signers);
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Checks if all required signers have signed the transaction.
|
|
122
|
-
*
|
|
123
|
-
* @returns Boolean indicating whether all required signers have signed.
|
|
124
|
-
*/
|
|
125
|
-
isSignedByRequiredSigners() {
|
|
126
|
-
return Object.values(this.requiredSigners).every(isSigned => isSigned);
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Add priority fee instructions (compute budget)
|
|
130
|
-
*/
|
|
131
|
-
addPriorityFeeIx(generalUtility, connection, priorityLevel, computeUnitLimit, maxPriorityFee) {
|
|
132
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
-
// First, remove priority fee instructions (compute budget if there is)
|
|
134
|
-
this.removePriorityFeeIxs();
|
|
135
|
-
// Then get fee estimate by simulating the transaction
|
|
136
|
-
const estimate = yield (0, functions_1.getFeeEstimate)(generalUtility, priorityLevel, this.txMetadataResponse);
|
|
137
|
-
const priorityFeeEstimate = maxPriorityFee !== undefined && maxPriorityFee > 0 ? Math.round(Math.min(estimate, maxPriorityFee)) : Math.round(estimate);
|
|
138
|
-
// Create priority fee ixs for transaction
|
|
139
|
-
const priorityFeeIxs = [
|
|
140
|
-
web3.ComputeBudgetProgram.setComputeUnitLimit({ units: computeUnitLimit }),
|
|
141
|
-
web3.ComputeBudgetProgram.setComputeUnitPrice({
|
|
142
|
-
// CU * CU PRICE -> 1400000 * feeEstimate.priorityFeeEstimate
|
|
143
|
-
microLamports: priorityFeeEstimate,
|
|
144
|
-
}),
|
|
145
|
-
];
|
|
146
|
-
this._priorityFeeEstimate = (new bn_js_1.BN(priorityFeeEstimate)
|
|
147
|
-
.mul(new bn_js_1.BN(computeUnitLimit))
|
|
148
|
-
.div(new bn_js_1.BN(1000000))
|
|
149
|
-
.add(new bn_js_1.BN(5000)).toNumber() / 1000000000).toString();
|
|
150
|
-
// Append priority fee instruction at the beginning
|
|
151
|
-
this._instructions.unshift(...priorityFeeIxs);
|
|
152
|
-
// Rebuild versioned transaction
|
|
153
|
-
const { blockhash } = yield connection.getLatestBlockhash();
|
|
154
|
-
this.buildTransaction(blockhash);
|
|
155
|
-
return priorityFeeIxs;
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Simulate transaction
|
|
160
|
-
*
|
|
161
|
-
* @param connection
|
|
162
|
-
* @returns
|
|
163
|
-
*/
|
|
164
|
-
simulateTransaction(connection) {
|
|
165
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
-
const testInstructions = [
|
|
167
|
-
web3.ComputeBudgetProgram.setComputeUnitLimit({ units: 1400000 }),
|
|
168
|
-
...this.instructions,
|
|
169
|
-
];
|
|
170
|
-
const testVersionedTxn = new web3.VersionedTransaction(new web3.TransactionMessage({
|
|
171
|
-
instructions: testInstructions,
|
|
172
|
-
payerKey: this.payerKey,
|
|
173
|
-
recentBlockhash: web3.PublicKey.default.toString(),
|
|
174
|
-
}).compileToV0Message(this.alts));
|
|
175
|
-
const simulation = yield connection.simulateTransaction(testVersionedTxn, {
|
|
176
|
-
replaceRecentBlockhash: true,
|
|
177
|
-
sigVerify: false,
|
|
178
|
-
});
|
|
179
|
-
if (simulation.value.unitsConsumed === undefined) {
|
|
180
|
-
throw new Error('Unable to calculate compute budget.');
|
|
181
|
-
}
|
|
182
|
-
return {
|
|
183
|
-
err: simulation.value.err,
|
|
184
|
-
logs: simulation.value.logs,
|
|
185
|
-
accounts: simulation.value.accounts,
|
|
186
|
-
unitsConsumed: simulation.value.unitsConsumed,
|
|
187
|
-
returnData: simulation.value.returnData,
|
|
188
|
-
};
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Builds transaction object
|
|
193
|
-
*/
|
|
194
|
-
buildTransaction(recentBlockhash) {
|
|
195
|
-
this._txMessage = new web3.TransactionMessage({
|
|
196
|
-
payerKey: this.payerKey,
|
|
197
|
-
instructions: this.instructions,
|
|
198
|
-
recentBlockhash,
|
|
199
|
-
});
|
|
200
|
-
this._versionedTransaction = new web3.VersionedTransaction(this.txMessage.compileToV0Message(this.alts));
|
|
201
|
-
return [this._txMessage, this._versionedTransaction];
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Gathers the public keys of all parties required to sign the transaction.
|
|
205
|
-
*
|
|
206
|
-
* @returns A record of signer public keys mapped to a boolean indicating whether they have signed.
|
|
207
|
-
*/
|
|
208
|
-
getRequiredSigners() {
|
|
209
|
-
const signerKeys = this.instructions.flatMap(ix => ix.keys.filter(meta => meta.isSigner).map(meta => meta.pubkey.toString()));
|
|
210
|
-
const result = {};
|
|
211
|
-
signerKeys.forEach(key => result[key] = false);
|
|
212
|
-
return result;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Find setComputeUnitLimit index within the instructions
|
|
216
|
-
*/
|
|
217
|
-
findSetComputeUnitLimitIndex() {
|
|
218
|
-
return this.instructions.findIndex(ix => {
|
|
219
|
-
const isComputeBudgetProgram = ix.programId.toString() === 'ComputeBudget111111111111111111111111111111';
|
|
220
|
-
const isSetComputeLimitIx = ix.data[0] === 2;
|
|
221
|
-
return isComputeBudgetProgram && isSetComputeLimitIx;
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Find setComputeUnitPrice index within the instructions
|
|
226
|
-
*/
|
|
227
|
-
findSetComputeUnitPriceIndex() {
|
|
228
|
-
return this.instructions.findIndex(ix => {
|
|
229
|
-
const isComputeBudgetProgram = ix.programId.toString() === 'ComputeBudget111111111111111111111111111111';
|
|
230
|
-
const isSetComputeUnitPriceIx = ix.data[0] === 3;
|
|
231
|
-
return isComputeBudgetProgram && isSetComputeUnitPriceIx;
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Remove priority fee instructions
|
|
236
|
-
*/
|
|
237
|
-
removePriorityFeeIxs() {
|
|
238
|
-
while (true) {
|
|
239
|
-
const setComputeUnitLimitIxIndex = this.findSetComputeUnitLimitIndex();
|
|
240
|
-
const setComputeUnitPriceIxIndex = this.findSetComputeUnitPriceIndex();
|
|
241
|
-
if (setComputeUnitLimitIxIndex !== -1)
|
|
242
|
-
this._instructions.splice(setComputeUnitLimitIxIndex, 1);
|
|
243
|
-
if (setComputeUnitPriceIxIndex !== -1)
|
|
244
|
-
this._instructions.splice(setComputeUnitPriceIxIndex, 1);
|
|
245
|
-
if (setComputeUnitLimitIxIndex && setComputeUnitPriceIxIndex)
|
|
246
|
-
break;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
exports.Transaction = Transaction;
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import * as web3 from "@solana/web3.js";
|
|
2
|
-
import * as _client from "@hawksightco/swagger-client";
|
|
3
|
-
import { ResponseWithStatus, TransactionMetadata, TransactionMetadataResponse } from "../types";
|
|
4
|
-
import { Client } from "./Client";
|
|
5
|
-
import { GeneralUtility } from "./GeneralUtility";
|
|
6
|
-
/**
|
|
7
|
-
* The `TxGenerator` class encapsulates methods to generate transactions with various trading operations
|
|
8
|
-
* on decentralized market making platforms like Meteora and Orca within the Solana ecosystem. It allows
|
|
9
|
-
* setting custom transaction priority and fees to manage transaction processing speed and cost.
|
|
10
|
-
*/
|
|
11
|
-
export declare class TxGenerator {
|
|
12
|
-
private readonly client;
|
|
13
|
-
private readonly generalUtility;
|
|
14
|
-
/**
|
|
15
|
-
* The current priority level of transactions generated by this instance.
|
|
16
|
-
*/
|
|
17
|
-
protected priorityLevel: _client.UtilGetPriorityFeeEstimateBodyPriorityEnum;
|
|
18
|
-
/**
|
|
19
|
-
* The maximum priority fee in lamports that can be added to transactions for faster processing.
|
|
20
|
-
*/
|
|
21
|
-
protected maxPriorityFee: number;
|
|
22
|
-
/**
|
|
23
|
-
* Initializes a new instance of the TxGenerator class with a specified client.
|
|
24
|
-
*
|
|
25
|
-
* @param client An instance of Client used to interact with various APIs for transaction generation.
|
|
26
|
-
*/
|
|
27
|
-
constructor(client: Client, generalUtility: GeneralUtility);
|
|
28
|
-
/**
|
|
29
|
-
* Sets the priority level of the transaction.
|
|
30
|
-
*
|
|
31
|
-
* @param priorityLevel The desired transaction priority level.
|
|
32
|
-
*/
|
|
33
|
-
setPriorityLevel(priorityLevel: _client.UtilGetPriorityFeeEstimateBodyPriorityEnum): void;
|
|
34
|
-
/**
|
|
35
|
-
* Sets the maximum priority fee for the transaction.
|
|
36
|
-
*
|
|
37
|
-
* @param maxPriorityFee The maximum priority fee in lamports.
|
|
38
|
-
*/
|
|
39
|
-
setMaxPriorityFee(maxPriorityFee: number): void;
|
|
40
|
-
/**
|
|
41
|
-
* Creates meteora instruction that creates new position and deposit.
|
|
42
|
-
*
|
|
43
|
-
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
44
|
-
* @param payer The public key of the payer for transaction fees.
|
|
45
|
-
* @param params Parameters required
|
|
46
|
-
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
47
|
-
*/
|
|
48
|
-
meteoraCreatePositionAndDeposit(connection: web3.Connection, payer: string, params: _client.TxCreatePositionAndDepositBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
49
|
-
/**
|
|
50
|
-
* Creates meteora instruction that deposits to position.
|
|
51
|
-
*
|
|
52
|
-
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
53
|
-
* @param payer The public key of the payer for transaction fees.
|
|
54
|
-
* @param params Parameters required
|
|
55
|
-
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
56
|
-
*/
|
|
57
|
-
meteoraDeposit(connection: web3.Connection, payer: string, params: _client.TxDepositBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
58
|
-
/**
|
|
59
|
-
* Creates meteora instruction withdraws from a position.
|
|
60
|
-
*
|
|
61
|
-
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
62
|
-
* @param payer The public key of the payer for transaction fees.
|
|
63
|
-
* @param params Parameters required
|
|
64
|
-
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
65
|
-
*/
|
|
66
|
-
meteoraWithdraw(connection: web3.Connection, payer: string, params: _client.TxWithdrawBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
67
|
-
/**
|
|
68
|
-
* Creates meteora instruction that claims fees and rewards.
|
|
69
|
-
*
|
|
70
|
-
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
71
|
-
* @param payer The public key of the payer for transaction fees.
|
|
72
|
-
* @param params Parameters required
|
|
73
|
-
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
74
|
-
*/
|
|
75
|
-
meteoraClaim(connection: web3.Connection, payer: string, params: _client.TxClaimBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
76
|
-
/**
|
|
77
|
-
* Creates meteora instruction that closes position.
|
|
78
|
-
*
|
|
79
|
-
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
80
|
-
* @param payer The public key of the payer for transaction fees.
|
|
81
|
-
* @param params Parameters required
|
|
82
|
-
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
83
|
-
*/
|
|
84
|
-
meteoraClosePosition(connection: web3.Connection, payer: string, params: _client.TxClosePositionBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
85
|
-
/**
|
|
86
|
-
* Creates orca instruction that opens new position
|
|
87
|
-
*
|
|
88
|
-
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
89
|
-
* @param payer The public key of the payer for transaction fees.
|
|
90
|
-
* @param params Parameters required
|
|
91
|
-
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
92
|
-
*/
|
|
93
|
-
orcaOpenPosition(connection: web3.Connection, payer: string, params: _client.TxOpenPositionBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
94
|
-
/**
|
|
95
|
-
* Creates orca instruction that closes position
|
|
96
|
-
*
|
|
97
|
-
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
98
|
-
* @param payer The public key of the payer for transaction fees.
|
|
99
|
-
* @param params Parameters required
|
|
100
|
-
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
101
|
-
*/
|
|
102
|
-
orcaClosePosition(connection: web3.Connection, payer: string, params: _client.TxClosePositionBody1): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
103
|
-
/**
|
|
104
|
-
* Creates orca instruction that deposits to a position
|
|
105
|
-
*
|
|
106
|
-
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
107
|
-
* @param payer The public key of the payer for transaction fees.
|
|
108
|
-
* @param params Parameters required
|
|
109
|
-
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
110
|
-
*/
|
|
111
|
-
orcaDeposit(connection: web3.Connection, payer: string, params: _client.TxDepositBody1): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
112
|
-
/**
|
|
113
|
-
* Creates orca instruction that withdraws from a position
|
|
114
|
-
*
|
|
115
|
-
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
116
|
-
* @param payer The public key of the payer for transaction fees.
|
|
117
|
-
* @param params Parameters required
|
|
118
|
-
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
119
|
-
*/
|
|
120
|
-
orcaWithdraw(connection: web3.Connection, payer: string, params: _client.TxWithdrawBody1): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
121
|
-
/**
|
|
122
|
-
* Creates orca instruction that claims fees and rewards
|
|
123
|
-
*
|
|
124
|
-
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
125
|
-
* @param payer The public key of the payer for transaction fees.
|
|
126
|
-
* @param params Parameters required
|
|
127
|
-
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
128
|
-
*/
|
|
129
|
-
orcaClaimRewards(connection: web3.Connection, payer: string, params: _client.TxClaimRewardsBody): Promise<ResponseWithStatus<TransactionMetadataResponse> | ResponseWithStatus<TransactionMetadata>>;
|
|
130
|
-
}
|
|
131
|
-
//# sourceMappingURL=TxGenerator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TxGenerator.d.ts","sourceRoot":"","sources":["../../../src/classes/TxGenerator.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,242 +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 (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.TxGenerator = void 0;
|
|
36
|
-
const _client = __importStar(require("@hawksightco/swagger-client"));
|
|
37
|
-
const functions_1 = require("../functions");
|
|
38
|
-
/**
|
|
39
|
-
* The `TxGenerator` class encapsulates methods to generate transactions with various trading operations
|
|
40
|
-
* on decentralized market making platforms like Meteora and Orca within the Solana ecosystem. It allows
|
|
41
|
-
* setting custom transaction priority and fees to manage transaction processing speed and cost.
|
|
42
|
-
*/
|
|
43
|
-
class TxGenerator {
|
|
44
|
-
/**
|
|
45
|
-
* Initializes a new instance of the TxGenerator class with a specified client.
|
|
46
|
-
*
|
|
47
|
-
* @param client An instance of Client used to interact with various APIs for transaction generation.
|
|
48
|
-
*/
|
|
49
|
-
constructor(client, generalUtility) {
|
|
50
|
-
this.client = client;
|
|
51
|
-
this.generalUtility = generalUtility;
|
|
52
|
-
this.priorityLevel = _client.UtilGetPriorityFeeEstimateBodyPriorityEnum.Default;
|
|
53
|
-
this.maxPriorityFee = 500000; // Default max priority fee in lamports
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Sets the priority level of the transaction.
|
|
57
|
-
*
|
|
58
|
-
* @param priorityLevel The desired transaction priority level.
|
|
59
|
-
*/
|
|
60
|
-
setPriorityLevel(priorityLevel) {
|
|
61
|
-
this.priorityLevel = priorityLevel;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Sets the maximum priority fee for the transaction.
|
|
65
|
-
*
|
|
66
|
-
* @param maxPriorityFee The maximum priority fee in lamports.
|
|
67
|
-
*/
|
|
68
|
-
setMaxPriorityFee(maxPriorityFee) {
|
|
69
|
-
this.maxPriorityFee = maxPriorityFee;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Creates meteora instruction that creates new position and deposit.
|
|
73
|
-
*
|
|
74
|
-
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
75
|
-
* @param payer The public key of the payer for transaction fees.
|
|
76
|
-
* @param params Parameters required
|
|
77
|
-
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
78
|
-
*/
|
|
79
|
-
meteoraCreatePositionAndDeposit(connection, payer, params) {
|
|
80
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
-
const result = yield this.client.meteoraDLMMInstructionsApi.meteoraDlmmTxCreatePositionAndDepositPost(params).catch(e => e.response);
|
|
82
|
-
return (0, functions_1.resultOrError)({
|
|
83
|
-
status: result.status,
|
|
84
|
-
data: result.data,
|
|
85
|
-
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, data, this.priorityLevel, this.maxPriorityFee); }));
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Creates meteora instruction that deposits to position.
|
|
90
|
-
*
|
|
91
|
-
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
92
|
-
* @param payer The public key of the payer for transaction fees.
|
|
93
|
-
* @param params Parameters required
|
|
94
|
-
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
95
|
-
*/
|
|
96
|
-
meteoraDeposit(connection, payer, params) {
|
|
97
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
-
const result = yield this.client.meteoraDLMMInstructionsApi.meteoraDlmmTxDepositPost(params).catch(e => e.response);
|
|
99
|
-
return (0, functions_1.resultOrError)({
|
|
100
|
-
status: result.status,
|
|
101
|
-
data: result.data,
|
|
102
|
-
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, data, this.priorityLevel, this.maxPriorityFee); }));
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Creates meteora instruction withdraws from a position.
|
|
107
|
-
*
|
|
108
|
-
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
109
|
-
* @param payer The public key of the payer for transaction fees.
|
|
110
|
-
* @param params Parameters required
|
|
111
|
-
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
112
|
-
*/
|
|
113
|
-
meteoraWithdraw(connection, payer, params) {
|
|
114
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
-
const result = yield this.client.meteoraDLMMInstructionsApi.meteoraDlmmTxWithdrawPost(params).catch(e => e.response);
|
|
116
|
-
return (0, functions_1.resultOrError)({
|
|
117
|
-
status: result.status,
|
|
118
|
-
data: result.data,
|
|
119
|
-
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, data, this.priorityLevel, this.maxPriorityFee); }));
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Creates meteora instruction that claims fees and rewards.
|
|
124
|
-
*
|
|
125
|
-
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
126
|
-
* @param payer The public key of the payer for transaction fees.
|
|
127
|
-
* @param params Parameters required
|
|
128
|
-
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
129
|
-
*/
|
|
130
|
-
meteoraClaim(connection, payer, params) {
|
|
131
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
-
const result = yield this.client.meteoraDLMMInstructionsApi.meteoraDlmmTxClaimPost(params).catch(e => e.response);
|
|
133
|
-
return (0, functions_1.resultOrError)({
|
|
134
|
-
status: result.status,
|
|
135
|
-
data: result.data,
|
|
136
|
-
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, data, this.priorityLevel, this.maxPriorityFee); }));
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Creates meteora instruction that closes position.
|
|
141
|
-
*
|
|
142
|
-
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
143
|
-
* @param payer The public key of the payer for transaction fees.
|
|
144
|
-
* @param params Parameters required
|
|
145
|
-
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
146
|
-
*/
|
|
147
|
-
meteoraClosePosition(connection, payer, params) {
|
|
148
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
-
const result = yield this.client.meteoraDLMMInstructionsApi.meteoraDlmmTxClosePositionPost(params).catch(e => e.response);
|
|
150
|
-
return (0, functions_1.resultOrError)({
|
|
151
|
-
status: result.status,
|
|
152
|
-
data: result.data,
|
|
153
|
-
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, data, this.priorityLevel, this.maxPriorityFee); }));
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Creates orca instruction that opens new position
|
|
158
|
-
*
|
|
159
|
-
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
160
|
-
* @param payer The public key of the payer for transaction fees.
|
|
161
|
-
* @param params Parameters required
|
|
162
|
-
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
163
|
-
*/
|
|
164
|
-
orcaOpenPosition(connection, payer, params) {
|
|
165
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
-
const result = yield this.client.orcaCLMMInstructionsApi.orcaTxOpenPositionPost(params).catch(e => e.response);
|
|
167
|
-
return (0, functions_1.resultOrError)({
|
|
168
|
-
status: result.status,
|
|
169
|
-
data: result.data,
|
|
170
|
-
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, data, this.priorityLevel, this.maxPriorityFee); }));
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Creates orca instruction that closes position
|
|
175
|
-
*
|
|
176
|
-
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
177
|
-
* @param payer The public key of the payer for transaction fees.
|
|
178
|
-
* @param params Parameters required
|
|
179
|
-
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
180
|
-
*/
|
|
181
|
-
orcaClosePosition(connection, payer, params) {
|
|
182
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
183
|
-
const result = yield this.client.orcaCLMMInstructionsApi.orcaTxClosePositionPost(params).catch(e => e.response);
|
|
184
|
-
return (0, functions_1.resultOrError)({
|
|
185
|
-
status: result.status,
|
|
186
|
-
data: result.data,
|
|
187
|
-
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, data, this.priorityLevel, this.maxPriorityFee); }));
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Creates orca instruction that deposits to a position
|
|
192
|
-
*
|
|
193
|
-
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
194
|
-
* @param payer The public key of the payer for transaction fees.
|
|
195
|
-
* @param params Parameters required
|
|
196
|
-
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
197
|
-
*/
|
|
198
|
-
orcaDeposit(connection, payer, params) {
|
|
199
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
-
const result = yield this.client.orcaCLMMInstructionsApi.orcaTxDepositPost(params).catch(e => e.response);
|
|
201
|
-
return (0, functions_1.resultOrError)({
|
|
202
|
-
status: result.status,
|
|
203
|
-
data: result.data,
|
|
204
|
-
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, data, this.priorityLevel, this.maxPriorityFee); }));
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Creates orca instruction that withdraws from a position
|
|
209
|
-
*
|
|
210
|
-
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
211
|
-
* @param payer The public key of the payer for transaction fees.
|
|
212
|
-
* @param params Parameters required
|
|
213
|
-
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
214
|
-
*/
|
|
215
|
-
orcaWithdraw(connection, payer, params) {
|
|
216
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
217
|
-
const result = yield this.client.orcaCLMMInstructionsApi.orcaTxWithdrawPost(params).catch(e => e.response);
|
|
218
|
-
return (0, functions_1.resultOrError)({
|
|
219
|
-
status: result.status,
|
|
220
|
-
data: result.data,
|
|
221
|
-
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, data, this.priorityLevel, this.maxPriorityFee); }));
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Creates orca instruction that claims fees and rewards
|
|
226
|
-
*
|
|
227
|
-
* @param connection The Solana web3 connection object for blockchain interactions.
|
|
228
|
-
* @param payer The public key of the payer for transaction fees.
|
|
229
|
-
* @param params Parameters required
|
|
230
|
-
* @returns A ResponseWithStatus containing either TransactionMetadataResponse or TransactionMetadata.
|
|
231
|
-
*/
|
|
232
|
-
orcaClaimRewards(connection, payer, params) {
|
|
233
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
234
|
-
const result = yield this.client.orcaCLMMInstructionsApi.orcaTxClaimRewardsPost(params).catch(e => e.response);
|
|
235
|
-
return (0, functions_1.resultOrError)({
|
|
236
|
-
status: result.status,
|
|
237
|
-
data: result.data,
|
|
238
|
-
}, (data) => __awaiter(this, void 0, void 0, function* () { return yield (0, functions_1.createTxMetadata)(this.generalUtility, connection, payer, data, this.priorityLevel, this.maxPriorityFee); }));
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
exports.TxGenerator = TxGenerator;
|