Skip to content

Commit e09a435

Browse files
committed
fix provider init error
1 parent f2f1465 commit e09a435

File tree

5 files changed

+22
-12
lines changed

5 files changed

+22
-12
lines changed

example/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ android {
3232
}
3333

3434
dependencies {
35-
implementation project(path: ':fcl-android')
35+
// implementation project(path: ':fcl-android')
3636

3737
implementation 'androidx.core:core-ktx:1.7.0'
3838
implementation 'androidx.appcompat:appcompat:1.4.1'
@@ -42,6 +42,8 @@ dependencies {
4242

4343
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2'
4444

45+
implementation 'com.github.Outblock:fcl-android:0.02'
46+
4547
testImplementation 'junit:junit:4.13.2'
4648
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
4749
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

example/src/main/AndroidManifest.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919
<category android:name="android.intent.category.LAUNCHER"/>
2020
</intent-filter>
2121
</activity>
22-
23-
<provider
24-
android:authorities="io.outblock.fcl.context"
25-
android:name="io.outblock.fcl.lifecycle.FCLContentProvider"
26-
android:exported="false"/>
2722
</application>
2823

2924
</manifest>

fcl-android/src/main/AndroidManifest.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@
88
<activity
99
android:name=".webview.WebViewActivity"
1010
android:launchMode="singleTop"/>
11+
12+
<provider
13+
android:authorities="io.outblock.fcl.context"
14+
android:name="io.outblock.fcl.lifecycle.FCLContentProvider"
15+
android:exported="false"/>
1116
</application>
1217
</manifest>

fcl-android/src/main/java/io/outblock/fcl/Fcl.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.outblock.fcl
22

3+
import android.os.Looper
34
import androidx.annotation.WorkerThread
45
import com.nftco.flow.sdk.FlowAddress
56
import com.nftco.flow.sdk.simpleFlowScript
@@ -14,6 +15,7 @@ import io.outblock.fcl.request.AuthnRequest
1415
import io.outblock.fcl.request.AuthzSend
1516
import io.outblock.fcl.request.SignMessageSend
1617
import io.outblock.fcl.request.builder.FclBuilder
18+
import io.outblock.fcl.utils.ioScope
1719
import kotlinx.coroutines.runBlocking
1820

1921
object Fcl {
@@ -67,11 +69,17 @@ object Fcl {
6769
*/
6870
@WorkerThread
6971
fun authenticate(provider: Provider): AuthnResponse {
72+
assert(Thread.currentThread() != Looper.getMainLooper().thread) { "can't call this method in main thread." }
73+
7074
val resp = AuthnRequest().authenticate(provider)
7175
currentUser = User.fromAuthn(resp)
7276
return AuthnResponse(resp.data?.addr, resp.status, resp.reason)
7377
}
7478

79+
fun authenticateAsync(provider: Provider, callback: (response: AuthnResponse) -> Unit) {
80+
ioScope { callback(authenticate(provider)) }
81+
}
82+
7583
/**
7684
* Mutate the chain: Send arbitrary transactions with your own signatures or via a user's wallet to perform state changes on chain.
7785
*
@@ -99,6 +107,7 @@ object Fcl {
99107
*/
100108
@WorkerThread
101109
fun mutate(builder: FclBuilder.() -> Unit): String {
110+
assert(Thread.currentThread() != Looper.getMainLooper().thread) { "can't call this method in main thread." }
102111
return runBlocking { AuthzSend().send(builder) }
103112
}
104113

@@ -125,6 +134,8 @@ object Fcl {
125134
*/
126135
@WorkerThread
127136
fun query(builder: FclBuilder.() -> Unit): String {
137+
assert(Thread.currentThread() != Looper.getMainLooper().thread) { "can't call this method in main thread." }
138+
128139
val outBuilder = FclBuilder().apply { builder(this) }
129140

130141
assert(!outBuilder.cadence.isNullOrBlank()) { "Script is empty" }
@@ -141,6 +152,8 @@ object Fcl {
141152
*/
142153
@WorkerThread
143154
fun signMessage(message: String): String {
155+
assert(Thread.currentThread() != Looper.getMainLooper().thread) { "can't call this method in main thread." }
156+
144157
return runBlocking { SignMessageSend().sign(message) }
145158
}
146159

fcl-android/src/main/java/io/outblock/fcl/utils/FclError.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
package io.outblock.fcl.utils
22

3-
import io.outblock.fcl.BuildConfig
4-
53
class FclException(
64
private val error: FclError,
75
private val exception: Exception? = null,
86
) : Exception(error.value) {
97

108
init {
11-
if (BuildConfig.DEBUG) {
12-
printStackTrace()
13-
}
9+
exception?.printStackTrace()
1410
}
15-
1611
}
1712

1813
enum class FclError(val value: String) {

0 commit comments

Comments
 (0)