From ed89b98b3e6a19ab17447372bdc430db24c0ee65 Mon Sep 17 00:00:00 2001 From: Ugo Amanoh Date: Wed, 25 Sep 2019 12:51:06 +0100 Subject: [PATCH 1/2] Added coroutine variant of the signTransaction() --- .../sdk/signer/UportHDSignerExtensions.kt | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/signer/src/main/java/com/uport/sdk/signer/UportHDSignerExtensions.kt b/signer/src/main/java/com/uport/sdk/signer/UportHDSignerExtensions.kt index dee0940..729d83f 100644 --- a/signer/src/main/java/com/uport/sdk/signer/UportHDSignerExtensions.kt +++ b/signer/src/main/java/com/uport/sdk/signer/UportHDSignerExtensions.kt @@ -2,6 +2,7 @@ package com.uport.sdk.signer import android.content.Context import com.uport.sdk.signer.encryption.KeyProtection +import org.kethereum.model.SignatureData import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException import kotlin.coroutines.suspendCoroutine @@ -24,6 +25,9 @@ suspend fun UportHDSigner.createHDSeed( } } +/** + * Extension function that wraps the `UportHDSigner.importHDSeed()` as a coroutine + */ suspend fun UportHDSigner.importHDSeed( context: Context, level: KeyProtection.Level, @@ -38,6 +42,26 @@ suspend fun UportHDSigner.importHDSeed( } } +/** + * Extension function that wraps the `UportHDSigner.signTransaction()` as a coroutine + */ + +suspend fun UportHDSigner.signTransaction( + context: Context, + rootAddress: String, + derivationPath: String, + txPayload: String, + prompt: String): SignatureData = suspendCoroutine { + + this.signTransaction(context, rootAddress, derivationPath, txPayload, prompt) { err, sigData -> + if (err != null) { + it.resumeWithException(err) + } else { + it.resume(sigData) + } + } +} + /** * Extension function that wraps the `computeAddressForPath` as a coroutine */ @@ -56,6 +80,9 @@ suspend fun UportHDSigner.computeAddressForPath( } } +/** + * Extension function that wraps the `UportHDSigner.showHDSeed()` as a coroutine + */ suspend fun UportHDSigner.showHDSeed( context: Context, rootAddress: String, From fa656065df0871ef167ff906f1f3651306053975 Mon Sep 17 00:00:00 2001 From: Mircea Nistor Date: Wed, 25 Sep 2019 14:18:41 +0200 Subject: [PATCH 2/2] chore: bump version to 0.3.5 --- Readme.md | 3 +++ build.gradle | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 7f480f7..3270c9a 100644 --- a/Readme.md +++ b/Readme.md @@ -159,6 +159,9 @@ UportHDSigner().signJwtBundle(activity, seedHandle, derivationPath, data, prompt ### Changelog +#### 0.3.5 +* [feat] add `suspend` extension for `UportHDSigner.signTransaction()` (#21) + #### 0.3.4 * [support] upgrade to kethereum 0.76.1 (#19) diff --git a/build.gradle b/build.gradle index 12814bf..f9a148a 100644 --- a/build.gradle +++ b/build.gradle @@ -28,7 +28,7 @@ buildscript { kotlin_common_version = "0.3.1" jacoco_version = "0.8.4" - current_release_version = "0.3.4" + current_release_version = "0.3.5" } repositories {