OZContractErrorCodes
public enum OZContractErrorCodes
Contract-level error codes from the OpenZeppelin smart account, WebAuthn verifier, and policy contracts.
When a contract rejects a call, the code appears inside the message of a
SmartAccountTransactionException (for example Error(Contract, #3016)). The SDK
surfaces the raw error but does not parse or map contract error codes itself; callers
can extract the code from the message and compare it against these constants, or
resolve it with the consumer-side decode(_:) and decodeFromMessage(_:) helpers.
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 -
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. -
Extracts and decodes the first known contract error code from an error
message.Soroban RPC surfaces contract failures as
Error(Contract, #NNNN)inside simulation and submission error strings (typically the message of a thrownSmartAccountTransactionException). 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