Skip to content

feat: implement dividend distribution and claim functionality for key holders#414

Open
syed-ghufran-hassan wants to merge 11 commits into
accesslayerorg:mainfrom
syed-ghufran-hassan:patch-3
Open

feat: implement dividend distribution and claim functionality for key holders#414
syed-ghufran-hassan wants to merge 11 commits into
accesslayerorg:mainfrom
syed-ghufran-hassan:patch-3

Conversation

@syed-ghufran-hassan

Copy link
Copy Markdown

Summary

  • Add distribute_dividend (callable by anyone) to deposit XLM, deduct protocol fee, and split the remainder proportionally among all current key holders of a creator.

  • Add claim_dividend for holders to withdraw accrued dividends; resets claimable balance to zero before transfer (reentrancy-safe).

  • Add get_claimable_dividend view to read unclaimed amounts for a (creator, holder) pair.

  • Maintain a HoldersList per creator, updated on buy/sell to efficiently iterate current holders for distributions.

  • Extend DataKey with HoldersList and DividendClaimable storage keys.

  • Append new error variants: ZeroClaimable, NoHolders, DividendAmountZero (at the end, preserving ABI).

  • Define and emit DividendDistributed and DividendClaimed events with stable fields.

  • Add corresponding error string constants in quote_view_errors.

  • Ensure holder list is kept in sync with key balance changes (add when balance goes 0→1, remove when 1→0).

Testing

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace

Checklist

  • Linked issue or backlog item
  • Added or updated creator-keys unit/integration tests for every changed contract behavior, including failure paths for new or reachable ContractError variants
  • Ran cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, and cargo test --workspace, or explained exactly why a command was not run
  • Reviewed persistent storage changes against docs/storage-key-invariants.md; any storage layout change includes a migration/backward-compatibility note
  • Confirmed event names, topic order, payload field order, and field meanings remain compatible with docs/contract-event-conventions.md, or documented the breaking change and versioning plan
  • Updated docs for any changed public contract interface, read-only method, event schema, storage behavior, fee logic, or deployment workflow
  • Scope stays limited to one contract concern and does not include unrelated formatting, lockfile, generated artifact, or dependency changes

… holders

- Add distribute_dividend (callable by anyone) to deposit XLM, deduct protocol fee, and split the remainder proportionally among all current key holders of a creator.

- Add claim_dividend for holders to withdraw accrued dividends; resets claimable balance to zero before transfer (reentrancy-safe).

- Add get_claimable_dividend view to read unclaimed amounts for a (creator, holder) pair.

- Maintain a HoldersList per creator, updated on buy/sell to efficiently iterate current holders for distributions.

- Extend DataKey with HoldersList and DividendClaimable storage keys.

- Append new error variants: ZeroClaimable, NoHolders, DividendAmountZero (at the end, preserving ABI).

- Define and emit DividendDistributed and DividendClaimed events with stable fields.

- Add corresponding error string constants in quote_view_errors.

- Ensure holder list is kept in sync with key balance changes (add when balance goes 0→1, remove when 1→0).

@syed-ghufran-hassan syed-ghufran-hassan left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Changes incorporated

@syed-ghufran-hassan syed-ghufran-hassan left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Changes incorporated

@syed-ghufran-hassan syed-ghufran-hassan left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Incorporaated changes

@syed-ghufran-hassan

Copy link
Copy Markdown
Author

r-contracts/pull/412/changes/88d267fca3266720369618b4ea02bd3483bab077 the event.rs file raised here as PR

@syed-ghufran-hassan syed-ghufran-hassan left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

changes incorporated

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.

1 participant