@hawksightco/hawk-sdk 1.1.10 → 1.1.11
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/Atomicity.d.ts +2 -1
- package/dist/src/classes/Atomicity.d.ts.map +1 -1
- package/dist/src/classes/Atomicity.js +2 -2
- package/dist/src/classes/HawkAPI.d.ts +3 -0
- package/dist/src/classes/HawkAPI.d.ts.map +1 -1
- package/dist/src/classes/HawkAPI.js +4 -2
- package/dist/src/classes/JupiterAlts.d.ts +35 -0
- package/dist/src/classes/JupiterAlts.d.ts.map +1 -1
- package/dist/src/classes/JupiterAlts.js +98 -0
- package/dist/src/classes/TransactionBatchExecute.d.ts +16 -1
- package/dist/src/classes/TransactionBatchExecute.d.ts.map +1 -1
- package/dist/src/classes/TransactionBatchExecute.js +53 -5
- package/package.json +3 -3
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
import * as web3 from '@solana/web3.js';
|
|
3
3
|
import { DummySigners, TransactionBatchExecute } from "./TransactionBatchExecute";
|
|
4
4
|
import { SimpleIxGenerator } from './SimpleIxGenerator';
|
|
5
|
+
import { JupiterAlts } from './JupiterAlts';
|
|
5
6
|
export declare class Atomicity extends TransactionBatchExecute {
|
|
6
7
|
private ixGenerator;
|
|
7
8
|
/**
|
|
8
9
|
* User wallet
|
|
9
10
|
*/
|
|
10
11
|
private userWallet?;
|
|
11
|
-
constructor(lookupTableAddresses: web3.PublicKey[], instructions: web3.TransactionInstruction[], payer: web3.Keypair, connection: web3.Connection, signers: web3.Keypair[] | undefined, ixGenerator: SimpleIxGenerator);
|
|
12
|
+
constructor(lookupTableAddresses: web3.PublicKey[], instructions: web3.TransactionInstruction[], payer: web3.Keypair, connection: web3.Connection, signers: web3.Keypair[] | undefined, jupiterAlts: JupiterAlts, ixGenerator: SimpleIxGenerator);
|
|
12
13
|
/**
|
|
13
14
|
* Set user wallet
|
|
14
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Atomicity.d.ts","sourceRoot":"","sources":["../../../src/classes/Atomicity.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"Atomicity.d.ts","sourceRoot":"","sources":["../../../src/classes/Atomicity.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,qBAAa,SAAU,SAAQ,uBAAuB;IAclD,OAAO,CAAC,WAAW;IAZrB;;OAEG;IACH,OAAO,CAAC,UAAU,CAAC,CAAiB;gBAGlC,oBAAoB,EAAE,IAAI,CAAC,SAAS,EAAE,EACtC,YAAY,EAAE,IAAI,CAAC,sBAAsB,EAAE,EAC3C,KAAK,EAAE,IAAI,CAAC,OAAO,EACnB,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,OAAO,4BAAqB,EAC5B,WAAW,EAAE,WAAW,EAChB,WAAW,EAAE,iBAAiB;IAYxC;;OAEG;IACH,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS;IAIxC;;;OAGG;IACH,OAAO,CAAC,aAAa;IAOrB;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,EAAE,CAAC;IA4B5D;;;;;;OAMG;cACa,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,sBAAsB,EAAE,EAAE,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,EAAE,CAAC;CAiDxJ"}
|
|
@@ -13,8 +13,8 @@ exports.Atomicity = void 0;
|
|
|
13
13
|
const TransactionBatchExecute_1 = require("./TransactionBatchExecute");
|
|
14
14
|
const functions_1 = require("../functions");
|
|
15
15
|
class Atomicity extends TransactionBatchExecute_1.TransactionBatchExecute {
|
|
16
|
-
constructor(lookupTableAddresses, instructions, payer, connection, signers = [], ixGenerator) {
|
|
17
|
-
super(lookupTableAddresses, instructions, payer, connection, signers);
|
|
16
|
+
constructor(lookupTableAddresses, instructions, payer, connection, signers = [], jupiterAlts, ixGenerator) {
|
|
17
|
+
super(lookupTableAddresses, instructions, payer, connection, signers, jupiterAlts);
|
|
18
18
|
this.ixGenerator = ixGenerator;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
@@ -10,6 +10,7 @@ import { HawkApiOptions } from "../types";
|
|
|
10
10
|
import { SimpleIxGenerator } from "./SimpleIxGenerator";
|
|
11
11
|
import { TransactionBatchExecute, TransactionBatchExecuteParams } from "./TransactionBatchExecute";
|
|
12
12
|
import { Atomicity } from "./Atomicity";
|
|
13
|
+
import { JupiterAlts } from "./JupiterAlts";
|
|
13
14
|
/**
|
|
14
15
|
* HawkAPI is a central gateway class that aggregates access to various functional modules
|
|
15
16
|
* for interacting with HawkSight's blockchain APIs. This class initializes and exposes modules
|
|
@@ -41,6 +42,8 @@ export declare class HawkAPI {
|
|
|
41
42
|
readonly search: Search;
|
|
42
43
|
/** Simple instruction generator */
|
|
43
44
|
readonly simpleIxGenerator: SimpleIxGenerator;
|
|
45
|
+
/** Jupiter alts */
|
|
46
|
+
readonly jupAlts: JupiterAlts;
|
|
44
47
|
/**
|
|
45
48
|
* Initializes a new instance of the HawkAPI class with a specified API URL.
|
|
46
49
|
* @param url The base URL for the HawkSight API services, defaulted to "https://api2.hawksight.co" if not specified.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HawkAPI.d.ts","sourceRoot":"","sources":["../../../src/classes/HawkAPI.ts"],"names":[],"mappings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C,EAAE,6BAA6B;CAW1G"}
|
|
@@ -13,6 +13,7 @@ const CreateTxMetadata_1 = require("./CreateTxMetadata");
|
|
|
13
13
|
const SimpleIxGenerator_1 = require("./SimpleIxGenerator");
|
|
14
14
|
const TransactionBatchExecute_1 = require("./TransactionBatchExecute");
|
|
15
15
|
const Atomicity_1 = require("./Atomicity");
|
|
16
|
+
const JupiterAlts_1 = require("./JupiterAlts");
|
|
16
17
|
/**
|
|
17
18
|
* HawkAPI is a central gateway class that aggregates access to various functional modules
|
|
18
19
|
* for interacting with HawkSight's blockchain APIs. This class initializes and exposes modules
|
|
@@ -41,6 +42,7 @@ class HawkAPI {
|
|
|
41
42
|
this.txGeneratorAutomation = new TxGeneratorAutomations_1.TxGeneratorAutomations(client, this.generalUtility);
|
|
42
43
|
this.search = new Search_1.Search(url);
|
|
43
44
|
this.simpleIxGenerator = new SimpleIxGenerator_1.SimpleIxGenerator();
|
|
45
|
+
this.jupAlts = new JupiterAlts_1.JupiterAlts();
|
|
44
46
|
// Load create tx metadata module
|
|
45
47
|
if (this.options === undefined || !this.options.disableTxMetadataLoad) {
|
|
46
48
|
CreateTxMetadata_1.CreateTxMetadata.instance().load();
|
|
@@ -64,7 +66,7 @@ class HawkAPI {
|
|
|
64
66
|
* @param param
|
|
65
67
|
*/
|
|
66
68
|
batchExecute({ lookupTableAddresses, instructions, payer, connection, signers }) {
|
|
67
|
-
return new TransactionBatchExecute_1.TransactionBatchExecute(lookupTableAddresses, instructions, payer, connection, signers);
|
|
69
|
+
return new TransactionBatchExecute_1.TransactionBatchExecute(lookupTableAddresses, instructions, payer, connection, signers, this.jupAlts);
|
|
68
70
|
}
|
|
69
71
|
/**
|
|
70
72
|
* Create instance of Atomicity class
|
|
@@ -72,7 +74,7 @@ class HawkAPI {
|
|
|
72
74
|
* @param param
|
|
73
75
|
*/
|
|
74
76
|
atomicity({ lookupTableAddresses, instructions, payer, connection, signers }) {
|
|
75
|
-
return new Atomicity_1.Atomicity(lookupTableAddresses, instructions, payer, connection, signers, this.simpleIxGenerator);
|
|
77
|
+
return new Atomicity_1.Atomicity(lookupTableAddresses, instructions, payer, connection, signers, this.jupAlts, this.simpleIxGenerator);
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
80
|
exports.HawkAPI = HawkAPI;
|
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
/// <reference types="@meteora-ag/dlmm/node_modules/@solana/web3.js" />
|
|
2
|
+
import * as web3 from "@solana/web3.js";
|
|
3
|
+
export type Alts = Record<string, string>;
|
|
1
4
|
export declare class JupiterAlts {
|
|
5
|
+
private username?;
|
|
6
|
+
private password?;
|
|
7
|
+
private hash?;
|
|
8
|
+
private url?;
|
|
9
|
+
private _alts;
|
|
10
|
+
/**
|
|
11
|
+
* Return jupiter alts object
|
|
12
|
+
*/
|
|
13
|
+
get alts(): Alts;
|
|
14
|
+
/**
|
|
15
|
+
* Set API URL
|
|
16
|
+
*/
|
|
17
|
+
setApiUrl(url: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Find address lookup table from given public keys
|
|
20
|
+
*
|
|
21
|
+
* @param pubkeys
|
|
22
|
+
*/
|
|
23
|
+
findAltByPubkeys(pubkeys: web3.PublicKey[]): web3.PublicKey[];
|
|
24
|
+
/**
|
|
25
|
+
* Set server credentials
|
|
26
|
+
*
|
|
27
|
+
* @param username
|
|
28
|
+
* @param password
|
|
29
|
+
*/
|
|
30
|
+
setCredentials(username: string, password: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Download jupiter alts from endpoint
|
|
33
|
+
*
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
downloadAlts(): Promise<void>;
|
|
2
37
|
}
|
|
3
38
|
//# sourceMappingURL=JupiterAlts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JupiterAlts.d.ts","sourceRoot":"","sources":["../../../src/classes/JupiterAlts.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAW;
|
|
1
|
+
{"version":3,"file":"JupiterAlts.d.ts","sourceRoot":"","sources":["../../../src/classes/JupiterAlts.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAExC,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE1C,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OAAO,CAAC,IAAI,CAAC,CAAS;IACtB,OAAO,CAAC,GAAG,CAAC,CAAS;IACrB,OAAO,CAAC,KAAK,CAAY;IAEzB;;OAEG;IACH,IAAI,IAAI,IAAI,IAAI,CAEf;IAED;;OAEG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM;IAIrB;;;;OAIG;IACH,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,SAAS,EAAE;IAW7D;;;;;OAKG;IACH,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAKjD;;;;OAIG;IACG,YAAY;CAsBnB"}
|
|
@@ -1,6 +1,104 @@
|
|
|
1
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
|
+
};
|
|
2
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
35
|
exports.JupiterAlts = void 0;
|
|
36
|
+
const web3 = __importStar(require("@solana/web3.js"));
|
|
4
37
|
class JupiterAlts {
|
|
38
|
+
constructor() {
|
|
39
|
+
this._alts = {};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Return jupiter alts object
|
|
43
|
+
*/
|
|
44
|
+
get alts() {
|
|
45
|
+
return this._alts;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Set API URL
|
|
49
|
+
*/
|
|
50
|
+
setApiUrl(url) {
|
|
51
|
+
this.url = url;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Find address lookup table from given public keys
|
|
55
|
+
*
|
|
56
|
+
* @param pubkeys
|
|
57
|
+
*/
|
|
58
|
+
findAltByPubkeys(pubkeys) {
|
|
59
|
+
const alts = [];
|
|
60
|
+
for (const pubkey of pubkeys) {
|
|
61
|
+
const alt = this._alts[pubkey.toBase58()];
|
|
62
|
+
if (alt !== undefined) {
|
|
63
|
+
alts.push(new web3.PublicKey(alt));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return alts;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Set server credentials
|
|
70
|
+
*
|
|
71
|
+
* @param username
|
|
72
|
+
* @param password
|
|
73
|
+
*/
|
|
74
|
+
setCredentials(username, password) {
|
|
75
|
+
this.username = username;
|
|
76
|
+
this.password = password;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Download jupiter alts from endpoint
|
|
80
|
+
*
|
|
81
|
+
* @returns
|
|
82
|
+
*/
|
|
83
|
+
downloadAlts() {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
if (this.url === undefined) {
|
|
86
|
+
throw new Error('Please set endpoint URL via hawkAPI.jupAlts.setApiUrl first!');
|
|
87
|
+
}
|
|
88
|
+
if (this.username === undefined || this.password === undefined) {
|
|
89
|
+
throw new Error('Please set credentials via hawkAPI.jupAlts.setCredentials() first!');
|
|
90
|
+
}
|
|
91
|
+
const base64Credentials = btoa(`${this.username}:${this.password}`);
|
|
92
|
+
const hash = yield (yield fetch(this.url, { headers: { Authorization: `Basic ${base64Credentials}`, Range: 'bytes=9-72' } })).text();
|
|
93
|
+
// If hash matches, then no need to download the file.
|
|
94
|
+
if (this.hash === hash)
|
|
95
|
+
return;
|
|
96
|
+
// Otherwise, download the alts
|
|
97
|
+
const response = yield fetch(this.url, { headers: { Authorization: `Basic ${base64Credentials}` } });
|
|
98
|
+
const content = yield response.text();
|
|
99
|
+
const jsonString = content.slice(82, content.length - 1);
|
|
100
|
+
this._alts = JSON.parse(jsonString);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
5
103
|
}
|
|
6
104
|
exports.JupiterAlts = JupiterAlts;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="@meteora-ag/dlmm/node_modules/@solana/web3.js" />
|
|
2
2
|
import * as web3 from '@solana/web3.js';
|
|
3
|
+
import { JupiterAlts } from './JupiterAlts';
|
|
3
4
|
/**
|
|
4
5
|
* Dummy signers
|
|
5
6
|
*/
|
|
@@ -28,6 +29,7 @@ export declare class TransactionBatchExecute {
|
|
|
28
29
|
protected payer: web3.Keypair;
|
|
29
30
|
protected connection: web3.Connection;
|
|
30
31
|
protected signers: web3.Keypair[];
|
|
32
|
+
protected jupiterAlts: JupiterAlts;
|
|
31
33
|
protected readonly MAX_SIZE = 1232;
|
|
32
34
|
/**
|
|
33
35
|
* Downloaded address lookup table accounts
|
|
@@ -42,11 +44,24 @@ export declare class TransactionBatchExecute {
|
|
|
42
44
|
* @param connection Connection to mainnet
|
|
43
45
|
* @param signers Required signers to fulfill the transactions
|
|
44
46
|
*/
|
|
45
|
-
constructor(lookupTableAddresses: web3.PublicKey[], instructions: web3.TransactionInstruction[], payer: web3.Keypair, connection: web3.Connection, signers
|
|
47
|
+
constructor(lookupTableAddresses: web3.PublicKey[], instructions: web3.TransactionInstruction[], payer: web3.Keypair, connection: web3.Connection, signers: web3.Keypair[], jupiterAlts: JupiterAlts);
|
|
46
48
|
/**
|
|
47
49
|
* Downoad address lookup table from given cluster
|
|
48
50
|
*/
|
|
49
51
|
downloadAlts(): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Get list of lookup tables to download
|
|
54
|
+
*/
|
|
55
|
+
private getListOfAltsToDownload;
|
|
56
|
+
/**
|
|
57
|
+
* Filter lookup tables
|
|
58
|
+
*/
|
|
59
|
+
private filterLookupTables;
|
|
60
|
+
/**
|
|
61
|
+
* Get public keys from instruction
|
|
62
|
+
* @returns
|
|
63
|
+
*/
|
|
64
|
+
private getPubkeyFromInstruction;
|
|
50
65
|
/**
|
|
51
66
|
* Override signers (in case that signers are set to empty array)
|
|
52
67
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionBatchExecute.d.ts","sourceRoot":"","sources":["../../../src/classes/TransactionBatchExecute.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"TransactionBatchExecute.d.ts","sourceRoot":"","sources":["../../../src/classes/TransactionBatchExecute.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,mBAAmB,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;IACtC,YAAY,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;IAC/B,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC;CACvB,CAAA;AAED,MAAM,MAAM,6BAA6B,GAAG;IAC1C,oBAAoB,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;IACvC,YAAY,EAAE,IAAI,CAAC,sBAAsB,EAAE,CAAC;IAC5C,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC;IACpB,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC;IAC5B,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;CACzB,CAAA;AAED;;GAEG;AACH,qBAAa,uBAAuB;IAmBhC,SAAS,CAAC,oBAAoB,EAAE,IAAI,CAAC,SAAS,EAAE;IAChD,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,sBAAsB,EAAE;IACrD,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO;IAC7B,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU;IACrC,SAAS,CAAC,OAAO,EAAE,I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,CAAC,sBAAsB,EAAE,EAAE,CAAC;IA8BvJ;;;;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;;;;;OAKG;IACH,OAAO,CAAC,4BAA4B;IAapC;;;;;OAKG;IACH,OAAO,CAAC,yBAAyB;IAajC;;;;;OAKG;IACH,OAAO,CAAC,0BAA0B;IAqBlC;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;CA2BjC"}
|
|
@@ -47,12 +47,13 @@ class TransactionBatchExecute {
|
|
|
47
47
|
* @param connection Connection to mainnet
|
|
48
48
|
* @param signers Required signers to fulfill the transactions
|
|
49
49
|
*/
|
|
50
|
-
constructor(lookupTableAddresses, instructions, payer, connection, signers = []) {
|
|
50
|
+
constructor(lookupTableAddresses, instructions, payer, connection, signers = [], jupiterAlts) {
|
|
51
51
|
this.lookupTableAddresses = lookupTableAddresses;
|
|
52
52
|
this.instructions = instructions;
|
|
53
53
|
this.payer = payer;
|
|
54
54
|
this.connection = connection;
|
|
55
55
|
this.signers = signers;
|
|
56
|
+
this.jupiterAlts = jupiterAlts;
|
|
56
57
|
this.MAX_SIZE = 1232;
|
|
57
58
|
/**
|
|
58
59
|
* Downloaded address lookup table accounts
|
|
@@ -65,11 +66,20 @@ class TransactionBatchExecute {
|
|
|
65
66
|
*/
|
|
66
67
|
downloadAlts() {
|
|
67
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
// Public keys across all instructions
|
|
70
|
+
const pubkeys = this.getPubkeyFromInstruction();
|
|
71
|
+
// Download jupiter alts first
|
|
72
|
+
yield this.jupiterAlts.downloadAlts();
|
|
73
|
+
// Then find alts from pubkeys
|
|
74
|
+
const jupAlts = this.jupiterAlts.findAltByPubkeys(pubkeys);
|
|
75
|
+
// Then append jupiter alts in the lookup table address
|
|
76
|
+
this.lookupTableAddresses.push(...jupAlts);
|
|
77
|
+
// Then make sure lookup table addresses are unique
|
|
78
|
+
this.filterLookupTables();
|
|
79
|
+
// Get list of lookup tables to download
|
|
80
|
+
const lookupTableAddresses = this.getListOfAltsToDownload();
|
|
71
81
|
// Download if address lookup table does not match with downloaded alts
|
|
72
|
-
for (const lookupTable of
|
|
82
|
+
for (const lookupTable of lookupTableAddresses) {
|
|
73
83
|
const alt = yield this.connection.getAddressLookupTable(lookupTable);
|
|
74
84
|
if (alt.value === null) {
|
|
75
85
|
throw new Error(`Address lookup table: ${lookupTable} does not exist on the blockchain.`);
|
|
@@ -78,6 +88,44 @@ class TransactionBatchExecute {
|
|
|
78
88
|
}
|
|
79
89
|
});
|
|
80
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Get list of lookup tables to download
|
|
93
|
+
*/
|
|
94
|
+
getListOfAltsToDownload() {
|
|
95
|
+
const alts = this.alts.map(alt => alt.key.toBase58());
|
|
96
|
+
const toDownload = [];
|
|
97
|
+
for (const alt of this.lookupTableAddresses) {
|
|
98
|
+
if (!alts.includes(alt.toBase58())) {
|
|
99
|
+
toDownload.push(alt);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return toDownload;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Filter lookup tables
|
|
106
|
+
*/
|
|
107
|
+
filterLookupTables() {
|
|
108
|
+
const map = {};
|
|
109
|
+
for (const alt of this.lookupTableAddresses) {
|
|
110
|
+
map[alt.toBase58()] = 1;
|
|
111
|
+
}
|
|
112
|
+
const filtered = [];
|
|
113
|
+
for (const alt in map) {
|
|
114
|
+
filtered.push(new web3.PublicKey(alt));
|
|
115
|
+
}
|
|
116
|
+
this.lookupTableAddresses = filtered;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get public keys from instruction
|
|
120
|
+
* @returns
|
|
121
|
+
*/
|
|
122
|
+
getPubkeyFromInstruction() {
|
|
123
|
+
const pubkeys = [];
|
|
124
|
+
this.instructions.map(ix => {
|
|
125
|
+
pubkeys.push(...ix.keys.map(meta => meta.pubkey));
|
|
126
|
+
});
|
|
127
|
+
return pubkeys;
|
|
128
|
+
}
|
|
81
129
|
/**
|
|
82
130
|
* Override signers (in case that signers are set to empty array)
|
|
83
131
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hawksightco/hawk-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11",
|
|
4
4
|
"description": "Hawksight v2 SDK",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"repository": "https://github.com/ghabxph/hawk-api-client.git",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"@types/jest": "^29.5.12",
|
|
18
18
|
"@types/lodash": "^4.17.7",
|
|
19
19
|
"@types/node": "^20.11.5",
|
|
20
|
-
"dotenv": "^16.4.5",
|
|
21
20
|
"jest": "^29.7.0",
|
|
22
21
|
"ts-jest": "^29.1.2",
|
|
23
|
-
"typescript": "^5.4.5"
|
|
22
|
+
"typescript": "^5.4.5",
|
|
23
|
+
"dotenv": "^16.4.5"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@coral-xyz/anchor": "~0.29.0",
|