elimu-ai / crowdsource

✍🏽 Android application which enables the crowd to upload and peer review educational content and ML datasets
https://play.google.com/store/apps/details?id=ai.elimu.crowdsource
MIT License
1 stars 1 forks source link

add web3 sign in #38

Open hhio618 opened 2 years ago

hhio618 commented 2 years ago

Description

Add web3 sign-in button

close #37

hhio618 commented 2 years ago

@nya-elimuai Just added a new commit. fixed the test case so you can build the project. also, I tested the sign-in process using TrustWallet and AlphaWallet (as they support web3 & WalletConnect). but Metamask doesn't seem to work completely, could be a problem with Metamask or the WalletConnect library I used. I forked the library If that's the problem I'll try to find a fix for that.

nya-elimu commented 2 years ago

@nya-elimuai Just added a new commit. fixed the test case so you can build the project. also, I tested the sign-in process using TrustWallet and AlphaWallet (as they support web3 & WalletConnect). but Metamask doesn't seem to work completely, could be a problem with Metamask or the WalletConnect library I used. I forked the library If that's the problem I'll try to find a fix for that.

@hhio618 Thanks. Updated, and tried again. The compilation is still not working for me:

./gradlew clean build

> Task :app:lintDebug FAILED
Lint found 1 errors, 135 warnings. First failure:

../SignInWithWeb3Activity.java: Error: The lint detector
    timber.lint.WrongTimberUsageDetector

The full lint text report is located at:
../crowdsource/app/build/intermediates/lint_intermediate_text_report/debug/lint-results-debug.txt

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:lintDebug'.
> Lint found errors in the project; aborting build.

  Fix the issues identified by lint, or create a baseline to see only new errors:
  android {
      lint {
          baseline = file("lint-baseline.xml")
      }
  }
hhio618 commented 2 years ago

@nya-elimuai fixed.

hhio618 commented 2 years ago

@nya-elimuai tested using Alphawallet! also, looks like trust wallet doesn't support Unicode chars in the input message(the thumbs up emoji)!

nya-elimu commented 2 years ago

@hhio618 I downloaded the latest version of the branch, and code is not compiling for me:


./gradlew clean build

> Task :app:testDebugUnitTest

ai.elimu.crowdsource.ExampleUnitTest > web3recover_SanityCheck FAILED
    java.lang.AssertionError at ExampleUnitTest.java:21
expected:<[B@17503f6b> but was:<0x438d6abe3d60b1a1f3f1e0c606ba249bc30e221001b9269f96be450c393c2f7c>
Expected :[B@17503f6b
Actual   :0x438d6abe3d60b1a1f3f1e0c606ba249bc30e221001b9269f96be450c393c2f7c

Does it work on your machine?

hhio618 commented 2 years ago

@nya-elimuai fixed, as I used android studio run tools didn't see that :D

nya-elimu commented 2 years ago

@nya-elimuai fixed, as I used android studio run tools didn't see that :D

@hhio618 I updated the code and tried again locally, but compilation still fails: https://github.com/elimu-ai/crowdsource/runs/6648804215?check_suite_focus=true

You can see the command used for compilation at https://github.com/elimu-ai/crowdsource/blob/main/README.md#development- and in the GitHub Action: https://github.com/elimu-ai/crowdsource/blob/main/.github/workflows/ci_pr.yml#L18

hhio618 commented 2 years ago

@nya-elimuai Although I couldn't reproduce it locally (for me it happens only on the CI pipeline), I updated the Timber Library back to 5.0.1 now works fine!

nya-elimu commented 2 years ago

@nya-elimuai Although I couldn't reproduce it locally (for me it happens only on the CI pipeline), I updated the Timber Library back to 5.0.1 now works fine!

Thank you, @hhio618! 🙌🏽

I was now able to compile the code and launch it on a device. Question: What will happen if the user does not have any Web3 wallet app installed on their device? I haven't tested scenario yet.

hhio618 commented 2 years ago

@nya-elimuai you're welcome!

Question: What will happen if the user does not have any Web3 wallet app installed on their device?

How about notifying/redirecting the user to install a web3 wallet?

nya-elimu commented 2 years ago

@nya-elimuai you're welcome!

Question: What will happen if the user does not have any Web3 wallet app installed on their device?

How about notifying/redirecting the user to install a web3 wallet?

@hhio618 Yes, I think that would make sense, because that way it would work similarly as in our webapp. If no Web3 wallet app is found, perhaps we could redirect the user to MetaMask's Google Play page? https://play.google.com/store/apps/details?id=io.metamask

Here is the error message I'm getting on an Android emulator (no Web3 wallet app installed):


2022-06-01 19:17:21.210 3089-3089/ai.elimu.crowdsource.debug I/SignInWithWeb3Activity: onCreate
2022-06-01 19:17:21.362 3089-3089/ai.elimu.crowdsource.debug I/SignInWithWeb3Activity: onStart
2022-06-01 19:17:24.848 3089-3089/ai.elimu.crowdsource.debug D/AndroidRuntime: Shutting down VM
2022-06-01 19:17:24.855 3089-3089/ai.elimu.crowdsource.debug E/AndroidRuntime: FATAL EXCEPTION: main
    Process: ai.elimu.crowdsource.debug, PID: 3089
    android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=wc:ffeb70b1-a244-4e51-a89c-c8a4c6209956@1?bridge=http://localhost:55380&key=9EDFD65F84A68C8619AA2E9ACB7914C95D2A01E7801E170014F90A86DA7DA2C8 }
        at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2067)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1727)
        at android.app.Activity.startActivityForResult(Activity.java:5314)
        at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:597)
        at android.app.Activity.startActivityForResult(Activity.java:5272)
        at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:583)
        at android.app.Activity.startActivity(Activity.java:5658)
        at android.app.Activity.startActivity(Activity.java:5611)
        at ai.elimu.crowdsource.ui.authentication.SignInWithWeb3Activity.lambda$onCreate$0$ai-elimu-crowdsource-ui-authentication-SignInWithWeb3Activity(SignInWithWeb3Activity.java:76)
        at ai.elimu.crowdsource.ui.authentication.SignInWithWeb3Activity$$ExternalSyntheticLambda0.onClick(Unknown Source:2)