Skip to content

Allow vanity keypairs - #127

Merged
MarkSackerberg merged 4 commits into
mainfrom
feat/vanityKeypairs
Jul 10, 2026
Merged

Allow vanity keypairs#127
MarkSackerberg merged 4 commits into
mainfrom
feat/vanityKeypairs

Conversation

@MarkSackerberg

Copy link
Copy Markdown
Contributor

This adds a --mint-keypair for minting and asset creation to allow previously minted vanity keypairs to be passed in.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@MarkSackerberg, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 26 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d9e4be62-a652-4b94-9873-f52a6e33171c

📥 Commits

Reviewing files that changed from the base of the PR and between 56d3cab and cc811c4.

📒 Files selected for processing (9)
  • src/commands/core/asset/create.ts
  • src/commands/core/collection/create.ts
  • src/commands/tm/create.ts
  • src/lib/mint-keypair.ts
  • test/commands/genesis/genesis.integration.test.ts
  • test/commands/genesis/genesis.presale.test.ts
  • test/commands/genesis/genesis.withdraw.test.ts
  • test/commands/genesis/genesishelpers.ts
  • test/helpers/temp-keypair-file.ts

Walkthrough

Adds a shared mintKeypairFlag/resolveMintSigner helper enabling an optional --mint-keypair CLI flag across bg collection, core asset, core collection, tm, and toolbox token create commands, so signers can be loaded from a provided keypair file instead of always generating a new one. Includes a test helper for temporary keypair files and corresponding tests. A flaky genesis test is separately skipped.

Changes

Mint keypair flag rollout

Layer / File(s) Summary
Shared mint-keypair helpers
src/lib/mint-keypair.ts, test/helpers/temp-keypair-file.ts
Adds mintKeypairFlag (oclif file flag) and resolveMintSigner(umi, path), plus createTempKeypairFile test helper that generates and writes a temp keypair JSON file with cleanup.
Bubblegum collection create signer flow
src/commands/bg/collection/create.ts, test/commands/bg/bg.collection.create.test.ts
Registers --mint-keypair flag and resolves the collection signer via resolveMintSigner; adds a test asserting the created collection ID matches the provided keypair.
Core asset create signer flow
src/commands/core/asset/create.ts, test/commands/core/core.create.test.ts
Adds --mint-keypair flag/description and applies resolveMintSigner across wizard, file-based, and simple asset-creation paths; adds a test verifying the asset ID matches the keypair.
Core collection create signer flow
src/commands/core/collection/create.ts, test/commands/core/core.collection.create.test.ts
Adds --mint-keypair flag/description and applies resolveMintSigner across wizard, file-based, and name/URI paths; adds a test verifying the collection ID matches the keypair.
Token Metadata create signer flow
src/commands/tm/create.ts, test/commands/tm/tm.create.test.ts
Adds --mint-keypair flag/description, threads mintKeypairPath through wizard, file-based, URI, and manual metadata paths, updates createNftFromArgs fallback logic, and adds a test verifying the minted mint address.
Toolbox token create signer flow
src/commands/toolbox/token/create.ts
Adds --mint-keypair flag/description and threads mintKeypairPath through createTokenWithMetadata/createToken for wizard and non-wizard flows.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Genesis Test Stabilization

Layer / File(s) Summary
Skip flaky genesis rewards test
test/commands/genesis/genesis.claim-creator-rewards.test.ts
Converts a devnet-dependent "no buckets" test to it.skip with an explanatory comment.

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant CreateCommand
  participant resolveMintSigner
  participant Umi

  CLI->>CreateCommand: run() with optional --mint-keypair
  CreateCommand->>resolveMintSigner: resolveMintSigner(umi, path)
  alt path provided
    resolveMintSigner-->>CreateCommand: signer loaded from file
  else no path
    resolveMintSigner->>Umi: generateSigner(umi)
    Umi-->>resolveMintSigner: new signer
    resolveMintSigner-->>CreateCommand: generated signer
  end
  CreateCommand-->>CLI: asset/collection/token/NFT created
Loading

Suggested reviewers: blockiosaurus, tonyboylehub

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding support for vanity keypairs.
Description check ✅ Passed The description is directly related to the changeset and mentions the new --mint-keypair option.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/vanityKeypairs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/lib/mintKeypair.ts (1)

