Contract 1188f6b59eeb10f909340e356ec5929e16ada61cdb100d8699770b705a1a5a52

← Back to Index 📥 Download WASM

Meta

rssdkver 23.2.1#ab415a33cc1f6bdce20ac4a12f0ddbe41a648949
rsver 1.91.1

Instances

  • CCD6DLECYOLOGCHOCFNKULPFB7PZP5B3O2WCD4I4NXXQPVJMBMQHH4KI
  • CDBSEFSPOHNTIZ2EZ65PA3ONC5LS3XNQWMHQDDKH25CXQX5WQKLOSI6K

Interface

Returns the current nonce (for management operations)

fn get_nonce(env: soroban_sdk::Env) -> u64

Returns the EVM address that owns this wallet.

Panics

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:

  1. Verifies all provided signatures against their signers
  2. Finds applicable context rules for each authorization context
  3. Checks if policies allow the operation
  4. Enforces policies (state changes if any)

Arguments

  • signature_payload - Hash of the transaction/auth data being signed
  • signatures - Map of signers to their signatures
  • auth_contexts - List of contexts being authorized
fn __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.

Arguments

  • owner_evm_address - The 20-byte Ethereum address that will control this wallet
  • secp256k1_verifier - Address of the deployed Secp256k1Verifier contract
  • defindex_policy - Address of the deployed DeFindexPolicy contract
  • initial_wasm_hashes - List of allowed WASM hashes for the policy

Note

This creates a default context rule that:

  • Uses the secp256k1 verifier with owner's EVM address as key data
  • Attaches the DeFindex policy with the provided WASM hashes
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:

  • Stellar Asset Contracts (SAC) - native tokens
  • Contracts with WASM hash in the allowed list

Blocks:

  • All other contracts
  • Contract creation (unless WASM hash is allowed)
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>,
)

Imports

WebAssembly Text (WAT) ▶