Skip to content
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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ Using a buffer account you can split the metadata update into the uploading of t
- `--rpc <string>`: Custom RPC URL
- `--export [address]`: Export transactions instead of running them. Optionally specify an override authority address.
- `--export-encoding <encoding>`: How to encode exported transactions. Choices: none, utf8, base58, base64 (default: base64)
- `--tx-version <version>`: Transaction version to build. Choices: legacy, 0 (default: 0)
- `-h, --help`: Show help for command

#### Squads Multisig
Expand All @@ -143,6 +144,12 @@ npx @solana-program/program-metadata@latest set-buffer-authority <buffer-address
npx @solana-program/program-metadata@latest write idl <program-address> --buffer <buffer-address> --export <multisig-address> --export-encoding base58 --close-buffer <your-address-to-get-the-buffer-rent-back>
```

Squads v3 only accepts legacy transactions. If your multisig is on Squads v3, add `--tx-version legacy` so the exported transaction is a legacy transaction instead of a version 0 transaction:

```bash
npx @solana-program/program-metadata@latest write idl <program-address> --buffer <buffer-address> --export <multisig-address> --export-encoding base58 --close-buffer <your-address-to-get-the-buffer-rent-back> --tx-version legacy
```

4. Sign the transaction in your multisig and send it

### Examples
Expand Down
27 changes: 24 additions & 3 deletions clients/js/src/cli/options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type Address, type MicroLamports } from '@solana/kit';
import { Option } from 'commander';
import { InvalidArgumentError, Option } from 'commander';

import { Compression, Encoding, Format } from '../generated';
import { logErrorAndExit } from './logs';
Expand All @@ -11,7 +11,8 @@ export type GlobalOptions = KeypairOption &
PriorityFeesOption &
RpcOption &
ExportOption &
ExportEncodingOption;
ExportEncodingOption &
TransactionVersionOption;

export function setGlobalOptions(command: CustomCommand) {
command
Expand All @@ -20,7 +21,8 @@ export function setGlobalOptions(command: CustomCommand) {
.addOption(priorityFeesOption)
.addOption(rpcOption)
.addOption(exportOption)
.addOption(exportEncodingOption);
.addOption(exportEncodingOption)
.addOption(transactionVersionOption);
}

export type KeypairOption = { keypair?: string };
Expand Down Expand Up @@ -66,6 +68,25 @@ export const exportEncodingOption = new Option(
(value: string): ExportEncoding => (value === 'instruction-list' ? 'instruction-list' : encodingParser(value)),
);

export type TransactionVersion = 'legacy' | 0;
export type TransactionVersionOption = { txVersion: TransactionVersion };
export const transactionVersionOption = new Option(
'--tx-version <version>',
'Transaction version to build. Squads v3 only accepts legacy transactions.',
)
.choices(['legacy', '0'])
.default(0, '0')
.argParser((value: string): TransactionVersion => {
switch (value) {
case 'legacy':
return 'legacy';
case '0':
return 0;
default:
throw new InvalidArgumentError('Allowed choices are legacy, 0.');
}
});

export type WriteOptions = TextOption &
UrlOption &
AccountOption &
Expand Down
18 changes: 16 additions & 2 deletions clients/js/src/cli/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
TransactionPlanExecutor,
TransactionSigner,
} from '@solana/kit';
import { solanaRpc } from '@solana/kit-plugin-rpc';
import { solanaRpc, TransactionPlannerConfig } from '@solana/kit-plugin-rpc';
import { identity, payer } from '@solana/kit-plugin-signer';
import { Command } from 'commander';
import picocolors from 'picocolors';
Expand Down Expand Up @@ -92,14 +92,28 @@ export async function getClient(options: GlobalOptions) {
solanaRpc({
rpcUrl,
rpcSubscriptionsUrl,
transactionConfig: { microLamportsPerComputeUnit: options.priorityFees },
transactionConfig: getTransactionConfig(options),
}),
)
.use(programMetadataProgram())
.use(cliConfigs(configs))
.use(cliRunOrExport(options));
}

/**
* Builds the transaction planner config for the requested transaction version.
* The config shape is discriminated by `version`: legacy and version 0
* transactions express priority fees per compute unit, while version 1 will
* use a total fee in lamports.
*/
function getTransactionConfig(options: GlobalOptions): TransactionPlannerConfig {
switch (options.txVersion) {
case 'legacy':
case 0:
return { microLamportsPerComputeUnit: options.priorityFees, version: options.txVersion };
}
}
Comment thread
lorisleiva marked this conversation as resolved.

/**
* Plugin that attaches the parsed `~/.config/solana/cli/config.yml` to the
* client so commands that need to introspect Solana config defaults can read
Expand Down
Loading