1-7: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Rename file to satisfy unicorn/filename-case.

Static analysis flags this filename as not kebab-case.

🔧 Suggested fix

Rename src/lib/mintKeypair.tssrc/lib/mint-keypair.ts and update the corresponding import paths in src/commands/bg/collection/create.ts, src/commands/core/asset/create.ts, src/commands/tm/create.ts, and src/commands/toolbox/token/create.ts.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/mintKeypair.ts` around lines 1 - 7, The filename for the mint keypair
flag module is not kebab-case, so rename the module from mintKeypair to
mint-keypair to satisfy unicorn/filename-case. Update the import references for
mintKeypairFlag in src/commands/bg/collection/create.ts,
src/commands/core/asset/create.ts, src/commands/tm/create.ts, and
src/commands/toolbox/token/create.ts so they point to the new filename.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/commands/bg/collection/create.ts`:
- Around line 12-14: Fix the lint errors in create by reordering the imports in
the top of the file and the object keys in the flagged object literal to match
the project’s sorting rules. In src/commands/bg/collection/create.ts, adjust the
import block containing generateSigner, mintKeypairFlag, and
createSignerFromPath so it is in the expected order, and update the object near
the create command logic so its keys are declared in the correct sorted order.
Use the create command and the related flag/object definitions as the reference
points when making the changes.

In `@src/commands/core/asset/create.ts`:
- Line 10: The lint failures in the asset create command need cleanup: adjust
the import ordering in the module so it matches the expected sort, reorder the
flag/object properties so mint-keypair appears before pluginsFile, and remove
the unnecessary await from the affected async call(s). Use the create command
implementation in create.ts and the related option/object construction spots to
update all reported occurrences.

In `@src/commands/core/collection/create.ts`:
- Line 125: The signer-selection ternary is duplicated in
`handleFileBasedCreation` and the other collection creation branches, so move
`mintKeypairPath ? await createSignerFromPath(mintKeypairPath) :
generateSigner(umi)` into a small private helper like
`resolveCollectionSigner(umi, mintKeypairPath?)`. Update
`handleFileBasedCreation` and the wizard/name-URI branches to call that helper
so the fallback logic lives in one place and future changes only need to be made
once.
- Around line 6-7: Fix the lint-only style issues in create.ts: reorder the
imports so the new block follows the existing import sort rules around
mintKeypairFlag and createSignerFromPath, adjust the object/flag definition in
createCommand so mint-keypair is placed according to the required key order, and
remove the unnecessary await from the return in the create flow where no
additional async work is needed.

In `@src/commands/tm/create.ts`:
- Around line 13-14: Fix the import/flag ordering lint issue in the create
command by reordering the related declarations in the tm/create.ts module.
Update the imports and flag definitions around mintKeypairFlag and
createSignerFromPath so the mint-keypair entry comes before type, matching the
required sort order used elsewhere in the file and in the other reported
location.

In `@src/commands/toolbox/token/create.ts`:
- Around line 12-13: Reorder the imports in the token create command so they
follow the project’s import sorting conventions, keeping mintKeypairFlag and
createSignerFromPath grouped correctly. Also remove the redundant await in the
create flow where createSignerFromPath is used, since it is not returning a
promise; update the surrounding logic in the create token command to call it
directly and keep the rest of the signer creation path unchanged.

In `@src/lib/mintKeypair.ts`:
- Around line 3-6: Extract the repeated mint-signer selection logic into a
shared helper in mintKeypair.ts and use it everywhere instead of duplicating the
path ? createSignerFromPath(path) : generateSigner(umi) pattern. Add a
resolveMintSigner(umi, path) function near mintKeypairFlag, then update the call
sites in collection create, asset create, tm create, and token create to call it
directly with flags['mint-keypair'] so any future changes to signer resolution
happen in one place.

In `@test/commands/bg/bg.collection.create.test.ts`:
- Around line 32-56: The vanity-keypair setup in this test duplicates the same
generate/write/run/cleanup flow used in other create specs, so extract it into a
shared test helper in a common utils module. Add a helper around the repeated
`createUmi`, `generateSigner`, temp-file write, and cleanup steps (for example,
a `createTempKeypairFile` helper returning the signer, path, and cleanup) and
update this `bg.collection.create` test plus the matching `core.create`,
`core.collection.create`, and `tm.create` specs to use it.

