- Struct
RevenueSource - Resource
PaymentRevenueHub - Struct
RevenueHubCreatedEvent - Struct
RevenueDepositedEvent - Struct
RevenueWithdrawnEvent - Constants
- Function
get_revenue_hub_id - Function
revenue_hub_exists - Function
get_revenue_balance - Function
get_revenue_by_source - Function
create_revenue_hub - Function
withdraw_revenue - Function
withdraw_revenue_entry - Function
deposit_revenue_generic - Function
withdraw_revenue_internal - Function
preview_withdrawal_fee - Function
create_revenue_source
use 0x1::option;
use 0x1::signer;
use 0x1::string;
use 0x2::event;
use 0x2::object;
use 0x2::table;
use 0x2::tx_context;
use 0x2::type_info;
use 0x3::account_coin_store;
use 0x3::coin;
use 0x3::multi_coin_store;
Revenue source information for tracking and events
struct RevenueSource has copy, drop, store
Revenue management hub for each account Stores revenue earned through various sources separately from principal funds
struct PaymentRevenueHub has key
Event emitted when a revenue hub is created
struct RevenueHubCreatedEvent has copy, drop
Event emitted when revenue is deposited
struct RevenueDepositedEvent has copy, drop
Event emitted when revenue is withdrawn
struct RevenueWithdrawnEvent has copy, drop
Insufficient revenue balance for withdrawal.
const ErrorInsufficientBalance: u64 = 1;
Invalid revenue source information.
const ErrorInvalidRevenueSource: u64 = 3;
Withdrawal amount must be greater than zero.
const ErrorInvalidWithdrawalAmount: u64 = 4;
The revenue hub does not exist for this account.
const ErrorRevenueHubNotExists: u64 = 2;
Get the revenue hub ID for an address
public fun get_revenue_hub_id(owner: address): object::ObjectID
Check if revenue hub exists for an address
public fun revenue_hub_exists(owner: address): bool
Get revenue balance for a specific coin type
public fun get_revenue_balance<CoinType: key>(owner: address): u256
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
Create a revenue hub for the sender
public entry fun create_revenue_hub()
Withdraw revenue to account coin store Future: This will support fee deduction
public fun withdraw_revenue<CoinType: store, key>(owner: &signer, amount: u256)
Entry function for withdrawing revenue
public entry fun withdraw_revenue_entry<CoinType: store, key>(owner: &signer, amount: u256)
Deposit revenue from trusted modules (friend only)
public(friend) fun deposit_revenue_generic(account: address, coin: coin::GenericCoin, source: payment_revenue::RevenueSource)
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>
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)
Create a revenue source for tracking purposes
public fun create_revenue_source(source_type: string::String, source_id: option::Option<object::ObjectID>, description: string::String): payment_revenue::RevenueSource