Skip to content

feat(sdk): add approve/revoke delegation for light-token ATAs#2351

Merged
SwenSchaeferjohann merged 14 commits intomainfrom
feat/approve-revoke-light-token
Mar 21, 2026
Merged

feat(sdk): add approve/revoke delegation for light-token ATAs#2351
SwenSchaeferjohann merged 14 commits intomainfrom
feat/approve-revoke-light-token

Conversation

@tilo-14
Copy link
Member

@tilo-14 tilo-14 commented Mar 18, 2026

Summary

  • Add createLightTokenApproveInstruction (discriminator 4) and createLightTokenRevokeInstruction (discriminator 5) instruction builders matching Rust SDK account layout
  • Add approveInterface / revokeInterface async actions with cold loading + tx sending, following the transferInterface pattern
  • Add getLightTokenDelegate test helper and extend FrozenOperation type with 'approve' | 'revoke'
  • Export all new functions from src/index.ts and src/v3/unified/index.ts

Test plan

  • Unit tests: discriminator encoding, account meta order/flags, amount u64 LE encoding, separate fee payer handling (9 tests)
  • E2E tests: approve delegate, revoke delegate, overwrite delegate, non-owner rejection, separate fee payer (5 tests)
  • LIGHT_PROTOCOL_VERSION=V2 pnpm run build passes (all 5 bundles)
  • All 14 tests pass via LIGHT_PROTOCOL_VERSION=V2 npx vitest run tests/e2e/approve-revoke-light-token.test.ts

Open with Devin

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 18, 2026

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (24)
  • cli/package.json is excluded by none and included by none
  • js/compressed-token/CHANGELOG.md is excluded by none and included by none
  • js/compressed-token/package.json is excluded by none and included by none
  • js/compressed-token/rollup.config.js is excluded by none and included by none
  • js/compressed-token/src/index.ts is excluded by none and included by none
  • js/compressed-token/src/v3/actions/approve-interface.ts is excluded by none and included by none
  • js/compressed-token/src/v3/actions/index.ts is excluded by none and included by none
  • js/compressed-token/src/v3/get-account-interface.ts is excluded by none and included by none
  • js/compressed-token/src/v3/instructions/approve-interface.ts is excluded by none and included by none
  • js/compressed-token/src/v3/instructions/approve-revoke.ts is excluded by none and included by none
  • js/compressed-token/src/v3/instructions/index.ts is excluded by none and included by none
  • js/compressed-token/src/v3/unified/index.ts is excluded by none and included by none
  • js/compressed-token/tests/e2e/approve-revoke-light-token.test.ts is excluded by none and included by none
  • js/compressed-token/tests/e2e/approve-revoke-spl-t22.test.ts is excluded by none and included by none
  • js/compressed-token/tests/e2e/light-token-account-helpers.ts is excluded by none and included by none
  • js/compressed-token/tests/e2e/transfer-delegated-failures.test.ts is excluded by none and included by none
  • js/compressed-token/tests/e2e/transfer-delegated-interface.test.ts is excluded by none and included by none
  • js/compressed-token/tests/e2e/transfer-delegated-spl-t22.test.ts is excluded by none and included by none
  • js/compressed-token/tests/unit/approve-revoke-regressions.test.ts is excluded by none and included by none
  • js/stateless.js/CHANGELOG.md is excluded by none and included by none
  • js/stateless.js/package.json is excluded by none and included by none
  • js/stateless.js/rollup.config.js is excluded by none and included by none
  • js/stateless.js/src/utils/instruction.ts is excluded by none and included by none
  • js/stateless.js/tests/unit/utils/packed-accounts.test.ts is excluded by none and included by none

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 60700010-1663-4d92-9e63-7c41872c7887

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/approve-revoke-light-token

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.

@tilo-14 tilo-14 changed the title feat(compressed-token): add approve/revoke delegation for light-token ATAs feat(sdk): add approve/revoke delegation for light-token ATAs Mar 18, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

@tilo-14 tilo-14 force-pushed the feat/approve-revoke-light-token branch 2 times, most recently from 84166d7 to 13ab9fe Compare March 19, 2026 21:32
devin-ai-integration[bot]

This comment was marked as resolved.

tilo-14 added 5 commits March 20, 2026 00:34
… ATAs

Add TypeScript SDK functions to call the on-chain CTokenApprove (discriminator 4)
and CTokenRevoke (discriminator 5) instruction handlers for light-token associated
token accounts.

New files:
- instructions/approve-revoke.ts: sync instruction builders matching Rust SDK layout
- actions/approve-interface.ts: async actions with cold loading + tx sending
- tests/e2e/approve-revoke-light-token.test.ts: unit + E2E tests

Also adds getLightTokenDelegate helper and extends FrozenOperation type.
Avoid unnecessary getMintInterface RPC call when caller provides decimals.
Add transferDelegatedInterface action and unified wrapper, completing
the approve → transfer → revoke delegation flow for light-token ATAs.
Update transferDelegatedInterface and
createTransferDelegatedInterfaceInstructions to accept a recipient
wallet address instead of an explicit destination token account,
matching the transferInterface convention from PR #2354.

ATA derivation and idempotent creation now happen internally for
all programId variants (light-token, SPL, Token-2022).
@tilo-14 tilo-14 force-pushed the feat/approve-revoke-light-token branch from 13ab9fe to 81d9662 Compare March 20, 2026 00:35
tilo-14 added 2 commits March 20, 2026 15:27
…ner==feePayer E2E test

Add @remarks to approve/revoke functions documenting that for light-token
mints, all cold (compressed) balances are loaded into the hot ATA regardless
of the delegation amount. Add E2E test covering the owner==feePayer code
path which was previously only tested at the unit level.
@SwenSchaeferjohann SwenSchaeferjohann merged commit 0bd606e into main Mar 21, 2026
15 checks passed
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