@streamflow/common 12.1.1 → 12.2.1-alpha.p361.abedd84
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 +4 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/solana/index.cjs +4 -3
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +4 -6
- package/dist/cjs/solana/rpc/index.cjs.map +1 -1
- package/dist/esm/index.js +4 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +4 -6
- package/dist/esm/solana/index.js +4 -3
- package/dist/esm/solana/index.js.map +1 -1
- package/dist/esm/solana/rpc/index.js.map +1 -1
- package/package.json +10 -5
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _solana_web3_js from '@solana/web3.js';
|
|
2
|
-
import { PublicKey, MemcmpFilter, Connection, TransactionInstruction,
|
|
2
|
+
import { PublicKey, MemcmpFilter, Connection, TransactionInstruction, AccountInfo, VersionedTransaction, BlockhashWithExpiryBlockHeight, Context, Commitment, SignatureStatus, Keypair, AddressLookupTableAccount, Transaction, RpcResponseAndContext, SimulatedTransactionResponse } from '@solana/web3.js';
|
|
3
3
|
import BN from 'bn.js';
|
|
4
4
|
import PQueue from 'p-queue';
|
|
5
|
-
import { Idl, Program,
|
|
5
|
+
import { Idl, Program, IdlAccounts, IdlTypes } from '@coral-xyz/anchor';
|
|
6
6
|
import { Mint } from '@solana/spl-token';
|
|
7
7
|
import { SignerWalletAdapter } from '@solana/wallet-adapter-base';
|
|
8
8
|
|
|
@@ -1178,12 +1178,10 @@ declare function executeTransaction(connection: Connection, tx: Transaction | Ve
|
|
|
1178
1178
|
* @param connection - Solana client connection
|
|
1179
1179
|
* @param txs - Transactions
|
|
1180
1180
|
* @param confirmationParams - Confirmation Params that will be used for execution
|
|
1181
|
-
* @param
|
|
1182
|
-
* @param throttleParams.sendRate - rate
|
|
1183
|
-
* @param throttleParams.sendThrottler - throttler instance
|
|
1181
|
+
* @param params - execution params: sendRate, sendThrottler, skipSimulation
|
|
1184
1182
|
* @returns Raw Promise Results - should be handled by the consumer and unwrapped accordingly
|
|
1185
1183
|
*/
|
|
1186
|
-
declare function executeMultipleTransactions(connection: Connection, txs: (Transaction | VersionedTransaction)[], confirmationParams: ConfirmationParams, { sendRate, sendThrottler, ...throttlingParams }:
|
|
1184
|
+
declare function executeMultipleTransactions(connection: Connection, txs: (Transaction | VersionedTransaction)[], confirmationParams: ConfirmationParams, { sendRate, sendThrottler, skipSimulation, ...throttlingParams }: TransactionExecutionParams): Promise<PromiseSettledResult<string>[]>;
|
|
1187
1185
|
/**
|
|
1188
1186
|
* Sends and confirm transaction in a loop, constantly re-broadcsting the tx until Blockheight expires.
|
|
1189
1187
|
* - we add additional 30 bocks to account for validators in an PRC pool divergence
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../solana/rpc/consume-limit-estimate/estimate.ts","../../../../solana/rpc/priority-fee-estimate/percentile.ts","../../../../solana/lib/deserialize-raw-transaction.ts","../../../../solana/rpc/priority-fee-estimate/calc-fee.ts","../../../../solana/rpc/priority-fee-estimate/general.ts","../../../../solana/lib/public-key.ts"],"names":["Buffer","Transaction","VersionedTransaction","message","accounts","writableAccounts","getPriorityFeeEstimate","getRecentPrioritizationFee","PublicKey","buildArgs"],"mappings":";;;;;;;;;;;;AAWO,IAAM,uBAAuB,OAClC,UAAA,EACA,EACA,EAAA,OAAA,GAA0C,EACvC,KAAA;AACH,EAAM,MAAA,EAAE,cAAiB,GAAA,IAAA,EAAS,GAAA,OAAA;AAClC,EAAA,MAAM,iBAAoB,GAAA,MAAM,UAAW,CAAA,mBAAA,CAAoB,EAAI,EAAA;AAAA,IACjE,SAAW,EAAA,KAAA;AAAA,IACX,sBAAwB,EAAA;AAAA,GACzB,CAAA;AACD,EAAO,OAAA;AAAA,IACL,aAAe,EAAA,iBAAA,CAAkB,KAAM,CAA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EAAA,OAAO,OAAO,OAAY,KAAA,QAAA,GAAW,IAAIC,iBAAA,CAAU,OAAO,CAAI,GAAA,OAAA;AAChE,CAAA;;;ADKO,IAAMF,uBAAAA,GAAyB,OAAO,UAAA,EAAwB,OAA2C,KAAA;AAC9G,EAAA,MAAM,uBAA0B,GAAA,MAAMC,2BAA2B,CAAA,UAAA,EAAY,OAAO,CAAA;AACpF,EAAM,MAAA,MAAA,GAAS,cAAc,uBAAwB,CAAA,GAAA,CAAI,CAAC,CAAM,KAAA,CAAA,CAAE,iBAAiB,CAAC,CAAA;AACpF,EAAO,OAAA,EAAE,MAAQ,EAAA,IAAA,CAAK,IAAK,CAAA,MAAA,IAAU,CAAK,IAAA,OAAA,CAAQ,cAAkB,IAAA,IAAA,CAAA,CAAM,CAAG,EAAA,IAAA,EAAM,uBAAwB,EAAA;AAC7G,CAAA;AASO,IAAMA,2BAAAA,GAA6B,OACxC,UAAA,EACA,OACG,KAAA;AACH,EAAO,OAAA,UAAA,CAAW,2BAA4B,CAAA,EAAE,sBAAwBE,EAAAA,UAAAA,CAAU,QAAQ,YAAY,CAAA,CAAE,CAAC,CAAA,EAAG,CAAA;AAC9G,CAAA;AAEA,IAAMA,UAAAA,GAAY,CAAC,YAAkD,KAAA;AACnE,EAAM,MAAA,aAAA,GACJ,wBAAwB,KAAQ,GAAA,YAAA,CAAa,IAAI,EAAE,CAAA,GAAI,yBAA0B,CAAA,YAAY,CAAE,CAAA,gBAAA;AACjG,EAAA,OAAO,CAAC,aAAa,CAAA;AACvB,CAAA","file":"index.cjs","sourcesContent":["import type { VersionedTransaction, Connection } from \"@solana/web3.js\";\n\nimport type { GetConsumeLimitEstimateOptions } from \"../types.js\";\n\n/**\n * Estimate the consume limit of a transaction based on the simulation results of the transaction.\n * @param connection - The connection to the RPC\n * @param tx - The transaction to estimate the consume limit for\n * @param options - The options for the estimate\n * @returns The consume limit estimate multiplied by a multiplier percent or undefined and the native simulation results\n */\nexport const estimateConsumeLimit = async (\n connection: Connection,\n tx: VersionedTransaction,\n options: GetConsumeLimitEstimateOptions = {},\n) => {\n const { increaseFactor = 0.05 } = options;\n const simulationResults = await connection.simulateTransaction(tx, {\n sigVerify: false,\n replaceRecentBlockhash: true,\n });\n return {\n unitsConsumed: simulationResults.value.unitsConsumed\n ? Math.ceil(simulationResults.value.unitsConsumed * (1 + increaseFactor))\n : simulationResults.value.unitsConsumed,\n data: simulationResults,\n };\n};\n","import type { Connection, PublicKey } from \"@solana/web3.js\";\n\nimport { deserializeRawTransaction } from \"../../lib/deserialize-raw-transaction.js\";\nimport type { GetPriorityFeeEstimateOptions } from \"../types.js\";\nimport { resolveMedian } from \"./calc-fee.js\";\n\ntype RpcRequest = (methodName: string, args: Array<any> | ReadonlyArray<any>) => Promise<any>;\n\n/**\n * @category GetPriorityFeeEstimateOptions\n * @interface RecentPrioritizationFee\n * @property result - The result of the recent prioritization fees.\n * @property result.prioritizationFee - The prioritization fee.\n * @property result.slot - The slot of the prioritization fee.\n */\ninterface RecentPrioritizationFee {\n result: Array<{ prioritizationFee: number; slot: number }>;\n}\n\n/**\n * Fetch the recent prioritization fees from the RPC [getRecentPrioritizationFees]\n * @param connection - The connection to the RPC\n * @param options - The options for the RPC\n * @returns The priority fee estimate\n */\nexport const getPriorityFeeEstimate = async (connection: Connection, options: GetPriorityFeeEstimateOptions) => {\n const recentPrioritizationFee = await getRecentPrioritizationFee(connection, options);\n const median = resolveMedian(recentPrioritizationFee.result.map((r) => r.prioritizationFee));\n return { median: Math.ceil(median * (1 + (options.increaseFactor ?? 0.05))), data: recentPrioritizationFee };\n};\n\n/**\n * If an RPC of use supports percentile value, aka {@link https://docs.triton.one/chains/solana/improved-priority-fees-api}\n * @param connection - The connection to the RPC\n * @param options - The options for the RPC\n * @returns The priority fee estimate\n */\nexport const getRecentPrioritizationFee = async (\n connection: Connection,\n options: Pick<GetPriorityFeeEstimateOptions, \"accountsOrTx\" | \"percentile\">,\n): Promise<RecentPrioritizationFee> => {\n const { accountsOrTx, percentile = 5000 } = options;\n\n return (connection as unknown as { _rpcRequest: RpcRequest })._rpcRequest(\n \"getRecentPrioritizationFees\",\n buildArgs(accountsOrTx, percentile),\n ) as Promise<RecentPrioritizationFee>;\n};\n\nconst buildArgs = (accountsOrTx: (string | PublicKey)[] | string, percentile: number) => {\n const accountsArray =\n accountsOrTx instanceof Array\n ? accountsOrTx.map((a) => a.toString())\n : deserializeRawTransaction(accountsOrTx).writableAccounts.map((a) => a.toString());\n return [\n accountsArray,\n {\n percentile,\n },\n ] as const;\n};\n","import { Transaction, VersionedTransaction, type PublicKey } from \"@solana/web3.js\";\nimport { Buffer } from \"buffer\";\n\ninterface TransactionAccountsProvider {\n accountKeys: PublicKey[];\n}\n\nexport function deserializeRawTransaction(serializedTx: string) {\n const txBuffer = Buffer.from(serializedTx, \"base64\");\n try {\n const tx = Transaction.from(txBuffer);\n return resolveTransactionAccounts(tx);\n } catch (error) {\n try {\n const vtx = VersionedTransaction.deserialize(txBuffer);\n return resolveTransactionAccounts(vtx);\n } catch (vError) {\n throw new Error(\"Failed to deserialize transaction: \" + (vError instanceof Error ? vError.message : vError), {\n cause: vError,\n });\n }\n }\n}\n\nexport const resolveTransactionAccounts = (tx: VersionedTransaction | Transaction) => {\n if (tx instanceof Transaction) {\n const message = tx.compileMessage();\n const accounts = message.accountKeys;\n const writableAccounts = accounts.filter((_, idx) => message.isAccountWritable(idx));\n return {\n type: \"legacy\",\n transaction: tx,\n accounts,\n writableAccounts,\n };\n }\n\n const message = tx.message;\n const accounts =\n \"staticAccountKeys\" in message\n ? message.staticAccountKeys\n : (message as unknown as TransactionAccountsProvider).accountKeys;\n\n const writableAccounts = accounts.filter((_, idx) => message.isAccountWritable(idx));\n return {\n type: \"versioned\",\n transaction: tx,\n accounts,\n writableAccounts,\n };\n};\n","export const resolveMedian = (values: number[]) => {\n if (values.length < 2) {\n return 0;\n }\n\n const sortedRates = [...values].sort((a, b) => a - b);\n const medianIndex = Math.floor(sortedRates.length / 2);\n const medianArrValue = sortedRates[medianIndex];\n const medianPrevValue = sortedRates[medianIndex - 1];\n\n if (medianPrevValue === undefined || medianArrValue === undefined) {\n return 0;\n }\n\n const medianValue = sortedRates.length % 2 === 0 ? (medianPrevValue + medianArrValue) / 2 : medianArrValue;\n\n return medianValue;\n};\n","import type { Connection, PublicKey } from \"@solana/web3.js\";\n\nimport { deserializeRawTransaction } from \"../../lib/deserialize-raw-transaction.js\";\nimport type { GetPriorityFeeEstimateOptions } from \"../types.js\";\nimport { resolveMedian } from \"./calc-fee.js\";\nimport { pk } from \"../../lib/public-key.js\";\n\n/**\n * Fetch the recent prioritization fees from the RPC [getRecentPrioritizationFees] (https://solana.com/docs/rpc/http/getrecentprioritizationfees)\n * @deprecated Not recommended for use because it provides a single number per slot to indicate the minimum priority fee amount.\n * @param connection - The connection to the RPC\n * @param options - The options for the RPC\n * @returns The priority fee estimate\n */\nexport const getPriorityFeeEstimate = async (connection: Connection, options: GetPriorityFeeEstimateOptions) => {\n const recentPrioritizationFee = await getRecentPrioritizationFee(connection, options);\n const median = resolveMedian(recentPrioritizationFee.map((r) => r.prioritizationFee));\n return { median: Math.ceil(median * (1 + (options.increaseFactor ?? 0.05))), data: recentPrioritizationFee };\n};\n\n/**\n * Fetch the recent prioritization fees from the RPC [getRecentPrioritizationFees] (https://solana.com/docs/rpc/http/getrecentprioritizationfees)\n * @deprecated Not recommended for use because it provides a single number per slot to indicate the minimum priority fee amount.\n * @param connection - The connection to the RPC\n * @param options - The options for the RPC\n * @returns The priority fee estimate\n */\nexport const getRecentPrioritizationFee = async (\n connection: Connection,\n options: Pick<GetPriorityFeeEstimateOptions, \"accountsOrTx\">,\n) => {\n return connection.getRecentPrioritizationFees({ lockedWritableAccounts: buildArgs(options.accountsOrTx)[0] });\n};\n\nconst buildArgs = (accountsOrTx: (string | PublicKey)[] | string) => {\n const accountsArray =\n accountsOrTx instanceof Array ? accountsOrTx.map(pk) : deserializeRawTransaction(accountsOrTx).writableAccounts;\n return [accountsArray] as const;\n};\n","import { PublicKey } from \"@solana/web3.js\";\n\n/**\n * Converts a string or PublicKey to a PublicKey object.\n * @param address - The input address as a string or PublicKey.\n * @returns The PublicKey object.\n */\nexport const pk = (address: string | PublicKey): PublicKey => {\n return typeof address === \"string\" ? new PublicKey(address) : address;\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../../solana/rpc/consume-limit-estimate/estimate.ts","../../../../solana/rpc/priority-fee-estimate/percentile.ts","../../../../solana/lib/deserialize-raw-transaction.ts","../../../../solana/rpc/priority-fee-estimate/calc-fee.ts","../../../../solana/rpc/priority-fee-estimate/general.ts","../../../../solana/lib/public-key.ts"],"names":["Buffer","Transaction","VersionedTransaction","message","accounts","writableAccounts","getPriorityFeeEstimate","getRecentPrioritizationFee","PublicKey","buildArgs"],"mappings":";;;;;;;;;;;;AAWO,IAAM,uBAAuB,OAClC,UAAA,EACA,EAAA,EACA,OAAA,GAA0C,EAAC,KACxC;AACH,EAAA,MAAM,EAAE,cAAA,GAAiB,IAAA,EAAK,GAAI,OAAA;AAClC,EAAA,MAAM,iBAAA,GAAoB,MAAM,UAAA,CAAW,mBAAA,CAAoB,EAAA,EAAI;AAAA,IACjE,SAAA,EAAW,KAAA;AAAA,IACX,sBAAA,EAAwB;AAAA,GACzB,CAAA;AACD,EAAA,OAAO;AAAA,IACL,aAAA,EAAe,iBAAA,CAAkB,KAAA,CAAM,aAAA,GACnC,IAAA,CAAK,IAAA,CAAK,iBAAA,CAAkB,KAAA,CAAM,aAAA,IAAiB,CAAA,GAAI,cAAA,CAAe,CAAA,GACtE,kBAAkB,KAAA,CAAM,aAAA;AAAA,IAC5B,IAAA,EAAM;AAAA,GACR;AACF;;;AC3BA,IAAA,kBAAA,GAAA;AAAA,QAAA,CAAA,kBAAA,EAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,0BAAA,EAAA,MAAA;AAAA,CAAA,CAAA;ACOO,SAAS,0BAA0B,YAAA,EAAsB;AAC9D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,CAAA;AACpF,EAAA,OAAO,EAAE,MAAA,EAAQ,IAAA,CAAK,IAAA,CAAK,MAAA,IAAU,CAAA,IAAK,OAAA,CAAQ,cAAA,IAAkB,IAAA,CAAA,CAAM,CAAA,EAAG,IAAA,EAAM,uBAAA,EAAwB;AAC7G,CAAA;AASO,IAAMA,2BAAAA,GAA6B,OACxC,UAAA,EACA,OAAA,KACG;AACH,EAAA,OAAO,UAAA,CAAW,2BAAA,CAA4B,EAAE,sBAAA,EAAwBE,UAAAA,CAAU,QAAQ,YAAY,CAAA,CAAE,CAAC,CAAA,EAAG,CAAA;AAC9G,CAAA;AAEA,IAAMA,UAAAA,GAAY,CAAC,YAAA,KAAkD;AACnE,EAAA,MAAM,aAAA,GACJ,wBAAwB,KAAA,GAAQ,YAAA,CAAa,IAAI,EAAE,CAAA,GAAI,yBAAA,CAA0B,YAAY,CAAA,CAAE,gBAAA;AACjG,EAAA,OAAO,CAAC,aAAa,CAAA;AACvB,CAAA","file":"index.cjs","sourcesContent":["import type { VersionedTransaction, Connection } from \"@solana/web3.js\";\n\nimport type { GetConsumeLimitEstimateOptions } from \"../types.js\";\n\n/**\n * Estimate the consume limit of a transaction based on the simulation results of the transaction.\n * @param connection - The connection to the RPC\n * @param tx - The transaction to estimate the consume limit for\n * @param options - The options for the estimate\n * @returns The consume limit estimate multiplied by a multiplier percent or undefined and the native simulation results\n */\nexport const estimateConsumeLimit = async (\n connection: Connection,\n tx: VersionedTransaction,\n options: GetConsumeLimitEstimateOptions = {},\n) => {\n const { increaseFactor = 0.05 } = options;\n const simulationResults = await connection.simulateTransaction(tx, {\n sigVerify: false,\n replaceRecentBlockhash: true,\n });\n return {\n unitsConsumed: simulationResults.value.unitsConsumed\n ? Math.ceil(simulationResults.value.unitsConsumed * (1 + increaseFactor))\n : simulationResults.value.unitsConsumed,\n data: simulationResults,\n };\n};\n","import type { Connection, PublicKey } from \"@solana/web3.js\";\n\nimport { deserializeRawTransaction } from \"../../lib/deserialize-raw-transaction.js\";\nimport type { GetPriorityFeeEstimateOptions } from \"../types.js\";\nimport { resolveMedian } from \"./calc-fee.js\";\n\ntype RpcRequest = (methodName: string, args: Array<any> | ReadonlyArray<any>) => Promise<any>;\n\n/**\n * @category GetPriorityFeeEstimateOptions\n * @interface RecentPrioritizationFee\n * @property result - The result of the recent prioritization fees.\n * @property result.prioritizationFee - The prioritization fee.\n * @property result.slot - The slot of the prioritization fee.\n */\ninterface RecentPrioritizationFee {\n result: Array<{ prioritizationFee: number; slot: number }>;\n}\n\n/**\n * Fetch the recent prioritization fees from the RPC [getRecentPrioritizationFees]\n * @param connection - The connection to the RPC\n * @param options - The options for the RPC\n * @returns The priority fee estimate\n */\nexport const getPriorityFeeEstimate = async (connection: Connection, options: GetPriorityFeeEstimateOptions) => {\n const recentPrioritizationFee = await getRecentPrioritizationFee(connection, options);\n const median = resolveMedian(recentPrioritizationFee.result.map((r) => r.prioritizationFee));\n return { median: Math.ceil(median * (1 + (options.increaseFactor ?? 0.05))), data: recentPrioritizationFee };\n};\n\n/**\n * If an RPC of use supports percentile value, aka {@link https://docs.triton.one/chains/solana/improved-priority-fees-api}\n * @param connection - The connection to the RPC\n * @param options - The options for the RPC\n * @returns The priority fee estimate\n */\nexport const getRecentPrioritizationFee = async (\n connection: Connection,\n options: Pick<GetPriorityFeeEstimateOptions, \"accountsOrTx\" | \"percentile\">,\n): Promise<RecentPrioritizationFee> => {\n const { accountsOrTx, percentile = 5000 } = options;\n\n return (connection as unknown as { _rpcRequest: RpcRequest })._rpcRequest(\n \"getRecentPrioritizationFees\",\n buildArgs(accountsOrTx, percentile),\n ) as Promise<RecentPrioritizationFee>;\n};\n\nconst buildArgs = (accountsOrTx: (string | PublicKey)[] | string, percentile: number) => {\n const accountsArray =\n accountsOrTx instanceof Array\n ? accountsOrTx.map((a) => a.toString())\n : deserializeRawTransaction(accountsOrTx).writableAccounts.map((a) => a.toString());\n return [\n accountsArray,\n {\n percentile,\n },\n ] as const;\n};\n","import { Transaction, VersionedTransaction, type PublicKey } from \"@solana/web3.js\";\nimport { Buffer } from \"buffer\";\n\ninterface TransactionAccountsProvider {\n accountKeys: PublicKey[];\n}\n\nexport function deserializeRawTransaction(serializedTx: string) {\n const txBuffer = Buffer.from(serializedTx, \"base64\");\n try {\n const tx = Transaction.from(txBuffer);\n return resolveTransactionAccounts(tx);\n } catch (error) {\n try {\n const vtx = VersionedTransaction.deserialize(txBuffer);\n return resolveTransactionAccounts(vtx);\n } catch (vError) {\n throw new Error(\"Failed to deserialize transaction: \" + (vError instanceof Error ? vError.message : vError), {\n cause: vError,\n });\n }\n }\n}\n\nexport const resolveTransactionAccounts = (tx: VersionedTransaction | Transaction) => {\n if (tx instanceof Transaction) {\n const message = tx.compileMessage();\n const accounts = message.accountKeys;\n const writableAccounts = accounts.filter((_, idx) => message.isAccountWritable(idx));\n return {\n type: \"legacy\",\n transaction: tx,\n accounts,\n writableAccounts,\n };\n }\n\n const message = tx.message;\n const accounts =\n \"staticAccountKeys\" in message\n ? message.staticAccountKeys\n : (message as unknown as TransactionAccountsProvider).accountKeys;\n\n const writableAccounts = accounts.filter((_, idx) => message.isAccountWritable(idx));\n return {\n type: \"versioned\",\n transaction: tx,\n accounts,\n writableAccounts,\n };\n};\n","export const resolveMedian = (values: number[]) => {\n if (values.length < 2) {\n return 0;\n }\n\n const sortedRates = [...values].sort((a, b) => a - b);\n const medianIndex = Math.floor(sortedRates.length / 2);\n const medianArrValue = sortedRates[medianIndex];\n const medianPrevValue = sortedRates[medianIndex - 1];\n\n if (medianPrevValue === undefined || medianArrValue === undefined) {\n return 0;\n }\n\n const medianValue = sortedRates.length % 2 === 0 ? (medianPrevValue + medianArrValue) / 2 : medianArrValue;\n\n return medianValue;\n};\n","import type { Connection, PublicKey } from \"@solana/web3.js\";\n\nimport { deserializeRawTransaction } from \"../../lib/deserialize-raw-transaction.js\";\nimport type { GetPriorityFeeEstimateOptions } from \"../types.js\";\nimport { resolveMedian } from \"./calc-fee.js\";\nimport { pk } from \"../../lib/public-key.js\";\n\n/**\n * Fetch the recent prioritization fees from the RPC [getRecentPrioritizationFees] (https://solana.com/docs/rpc/http/getrecentprioritizationfees)\n * @deprecated Not recommended for use because it provides a single number per slot to indicate the minimum priority fee amount.\n * @param connection - The connection to the RPC\n * @param options - The options for the RPC\n * @returns The priority fee estimate\n */\nexport const getPriorityFeeEstimate = async (connection: Connection, options: GetPriorityFeeEstimateOptions) => {\n const recentPrioritizationFee = await getRecentPrioritizationFee(connection, options);\n const median = resolveMedian(recentPrioritizationFee.map((r) => r.prioritizationFee));\n return { median: Math.ceil(median * (1 + (options.increaseFactor ?? 0.05))), data: recentPrioritizationFee };\n};\n\n/**\n * Fetch the recent prioritization fees from the RPC [getRecentPrioritizationFees] (https://solana.com/docs/rpc/http/getrecentprioritizationfees)\n * @deprecated Not recommended for use because it provides a single number per slot to indicate the minimum priority fee amount.\n * @param connection - The connection to the RPC\n * @param options - The options for the RPC\n * @returns The priority fee estimate\n */\nexport const getRecentPrioritizationFee = async (\n connection: Connection,\n options: Pick<GetPriorityFeeEstimateOptions, \"accountsOrTx\">,\n) => {\n return connection.getRecentPrioritizationFees({ lockedWritableAccounts: buildArgs(options.accountsOrTx)[0] });\n};\n\nconst buildArgs = (accountsOrTx: (string | PublicKey)[] | string) => {\n const accountsArray =\n accountsOrTx instanceof Array ? accountsOrTx.map(pk) : deserializeRawTransaction(accountsOrTx).writableAccounts;\n return [accountsArray] as const;\n};\n","import { PublicKey } from \"@solana/web3.js\";\n\n/**\n * Converts a string or PublicKey to a PublicKey object.\n * @param address - The input address as a string or PublicKey.\n * @returns The PublicKey object.\n */\nexport const pk = (address: string | PublicKey): PublicKey => {\n return typeof address === \"string\" ? new PublicKey(address) : address;\n};\n"]}
|
package/dist/esm/index.js
CHANGED
|
@@ -51,7 +51,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
51
51
|
|
|
52
52
|
// ../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.js
|
|
53
53
|
var require_eventemitter3 = __commonJS({
|
|
54
|
-
"../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.js"(exports, module) {
|
|
54
|
+
"../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.js"(exports$1, module) {
|
|
55
55
|
var has = Object.prototype.hasOwnProperty;
|
|
56
56
|
var prefix2 = "~";
|
|
57
57
|
function Events() {
|
|
@@ -1830,7 +1830,7 @@ async function executeTransaction(connection, tx, confirmationParams, transactio
|
|
|
1830
1830
|
}
|
|
1831
1831
|
return sendAndConfirmTransaction(connection, tx, confirmationParams, transactionExecutionParams);
|
|
1832
1832
|
}
|
|
1833
|
-
async function executeMultipleTransactions(connection, txs, confirmationParams, { sendRate = 1, sendThrottler, ...throttlingParams }) {
|
|
1833
|
+
async function executeMultipleTransactions(connection, txs, confirmationParams, { sendRate = 1, sendThrottler, skipSimulation, ...throttlingParams }) {
|
|
1834
1834
|
if (!sendThrottler) {
|
|
1835
1835
|
sendThrottler = buildSendThrottler(sendRate);
|
|
1836
1836
|
}
|
|
@@ -1839,7 +1839,8 @@ async function executeMultipleTransactions(connection, txs, confirmationParams,
|
|
|
1839
1839
|
(tx) => executeTransaction(connection, tx, confirmationParams, {
|
|
1840
1840
|
...throttlingParams,
|
|
1841
1841
|
sendRate,
|
|
1842
|
-
sendThrottler
|
|
1842
|
+
sendThrottler,
|
|
1843
|
+
skipSimulation
|
|
1843
1844
|
})
|
|
1844
1845
|
)
|
|
1845
1846
|
);
|