@hawksightco/hawk-sdk 0.0.55 → 0.0.57

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.
@@ -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;IAUhB;;;;;;;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,202 @@
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
+ return;
95
+ }
96
+ setTimeout(() => __awaiter(this, void 0, void 0, function* () { return yield this.updateAlts(); }), 1000); // Update until done
97
+ });
98
+ }
99
+ /**
100
+ * Loads a single address lookup table account.
101
+ *
102
+ * @param alt - The address lookup table account address as a string.
103
+ * @param connection - (Optional) A specific Solana blockchain connection object to use.
104
+ * @returns A promise that resolves to the address lookup table account.
105
+ * @throws Error if the address lookup table does not exist.
106
+ */
107
+ loadSingleAlt(alt, connection) {
108
+ return __awaiter(this, void 0, void 0, function* () {
109
+ if (!!connection) {
110
+ this.alts[alt] = (yield connection.getAddressLookupTable(new web3.PublicKey(alt))).value;
111
+ }
112
+ else if (!!this.connection) {
113
+ this.alts[alt] = (yield this.connection.getAddressLookupTable(new web3.PublicKey(alt))).value;
114
+ }
115
+ const result = this.alts[alt];
116
+ if (!!result) {
117
+ return result;
118
+ }
119
+ else {
120
+ throw new Error(`ALT ${alt} does not exist`);
121
+ }
122
+ });
123
+ }
124
+ /**
125
+ * Gets an address lookup table account.
126
+ *
127
+ * @param alt - The address lookup table account address as a string.
128
+ * @returns A promise that resolves to the address lookup table account or null if it does not exist.
129
+ */
130
+ getAlt(alt) {
131
+ return __awaiter(this, void 0, void 0, function* () {
132
+ return this.alts[alt];
133
+ });
134
+ }
135
+ /**
136
+ * Asynchronously creates transaction metadata based on the provided transaction parameters and network state.
137
+ * This includes constructing a transaction with given instructions, calculating fees, and optionally handling priority fees.
138
+ *
139
+ * @param generalUtility - The utility object for general helper functions.
140
+ * @param connection - The active Solana blockchain connection used to fetch state and simulate the transaction.
141
+ * @param payer - The public key (as a string) of the payer for the transaction, responsible for fees.
142
+ * @param data - An object containing necessary information to construct the transaction, such as:
143
+ * - addressLookupTableAddresses: Array of addresses for lookup tables.
144
+ * - computeBudgetInstructions: Array of instructions for setting compute budget.
145
+ * - description: Description of the transaction.
146
+ * - estimatedFeeInSOL: Estimated fee in SOL units.
147
+ * @returns A promise resolving to an object containing the transaction metadata including the description,
148
+ * estimated fee, and the transaction object itself.
149
+ * @throws Error if there is an issue in constructing the transaction or during simulation which includes logs of errors.
150
+ */
151
+ createTxMetadata(generalUtility, connection, payer, data) {
152
+ return __awaiter(this, void 0, void 0, function* () {
153
+ // Retrieve address lookup table accounts
154
+ const alts = [];
155
+ console.log(`createTxMetadata`);
156
+ const mainStartTime = new Date().getTime() / 1000;
157
+ // Find jup alts
158
+ let startTime = mainStartTime;
159
+ const jupAlts = yield generalUtility.findAltWithTxPost({ transaction: data });
160
+ console.log(`createTxMetadata: Checkpoint: (jupAlts) ${(new Date().getTime() / 1000) - startTime}`);
161
+ startTime = new Date().getTime() / 1000;
162
+ for (const alt of data.addressLookupTableAddresses) {
163
+ const _alt = yield this.getAlt(alt);
164
+ if (!!_alt) {
165
+ alts.push(_alt);
166
+ }
167
+ else {
168
+ alts.push(yield this.loadSingleAlt(alt));
169
+ }
170
+ }
171
+ if (jupAlts.status === 200) {
172
+ for (const alt of jupAlts.data) {
173
+ const _alt = yield this.getAlt(alt);
174
+ if (!!_alt) {
175
+ alts.push(_alt);
176
+ }
177
+ else {
178
+ alts.push(yield this.loadSingleAlt(alt));
179
+ }
180
+ }
181
+ }
182
+ else {
183
+ console.error(jupAlts.data);
184
+ }
185
+ console.log(`createTxMetadata: Checkpoint: (jupAlts after loop) ${(new Date().getTime() / 1000) - startTime}`);
186
+ // Get the recent blockhash
187
+ startTime = new Date().getTime() / 1000;
188
+ const latestBlockhash = yield connection.getLatestBlockhash();
189
+ console.log(`createTxMetadata: Checkpoint: (latestBlockhash) ${(new Date().getTime() / 1000) - startTime}`);
190
+ // Create initial transaction instance
191
+ const transaction = new Transaction_1.Transaction(data, new web3.PublicKey(payer), latestBlockhash, alts, generalUtility);
192
+ console.log(`createTxMetadata: Elapsed time: ${(new Date().getTime() / 1000) - mainStartTime}`);
193
+ // Return transaction metadata
194
+ return {
195
+ description: data.description,
196
+ estimatedFeeInSOL: data.estimatedFeeInSOL,
197
+ transaction,
198
+ };
199
+ });
200
+ }
201
+ }
202
+ 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;AAElC;;;;;;;;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,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,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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;;;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"}
@@ -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 web3 = __importStar(require("@solana/web3.js"));
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
- // Retrieve address lookup table accounts
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;
@@ -2,4 +2,5 @@ export * from "./types";
2
2
  export { HawkAPI } from "./classes/HawkAPI";
3
3
  export { TxGenerator } from "./classes/TxGenerator";
4
4
  export { Client } from "./classes/Client";
5
+ export { CreateTxMetadata } from "./classes/CreateTxMetadata";
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC"}
package/dist/src/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.Client = exports.TxGenerator = exports.HawkAPI = void 0;
17
+ exports.CreateTxMetadata = exports.Client = exports.TxGenerator = exports.HawkAPI = void 0;
18
18
  __exportStar(require("./types"), exports);
19
19
  var HawkAPI_1 = require("./classes/HawkAPI");
20
20
  Object.defineProperty(exports, "HawkAPI", { enumerable: true, get: function () { return HawkAPI_1.HawkAPI; } });
@@ -22,3 +22,5 @@ var TxGenerator_1 = require("./classes/TxGenerator");
22
22
  Object.defineProperty(exports, "TxGenerator", { enumerable: true, get: function () { return TxGenerator_1.TxGenerator; } });
23
23
  var Client_1 = require("./classes/Client");
24
24
  Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return Client_1.Client; } });
25
+ var CreateTxMetadata_1 = require("./classes/CreateTxMetadata");
26
+ Object.defineProperty(exports, "CreateTxMetadata", { enumerable: true, get: function () { return CreateTxMetadata_1.CreateTxMetadata; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hawksightco/hawk-sdk",
3
- "version": "0.0.55",
3
+ "version": "0.0.57",
4
4
  "description": "Hawksight v2 SDK",
5
5
  "main": "dist/src/index.js",
6
6
  "repository": "https://github.com/ghabxph/hawk-api-client.git",