OZPolicyManager

public final class OZPolicyManager : OZManagerHelpers, @unchecked Sendable

Manager for policy operations on OpenZeppelin Smart Accounts.

Adds and removes policies on context rules. A context rule may carry up to maxPolicies policies; every attached policy must be satisfied for a transaction to authorize.

Built-in conveniences: addSimpleThreshold, addWeightedThreshold, addSpendingLimit. For custom policy contracts, pass encoded SCValXDR install params to addPolicy(contextRuleId:policyAddress:installParams:selectedSigners:forceMethod:).

All state-changing methods accept an optional selectedSigners list. An empty list routes through the single-signer path (connected passkey); a non-empty list routes through the multi-signer ceremony coordinator.

Example:

let result = try await kit.policyManager.addSimpleThreshold(
    contextRuleId: 0,
    policyAddress: "CBCD1234...",
    threshold: 2
)

Initialization

ScMap key sorting

  • Sorts a list of SCMapEntryXDR entries into the Soroban host’s ScMap key order.

    The host stores and validates ScMap keys in a semantic order (see compareScValHostOrder) and rejects a map materialized from an out-of-order SCVal argument. Use this helper whenever a dynamically-keyed map is built from caller-supplied data so the on-chain shape is deterministic regardless of insertion order.

    The supplied list is not mutated; a new sorted list is returned. Two entries with equal keys preserve their relative input order (stable sort), but equal keys signal a duplicate-key bug and the on-chain host rejects such maps at simulation time.

    Declaration

    Swift

    public static func sortMapByKeyXdr(
        _ entries: [SCMapEntryXDR]
    ) -> [SCMapEntryXDR]

    Parameters

    entries

    Entries to sort.

    Return Value

    A new array of entries whose keys are in the host’s ScMap key order.