Add genesis claim-creator-rewards command - #124
Conversation
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.
|
Warning Rate limit exceeded
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 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 configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughAdds a dependency bump for ChangesDependency Update
Genesis Claim Command + Support
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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. Review rate limit: 0/1 reviews remaining, refill in 40 minutes and 46 seconds.Comment |
There was a problem hiding this comment.
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
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (2)
package.jsonsrc/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.
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
src/commands/genesis/claim-creator-rewards.ts
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.
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
src/commands/genesis/claim-creator-rewards.tssrc/lib/util.tstest/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.
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
New
mplx genesis claim-creator-rewardscommand 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
claimCreatorRewardsSDK function.