@hawksightco/hawk-sdk 0.0.15 → 0.0.16
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.
|
@@ -9,7 +9,7 @@ import { GeneralUtility } from "./GeneralUtility";
|
|
|
9
9
|
export declare class Transaction {
|
|
10
10
|
readonly txMetadataResponse: TransactionMetadataResponse;
|
|
11
11
|
readonly payerKey: web3.PublicKey;
|
|
12
|
-
private
|
|
12
|
+
private latestBlockhash;
|
|
13
13
|
readonly alts: web3.AddressLookupTableAccount[];
|
|
14
14
|
private generalUtility;
|
|
15
15
|
/** Compiled TransactionMessage which includes payer, instructions, and recent blockhash */
|
|
@@ -28,6 +28,8 @@ export declare class Transaction {
|
|
|
28
28
|
/** Array of TransactionInstruction to be executed in this transaction */
|
|
29
29
|
private _instructions;
|
|
30
30
|
get instructions(): web3.TransactionInstruction[];
|
|
31
|
+
/** last valid block height */
|
|
32
|
+
get lastValidBlockHeight(): number;
|
|
31
33
|
/**
|
|
32
34
|
* Constructs a new Transaction object.
|
|
33
35
|
*
|
|
@@ -36,7 +38,7 @@ export declare class Transaction {
|
|
|
36
38
|
* @param recentBlockhash The blockhash of a recent ledger entry
|
|
37
39
|
* @param alts Address lookup tables that optimize account address storage
|
|
38
40
|
*/
|
|
39
|
-
constructor(txMetadataResponse: TransactionMetadataResponse, payerKey: web3.PublicKey,
|
|
41
|
+
constructor(txMetadataResponse: TransactionMetadataResponse, payerKey: web3.PublicKey, latestBlockhash: web3.BlockhashWithExpiryBlockHeight, alts: web3.AddressLookupTableAccount[], generalUtility: GeneralUtility);
|
|
40
42
|
/**
|
|
41
43
|
* Signs the transaction with provided signers.
|
|
42
44
|
*
|
|
@@ -65,7 +67,7 @@ export declare class Transaction {
|
|
|
65
67
|
/**
|
|
66
68
|
* Builds transaction object
|
|
67
69
|
*/
|
|
68
|
-
buildTransaction(
|
|
70
|
+
buildTransaction(latestBlockhash: web3.BlockhashWithExpiryBlockHeight): [web3.TransactionMessage, web3.VersionedTransaction];
|
|
69
71
|
/**
|
|
70
72
|
* Gathers the public keys of all parties required to sign the transaction.
|
|
71
73
|
*
|
|
@@ -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;AACxC,OAAO,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAGrF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;GAGG;AACH,qBAAa,WAAW;
|
|
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;AACxC,OAAO,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAGrF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;GAGG;AACH,qBAAa,WAAW;IAoCpB,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;IAtCxB,2FAA2F;IAC3F,OAAO,CAAC,UAAU,CAA0B;IAC5C,IAAI,SAAS,IAAI,IAAI,CAAC,kBAAkB,CAA2B;IAEnE,+DAA+D;IAC/D,OAAO,CAAC,qBAAqB,CAA4B;IACzD,IAAI,oBAAoB,IAAI,IAAI,CAAC,oBAAoB,CAAuC;IAE5F,+EAA+E;IAC/E,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC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,CAAC,4BAA4B;IAQpC;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAW7B"}
|
|
@@ -45,8 +45,10 @@ class Transaction {
|
|
|
45
45
|
get versionedTransaction() { return this._versionedTransaction; }
|
|
46
46
|
get priorityFeeEstimate() { return this._priorityFeeEstimate; }
|
|
47
47
|
/** The blockhash of a recent ledger entry */
|
|
48
|
-
get recentBlockhash() { return this.
|
|
48
|
+
get recentBlockhash() { return this.latestBlockhash.blockhash; }
|
|
49
49
|
get instructions() { return this._instructions; }
|
|
50
|
+
/** last valid block height */
|
|
51
|
+
get lastValidBlockHeight() { return this.latestBlockhash.lastValidBlockHeight; }
|
|
50
52
|
/**
|
|
51
53
|
* Constructs a new Transaction object.
|
|
52
54
|
*
|
|
@@ -55,7 +57,7 @@ class Transaction {
|
|
|
55
57
|
* @param recentBlockhash The blockhash of a recent ledger entry
|
|
56
58
|
* @param alts Address lookup tables that optimize account address storage
|
|
57
59
|
*/
|
|
58
|
-
constructor(txMetadataResponse, payerKey,
|
|
60
|
+
constructor(txMetadataResponse, payerKey, latestBlockhash, alts, generalUtility) {
|
|
59
61
|
// // Construct compute instructions
|
|
60
62
|
// const computeIxs = txMetadataResponse.computeBudgetInstructions.map(ix => {
|
|
61
63
|
// return new web3.TransactionInstruction({
|
|
@@ -68,7 +70,7 @@ class Transaction {
|
|
|
68
70
|
// });
|
|
69
71
|
this.txMetadataResponse = txMetadataResponse;
|
|
70
72
|
this.payerKey = payerKey;
|
|
71
|
-
this.
|
|
73
|
+
this.latestBlockhash = latestBlockhash;
|
|
72
74
|
this.alts = alts;
|
|
73
75
|
this.generalUtility = generalUtility;
|
|
74
76
|
/** Estimated fee in SOL for priority fee when addPriorityFee() method is called. */
|
|
@@ -84,7 +86,7 @@ class Transaction {
|
|
|
84
86
|
});
|
|
85
87
|
});
|
|
86
88
|
this._instructions = [...mainIxs];
|
|
87
|
-
const [txMessage, versionedTransaction] = this.buildTransaction(
|
|
89
|
+
const [txMessage, versionedTransaction] = this.buildTransaction(latestBlockhash);
|
|
88
90
|
this._txMessage = txMessage;
|
|
89
91
|
this._versionedTransaction = versionedTransaction;
|
|
90
92
|
this.requiredSigners = this.getRequiredSigners();
|
|
@@ -151,7 +153,7 @@ class Transaction {
|
|
|
151
153
|
// Append priority fee instruction at the beginning
|
|
152
154
|
this._instructions.unshift(...priorityFeeIxs);
|
|
153
155
|
// Rebuild versioned transaction
|
|
154
|
-
const
|
|
156
|
+
const blockhash = yield connection.getLatestBlockhash();
|
|
155
157
|
this.buildTransaction(blockhash);
|
|
156
158
|
return priorityFeeIxs;
|
|
157
159
|
});
|
|
@@ -192,11 +194,12 @@ class Transaction {
|
|
|
192
194
|
/**
|
|
193
195
|
* Builds transaction object
|
|
194
196
|
*/
|
|
195
|
-
buildTransaction(
|
|
197
|
+
buildTransaction(latestBlockhash) {
|
|
198
|
+
this.latestBlockhash = latestBlockhash;
|
|
196
199
|
this._txMessage = new web3.TransactionMessage({
|
|
197
200
|
payerKey: this.payerKey,
|
|
198
201
|
instructions: this.instructions,
|
|
199
|
-
recentBlockhash,
|
|
202
|
+
recentBlockhash: this.recentBlockhash,
|
|
200
203
|
});
|
|
201
204
|
this._versionedTransaction = new web3.VersionedTransaction(this.txMessage.compileToV0Message(this.alts));
|
|
202
205
|
return [this._txMessage, this._versionedTransaction];
|
package/dist/src/functions.js
CHANGED
|
@@ -60,9 +60,9 @@ function createTxMetadata(generalUtility, connection, payer, data, priorityLevel
|
|
|
60
60
|
alts.push((yield connection.getAddressLookupTable(new web3.PublicKey(alt))).value);
|
|
61
61
|
}
|
|
62
62
|
// Get the recent blockhash
|
|
63
|
-
const
|
|
63
|
+
const latestBlockhash = yield connection.getLatestBlockhash();
|
|
64
64
|
// Create initial transaction instance
|
|
65
|
-
const transaction = new Transaction_1.Transaction(data, new web3.PublicKey(payer),
|
|
65
|
+
const transaction = new Transaction_1.Transaction(data, new web3.PublicKey(payer), latestBlockhash, alts, generalUtility);
|
|
66
66
|
// // Simulate transaction to get consumed units
|
|
67
67
|
// const simulation = await transaction.simulateTransaction(connection);
|
|
68
68
|
// // Check if there's error in transaction
|