Skip to content

Latest commit

 

History

History
279 lines (133 loc) · 9.13 KB

File metadata and controls

279 lines (133 loc) · 9.13 KB

Module 0x3::payment_revenue

Struct RevenueSource

Revenue source information for tracking and events

struct RevenueSource has copy, drop, store

Resource PaymentRevenueHub

Revenue management hub for each account Stores revenue earned through various sources separately from principal funds

struct PaymentRevenueHub has key

Struct RevenueHubCreatedEvent

Event emitted when a revenue hub is created

struct RevenueHubCreatedEvent has copy, drop

Struct RevenueDepositedEvent

Event emitted when revenue is deposited

struct RevenueDepositedEvent has copy, drop

Struct RevenueWithdrawnEvent

Event emitted when revenue is withdrawn

struct RevenueWithdrawnEvent has copy, drop

Constants

Insufficient revenue balance for withdrawal.

const ErrorInsufficientBalance: u64 = 1;

Invalid revenue source information.

const ErrorInvalidRevenueSource: u64 = 3;

Withdrawal amount must be greater than zero.

The revenue hub does not exist for this account.

const ErrorRevenueHubNotExists: u64 = 2;

Function get_revenue_hub_id

Get the revenue hub ID for an address

public fun get_revenue_hub_id(owner: address): object::ObjectID

Function revenue_hub_exists

Check if revenue hub exists for an address

public fun revenue_hub_exists(owner: address): bool

Function get_revenue_balance

Get revenue balance for a specific coin type

public fun get_revenue_balance<CoinType: key>(owner: address): u256

Function get_revenue_by_source

Get revenue balance by source type and coin type

public fun get_revenue_by_source(owner: address, source_type: string::String, coin_type: string::String): u256

Function create_revenue_hub

Create a revenue hub for the sender

public entry fun create_revenue_hub()

Function withdraw_revenue

Withdraw revenue to account coin store Future: This will support fee deduction

public fun withdraw_revenue<CoinType: store, key>(owner: &signer, amount: u256)

Function withdraw_revenue_entry

Entry function for withdrawing revenue

public entry fun withdraw_revenue_entry<CoinType: store, key>(owner: &signer, amount: u256)

Function deposit_revenue_generic

Deposit revenue from trusted modules (friend only)

Function withdraw_revenue_internal

Internal withdrawal for system modules (friend only) Future: This will be used by gas fee deduction or other system operations

public(friend) fun withdraw_revenue_internal<CoinType: key>(account: address, amount: u256): coin::Coin<CoinType>

Function preview_withdrawal_fee

Preview withdrawal fee (placeholder for future fee mechanism) Currently returns zero fee, will be implemented when RevenueConfig is added

public fun preview_withdrawal_fee<CoinType: key>(_owner: address, amount: u256): (u256, u256, u256)

Function create_revenue_source

Create a revenue source for tracking purposes