@hawksightco/hawk-sdk 0.0.19 → 0.0.21
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.
|
@@ -1 +1 @@
|
|
|
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;AAGxC,OAAO,EACL,4BAA4B,EAC5B,2BAA2B,EAC5B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;GAGG;AACH,qBAAa,WAAW;IA+CpB,QAAQ,CAAC,kBAAkB,EAAE,2BAA2B;IACxD,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS;IACjC,OAAO,CAAC,eAAe;IACvB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,yBAAyB,EAAE;IAC/C,OAAO,CAAC,cAAc;IAlDxB,2FAA2F;IAC3F,OAAO,CAAC,UAAU,CAA0B;IAC5C,IAAI,SAAS,IAAI,IAAI,CAAC,kBAAkB,CAEvC;IAED,+DAA+D;IAC/D,OAAO,CAAC,qBAAqB,CAA4B;IACzD,IAAI,oBAAoB,IAAI,IAAI,CAAC,oBAAoB,CAEpD;IAED,+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,CAEhC;IAED,6CAA6C;IAC7C,IAAI,eAAe,IAAI,MAAM,CAE5B;IAED,yEAAyE;IACzE,OAAO,CAAC,aAAa,CAAgC;IACrD,IAAI,YAAY,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAEhD;IAED,8BAA8B;IAC9B,IAAI,oBAAoB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C;;;;;OAKG;IACG,mBAAmB,CACvB,UAAU,EAAE,IAAI,CAAC,UAAU,GAC1B,OAAO,CAAC,4BAA4B,CAAC;IAsCxC;;OAEG;IACH,gBAAgB,CACd,eAAe,EAAE,IAAI,CAAC,8BAA8B,GACnD,CAAC,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,oBAAoB,CAAC;IAcvD;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAW1B;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAgBpC;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAgBpC;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAW7B"}
|
|
@@ -190,7 +190,6 @@ class Transaction {
|
|
|
190
190
|
.toNumber() / 1000000000).toString();
|
|
191
191
|
// Append priority fee instruction at the beginning
|
|
192
192
|
this._instructions.unshift(...priorityFeeIxs);
|
|
193
|
-
console.log(this._instructions);
|
|
194
193
|
// Rebuild versioned transaction
|
|
195
194
|
const blockhash = yield connection.getLatestBlockhash();
|
|
196
195
|
this.buildTransaction(blockhash);
|
|
@@ -206,9 +205,17 @@ class Transaction {
|
|
|
206
205
|
simulateTransaction(connection) {
|
|
207
206
|
return __awaiter(this, void 0, void 0, function* () {
|
|
208
207
|
const testInstructions = [
|
|
209
|
-
web3.ComputeBudgetProgram.setComputeUnitLimit({ units: 1400000 }),
|
|
210
208
|
...this.instructions,
|
|
211
209
|
];
|
|
210
|
+
if (this.findSetComputeUnitLimitIndex(testInstructions) === -1) {
|
|
211
|
+
testInstructions.unshift(web3.ComputeBudgetProgram.setComputeUnitLimit({ units: 1400000 }));
|
|
212
|
+
}
|
|
213
|
+
if (this.findSetComputeUnitPriceIndex(testInstructions) === -1) {
|
|
214
|
+
testInstructions.unshift(web3.ComputeBudgetProgram.setComputeUnitPrice({
|
|
215
|
+
// CU * CU PRICE -> 1400000 * feeEstimate.priorityFeeEstimate
|
|
216
|
+
microLamports: 100000,
|
|
217
|
+
}));
|
|
218
|
+
}
|
|
212
219
|
const testVersionedTxn = new web3.VersionedTransaction(new web3.TransactionMessage({
|
|
213
220
|
instructions: testInstructions,
|
|
214
221
|
payerKey: this.payerKey,
|
|
@@ -259,8 +266,15 @@ class Transaction {
|
|
|
259
266
|
/**
|
|
260
267
|
* Find setComputeUnitLimit index within the instructions
|
|
261
268
|
*/
|
|
262
|
-
findSetComputeUnitLimitIndex() {
|
|
263
|
-
|
|
269
|
+
findSetComputeUnitLimitIndex(instructions) {
|
|
270
|
+
let _instructions = [];
|
|
271
|
+
if (instructions !== undefined) {
|
|
272
|
+
_instructions = instructions;
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
_instructions = this.instructions;
|
|
276
|
+
}
|
|
277
|
+
return _instructions.findIndex((ix) => {
|
|
264
278
|
const isComputeBudgetProgram = ix.programId.toString() ===
|
|
265
279
|
"ComputeBudget111111111111111111111111111111";
|
|
266
280
|
const isSetComputeLimitIx = ix.data[0] === 2;
|
|
@@ -270,8 +284,15 @@ class Transaction {
|
|
|
270
284
|
/**
|
|
271
285
|
* Find setComputeUnitPrice index within the instructions
|
|
272
286
|
*/
|
|
273
|
-
findSetComputeUnitPriceIndex() {
|
|
274
|
-
|
|
287
|
+
findSetComputeUnitPriceIndex(instructions) {
|
|
288
|
+
let _instructions = [];
|
|
289
|
+
if (instructions !== undefined) {
|
|
290
|
+
_instructions = instructions;
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
_instructions = this.instructions;
|
|
294
|
+
}
|
|
295
|
+
return _instructions.findIndex((ix) => {
|
|
275
296
|
const isComputeBudgetProgram = ix.programId.toString() ===
|
|
276
297
|
"ComputeBudget111111111111111111111111111111";
|
|
277
298
|
const isSetComputeUnitPriceIx = ix.data[0] === 3;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hawksightco/hawk-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"description": "Hawksight v2 SDK",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"repository": "https://github.com/ghabxph/hawk-api-client.git",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"scripts": {
|
|
28
28
|
"start": "npx ts-node src/index.ts",
|
|
29
29
|
"test": "npx jest --silent=false",
|
|
30
|
-
"build": "tsc --outDir dist/"
|
|
30
|
+
"build": "tsc --outDir dist/",
|
|
31
|
+
"prepublishOnly": "npm run build"
|
|
31
32
|
}
|
|
32
33
|
}
|