Returns the current nonce (for management operations)
fn get_nonce(env: soroban_sdk::Env) -> u64
Returns the EVM address that owns this wallet.
Panics with SmartWalletError::OwnerNotSet if owner is not initialized.
fn get_owner(env: soroban_sdk::Env) -> soroban_sdk::BytesN<20>
Adds a new policy to an existing context rule. This operation requires owner signature.
fn add_policy(
env: soroban_sdk::Env,
context_rule_id: u32,
policy: soroban_sdk::Address,
install_param: soroban_sdk::Val,
)
Main authorization entry point called by Soroban runtime.
This function:
signature_payload - Hash of the transaction/auth data being signedsignatures - Map of signers to their signaturesauth_contexts - List of contexts being authorizedfn __check_auth(
env: soroban_sdk::Env,
signature_payload: soroban_sdk::BytesN<32>,
signatures: Signatures,
auth_contexts: soroban_sdk::Vec,
) -> Result<(), SmartWalletError>
Constructs a new smart wallet with the given owner and initial configuration.
owner_evm_address - The 20-byte Ethereum address that will control this walletsecp256k1_verifier - Address of the deployed Secp256k1Verifier contractdefindex_policy - Address of the deployed DeFindexPolicy contractinitial_wasm_hashes - List of allowed WASM hashes for the policyThis creates a default context rule that:
fn __constructor(
env: soroban_sdk::Env,
owner_evm_address: soroban_sdk::BytesN<20>,
secp256k1_verifier: soroban_sdk::Address,
defindex_policy: soroban_sdk::Address,
initial_wasm_hashes: soroban_sdk::Vec>,
)
Removes a policy from a context rule. This operation requires owner signature.
fn remove_policy(
env: soroban_sdk::Env,
context_rule_id: u32,
policy: soroban_sdk::Address,
)
Adds a new context rule. This operation requires owner signature.
fn add_context_rule(
env: soroban_sdk::Env,
context_type: ContextRuleType,
name: soroban_sdk::String,
valid_until: Option,
signers: soroban_sdk::Vec,
policies: soroban_sdk::Map,
) -> ContextRule
Returns a context rule by ID
fn get_context_rule(env: soroban_sdk::Env, id: u32) -> ContextRule
Returns all context rules of a specific type
fn get_context_rules(
env: soroban_sdk::Env,
context_type: ContextRuleType,
) -> soroban_sdk::Vec
Removes a context rule. This operation requires owner signature.
fn remove_context_rule(env: soroban_sdk::Env, context_rule_id: u32)
Returns the number of context rules
fn get_context_rules_count(env: soroban_sdk::Env) -> u32
Enforcement hook - no state changes needed for this policy
fn enforce(
env: soroban_sdk::Env,
context: Context,
authenticated_signers: soroban_sdk::Vec,
context_rule: ContextRule,
smart_account: soroban_sdk::Address,
)
Installs the policy with the given allowed WASM hashes
fn install(
env: soroban_sdk::Env,
install_params: DeFindexPolicyParams,
context_rule: ContextRule,
smart_account: soroban_sdk::Address,
)
Uninstalls the policy, cleaning up storage
fn uninstall(
env: soroban_sdk::Env,
context_rule: ContextRule,
smart_account: soroban_sdk::Address,
)
Checks if the context is allowed by this policy.
Allows:
Blocks:
fn can_enforce(
env: soroban_sdk::Env,
context: Context,
authenticated_signers: soroban_sdk::Vec,
context_rule: ContextRule,
smart_account: soroban_sdk::Address,
) -> bool
Adds a WASM hash to the allowed list for a specific account and rule. Note: This should be called through the smart wallet's policy management.
fn add_allowed_hash(
env: soroban_sdk::Env,
smart_account: soroban_sdk::Address,
rule_id: u32,
wasm_hash: soroban_sdk::BytesN<32>,
)
Gets the list of allowed WASM hashes for a specific account and rule.
fn get_allowed_hashes(
env: soroban_sdk::Env,
smart_account: soroban_sdk::Address,
rule_id: u32,
) -> soroban_sdk::Vec>
Removes a WASM hash from the allowed list.
fn remove_allowed_hash(
env: soroban_sdk::Env,
smart_account: soroban_sdk::Address,
rule_id: u32,
wasm_hash: soroban_sdk::BytesN<32>,
)