@hawksightco/hawk-sdk 1.1.7 → 1.1.9
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 +34 -0
- package/dist/src/classes/Atomicity.d.ts.map +1 -0
- package/dist/src/classes/Atomicity.js +113 -0
- package/dist/src/classes/HawkAPI.d.ts +14 -0
- package/dist/src/classes/HawkAPI.d.ts.map +1 -1
- package/dist/src/classes/HawkAPI.js +19 -1
- package/dist/src/classes/SimpleIxGenerator.d.ts +0 -8
- package/dist/src/classes/SimpleIxGenerator.d.ts.map +1 -1
- package/dist/src/classes/SimpleIxGenerator.js +0 -8
- package/dist/src/classes/TransactionBatchExecute.d.ts +113 -0
- package/dist/src/classes/TransactionBatchExecute.d.ts.map +1 -0
- package/dist/src/classes/TransactionBatchExecute.js +294 -0
- package/dist/src/idl/iyf-main-idl.d.ts +4 -1
- package/dist/src/idl/iyf-main-idl.d.ts.map +1 -1
- package/dist/src/idl/iyf-main-idl.js +4 -1
- package/package.json +1 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/// <reference types="@meteora-ag/dlmm/node_modules/@solana/web3.js" />
|
|
2
|
+
import * as web3 from '@solana/web3.js';
|
|
3
|
+
import { DummySigners, TransactionBatchExecute } from "./TransactionBatchExecute";
|
|
4
|
+
import { SimpleIxGenerator } from './SimpleIxGenerator';
|
|
5
|
+
export declare class Atomicity extends TransactionBatchExecute {
|
|
6
|
+
private ixGenerator;
|
|
7
|
+
/**
|
|
8
|
+
* User wallet
|
|
9
|
+
*/
|
|
10
|
+
private userWallet?;
|
|
11
|
+
constructor(lookupTableAddresses: web3.PublicKey[], instructions: web3.TransactionInstruction[], payer: web3.Keypair, connection: web3.Connection, signers: web3.Keypair[] | undefined, ixGenerator: SimpleIxGenerator);
|
|
12
|
+
/**
|
|
13
|
+
* Set user wallet
|
|
14
|
+
*/
|
|
15
|
+
setUserWallet(userWallet: web3.PublicKey): void;
|
|
16
|
+
/**
|
|
17
|
+
* Check whether instruction is an atomicity instruction
|
|
18
|
+
* @param ix
|
|
19
|
+
*/
|
|
20
|
+
private isAtomicityIx;
|
|
21
|
+
/**
|
|
22
|
+
* Builds a batch of executable transaction instructions
|
|
23
|
+
*/
|
|
24
|
+
buildBatch(): Promise<web3.TransactionInstruction[][]>;
|
|
25
|
+
/**
|
|
26
|
+
* Split transactions
|
|
27
|
+
*
|
|
28
|
+
* @param simulationIxs
|
|
29
|
+
* @param dummySigners
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
protected splitToTransactions(simulationIxs: web3.TransactionInstruction[], dummySigners: DummySigners): Promise<web3.TransactionInstruction[][]>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=Atomicity.d.ts.map
|
|
@@ -0,0 +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;AAGxD,qBAAa,SAAU,SAAQ,uBAAuB;IAalD,OAAO,CAAC,WAAW;IAXrB;;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,EACpB,WAAW,EAAE,iBAAiB;IAWxC;;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"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Atomicity = void 0;
|
|
13
|
+
const TransactionBatchExecute_1 = require("./TransactionBatchExecute");
|
|
14
|
+
const functions_1 = require("../functions");
|
|
15
|
+
class Atomicity extends TransactionBatchExecute_1.TransactionBatchExecute {
|
|
16
|
+
constructor(lookupTableAddresses, instructions, payer, connection, signers = [], ixGenerator) {
|
|
17
|
+
super(lookupTableAddresses, instructions, payer, connection, signers);
|
|
18
|
+
this.ixGenerator = ixGenerator;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Set user wallet
|
|
22
|
+
*/
|
|
23
|
+
setUserWallet(userWallet) {
|
|
24
|
+
this.userWallet = userWallet;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Check whether instruction is an atomicity instruction
|
|
28
|
+
* @param ix
|
|
29
|
+
*/
|
|
30
|
+
isAtomicityIx(ix) {
|
|
31
|
+
if (ix.data.length >= 8) {
|
|
32
|
+
return (0, functions_1.sighashMatch)(ix.data, "setTransactionSlot") || (0, functions_1.sighashMatch)(ix.data, "verifyTransactionSlot");
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Builds a batch of executable transaction instructions
|
|
38
|
+
*/
|
|
39
|
+
buildBatch() {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
// Download address lookup table from given cluster
|
|
42
|
+
yield this.downloadAlts();
|
|
43
|
+
// Generate dummy instructions for batch calculation
|
|
44
|
+
const [simulationIxs, dummySigners] = this.generateSimulationIxs();
|
|
45
|
+
// Split simulation ixs
|
|
46
|
+
const dummyBatches = yield this.splitToTransactions(simulationIxs, dummySigners);
|
|
47
|
+
// Batch of actual instructions
|
|
48
|
+
const batch = [];
|
|
49
|
+
let index = 0;
|
|
50
|
+
for (const dummyIxs of dummyBatches) {
|
|
51
|
+
const currentBatch = [];
|
|
52
|
+
for (const dummyIx of dummyIxs) {
|
|
53
|
+
if (this.isAtomicityIx(dummyIx)) {
|
|
54
|
+
currentBatch.push(dummyIx);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
currentBatch.push(this.instructions[index++]);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
batch.push(currentBatch);
|
|
61
|
+
}
|
|
62
|
+
return batch;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Split transactions
|
|
67
|
+
*
|
|
68
|
+
* @param simulationIxs
|
|
69
|
+
* @param dummySigners
|
|
70
|
+
* @returns
|
|
71
|
+
*/
|
|
72
|
+
splitToTransactions(simulationIxs, dummySigners) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
// Fetch latest blockhash required to calculate transaction size
|
|
75
|
+
const latestBlockhash = yield this.connection.getLatestBlockhash();
|
|
76
|
+
// User wallet must be set
|
|
77
|
+
if (this.userWallet === undefined) {
|
|
78
|
+
throw new Error(`Atomicity.userWallet is not set`);
|
|
79
|
+
}
|
|
80
|
+
// Generate set transaction slot instruction
|
|
81
|
+
const setTransactionSlotIx = yield this.ixGenerator.setTransactionSlot(this.connection, { userWallet: this.userWallet });
|
|
82
|
+
// Generate verify transaction slot instruction
|
|
83
|
+
const verifyTransactionSlotIx = yield this.ixGenerator.verifyTransactionSlot(this.connection, { userWallet: this.userWallet });
|
|
84
|
+
// Run simulation
|
|
85
|
+
let batch = [];
|
|
86
|
+
let result = [];
|
|
87
|
+
let postIx;
|
|
88
|
+
for (const ix of simulationIxs) {
|
|
89
|
+
// Include dummy ix to transaction
|
|
90
|
+
batch.push(ix);
|
|
91
|
+
// Include setTransactionSlot instruction if result batch is still zero
|
|
92
|
+
if (result.length === 0) {
|
|
93
|
+
postIx = setTransactionSlotIx;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
postIx = verifyTransactionSlotIx;
|
|
97
|
+
}
|
|
98
|
+
// Calculate transaction size
|
|
99
|
+
const txSize = this.calculateTransactionSize(latestBlockhash, [...batch, postIx], dummySigners);
|
|
100
|
+
if (txSize > this.MAX_SIZE) {
|
|
101
|
+
batch.pop();
|
|
102
|
+
result.push([...batch, postIx]);
|
|
103
|
+
batch = [ix];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (batch.length > 0 && simulationIxs.length !== 0) {
|
|
107
|
+
result.push([...batch, postIx]);
|
|
108
|
+
}
|
|
109
|
+
return result;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.Atomicity = Atomicity;
|
|
@@ -8,6 +8,8 @@ import { GeneralUtility } from "./GeneralUtility";
|
|
|
8
8
|
import { Search } from "./Search";
|
|
9
9
|
import { HawkApiOptions } from "../types";
|
|
10
10
|
import { SimpleIxGenerator } from "./SimpleIxGenerator";
|
|
11
|
+
import { TransactionBatchExecute, TransactionBatchExecuteParams } from "./TransactionBatchExecute";
|
|
12
|
+
import { Atomicity } from "./Atomicity";
|
|
11
13
|
/**
|
|
12
14
|
* HawkAPI is a central gateway class that aggregates access to various functional modules
|
|
13
15
|
* for interacting with HawkSight's blockchain APIs. This class initializes and exposes modules
|
|
@@ -50,5 +52,17 @@ export declare class HawkAPI {
|
|
|
50
52
|
* @param txGenerator
|
|
51
53
|
*/
|
|
52
54
|
overrideTxGenerator(builderFn: (client: Client, generalUtility: GeneralUtility) => TxGenerator): void;
|
|
55
|
+
/**
|
|
56
|
+
* Create instance of TransactionBatchExecute class
|
|
57
|
+
*
|
|
58
|
+
* @param param
|
|
59
|
+
*/
|
|
60
|
+
batchExecute({ lookupTableAddresses, instructions, payer, connection, signers }: TransactionBatchExecuteParams): TransactionBatchExecute;
|
|
61
|
+
/**
|
|
62
|
+
* Create instance of Atomicity class
|
|
63
|
+
*
|
|
64
|
+
* @param param
|
|
65
|
+
*/
|
|
66
|
+
atomicity({ lookupTableAddresses, instructions, payer, connection, signers }: TransactionBatchExecuteParams): Atomicity;
|
|
53
67
|
}
|
|
54
68
|
//# sourceMappingURL=HawkAPI.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HawkAPI.d.ts","sourceRoot":"","sources":["../../../src/classes/HawkAPI.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HawkAPI.d.ts","sourceRoot":"","sources":["../../../src/classes/HawkAPI.ts"],"names":[],"mappings":"AACA,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,EA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,EAAE,6BAA6B;IAU5G;;;;OAIG;IACH,SAAS,CAAC,EAAC,oBAAoB,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAC,EAAE,6BAA6B;CAU1G"}
|
|
@@ -11,6 +11,8 @@ const GeneralUtility_1 = require("./GeneralUtility");
|
|
|
11
11
|
const Search_1 = require("./Search");
|
|
12
12
|
const CreateTxMetadata_1 = require("./CreateTxMetadata");
|
|
13
13
|
const SimpleIxGenerator_1 = require("./SimpleIxGenerator");
|
|
14
|
+
const TransactionBatchExecute_1 = require("./TransactionBatchExecute");
|
|
15
|
+
const Atomicity_1 = require("./Atomicity");
|
|
14
16
|
/**
|
|
15
17
|
* HawkAPI is a central gateway class that aggregates access to various functional modules
|
|
16
18
|
* for interacting with HawkSight's blockchain APIs. This class initializes and exposes modules
|
|
@@ -38,7 +40,7 @@ class HawkAPI {
|
|
|
38
40
|
this._txGenerator = new TxGenerator_1.TxGenerator(client, this.generalUtility);
|
|
39
41
|
this.txGeneratorAutomation = new TxGeneratorAutomations_1.TxGeneratorAutomations(client, this.generalUtility);
|
|
40
42
|
this.search = new Search_1.Search(url);
|
|
41
|
-
this.simpleIxGenerator = new SimpleIxGenerator_1.SimpleIxGenerator(
|
|
43
|
+
this.simpleIxGenerator = new SimpleIxGenerator_1.SimpleIxGenerator();
|
|
42
44
|
// Load create tx metadata module
|
|
43
45
|
if (this.options === undefined || !this.options.disableTxMetadataLoad) {
|
|
44
46
|
CreateTxMetadata_1.CreateTxMetadata.instance().load();
|
|
@@ -56,5 +58,21 @@ class HawkAPI {
|
|
|
56
58
|
overrideTxGenerator(builderFn) {
|
|
57
59
|
this._txGenerator = builderFn(this.client, this.generalUtility);
|
|
58
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Create instance of TransactionBatchExecute class
|
|
63
|
+
*
|
|
64
|
+
* @param param
|
|
65
|
+
*/
|
|
66
|
+
batchExecute({ lookupTableAddresses, instructions, payer, connection, signers }) {
|
|
67
|
+
return new TransactionBatchExecute_1.TransactionBatchExecute(lookupTableAddresses, instructions, payer, connection, signers);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Create instance of Atomicity class
|
|
71
|
+
*
|
|
72
|
+
* @param param
|
|
73
|
+
*/
|
|
74
|
+
atomicity({ lookupTableAddresses, instructions, payer, connection, signers }) {
|
|
75
|
+
return new Atomicity_1.Atomicity(lookupTableAddresses, instructions, payer, connection, signers, this.simpleIxGenerator);
|
|
76
|
+
}
|
|
59
77
|
}
|
|
60
78
|
exports.HawkAPI = HawkAPI;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="@meteora-ag/dlmm/node_modules/@solana/web3.js" />
|
|
2
2
|
import * as web3 from "@solana/web3.js";
|
|
3
|
-
import { GeneralUtility } from "./GeneralUtility";
|
|
4
3
|
import { AtomicityContextParams } from "../hawksight";
|
|
5
4
|
/**
|
|
6
5
|
* The SimpleIxGenerator class is a general-purpose utility for generating single
|
|
@@ -9,13 +8,6 @@ import { AtomicityContextParams } from "../hawksight";
|
|
|
9
8
|
* interacting with the user's PDA (Program Derived Address) account.
|
|
10
9
|
*/
|
|
11
10
|
export declare class SimpleIxGenerator {
|
|
12
|
-
protected readonly generalUtility: GeneralUtility;
|
|
13
|
-
/**
|
|
14
|
-
* Initializes an instance of the SimpleIxGenerator class.
|
|
15
|
-
*
|
|
16
|
-
* @param generalUtility - An instance of GeneralUtility that provides general utility functions.
|
|
17
|
-
*/
|
|
18
|
-
constructor(generalUtility: GeneralUtility);
|
|
19
11
|
/**
|
|
20
12
|
* Generates a transaction instruction that sets the current blockchain clock
|
|
21
13
|
* to the user's PDA (Program Derived Address) account.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleIxGenerator.d.ts","sourceRoot":"","sources":["../../../src/classes/SimpleIxGenerator.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"SimpleIxGenerator.d.ts","sourceRoot":"","sources":["../../../src/classes/SimpleIxGenerator.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAGxC,OAAO,EAA6C,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEjG;;;;;GAKG;AACH,qBAAa,iBAAiB;IAE5B;;;;;;;OAOG;IACG,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAQ3H;;;;;;;OAOG;IACG,qBAAqB,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC;CAO/H"}
|
|
@@ -19,14 +19,6 @@ const hawksight_1 = require("../hawksight");
|
|
|
19
19
|
* interacting with the user's PDA (Program Derived Address) account.
|
|
20
20
|
*/
|
|
21
21
|
class SimpleIxGenerator {
|
|
22
|
-
/**
|
|
23
|
-
* Initializes an instance of the SimpleIxGenerator class.
|
|
24
|
-
*
|
|
25
|
-
* @param generalUtility - An instance of GeneralUtility that provides general utility functions.
|
|
26
|
-
*/
|
|
27
|
-
constructor(generalUtility) {
|
|
28
|
-
this.generalUtility = generalUtility;
|
|
29
|
-
}
|
|
30
22
|
/**
|
|
31
23
|
* Generates a transaction instruction that sets the current blockchain clock
|
|
32
24
|
* to the user's PDA (Program Derived Address) account.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/// <reference types="@meteora-ag/dlmm/node_modules/@solana/web3.js" />
|
|
2
|
+
import * as web3 from '@solana/web3.js';
|
|
3
|
+
/**
|
|
4
|
+
* Dummy signers
|
|
5
|
+
*/
|
|
6
|
+
export type DummySigners = Record<string, web3.Keypair>;
|
|
7
|
+
/**
|
|
8
|
+
* Transaction batch
|
|
9
|
+
*/
|
|
10
|
+
export type Batch = {
|
|
11
|
+
addressLookupTables: web3.PublicKey[];
|
|
12
|
+
instructions: web3.PublicKey[];
|
|
13
|
+
signers: web3.Keypair;
|
|
14
|
+
};
|
|
15
|
+
export type TransactionBatchExecuteParams = {
|
|
16
|
+
lookupTableAddresses: web3.PublicKey[];
|
|
17
|
+
instructions: web3.TransactionInstruction[];
|
|
18
|
+
payer: web3.Keypair;
|
|
19
|
+
connection: web3.Connection;
|
|
20
|
+
signers: web3.Keypair[];
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Executes transactions in batches
|
|
24
|
+
*/
|
|
25
|
+
export declare class TransactionBatchExecute {
|
|
26
|
+
protected lookupTableAddresses: web3.PublicKey[];
|
|
27
|
+
protected instructions: web3.TransactionInstruction[];
|
|
28
|
+
protected payer: web3.Keypair;
|
|
29
|
+
protected connection: web3.Connection;
|
|
30
|
+
protected signers: web3.Keypair[];
|
|
31
|
+
protected readonly MAX_SIZE = 1232;
|
|
32
|
+
/**
|
|
33
|
+
* Downloaded address lookup table accounts
|
|
34
|
+
*/
|
|
35
|
+
protected alts: web3.AddressLookupTableAccount[];
|
|
36
|
+
/**
|
|
37
|
+
* Creates an instance of TransactionExecute class
|
|
38
|
+
*
|
|
39
|
+
* @param lookupTableAddresses Address lookup table addresses to be used by batch of transactions
|
|
40
|
+
* @param instructions Array of instructions to be batched into transactions
|
|
41
|
+
* @param payer Payer that will pay for the batch of transactions
|
|
42
|
+
* @param connection Connection to mainnet
|
|
43
|
+
* @param signers Required signers to fulfill the transactions
|
|
44
|
+
*/
|
|
45
|
+
constructor(lookupTableAddresses: web3.PublicKey[], instructions: web3.TransactionInstruction[], payer: web3.Keypair, connection: web3.Connection, signers?: web3.Keypair[]);
|
|
46
|
+
/**
|
|
47
|
+
* Downoad address lookup table from given cluster
|
|
48
|
+
*/
|
|
49
|
+
downloadAlts(): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Override signers (in case that signers are set to empty array)
|
|
52
|
+
*
|
|
53
|
+
* @param signers
|
|
54
|
+
*/
|
|
55
|
+
setSigners(signers: web3.Keypair[]): void;
|
|
56
|
+
/**
|
|
57
|
+
* Find missing signers
|
|
58
|
+
*/
|
|
59
|
+
findMissingSigners(): web3.PublicKey[];
|
|
60
|
+
/**
|
|
61
|
+
* Returns list of public keys that are required to sign the batch of transaction
|
|
62
|
+
*/
|
|
63
|
+
findRequiredSigningPubkeys(): web3.PublicKey[];
|
|
64
|
+
/**
|
|
65
|
+
* Generate dummy signers needed for simulation
|
|
66
|
+
*
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
69
|
+
generateDummySigners(): DummySigners;
|
|
70
|
+
/**
|
|
71
|
+
* Generate instruction that has modified signers for simulation purposes
|
|
72
|
+
*/
|
|
73
|
+
generateSimulationIxs(): [web3.TransactionInstruction[], DummySigners];
|
|
74
|
+
/**
|
|
75
|
+
* Builds a batch of executable transaction instructions
|
|
76
|
+
*/
|
|
77
|
+
buildBatch(): Promise<web3.TransactionInstruction[][]>;
|
|
78
|
+
/**
|
|
79
|
+
* Split transactions
|
|
80
|
+
*
|
|
81
|
+
* @param simulationIxs
|
|
82
|
+
* @param dummySigners
|
|
83
|
+
* @returns
|
|
84
|
+
*/
|
|
85
|
+
protected splitToTransactions(simulationIxs: web3.TransactionInstruction[], dummySigners: DummySigners): Promise<web3.TransactionInstruction[][]>;
|
|
86
|
+
/**
|
|
87
|
+
* Calculate transaction size
|
|
88
|
+
*
|
|
89
|
+
* @param batch
|
|
90
|
+
*/
|
|
91
|
+
protected calculateTransactionSize(latestBlockhash: web3.BlockhashWithExpiryBlockHeight, batch: web3.TransactionInstruction[], dummySigners: DummySigners): number;
|
|
92
|
+
/**
|
|
93
|
+
* Find required signers from batch
|
|
94
|
+
*
|
|
95
|
+
* @param ixs
|
|
96
|
+
* @param dummySigners
|
|
97
|
+
*/
|
|
98
|
+
private findRequiredSignersFromBatch;
|
|
99
|
+
/**
|
|
100
|
+
* Find required signers from instructions
|
|
101
|
+
*
|
|
102
|
+
* @param ixs
|
|
103
|
+
* @param dummySigners
|
|
104
|
+
*/
|
|
105
|
+
private findRequiredSignersFromIxs;
|
|
106
|
+
/**
|
|
107
|
+
* Find required address lookup table addresses for given batch of instructions
|
|
108
|
+
*
|
|
109
|
+
* @param batch
|
|
110
|
+
*/
|
|
111
|
+
private findRequiredAltsForBatch;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=TransactionBatchExecute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionBatchExecute.d.ts","sourceRoot":"","sources":["../../../src/classes/TransactionBatchExecute.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAExC;;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,IAA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