Skip to content

feat: anchor v1 support and backward compat#18

Merged
GabrielePicco merged 3 commits into
masterfrom
feat/anchor-v1-backward-compat
May 25, 2026
Merged

feat: anchor v1 support and backward compat#18
GabrielePicco merged 3 commits into
masterfrom
feat/anchor-v1-backward-compat

Conversation

@jonasXchen
Copy link
Copy Markdown
Contributor

@jonasXchen jonasXchen commented May 25, 2026

Problem

Enable support for Anchor v1 and backward compatibility

Solution

  • Version bumped 3.0.11 → 3.1.0.
  • Added workspace dep anchor-lang = ">=0.28, <2.0" — a broad range so the consumer's pin decides the actual version.
  • Added workspace proc-macro helpers (proc-macro2, quote, syn).
  • Replaced anchor-lang = "^0" with the broad-range workspace dep.
  • Removed path = "macros" next to workspace = true on session-keys-macros (was silently ignored, emitted warning).
  • Replaced use anchor_lang::system_program; with use anchor_lang::solana_program::{program::invoke, system_instruction};.
  • Both top-up transfer call sites now CPI through solana_program::program::invoke + system_instruction::transfer instead of CpiContext::new + system_program::transfer. This sidesteps the only Anchor 0.32 → 1.0 breaking change (CpiContext::new signature) — no anchor-compat feature needed.
  • Removed redundant path = "attribute" next to workspace = true on session-keys-macros-attribute.

Summary by CodeRabbit

  • Chores
    • Version bumped to 3.1.0
    • Updated workspace dependencies to align with new release
    • Refined dependency resolution for improved compatibility across projects

Review Change Stack

@jonasXchen jonasXchen requested a review from GabrielePicco May 25, 2026 05:21
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

Walkthrough

Workspace version bumped to 3.1.0 and internal session-keys* pins updated; Cargo manifests switched many dependencies to workspace-managed entries and added anchor-compat; program top-up transfers now use solana_program::invoke with system_instruction::transfer and target program accounts changed to UncheckedAccount; version_align.sh now only targets session-keys* lines.

Changes

Version, Dependencies, and Anchor Compatibility

Layer / File(s) Summary
Workspace version and dependency pins
Cargo.toml
Workspace package version updated to 3.1.0 and internal crate pins for session-keys* updated to =3.1.0.
Manifest workspace dependency consolidation
programs/gpl_session/Cargo.toml, programs/gpl_session/macros/Cargo.toml, programs/gpl_session/macros/attribute/Cargo.toml
anchor-lang and macro crate dependencies changed to { workspace = true }, session-keys-macros and session-keys-macros-attribute path overrides removed, proc-macro2/quote/syn consolidated to workspace resolution, and anchor-compat feature plus explanatory comments added.
Session token top-up and account types
programs/gpl_session/src/lib.rs, programs/gpl_session/macros/attribute/src/lib.rs
Top-up logic rewritten to use invoke(&system_instruction::transfer(...)) (with explicit accounts slice) instead of system_program::transfer via CPI; imports adjusted; target_program fields changed from AccountInfo<'info> to UncheckedAccount<'info>; derive helper attribute detection updated to attr.path().is_ident(\"session\").
Version alignment script narrowing
version_align.sh
version_align.sh sed logic narrowed to update only workspace dependency keys matching session-keys* rather than broadly editing [workspace.dependencies].

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 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 accurately summarizes the main changes: adding Anchor v1 support and backward compatibility through version bumps and dependency restructuring.
Description check ✅ Passed The description covers Problem, Solution, and includes necessary technical details about version bumps, dependency changes, and CPI implementation changes. All required sections from the template are adequately addressed.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/anchor-v1-backward-compat

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
Copy Markdown

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

🤖 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 `@version_align.sh`:
- Line 29: Update the sed invocation that edits Cargo.toml so it tolerates
varying whitespace around the dependency and version tokens: change the regex
used in the sed command that targets the session-keys dependency (the expression
beginning with /^session-keys[a-zA-Z0-9_-]* = / and the subsequent s/version =
"[^"]*"/...) to allow optional spaces around the equals signs (e.g., use
character classes or \s/[[:space:]]*/ for the spaces) and to match `version`
with optional whitespace before/after `=`; keep the same replacement value using
the shell $version variable and ensure the overall sed invocation name (the sed
line in version_align.sh) is updated accordingly so it won’t silently miss lines
like `version="..."` or `session-keys= "..."`.
🪄 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: c957ac9c-c4cc-4122-94d5-c55d636f8daf

📥 Commits

Reviewing files that changed from the base of the PR and between ac1ed07 and 7e3e596.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • Cargo.toml
  • programs/gpl_session/Cargo.toml
  • programs/gpl_session/macros/attribute/src/lib.rs
  • programs/gpl_session/src/lib.rs
  • version_align.sh

Comment thread version_align.sh
Copy link
Copy Markdown
Contributor

@GabrielePicco GabrielePicco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@GabrielePicco GabrielePicco merged commit a0e040b into master May 25, 2026
1 check passed
@GabrielePicco GabrielePicco deleted the feat/anchor-v1-backward-compat branch May 25, 2026 15:37
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