---

Outside diff comments:
In `@src/lib/mintKeypair.ts`:
- Around line 1-7: The filename for the mint keypair flag module is not
kebab-case, so rename the module from mintKeypair to mint-keypair to satisfy
unicorn/filename-case. Update the import references for mintKeypairFlag in
src/commands/bg/collection/create.ts, src/commands/core/asset/create.ts,
src/commands/tm/create.ts, and src/commands/toolbox/token/create.ts so they
point to the new filename.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7e5278de-f42d-4df8-aaaa-3f7f5e37a10e

📥 Commits

Reviewing files that changed from the base of the PR and between 6d1094a and bfc1086.

📒 Files selected for processing (11)
  • src/commands/bg/collection/create.ts
  • src/commands/core/asset/create.ts
  • src/commands/core/collection/create.ts
  • src/commands/tm/create.ts
  • src/commands/toolbox/token/create.ts
  • src/lib/mintKeypair.ts
  • test/commands/bg/bg.collection.create.test.ts
  • test/commands/core/core.collection.create.test.ts
  • test/commands/core/core.create.test.ts
  • test/commands/genesis/genesis.claim-creator-rewards.test.ts
  • test/commands/tm/tm.create.test.ts

Comment thread src/commands/bg/collection/create.ts Outdated
Comment thread src/commands/core/asset/create.ts Outdated
Comment thread src/commands/core/collection/create.ts Outdated
Comment thread src/commands/core/collection/create.ts
Comment thread src/commands/tm/create.ts Outdated
Comment thread src/commands/toolbox/token/create.ts Outdated
Comment thread src/lib/mintKeypair.ts Outdated
Comment thread test/commands/bg/bg.collection.create.test.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/commands/bg/collection/create.ts (1)

32-48: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Flag-object key order still violates perfectionist/sort-objects lint rule.

Current static analysis reports mint-keypair must come before uri, but it's currently placed after uri (and after name). This will fail the lint gate.

