diff --git a/README.md b/README.md index b976d97..df2657d 100644 --- a/README.md +++ b/README.md @@ -106,8 +106,8 @@ A **convenience method** that produces the needed authorization details for the **Note:** The default values for `proposer`, `payer`, and `authorizations` are already `fcl.authz` so there is no need to include these parameters, it is shown only for example purposes. See more on [signing roles](https://docs.onflow.org/concepts/accounts-and-keys/#signing-a-transaction). ```kotlin -val tid = Fcl.send { - script( +val tid = Fcl.mutate { + cadence( """ transaction(test: String, testInt: Int) { prepare(signer: AuthAccount) { @@ -120,7 +120,7 @@ val tid = Fcl.send { ) arg { string("Test2") } arg { int(1) } - gaslimit(1000) + gasLimit(1000) } ``` diff --git a/example/build.gradle b/example/build.gradle index 957959f..0416b1a 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -4,12 +4,12 @@ plugins { } android { - compileSdk 31 + compileSdk 28 defaultConfig { applicationId "io.outblock.fcl.example" minSdk 21 - targetSdk 31 + targetSdk 28 versionCode 1 versionName "1.0" @@ -34,15 +34,15 @@ android { dependencies { implementation project(path: ':fcl-android') - implementation 'androidx.core:core-ktx:1.7.0' - implementation 'androidx.appcompat:appcompat:1.4.1' - implementation 'com.google.android.material:material:1.6.0' + implementation 'androidx.core:core-ktx:1.6.0' + implementation 'androidx.appcompat:appcompat:1.3.1' + implementation 'com.google.android.material:material:1.3.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.3' implementation 'com.google.code.gson:gson:2.8.9' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2' -// implementation 'com.github.Outblock:fcl-android:0.03' +// implementation 'com.github.Outblock:fcl-android:0.05' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' diff --git a/example/src/main/java/io/outblock/fcl/example/MainActivity.kt b/example/src/main/java/io/outblock/fcl/example/MainActivity.kt index bba13e3..e7b565d 100644 --- a/example/src/main/java/io/outblock/fcl/example/MainActivity.kt +++ b/example/src/main/java/io/outblock/fcl/example/MainActivity.kt @@ -97,7 +97,7 @@ class MainActivity : AppCompatActivity() { Log.d(TAG, "authenticate complete:$auth") CoroutineScope(Dispatchers.Main).launch { Toast.makeText(this@MainActivity, "authenticate complete", Toast.LENGTH_SHORT).show() - findViewById(R.id.address).text = auth.address + findViewById(R.id.address).text = auth.data?.address } } } @@ -129,7 +129,7 @@ class MainActivity : AppCompatActivity() { cadence(editText.text.toString()) arg { string("Test2") } arg { int(1) } - gaslimit(1000) + gasLimit(1000) } Log.d(TAG, "tid:$tid") CoroutineScope(Dispatchers.Main).launch { diff --git a/fcl-android/build.gradle b/fcl-android/build.gradle index 1990b29..e3489a7 100644 --- a/fcl-android/build.gradle +++ b/fcl-android/build.gradle @@ -35,12 +35,7 @@ android { } dependencies { - implementation 'androidx.core:core-ktx:1.8.0' - implementation 'androidx.appcompat:appcompat:1.4.2' - implementation 'com.google.android.material:material:1.6.1' - implementation 'androidx.browser:browser:1.4.0' - - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0' diff --git a/fcl-android/src/main/java/io/outblock/fcl/Fcl.kt b/fcl-android/src/main/java/io/outblock/fcl/Fcl.kt index 6e660a7..d0f08cd 100644 --- a/fcl-android/src/main/java/io/outblock/fcl/Fcl.kt +++ b/fcl-android/src/main/java/io/outblock/fcl/Fcl.kt @@ -1,11 +1,9 @@ package io.outblock.fcl import android.os.Looper -import androidx.annotation.WorkerThread import com.nftco.flow.sdk.FlowAddress import com.nftco.flow.sdk.simpleFlowScript import io.outblock.fcl.config.Config -import io.outblock.fcl.models.response.AuthnResponse import io.outblock.fcl.models.response.PollingResponse import io.outblock.fcl.models.response.Service import io.outblock.fcl.provider.Provider @@ -67,16 +65,15 @@ object Fcl { * * @param [provider] provider used for authentication */ - @WorkerThread - fun authenticate(provider: Provider): AuthnResponse { + fun authenticate(provider: Provider): PollingResponse { assert(Thread.currentThread() != Looper.getMainLooper().thread) { "can't call this method in main thread." } val resp = AuthnRequest().authenticate(provider) currentUser = User.fromAuthn(resp) - return AuthnResponse(resp.data?.addr, resp.status, resp.reason) + return resp } - fun authenticateAsync(provider: Provider, callback: (response: AuthnResponse) -> Unit) { + fun authenticateAsync(provider: Provider, callback: (response: PollingResponse) -> Unit) { ioScope { callback(authenticate(provider)) } } @@ -105,7 +102,6 @@ object Fcl { * * @throws FCLException If run into problems */ - @WorkerThread fun mutate(builder: FclBuilder.() -> Unit): String { assert(Thread.currentThread() != Looper.getMainLooper().thread) { "can't call this method in main thread." } return runBlocking { AuthzSend().send(builder) } @@ -132,7 +128,6 @@ object Fcl { * * @return executed result of cadence */ - @WorkerThread fun query(builder: FclBuilder.() -> Unit): String { assert(Thread.currentThread() != Looper.getMainLooper().thread) { "can't call this method in main thread." } @@ -150,7 +145,6 @@ object Fcl { /** * TODO : not support right now */ - @WorkerThread fun signMessage(message: String): String { assert(Thread.currentThread() != Looper.getMainLooper().thread) { "can't call this method in main thread." } @@ -181,7 +175,7 @@ class User( ) { companion object { fun fromAuthn(authn: PollingResponse): User? { - val address = authn.data?.addr ?: return null + val address = authn.data?.address ?: return null return User( address = FlowAddress(address), services = authn.data.services, diff --git a/fcl-android/src/main/java/io/outblock/fcl/models/response/AuthnResponse.kt b/fcl-android/src/main/java/io/outblock/fcl/models/response/AuthnResponse.kt deleted file mode 100644 index 0977be6..0000000 --- a/fcl-android/src/main/java/io/outblock/fcl/models/response/AuthnResponse.kt +++ /dev/null @@ -1,14 +0,0 @@ -package io.outblock.fcl.models.response - -/** - * Authentication response - * - * @property [address] address of the authenticated account - * @property [status] status of the authentication (approved or declined) - * @property [reason] if authentication is declined this property will contain more description - */ -data class AuthnResponse( - val address: String?, - val status: ResponseStatus, - val reason: String? -) \ No newline at end of file diff --git a/fcl-android/src/main/java/io/outblock/fcl/models/response/PollingResponse.kt b/fcl-android/src/main/java/io/outblock/fcl/models/response/PollingResponse.kt index e4400bb..5bd5d2b 100644 --- a/fcl-android/src/main/java/io/outblock/fcl/models/response/PollingResponse.kt +++ b/fcl-android/src/main/java/io/outblock/fcl/models/response/PollingResponse.kt @@ -50,7 +50,7 @@ data class PollingResponse( data class PollingData( @SerializedName("addr") - val addr: String?, + val address: String?, @SerializedName("services") val services: List?, @SerializedName("f_type") diff --git a/fcl-android/src/main/java/io/outblock/fcl/request/AuthzRequest.kt b/fcl-android/src/main/java/io/outblock/fcl/request/AuthzRequest.kt index c0a5966..0de60ac 100644 --- a/fcl-android/src/main/java/io/outblock/fcl/request/AuthzRequest.kt +++ b/fcl-android/src/main/java/io/outblock/fcl/request/AuthzRequest.kt @@ -1,6 +1,5 @@ package io.outblock.fcl.request -import androidx.annotation.WorkerThread import io.outblock.fcl.FlowApi import io.outblock.fcl.models.Argument import io.outblock.fcl.models.Interaction @@ -10,7 +9,7 @@ import io.outblock.fcl.request.builder.FclBuilder import io.outblock.fcl.resolve.* internal class AuthzSend { - @WorkerThread + suspend fun send(builder: FclBuilder.() -> Unit): String { val ix = prepare(FclBuilder().apply { builder(this) }) listOf( diff --git a/fcl-android/src/main/java/io/outblock/fcl/request/builder/FclBuilder.kt b/fcl-android/src/main/java/io/outblock/fcl/request/builder/FclBuilder.kt index 908a246..9109ddc 100644 --- a/fcl-android/src/main/java/io/outblock/fcl/request/builder/FclBuilder.kt +++ b/fcl-android/src/main/java/io/outblock/fcl/request/builder/FclBuilder.kt @@ -28,7 +28,7 @@ class FclBuilder { fun arg(argument: JsonCadenceBuilder.() -> Field<*>) = arg(argument(JsonCadenceBuilder())) - fun gaslimit(limit: Int) { + fun gasLimit(limit: Int) { this.limit = limit } } \ No newline at end of file diff --git a/fcl-android/src/main/java/io/outblock/fcl/webview/WebViewActivity.kt b/fcl-android/src/main/java/io/outblock/fcl/webview/WebViewActivity.kt index 5c0f3ce..e04caeb 100644 --- a/fcl-android/src/main/java/io/outblock/fcl/webview/WebViewActivity.kt +++ b/fcl-android/src/main/java/io/outblock/fcl/webview/WebViewActivity.kt @@ -1,13 +1,13 @@ package io.outblock.fcl.webview +import android.app.Activity import android.app.Application import android.content.Context import android.content.Intent import android.os.Bundle -import androidx.appcompat.app.AppCompatActivity import io.outblock.fcl.utils.logd -internal class WebViewActivity : AppCompatActivity() { +internal class WebViewActivity : Activity() { private val url by lazy { intent.getStringExtra(EXTRA_URL).orEmpty() } @@ -21,7 +21,6 @@ internal class WebViewActivity : AppCompatActivity() { FCLWebViewLifecycle.onWebViewOpen(url) actionBar?.hide() - supportActionBar?.hide() } override fun onBackPressed() {