Skip to content

Add genesis claim-creator-rewards command - #124

Merged
MarkSackerberg merged 5 commits into
mainfrom
feat/genesis-claim-creator-rewards
May 5, 2026
Merged

Add genesis claim-creator-rewards command#124
MarkSackerberg merged 5 commits into
mainfrom
feat/genesis-claim-creator-rewards

Conversation

@MarkSackerberg

Copy link
Copy Markdown
Contributor

New mplx genesis claim-creator-rewards command that calls the Genesis API to claim accrued creator rewards across all bonding-curve and Raydium CPMM buckets where a wallet is the creator fee recipient. Pre-fetches buckets via GPA and prints pending amounts (formatted as SOL when quote is wSOL) before sending. The configured signer always pays fees so --wallet <other> works for claiming on behalf of another recipient.

Bumps @metaplex-foundation/genesis to ^0.36.1 for the claimCreatorRewards SDK function.

New `mplx genesis claim-creator-rewards` command that calls the Genesis API
to claim accrued creator rewards across all bonding-curve and Raydium CPMM
buckets where a wallet is the creator fee recipient. Pre-fetches buckets via
GPA and prints pending amounts (formatted as SOL when quote is wSOL) before
sending. The configured signer always pays fees so `--wallet <other>` works
for claiming on behalf of another recipient.

Bumps @metaplex-foundation/genesis to ^0.36.1 for the `claimCreatorRewards`
SDK function.
@coderabbitai

coderabbitai Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@MarkSackerberg has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 40 minutes and 46 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 132f87d0-11c5-4c8d-ad65-3198a5322dff

📥 Commits

Reviewing files that changed from the base of the PR and between 74aa037 and c9d57a7.

📒 Files selected for processing (1)
  • src/commands/genesis/claim-creator-rewards.ts

Walkthrough

Adds a dependency bump for @metaplex-foundation/genesis and a new oclif transaction command genesis claim-creator-rewards that queries Genesis for claimable creator rewards, prints a preview, signs and submits claim transactions, and returns confirmations and bucket previews. Also exposes DEVNET_RPC_URL and updates DUMMY_UMI to use it, and adds tests for the new command.

Changes

Dependency Update

Layer / File(s) Summary
Manifest
package.json
Bumps @metaplex-foundation/genesis from ^0.35.0 to ^0.36.1.

Genesis Claim Command + Support

