One-time setup. The caller becomes the admin AND the first profiled
member of the wallet. factory is the SobreFactory that deployed this
instance; upgrade() reads its current_sobre_wasm view to opt this
Sobre into the latest contract code without trusting the admin to
pass the right hash by hand.
fn init(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
payment_token: soroban_sdk::Address,
percents: soroban_sdk::Vec,
envelope_names: soroban_sdk::Vec,
wallet_name: soroban_sdk::String,
admin_name: soroban_sdk::String,
admin_emoji: soroban_sdk::String,
factory: soroban_sdk::Address,
)
Members-only. Routes through the configured SpendPolicy:
fn spend(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
envelope: Envelope,
amount: i128,
memo: soroban_sdk::String,
)
fn deposit(env: soroban_sdk::Env, from: soroban_sdk::Address, amount: i128)
Admin-only. Opt this Sobre into the factory's current SobreContract wasm. Same contract address, same storage, new code on the next call. Reads the target hash from the factory rather than taking it as an argument so the admin can't fat-finger a wrong or malicious wasm.
Trust assumption: whoever holds the factory's admin key controls what
wasm this Sobre adopts on upgrade(). Move the factory admin to a
multisig + timelock before mainnet.
fn upgrade(env: soroban_sdk::Env)
Polled by both dashboards every 2-3s. Returns admin, payment token, wallet name, envelope split + balances, profiled members, the active SpendPolicy, and the list of pending requests — in one call.
fn get_state(env: soroban_sdk::Env) -> WalletState
Admin-only. Replace the entire spending policy in one call. Any spend that lands AFTER this updates against the new policy immediately.
fn set_policy(env: soroban_sdk::Env, policy: SpendPolicy)
Self-service join used by the invite-link flow. Anyone with the link can call this until the 2-member cap is reached — the cap is the demo's safety net since the URL itself isn't authenticated.
fn join_wallet(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
name: soroban_sdk::String,
emoji: soroban_sdk::String,
)
Admin-only. Sweeps every envelope balance back to admin in a single SEP-41 transfer and zeroes the envelopes. The wallet remains callable — re-depositing would re-split per the current percentages — but for the demo this represents "closing the wallet."
fn close_wallet(env: soroban_sdk::Env)
Admin-only. Drop a pending request without transferring anything.
fn deny_request(env: soroban_sdk::Env, request_id: u64)
Auto-invoked on deploy_v2 with the constructor args, so the
SobreFactory can deploy + init atomically (no front-run window).
Manual deploys can still call init directly with the same args.
fn __constructor(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
payment_token: soroban_sdk::Address,
percents: soroban_sdk::Vec,
envelope_names: soroban_sdk::Vec,
wallet_name: soroban_sdk::String,
admin_name: soroban_sdk::String,
admin_emoji: soroban_sdk::String,
factory: soroban_sdk::Address,
)
Admin-only. Kicks a member out of the wallet. The admin cannot kick
themselves — close_wallet is the right tool for shutting down.
fn remove_member(env: soroban_sdk::Env, member: soroban_sdk::Address)
Admin-only. Overwrite the envelope percentage split. Only affects how FUTURE deposits are distributed — existing balances are untouched.
fn set_envelopes(env: soroban_sdk::Env, percents: soroban_sdk::Vec)
Admin-only. Execute a previously created pending request. Emits both
Spend (for the transfer) and RequestApproved (for correlation).
fn approve_request(env: soroban_sdk::Env, request_id: u64)
Admin-only. Renames the wallet (the "Pagunsan Family" string at the top of both dashboards).
fn set_wallet_name(env: soroban_sdk::Env, new_name: soroban_sdk::String)
Admin-only. Rename the three envelopes. Purely cosmetic — the on-chain
Envelope::Groceries|Tuition|Savings enum still indexes balances and
policies, so existing pending requests + balances stay valid.
fn set_envelope_names(
env: soroban_sdk::Env,
names: soroban_sdk::Vec,
)