@streamflow/common 8.0.0-alpha.p287.5172056 → 8.0.0-alpha.p287.84ff30f
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 +1 -1
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +6 -48
- package/dist/cjs/solana/rpc/index.cjs +2 -2
- package/dist/cjs/solana/rpc/index.cjs.map +1 -1
- package/dist/cjs/solana/rpc/index.d.cts +4 -53
- package/dist/cjs/types-DGCX8JLm.d.cts +73 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +6 -48
- package/dist/esm/solana/index.js +1 -1
- package/dist/esm/solana/index.js.map +1 -1
- package/dist/esm/solana/rpc/index.d.ts +4 -53
- package/dist/esm/solana/rpc/index.js +2 -2
- package/dist/esm/solana/rpc/index.js.map +1 -1
- package/dist/esm/types-DGCX8JLm.d.ts +73 -0
- package/package.json +3 -3
|
@@ -68,7 +68,7 @@ var resolveMedian = (values) => {
|
|
|
68
68
|
var getPriorityFeeEstimate = async (connection, options) => {
|
|
69
69
|
const recentPrioritizationFee = await getRecentPrioritizationFee(connection, options);
|
|
70
70
|
const median = resolveMedian(recentPrioritizationFee.result.map((r) => r.prioritizationFee));
|
|
71
|
-
return { median:
|
|
71
|
+
return { median: median * (1 + (options.safeAreaIncrease ?? 0.05)), data: recentPrioritizationFee };
|
|
72
72
|
};
|
|
73
73
|
var getRecentPrioritizationFee = async (connection, options) => {
|
|
74
74
|
const { accountsOrTx, percentile = 5e3 } = options;
|
|
@@ -101,7 +101,7 @@ var pk = (address) => {
|
|
|
101
101
|
var getPriorityFeeEstimate2 = async (connection, options) => {
|
|
102
102
|
const recentPrioritizationFee = await getRecentPrioritizationFee2(connection, options);
|
|
103
103
|
const median = resolveMedian(recentPrioritizationFee.map((r) => r.prioritizationFee));
|
|
104
|
-
return { median:
|
|
104
|
+
return { median: median * (1 + (options.safeAreaIncrease ?? 0.05)), data: recentPrioritizationFee };
|
|
105
105
|
};
|
|
106
106
|
var getRecentPrioritizationFee2 = async (connection, options) => {
|
|
107
107
|
return connection.getRecentPrioritizationFees({ lockedWritableAccounts: buildArgs2(options.accountsOrTx)[0] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../solana/rpc/priority-fee-estimate/percentile.ts","../../../../solana/deserialize-raw-transaction.ts","../../../../solana/rpc/priority-fee-estimate/calc-fee.ts","../../../../solana/rpc/priority-fee-estimate/general.ts","../../../../solana/public-key.ts"],"names":["Buffer","Transaction","VersionedTransaction","getPriorityFeeEstimate","getRecentPrioritizationFee","PublicKey","buildArgs"],"mappings":";;;;;;;;;;;;AAAA,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,YAAsB,EAAA;AAC9D,EAAA,MAAM,QAAWA,GAAAA,aAAAA,CAAO,IAAK,CAAA,YAAA,EAAc,QAAQ,CAAA;AACnD,EAAI,IAAA;AACF,IAAM,MAAA,EAAA,GAAKC,mBAAY,CAAA,IAAA,CAAK,QAAQ,CAAA;AACpC,IAAM,MAAA,OAAA,GAAU,GAAG,cAAe,EAAA;AAClC,IAAA,MAAM,WAAW,OAAQ,CAAA,WAAA;AACzB,IAAM,MAAA,gBAAA,GAAmB,SAAS,MAAO,CAAA,CAAC,GAAG,GAAQ,KAAA,OAAA,CAAQ,iBAAkB,CAAA,GAAG,CAAC,CAAA;AACnF,IAAO,OAAA;AAAA,MACL,IAAM,EAAA,QAAA;AAAA,MACN,WAAa,EAAA,EAAA;AAAA,MACb,QAAA;AAAA,MACA;AAAA,KACF;AAAA,WACO,KAAO,EAAA;AAC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,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,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,KAAM,CAAA,MAAA,IAAU,CAAK,IAAA,OAAA,CAAQ,gBAAoB,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,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 { Connection, PublicKey } from \"@solana/web3.js\";\n\nimport { deserializeRawTransaction } from \"../../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.trunc(median * (1 + (options.safeAreaIncrease ?? 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 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 } catch (error) {\n try {\n const vtx = VersionedTransaction.deserialize(txBuffer);\n const message = vtx.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: vtx,\n accounts,\n writableAccounts,\n };\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","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 \"../../deserialize-raw-transaction.js\";\nimport { pk } from \"../../public-key.js\";\nimport type { GetPriorityFeeEstimateOptions } from \"../types.js\";\nimport { resolveMedian } from \"./calc-fee.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.trunc(median * (1 + (options.safeAreaIncrease ?? 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/priority-fee-estimate/percentile.ts","../../../../solana/deserialize-raw-transaction.ts","../../../../solana/rpc/priority-fee-estimate/calc-fee.ts","../../../../solana/rpc/priority-fee-estimate/general.ts","../../../../solana/public-key.ts"],"names":["Buffer","Transaction","VersionedTransaction","getPriorityFeeEstimate","getRecentPrioritizationFee","PublicKey","buildArgs"],"mappings":";;;;;;;;;;;;AAAA,IAAA,kBAAA,GAAA;AAAA,QAAA,CAAA,kBAAA,EAAA;AAAA,EAAA,sB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A,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 { Connection, PublicKey } from \"@solana/web3.js\";\n\nimport { deserializeRawTransaction } from \"../../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>;\ninterface RecentPrioritizationFee {\n result: Array<{ prioritizationFee: number; slot: number }>;\n}\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: median * (1 + (options.safeAreaIncrease ?? 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 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 } catch (error) {\n try {\n const vtx = VersionedTransaction.deserialize(txBuffer);\n const message = vtx.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: vtx,\n accounts,\n writableAccounts,\n };\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","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 \"../../deserialize-raw-transaction.js\";\nimport { pk } from \"../../public-key.js\";\nimport type { GetPriorityFeeEstimateOptions } from \"../../types.js\";\nimport { resolveMedian } from \"./calc-fee.js\";\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: median * (1 + (options.safeAreaIncrease ?? 0.05)), data: recentPrioritizationFee };\n};\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,49 +1,14 @@
|
|
|
1
1
|
import * as _solana_web3_js from '@solana/web3.js';
|
|
2
|
-
import {
|
|
2
|
+
import { Connection } from '@solana/web3.js';
|
|
3
|
+
import { G as GetPriorityFeeEstimateOptions } from '../../types-DGCX8JLm.cjs';
|
|
4
|
+
import 'p-queue';
|
|
3
5
|
|
|
4
|
-
/**
|
|
5
|
-
* @interface GetPriorityFeeEstimateOptions - The options for the priority fee estimate
|
|
6
|
-
*/
|
|
7
|
-
interface GetPriorityFeeEstimateOptions {
|
|
8
|
-
/**
|
|
9
|
-
* The accounts or transaction to get the priority fee estimate for.
|
|
10
|
-
* `string` is a serialized base64 transaction.
|
|
11
|
-
* `array` is interpreted as an array of public keys in string format or as PublicKey instances (writable accounts).
|
|
12
|
-
*/
|
|
13
|
-
accountsOrTx: (string | PublicKey)[] | string;
|
|
14
|
-
/**
|
|
15
|
-
* The percentile of the priority fee estimate to return.
|
|
16
|
-
*
|
|
17
|
-
* examples: Triton RPC - [0, 10000]
|
|
18
|
-
* @default 5000
|
|
19
|
-
*/
|
|
20
|
-
percentile?: number;
|
|
21
|
-
/**
|
|
22
|
-
* The safe area increase to apply to the priority fee estimate.
|
|
23
|
-
* @default 0.05 = 5%
|
|
24
|
-
*/
|
|
25
|
-
safeAreaIncrease?: number;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @category GetPriorityFeeEstimateOptions
|
|
30
|
-
* @interface RecentPrioritizationFee
|
|
31
|
-
* @property result - The result of the recent prioritization fees.
|
|
32
|
-
* @property result.prioritizationFee - The prioritization fee.
|
|
33
|
-
* @property result.slot - The slot of the prioritization fee.
|
|
34
|
-
*/
|
|
35
6
|
interface RecentPrioritizationFee {
|
|
36
7
|
result: Array<{
|
|
37
8
|
prioritizationFee: number;
|
|
38
9
|
slot: number;
|
|
39
10
|
}>;
|
|
40
11
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Fetch the recent prioritization fees from the RPC [getRecentPrioritizationFees]
|
|
43
|
-
* @param connection - The connection to the RPC
|
|
44
|
-
* @param options - The options for the RPC
|
|
45
|
-
* @returns The priority fee estimate
|
|
46
|
-
*/
|
|
47
12
|
declare const getPriorityFeeEstimate$1: (connection: Connection, options: GetPriorityFeeEstimateOptions) => Promise<{
|
|
48
13
|
median: number;
|
|
49
14
|
data: RecentPrioritizationFee;
|
|
@@ -60,24 +25,10 @@ declare namespace percentile {
|
|
|
60
25
|
export { getPriorityFeeEstimate$1 as getPriorityFeeEstimate, getRecentPrioritizationFee$1 as getRecentPrioritizationFee };
|
|
61
26
|
}
|
|
62
27
|
|
|
63
|
-
/**
|
|
64
|
-
* Fetch the recent prioritization fees from the RPC [getRecentPrioritizationFees] (https://solana.com/docs/rpc/http/getrecentprioritizationfees)
|
|
65
|
-
* @deprecated Not recommended for use because it provides a single number per slot to indicate the minimum priority fee amount.
|
|
66
|
-
* @param connection - The connection to the RPC
|
|
67
|
-
* @param options - The options for the RPC
|
|
68
|
-
* @returns The priority fee estimate
|
|
69
|
-
*/
|
|
70
28
|
declare const getPriorityFeeEstimate: (connection: Connection, options: GetPriorityFeeEstimateOptions) => Promise<{
|
|
71
29
|
median: number;
|
|
72
30
|
data: _solana_web3_js.RecentPrioritizationFees[];
|
|
73
31
|
}>;
|
|
74
|
-
/**
|
|
75
|
-
* Fetch the recent prioritization fees from the RPC [getRecentPrioritizationFees] (https://solana.com/docs/rpc/http/getrecentprioritizationfees)
|
|
76
|
-
* @deprecated Not recommended for use because it provides a single number per slot to indicate the minimum priority fee amount.
|
|
77
|
-
* @param connection - The connection to the RPC
|
|
78
|
-
* @param options - The options for the RPC
|
|
79
|
-
* @returns The priority fee estimate
|
|
80
|
-
*/
|
|
81
32
|
declare const getRecentPrioritizationFee: (connection: Connection, options: Pick<GetPriorityFeeEstimateOptions, "accountsOrTx">) => Promise<_solana_web3_js.RecentPrioritizationFees[]>;
|
|
82
33
|
|
|
83
34
|
declare const general_getPriorityFeeEstimate: typeof getPriorityFeeEstimate;
|
|
@@ -86,4 +37,4 @@ declare namespace general {
|
|
|
86
37
|
export { general_getPriorityFeeEstimate as getPriorityFeeEstimate, general_getRecentPrioritizationFee as getRecentPrioritizationFee };
|
|
87
38
|
}
|
|
88
39
|
|
|
89
|
-
export {
|
|
40
|
+
export { general as priorityFeeEstimation, percentile as priorityFeeEstimationPercentile };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { PublicKey, AccountInfo, BlockhashWithExpiryBlockHeight, Context, Commitment } from '@solana/web3.js';
|
|
2
|
+
import PQueue from 'p-queue';
|
|
3
|
+
|
|
4
|
+
type ComputePriceEstimate = (tx: string | (string | PublicKey)[]) => Promise<number>;
|
|
5
|
+
interface ITransactionSolanaExt {
|
|
6
|
+
computePrice?: number | ComputePriceEstimate;
|
|
7
|
+
computeLimit?: number;
|
|
8
|
+
}
|
|
9
|
+
interface IInteractSolanaExt extends ITransactionSolanaExt {
|
|
10
|
+
invoker: {
|
|
11
|
+
publicKey: string | PublicKey | null;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
interface Account {
|
|
15
|
+
pubkey: PublicKey;
|
|
16
|
+
account: AccountInfo<Buffer>;
|
|
17
|
+
}
|
|
18
|
+
interface CheckAssociatedTokenAccountsData {
|
|
19
|
+
sender: PublicKey;
|
|
20
|
+
recipient: PublicKey;
|
|
21
|
+
partner: PublicKey;
|
|
22
|
+
streamflowTreasury: PublicKey;
|
|
23
|
+
mint: PublicKey;
|
|
24
|
+
}
|
|
25
|
+
interface AtaParams {
|
|
26
|
+
mint: PublicKey;
|
|
27
|
+
owner: PublicKey;
|
|
28
|
+
programId?: PublicKey;
|
|
29
|
+
}
|
|
30
|
+
interface ConfirmationParams {
|
|
31
|
+
hash: BlockhashWithExpiryBlockHeight;
|
|
32
|
+
context: Context;
|
|
33
|
+
commitment?: Commitment;
|
|
34
|
+
}
|
|
35
|
+
interface ThrottleParams {
|
|
36
|
+
sendRate?: number;
|
|
37
|
+
sendThrottler?: PQueue;
|
|
38
|
+
waitBeforeConfirming?: number | undefined;
|
|
39
|
+
}
|
|
40
|
+
interface IProgramAccount<T> {
|
|
41
|
+
publicKey: PublicKey;
|
|
42
|
+
account: T;
|
|
43
|
+
}
|
|
44
|
+
declare class TransactionFailedError extends Error {
|
|
45
|
+
constructor(m: string);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @interface GetPriorityFeeEstimateOptions - The options for the priority fee estimate
|
|
49
|
+
* @property accountsOrTx - The accounts or transaction to get the priority fee estimate for.
|
|
50
|
+
* @property percentile - The percentile of the priority fee estimate to return.
|
|
51
|
+
* @property safeAreaIncrease - The safe area increase to apply to the priority fee estimate.
|
|
52
|
+
*/
|
|
53
|
+
interface GetPriorityFeeEstimateOptions {
|
|
54
|
+
/**
|
|
55
|
+
* The accounts or transaction to get the priority fee estimate for.
|
|
56
|
+
* String is a serialized base64 transaction.
|
|
57
|
+
* Array is interpreted as an array of public keys in string format or as PublicKey instances.
|
|
58
|
+
*/
|
|
59
|
+
accountsOrTx: (string | PublicKey)[] | string;
|
|
60
|
+
/**
|
|
61
|
+
* The percentile of the priority fee estimate to return.
|
|
62
|
+
* [0, 10000] for Triton RPC signature
|
|
63
|
+
* Default: 5000
|
|
64
|
+
*/
|
|
65
|
+
percentile?: number;
|
|
66
|
+
/**
|
|
67
|
+
* The safe area increase to apply to the priority fee estimate.
|
|
68
|
+
* Default: 0.05 = 5%
|
|
69
|
+
*/
|
|
70
|
+
safeAreaIncrease?: number;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { type Account as A, type ConfirmationParams as C, type GetPriorityFeeEstimateOptions as G, type ITransactionSolanaExt as I, type ThrottleParams as T, type AtaParams as a, type ComputePriceEstimate as b, type IInteractSolanaExt as c, type CheckAssociatedTokenAccountsData as d, type IProgramAccount as e, TransactionFailedError as f };
|
package/dist/esm/index.js
CHANGED
|
@@ -25,7 +25,7 @@ var ContractError = class _ContractError extends Error {
|
|
|
25
25
|
* @param code extracted code from the error if managed to parse it
|
|
26
26
|
*/
|
|
27
27
|
constructor(error, code, description) {
|
|
28
|
-
super(error.message
|
|
28
|
+
super(error.message);
|
|
29
29
|
this.contractErrorCode = code ?? null;
|
|
30
30
|
this.description = description ?? null;
|
|
31
31
|
Object.setPrototypeOf(this, _ContractError.prototype);
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../types.ts","../../lib/assertions.ts","../../lib/utils.ts"],"names":["ICluster","IChain"],"mappings":";;;;AAQY,IAAA,QAAA,qBAAAA,SAAL,KAAA;AACL,EAAAA,UAAA,SAAU,CAAA,GAAA,SAAA;AACV,EAAA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AAC,CAAW,EAAA,CAAA,KAAsB,CAAI,GAAA,CAAA,IAAK,CAAI,GAAA,CAAA,GAAI,MAAO,CAAA,CAAC,CAAI,GAAA,MAAA,CAAO,CAAC,CAAA","file":"index.js","sourcesContent":["import { type TransactionInstruction } from \"@solana/web3.js\";\n\nexport interface ITransactionResult {\n ixs: TransactionInstruction[];\n txId: string;\n}\n\n// Utility types\nexport enum ICluster {\n Mainnet = \"mainnet\",\n Devnet = \"devnet\",\n Testnet = \"testnet\",\n Local = \"local\",\n}\n\nexport enum IChain {\n Solana = \"Solana\",\n Aptos = \"Aptos\",\n Ethereum = \"Ethereum\",\n BNB = \"BNB\",\n Polygon = \"Polygon\",\n Sui = \"Sui\",\n}\n\n/**\n * Error wrapper for calls made to the contract on chain\n */\nexport class ContractError extends Error {\n public contractErrorCode: string | null;\n\n public description: string | null;\n\n /**\n * Constructs the Error Wrapper\n * @param error Original error raised probably by the chain SDK\n * @param code extracted code from the error if managed to parse it\n */\n constructor(error: Error, code?: string | null, description?: string | null) {\n super(error.message); // Call the base class constructor with the error message\n this.contractErrorCode = code ?? null;\n this.description = description ?? null;\n // Copy properties from the original error\n Object.setPrototypeOf(this, ContractError.prototype);\n this.name = \"ContractError\"; // Set the name property\n this.stack = error.stack;\n }\n}\n","const prefix = \"Assertion failed\";\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const invariant: (condition: any, message?: string | (() => string)) => asserts condition = (\n condition,\n message,\n) => {\n if (condition) {\n return;\n }\n const provided: string | undefined = typeof message === \"function\" ? message() : message;\n const value: string = provided ? `${prefix}: ${provided}` : prefix;\n throw new Error(value);\n};\n","import BN from \"bn.js\";\n\nimport { ContractError } from \"../types.js\";\n\n/**\n * Used for conversion of token amounts to their Big Number representation.\n * Get Big Number representation in the smallest units from the same value in the highest units.\n * @param {number} value - Number of tokens you want to convert to its BN representation.\n * @param {number} decimals - Number of decimals the token has.\n */\nexport const getBN = (value: number, decimals: number): BN => {\n const decimalPart = value - Math.trunc(value);\n const integerPart = new BN(Math.trunc(value));\n\n const decimalE = new BN(decimalPart * 1e9);\n\n const sum = integerPart.mul(new BN(1e9)).add(decimalE);\n const resultE = sum.mul(new BN(10).pow(new BN(decimals)));\n return resultE.div(new BN(1e9));\n};\n\n/**\n * Used for token amounts conversion from their Big Number representation to number.\n * Get value in the highest units from BN representation of the same value in the smallest units.\n * @param {BN} value - Big Number representation of value in the smallest units.\n * @param {number} decimals - Number of decimals the token has.\n */\nexport const getNumberFromBN = (value: BN, decimals: number): number =>\n value.gt(new BN(2 ** 53 - 1)) ? value.div(new BN(10 ** decimals)).toNumber() : value.toNumber() / 10 ** decimals;\n\n/**\n * Used to make on chain calls to the contract and wrap raised errors if any\n * @param func function that interacts with the contract\n * @param callback callback that may be used to extract error code\n * @returns {T}\n */\nexport async function handleContractError<T>(\n func: () => Promise<T>,\n callback?: (err: Error) => string | null,\n): Promise<T> {\n try {\n return await func();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (err: any) {\n if (err instanceof Error) {\n if (callback) {\n throw new ContractError(err, callback(err));\n }\n throw new ContractError(err);\n }\n throw err;\n }\n}\n\n/**\n * Pause async function execution for given amount of milliseconds\n * @param ms millisecond to sleep for\n */\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport const divCeilN = (n: bigint, d: bigint): bigint => n / d + (n % d ? BigInt(1) : BigInt(0));\n"]}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { PublicKey, MemcmpFilter, Connection, TransactionInstruction,
|
|
1
|
+
import { PublicKey, MemcmpFilter, Connection, TransactionInstruction, Keypair, Transaction, VersionedTransaction, Commitment, BlockhashWithExpiryBlockHeight, Context, RpcResponseAndContext, SimulatedTransactionResponse, SignatureStatus, AccountInfo } from '@solana/web3.js';
|
|
2
2
|
import BN from 'bn.js';
|
|
3
|
-
import
|
|
3
|
+
import { A as Account, C as ConfirmationParams, T as ThrottleParams, a as AtaParams, I as ITransactionSolanaExt, b as ComputePriceEstimate, c as IInteractSolanaExt } from '../types-DGCX8JLm.js';
|
|
4
|
+
export { d as CheckAssociatedTokenAccountsData, G as GetPriorityFeeEstimateOptions, e as IProgramAccount, f as TransactionFailedError } from '../types-DGCX8JLm.js';
|
|
4
5
|
import { Mint } from '@solana/spl-token';
|
|
5
6
|
import { SignerWalletAdapter } from '@solana/wallet-adapter-base';
|
|
7
|
+
import PQueue from 'p-queue';
|
|
6
8
|
|
|
7
9
|
declare const getFilters: <T extends Record<string, number | PublicKey>>(criteria: T, byteOffsets: Record<keyof T, number>) => MemcmpFilter[];
|
|
8
10
|
|
|
@@ -15,50 +17,6 @@ declare const prepareWrappedAccount: (connection: Connection, senderAddress: Pub
|
|
|
15
17
|
*/
|
|
16
18
|
declare const pk: (address: string | PublicKey) => PublicKey;
|
|
17
19
|
|
|
18
|
-
type ComputePriceEstimate = (tx: string | (string | PublicKey)[]) => Promise<number>;
|
|
19
|
-
interface ITransactionSolanaExt {
|
|
20
|
-
computePrice?: number | ComputePriceEstimate;
|
|
21
|
-
computeLimit?: number;
|
|
22
|
-
}
|
|
23
|
-
interface IInteractSolanaExt extends ITransactionSolanaExt {
|
|
24
|
-
invoker: {
|
|
25
|
-
publicKey: string | PublicKey | null;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
interface Account {
|
|
29
|
-
pubkey: PublicKey;
|
|
30
|
-
account: AccountInfo<Buffer>;
|
|
31
|
-
}
|
|
32
|
-
interface CheckAssociatedTokenAccountsData {
|
|
33
|
-
sender: PublicKey;
|
|
34
|
-
recipient: PublicKey;
|
|
35
|
-
partner: PublicKey;
|
|
36
|
-
streamflowTreasury: PublicKey;
|
|
37
|
-
mint: PublicKey;
|
|
38
|
-
}
|
|
39
|
-
interface AtaParams {
|
|
40
|
-
mint: PublicKey;
|
|
41
|
-
owner: PublicKey;
|
|
42
|
-
programId?: PublicKey;
|
|
43
|
-
}
|
|
44
|
-
interface ConfirmationParams {
|
|
45
|
-
hash: BlockhashWithExpiryBlockHeight;
|
|
46
|
-
context: Context;
|
|
47
|
-
commitment?: Commitment;
|
|
48
|
-
}
|
|
49
|
-
interface ThrottleParams {
|
|
50
|
-
sendRate?: number;
|
|
51
|
-
sendThrottler?: PQueue;
|
|
52
|
-
waitBeforeConfirming?: number | undefined;
|
|
53
|
-
}
|
|
54
|
-
interface IProgramAccount<T> {
|
|
55
|
-
publicKey: PublicKey;
|
|
56
|
-
account: T;
|
|
57
|
-
}
|
|
58
|
-
declare class TransactionFailedError extends Error {
|
|
59
|
-
constructor(m: string);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
20
|
declare const buildSendThrottler: (sendRate: number, sendInterval?: number) => PQueue;
|
|
63
21
|
/**
|
|
64
22
|
* Wrapper function for Solana web3 getProgramAccounts with slightly better call interface
|
|
@@ -214,7 +172,7 @@ declare function createAtaBatch(connection: Connection, invoker: Keypair | Signe
|
|
|
214
172
|
declare function checkOrCreateAtaBatch(connection: Connection, owners: PublicKey[], mint: PublicKey, invoker: SignerWalletAdapter | Keypair, programId?: PublicKey): Promise<TransactionInstruction[]>;
|
|
215
173
|
/**
|
|
216
174
|
* Create Base instructions for Solana
|
|
217
|
-
* - sets compute price if `computePrice` is provided
|
|
175
|
+
* - sets compute price if `computePrice` is provided
|
|
218
176
|
* - sets compute limit if `computeLimit` is provided
|
|
219
177
|
*/
|
|
220
178
|
declare function prepareBaseInstructions(connection: Connection, { computePrice, computeLimit }: ITransactionSolanaExt): TransactionInstruction[];
|
|
@@ -259,4 +217,4 @@ declare function deserializeRawTransaction(serializedTx: string): {
|
|
|
259
217
|
writableAccounts: PublicKey[];
|
|
260
218
|
};
|
|
261
219
|
|
|
262
|
-
export {
|
|
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 };
|
package/dist/esm/solana/index.js
CHANGED
|
@@ -989,7 +989,7 @@ async function checkOrCreateAtaBatch(connection, owners, mint, invoker, programI
|
|
|
989
989
|
}
|
|
990
990
|
function prepareBaseInstructions(connection, { computePrice, computeLimit }) {
|
|
991
991
|
const ixs = [];
|
|
992
|
-
if (computePrice && typeof computePrice
|
|
992
|
+
if (computePrice && typeof computePrice === "number") {
|
|
993
993
|
ixs.push(ComputeBudgetProgram.setComputeUnitPrice({ microLamports: computePrice }));
|
|
994
994
|
}
|
|
995
995
|
if (computeLimit) {
|