Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

add web3 sign in #38

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

add web3 sign in #38

wants to merge 9 commits into from

Conversation

hhio618
Copy link

@hhio618 hhio618 commented May 17, 2022

Description

Add web3 sign-in button

  • Investigate web3 integrations for android
  • Find a working WalletConnect implementation
  • Add web3j utils to verify the signature on the android device before pushing to the server
  • Sign in using rest api (depends on Add REST API for signing in with Web3 webapp#1544)

close #37

@hhio618 hhio618 requested a review from a team as a code owner May 17, 2022 10:04
Copy link
Member

@nya-elimu nya-elimu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest using two separate Android Activities for SignInWithGoogleActivity and SignInWithGoogleActivity, so that we avoid mixing the code used for each sign-in provider.

Copy link
Member

@nya-elimu nya-elimu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hhio618 I tried compiling the code, but got this error:

./gradlew clean build
> Task :app:testDebugUnitTest FAILED

ai.elimu.crowdsource.ExampleUnitTest > web3recover_SanityCheck FAILED
    java.lang.AssertionError at ExampleUnitTest.java:22

@hhio618
Copy link
Author

hhio618 commented May 18, 2022

@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
Copy link
Member

@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
Copy link
Author

hhio618 commented May 19, 2022

@nya-elimuai fixed.

@hhio618
Copy link
Author

hhio618 commented May 21, 2022

@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
Copy link
Member

@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?

Copy link
Member

@nya-elimu nya-elimu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was unable to launch the app, due to compilation error: #38 (comment)

@hhio618
Copy link
Author

hhio618 commented May 27, 2022

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

@hhio618 hhio618 requested a review from nya-elimu May 28, 2022 13:25
@nya-elimu
Copy link
Member

@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

Copy link
Member

@nya-elimu nya-elimu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hhio618
Copy link
Author

hhio618 commented May 30, 2022

@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
Copy link
Member

@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
Copy link
Author

hhio618 commented May 31, 2022

@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
Copy link
Member

nya-elimu commented May 31, 2022

@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)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a "Sign in with Web3" option
2 participants