Skip to content
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

Priority fees as optional flag #43

Merged
merged 4 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/flat-phones-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"mucho": minor
---

add priority-fee optional command flag and updated deploy command to use it
2 changes: 2 additions & 0 deletions src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export function deployCommand() {
.addOption(COMMON_OPTIONS.keypair)
.addOption(COMMON_OPTIONS.config)
.addOption(COMMON_OPTIONS.outputOnly)
.addOption(COMMON_OPTIONS.priorityFee)
.action(async (options, { args: passThroughArgs }) => {
if (!options.outputOnly) {
titleMessage("Deploy a Solana program");
Expand Down Expand Up @@ -268,6 +269,7 @@ export function deployCommand() {
programId: programIdPath || programId,
url: options.url,
keypair: options.keypair,
priorityFee: options.priorityFee,
});

// todo: if options.url is localhost, verify the test validator is running
Expand Down
7 changes: 7 additions & 0 deletions src/const/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,11 @@ export const COMMON_OPTIONS = {
"--manifest-path <PATH>",
"path to Cargo.toml",
).default(join(process.cwd(), "Cargo.toml")),
/**
* priority fee in micro-lamports to add to transactions
*/
priorityFee: new Option(
"--priority-fee <MICRO_LAMPORTS>",
"priority fee in micro-lamports to add to transactions",
),
};
7 changes: 7 additions & 0 deletions src/lib/shell/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type DeployProgramCommandInput = {
upgradeAuthority?: string;
keypair?: string;
url?: SolanaCluster | string;
priorityFee?: string;
};

export function buildDeployProgramCommand({
Expand All @@ -24,6 +25,7 @@ export function buildDeployProgramCommand({
url,
keypair,
upgradeAuthority,
priorityFee,
}: DeployProgramCommandInput) {
const command: string[] = ["solana program deploy"];

Expand Down Expand Up @@ -53,6 +55,11 @@ export function buildDeployProgramCommand({
command.push(`--program-id ${programId}`);
}

// Add priority fee if specified
if (priorityFee) {
command.push(`--with-compute-unit-price ${priorityFee}`);
}

// todo: validate the `programPath` file exists
command.push(programPath);

Expand Down