-
Notifications
You must be signed in to change notification settings - Fork 7
Replace priorityFees with TransactionPlannerConfig in transaction planner plugins
#193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| --- | ||
| '@solana/kit-plugin-rpc': minor | ||
| '@solana/kit-plugin-litesvm': minor | ||
| --- | ||
|
|
||
| Replace the `priorityFees` config option on `rpcTransactionPlanner` and `litesvmTransactionPlanner` with a new `TransactionPlannerConfig` object that supports `microLamportsPerComputeUnit` and `version`. Add a `transactionConfig` option to `solanaRpc` and `litesvm` for passing transaction planner configuration through the all-in-one plugins. | ||
|
|
||
| **BREAKING CHANGES** | ||
|
|
||
| **`priorityFees` replaced with `TransactionPlannerConfig`.** The inline `priorityFees` option has been replaced with a `TransactionPlannerConfig` object. The `priorityFees` option on `SolanaRpcConfig` has been replaced with `transactionConfig`. | ||
|
|
||
| ```diff | ||
| - rpcTransactionPlanner({ priorityFees: 100n as MicroLamports }) | ||
| + rpcTransactionPlanner({ microLamportsPerComputeUnit: 100n as MicroLamports }) | ||
| ``` | ||
|
|
||
| ```diff | ||
| - solanaRpc({ url, priorityFees: 100n as MicroLamports }) | ||
| + solanaRpc({ url, transactionConfig: { microLamportsPerComputeUnit: 100n as MicroLamports } }) | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,26 +32,44 @@ import { | |
| * .use(litesvmTransactionPlanExecutor()); | ||
| * ``` | ||
| */ | ||
| export function litesvmTransactionPlanner( | ||
| config: { | ||
| /** | ||
| * The priority fees to be set on the transaction in micro lamports per compute unit. | ||
| * Defaults to using no priority fees. | ||
| */ | ||
| priorityFees?: MicroLamports; | ||
| } = {}, | ||
| ) { | ||
| export function litesvmTransactionPlanner(config: TransactionPlannerConfig = {}) { | ||
| return <T extends ClientWithPayer>(client: T) => { | ||
| const transactionPlanner = createTransactionPlanner({ | ||
| createTransactionMessage: () => { | ||
| return pipe( | ||
| createTransactionMessage({ version: 0 }), | ||
| createTransactionMessage({ version: config.version ?? 0 }), | ||
| tx => setTransactionMessageFeePayerSigner(client.payer, tx), | ||
| tx => (config.priorityFees ? setTransactionMessageComputeUnitPrice(config.priorityFees, tx) : tx), | ||
| tx => | ||
| config.microLamportsPerComputeUnit | ||
| ? setTransactionMessageComputeUnitPrice(config.microLamportsPerComputeUnit, tx) | ||
| : tx, | ||
| ); | ||
| }, | ||
| }); | ||
|
|
||
| return extendClient(client, { transactionPlanner }); | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Configuration options for the transaction planner. | ||
| * | ||
| * The `version` field is used to determine the transaction version | ||
| * to use when creating transaction messages and determines the shape | ||
| * of the rest of the configuration options, as some options are only | ||
| * applicable to certain transaction versions. | ||
| */ | ||
| // TODO(loris): Add support for v1 transactions when LiteSVM supports them. | ||
| // This includes: `version: 1` and `priorityFees?: Lamports` in a new union variant. | ||
| export type TransactionPlannerConfig = { | ||
| /** | ||
| * The priority fees to be set on the transaction in micro lamports per compute unit. | ||
| * Defaults to using no priority fees. | ||
| */ | ||
| microLamportsPerComputeUnit?: MicroLamports; | ||
| /** | ||
| * The transaction message version to use when creating transaction messages. | ||
| * Defaults to version 0. | ||
| */ | ||
| version?: 'legacy' | 0; | ||
| }; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: since this type is identical to the one in
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did that on purpose to allow the two config objects to grow independently of each other. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch exporting
LiteSvmConfigfrom the browser entry point so consumers can still reference the type even when the runtime function throws.