Allow vanity keypairs - #127
Conversation
|
Warning Review limit reached
Next review available in: 26 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (9)
WalkthroughAdds a shared ChangesMint keypair flag rollout
Estimated code review effort: 3 (Moderate) | ~25 minutes Genesis Test Stabilization
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
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 winRename file to satisfy
unicorn/filename-case.Static analysis flags this filename as not kebab-case.
🔧 Suggested fix
Rename
src/lib/mintKeypair.ts→src/lib/mint-keypair.tsand update the corresponding import paths insrc/commands/bg/collection/create.ts,src/commands/core/asset/create.ts,src/commands/tm/create.ts, andsrc/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
📒 Files selected for processing (11)
src/commands/bg/collection/create.tssrc/commands/core/asset/create.tssrc/commands/core/collection/create.tssrc/commands/tm/create.tssrc/commands/toolbox/token/create.tssrc/lib/mintKeypair.tstest/commands/bg/bg.collection.create.test.tstest/commands/core/core.collection.create.test.tstest/commands/core/core.create.test.tstest/commands/genesis/genesis.claim-creator-rewards.test.tstest/commands/tm/tm.create.test.ts
There was a problem hiding this comment.
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 winFlag-object key order still violates
perfectionist/sort-objectslint rule.Current static analysis reports
mint-keypairmust come beforeuri, but it's currently placed afteruri(and aftername). 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 winFlag-object key order violates
perfectionist/sort-objects.Lint expects
mint-keypairto come beforeoffchain; it's currently placed afteroffchain.🔧 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
📒 Files selected for processing (11)
src/commands/bg/collection/create.tssrc/commands/core/asset/create.tssrc/commands/core/collection/create.tssrc/commands/tm/create.tssrc/commands/toolbox/token/create.tssrc/lib/mint-keypair.tstest/commands/bg/bg.collection.create.test.tstest/commands/core/core.collection.create.test.tstest/commands/core/core.create.test.tstest/commands/tm/tm.create.test.tstest/helpers/temp-keypair-file.ts
This adds a --mint-keypair for minting and asset creation to allow previously minted vanity keypairs to be passed in.