Skip to content

Auto-detect Core asset vs collection for plugin add/update - #130

Merged
MarkSackerberg merged 4 commits into
mainfrom
cursor/auto-detect-plugin-collection-e1e4
Jul 24, 2026
Merged

Auto-detect Core asset vs collection for plugin add/update#130
MarkSackerberg merged 4 commits into
mainfrom
cursor/auto-detect-plugin-collection-e1e4

Conversation

@MarkSackerberg

@MarkSackerberg MarkSackerberg commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

mplx core plugins add and update previously assumed the address was an asset unless --collection was passed. Passing a collection address without the flag failed with Unable to fetch asset.

This change introduces resolveCoreAccount, which:

  1. Honors --collection as an explicit override (collection only)
  2. Otherwise resolves Asset vs Collection via a single getAccount + account Key check
  3. Surfaces a clear error if the address is neither (RPC/transport failures are not swallowed)

This mirrors the auto-detect pattern already used by genesis bucket fetch when --type is omitted.

Also prepends a 400k compute unit limit on Genesis create only (shared GENESIS_CREATE_COMPUTE_UNIT_LIMIT). Create was flaking on Node 24 CI with Computational budget exceeded at Solana's 200k default. A global CU limit was tried and rejected because it pushed near-full txs (e.g. add presale bucket) over the transaction size cap.

Replaces closed PR #129 (GitHub had stuck the PR head on an intermediate commit).

Usage

# Works for collections without --collection
mplx core plugins add <collectionPublicKey> ./plugin.json

# Explicit override still supported
mplx core plugins add <collectionPublicKey> ./plugin.json --collection

Test plan

Open in Web Open in Cursor 

cursoragent and others added 3 commits July 23, 2026 06:19
When adding or updating plugins, resolve the address as an asset first
and fall back to a collection instead of failing with "Unable to fetch
asset". The --collection flag remains as an explicit override.

Co-authored-by: MarkSackerberg <MarkSackerberg@users.noreply.github.com>
Genesis account creation can exceed Solana's 200k default compute
budget under Node 24 CI. Prepend setComputeUnitLimit (400k) in the
shared send path so heavier Metaplex transactions stop failing flakily.

Co-authored-by: MarkSackerberg <MarkSackerberg@users.noreply.github.com>
A global compute-unit limit pushed near-full transactions (e.g. add
presale bucket) over Solana's size cap. Scope the 400k CU limit to
Genesis initialize only, where create was flaking on the 200k default.

Co-authored-by: MarkSackerberg <MarkSackerberg@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Core plugin commands now auto-resolve asset or collection targets and pass the resolved type through add/update flows. Genesis initialization transactions now include a 400,000 compute-unit limit, with tests covering collection auto-detection.

Changes

Core account resolution

Layer / File(s) Summary
Resolve Core account types
src/lib/core/fetch/resolveCoreAccount.ts
Adds resolveCoreAccount with structured asset/collection results, optional forced collection resolution, and parent collection IDs.
Integrate resolution into plugin commands
src/commands/core/plugins/add.ts, src/commands/core/plugins/update.ts, test/commands/core/core.plugins.test.ts
Add and update commands use resolved account types in wizard and JSON flows, with tests for collection auto-detection without --collection.

Genesis compute budget

Layer / File(s) Summary
Add Genesis compute limit
src/commands/genesis/create.ts, src/lib/genesis/operations.ts
Prepends setComputeUnitLimit with 400,000 units to Genesis initialization transactions.

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

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant resolveCoreAccount
  participant CoreFetch
  participant PluginBatch
  CLI->>resolveCoreAccount: resolve target address
  resolveCoreAccount->>CoreFetch: fetch asset or collection
  CoreFetch-->>resolveCoreAccount: resolved account data
  resolveCoreAccount-->>CLI: isCollection and collectionId
  CLI->>PluginBatch: add or update plugins with resolved values
Loading

Possibly related PRs

