Skip to content

Commit

Permalink
[wip]: Use buffer-only and priority-fees options in CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
lorisleiva committed Jan 23, 2025
1 parent d34177c commit f71c3af
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions clients/js/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ import {
createKeyPairSignerFromBytes,
createSolanaRpc,
createSolanaRpcSubscriptions,
getBase58Decoder,
getBase64Decoder,
getTransactionEncoder,
isSolanaError,
KeyPairSigner,
MicroLamports,
Rpc,
RpcSubscriptions,
SolanaRpcApi,
Expand Down Expand Up @@ -55,7 +59,6 @@ program
'Path to keypair file of transaction fee and storage payer. (default: keypair)'
)
.option('--rpc <string>', 'RPC URL. (default: solana config or localhost)')
// TODO: Support priority fees.
.option(
'--priority-fees <number>',
'Priority fees per compute unit for sending transactions',
Expand Down Expand Up @@ -118,7 +121,6 @@ program
'Describes how to compress the data. (default: "zlib")'
).choices(['none', 'gzip', 'zlib'])
)
// TODO: Support buffer-only uploads.
.option(
'--buffer-only',
'Only create the buffer and export the transaction that sets the buffer.',
Expand All @@ -142,18 +144,37 @@ program
'You must be the program authority to upload a canonical metadata account. Use `--third-party` option to upload as a third party.'
);
}
await uploadMetadata({
const { lastTransaction } = await uploadMetadata({
...client,
...getPackedData(content, options),
payer,
authority: keypair,
program: address(programAddress),
seed,
format: getFormat(options),
buffer: options.bufferOnly ? true : undefined,
extractLastTransaction: options.bufferOnly,
priorityFees: options.priorityFees
? (BigInt(options.priorityFees) as MicroLamports)
: undefined,
});
logSuccess(
`Metadata uploaded successfully for program ${chalk.bold(programAddress)} and seed "${chalk.bold(seed)}"!`
);
if (lastTransaction) {
const transactionBytes =
getTransactionEncoder().encode(lastTransaction);
const base64EncodedTransaction =
getBase64Decoder().decode(transactionBytes);
const base58EncodedTransaction =
getBase58Decoder().decode(transactionBytes);
logSuccess(
`Buffer successfully created for program ${chalk.bold(programAddress)} and seed "${chalk.bold(seed)}"!\n` +
`Use the following transaction data to apply the buffer:\n\n` +
`[base64]\n${base64EncodedTransaction}\n\n[base58]\n${base58EncodedTransaction}`
);
} else {
logSuccess(
`Metadata uploaded successfully for program ${chalk.bold(programAddress)} and seed "${chalk.bold(seed)}"!`
);
}
}
);

Expand Down

0 comments on commit f71c3af

Please sign in to comment.