Skip to content

refactor: add opt fee payer to revoke and approve instructions#2306

Merged
ananas-block merged 2 commits intomainfrom
jorrit/refactor-add-opt-fee-payer-to-revoke-approve
Feb 20, 2026
Merged

refactor: add opt fee payer to revoke and approve instructions#2306
ananas-block merged 2 commits intomainfrom
jorrit/refactor-add-opt-fee-payer-to-revoke-approve

Conversation

@ananas-block
Copy link
Contributor

@ananas-block ananas-block commented Feb 20, 2026

  1. Account index constants restructured: Renamed APPROVE_PAYER_IDX/REVOKE_PAYER_IDX to OWNER_IDX and added separate FEE_PAYER_IDX constants (Approve:
    owner=2, fee_payer=4; Revoke: owner=1, fee_payer=3) with system program placement documented
  2. Generic function signatures expanded: Both handle_compressible_top_up and process_compressible_top_up now take three const generics (BASE_LEN, OWNER_IDX,
    FEE_PAYER_IDX) instead of two
  3. Payer fallback logic implemented: Changed from direct owner lookup to optional fee_payer with owner fallback (fee_payer.or(authority_payer))
  4. Documentation updated: Doc comments reflect new account layout with optional fee_payer and updated parameter descriptions

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of owner and fee-payer account references in token approval and revocation flows, ensuring correct fee assignment and more reliable transactions.
  • Documentation
    • Clarified instruction semantics for approve and revoke operations to reflect updated account roles.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 20, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Refactors approve/revoke instruction handling to separate an "owner" account and an optional "fee_payer" account. Constants and call sites were updated; handle_compressible_top_up and downstream calls now accept OWNER_IDX and FEE_PAYER_IDX, and payer selection uses fee_payer if present, otherwise owner. (≈38 added / 12 removed lines)

Changes

Cohort / File(s) Summary
Approve Instruction Index Updates
programs/compressed-token/program/src/ctoken/approve_revoke.rs
Replaced APPROVE_PAYER_IDX with APPROVE_OWNER_IDX (2) and APPROVE_FEE_PAYER_IDX (4). Updated process_ctoken_approve to call handle_compressible_top_up::<APPROVE_BASE_LEN, APPROVE_OWNER_IDX, APPROVE_FEE_PAYER_IDX>(...). Documentation comments adjusted.
Revoke Instruction Index Updates
programs/compressed-token/program/src/ctoken/approve_revoke.rs
Replaced REVOKE_PAYER_IDX with REVOKE_OWNER_IDX (1) and REVOKE_FEE_PAYER_IDX (3). Updated process_ctoken_revoke to call handle_compressible_top_up::<REVOKE_BASE_LEN, REVOKE_OWNER_IDX, REVOKE_FEE_PAYER_IDX>(...). Documentation comments adjusted.
Top-up Processing Function Refactor
programs/compressed-token/program/src/ctoken/approve_revoke.rs
Changed handle_compressible_top_up signature from (BASE_LEN, PAYER_IDX) to (BASE_LEN, OWNER_IDX, FEE_PAYER_IDX). Internal logic now resolves authority_payer (owner) and optional fee_payer; effective payer = fee_payer if present else owner. Updated nested calls and parameter docs accordingly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested reviewers

  • sergeytimoshin
  • SwenSchaeferjohann

Poem

Owner and fee, a duo now true,
Indexes shifted, clearer view,
Calls updated, logic neat,
Fee first if present — owner keeps the seat,
Small refactor, tidy and new ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding an optional fee payer parameter to the revoke and approve instructions, which aligns with the refactoring of instruction data semantics and constant reindexing throughout the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 70.00%.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jorrit/refactor-add-opt-fee-payer-to-revoke-approve

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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 `@programs/compressed-token/program/src/ctoken/approve_revoke.rs`:
- Around line 104-105: Doc comment for the account index constants is stale:
update the FEE_PAYER_IDX description near the OWNER_IDX/FEE_PAYER_IDX doc block
in approve_revoke.rs to read "(4 for approve, 3 for revoke)" (leave OWNER_IDX as
"2 for approve, 1 for revoke"); locate the doc comment that currently shows the
wrong values and replace only the FEE_PAYER_IDX tuple so the comment matches the
actual indexing used by handle_compressible_top_up and approve/revoke logic.
- Around line 75-76: The doc comment for FEE_PAYER_IDX has incorrect index
numbers; update the text to match the actual constants APPROVE_FEE_PAYER_IDX = 4
and REVOKE_FEE_PAYER_IDX = 3 (i.e. "4 for approve, 3 for revoke") so it no
longer mirrors the OWNER_IDX values and correctly documents the fee payer
account positions.

@ananas-block ananas-block merged commit 12bec0c into main Feb 20, 2026
28 checks passed
@ananas-block ananas-block deleted the jorrit/refactor-add-opt-fee-payer-to-revoke-approve branch February 20, 2026 18:48
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