Suggested reviewers: tonyboylehub

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly summarizes the main change: auto-detecting Core assets vs collections for plugin add/update.
Description check ✅ Passed The description is directly related to the changeset and accurately describes the Core auto-detection and Genesis compute-limit updates.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/auto-detect-plugin-collection-e1e4

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.

@cursor
cursor Bot force-pushed the cursor/auto-detect-plugin-collection-e1e4 branch from 2334cac to 87288dd Compare July 23, 2026 07:51
@MarkSackerberg
MarkSackerberg marked this pull request as ready for review July 23, 2026 07:57

@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: 6

🤖 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/plugins/add.ts`:
- Around line 57-60: Update the pluginSelector calls in
src/commands/core/plugins/add.ts lines 57-60 and
src/commands/core/plugins/update.ts lines 56-60 to combine the resolved
Asset/Collection filter with the authority-managed constraint, rather than
allowing managedBy to override filter. Ensure each wizard only presents plugins
matching both the requested plugin type and authority ownership.
- Around line 3-7: Fix lint ordering in src/commands/core/plugins/add.ts (lines
3-7 and 25-36) and src/commands/core/plugins/update.ts (lines 3-7 and 25-30):
reorder imports and imported specifiers, use the node:fs module specifier, order
static declarations consistently, and arrange flag properties according to the
project’s lint rules.

In `@src/lib/core/fetch/resolveCoreAccount.ts`:
- Around line 1-12: Resolve lint violations across the new core-account resolver
module: rename resolveCoreAccount.ts to kebab-case, update all command imports
and references to the renamed module, and correct import ordering, type/object
member ordering, and required blank-line padding. Use the existing symbols from
the resolver and its command consumers without changing behavior.
- Around line 38-55: The fetches in the account-resolution flow should not
convert RPC or network rejections into null results. Remove the catch handlers
from safeFetchAssetV1 and safeFetchCollectionV1, while preserving the existing
null checks and corresponding missing-account errors for genuinely absent Core
accounts.

In `@src/lib/genesis/operations.ts`:
- Around line 30-32: Use a single shared compute-unit limit: export
GENESIS_CREATE_COMPUTE_UNIT_LIMIT from src/lib/genesis/operations.ts at lines
30-32, then remove the duplicate declaration and import the shared constant in
src/commands/genesis/create.ts at lines 18-20.

In `@test/commands/core/core.plugins.test.ts`:
- Line 44: Update the added integration tests at the referenced timeout
declarations to use numeric separators, such as 30_000 or 45_000, and reorder
each destructuring pattern so code appears before stderr. Apply these lint fixes
consistently across all affected tests.
🪄 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 Plus

Run ID: c5e42161-0e37-41bb-be17-5ab3386f8727

📥 Commits

Reviewing files that changed from the base of the PR and between a3c03ae and 87288dd.

📒 Files selected for processing (6)
  • src/commands/core/plugins/add.ts
  • src/commands/core/plugins/update.ts
  • src/commands/genesis/create.ts
  • src/lib/core/fetch/resolveCoreAccount.ts
  • src/lib/genesis/operations.ts
  • test/commands/core/core.plugins.test.ts

Comment thread src/commands/core/plugins/add.ts
Comment thread src/commands/core/plugins/add.ts
Comment thread src/lib/core/fetch/resolveCoreAccount.ts
Comment thread src/lib/core/fetch/resolveCoreAccount.ts Outdated
Comment thread src/lib/genesis/operations.ts
Comment thread test/commands/core/core.plugins.test.ts
Resolve asset vs collection via a single getAccount + Key check so
RPC failures are not swallowed as missing accounts. Export the Genesis
create compute-unit limit from operations and reuse it in the command.

Co-authored-by: MarkSackerberg <MarkSackerberg@users.noreply.github.com>
@MarkSackerberg
MarkSackerberg merged commit ec1a36c into main Jul 24, 2026
3 checks passed
@MarkSackerberg
MarkSackerberg deleted the cursor/auto-detect-plugin-collection-e1e4 branch July 24, 2026 08:04
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.

3 participants