Skip to content

Commit

Permalink
Merge pull request #18 from tari-project/release/0.4.0
Browse files Browse the repository at this point in the history
feat: release 0.4.0
  • Loading branch information
igordanilcenko authored Feb 20, 2024
2 parents dd2ac6b + d1c9277 commit 4f40977
Show file tree
Hide file tree
Showing 19 changed files with 215 additions and 209 deletions.
171 changes: 60 additions & 111 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,14 @@ This framework is designed to make it easy for Yat partners to integrate the Yat

This repository contains an example app module named `yat-lib-example` that illustrates the steps below. The `YatAppConfig` instance in the `MainActivity` of the sample app needs to be edited for the app to function correctly.

## Note to Developer

https://jitpack.io/#yat-labs/yat-lib-android

Constant URL values below in the class `YatLib` need to be adjusted according to the service locations.

```kotlin
class YatLib {

// ...

companion object {

internal const val signingAPIBaseURL = "https://partner-aurora.emojid.me"
internal const val userActivationAPIBaseURL = "https://partner.scratch.emojid.me"
internal const val yatAPIBaseURL = "https://api-dev.yat.rocks/"
internal const val yatWebAppBaseURL = "https://dev.yat.rocks"
internal const val yatTermsURL = "https://pre-waitlist.y.at/terms"

// ...

}

// ...

}
```

## Requirements

- Android OS 7.0+
- Android OS 8.0+ (API level 26+)

## Installation

https://jitpack.io/#yat-labs/yat-lib-android

1. Add the JitPack repository in your root `build.gradle` at the end of repositories:

