OZBuilders

public enum OZBuilders

Builder utilities for OpenZeppelin smart account context rules.

Provides type-safe constructors and display utilities for OZContextRuleType and related OZ-specific operations. These functions are separated from OZSmartAccountBuilders to avoid a circular dependency between core and OZ types.

OZBuilders is a caseless enum used as a namespace; it cannot be instantiated.

Context Rule Type Builders

  • Creates a default context rule type.

    Default rules match any operation.

    Declaration

    Swift

    public static func createDefaultContextType() -> OZContextRuleType

    Return Value

    defaultRule for default authorization.

  • Creates a call-contract context rule type.

    Call-contract rules apply only when invoking a specific contract. Useful for restricting signers to specific dApps or operations.

    Throws

    InvalidAddress if the contract address format is invalid.

    Declaration

    Swift

    public static func createCallContractContextType(contractAddress: String) throws -> OZContextRuleType

    Parameters

    contractAddress

    Contract address this rule applies to (C…).

    Return Value

    An callContract(contractAddress:) configured for the supplied contract.

  • Creates a create-contract context rule type from a hex-encoded WASM hash.

    Create-contract rules apply only when deploying contracts with a specific WASM hash.

    Throws

    InvalidInput when the hex string is not exactly 64 characters after stripping any 0x prefix or when it contains non-hex characters.

    Declaration

    Swift

    public static func createCreateContractContextType(wasmHashHex: String) throws -> OZContextRuleType

    Parameters

    wasmHashHex

    WASM hash as a 64-character hex string (an optional 0x prefix is accepted and stripped).

    Return Value

    An createContract(wasmHash:) for the supplied hash.

  • Creates a create-contract context rule type from raw WASM hash bytes.

    Create-contract rules apply only when deploying contracts with a specific WASM hash.

    Throws

    InvalidInput when wasmHash is not exactly 32 bytes.

    Declaration

    Swift

    public static func createCreateContractContextType(wasmHash: Data) throws -> OZContextRuleType

    Parameters

    wasmHash

    32-byte WASM hash.

    Return Value

    An createContract(wasmHash:) for the supplied hash.

  • Creates a create-contract context rule type for deployments from a CAP-0085 executable reference.

    The rule applies only when deploying contracts from the WASM hash that the owner contract stores under tag. The hash is resolved at deployment time, so the rule trusts the owner contract to keep the reference pointing at acceptable code. An account build without this rule kind, such as stellar-accounts 0.7, rejects it during simulation.

    Example:

    let contextType = try OZBuilders.createCreateContractExternalRefContextType(
        owner: "CDEF5678...",
        tag: "account-v1"
    )
    

    Throws

    InvalidAddress when owner is not a valid contract address.

    Declaration

    Swift

    public static func createCreateContractExternalRefContextType(
        owner: String,
        tag: String
    ) throws -> OZContextRuleType

    Parameters

    owner

    Contract address (C…) that stores the executable reference.

    tag

    The tag the reference is stored under.

    Return Value

    An createContractExternalRef(owner:tag:) for the supplied owner and tag.

Signer Inspection Utilities