Skip to content

Commit

Permalink
remove unnecessary libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
john990 committed Jul 20, 2022
1 parent 48d9a12 commit a8ecccd
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 48 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -120,7 +120,7 @@ val tid = Fcl.send {
)
arg { string("Test2") }
arg { int(1) }
gaslimit(1000)
gasLimit(1000)
}
```

Expand Down
12 changes: 6 additions & 6 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions example/src/main/java/io/outblock/fcl/example/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<TextView>(R.id.address).text = auth.address
findViewById<TextView>(R.id.address).text = auth.data?.address
}
}
}
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 1 addition & 6 deletions fcl-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
14 changes: 4 additions & 10 deletions fcl-android/src/main/java/io/outblock/fcl/Fcl.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)) }
}

Expand Down Expand Up @@ -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) }
Expand All @@ -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." }

Expand All @@ -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." }

Expand Down Expand Up @@ -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,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ data class PollingResponse(

data class PollingData(
@SerializedName("addr")
val addr: String?,
val address: String?,
@SerializedName("services")
val services: List<Service>?,
@SerializedName("f_type")
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
@@ -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() }

Expand All @@ -21,7 +21,6 @@ internal class WebViewActivity : AppCompatActivity() {
FCLWebViewLifecycle.onWebViewOpen(url)

actionBar?.hide()
supportActionBar?.hide()
}

override fun onBackPressed() {
Expand Down

0 comments on commit a8ecccd

Please sign in to comment.