CapsuleManager Class

The CapsuleManager class provides a Swift interface for the Capsule SDK, managing wallet operations, authentication, and transactions.

Properties

wallet
Wallet?

The current wallet associated with the CapsuleManager.

sessionState
CapsuleSessionState

The current session state of the Capsule SDK.

environment
CapsuleEnvironment

The environment configuration for the Capsule SDK.

apiKey
String

The API key used for authentication with Capsule services.

webView
WKWebView

The WebKit view used for handling web-based operations.

Methods

init(environment:apiKey:)
Function

Initializes a new CapsuleManager instance.

environment
CapsuleEnvironment

The environment to use for the Capsule SDK.

apiKey
String

The API key for authentication.

initCapsule()
Function

Initializes the Capsule SDK within the WebView.

checkIfUserExists(email:)
Function

Checks if a user exists with the given email.

email
String

The email to check.

exists
Bool

Whether the user exists.

createUser(email:)
Function

Creates a new user with the given email.

email
String

The email for the new user.

login(authorizationController:)
Function

Logs in a user using passkeys.

authorizationController
AuthorizationController

The authorization controller for handling passkey operations.

verify(verificationCode:)
Function

Verifies an email using a verification code.

verificationCode
String

The verification code sent to the user’s email.

biometricsId
String

The biometrics ID associated with the verification.

generatePasskey(email:biometricsId:authorizationController:)
Function

Generates a passkey for the user.

email
String

The user’s email.

biometricsId
String

The biometrics ID obtained from verification.

authorizationController
AuthorizationController

The authorization controller for handling passkey operations.

setup2FA()
Function

Sets up two-factor authentication for the user.

uri
String

The URI for setting up 2FA in an authenticator app.

enable2FA()
Function

Enables two-factor authentication for the user.

is2FASetup()
Function

Checks if 2FA is set up for the user.

isSetup
Bool

Whether 2FA is set up.

createWallet(skipDistributable:)
Function

Creates a new wallet for the user.

skipDistributable
Bool

Whether to skip distributable wallet creation.

fetchWallets()
Function

Fetches all wallets associated with the user.

wallets
[Wallet]

An array of user wallets.

signMessage(walletId:message:)
Function

Signs a message using the specified wallet.

walletId
String

The ID of the wallet to use for signing.

message
String

The message to sign.

signature
String

The signed message.

signTransaction(walletId:rlpEncodedTx:chainId:)
Function

Signs a transaction using the specified wallet.

walletId
String

The ID of the wallet to use for signing.

rlpEncodedTx
String

The RLP encoded transaction.

chainId
String

The chain ID of the network.

signature
String

The signed transaction.

sendTransaction(walletId:rlpEncodedTx:chainId:)
Function

Sends a transaction using the specified wallet.

walletId
String

The ID of the wallet to use for sending.

rlpEncodedTx
String

The RLP encoded transaction.

chainId
String

The chain ID of the network.

signature
String

The transaction signature.