Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pallet partner attribution #920

Merged
merged 31 commits into from
Jan 31, 2025
Merged

Pallet partner attribution #920

merged 31 commits into from
Jan 31, 2025

Conversation

zees-dev
Copy link
Contributor

@zees-dev zees-dev commented Jan 23, 2025

Description

This PR introduces the Partner Attribution pallet which enables partner management and user attribution.
The pallet allows:

  • Registration of partners with associated account addresses (EOA's)
  • Management of partner accounts (update/remove)
  • User attribution to partners
  • Partner fee percentage management by privileged accounts
  • Fee accumulation tracking for partners

Context & Background

The Partner Attribution pallet is designed to support Futureverse's partner ecosystem by enabling:

  • A decentralized way to track and manage partner relationships
  • Attribution of user activities to specific partners
  • Fee distribution capabilities based on configurable percentages
  • Transparent tracking of accumulated partner fees

Key components:

  • Partner registration with owner and account management
  • User attribution system with update/removal capabilities
  • Privileged partner upgrades to set fee percentages
  • Storage for partner information and user attributions

Notes & Additional Information

Technical Implementation Details:

  • Partners are identified by unique incremental IDs
  • Partner info includes owner account, recipient account, fee percentage and accumulated fees
  • User attributions are stored in a dedicated mapping
  • Integration with Futurepass system for account verification
    • Note: Only futurepasses can be associated to registered partners
  • Fee percentages use Permill for precise percentage calculations
  • Error handling for invalid operations and unauthorized access

TODOs

  • Weight generation

Release Notes

Key Changes

Type of Change

  • Runtime Changes
  • Client Changes

API Changes

Storage Changes

Added

  • PartnerAttribution: NextPartnerId - increment-only unique partner id
  • PartnerAttribution: Partners - partner registration details
  • PartnerAttribution: Attributions - futurepass -> partner attributions

Extrinsic Changes

Added

  • PartnerAttribution: register_partner
  • PartnerAttribution: update_partner_account
  • PartnerAttribution: attribute_account
  • PartnerAttribution: upgrade_partner

Event Changes

Added

  • PartnerAttribution: PartnerRegistered
  • PartnerAttribution: PartnerUpdated
  • PartnerAttribution: PartnerRemoved
  • PartnerAttribution: PartnerUpgraded
  • PartnerAttribution: AccountAttributed

Error Messages

Added

  • PartnerAttribution: NoAvailableIds
  • PartnerAttribution: PartnerNotFound
  • PartnerAttribution: PartnerAlreadyExists
  • PartnerAttribution: Unauthorized
  • PartnerAttribution: CallerNotFuturepass
  • PartnerAttribution: AccountAlreadyAttributed

@zees-dev zees-dev requested a review from JasonTulp January 23, 2025 00:58
Copy link
Contributor

@JasonTulp JasonTulp left a comment

Choose a reason for hiding this comment

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

Looking good! Would be useful adding a test for the EnsureFuturepass logic. Need to run benchmarks

pallet/partner-attribution/src/lib.rs Outdated Show resolved Hide resolved
pallet/partner-attribution/src/lib.rs Outdated Show resolved Hide resolved
pallet/partner-attribution/src/lib.rs Outdated Show resolved Hide resolved
runtime/src/impls.rs Show resolved Hide resolved
pallet/partner-attribution/src/tests.rs Outdated Show resolved Hide resolved
pallet/partner-attribution/src/lib.rs Outdated Show resolved Hide resolved
pallet/partner-attribution/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@JasonTulp JasonTulp left a comment

Choose a reason for hiding this comment

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

Lgtm, nice work 🚀

Copy link
Contributor

@surangap surangap left a comment

Choose a reason for hiding this comment

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

lgtm👍 Added a minor comment.

@zees-dev zees-dev merged commit c666f24 into main Jan 31, 2025
@zees-dev zees-dev deleted the pallet-partner-attribution branch January 31, 2025 00:13
@JasonTulp JasonTulp mentioned this pull request Feb 3, 2025
4 tasks
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.

4 participants