Skip to content

revenue-distribution: register rewards integrations#113

Merged
karl-dz merged 3 commits intomainfrom
ms/1031
Apr 16, 2026
Merged

revenue-distribution: register rewards integrations#113
karl-dz merged 3 commits intomainfrom
ms/1031

Conversation

@martinsander00
Copy link
Copy Markdown
Contributor

Resolves: malbeclabs/infra#1031

Summary

  • Introduces the registration primitive for the forthcoming contributor-rewards-integration flow: external programs (first consumer: Shred Subscription) will be allowed to drive the Revenue Distribution program's contributor-rewards payout only if the admin has registered them here first.
  • Adds a new RewardsIntegration PDA (seeded by [b"rewards_integration", integration_program_id]) that records the integration program's pubkey.
  • Adds the admin-only InitializeRewardsIntegration instruction, which validates the integration program account is executable before writing the record.

Lines of Code

Section Added Removed
Core logic +175 -3
SDKs +0 -0
Tests +277 -3

Testing Verification

  • New test file initialize_rewards_integration_test.rs covers happy path, unauthorized signer, non-executable integration program, wrong PDA seeds, and double-registration.

…uction

Adds the admin-only InitializeRewardsIntegration instruction which
registers an external program as a rewards integration by creating a
RewardsIntegration PDA seeded by [b"rewards_integration", program_id].

This is the registration primitive that DistributeIntegrationRewards
will later use to verify that a CPI caller is authorized to drive
contributor reward payouts.
@martinsander00 martinsander00 requested a review from karl-dz as a code owner April 16, 2026 18:39
Comment thread programs/revenue-distribution/src/state/rewards_integration.rs Outdated
Comment thread programs/revenue-distribution/src/state/rewards_integration.rs Outdated
Comment thread programs/revenue-distribution/src/processor.rs Outdated
Comment thread programs/revenue-distribution/tests/initialize_rewards_integration_test.rs Outdated
Comment thread programs/revenue-distribution/CHANGELOG.md
Comment thread programs/revenue-distribution/src/processor.rs
Copy link
Copy Markdown
Contributor

@karl-dz karl-dz left a comment

Choose a reason for hiding this comment

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

Didn't mean to be confusing about the Custom(0) comment in the test. All I meant was we can match exactly to that error variant because that's what the system program reverts with for an already-created account

@karl-dz
Copy link
Copy Markdown
Contributor

karl-dz commented Apr 16, 2026

Can revisit removing the logic for checking an already-created account in a subsequent PR

@karl-dz karl-dz merged commit 0261628 into main Apr 16, 2026
7 checks passed
@karl-dz karl-dz deleted the ms/1031 branch April 16, 2026 19:54
karl-dz pushed a commit that referenced this pull request Apr 16, 2026
Follow-up to #113 (malbeclabs/infra#1031) addressing post-merge review
feedback.

## Summary
- Drops the redundant `owner == &ID` pre-check in
`try_initialize_rewards_integration`. Re-registration attempts already
fail via the system program's `AccountAlreadyInUse` revert inside
`try_create_account`, so the explicit check was duplicative.
- Tightens the double-registration test to assert exactly
`InstructionError::Custom(0)` — the serialized form of
`SystemError::AccountAlreadyInUse` — instead of the broader wildcard
match.

## Lines of Code
| Section | Added | Removed |
|---------|-------|---------|
| Core logic | +0 | -10 |
| SDKs | +0 | -0 |
| Tests | +3 | -3 |
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