kleros / kleros-v2

Kleros version 2
https://v2.kleros.builders
MIT License
61 stars 43 forks source link

Feat/web3auth wallet #1679

Open salgozino opened 2 months ago

salgozino commented 2 months ago

This PR inclues Web3Auth as a login method to enable social logins.

This connector allow users to login with their email (or facebook, github, etc) to kleros court. Behind the scenes a wallet is created and all the txs signs are handled without interaction from the user.

I don't think that this is a great wallet considering safety, or transparency of the txs that you are making, but will be great to onboard new jurors without crypto knowleadge and remove some frictions in the onboarding. For example, when you perform a stake, or approval or whatever, there is no popup to sign or nothing like that, all the transactions are signed automatically. This creates a "web2"experience, and I think that is great for users without crypto knowleadge. We can include in the docs or somewhere some disclaimers abourt not having a lot of money on that wallet).

Web3Auth is not free, but in the free plan there are until 1000 monthly active users.

This is very draft and more a PoC than a PR to be merged. Opening here to be discussed.


PR-Codex overview

This PR focuses on restructuring API calls and environment variables for better functionality and security.

Detailed summary

The following files were skipped due to too many changes: web/src/utils/atlas/loginUser.ts, web/src/context/Web3Provider.tsx, web/src/utils/Web3AuthInstance.tsx, web/src/components/EnsureAuth.tsx, web/src/app.tsx, web/src/layout/Header/navbar/Menu/Settings/Notifications/FormContactDetails/index.tsx, web/src/context/AtlasProvider.tsx, yarn.lock

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

netlify[bot] commented 2 months ago

Deploy Preview for kleros-v2-testnet ready!

Name Link
Latest commit f1a7943bbac05063f63ddc87e3cc9f3b5b029c55
Latest deploy log https://app.netlify.com/sites/kleros-v2-testnet/deploys/66d5e969d1dd5d000899b4f0
Deploy Preview https://deploy-preview-1679--kleros-v2-testnet.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] commented 2 months ago

Deploy Preview for kleros-v2-university failed. Why did it fail? β†’

Name Link
Latest commit f1a7943bbac05063f63ddc87e3cc9f3b5b029c55
Latest deploy log https://app.netlify.com/sites/kleros-v2-university/deploys/66d5e9699451250008406d16
netlify[bot] commented 2 months ago

Deploy Preview for kleros-v2-neo ready!

Name Link
Latest commit f1a7943bbac05063f63ddc87e3cc9f3b5b029c55
Latest deploy log https://app.netlify.com/sites/kleros-v2-neo/deploys/66d5e9693b67960008a4b0d2
Deploy Preview https://deploy-preview-1679--kleros-v2-neo.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

coderabbitai[bot] commented 2 months ago

Walkthrough

The changes introduce several new features and modifications across various files in the application. Notably, new environment variables for GraphQL API connections are added, and the authentication logic is refactored to utilize a context provider. Several new utility functions for user management are introduced, enhancing the application's interaction with a GraphQL backend. Additionally, modifications to existing components streamline logic and improve code organization.

Changes

Files Change Summary
web/.env.* Added REACT_APP_ATLAS_URI environment variable set to http://localhost:3000/graphql.
web/netlify/middleware/authMiddleware.ts Removed issuer and audience variables from JWT verification logic.
web/package.json Added Web3 authentication dependencies and downgraded viem package version.
web/src/app.tsx Introduced AtlasProvider to enhance context management in the component hierarchy.
web/src/components/EnsureAuth.tsx Simplified authentication logic using useAtlasProvider context; removed local state.
web/src/consts/index.ts Updated EMAIL_REGEX to a more comprehensive pattern for email validation.
web/src/context/AtlasProvider.tsx Implemented AtlasProvider for user authentication and data interactions with Atlas backend.
web/src/context/Web3Provider.tsx Enhanced Web3 authentication setup with new imports and configurations.
web/src/hooks/useSessionStorage.ts Changed storage from localStorage to sessionStorage.
web/src/layout/Header/navbar/Menu/Settings/Notifications/... Refactored user management logic to utilize useAtlasProvider for email handling.
web/src/utils/atlas/*.ts Introduced several utility functions for user management (e.g., addUser, fetchUser).
web/src/utils/uploadFormDataToIPFS.ts Renamed session storage key from "auth-token" to "authToken".

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant AtlasProvider
    participant GraphQLAPI

    User->>App: Initiates authentication
    App->>AtlasProvider: Calls authoriseUser
    AtlasProvider->>GraphQLAPI: Sends authentication request
    GraphQLAPI-->>AtlasProvider: Returns access token
    AtlasProvider-->>App: Provides user data
    App-->>User: Displays user information

🐰 Hopping through the code, oh what a delight,
New paths to explore, everything feels right!
With Atlas in tow, we leap and we bound,
In a world of GraphQL, new treasures are found.
So let’s dance and rejoice, with a hop and a cheer,
For the changes we’ve made, let’s celebrate here! πŸŽ‰


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (Invoked using PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. ### Other keywords and placeholders - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. - Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description. - Add `@coderabbitai` or `@coderabbitai title` anywhere in the PR title to generate the title automatically. ### CodeRabbit Configuration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
Early access features: disabled We are currently testing the following features in early access: - **Anthropic `claude-3-5-sonnet` for code reviews**: Anthropic claims that the new Claude model has stronger code understanding and code generation capabilities than their previous models. Note: Our default code review model was also updated late last week. Please compare the quality of the reviews between the two models by toggling the early access feature. Note: - You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file. - Please join our [Discord Community](https://discord.com/invite/GsXnASn26c) to provide feedback and report issues on the [discussion post](https://discordapp.com/channels/1134356397673414807/1279579842131787838).
sonarcloud[bot] commented 2 months ago

Quality Gate Passed Quality Gate passed

Issues
9 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

codeclimate[bot] commented 2 months ago

Code Climate has analyzed commit f1a7943b and detected 21 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1
Duplication 2
Style 18

View more on Code Climate.

jaybuidl commented 2 months ago

Only 4 file changes after changing the base branch to feat/atlas-siwe :)