Gọi bởi do_check_auth của ví trong lúc xác thực chữ ký — invoker là
chính ví nên smart_account.require_auth() bên trong tự thoả
(invoker auth, cùng khuôn recovery_rotate).
fn enforce(
env: soroban_sdk::Env,
context: Context,
authenticated_signers: soroban_sdk::Vec,
context_rule: ContextRule,
smart_account: soroban_sdk::Address,
)
Gọi bởi ví khi add_policy/add_context_rule (ví tự ký qua passkey).
Nhận Val vì hai đường install có shape params khác nhau; phân nhánh
theo kiểu rule — KHÔNG theo shape client gửi (fail-closed).
fn install(
env: soroban_sdk::Env,
install_params: soroban_sdk::Val,
context_rule: ContextRule,
smart_account: soroban_sdk::Address,
)
Gọi bởi ví khi remove_policy — dọn state của (ví, rule), cả hai đường.
fn uninstall(
env: soroban_sdk::Env,
context_rule: ContextRule,
smart_account: soroban_sdk::Address,
)
View: token đang bị đo trên rule Default (None = rule đó đi đường CallContract hoặc chưa install).
fn get_metered_token(
env: soroban_sdk::Env,
context_rule_id: u32,
smart_account: soroban_sdk::Address,
) -> Option
Đổi hạn mức — OZ đòi chính VÍ ký (smart_account.require_auth), tức là
passkey chủ ví; backend không có đường sửa.
fn set_spending_limit(
env: soroban_sdk::Env,
spending_limit_value: i128,
context_rule: ContextRule,
smart_account: soroban_sdk::Address,
)
View cho FE/BE: hạn mức + cửa sổ + tổng đã chi trong kỳ (chung 2 đường).
fn get_spending_limit_data(
env: soroban_sdk::Env,
context_rule_id: u32,
smart_account: soroban_sdk::Address,
) -> SpendingLimitData