@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 +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,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,c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;;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,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"]}
|
|
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,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,EAAA,MAAM,QAAA,GAAWA,MAAAA,CAAO,IAAA,CAAK,YAAA,EAAc,QAAQ,CAAA;AACnD,EAAA,IAAI;AACF,IAAA,MAAM,EAAA,GAAK,WAA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M,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,EAAwBC,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.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,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamflow/common",
|
|
3
|
-
"version": "12.1.
|
|
3
|
+
"version": "12.2.1-alpha.p361.abedd84",
|
|
4
4
|
"description": "Common utilities and types used by streamflow packages.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/streamflow-finance/js-sdk.git",
|
|
8
|
+
"directory": "packages/common"
|
|
9
|
+
},
|
|
5
10
|
"homepage": "https://github.com/streamflow-finance/js-sdk/",
|
|
6
11
|
"type": "module",
|
|
7
12
|
"main": "./dist/cjs/index.cjs",
|
|
@@ -35,9 +40,9 @@
|
|
|
35
40
|
"lint-config": "eslint --print-config",
|
|
36
41
|
"prepublishOnly": "pnpm run lint && pnpm run build"
|
|
37
42
|
},
|
|
38
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "dcd079e7049183a87fc372c73bfeadf7c8588c73",
|
|
39
44
|
"devDependencies": {
|
|
40
|
-
"@streamflow/eslint-config": "12.1.
|
|
45
|
+
"@streamflow/eslint-config": "12.2.1-alpha.p361.abedd84",
|
|
41
46
|
"@types/bn.js": "5.1.1",
|
|
42
47
|
"typescript": "^5.6.3"
|
|
43
48
|
},
|
|
@@ -47,8 +52,8 @@
|
|
|
47
52
|
"@solana/buffer-layout": "4.0.1",
|
|
48
53
|
"@solana/spl-token": "0.4.9",
|
|
49
54
|
"@solana/wallet-adapter-base": "0.9.19",
|
|
50
|
-
"@solana/web3.js": "1.
|
|
51
|
-
"bn.js": "5.2.
|
|
55
|
+
"@solana/web3.js": "1.98.4",
|
|
56
|
+
"bn.js": "5.2.3",
|
|
52
57
|
"borsh": "^2.0.0",
|
|
53
58
|
"bs58": "5.0.0",
|
|
54
59
|
"p-queue": "^8.0.1"
|