@streamflow/common 8.0.1-alpha.p287.54fe41f → 8.0.2-alpha.p287.a3616ff

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.
@@ -20,10 +20,10 @@ interface GetPriorityFeeEstimateOptions {
20
20
  percentile?: number;
21
21
  /**
22
22
  * The multiplier to apply to the priority fee estimate.
23
- * The result is multiplied by 1 + multiplierPercent.
23
+ * The result is multiplied by 1 + increaseFactor.
24
24
  * @default 0.05 = 5%
25
25
  */
26
- multiplierPercent?: number;
26
+ increaseFactor?: number;
27
27
  }
28
28
  /**
29
29
  * @interface GetConsumeLimitEstimateOptions - The options for the consume limit estimate
@@ -31,10 +31,10 @@ interface GetPriorityFeeEstimateOptions {
31
31
  interface GetConsumeLimitEstimateOptions {
32
32
  /**
33
33
  * The multiplier to apply to the consume limit estimate.
34
- * The result is multiplied by 1 + multiplierPercent.
34
+ * The result is multiplied by 1 + increaseFactor.
35
35
  * @default 0.05 = 5%
36
36
  */
37
- multiplierPercent?: number;
37
+ increaseFactor?: number;
38
38
  }
39
39
 
40
40
  /**
@@ -9,13 +9,13 @@ var __export = (target, all) => {
9
9
 
10
10
  // solana/rpc/consume-limit-estimate/estimate.ts
11
11
  var estimateConsumeLimit = async (connection, tx, options = {}) => {
12
- const { multiplierPercent = 0.05 } = options;
12
+ const { increaseFactor = 0.05 } = options;
13
13
  const simulationResults = await connection.simulateTransaction(tx, {
14
14
  sigVerify: false,
15
15
  replaceRecentBlockhash: true
16
16
  });
17
17
  return {
18
- unitsConsumed: simulationResults.value.unitsConsumed ? Math.ceil(simulationResults.value.unitsConsumed * (1 + multiplierPercent)) : simulationResults.value.unitsConsumed,
18
+ unitsConsumed: simulationResults.value.unitsConsumed ? Math.ceil(simulationResults.value.unitsConsumed * (1 + increaseFactor)) : simulationResults.value.unitsConsumed,
19
19
  data: simulationResults
20
20
  };
21
21
  };
@@ -85,7 +85,7 @@ var resolveMedian = (values) => {
85
85
  var getPriorityFeeEstimate = async (connection, options) => {
86
86
  const recentPrioritizationFee = await getRecentPrioritizationFee(connection, options);
87
87
  const median = resolveMedian(recentPrioritizationFee.result.map((r) => r.prioritizationFee));
88
- return { median: Math.ceil(median * (1 + (options.multiplierPercent ?? 0.05))), data: recentPrioritizationFee };
88
+ return { median: Math.ceil(median * (1 + (options.increaseFactor ?? 0.05))), data: recentPrioritizationFee };
89
89
  };
90
90
  var getRecentPrioritizationFee = async (connection, options) => {
91
91
  const { accountsOrTx, percentile = 5e3 } = options;
@@ -118,7 +118,7 @@ var pk = (address) => {
118
118
  var getPriorityFeeEstimate2 = async (connection, options) => {
119
119
  const recentPrioritizationFee = await getRecentPrioritizationFee2(connection, options);
120
120
  const median = resolveMedian(recentPrioritizationFee.map((r) => r.prioritizationFee));
121
- return { median: Math.ceil(median * (1 + (options.multiplierPercent ?? 0.05))), data: recentPrioritizationFee };
121
+ return { median: Math.ceil(median * (1 + (options.increaseFactor ?? 0.05))), data: recentPrioritizationFee };
122
122
  };
123
123
  var getRecentPrioritizationFee2 = async (connection, options) => {
124
124
  return connection.getRecentPrioritizationFees({ lockedWritableAccounts: buildArgs2(options.accountsOrTx)[0] });
@@ -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","message","accounts","writableAccounts","getPriorityFeeEstimate","getRecentPrioritizationFee","buildArgs"],"mappings":";;;;;;;;;;AAWO,IAAM,uBAAuB,OAClC,UAAA,EACA,EACA,EAAA,OAAA,GAA0C,EACvC,KAAA;AACH,EAAM,MAAA,EAAE,iBAAoB,GAAA,IAAA,EAAS,GAAA,OAAA;AACrC,EAAA,MAAM,iBAAoB,GAAA,MAAM,UAAW,CAAA,mBAAA,CA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AA;AAAA,EAAAC,sBAAAA,EAAAA,MAAAA,uBAAAA;AAAA,EAAA,0BAAAC,EAAAA,MAAAA;AAAA,CAAA,CAAA;ACOO,IAAM,EAAA,GAAK,CAAC,OAA2C,KAAA;AAC5D,EAAA,OAAO,OAAO,OAAY,KAAA,QAAA,GAAW,IAAI,SAAA,CAAU,OAAO,CAAI,GAAA,OAAA;AAChE,CAAA;;;ADKO,IAAMD,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,iBAAqB,IAAA,IAAA,CAAA,CAAM,CAAG,EAAA,IAAA,EAAM,uBAAwB,EAAA;AAChH,CAAA;AASO,IAAMA,2BAAAA,GAA6B,OACxC,UAAA,EACA,OACG,KAAA;AACH,EAAO,OAAA,UAAA,CAAW,2BAA4B,CAAA,EAAE,sBAAwBC,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.js","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 { multiplierPercent = 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 + multiplierPercent))\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.multiplierPercent ?? 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.multiplierPercent ?? 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","message","accounts","writableAccounts","getPriorityFeeEstimate","getRecentPrioritizationFee","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,CAAA,aAAA,GACnC,IAAK,CAAA,IAAA,CAAK,iBAAkB,CAAA,KAAA,CAAM,aAAiB,IAAA,CAAA,GAAI,cAAe,CAAA,CAAA,GACtE,kBAAkB,KAAM,CAAA,aAAA;AAAA,IAC5B,IAAM,EAAA;AAAA,GACR;AACF;;;AC3BA,IAAA,kBAAA,GAAA;AAAA,QAAA,CAAA,kBAAA,EAAA;AAAA,EAA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,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,sBAAwBC,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.js","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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/common",
3
- "version": "8.0.1-alpha.p287.54fe41f",
3
+ "version": "8.0.2-alpha.p287.a3616ff",
4
4
  "description": "Common utilities and types used by streamflow packages.",
5
5
  "homepage": "https://github.com/streamflow-finance/js-sdk/",
6
6
  "type": "module",
@@ -43,9 +43,9 @@
43
43
  "lint-config": "eslint --print-config",
44
44
  "prepublishOnly": "pnpm run lint && pnpm run build"
45
45
  },
46
- "gitHead": "e621ebf951781bcbe1e4f12370526f94ec39d6e8",
46
+ "gitHead": "2f1f50c04b56417ba0b30529e5163cbc20c05cdd",
47
47
  "devDependencies": {
48
- "@streamflow/eslint-config": "8.0.1-alpha.p287.54fe41f",
48
+ "@streamflow/eslint-config": "8.0.2-alpha.p287.a3616ff",
49
49
  "@types/bn.js": "5.1.1",
50
50
  "typescript": "^5.6.3"
51
51
  },