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 by the lexicographic byte ordering of their keys’ XDR encoding.

    Soroban’s host enforces strict byte-lexicographic ordering of SCMap keys for canonicality and uniqueness checks. 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 whose keys encode to byte-equal sequences preserve their relative input order (stable sort), but byte-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 sorted by XDR-encoded key bytes in ascending order.