🔧 Suggested fix
   static override flags = {
     name: Flags.string({
       description: 'Collection name',
       required: true,
     }),
+    'mint-keypair': mintKeypairFlag,
     uri: Flags.string({
       description: 'Collection metadata URI',
       required: true,
     }),
-    'mint-keypair': mintKeypairFlag,
     royalties: Flags.integer({
       description: 'Royalty percentage for secondary sales (0-100)',
       min: 0,
       max: 100,
       default: 0,
     }),
   }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands/bg/collection/create.ts` around lines 32 - 48, The flags object
in create.ts is still out of order for the perfectionist/sort-objects rule.
Reorder the entries in the static override flags definition so the keys are
sorted correctly, placing mint-keypair before uri while keeping the other flag
definitions in their expected order. Use the flags object on the create command
as the reference point when updating the key order.

Source: Linters/SAST tools

src/commands/core/asset/create.ts (1)

89-102: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Flag-object key order violates perfectionist/sort-objects.

Lint expects mint-keypair to come before offchain; it's currently placed after offchain.

🔧 Suggested fix
+    'mint-keypair': mintKeypairFlag,
     offchain: Flags.directory({
       name: 'offchain',
       description: 'path to JSON offchain metadata file to upload and assign to Asset',
       dependsOn: ['files'],
       exclusive: ['name', 'uri', 'wizard'],
       hidden: true,
     }),
     // Plugin configuration flags
-    'mint-keypair': mintKeypairFlag,
     plugins: Flags.boolean({
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands/core/asset/create.ts` around lines 89 - 102, The flag object in
the create command violates perfectionist/sort-objects because the keys are not
in the expected order; update the flags definition so the `mint-keypair` entry
in the `Flags` object is placed before `offchain`, keeping the rest of the flag
declarations in the linted order. Use the `mintKeypairFlag` and
`Flags.boolean`/`Flags.directory` definitions in
`src/commands/core/asset/create.ts` to locate and reorder the affected object
properties.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/commands/core/asset/create.ts`:
- Around line 6-7: Fix the import ordering in create.ts to satisfy the lint
rule: place the `@metaplex-foundation/umi` import before ora with the correct
blank-line grouping, and reorder the named imports so Umi comes before
publicKey. Keep the existing symbols like generateCoreExplorerUrl and
generateExplorerUrl in their current grouped import, and ensure the top-of-file
imports follow the project’s standard ordering consistently.

In `@src/commands/core/collection/create.ts`:
- Around line 161-163: The spinner started in the collection creation flow is
left running if resolveMintSigner(umi, mintKeypairPath) throws, so make signer
resolution use the same fail/cleanup path as the transaction execution. Update
the create flow in createCollection to wrap resolveMintSigner with try/catch (or
equivalent shared error handling), call spinner.fail() with a helpful message on
failure, and ensure the spinner is stopped before rethrowing or returning.

In `@src/commands/tm/create.ts`:
- Around line 161-162: Handle signer resolution before starting the NFT spinner
in all four create flows so a bad mint-keypair path cannot reject while the
spinner is still active. In the create command’s NFT/setup branches around
resolveMintSigner, either await resolveMintSigner(umi, mintKeypairPath) before
calling ora(...).start(), or wrap the resolution in its own try/catch and make
sure any failure always reaches fail()/succeed() cleanup. Apply the same fix to
each matching branch in create.ts so the spinner lifecycle is always closed.

In `@src/lib/mint-keypair.ts`:
- Around line 8-11: Add fail-fast validation to mintKeypairFlag by enabling file
existence checking on the Flags.file definition in mint-keypair.ts. The issue is
that the current flag accepts any string path and defers invalid-path failures
until createSignerFromPath, so update the shared mintKeypairFlag declaration to
validate that the file exists and surface an oclif CLI error immediately. This
change should be made in the mintKeypairFlag symbol so all commands that consume
it get the improved behavior automatically.

In `@test/helpers/temp-keypair-file.ts`:
- Line 15: The temp keypair filename generation in temp-keypair-file helper is
only using Date.now(), which can collide when tests run concurrently. Update the
mintKeypairPath creation to use a stronger unique identifier in addition to the
timestamp, and keep the existing cleanup() logic working against the exact file
created by this helper so parallel invocations do not overwrite or delete each
other’s temp data.

---

Outside diff comments:
In `@src/commands/bg/collection/create.ts`:
- Around line 32-48: The flags object in create.ts is still out of order for the
perfectionist/sort-objects rule. Reorder the entries in the static override
flags definition so the keys are sorted correctly, placing mint-keypair before
uri while keeping the other flag definitions in their expected order. Use the
flags object on the create command as the reference point when updating the key
order.

In `@src/commands/core/asset/create.ts`:
- Around line 89-102: The flag object in the create command violates
perfectionist/sort-objects because the keys are not in the expected order;
update the flags definition so the `mint-keypair` entry in the `Flags` object is
placed before `offchain`, keeping the rest of the flag declarations in the
linted order. Use the `mintKeypairFlag` and `Flags.boolean`/`Flags.directory`
definitions in `src/commands/core/asset/create.ts` to locate and reorder the
affected object properties.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d6da5dab-c0bf-4a9b-8145-acd92cc40e3b

📥 Commits

Reviewing files that changed from the base of the PR and between bfc1086 and 56d3cab.

📒 Files selected for processing (11)
  • src/commands/bg/collection/create.ts
  • src/commands/core/asset/create.ts
  • src/commands/core/collection/create.ts
  • src/commands/tm/create.ts
  • src/commands/toolbox/token/create.ts
  • src/lib/mint-keypair.ts
  • test/commands/bg/bg.collection.create.test.ts
  • test/commands/core/core.collection.create.test.ts
  • test/commands/core/core.create.test.ts
  • test/commands/tm/tm.create.test.ts
  • test/helpers/temp-keypair-file.ts

Comment thread src/commands/core/asset/create.ts Outdated
Comment thread src/commands/core/collection/create.ts Outdated
Comment thread src/commands/tm/create.ts Outdated
Comment thread src/lib/mint-keypair.ts
Comment thread test/helpers/temp-keypair-file.ts Outdated
@MarkSackerberg
MarkSackerberg merged commit 58504e2 into main Jul 10, 2026
3 checks passed
@MarkSackerberg
MarkSackerberg deleted the feat/vanityKeypairs branch July 10, 2026 16:25
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.

2 participants