fn has_role(
env: soroban_sdk::Env,
account: soroban_sdk::Address,
role: soroban_sdk::Symbol,
) -> Option
fn get_admin(env: soroban_sdk::Env) -> Option
Get a user's current level.
user - Address to queryThe user's level as u32 (0=Rookie, 1=Bronze, 2=Silver, 3=Gold, 4=Diamond)
fn get_level(env: soroban_sdk::Env, user: soroban_sdk::Address) -> u32
Get a user's total points.
user - Address to queryThe user's total points
fn get_points(env: soroban_sdk::Env, user: soroban_sdk::Address) -> u32
fn grant_role(
env: soroban_sdk::Env,
account: soroban_sdk::Address,
role: soroban_sdk::Symbol,
caller: soroban_sdk::Address,
)
Get the config role symbol.
fn config_role(env: soroban_sdk::Env) -> soroban_sdk::Symbol
fn revoke_role(
env: soroban_sdk::Env,
account: soroban_sdk::Address,
role: soroban_sdk::Symbol,
caller: soroban_sdk::Address,
)
Record a reputation event for a user.
Requires the "recorder" role.
caller - Address initiating the record (must have recorder role)user - Address receiving the reputation pointsevent_type - Type of event being recordedThe user's new total points
fn record_event(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
user: soroban_sdk::Address,
event_type: EventType,
) -> u32
Initialize the Reputation contract.
admin - Address that will have admin privileges and can grant rolesnft_contract - Optional NFT contract address for integrationError::AlreadyInitialized - If the contract has already been initializedfn __constructor(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
nft_contract: Option,
)
Get the recorder role symbol.
fn recorder_role(env: soroban_sdk::Env) -> soroban_sdk::Symbol
fn renounce_role(
env: soroban_sdk::Env,
role: soroban_sdk::Symbol,
caller: soroban_sdk::Address,
)
fn get_role_admin(
env: soroban_sdk::Env,
role: soroban_sdk::Symbol,
) -> Option
fn renounce_admin(env: soroban_sdk::Env)
fn set_role_admin(
env: soroban_sdk::Env,
role: soroban_sdk::Symbol,
admin_role: soroban_sdk::Symbol,
)
Calculate what level a given point total would achieve.
points - Point total to evaluateThe level as u32
fn calculate_level(env: soroban_sdk::Env, points: u32) -> u32
fn get_role_member(
env: soroban_sdk::Env,
role: soroban_sdk::Symbol,
index: u32,
) -> soroban_sdk::Address
Get a user's event history.
user - Address to queryVector of ReputationEventRecord
fn get_user_events(
env: soroban_sdk::Env,
user: soroban_sdk::Address,
) -> soroban_sdk::Vec
Check if a user meets a permission threshold.
user - Address to checkthreshold_type - Type of threshold to check againstTrue if user's level meets or exceeds the threshold
fn meets_threshold(
env: soroban_sdk::Env,
user: soroban_sdk::Address,
threshold_type: ThresholdType,
) -> bool
Set the NFT contract address for integration.
Only admin can call this function.
caller - Admin addressnft_address - NFT contract addressfn set_nft_contract(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
nft_address: soroban_sdk::Address,
)
Register a user's NFT token ID.
Requires the "recorder" role.
caller - Address initiating the registration (must have recorder role)user - User addresstoken_id - NFT token ID to registerfn register_user_nft(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
user: soroban_sdk::Address,
token_id: u32,
)
Get the point threshold for a specific level.
level - Level to query (0-4)Points required for that level
fn get_level_threshold(env: soroban_sdk::Env, level: u32) -> u32
fn transfer_admin_role(
env: soroban_sdk::Env,
new_admin: soroban_sdk::Address,
live_until_ledger: u32,
)
Set level thresholds.
Requires the "config" role.
caller - Address initiating the update (must have config role)thresholds - Map of level (u32) to point thresholdfn set_level_thresholds(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
thresholds: soroban_sdk::Map,
)
fn accept_admin_transfer(env: soroban_sdk::Env)
Get the point value for a specific event type.
event_type - Event type to queryPoints awarded for that event type
fn get_event_point_value(env: soroban_sdk::Env, event_type: EventType) -> u32
fn get_role_member_count(env: soroban_sdk::Env, role: soroban_sdk::Symbol) -> u32
Get the NFT token ID registered for a user.
user - Address to queryOption containing the token ID if registered
fn get_user_nft_token_id(
env: soroban_sdk::Env,
user: soroban_sdk::Address,
) -> Option
Set event point values.
Requires the "config" role.
caller - Address initiating the update (must have config role)event_points - Map of EventType to point valuefn set_event_point_values(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
event_points: soroban_sdk::Map,
)
Record a reputation event with custom points.
Requires the "recorder" role.
caller - Address initiating the record (must have recorder role)user - Address receiving the reputation pointsevent_type - Type of event being recordedpoints - Custom points to awardThe user's new total points
Error::InvalidPoints - If points is 0Error::PointsOverflow - If adding points would overflowfn record_event_with_points(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
user: soroban_sdk::Address,
event_type: EventType,
points: u32,
) -> u32
Set a permission threshold.
Requires the "config" role.
caller - Address initiating the update (must have config role)threshold_type - Type of threshold to setlevel - Required level (0-4)fn set_permission_threshold(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
threshold_type: ThresholdType,
level: u32,
)