Called when the signer is added to a smart account. Records the expiry ledger for this wallet.
fn on_add(env: soroban_sdk::Env, source: soroban_sdk::Address)
Called when the signer is revoked from a smart account. Cleans up the expiry data.
fn on_revoke(env: soroban_sdk::Env, source: soroban_sdk::Address)
Get the expiry data for a wallet. Returns None if wallet has no registered session.
fn get_expiry(
env: soroban_sdk::Env,
wallet: soroban_sdk::Address,
) -> Option
Initialize the policy contract with a custom duration. Can only be called once (by deployer).
duration_ledgers - Number of ledgers until expiry (e.g., 120960 for 7 days)fn initialize(env: soroban_sdk::Env, duration_ledgers: u32)
Check if a wallet's session signer has expired. This is a view function for frontend use.
true if expired or never registeredfalse if still validfn is_expired(env: soroban_sdk::Env, wallet: soroban_sdk::Address) -> bool
Get the configured duration in ledgers.
fn get_duration(env: soroban_sdk::Env) -> u32
Called during every signature verification. Returns false if the session has expired.
fn is_authorized(
env: soroban_sdk::Env,
source: soroban_sdk::Address,
_contexts: soroban_sdk::Vec,
) -> bool
Get remaining ledgers until expiry. Returns 0 if already expired or not registered.
fn remaining_ledgers(env: soroban_sdk::Env, wallet: soroban_sdk::Address) -> u32