@hawksightco/hawk-sdk 0.0.55 → 0.0.56
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/dist/src/classes/CreateTxMetadata.d.ts +67 -0
- package/dist/src/classes/CreateTxMetadata.d.ts.map +1 -0
- package/dist/src/classes/CreateTxMetadata.js +200 -0
- package/dist/src/classes/HawkAPI.d.ts.map +1 -1
- package/dist/src/classes/HawkAPI.js +3 -0
- package/dist/src/functions.d.ts.map +1 -1
- package/dist/src/functions.js +2 -35
- package/package.json +1 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as web3 from "@solana/web3.js";
|
|
2
|
+
import { TransactionMetadata, TransactionMetadataResponse } from "../types";
|
|
3
|
+
import { GeneralUtility } from "./GeneralUtility";
|
|
4
|
+
/**
|
|
5
|
+
* The CreateTxMetadata class is responsible for creating and managing transaction metadata,
|
|
6
|
+
* including handling address lookup tables and constructing transactions with the necessary parameters.
|
|
7
|
+
*/
|
|
8
|
+
export declare class CreateTxMetadata {
|
|
9
|
+
private constructor();
|
|
10
|
+
private connection?;
|
|
11
|
+
/**
|
|
12
|
+
* Sets the connection to the Solana blockchain.
|
|
13
|
+
*
|
|
14
|
+
* @param connection - The Solana blockchain connection object.
|
|
15
|
+
*/
|
|
16
|
+
setConnection(connection: web3.Connection): void;
|
|
17
|
+
private static _instance;
|
|
18
|
+
/**
|
|
19
|
+
* Gets the singleton instance of the CreateTxMetadata class.
|
|
20
|
+
*
|
|
21
|
+
* @returns The singleton instance of CreateTxMetadata.
|
|
22
|
+
*/
|
|
23
|
+
static instance(): CreateTxMetadata;
|
|
24
|
+
private alts;
|
|
25
|
+
/**
|
|
26
|
+
* Loads the address lookup tables.
|
|
27
|
+
*/
|
|
28
|
+
load(): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Updates the address lookup tables by fetching their latest state from the Solana blockchain.
|
|
31
|
+
*/
|
|
32
|
+
updateAlts(): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Loads a single address lookup table account.
|
|
35
|
+
*
|
|
36
|
+
* @param alt - The address lookup table account address as a string.
|
|
37
|
+
* @param connection - (Optional) A specific Solana blockchain connection object to use.
|
|
38
|
+
* @returns A promise that resolves to the address lookup table account.
|
|
39
|
+
* @throws Error if the address lookup table does not exist.
|
|
40
|
+
*/
|
|
41
|
+
loadSingleAlt(alt: string, connection?: web3.Connection): Promise<web3.AddressLookupTableAccount>;
|
|
42
|
+
/**
|
|
43
|
+
* Gets an address lookup table account.
|
|
44
|
+
*
|
|
45
|
+
* @param alt - The address lookup table account address as a string.
|
|
46
|
+
* @returns A promise that resolves to the address lookup table account or null if it does not exist.
|
|
47
|
+
*/
|
|
48
|
+
getAlt(alt: string): Promise<web3.AddressLookupTableAccount | null>;
|
|
49
|
+
/**
|
|
50
|
+
* Asynchronously creates transaction metadata based on the provided transaction parameters and network state.
|
|
51
|
+
* This includes constructing a transaction with given instructions, calculating fees, and optionally handling priority fees.
|
|
52
|
+
*
|
|
53
|
+
* @param generalUtility - The utility object for general helper functions.
|
|
54
|
+
* @param connection - The active Solana blockchain connection used to fetch state and simulate the transaction.
|
|
55
|
+
* @param payer - The public key (as a string) of the payer for the transaction, responsible for fees.
|
|
56
|
+
* @param data - An object containing necessary information to construct the transaction, such as:
|
|
57
|
+
* - addressLookupTableAddresses: Array of addresses for lookup tables.
|
|
58
|
+
* - computeBudgetInstructions: Array of instructions for setting compute budget.
|
|
59
|
+
* - description: Description of the transaction.
|
|
60
|
+
* - estimatedFeeInSOL: Estimated fee in SOL units.
|
|
61
|
+
* @returns A promise resolving to an object containing the transaction metadata including the description,
|
|
62
|
+
* estimated fee, and the transaction object itself.
|
|
63
|
+
* @throws Error if there is an issue in constructing the transaction or during simulation which includes logs of errors.
|
|
64
|
+
*/
|
|
65
|
+
createTxMetadata(generalUtility: GeneralUtility, connection: web3.Connection, payer: string, data: TransactionMetadataResponse): Promise<TransactionMetadata>;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=CreateTxMetadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CreateTxMetadata.d.ts","sourceRoot":"","sources":["../../../src/classes/CreateTxMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAE5E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;GAGG;AACH,qBAAa,gBAAgB;IAE3B,OAAO;IAEP,OAAO,CAAC,UAAU,CAAC,CAAkB;IAErC;;;;OAIG;IACH,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU;IAEzC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAmB;IAE3C;;;;OAIG;IACH,MAAM,CAAC,QAAQ,IAAI,gBAAgB;IAOnC,OAAO,CAAC,IAAI,CAaV;IAEF;;OAEG;IACG,IAAI;IAIV;;OAEG;IACG,UAAU;IAQhB;;;;;;;OAOG;IACG,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,yBAAyB,CAAC;IAcvG;;;;;OAKG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC;IAIzE;;;;;;;;;;;;;;;OAeG;IACG,gBAAgB,CACpB,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,2BAA2B,GAChC,OAAO,CAAC,mBAAmB,CAAC;CAyDhC"}
|
|
@@ -0,0 +1,200 @@
|
|
|
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.CreateTxMetadata = void 0;
|
|
36
|
+
const web3 = __importStar(require("@solana/web3.js"));
|
|
37
|
+
const Transaction_1 = require("./Transaction");
|
|
38
|
+
/**
|
|
39
|
+
* The CreateTxMetadata class is responsible for creating and managing transaction metadata,
|
|
40
|
+
* including handling address lookup tables and constructing transactions with the necessary parameters.
|
|
41
|
+
*/
|
|
42
|
+
class CreateTxMetadata {
|
|
43
|
+
constructor() {
|
|
44
|
+
this.alts = {
|
|
45
|
+
"AC3t5k5PUTJirxGEHgGGQStafu1vXkvddPyqVNDrRQDt": null,
|
|
46
|
+
"F2gRaSdfWYucAMAKv3CHReKMHvPkE3sNWrQPPPPR6UMV": null,
|
|
47
|
+
"FQHdXaRjfKxEfqDXMs6L1gfx2wwa6idDVB8hdQuf6eSD": null,
|
|
48
|
+
"4vMQAkkjhxrgJmqbRd4Z9YP9K7WFVAhHZn4jTJoN45Qj": null,
|
|
49
|
+
"6KhzJ2cs85hKdLeUXS6QjQnygUY9rFUnJADJwrYp9mjM": null,
|
|
50
|
+
"4UgEL5PQVu9MSarh8yb7U22GEZQoSkmNM3w7mZFx47aL": null,
|
|
51
|
+
"5FrgBCVUtwD1cFw39PZxnUsBaAecZVxmaYEcvv6y7b1h": null,
|
|
52
|
+
"FJ76CVMrHBxQxLcQkKdh9YBpwZuECsPjBLJWphwS34XF": null,
|
|
53
|
+
"Fgxms1gyzwhF1L3pJSoAxrNkogbg9sqct7U1z6HfLv5A": null,
|
|
54
|
+
"7vaSmpacdSv7vDjpGhBfZf3rLXjsfDkY6A12JkbNqK5Q": null,
|
|
55
|
+
"AEAMg38ZiQHanFqFiYBQSqsmqyUHj66LZXQzEaD8YJxc": null,
|
|
56
|
+
"4gitar8xUmh2wJoY6tP6f2rbyoBWRnY6RJmMK1BLUtjh": null,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
;
|
|
60
|
+
/**
|
|
61
|
+
* Sets the connection to the Solana blockchain.
|
|
62
|
+
*
|
|
63
|
+
* @param connection - The Solana blockchain connection object.
|
|
64
|
+
*/
|
|
65
|
+
setConnection(connection) { this.connection = connection; }
|
|
66
|
+
/**
|
|
67
|
+
* Gets the singleton instance of the CreateTxMetadata class.
|
|
68
|
+
*
|
|
69
|
+
* @returns The singleton instance of CreateTxMetadata.
|
|
70
|
+
*/
|
|
71
|
+
static instance() {
|
|
72
|
+
if (this._instance === undefined) {
|
|
73
|
+
this._instance = new CreateTxMetadata();
|
|
74
|
+
}
|
|
75
|
+
return this._instance;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Loads the address lookup tables.
|
|
79
|
+
*/
|
|
80
|
+
load() {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
this.updateAlts();
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Updates the address lookup tables by fetching their latest state from the Solana blockchain.
|
|
87
|
+
*/
|
|
88
|
+
updateAlts() {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
if (!!this.connection) {
|
|
91
|
+
for (const alt in this.alts) {
|
|
92
|
+
this.alts[alt] = (yield this.connection.getAddressLookupTable(new web3.PublicKey(alt))).value;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Loads a single address lookup table account.
|
|
99
|
+
*
|
|
100
|
+
* @param alt - The address lookup table account address as a string.
|
|
101
|
+
* @param connection - (Optional) A specific Solana blockchain connection object to use.
|
|
102
|
+
* @returns A promise that resolves to the address lookup table account.
|
|
103
|
+
* @throws Error if the address lookup table does not exist.
|
|
104
|
+
*/
|
|
105
|
+
loadSingleAlt(alt, connection) {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
if (!!connection) {
|
|
108
|
+
this.alts[alt] = (yield connection.getAddressLookupTable(new web3.PublicKey(alt))).value;
|
|
109
|
+
}
|
|
110
|
+
else if (!!this.connection) {
|
|
111
|
+
this.alts[alt] = (yield this.connection.getAddressLookupTable(new web3.PublicKey(alt))).value;
|
|
112
|
+
}
|
|
113
|
+
const result = this.alts[alt];
|
|
114
|
+
if (!!result) {
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
throw new Error(`ALT ${alt} does not exist`);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Gets an address lookup table account.
|
|
124
|
+
*
|
|
125
|
+
* @param alt - The address lookup table account address as a string.
|
|
126
|
+
* @returns A promise that resolves to the address lookup table account or null if it does not exist.
|
|
127
|
+
*/
|
|
128
|
+
getAlt(alt) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
return this.alts[alt];
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Asynchronously creates transaction metadata based on the provided transaction parameters and network state.
|
|
135
|
+
* This includes constructing a transaction with given instructions, calculating fees, and optionally handling priority fees.
|
|
136
|
+
*
|
|
137
|
+
* @param generalUtility - The utility object for general helper functions.
|
|
138
|
+
* @param connection - The active Solana blockchain connection used to fetch state and simulate the transaction.
|
|
139
|
+
* @param payer - The public key (as a string) of the payer for the transaction, responsible for fees.
|
|
140
|
+
* @param data - An object containing necessary information to construct the transaction, such as:
|
|
141
|
+
* - addressLookupTableAddresses: Array of addresses for lookup tables.
|
|
142
|
+
* - computeBudgetInstructions: Array of instructions for setting compute budget.
|
|
143
|
+
* - description: Description of the transaction.
|
|
144
|
+
* - estimatedFeeInSOL: Estimated fee in SOL units.
|
|
145
|
+
* @returns A promise resolving to an object containing the transaction metadata including the description,
|
|
146
|
+
* estimated fee, and the transaction object itself.
|
|
147
|
+
* @throws Error if there is an issue in constructing the transaction or during simulation which includes logs of errors.
|
|
148
|
+
*/
|
|
149
|
+
createTxMetadata(generalUtility, connection, payer, data) {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
151
|
+
// Retrieve address lookup table accounts
|
|
152
|
+
const alts = [];
|
|
153
|
+
console.log(`createTxMetadata`);
|
|
154
|
+
const mainStartTime = new Date().getTime() / 1000;
|
|
155
|
+
// Find jup alts
|
|
156
|
+
let startTime = mainStartTime;
|
|
157
|
+
const jupAlts = yield generalUtility.findAltWithTxPost({ transaction: data });
|
|
158
|
+
console.log(`createTxMetadata: Checkpoint: (jupAlts) ${(new Date().getTime() / 1000) - startTime}`);
|
|
159
|
+
startTime = new Date().getTime() / 1000;
|
|
160
|
+
for (const alt of data.addressLookupTableAddresses) {
|
|
161
|
+
const _alt = yield this.getAlt(alt);
|
|
162
|
+
if (!!_alt) {
|
|
163
|
+
alts.push(_alt);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
alts.push(yield this.loadSingleAlt(alt));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (jupAlts.status === 200) {
|
|
170
|
+
for (const alt of jupAlts.data) {
|
|
171
|
+
const _alt = yield this.getAlt(alt);
|
|
172
|
+
if (!!_alt) {
|
|
173
|
+
alts.push(_alt);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
alts.push(yield this.loadSingleAlt(alt));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
console.error(jupAlts.data);
|
|
182
|
+
}
|
|
183
|
+
console.log(`createTxMetadata: Checkpoint: (jupAlts after loop) ${(new Date().getTime() / 1000) - startTime}`);
|
|
184
|
+
// Get the recent blockhash
|
|
185
|
+
startTime = new Date().getTime() / 1000;
|
|
186
|
+
const latestBlockhash = yield connection.getLatestBlockhash();
|
|
187
|
+
console.log(`createTxMetadata: Checkpoint: (latestBlockhash) ${(new Date().getTime() / 1000) - startTime}`);
|
|
188
|
+
// Create initial transaction instance
|
|
189
|
+
const transaction = new Transaction_1.Transaction(data, new web3.PublicKey(payer), latestBlockhash, alts, generalUtility);
|
|
190
|
+
console.log(`createTxMetadata: Elapsed time: ${(new Date().getTime() / 1000) - mainStartTime}`);
|
|
191
|
+
// Return transaction metadata
|
|
192
|
+
return {
|
|
193
|
+
description: data.description,
|
|
194
|
+
estimatedFeeInSOL: data.estimatedFeeInSOL,
|
|
195
|
+
transaction,
|
|
196
|
+
};
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
exports.CreateTxMetadata = CreateTxMetadata;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HawkAPI.d.ts","sourceRoot":"","sources":["../../../src/classes/HawkAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"HawkAPI.d.ts","sourceRoot":"","sources":["../../../src/classes/HawkAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC;;;;;;;;GAQG;AACH,qBAAa,OAAO;IA+BhB,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM;IA9BhC,+BAA+B;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC,iEAAiE;IACjE,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,6GAA6G;IAC7G,SAAgB,OAAO,EAAE,OAAO,CAAC;IAEjC,+BAA+B;IAC/B,SAAgB,cAAc,EAAE,cAAc,CAAC;IAE/C,0FAA0F;IAC1F,SAAgB,IAAI,EAAE,IAAI,CAAC;IAE3B,mFAAmF;IACnF,OAAO,CAAC,YAAY,CAAc;IAClC,IAAI,WAAW,gBAAgC;IAE/C,kGAAkG;IAClG,SAAgB,qBAAqB,EAAE,sBAAsB,CAAC;IAE9D,mDAAmD;IACnD,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B;;;OAGG;gBAEkB,GAAG,GAAE,MAAoC;IAmB9D;;;;OAIG;IACH,mBAAmB,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,KAAK,WAAW;CAG/F"}
|
|
@@ -9,6 +9,7 @@ const TxGeneratorAutomations_1 = require("./TxGeneratorAutomations");
|
|
|
9
9
|
const Client_1 = require("./Client");
|
|
10
10
|
const GeneralUtility_1 = require("./GeneralUtility");
|
|
11
11
|
const Search_1 = require("./Search");
|
|
12
|
+
const CreateTxMetadata_1 = require("./CreateTxMetadata");
|
|
12
13
|
/**
|
|
13
14
|
* HawkAPI is a central gateway class that aggregates access to various functional modules
|
|
14
15
|
* for interacting with HawkSight's blockchain APIs. This class initializes and exposes modules
|
|
@@ -35,6 +36,8 @@ class HawkAPI {
|
|
|
35
36
|
this._txGenerator = new TxGenerator_1.TxGenerator(client, this.generalUtility);
|
|
36
37
|
this.txGeneratorAutomation = new TxGeneratorAutomations_1.TxGeneratorAutomations(client, this.generalUtility);
|
|
37
38
|
this.search = new Search_1.Search(url);
|
|
39
|
+
// Load create tx metadata module
|
|
40
|
+
CreateTxMetadata_1.CreateTxMetadata.instance().load();
|
|
38
41
|
// Load search module
|
|
39
42
|
this.search.load();
|
|
40
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,2BAA2B,
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../src/functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CACpC,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,2BAA2B,GAChC,OAAO,CAAC,mBAAmB,CAAC,CAO9B;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,GAAG,EAC/C,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,EAC1C,SAAS,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC,GAAG,CAAC,GAC1C,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAYlC;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,MAAM,CAAC,aAAa,EAC9B,WAAW,EAAE,2BAA2B,GACvC,OAAO,CAAC,MAAM,CAAC,CAwBjB"}
|
package/dist/src/functions.js
CHANGED
|
@@ -34,8 +34,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
exports.getFeeEstimate = exports.resultOrError = exports.createTxMetadata = void 0;
|
|
36
36
|
const client = __importStar(require("@hawksightco/swagger-client"));
|
|
37
|
-
const
|
|
38
|
-
const Transaction_1 = require("./classes/Transaction");
|
|
37
|
+
const CreateTxMetadata_1 = require("./classes/CreateTxMetadata");
|
|
39
38
|
/**
|
|
40
39
|
* Asynchronously creates transaction metadata based on the provided transaction parameters and network state.
|
|
41
40
|
* This includes constructing a transaction with given instructions, calculating fees, and optionally handling priority fees.
|
|
@@ -53,39 +52,7 @@ const Transaction_1 = require("./classes/Transaction");
|
|
|
53
52
|
*/
|
|
54
53
|
function createTxMetadata(generalUtility, connection, payer, data) {
|
|
55
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
-
|
|
57
|
-
const alts = [];
|
|
58
|
-
console.log(`createTxMetadata`);
|
|
59
|
-
const startTime = new Date().getTime() / 1000;
|
|
60
|
-
// Find jup alts
|
|
61
|
-
const jupAlts = yield generalUtility.findAltWithTxPost({
|
|
62
|
-
transaction: data,
|
|
63
|
-
});
|
|
64
|
-
console.log(`createTxMetadata: Checkpoint: (jupAlts) ${(new Date().getTime() / 1000) - startTime}`);
|
|
65
|
-
for (const alt of data.addressLookupTableAddresses) {
|
|
66
|
-
alts.push((yield connection.getAddressLookupTable(new web3.PublicKey(alt))).value);
|
|
67
|
-
}
|
|
68
|
-
if (jupAlts.status === 200) {
|
|
69
|
-
for (const alt of jupAlts.data) {
|
|
70
|
-
alts.push((yield connection.getAddressLookupTable(new web3.PublicKey(alt))).value);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
console.error(jupAlts.data);
|
|
75
|
-
}
|
|
76
|
-
console.log(`createTxMetadata: Checkpoint: (jupAlts after loop) ${(new Date().getTime() / 1000) - startTime}`);
|
|
77
|
-
// Get the recent blockhash
|
|
78
|
-
const latestBlockhash = yield connection.getLatestBlockhash();
|
|
79
|
-
console.log(`createTxMetadata: Checkpoint: (latestBlockhash) ${(new Date().getTime() / 1000) - startTime}`);
|
|
80
|
-
// Create initial transaction instance
|
|
81
|
-
const transaction = new Transaction_1.Transaction(data, new web3.PublicKey(payer), latestBlockhash, alts, generalUtility);
|
|
82
|
-
console.log(`createTxMetadata: Elapsed time: ${(new Date().getTime() / 1000) - startTime}`);
|
|
83
|
-
// Return transaction metadatauni
|
|
84
|
-
return {
|
|
85
|
-
description: data.description,
|
|
86
|
-
estimatedFeeInSOL: data.estimatedFeeInSOL,
|
|
87
|
-
transaction,
|
|
88
|
-
};
|
|
55
|
+
return yield CreateTxMetadata_1.CreateTxMetadata.instance().createTxMetadata(generalUtility, connection, payer, data);
|
|
89
56
|
});
|
|
90
57
|
}
|
|
91
58
|
exports.createTxMetadata = createTxMetadata;
|