Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/airgap-it/beacon-android-sdk
The beacon sdk allows Android developers of dApps and wallets on Tezos to implement the wallet interaction standard tzip-10.
https://github.com/airgap-it/beacon-android-sdk
beacon beacon-sdk dapps tezos wallet
Last synced: 5 days ago
JSON representation
The beacon sdk allows Android developers of dApps and wallets on Tezos to implement the wallet interaction standard tzip-10.
- Host: GitHub
- URL: https://github.com/airgap-it/beacon-android-sdk
- Owner: airgap-it
- License: mit
- Created: 2020-10-13T11:23:41.000Z (about 4 years ago)
- Default Branch: develop
- Last Pushed: 2023-08-02T14:08:32.000Z (over 1 year ago)
- Last Synced: 2023-08-02T15:27:15.250Z (over 1 year ago)
- Topics: beacon, beacon-sdk, dapps, tezos, wallet
- Language: Kotlin
- Homepage: https://walletbeacon.io
- Size: 1.64 MB
- Stars: 8
- Watchers: 8
- Forks: 7
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Beacon Android SDK
[![stable](https://img.shields.io/github/v/tag/airgap-it/beacon-android-sdk?label=stable&sort=semver)](https://github.com/airgap-it/beacon-android-sdk/releases)
[![latest](https://img.shields.io/github/v/tag/airgap-it/beacon-android-sdk?color=orange&include_prereleases&label=latest)](https://github.com/airgap-it/beacon-android-sdk/releases)
[![release](https://img.shields.io/jitpack/v/github/airgap-it/beacon-android-sdk)](https://jitpack.io/#airgap-it/beacon-android-sdk)
[![documentation](https://img.shields.io/badge/documentation-online-brightgreen.svg)](https://docs.walletbeacon.io/wallet/getting-started/android/installation)
[![license](https://img.shields.io/github/license/airgap-it/beacon-android-sdk)](https://github.com/airgap-it/beacon-android-sdk/blob/master/LICENSE)> Connect Wallets with dApps on Tezos
[Beacon](https://walletbeacon.io) is an implementation of the wallet interaction standard [tzip-10](https://gitlab.com/tzip/tzip/blob/master/proposals/tzip-10/tzip-10.md) which describes the connection of a dApp with a wallet.
## About
The `Beacon Android SDK` provides Android developers with tools useful for setting up communication between native wallets supporting Tezos and dApps that implement [`beacon-sdk`](https://github.com/airgap-it/beacon-sdk).
## Installation
To add `Beacon Android SDK` into your project:
1. Make sure the [JitPack](https://jitpack.io/) repository is included in your root `build.gradle` file:
#### Groovy
```groovy
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```#### Kotlin
```kotlin
allprojects {
repositories {
...
maven("https://jitpack.io")
}
}
```2. Add the dependencies:
#### Groovy
```groovy
dependencies {
def beacon_version = "x.y.z"// REQUIRED, core
implementation "com.github.airgap-it.beacon-android-sdk:core:$beacon_version"// optional, client-dapp
implementation "com.github.airgap-it.beacon-android-sdk:client-dapp:$beacon_version"
// optional, client-wallet
implementation "com.github.airgap-it.beacon-android-sdk:client-wallet:$beacon_version"
// optional, client-wallet-compat
implementation "com.github.airgap-it.beacon-android-sdk:client-wallet-compat:$beacon_version"
// optional, blockchain-substrate
implementation "com.github.airgap-it.beacon-android-sdk:blockchain-substrate:$beacon_version"
// optional, blockchain-tezos
implementation "com.github.airgap-it.beacon-android-sdk:blockchain-tezos:$beacon_version"
// optional, transport-p2p-matrix
implementation "com.github.airgap-it.beacon-android-sdk:transport-p2p-matrix:$beacon_version"
---// alternatively, all modules
implementation "com.github.airgap-it:beacon-android-sdk:$beacon_version"
}
```#### Kotlin
```kotlin
dependencies {
val beaconVersion = "x.y.z"
// REQUIRED, core
implementation("com.github.airgap-it.beacon-android-sdk:core:$beaconVersion")// optional, client-dapp
implementation("com.github.airgap-it.beacon-android-sdk:client-dapp:$beaconVersion")
// optional, client-wallet
implementation("com.github.airgap-it.beacon-android-sdk:client-wallet:$beaconVersion")
// optional, client-wallet-compat
implementation("com.github.airgap-it.beacon-android-sdk:client-wallet-compat:$beaconVersion")
// optional, blockchain-substrate
implementation("com.github.airgap-it.beacon-android-sdk:blockchain-substrate:$beaconVersion")
// optional, blockchain-tezos
implementation("com.github.airgap-it.beacon-android-sdk:blockchain-tezos:$beaconVersion")
// optional, transport-p2p-matrix
implementation("com.github.airgap-it.beacon-android-sdk:transport-p2p-matrix:$beaconVersion")
---
// alternatively, all modules
implementation("com.github.airgap-it:beacon-android-sdk:$beaconVersion")
}
```
### Proguard and R8`Beacon Android SDK` internally uses various libraries that may require custom ProGuard rules. If you're using ProGuard or R8, please follow the guides listed below to make sure your app works correctly after obfuscation:
- [ProGuard rules for Kotlin Serialization](https://github.com/Kotlin/kotlinx.serialization#android)
- [ProGuard rules for LazySodium](https://github.com/terl/lazysodium-java/wiki/installation#proguard)### Troubleshooting
See the list of known issues and how to fix them if you run into problems after adding the dependencies.
- `Native library (com/sun/jna/xxxxx/libjnidispatch.so) not found in resource path`
Add the `"net.java.dev.jna:jna:x.y.z@aar"` dependency **and exclude the `net.java.dev.jna` group from the Beacon dependencies**.
#### Groovy
```groovy
def withoutJna = { exclude group: "net.java.dev.jna" }
implementation "com.github.airgap-it.beacon-android-sdk:core:$beacon_version", withoutJna
implementation "com.github.airgap-it.beacon-android-sdk:client-wallet:$beacon_version", withoutJna
...
def jna_version = "5.9.0"
implementation "net.java.dev.jna:jna:$jna_version@aar"
```
#### Kotlin
```kotlin
fun ModuleDependency.excludeJna(): ModuleDependency = apply {
exclude(group = "net.java.dev.jna")
}
implementation("com.github.airgap-it.beacon-android-sdk:core:$beaconVersion") { withoutJna() }
implementation("com.github.airgap-it.beacon-android-sdk:client-wallet:$beaconVersion") { withoutJna() }
...
val jnaVersion = "5.9.0"
implementation("net.java.dev.jna:jna:$jnaVersion@aar")
```## Documentation
The documentation can be found [here](https://docs.walletbeacon.io/).
## Project Overview
The project consists of the following modules:
### Core
Core modules are the basis for other modules. They are required for the SDK to work as expected.
| Module | Description | Dependencies | Required by |
| ------- | ---------------------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `:core` | Base for other modules | ✖️ | `:client-wallet`
`:client-wallet-compat`
`:blockchain-substrate`
`:blockchain-tezos`
`:transport-p2p-matrix` |### Client
Client modules ship with Beacon implementations for different parts of the network.
| Module | Description | Dependencies | Required by |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------- | ----------------------- |
| `:client-dapp` | Beacon implementation for dApps | `:core` | ✖️ |
| `:client-wallet` | Beacon implementation for wallets | `:core` | `:client-wallet-compat` |
| `:client-wallet-compat` | Provides a supplementary interface for `:client-wallet` for use without [Coroutines](https://kotlinlang.org/docs/coroutines-overview.html) | `:core`
`:client-wallet` | ✖️ |### Blockchain
Blockchain modules provide support for different blockchains.
| Module | Description | Dependencies | Required by |
| ----------------------- | ----------------------------- | ------------ | ----------- |
| `:blockchain-substrate` | Substrate specific components | `:core` | ✖️ |
| `:blockchain-tezos` | Tezos specific components | `:core` | ✖️ |### Transport
Transport modules provide various interfaces used to establish connection between Beacon clients.
| Module | Description | Dependencies | Required by |
| ----------------------- | ---------------------------------------------------------------------------------------- | ------------ | ----------- |
| `:transport-p2p-matrix` | Beacon P2P implementation which uses [Matrix](https://matrix.org/) for the communication | `:core` | ✖️ |### Demo
Demo modules provide examples of how to use the library.
| Module | Description |
| ------- | ------------------- |
| `:demo` | Example application |## Examples
The snippets below show how to quickly setup a wallet listening for incoming Beacon messages in Kotlin with coroutines.
For more examples or examples of how to use the SDK without coroutines or in Java, please see our `demo` app (WIP).
### Create a Beacon wallet client and listen for incoming requests
```kotlin
import it.airgap.beaconsdk.blockchain.substrate.substrate
import it.airgap.beaconsdk.blockchain.tezos.tezos
import it.airgap.beaconsdk.client.wallet.BeaconWalletClient
import it.airgap.beaconsdk.transport.p2p.matrix.p2pMatrixclass MainActivity : AppCompatActivity() {
lateinit var client: BeaconWalletClient// ...
suspend fun listenForBeaconMessages() {
// create a wallet Beacon client that can listen for Substrate and Tezos messages via Matrix network
client = BeaconWalletClient("My App") {
support(substrate(), tezos())
use(p2pMatrix())
}myCoroutineScope.launch {
// subscribe to a message Flow
client.connect().collect { /* process messages */ }
}
}
}
```## Migration
See the below guides to learn how to migrate your existing code to new `Beacon Android SDK` versions.
### From { ... }
* is OperationBeaconRequest -> { ... }
* is SignPayloadBeaconRequest -> { ... }
* is BroadcastBeaconRequest -> { ... }
* }
*/import it.airgap.beaconsdk.blockchain.tezos.message.request.PermissionTezosRequest
import it.airgap.beaconsdk.blockchain.tezos.message.request.BroadcastTezosRequest
import it.airgap.beaconsdk.blockchain.tezos.message.request.OperationTezosRequest
import it.airgap.beaconsdk.blockchain.tezos.message.request.SignPayloadTezosRequestwhen (beaconRequest) {
is PermissionTezosRequest -> { /* ... */ }
is OperationTezosRequest -> { /* ... */ }
is SignPayloadTezosRequest -> { /* ... */ }
is BroadcastTezosRequest -> { /* ... */ }
else -> { /* ... */ }
}
``````kotlin
/*