Skip to content

chore: dump fixtures without rewriting the global Solana config - #720

Open
MarkFeder wants to merge 1 commit into
solana-foundation:mainfrom
MarkFeder:prepare-mjs-global-config
Open

chore: dump fixtures without rewriting the global Solana config#720
MarkFeder wants to merge 1 commit into
solana-foundation:mainfrom
MarkFeder:prepare-mjs-global-config

Conversation

@MarkFeder

Copy link
Copy Markdown
Contributor

Repo-wide follow-up to a review finding on #719, in the same spirit as #702.

The problem

Every prepare.mjs that pulls a program fixture from mainnet ran this first:

await $`solana config set -um`;

That is not a per-command flag — it writes mainnet into ~/.config/solana/cli/config.yml and leaves it there. So pnpm install in any of these examples silently repoints the developer's CLI at mainnet, and since the deploy scripts here take no cluster flag, a later pnpm deploy follows it.

The fix

Drop the global mutation and pass -um to the dump itself, so the cluster is scoped to the one command that needs it:

await $`solana program dump -um ${id} ${outputFile}`;

8 files, two script styles (zx in seven, Node stdlib in nft-operations/pinocchio). No behavioural change to what gets downloaded.

The deploy scripts keep taking no cluster flag on purpose — they should deploy wherever the developer has pointed their CLI. That is only correct once prepare.mjs stops moving the target underneath them.

Verification

Ran both script styles in a container with the global config deliberately set to devnet:

  • tokens/create-token/anchor (zx, via pnpm install) → token_metadata.so downloaded, 793,991 bytes
  • tokens/nft-operations/pinocchio (stdlib, via node prepare.mjs) → same fixture, same size
  • solana config get still reported devnet after both

prettier --check passes on all 8 files.

Every `prepare.mjs` that pulls a program fixture from mainnet ran
`solana config set -um` first, which writes mainnet into
`~/.config/solana/cli/config.yml` and leaves it there. A plain `pnpm install`
was therefore enough to silently repoint a developer's CLI, and the `deploy`
scripts in these examples take no cluster flag, so a later deploy would follow
it to mainnet.

Passing `-um` to `solana program dump` scopes the cluster to that one command
instead. Verified for both script styles (zx and stdlib) with the global config
on devnet: the fixtures still download from mainnet and `solana config get` is
unchanged afterwards.
@MarkFeder
MarkFeder requested a review from dev-jodee as a code owner September 1, 2026 10:31
@greptile-apps

greptile-apps Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR scopes mainnet selection to each fixture download instead of mutating the developer’s global Solana CLI configuration.

  • Removes solana config set -um from eight token-example preparation scripts.
  • Passes -um directly to solana program dump in both zx and Node stdlib implementations.
  • Preserves the developer-selected cluster for subsequent CLI operations such as deployment.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete correctness, security, or compatibility issues identified.

The changes consistently replace a persistent global CLI mutation with a command-scoped cluster option, and the supplied verification confirms both invocation styles still download the expected fixture without altering the configured cluster.

Important Files Changed

Filename Overview
tokens/create-token/anchor/prepare.mjs Replaces the persistent cluster configuration change with a command-scoped mainnet flag while preserving fixture output and error handling.
tokens/create-token/native/prepare.mjs Applies the same safe command-scoped fixture download behavior to the native create-token example.
tokens/nft-operations/anchor/prepare.mjs Downloads the metadata fixture from mainnet without changing the global CLI target.
tokens/nft-operations/pinocchio/prepare.mjs Correctly applies command-scoped mainnet selection in the distinct Node execSync implementation.
tokens/pda-mint-authority/anchor/prepare.mjs Removes the global configuration side effect while retaining the existing fixture preparation flow.
tokens/pda-mint-authority/native/prepare.mjs Scopes mainnet selection to the fixture dump command with no other behavioral change.
tokens/transfer-tokens/anchor/prepare.mjs Preserves mainnet fixture retrieval without repointing later Solana CLI commands.
tokens/transfer-tokens/native/prepare.mjs Uses the per-command mainnet flag consistently with the other zx-based preparation scripts.

Reviews (1): Last reviewed commit: "chore: dump fixtures without rewriting t..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant