OZExternalWalletAdapter
public protocol OZExternalWalletAdapter : AnyObject, Sendable
Protocol for integrating external wallet adapters for multi-signer support.
External wallet adapters enable signing with external wallets like Freighter or Albedo for multi-signature smart accounts. They handle wallet connection and signature collection.
Example implementation:
final class FreighterAdapter: OZExternalWalletAdapter {
func connect() async throws -> OZConnectedWallet? {
return OZConnectedWallet(address: "G...", walletId: "freighter", walletName: "Freighter")
}
func signAuthEntry(
preimageXdr: String,
options: OZSignAuthEntryOptions?
) async throws -> OZSignAuthEntryResult {
// Decode preimage, hash with SHA-256, sign with Ed25519, return result.
}
// ... remaining members ...
}
-
connect()AsynchronousConnects to the external wallet, prompting the user to authorize via the wallet’s UI (for example a wallet selection modal).
Throws
SmartAccountWalletExceptionif connection fails.Declaration
Swift
func connect() async throws -> OZConnectedWallet?Return Value
The connected wallet info, or
nilif the user cancelled. -
disconnect()AsynchronousDisconnects all external wallets.
Throws
SmartAccountWalletExceptionif disconnection fails.Declaration
Swift
func disconnect() async throws -
disconnectByAddress(address:Default implementation, asynchronous) Disconnects a specific wallet by address. The default implementation is a no-op suitable for adapters that do not need per-address cleanup.
Default Implementation
Declaration
Swift
func disconnectByAddress(address: String) async throwsParameters
addressThe Stellar G-address of the wallet to disconnect.
-
signAuthEntry(preimageXdr:Asynchronousoptions: ) Signs an authorization preimage with the external wallet.
The SDK passes a base64-encoded
HashIDPreimageXDR. The wallet must:- Base64-decode the preimage bytes.
- SHA-256 hash the preimage bytes.
- Ed25519-sign the 32-byte hash.
- Return the 64-byte raw signature as base64.
The SDK handles auth-entry construction and signature format; the wallet only needs to produce the raw Ed25519 signature.
Throws
SmartAccountTransactionException.SigningFailedif signing fails or is rejected.Declaration
Swift
func signAuthEntry( preimageXdr: String, options: OZSignAuthEntryOptions? ) async throws -> OZSignAuthEntryResultParameters
preimageXdrThe base64-encoded
HashIDPreimageXDR to sign.optionsOptional signing options (network passphrase, specific address).
Return Value
The signing result with base64-encoded raw Ed25519 signature (64 bytes).
-
Returns all currently connected wallets with their addresses and identifiers.
Declaration
Swift
func getConnectedWallets() -> [OZConnectedWallet] -
Returns whether a specific address has a connected wallet that can sign for it.
Declaration
Swift
func canSignFor(address: String) -> Bool -
getWalletForAddress(address:Default implementation) Returns wallet info for a specific address, or
nilwhen not found.The default implementation returns
nil.Default Implementation
Declaration
Swift
func getWalletForAddress(address: String) -> OZConnectedWallet?
View on GitHub
Install in Dash