```gradle
Expand All @@ -49,16 +23,17 @@ class YatLib {
}
```
2. Add the dependency:
2. Add the dependency (check the latest version on [the JitPack page](https://jitpack.io/#yat-labs/yat-lib-android)) in your app `build.gradle` file
```gradle
dependencies {
implementation 'com.github.yat-labs:yat-lib-android:0.1.2'
implementation 'com.github.yat-labs:yat-lib-android:0.2.8'
}
```

## Usage

1. This library uses deep links to return from the Yat web application back to the partner application. URL scheme of the deep link is agreed upon in between the Yat development team and the integration partner. Currently used scheme is {partner_key}://y.at?{query_params}. Add deep link support to your activity using an intent filter.
1. This library uses deep links to return from the Yat web application back to the partner application. URL scheme of the deep link is agreed upon in between the Yat development team and the integration partner. Currently used scheme is `{partner_key}://y.at?{query_params}`. Add deep link support to your activity using an intent filter.

```xml
<intent-filter>
Expand All @@ -77,12 +52,10 @@ class YatLib {
</intent-filter>
```

2. Implement the Yat library delegate in your activity.
2. Implement the Yat library delegate in the class that will handle the Yat integration (e.g. `MainActivity`).

```kotlin
class MainActivity :
AppCompatActivity(),
YatLib.Delegate {
class MainActivity : AppCompatActivity(), YatIntegration.Delegate {

// ...

Expand All @@ -92,7 +65,7 @@ class YatLib {
*/
}

override fun onYatIntegrationFailed(failureType: YatLib.FailureType) {
override fun onYatIntegrationFailed(failureType: YatIntegration.FailureType) {
/*
* Code to run when the integration has failed.
*/
Expand All @@ -103,75 +76,33 @@ class YatLib {
}
```

3. Implement a function that initializes the library with the app-specific constants, user information and Yat records that should be linked to the Yat.
3. Initialize the Yat library.

```kotlin
class MainActivity :
AppCompatActivity(),
YatLib.Delegate {
class MainActivity : AppCompatActivity(), YatIntegration.Delegate {

// ...

private fun initializeYatLib() {
// library configuration
val config = YatAppConfig(
name = "Super Cool Wallet",
sourceName = "SCW",
// used in partner-specific URLs
pathKey = "scw",
// app-specific public key
pubKey = "{64 character hex public key}",
// app-specific access code
code = "66b6a5aa-11b4-12a9-1c1e-84765ef174ab",
// app-specific authentication token
authToken = "AppToken84765783"

// You can define your own environment(e.g. SandBox), or use the default Production one ("https://y.at/")
val yourEnvironment = YatIntegration.Environment(
yatAPIBaseURL = "https://a.yourdomain.y.at",
yatWebAppBaseURL = "https://yourdomain.y.at",
)
// Yat records
val yatRecords = listOf(
YatRecord(
YatRecordType.ADA_ADDRESS,
"DdzFFzCqrhsgwQmeWNBTsG8VjYunBLK9GNR93GSLTGj1FeMm8kFoby2cTHxEHBEraHQXmgTtFGz7fThjDRNNvwzcaw6fQdkYySBneRas"
),
YatRecord(
YatRecordType.DOT_ADDRESS,
"GC8fuEZG4E5epGf5KGXtcDfvrc6HXE7GJ5YnbiqSpqdQYLg"
),
YatRecord(
YatRecordType.BTC_ADDRESS,
"1NDyJtNTjmwk5xPNhjgAMu4HDHigtobu1s"
),
YatRecord(
YatRecordType.ETH_ADDRESS,
"108dEFa0272dC118EF03a7993e4fC7A8AcF3a3d1"
),
YatRecord(
YatRecordType.XTR_ADDRESS,
"d2e4db6dac593a9af36987a35676838ede4f69684ba433baeed68bce048e111b"
),
YatRecord(
YatRecordType.XMR_STANDARD_ADDRESS,
"4AdUndXHHZ6cfufTMvppY6JwXNouMBzSkbLYfpAV5Usx3skxNgYeYTRj5UzqtReoS44qo9mtmXCqY45DJ852K5Jv2684Rge"
)

val yourConfig = YatConfiguration(
appReturnLink = "app://y.at?action", // deep link to return to the app
organizationName = "Yat Labs",
organizationKey = "yat",
)
// initialize the library
YatLib.initialize(
config = config,
/*
* User information below is utilized to link the partner application user
* to the Yat user.
*/
userId = "partner_app_user_identifier",
userPassword = "partner_app_user_password",
/*
* YatLib.ColorMode.LIGHT for light mode,
* YatLib.ColorMode.DARK for dark mode,
*/
colorMode = YatLib.ColorMode.LIGHT,
/*
* Delegate interface is described below.
*/

YatIntegration.setup(
context = this,
config = yourConfig,
colorMode = YatIntegration.ColorMode.LIGHT, // Choose between LIGHT and DARK
delegate = this,
yatRecords = yatRecords
environment = yourEnvironment,
)
}

Expand All @@ -183,16 +114,14 @@ class YatLib {
4. Add the code that handles deep links.

```kotlin
class MainActivity :
AppCompatActivity(),
YatLib.Delegate {
class MainActivity : AppCompatActivity(), YatIntegration.Delegate {

// ...

override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
intent.data?.let { deepLink ->
YatLib.processDeepLink(deepLink)
YatIntegration.processDeepLink(deepLink)
}
}

Expand All @@ -201,22 +130,42 @@ class YatLib {
}
```

4. Start the library.
5. Start the library.

```kotlin
class MainActivity :
AppCompatActivity(),
YatLib.Delegate {
class MainActivity : AppCompatActivity(), YatIntegration.Delegate {

// Your Yat records
val yatRecords = listOf(
YatRecord(
YatRecordType.ADA_ADDRESS,
"DdzFFzCqrhsgwQmeWNBTsG8VjYunBLK9GNR93GSLTGj1FeMm8kFoby2cTHxEHBEraHQXmgTtFGz7fThjDRNNvwzcaw6fQdkYySBneRas"
),
YatRecord(
YatRecordType.DOT_ADDRESS,
"GC8fuEZG4E5epGf5KGXtcDfvrc6HXE7GJ5YnbiqSpqdQYLg"
),
YatRecord(
YatRecordType.BTC_ADDRESS,
"1NDyJtNTjmwk5xPNhjgAMu4HDHigtobu1s"
),
// ...
)

// ...

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
ui = ActivityMainBinding.inflate(layoutInflater)
setContentView(ui.root)

// init your view ...

initializeYatLib()
ui.getAYatButton.setOnClickListener {
YatLib.start(this@MainActivity)

ui.getYatButton.setOnClickListener {
YatIntegration.showOnboarding(
context = this@MainActivity,
yatRecords = yatRecords,
)
}
}

Expand All @@ -225,7 +174,7 @@ class YatLib {
}
```

## Looking up a Yat
## Looking up a Yat (OUTDATED TBA)

Below is an example call to the `YatLib.lookupYat` function to query for the records linked to a Yat and print them.

Expand Down
14 changes: 8 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
agp_version = '8.1.2'
}
ext.kotlin_version = '1.9.10'
ext.agp_version = "8.2.2"
ext.kotlin_version = "1.9.22"

ext.versionNumber = "0.4.0"

repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}

dependencies {
classpath "com.android.tools.build:gradle:$agp_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
Expand All @@ -26,6 +28,6 @@ allprojects {
}
}

task clean(type: Delete) {
delete rootProject.buildDir
tasks.register('clean', Delete) {
delete rootProject.layout.buildDirectory
}
12 changes: 5 additions & 7 deletions yat-lib-example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ android {
minSdkVersion 26
targetSdkVersion 34
compileSdk 34
versionCode 6
versionName "0.2.0"
versionName versionNumber

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -24,9 +23,8 @@ android {
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
kotlin {
jvmToolchain(17)
}

buildFeatures {
Expand All @@ -39,14 +37,14 @@ dependencies {
def coroutines_version = "1.7.3"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.2"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.7.0"


implementation project(path: ':yat-lib')
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.10.0'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
testImplementation 'junit:junit:4.13.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import yat.android.lib.YatLibApi
import yat.android.ui.transactions.outcoming.YatLibOutcomingTransactionActivity
import yat.android.ui.transactions.outcoming.YatLibOutcomingTransactionData
import yat.yat_lib_example.databinding.ActivityMainBinding
import java.util.*

internal class MainActivity : AppCompatActivity(), YatIntegration.Delegate {

Expand Down Expand Up @@ -67,11 +66,10 @@ internal class MainActivity : AppCompatActivity(), YatIntegration.Delegate {
)

YatIntegration.setup(
this,
context = this,
config = config,
colorMode = YatIntegration.ColorMode.LIGHT,
this,
environment = YatIntegration.Environment.SandBox
delegate = this,
)
}

Expand Down
Loading

0 comments on commit 4f40977

Please sign in to comment.