Skip to content

Commit 065a454

Browse files
committed
cli: solana deployment improvements (resume + priority fees)
1 parent 3f8d41c commit 065a454

File tree

1 file changed

+35
-13
lines changed

1 file changed

+35
-13
lines changed

cli/src/index.ts

+35-13
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,11 @@ yargs(hideBin(process.argv))
318318
type: "string",
319319
choices: ["locking", "burning"],
320320
})
321+
.option("solana-priority-fee", {
322+
describe: "Priority fee for Solana deployment (in microlamports)",
323+
type: "number",
324+
default: 50000,
325+
})
321326
.option("signer-type", options.signerType)
322327
.option("skip-verify", options.skipVerify)
323328
.option("ver", options.version)
@@ -372,7 +377,7 @@ yargs(hideBin(process.argv))
372377
const ch = wh.getChain(chain);
373378

374379
// TODO: make manager configurable
375-
const deployedManager = await deploy(version, mode, ch, token, signerType, !argv["skip-verify"], argv["yes"], argv["payer"], argv["program-key"], argv["binary"]);
380+
const deployedManager = await deploy(version, mode, ch, token, signerType, !argv["skip-verify"], argv["yes"], argv["payer"], argv["program-key"], argv["binary"], argv["solana-priority-fee"]);
376381

377382
const [config, _ctx, _ntt, decimals] =
378383
await pullChainConfig(network, deployedManager, overrides);
@@ -1058,6 +1063,7 @@ async function deploy<N extends Network, C extends Chain>(
10581063
solanaPayer?: string,
10591064
solanaProgramKeyPath?: string,
10601065
solanaBinaryPath?: string,
1066+
solanaPriorityFee?: number
10611067
): Promise<ChainAddress<C>> {
10621068
if (version === null) {
10631069
await warnLocalDeployment(yes);
@@ -1073,7 +1079,7 @@ async function deploy<N extends Network, C extends Chain>(
10731079
process.exit(1);
10741080
}
10751081
const solanaCtx = ch as ChainContext<N, SolanaChains>;
1076-
return await deploySolana(worktree, version, mode, solanaCtx, token, solanaPayer, true, solanaProgramKeyPath, solanaBinaryPath) as ChainAddress<C>;
1082+
return await deploySolana(worktree, version, mode, solanaCtx, token, solanaPayer, true, solanaProgramKeyPath, solanaBinaryPath, solanaPriorityFee) as ChainAddress<C>;
10771083
default:
10781084
throw new Error("Unsupported platform");
10791085
}
@@ -1191,7 +1197,8 @@ async function deploySolana<N extends Network, C extends SolanaChains>(
11911197
payer: string,
11921198
initialize: boolean,
11931199
managerKeyPath?: string,
1194-
binaryPath?: string
1200+
binaryPath?: string,
1201+
priorityFee?: number
11951202
): Promise<ChainAddress<C>> {
11961203
ensureNttRoot(pwd);
11971204

@@ -1351,16 +1358,31 @@ async function deploySolana<N extends Network, C extends SolanaChains>(
13511358

13521359
await checkSolanaBinary(binary, wormhole, providedProgramId, version ?? undefined)
13531360

1354-
// do the actual deployment
1355-
const deployProc = Bun.spawn(
1356-
["solana",
1357-
"program",
1358-
"deploy",
1359-
"--program-id", programKeypairPath,
1360-
binary,
1361-
"--keypair", payer,
1362-
"-u", ch.config.rpc
1363-
]);
1361+
// if buffer.json doesn't exist, create it
1362+
if (!fs.existsSync(`buffer.json`)) {
1363+
execSync(`solana-keygen new -o buffer.json --no-bip39-passphrase`);
1364+
} else {
1365+
console.info("buffer.json already exists.")
1366+
askForConfirmation("Do you want continue an exiting deployment? If not, delete the buffer.json file and run the command again.");
1367+
}
1368+
1369+
const deployCommand = [
1370+
"solana",
1371+
"program",
1372+
"deploy",
1373+
"--program-id", programKeypairPath,
1374+
"--max-sign-attempts", "20",
1375+
"--buffer", `buffer.json`,
1376+
binary,
1377+
"--keypair", payer,
1378+
"-u", ch.config.rpc
1379+
];
1380+
1381+
if (priorityFee !== undefined) {
1382+
deployCommand.push("--with-compute-unit-price", priorityFee.toString());
1383+
}
1384+
1385+
const deployProc = Bun.spawn(deployCommand);
13641386

13651387
const out = await new Response(deployProc.stdout).text();
13661388

0 commit comments

Comments
 (0)