OZSmartAccountBuilders
public enum OZSmartAccountBuilders
Builder utilities for OpenZeppelin smart-account signers.
Provides type-safe constructors for creating signers and inspection helpers used by the higher-level smart-account managers. Includes:
- Signer builders for delegated, external, WebAuthn, and Ed25519 signers.
- Signer inspection (type checks, type description, credential and address extraction).
- Signer matching (by credential ID, by address, equality).
- Signer deduplication.
-
Creates a delegated signer for a native Stellar account.
Delegated signers use Stellar’s native
require_auth()mechanism; no external verifier contract is needed.Declaration
Swift
public static func createDelegatedSigner(publicKey: String) throws -> OZDelegatedSignerParameters
publicKeyStellar account or contract address (
G…orC…strkey).Return Value
An
OZDelegatedSignerfor use in context rules. -
Creates an external signer that delegates verification to a custom contract.
Used for WebAuthn passkeys, Ed25519 with custom logic, and other non-native schemes.
Throws
SmartAccountValidationException.InvalidAddresswhenverifierAddressis not valid;SmartAccountValidationException.InvalidInputwhenkeyDatais empty.Declaration
Swift
public static func createExternalSigner( verifierAddress: String, keyData: Data ) throws -> OZExternalSignerParameters
verifierAddressContract address (
C…strkey) of the signature verifier.keyDataPublic-key bytes plus any auxiliary authentication data; must not be empty.
Return Value
An
OZExternalSignerfor use in context rules. -
Creates a WebAuthn passkey signer.
Convenience wrapper around
createExternalSignerthat handles thekeyDataformat for WebAuthn (publicKey || credentialId).Throws
SmartAccountValidationException.InvalidAddresswhen the verifier address is invalid;SmartAccountValidationException.InvalidInputwhen the public key size or shape is wrong, or when the credential ID is empty.Declaration
Swift
public static func createWebAuthnSigner( webauthnVerifierAddress: String, publicKey: Data, credentialId: Data ) throws -> OZExternalSignerParameters
webauthnVerifierAddressWebAuthn verifier contract address (
C…strkey).publicKey65-byte secp256r1 uncompressed public key (
0x04prefix + X + Y).credentialIdWebAuthn credential identifier bytes; must not be empty.
Return Value
An
OZExternalSignerconfigured for WebAuthn verification. -
Creates an Ed25519 signer that delegates verification to a custom contract.
The key data is the 32-byte Ed25519 public key.
Throws
SmartAccountValidationException.InvalidAddresswhen the verifier address is invalid;SmartAccountValidationException.InvalidInputwhen the public key is not 32 bytes.Declaration
Swift
public static func createEd25519Signer( ed25519VerifierAddress: String, publicKey: Data ) throws -> OZExternalSignerParameters
ed25519VerifierAddressEd25519 verifier contract address (
C…strkey).publicKey32-byte Ed25519 public key.
Return Value
An
OZExternalSignerconfigured for Ed25519 verification. -
Extracts the credential ID from a WebAuthn signer’s key data.
WebAuthn signers store key data as: 65-byte uncompressed public key followed by the credential ID. Returns
nilfor non-WebAuthn signers (delegated signers, or external signers whose key data is not longer than 65 bytes).Declaration
Swift
public static func getCredentialIdFromSigner(signer: any OZSmartAccountSigner) -> Data?Parameters
signerSigner to inspect.
Return Value
Credential ID bytes, or
nilfor non-WebAuthn signers. -
Returns the WebAuthn credential ID as a Base64URL-encoded string, or
nilfor non-WebAuthn signers.Declaration
Swift
public static func getCredentialIdStringFromSigner(signer: any OZSmartAccountSigner) -> String?Parameters
signerSigner to inspect.
Return Value
Base64URL-encoded credential ID string, or
nil. -
Undocumented
Declaration
Swift
public static func isDelegatedSigner(signer: any OZSmartAccountSigner) -> Bool -
Undocumented
Declaration
Swift
public static func isExternalSigner(signer: any OZSmartAccountSigner) -> Bool -
Returns
truewhensigneris a WebAuthn signer whose credential ID matches the given rawcredentialIdbytes.Declaration
Swift
public static func signerMatchesCredential( signer: any OZSmartAccountSigner, credentialId: Data ) -> Bool -
Returns
truewhensigneris a WebAuthn signer whose credential ID, encoded as Base64URL, equalscredentialId.The caller-supplied
credentialIdis normalised by stripping trailing=padding before comparison so padded and unpadded Base64URL spellings of the same credential match. The signer-derived id is already unpadded.Declaration
Swift
public static func signerMatchesCredentialId( signer: any OZSmartAccountSigner, credentialId: String ) -> Bool -
Returns
truewhensigneris anOZDelegatedSignerwhose address equalsaddress.Declaration
Swift
public static func signerMatchesAddress( signer: any OZSmartAccountSigner, address: String ) -> Bool -
Compares two signers by type and field values.
For delegated signers compares the address. For external signers compares the verifier address and the byte content of the key data.
Declaration
Swift
public static func signersEqual( _ a: any OZSmartAccountSigner, _ b: any OZSmartAccountSigner ) -> Bool -
Returns the unique-key string for
signer. Equivalent tosigner.uniqueKey.Declaration
Swift
public static func getSignerKey(signer: any OZSmartAccountSigner) -> String -
Returns a list of unique signers preserving the first occurrence of each duplicate.
Uses
getSignerKeyto determine uniqueness; subsequent duplicates are discarded.Declaration
Swift
public static func collectUniqueSigners( signers: [any OZSmartAccountSigner] ) -> [any OZSmartAccountSigner]Parameters
signersSource list (may contain duplicates).
Return Value
List of unique signers in insertion order.
View on GitHub
Install in Dash