OZContractErrorCodes
public enum OZContractErrorCodes
Contract-level error codes from the OpenZeppelin smart account, WebAuthn verifier, and policy contracts.
When a contract rejects a simulated call, the kit’s
SmartAccountTransactionException.SimulationFailed carries the contract error the
simulation reports as reportedContractError, taken from the host error or, when the host
masks it, from the diagnostic events; decodeFromSimulationFailure(_:) names it. The
code also appears in the exception’s message (for example Error(Contract, #3016)), where
decodeFromMessage(_:) finds it. decode(_:) resolves a raw code.
The named constants below cover the smart account contract’s own error enum — the
codes a caller is most likely to branch on. decode(_:) resolves any known code
(smart account, WebAuthn, or a policy contract) into its contract and variant name.
-
The referenced context rule does not exist on the account.
Declaration
Swift
public static let contextRuleNotFound: Int -
The invocation context could not be validated against the account’s context rules.
Declaration
Swift
public static let unvalidatedContext: Int -
An external signer’s verifier contract rejected the signature.
Declaration
Swift
public static let externalVerificationFailed: Int -
A context rule must have at least one signer or one policy.
Declaration
Swift
public static let noSignersAndPolicies: Int -
The context rule’s
valid_untilledger has already passed.Declaration
Swift
public static let pastValidUntil: Int -
The referenced signer is not present on the context rule.
Declaration
Swift
public static let signerNotFound: Int -
The signer is already present on the context rule.
Declaration
Swift
public static let duplicateSigner: Int -
The referenced policy is not installed on the context rule.
Declaration
Swift
public static let policyNotFound: Int -
The policy is already installed on the context rule.
Declaration
Swift
public static let duplicatePolicy: Int -
The context rule exceeds the maximum number of signers.
Declaration
Swift
public static let tooManySigners: Int -
The context rule exceeds the maximum number of policies.
Declaration
Swift
public static let tooManyPolicies: Int -
Integer arithmetic overflow occurred in the contract.
Declaration
Swift
public static let mathOverflow: Int -
The
key_datafield on a signer exceeds the maximum allowed size.Declaration
Swift
public static let keyDataTooLarge: Int -
The number of context rule IDs in the auth payload does not match the expected count.
Declaration
Swift
public static let contextRuleIdsLengthMismatch: Int -
A name field (e.g. context rule name) exceeds the maximum allowed length.
Declaration
Swift
public static let nameTooLong: Int -
The signer is not authorized to sign the given context rule.
Declaration
Swift
public static let unauthorizedSigner: Int -
A Delegated signer’s address is the contract of a context being authorized.
Declaration
Swift
public static let delegatedSignerIsContextContract: Int -
A Delegated signer’s address is the smart account itself.
Declaration
Swift
public static let selfDelegatedSigner: Int -
Decodes a raw contract error
codeinto the OZ contract and variant name that defined it, ornilifcodeis not a known OZ smart-account contract error.Declaration
Swift
public static func decode(_ code: Int) -> OZContractError?Parameters
codeThe numeric contract error code to decode.
Return Value
The decoded
OZContractError, ornilfor unknown codes. -
Decodes the contract error a simulation failure reports.
Reads only
failure.reportedContractError; the message is not searched, so an unknown reported code givesnileven when the message names a known one. The selection behind the reported code is a heuristic, and a code of a contract outside the OpenZeppelin suite can collide with a known code; seeReportedContractError.Declaration
Swift
public static func decodeFromSimulationFailure( _ failure: SmartAccountTransactionException.SimulationFailed ) -> OZContractError?Parameters
failureThe simulation failure thrown by the kit.
Return Value
The decoded
OZContractError, ornilwhen the failure reports no code or an unknown one. -
Extracts and decodes the first known contract error code from an error
message.Contract failures appear as
Error(Contract, #NNNN)inside simulation and submission error strings (typically the message of a thrownSmartAccountTransactionException, including the contract error suffix the kit appends when the host error masks the code). This scans the message for such markers and returns the first one whose code is a known OZ smart-account contract error, ornilwhen the message isnil, carries no marker, or carries only unknown codes.Declaration
Swift
public static func decodeFromMessage(_ message: String?) -> OZContractError?Parameters
messageThe error message to scan.
Return Value
The decoded
OZContractError, ornilwhen no known code is found.
View on GitHub
Install in Dash