OZContextRuleType
public enum OZContextRuleType : Sendable, Hashable
Type of context rule that determines which operations it applies to.
Context rules use pattern matching to determine when signers and policies should be enforced. Three types of context matching are supported:
- Default: Matches any operation (fallback rule)
- CallContract: Matches invocations to a specific contract address
- CreateContract: Matches contract deployments using a specific WASM hash
Example:
// Default rule applies to all operations
let defaultRule = OZContextRuleType.defaultRule
// Rule for calling a specific token contract
let tokenRule = OZContextRuleType.callContract(contractAddress: "CBCD1234...")
// Rule for deploying contracts with a specific WASM hash
let deployRule = OZContextRuleType.createContract(wasmHash: wasmHashData)
-
Matches any operation (fallback / default rule).
Declaration
Swift
case defaultRule -
Matches invocations to a specific contract address (
C…, 56 characters).Declaration
Swift
case callContract(contractAddress: String) -
Matches contract deployments using a specific 32-byte WASM hash.
Declaration
Swift
case createContract(wasmHash: Data) -
Declaration
Swift
public static func == (lhs: OZContextRuleType, rhs: OZContextRuleType) -> Bool -
Declaration
Swift
public func hash(into hasher: inout Hasher) -
Converts the context rule type to its on-chain
SCValXDRrepresentation.The on-chain representation is:
- Default:
SCValXDR.vec([Symbol("Default")]) - CallContract:
SCValXDR.vec([Symbol("CallContract"), Address(contractAddress)]) CreateContract:
SCValXDR.vec([Symbol("CreateContract"), Bytes(wasmHash)])
Throws
InvalidAddresswhen the call-contract address cannot be converted to anSCAddressXDR.Declaration
Swift
public func toScVal() throws -> SCValXDRReturn Value
The
SCValXDRrepresentation of this context rule type. - Default:
View on GitHub
Install in Dash