Layer / File(s) Summary
Constants & Types
src/commands/genesis/claim-creator-rewards.ts
Adds NO_REWARDS_MESSAGE, creator-fee wallet offsets, WSOL mint constant, and ClaimablePreview interface.
CLI wiring / Input validation
src/commands/genesis/claim-creator-rewards.ts
New oclif GenesisClaimCreatorRewards class (extends TransactionCommand) with flags (wallet, network, apiUrl), wallet validation/resolution, network/api resolution, and payer signer selection.
API call / Error handling
src/commands/genesis/claim-creator-rewards.ts
Calls claimCreatorRewards; treats Genesis API error message No rewards available to claim (and empty transactions) as no-op returning empty result.
Preview collection
src/commands/genesis/claim-creator-rewards.ts
Adds fetchClaimablePreview that queries BondingCurveBucketV2 and RaydiumCpmmBucketV2 filtered by creator-fee recipient, computes pending = creatorFeeAccrued - creatorFeeClaimed, filters non-positive, and derives quoteMint.
Output formatting
src/commands/genesis/claim-creator-rewards.ts
Adds printPreview, getQuoteMint, formatAmount, and formatLamports helpers; formats WSOL in SOL and groups totals by quoteMint.
Transaction execution
src/commands/genesis/claim-creator-rewards.ts
Signs each claim transaction with payer signer, sends via umi.rpc.sendTransaction using allowed commitment (processed
Devnet RPC constant & dummy umi
src/lib/util.ts
Adds exported DEVNET_RPC_URL and updates DUMMY_UMI to use it (createUmi(DEVNET_RPC_URL)).
Tests
test/commands/genesis/genesis.claim-creator-rewards.test.ts
New tests run the CLI against devnet API: (1) valid system wallet yields “No rewards to claim” and includes wallet in output; (2) invalid --wallet flag exits non-zero with a validation error. Includes runner helper runCliRaw and ANSI stripping for stable assertions.

Sequence Diagram(s)

sequenceDiagram
    participant User as User/CLI
    participant Cmd as claim-creator-rewards
    participant GenesisAPI as Genesis API
    participant RPC as Solana RPC
    participant Blockchain as Blockchain

    User->>Cmd: Run command (--wallet, --network, --apiUrl)
    Cmd->>Cmd: Validate wallet & determine network
    Cmd->>GenesisAPI: Request claimCreatorRewards (and fetch bucket accounts)
    alt No rewards available
        GenesisAPI-->>Cmd: Error "No rewards available to claim" or empty txs
        Cmd-->>User: Print info and return empty result
    else Rewards available
        GenesisAPI-->>Cmd: Bucket data & claim transactions
        Cmd->>Cmd: Prepare and sign each tx with payer signer
        loop For each transaction
            Cmd->>RPC: sendTransaction
            RPC-->>Blockchain: Submit tx
            Cmd->>RPC: confirmTransaction (blockhash strategy)
            RPC-->>Cmd: Confirmation result
        end
        Cmd-->>User: Print previews, explorer links, and return signatures
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • tonyboylehub
  • blockiosaurus
  • nhanphan
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main feature being added: a new genesis claim-creator-rewards command. It directly matches the primary change in the changeset.
Description check ✅ Passed The description is well-detailed and directly related to the changeset, explaining the command's purpose, functionality, wallet handling, and dependency bump.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/genesis-claim-creator-rewards

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
Review rate limit: 0/1 reviews remaining, refill in 40 minutes and 46 seconds.

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

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/commands/genesis/claim-creator-rewards.ts`:
- Around line 92-95: The early-return for the no-claimable path returns {
claimed: 0, wallet } which differs from the success return shape; update both
empty branches (the block around the spinner.info at the top and the later block
around lines 160-169) to return the same schema as the successful path (include
buckets and signatures arrays alongside claimed and wallet) so --json consumers
always get the same fields (e.g., buckets: [], signatures: [], claimed: 0,
wallet: wallet.toString()) and keep spinner.info messages unchanged.
- Around line 104-107: The call to claimCreatorRewards currently uses
this.context.umi.identity.publicKey and a local wallet, bypassing
TransactionCommand's signer/payer hooks; replace those with the command context
signers so transactions respect configured payer/signing flows—pass
this.context.payer as the payer and this.context.signer (or
this.context.signer.publicKey where a PublicKey is required) instead of
this.context.umi.identity and the local wallet in the claimCreatorRewards
invocation(s) (see the call around claimCreatorRewards and the similar block at
lines 132-145) so the TransactionCommand context is used for signing and
building transactions.
🪄 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: fa33a4ce-330b-46f1-be99-64d25c04d94a

📥 Commits

Reviewing files that changed from the base of the PR and between b702f55 and 0015f8a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • package.json
  • src/commands/genesis/claim-creator-rewards.ts

Comment thread src/commands/genesis/claim-creator-rewards.ts Outdated
Comment thread src/commands/genesis/claim-creator-rewards.ts
- Use this.context.signer / this.context.payer instead of umi.identity so
  asset-signer, --payer, and ledger flows sign correctly.
- Unify the JSON return shape between the empty and success paths so --json
  consumers always get { buckets, signatures, wallet }.
- Call the API before the GPA preview and treat the preview as informational
  only — Raydium buckets can have uncollected pool fees the API sweeps up
  even when the bucket-tracked accrued is zero.

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/commands/genesis/claim-creator-rewards.ts`:
- Around line 117-120: The call to fetchClaimablePreview is currently allowed to
throw and abort the command; change it to be non-blocking by wrapping the await
this.fetchClaimablePreview(this.context.umi, wallet) call in a try/catch inside
the code path where printPreview is invoked, so any RPC/GPA error is caught,
logged (or ignored) and execution continues to the claim logic; specifically,
keep using this.fetchClaimablePreview and this.printPreview but catch exceptions
from fetchClaimablePreview, set claimable to an empty array (or undefined) on
error, and ensure the subsequent claim execution path still runs regardless of
preview failures.
🪄 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: cca15aa4-cbec-42cd-88e0-e8933516a520

📥 Commits

Reviewing files that changed from the base of the PR and between 0015f8a and 4d1e6c6.

📒 Files selected for processing (1)
  • src/commands/genesis/claim-creator-rewards.ts

Comment thread src/commands/genesis/claim-creator-rewards.ts Outdated
Wrap fetchClaimablePreview in try/catch so a GPA/RPC failure during the
informational preview step doesn't abort the claim — by that point the API
has already returned valid transactions and we shouldn't throw them away.
Two tests against the live devnet API at api.metaplex.dev:
- no-rewards path: hits the API with the system program pubkey and asserts
  the friendly "No rewards to claim" message.
- client-side --wallet validation: rejects an invalid pubkey before any
  network call.

Extracts DEVNET_RPC_URL in src/lib/util.ts (already used inline by
DUMMY_UMI) so the new test can reuse it without re-hardcoding the URL.

Spawns the CLI directly rather than via runCli — the existing helper
auto-injects a localnet RPC that would override --network solana-devnet
at the CLI level. Mirrors the inline pattern already used by
test/commands/core/core.asset-signer.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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/commands/genesis/claim-creator-rewards.ts`:
- Around line 82-87: Before building/fetching claims, verify the selected
SvmNetwork (variable network from flags.network or
detectSvmNetwork(this.context.chain)) matches the network implied by the
connected RPC (derive rpcNetwork via detectSvmNetwork(this.context.chain) or
equivalent); if they differ, throw/exit with a clear error asking the user to
either point the CLI to the correct RPC or pass --network to match the RPC.
Apply this guard immediately after computing network and before constructing
apiConfig or fetching claims (references: network, flags.network,
detectSvmNetwork, this.context.chain, apiConfig, getDefaultApiUrl) so the
command fails fast on mismatched RPC/network combos.

In `@test/commands/genesis/genesis.claim-creator-rewards.test.ts`:
- Around line 30-45: The devnet-dependent test "reports no rewards for a wallet
with no buckets (devnet API)" is flaky and should be opt-in; guard it with an
integration env var such as process.env.RUN_GENESIS_INTEGRATION. Update the test
body in genesis.claim-creator-rewards.test.ts (the it(...) that calls runCliRaw
with SYSTEM_PROGRAM, DEVNET_RPC_URL, KEYPAIR_PATH) to early-skip when the var is
not set (e.g., if (!process.env.RUN_GENESIS_INTEGRATION) this.skip()) or wrap
the entire it in a conditional so the invalid-wallet case remains in the default
suite while this live devnet smoke test only runs when the env var is present.
🪄 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: 5beea9f3-0873-47ef-aa47-54fe75eae309

📥 Commits

Reviewing files that changed from the base of the PR and between 4d1e6c6 and 74aa037.

📒 Files selected for processing (3)
  • src/commands/genesis/claim-creator-rewards.ts
  • src/lib/util.ts
  • test/commands/genesis/genesis.claim-creator-rewards.test.ts

Comment thread src/commands/genesis/claim-creator-rewards.ts
Comment thread test/commands/genesis/genesis.claim-creator-rewards.test.ts
Fail fast when the connected RPC and the resolved Genesis API network
disagree, so users get a clear error instead of confusing tx submission
failures:

- Localnet RPC errors out — the API only supports mainnet and devnet.
- Explicit --network that disagrees with the detected RPC cluster errors
  out with both values surfaced.
@MarkSackerberg
MarkSackerberg merged commit 649e0ff into main May 5, 2026
4 of 5 checks passed
@MarkSackerberg
MarkSackerberg deleted the feat/genesis-claim-creator-rewards branch May 5, 2026 19:56
tonyboylehub pushed a commit to metaplex-foundation/developer-hub that referenced this pull request May 19, 2026
Adds a cli.sh example showing the new `mplx genesis claim-creator-rewards`
command and registers `cli` in the example-request code-tabs across
en/ja/ko/zh so the docs page renders a CLI tab alongside Umi and cURL.
Regenerates the bundled index.js via scripts/build-examples.js.

The recommended-SDK tab keeps frameworks="umi" since the SDK guidance
is umi-only.

CLI command: metaplex-foundation/cli#124
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