Skip to main content

Configuration

Ignore unsupported blockchains

If BeaconWalletClient encounters a structure that belongs to a blockchain that hasn't been registered in the client, it's considered an error by default and the client may fail at runtime. Usually, this means the developer has made an error and forgot to configure the client with that blockchain.

Sometimes, however, such situations aren't the result of a developer error and shouldn't cause the app to crash. The default behaviour can therefore be overriden with the BeaconWalletClient.Builder#ignoreUnsupportedBlockchains flag.

import it.airgap.beaconsdk.client.wallet.BeaconWalletClient

val beaconWallet = BeaconWalletClient {
...

ignoreUnsupportedBlockchains = true
}

Custom storage

Beacon Android SDK is not a stateless library and bases part of its functionality on preserved data. By default the SDK stores its data in SharedPreferences. However, it is possible to override the default storage and provide your own implementation. The :core module ships with 3 public interfaces that can be satisfied and provided externally during the BeaconWalletClient setup: Storage, ExtendedStorage (an extended version of Storage) and SecureStorage.

import it.airgap.beaconsdk.client.wallet.BeaconWalletClient
import it.airgap.beaconsdk.core.storage.ExtendedStorage
import it.airgap.beaconsdk.core.storage.SecureStorage
import it.airgap.beaconsdk.core.storage.Storage

val beaconWallet = BeaconWalletClient {
...

storage = MyStorage() /* or MyExtendedStorage() */
secureStorage = MySecureStorage()
}

class MyStorage : Storage {
// implementation
}

class MyExtendedStorage : ExtendedStorage {
// implementation
}

class MySecureStorage : SecureStorage {
// implementation
}

Plugins

Some modules may require additional data to store. Those modules usually come with their own storage plugin interfaces which can be satisfied and provided externally.

:transport-p2p-matrix

The :transport-p2p-matrix module defines P2pMatrixStoragePlugin and ExtendedP2pMatrixStoragePlugin interfaces.

import it.airgap.beaconsdk.client.wallet.BeaconWalletClient
import it.airgap.beaconsdk.transport.p2p.matrix.p2pMatrix
import it.airgap.beaconsdk.transport.p2p.matrix.storage.ExtendedP2pMatrixStoragePlugin
import it.airgap.beaconsdk.transport.p2p.matrix.storage.P2pMatrixStoragePlugin

val beaconWallet = BeaconWalletClient {
...

use(p2pMatrix(storagePlugin = MyP2pMatrixStoragePlugin() /* or MyExtendedP2pMatrixStoragePlugin() */))
}

class MyP2pMatrixStoragePlugin : P2pMatrixStoragePlugin {
// implementation
}

class MyExtendedP2pMatrixStoragePlugin : ExtendedP2pMatrixStoragePlugin {
// implementation
}

Custom Matrix nodes

You can provide your own Matrix node URLs while setting BeaconWalletClient up with the :transport-p2p-matrix transport layer. Use the p2pMatrix factory arguments to set your values.

import it.airgap.beaconsdk.client.wallet.BeaconWalletClient
import it.airgap.beaconsdk.transport.p2p.matrix.p2pMatrix

val beaconWallet = BeaconWalletClient {
...

use(p2pMatrix(matrixNodes = listOf("my.matrix.node")))
}