@streamflow/common 8.0.0-alpha.p287.84ff30f → 8.0.1-alpha.p287.54fe41f
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/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/solana/index.cjs +92 -57
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +96 -19
- package/dist/cjs/solana/rpc/index.cjs +40 -20
- package/dist/cjs/solana/rpc/index.cjs.map +1 -1
- package/dist/cjs/solana/rpc/index.d.cts +77 -4
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +96 -19
- package/dist/esm/solana/index.js +93 -60
- package/dist/esm/solana/index.js.map +1 -1
- package/dist/esm/solana/rpc/index.d.ts +77 -4
- package/dist/esm/solana/rpc/index.js +40 -21
- package/dist/esm/solana/rpc/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/cjs/types-DGCX8JLm.d.cts +0 -73
- package/dist/esm/types-DGCX8JLm.d.ts +0 -73
|
@@ -1,21 +1,73 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _solana_web3_js from '@solana/web3.js';
|
|
2
|
+
import { PublicKey, MemcmpFilter, Connection, TransactionInstruction, VersionedTransaction, AccountInfo, BlockhashWithExpiryBlockHeight, Context, Commitment, Keypair, Transaction, RpcResponseAndContext, SimulatedTransactionResponse, SignatureStatus } from '@solana/web3.js';
|
|
2
3
|
import BN from 'bn.js';
|
|
3
|
-
import
|
|
4
|
-
export { d as CheckAssociatedTokenAccountsData, G as GetPriorityFeeEstimateOptions, e as IProgramAccount, f as TransactionFailedError } from '../types-DGCX8JLm.js';
|
|
4
|
+
import PQueue from 'p-queue';
|
|
5
5
|
import { Mint } from '@solana/spl-token';
|
|
6
6
|
import { SignerWalletAdapter } from '@solana/wallet-adapter-base';
|
|
7
|
-
import PQueue from 'p-queue';
|
|
8
7
|
|
|
9
8
|
declare const getFilters: <T extends Record<string, number | PublicKey>>(criteria: T, byteOffsets: Record<keyof T, number>) => MemcmpFilter[];
|
|
10
9
|
|
|
11
10
|
declare const prepareWrappedAccount: (connection: Connection, senderAddress: PublicKey, amount: BN) => Promise<TransactionInstruction[]>;
|
|
12
11
|
|
|
12
|
+
type ComputePriceEstimate = (tx: string | (string | PublicKey)[]) => Promise<number>;
|
|
13
|
+
type ComputeLimitEstimate = (tx: VersionedTransaction) => Promise<number>;
|
|
14
|
+
interface ITransactionSolanaExt {
|
|
15
|
+
computePrice?: number | ComputePriceEstimate;
|
|
16
|
+
computeLimit?: number | ComputeLimitEstimate | "autoSimulate";
|
|
17
|
+
}
|
|
13
18
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* @returns The PublicKey object.
|
|
19
|
+
* Acceptable type with resolved values.
|
|
20
|
+
* Function types may be omitted if passed to destinations that do not support them.
|
|
17
21
|
*/
|
|
18
|
-
|
|
22
|
+
type ITransactionSolanaExtResolvedValues = {
|
|
23
|
+
computePrice?: number | ComputePriceEstimate;
|
|
24
|
+
computeLimit?: number | ComputeLimitEstimate;
|
|
25
|
+
};
|
|
26
|
+
type KeysNotOfA<T, ToExclude> = Pick<T, Exclude<keyof T, keyof ToExclude>>;
|
|
27
|
+
type ITransactionSolanaExtResolved<T extends ITransactionSolanaExt = ITransactionSolanaExt> = {
|
|
28
|
+
[AK in keyof KeysNotOfA<T, ITransactionSolanaExt>]: T[AK];
|
|
29
|
+
} & ITransactionSolanaExtResolvedValues;
|
|
30
|
+
interface IInteractSolanaExt extends ITransactionSolanaExt {
|
|
31
|
+
invoker: {
|
|
32
|
+
publicKey: string | PublicKey | null;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
interface Account {
|
|
36
|
+
pubkey: PublicKey;
|
|
37
|
+
account: AccountInfo<Buffer>;
|
|
38
|
+
}
|
|
39
|
+
interface CheckAssociatedTokenAccountsData {
|
|
40
|
+
sender: PublicKey;
|
|
41
|
+
recipient: PublicKey;
|
|
42
|
+
partner: PublicKey;
|
|
43
|
+
streamflowTreasury: PublicKey;
|
|
44
|
+
mint: PublicKey;
|
|
45
|
+
}
|
|
46
|
+
interface AtaParams {
|
|
47
|
+
mint: PublicKey;
|
|
48
|
+
owner: PublicKey;
|
|
49
|
+
programId?: PublicKey;
|
|
50
|
+
}
|
|
51
|
+
interface ConfirmationParams {
|
|
52
|
+
hash: BlockhashWithExpiryBlockHeight;
|
|
53
|
+
context: Context;
|
|
54
|
+
commitment?: Commitment;
|
|
55
|
+
}
|
|
56
|
+
interface ThrottleParams {
|
|
57
|
+
sendRate?: number;
|
|
58
|
+
sendThrottler?: PQueue;
|
|
59
|
+
waitBeforeConfirming?: number | undefined;
|
|
60
|
+
}
|
|
61
|
+
interface TransactionExecutionParams extends ThrottleParams {
|
|
62
|
+
skipSimulation?: boolean;
|
|
63
|
+
}
|
|
64
|
+
interface IProgramAccount<T> {
|
|
65
|
+
publicKey: PublicKey;
|
|
66
|
+
account: T;
|
|
67
|
+
}
|
|
68
|
+
declare class TransactionFailedError extends Error {
|
|
69
|
+
constructor(m: string);
|
|
70
|
+
}
|
|
19
71
|
|
|
20
72
|
declare const buildSendThrottler: (sendRate: number, sendInterval?: number) => PQueue;
|
|
21
73
|
/**
|
|
@@ -67,10 +119,10 @@ declare function signTransaction<T extends Transaction | VersionedTransaction>(i
|
|
|
67
119
|
* @param invoker - Keypair used as signer
|
|
68
120
|
* @param tx - Transaction instance
|
|
69
121
|
* @param confirmationParams - Confirmation Params that will be used for execution
|
|
70
|
-
* @param
|
|
122
|
+
* @param transactionExecutionParams - rate or throttler instance to throttle TX sending - to not spam the blockchain too much and solana execution params (eg. skipSimulation)
|
|
71
123
|
* @returns Transaction signature
|
|
72
124
|
*/
|
|
73
|
-
declare function signAndExecuteTransaction(connection: Connection, invoker: Keypair | SignerWalletAdapter, tx: Transaction | VersionedTransaction, confirmationParams: ConfirmationParams,
|
|
125
|
+
declare function signAndExecuteTransaction(connection: Connection, invoker: Keypair | SignerWalletAdapter, tx: Transaction | VersionedTransaction, confirmationParams: ConfirmationParams, transactionExecutionParams: TransactionExecutionParams): Promise<string>;
|
|
74
126
|
/**
|
|
75
127
|
* Sends and confirms Transaction
|
|
76
128
|
* Uses custom confirmation logic that:
|
|
@@ -83,10 +135,10 @@ declare function signAndExecuteTransaction(connection: Connection, invoker: Keyp
|
|
|
83
135
|
* @param connection - Solana client connection
|
|
84
136
|
* @param tx - Transaction instance
|
|
85
137
|
* @param confirmationParams - Confirmation Params that will be used for execution
|
|
86
|
-
* @param
|
|
138
|
+
* @param transactionExecutionParams - rate or throttler instance to throttle TX sending - to not spam the blockchain too much and solana execution params (eg. skipSimulation)
|
|
87
139
|
* @returns Transaction signature
|
|
88
140
|
*/
|
|
89
|
-
declare function executeTransaction(connection: Connection, tx: Transaction | VersionedTransaction, confirmationParams: ConfirmationParams,
|
|
141
|
+
declare function executeTransaction(connection: Connection, tx: Transaction | VersionedTransaction, confirmationParams: ConfirmationParams, transactionExecutionParams: TransactionExecutionParams): Promise<string>;
|
|
90
142
|
/**
|
|
91
143
|
* Launches a PromisePool with all transaction being executed at the same time, allows to throttle all TXs through one Queue
|
|
92
144
|
* @param connection - Solana client connection
|
|
@@ -172,8 +224,8 @@ declare function createAtaBatch(connection: Connection, invoker: Keypair | Signe
|
|
|
172
224
|
declare function checkOrCreateAtaBatch(connection: Connection, owners: PublicKey[], mint: PublicKey, invoker: SignerWalletAdapter | Keypair, programId?: PublicKey): Promise<TransactionInstruction[]>;
|
|
173
225
|
/**
|
|
174
226
|
* Create Base instructions for Solana
|
|
175
|
-
* - sets compute price if `computePrice` is provided
|
|
176
|
-
* - sets compute limit if `computeLimit` is provided
|
|
227
|
+
* - sets compute price if `computePrice` is provided. If `computePrice` is a function, it will be ignored (the value must be resolved before calling this function).
|
|
228
|
+
* - sets compute limit if `computeLimit` is provided. If `computeLimit` is a function, it will be ignored (the value must be resolved before calling this function).
|
|
177
229
|
*/
|
|
178
230
|
declare function prepareBaseInstructions(connection: Connection, { computePrice, computeLimit }: ITransactionSolanaExt): TransactionInstruction[];
|
|
179
231
|
/**
|
|
@@ -201,10 +253,6 @@ declare function getMintAndProgram(connection: Connection, address: PublicKey, c
|
|
|
201
253
|
*/
|
|
202
254
|
declare function getMultipleAccountsInfoBatched(connection: Connection, pubKeys: PublicKey[], commitment?: Commitment): Promise<(AccountInfo<Buffer> | null)[]>;
|
|
203
255
|
|
|
204
|
-
declare function estimateComputeUnitPrice(estimate: ComputePriceEstimate, ixs: Parameters<typeof createVersionedTransaction>[0], payer: Parameters<typeof createVersionedTransaction>[1], recentBlockhash?: Parameters<typeof createVersionedTransaction>[2], partialSigners?: Parameters<typeof createVersionedTransaction>[3]): Promise<number>;
|
|
205
|
-
declare function createAndEstimateTransaction<CreateFn extends (extParams: IInteractSolanaExt) => Promise<TransactionInstruction[]>>(createFn: CreateFn, extParams: IInteractSolanaExt): Promise<Awaited<ReturnType<CreateFn>>>;
|
|
206
|
-
declare function createAndEstimateTransaction<CreateFn extends (extParams: IInteractSolanaExt) => Promise<any>>(createFn: CreateFn, extParams: IInteractSolanaExt, select: (result: Awaited<ReturnType<CreateFn>>) => TransactionInstruction[]): Promise<Awaited<ReturnType<CreateFn>>>;
|
|
207
|
-
|
|
208
256
|
declare function deserializeRawTransaction(serializedTx: string): {
|
|
209
257
|
type: string;
|
|
210
258
|
transaction: Transaction;
|
|
@@ -216,5 +264,34 @@ declare function deserializeRawTransaction(serializedTx: string): {
|
|
|
216
264
|
accounts: PublicKey[];
|
|
217
265
|
writableAccounts: PublicKey[];
|
|
218
266
|
};
|
|
267
|
+
declare const resolveTransactionAccounts: (tx: VersionedTransaction | Transaction) => {
|
|
268
|
+
type: string;
|
|
269
|
+
transaction: Transaction;
|
|
270
|
+
accounts: PublicKey[];
|
|
271
|
+
writableAccounts: PublicKey[];
|
|
272
|
+
} | {
|
|
273
|
+
type: string;
|
|
274
|
+
transaction: VersionedTransaction;
|
|
275
|
+
accounts: PublicKey[];
|
|
276
|
+
writableAccounts: PublicKey[];
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
declare const createTestTransaction: (ixs: Parameters<typeof createVersionedTransaction>[0], payer: Parameters<typeof createVersionedTransaction>[1], recentBlockhash?: Parameters<typeof createVersionedTransaction>[2], partialSigners?: Parameters<typeof createVersionedTransaction>[3]) => _solana_web3_js.VersionedTransaction;
|
|
280
|
+
declare function estimateComputeUnitPrice(estimate: ComputePriceEstimate, testTx: ReturnType<typeof createTestTransaction>): Promise<number>;
|
|
281
|
+
declare function createAndEstimateTransaction<ParamsT extends ITransactionSolanaExtResolved<IInteractSolanaExt>, CreateFn extends (extParams: ParamsT) => Promise<TransactionInstruction[]>>(createFn: CreateFn, extParams: ParamsT): Promise<Awaited<ReturnType<CreateFn>>>;
|
|
282
|
+
declare function createAndEstimateTransaction<ParamsT extends ITransactionSolanaExtResolved<IInteractSolanaExt>, CreateFn extends (extParams: ParamsT) => Promise<any>>(createFn: CreateFn, extParams: ParamsT, select: (result: Awaited<ReturnType<CreateFn>>) => TransactionInstruction[]): Promise<Awaited<ReturnType<CreateFn>>>;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Converts a string or PublicKey to a PublicKey object.
|
|
286
|
+
* @param address - The input address as a string or PublicKey.
|
|
287
|
+
* @returns The PublicKey object.
|
|
288
|
+
*/
|
|
289
|
+
declare const pk: (address: string | PublicKey) => PublicKey;
|
|
290
|
+
|
|
291
|
+
type UnwrapAutoSimulate<T extends IInteractSolanaExt = IInteractSolanaExt> = Omit<T, "computeLimit"> & {
|
|
292
|
+
skipSimulation: boolean;
|
|
293
|
+
computeLimit?: ITransactionSolanaExtResolved["computeLimit"];
|
|
294
|
+
};
|
|
295
|
+
declare const unwrapExecutionParams: <T extends IInteractSolanaExt>({ computeLimit, ...rest }: T, connection: Connection) => UnwrapAutoSimulate<T>;
|
|
219
296
|
|
|
220
|
-
export { Account, AtaParams, ComputePriceEstimate, ConfirmationParams, IInteractSolanaExt, ITransactionSolanaExt, ThrottleParams, ata, ataBatchExist, buildSendThrottler, checkOrCreateAtaBatch, confirmAndEnsureTransaction, createAndEstimateTransaction, createAtaBatch, createVersionedTransaction, deserializeRawTransaction, enrichAtaParams, estimateComputeUnitPrice, executeMultipleTransactions, executeTransaction, generateCreateAtaBatchTx, getFilters, getMintAndProgram, getMultipleAccountsInfoBatched, getProgramAccounts, isSignerKeypair, isSignerWallet, isTransactionVersioned, pk, prepareBaseInstructions, prepareTransaction, prepareWrappedAccount, sendAndConfirmTransaction, signAndExecuteTransaction, signTransaction, simulateTransaction };
|
|
297
|
+
export { type Account, type AtaParams, type CheckAssociatedTokenAccountsData, type ComputeLimitEstimate, type ComputePriceEstimate, type ConfirmationParams, type IInteractSolanaExt, type IProgramAccount, type ITransactionSolanaExt, type ITransactionSolanaExtResolved, type ThrottleParams, type TransactionExecutionParams, TransactionFailedError, ata, ataBatchExist, buildSendThrottler, checkOrCreateAtaBatch, confirmAndEnsureTransaction, createAndEstimateTransaction, createAtaBatch, createVersionedTransaction, deserializeRawTransaction, enrichAtaParams, estimateComputeUnitPrice, executeMultipleTransactions, executeTransaction, generateCreateAtaBatchTx, getFilters, getMintAndProgram, getMultipleAccountsInfoBatched, getProgramAccounts, isSignerKeypair, isSignerWallet, isTransactionVersioned, pk, prepareBaseInstructions, prepareTransaction, prepareWrappedAccount, resolveTransactionAccounts, sendAndConfirmTransaction, signAndExecuteTransaction, signTransaction, simulateTransaction, unwrapExecutionParams };
|
package/dist/esm/solana/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getAssociatedTokenAddress, NATIVE_MINT, createAssociatedTokenAccountInstruction, createSyncNativeInstruction, TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, unpackMint } from '@solana/spl-token';
|
|
2
|
-
import { SystemProgram,
|
|
2
|
+
import { SystemProgram, Keypair, TransactionMessage, VersionedTransaction, SendTransactionError, ComputeBudgetProgram, Transaction, PublicKey } from '@solana/web3.js';
|
|
3
3
|
import bs58 from 'bs58';
|
|
4
4
|
import 'bn.js';
|
|
5
|
-
import { Buffer
|
|
5
|
+
import { Buffer } from 'buffer';
|
|
6
6
|
|
|
7
7
|
var __create = Object.create;
|
|
8
8
|
var __defProp = Object.defineProperty;
|
|
@@ -239,9 +239,6 @@ var prepareWrappedAccount = async (connection, senderAddress, amount) => {
|
|
|
239
239
|
createSyncNativeInstruction(tokenAccount)
|
|
240
240
|
];
|
|
241
241
|
};
|
|
242
|
-
var pk = (address) => {
|
|
243
|
-
return typeof address === "string" ? new PublicKey(address) : address;
|
|
244
|
-
};
|
|
245
242
|
|
|
246
243
|
// solana/types.ts
|
|
247
244
|
var TransactionFailedError = class _TransactionFailedError extends Error {
|
|
@@ -783,16 +780,18 @@ async function signTransaction(invoker, tx) {
|
|
|
783
780
|
}
|
|
784
781
|
return signedTx;
|
|
785
782
|
}
|
|
786
|
-
async function signAndExecuteTransaction(connection, invoker, tx, confirmationParams,
|
|
783
|
+
async function signAndExecuteTransaction(connection, invoker, tx, confirmationParams, transactionExecutionParams) {
|
|
787
784
|
const signedTx = await signTransaction(invoker, tx);
|
|
788
|
-
return executeTransaction(connection, signedTx, confirmationParams,
|
|
785
|
+
return executeTransaction(connection, signedTx, confirmationParams, transactionExecutionParams);
|
|
789
786
|
}
|
|
790
|
-
async function executeTransaction(connection, tx, confirmationParams,
|
|
787
|
+
async function executeTransaction(connection, tx, confirmationParams, transactionExecutionParams) {
|
|
791
788
|
if (tx.signatures.length === 0) {
|
|
792
789
|
throw Error("Error with transaction parameters.");
|
|
793
790
|
}
|
|
794
|
-
|
|
795
|
-
|
|
791
|
+
if (!transactionExecutionParams.skipSimulation) {
|
|
792
|
+
await simulateTransaction(connection, tx);
|
|
793
|
+
}
|
|
794
|
+
return sendAndConfirmTransaction(connection, tx, confirmationParams, transactionExecutionParams);
|
|
796
795
|
}
|
|
797
796
|
async function executeMultipleTransactions(connection, txs, confirmationParams, { sendRate = 1, sendThrottler, ...throttlingParams }) {
|
|
798
797
|
if (!sendThrottler) {
|
|
@@ -989,10 +988,10 @@ async function checkOrCreateAtaBatch(connection, owners, mint, invoker, programI
|
|
|
989
988
|
}
|
|
990
989
|
function prepareBaseInstructions(connection, { computePrice, computeLimit }) {
|
|
991
990
|
const ixs = [];
|
|
992
|
-
if (computePrice && typeof computePrice
|
|
991
|
+
if (computePrice && typeof computePrice !== "function") {
|
|
993
992
|
ixs.push(ComputeBudgetProgram.setComputeUnitPrice({ microLamports: computePrice }));
|
|
994
993
|
}
|
|
995
|
-
if (computeLimit) {
|
|
994
|
+
if (computeLimit && typeof computeLimit === "number") {
|
|
996
995
|
ixs.push(ComputeBudgetProgram.setComputeUnitLimit({ units: computeLimit }));
|
|
997
996
|
}
|
|
998
997
|
return ixs;
|
|
@@ -1018,69 +1017,103 @@ async function getMultipleAccountsInfoBatched(connection, pubKeys, commitment) {
|
|
|
1018
1017
|
const results = await Promise.all(batches);
|
|
1019
1018
|
return results.flat();
|
|
1020
1019
|
}
|
|
1020
|
+
function deserializeRawTransaction(serializedTx) {
|
|
1021
|
+
const txBuffer = Buffer.from(serializedTx, "base64");
|
|
1022
|
+
try {
|
|
1023
|
+
const tx = Transaction.from(txBuffer);
|
|
1024
|
+
return resolveTransactionAccounts(tx);
|
|
1025
|
+
} catch (error) {
|
|
1026
|
+
try {
|
|
1027
|
+
const vtx = VersionedTransaction.deserialize(txBuffer);
|
|
1028
|
+
return resolveTransactionAccounts(vtx);
|
|
1029
|
+
} catch (vError) {
|
|
1030
|
+
throw new Error("Failed to deserialize transaction: " + (vError instanceof Error ? vError.message : vError), {
|
|
1031
|
+
cause: vError
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
var resolveTransactionAccounts = (tx) => {
|
|
1037
|
+
if (tx instanceof Transaction) {
|
|
1038
|
+
const message2 = tx.compileMessage();
|
|
1039
|
+
const accounts2 = message2.accountKeys;
|
|
1040
|
+
const writableAccounts2 = accounts2.filter((_, idx) => message2.isAccountWritable(idx));
|
|
1041
|
+
return {
|
|
1042
|
+
type: "legacy",
|
|
1043
|
+
transaction: tx,
|
|
1044
|
+
accounts: accounts2,
|
|
1045
|
+
writableAccounts: writableAccounts2
|
|
1046
|
+
};
|
|
1047
|
+
}
|
|
1048
|
+
const message = tx.message;
|
|
1049
|
+
const accounts = "staticAccountKeys" in message ? message.staticAccountKeys : message.accountKeys;
|
|
1050
|
+
const writableAccounts = accounts.filter((_, idx) => message.isAccountWritable(idx));
|
|
1051
|
+
return {
|
|
1052
|
+
type: "versioned",
|
|
1053
|
+
transaction: tx,
|
|
1054
|
+
accounts,
|
|
1055
|
+
writableAccounts
|
|
1056
|
+
};
|
|
1057
|
+
};
|
|
1058
|
+
var pk = (address) => {
|
|
1059
|
+
return typeof address === "string" ? new PublicKey(address) : address;
|
|
1060
|
+
};
|
|
1021
1061
|
|
|
1022
1062
|
// solana/lib/estimate.ts
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
partialSigners
|
|
1029
|
-
);
|
|
1030
|
-
return estimate(Buffer.from(tx.serialize()).toString("base64"));
|
|
1063
|
+
var createTestTransaction = (ixs, payer, recentBlockhash, partialSigners) => {
|
|
1064
|
+
return createVersionedTransaction(ixs, payer, "11111111111111111111111111111111", partialSigners);
|
|
1065
|
+
};
|
|
1066
|
+
async function estimateComputeUnitPrice(estimate, testTx) {
|
|
1067
|
+
return estimate(resolveTransactionAccounts(testTx).writableAccounts);
|
|
1031
1068
|
}
|
|
1032
1069
|
async function createAndEstimateTransaction(createFn, extParams, select) {
|
|
1033
1070
|
select = select ?? ((value) => value);
|
|
1034
1071
|
const createResult = await createFn(extParams);
|
|
1035
1072
|
const prepareIxs = select(createResult);
|
|
1036
|
-
const
|
|
1037
|
-
if (priorityFee === void 0 || typeof priorityFee === "number") {
|
|
1038
|
-
return createResult;
|
|
1039
|
-
}
|
|
1073
|
+
const { computePrice, computeLimit } = extParams;
|
|
1040
1074
|
const invoker = extParams.invoker.publicKey;
|
|
1041
1075
|
invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
1042
|
-
const
|
|
1076
|
+
const testTx = createTestTransaction(prepareIxs, pk(invoker), void 0, void 0);
|
|
1077
|
+
const estimatedComputeLimit = typeof computeLimit === "function" ? await computeLimit(testTx) : computeLimit;
|
|
1078
|
+
if (typeof computePrice !== "function") {
|
|
1079
|
+
if (typeof computeLimit !== "function") {
|
|
1080
|
+
return createResult;
|
|
1081
|
+
}
|
|
1082
|
+
return createFn({
|
|
1083
|
+
...extParams,
|
|
1084
|
+
computeLimit: estimatedComputeLimit
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
const estimatedComputeUnitPrice = typeof computePrice === "function" ? await estimateComputeUnitPrice(computePrice, testTx) : (
|
|
1043
1088
|
// unachievable because we don't execute estimation for constant or undefined priority fee
|
|
1044
|
-
|
|
1089
|
+
computePrice
|
|
1045
1090
|
);
|
|
1046
1091
|
return createFn({
|
|
1047
1092
|
...extParams,
|
|
1048
|
-
computePrice: estimatedComputeUnitPrice
|
|
1093
|
+
computePrice: estimatedComputeUnitPrice,
|
|
1094
|
+
computeLimit: estimatedComputeLimit
|
|
1049
1095
|
});
|
|
1050
1096
|
}
|
|
1051
|
-
function deserializeRawTransaction(serializedTx) {
|
|
1052
|
-
const txBuffer = Buffer$1.from(serializedTx, "base64");
|
|
1053
|
-
try {
|
|
1054
|
-
const tx = Transaction.from(txBuffer);
|
|
1055
|
-
const message = tx.compileMessage();
|
|
1056
|
-
const accounts = message.accountKeys;
|
|
1057
|
-
const writableAccounts = accounts.filter((_, idx) => message.isAccountWritable(idx));
|
|
1058
|
-
return {
|
|
1059
|
-
type: "legacy",
|
|
1060
|
-
transaction: tx,
|
|
1061
|
-
accounts,
|
|
1062
|
-
writableAccounts
|
|
1063
|
-
};
|
|
1064
|
-
} catch (error) {
|
|
1065
|
-
try {
|
|
1066
|
-
const vtx = VersionedTransaction.deserialize(txBuffer);
|
|
1067
|
-
const message = vtx.message;
|
|
1068
|
-
const accounts = "staticAccountKeys" in message ? message.staticAccountKeys : message.accountKeys;
|
|
1069
|
-
const writableAccounts = accounts.filter((_, idx) => message.isAccountWritable(idx));
|
|
1070
|
-
return {
|
|
1071
|
-
type: "versioned",
|
|
1072
|
-
transaction: vtx,
|
|
1073
|
-
accounts,
|
|
1074
|
-
writableAccounts
|
|
1075
|
-
};
|
|
1076
|
-
} catch (vError) {
|
|
1077
|
-
throw new Error("Failed to deserialize transaction: " + (vError instanceof Error ? vError.message : vError), {
|
|
1078
|
-
cause: vError
|
|
1079
|
-
});
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
1097
|
|
|
1084
|
-
|
|
1098
|
+
// solana/rpc/consume-limit-estimate/estimate.ts
|
|
1099
|
+
var estimateConsumeLimit = async (connection, tx, options = {}) => {
|
|
1100
|
+
const { multiplierPercent = 0.05 } = options;
|
|
1101
|
+
const simulationResults = await connection.simulateTransaction(tx, {
|
|
1102
|
+
sigVerify: false,
|
|
1103
|
+
replaceRecentBlockhash: true
|
|
1104
|
+
});
|
|
1105
|
+
return {
|
|
1106
|
+
unitsConsumed: simulationResults.value.unitsConsumed ? Math.ceil(simulationResults.value.unitsConsumed * (1 + multiplierPercent)) : simulationResults.value.unitsConsumed,
|
|
1107
|
+
data: simulationResults
|
|
1108
|
+
};
|
|
1109
|
+
};
|
|
1110
|
+
|
|
1111
|
+
// solana/lib/unwrap-auto-simulate-ext.ts
|
|
1112
|
+
var unwrapExecutionParams = ({ computeLimit, ...rest }, connection) => {
|
|
1113
|
+
const consumeLimitFn = computeLimit === "autoSimulate" ? (tx) => estimateConsumeLimit(connection, tx).then((limit) => limit.unitsConsumed ?? 0) : computeLimit;
|
|
1114
|
+
return { ...rest, computeLimit: consumeLimitFn, skipSimulation: computeLimit === "autoSimulate" };
|
|
1115
|
+
};
|
|
1116
|
+
|
|
1117
|
+
export { TransactionFailedError, ata, ataBatchExist, buildSendThrottler, checkOrCreateAtaBatch, confirmAndEnsureTransaction, createAndEstimateTransaction, createAtaBatch, createVersionedTransaction, deserializeRawTransaction, enrichAtaParams, estimateComputeUnitPrice, executeMultipleTransactions, executeTransaction, generateCreateAtaBatchTx, getFilters, getMintAndProgram, getMultipleAccountsInfoBatched, getProgramAccounts, isSignerKeypair, isSignerWallet, isTransactionVersioned, pk, prepareBaseInstructions, prepareTransaction, prepareWrappedAccount, resolveTransactionAccounts, sendAndConfirmTransaction, signAndExecuteTransaction, signTransaction, simulateTransaction, unwrapExecutionParams };
|
|
1085
1118
|
//# sourceMappingURL=index.js.map
|
|
1086
1119
|
//# sourceMappingURL=index.js.map
|