Giveth / giveth-dapps-v2

This project is the aggregation of GIVeconomy and Giveth.io DApps in a single repo
https://staging.giveth.io
GNU General Public License v3.0
54 stars 32 forks source link

Fix permit #4273

Closed MohammadPCh closed 2 days ago

MohammadPCh commented 3 weeks ago

Summary by CodeRabbit

vercel[bot] commented 3 weeks ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
giveth-dapps-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 1, 2024 7:42am
coderabbitai[bot] commented 3 weeks ago

Walkthrough

The updates introduce a permit-based staking mechanism in the Stake and StakeGIV components by adding permitSignature, adjusting function calls, and implementing logic to handle token permitting. Additionally, new strings for multi-language support and updates to the subgraph URLs for both development and production environments have been included.

Changes

Files Change Summary
src/.../Stake.tsx Introduced permit handling and refactored stake token function calls.
src/.../StakeGIV.tsx Added permit handling, toggle switch for permit/approve mode, and logic adjustments.
src/lib/stakingPool.ts Added signature parsing and encoding functions, adjusted staking functions for permit support.
lang/ca.json Added new permit-related labels for multi-language support.
lang/en.json Added new permit-related labels for multi-language support.
lang/es.json Added new permit-related labels for multi-language support.
src/config/development.tsx Updated subgraph URLs for the development environment.
src/config/production.tsx Updated subgraph URLs for the production environment.

Poem

Amidst the staking, a change arrives, Permit the tokens, watch them thrive. With toggle switch and new URLs, Multilingual support as well. Code evolves, now sleek and bright, In staking’s realm, the future’s light. 🌟


Recent review details **Configuration used: CodeRabbit UI** **Review profile: CHILL**
Commits Files that changed from the base of the PR and between 5ccb1e3c165517775f15dc793f517076345af0f8 and 3e62f27d52e91d204fb90d4e9cbe55c7c70df6f9.
Files selected for processing (2) * src/config/development.tsx (4 hunks) * src/config/production.tsx (5 hunks)
Additional context used
Gitleaks
src/config/development.tsx
48-48: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 49-49: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 140-140: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 153-153: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 156-156: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 157-157: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 158-158: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 214-214: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 215-215: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 217-217: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 375-375: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 376-376: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)
src/config/production.tsx
34-34: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 35-35: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 112-112: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 125-125: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 127-127: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 128-128: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 129-129: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 271-271: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 273-273: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 274-274: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 276-276: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 420-420: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key) --- 421-421: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)
Additional comments not posted (4)
src/config/development.tsx (2)
`371-371`: **Verify the new subgraph address for Optimism Sepolia.** Ensure that the new subgraph address is correct and accessible. --- `193-193`: **Verify the new subgraph address for Uniswap V2.** Ensure that the new subgraph address is correct and accessible.
Verification successful --- **The new subgraph address for Uniswap V2 is correct and accessible.** The POST request with the GraphQL query returned a valid response, confirming that the subgraph endpoint is functional. -
Scripts executed The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Description: Verify the new subgraph address for Uniswap V2. # Test: Fetch the subgraph schema. Expect: Successful response. curl -s 'https://gateway-arbitrum.network.thegraph.com/api/49102048d5822209c7cd189f8e4a51a9/subgraphs/id/EYCKATKGBKLWvSfwvBjzfCBmGwYNdVkduYXVivCsLRFu' | jq '.data.__schema' ``` Length of output: 170 --- --- Script: ```shell #!/bin/bash # Description: Re-verify the new subgraph address for Uniswap V2 and capture error messages. # Test: Fetch the subgraph schema with detailed error capture. Expect: Successful response or detailed error message. curl -s -D - 'https://gateway-arbitrum.network.thegraph.com/api/49102048d5822209c7cd189f8e4a51a9/subgraphs/id/EYCKATKGBKLWvSfwvBjzfCBmGwYNdVkduYXVivCsLRFu' | jq '.data.__schema' ``` Length of output: 232 --- --- Script: ```shell #!/bin/bash # Description: Fetch the raw response from the subgraph address to diagnose the issue. # Test: Fetch the raw response and capture headers and body. Expect: Detailed error message or status code. curl -s -D - 'https://gateway-arbitrum.network.thegraph.com/api/49102048d5822209c7cd189f8e4a51a9/subgraphs/id/EYCKATKGBKLWvSfwvBjzfCBmGwYNdVkduYXVivCsLRFu' ``` Length of output: 1022 --- --- Script: ```shell #!/bin/bash # Description: Send a POST request with a basic GraphQL query to verify the subgraph address. # GraphQL query to fetch the subgraph schema QUERY='{"query":"{ __schema { queryType { name } } }"}' # Test: Send POST request with the GraphQL query and capture the response. curl -s -X POST -H "Content-Type: application/json" -d "$QUERY" 'https://gateway-arbitrum.network.thegraph.com/api/49102048d5822209c7cd189f8e4a51a9/subgraphs/id/EYCKATKGBKLWvSfwvBjzfCBmGwYNdVkduYXVivCsLRFu' ``` Length of output: 358
src/config/production.tsx (2)
`416-416`: **Verify the new subgraph address for Optimism.** Ensure that the new subgraph address is correct and accessible. --- `240-240`: **Verify the new subgraph address for Uniswap V2.** Ensure that the new subgraph address is correct and accessible.
Verification successful --- **Verification Successful: Subgraph Address for Uniswap V2** The new subgraph address for Uniswap V2 is correct and accessible. A POST request to the endpoint returned a successful response with HTTP status code 200 and the expected schema data. - **File**: `src/config/production.tsx` - **Line**: 240
Scripts executed The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Description: Verify the new subgraph address for Uniswap V2. # Test: Fetch the subgraph schema. Expect: Successful response. curl -s 'https://gateway-arbitrum.network.thegraph.com/api/49102048d5822209c7cd189f8e4a51a9/subgraphs/id/EYCKATKGBKLWvSfwvBjzfCBmGwYNdVkduYXVivCsLRFu' | jq '.data.__schema' ``` Length of output: 170 --- --- Script: ```shell #!/bin/bash # Description: Verify the new subgraph address for Uniswap V2. # Test: Fetch the HTTP status code and response body. Expect: Successful response. response=$(curl -s -w "%{http_code}" -o response_body.txt 'https://gateway-arbitrum.network.thegraph.com/api/49102048d5822209c7cd189f8e4a51a9/subgraphs/id/EYCKATKGBKLWvSfwvBjzfCBmGwYNdVkduYXVivCsLRFu') http_code=$(tail -n1 <<< "$response") echo "HTTP Status Code: $http_code" echo "Response Body:" cat response_body.txt ``` Length of output: 349 --- --- Script: ```shell #!/bin/bash # Description: Verify the new subgraph address for Uniswap V2 using a POST request. # Test: Send a POST request to fetch the subgraph schema. Expect: Successful response. response=$(curl -s -w "%{http_code}" -o response_body.txt -X POST -H "Content-Type: application/json" --data '{"query":"{ __schema { types { name } } }"}' 'https://gateway-arbitrum.network.thegraph.com/api/49102048d5822209c7cd189f8e4a51a9/subgraphs/id/EYCKATKGBKLWvSfwvBjzfCBmGwYNdVkduYXVivCsLRFu') http_code=$(tail -n1 <<< "$response") echo "HTTP Status Code: $http_code" echo "Response Body:" cat response_body.txt ``` Length of output: 2086
--- > [!TIP] >
> Early access features: enabled > > We are currently testing the following features in early access: > > - **OpenAI `gpt-4o` model for code reviews and chat**: OpenAI claims that this model is better at understanding and generating code than the previous models. We seek your feedback over the next few weeks before making it generally available. > > 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. > - OSS projects are currently opted into early access features by default. > >

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 as 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. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration 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.
MohammadPCh commented 2 weeks ago

@kkatusic Thanks, Please DONT MERGE THIS since the UI is not complete. can you take this and finalize it?

kkatusic commented 2 weeks ago

@kkatusic Thanks, Please DONT MERGE THIS since the UI is not complete. can you take this and finalize it?

@MohammadPCh I don't understand what is missing, I only tested this, doesn't make any code change? Write what is missing and I will add it, thx

kkatusic commented 2 weeks ago

I tested on Op Sepolia: https://optimism-sepolia.blockscout.com/tx/0x298ba7c241c9dee93c738e5806722290ca62bd9da7540433fff3efaedfb75439?tab=logs

with permit and without permit option it is working.

Enabled also FOX/xDAI otpion on production on Gnosis network:

without permit: https://gnosisscan.io/tx/0x930579bc4497a8a0b310dd3c2d429b7fee308194496935625f1098028ab74383

wit permit:

https://gnosisscan.io/tx/0xfed288e5a9c5890d616bf5be9dbc5d7b8611bd6a801dd8632ef4953ccf54a852

kkatusic commented 2 weeks ago

https://gnosisscan.io/tx/0x801ecb80e130765822518416633174b5e42a1a7ad1d0e75ab4c003a05f3506e4

Just for me @aminlatifi , how to find on transaction contract that you provide function stakeWithPermit: https://gnosisscan.io/token/0x8a0bee989c591142414ad67fb604539d917889df#code

thx in advance

aminlatifi commented 2 weeks ago

https://gnosisscan.io/tx/0x801ecb80e130765822518416633174b5e42a1a7ad1d0e75ab4c003a05f3506e4

Just for me @aminlatifi , how to find on transaction contract that you provide function stakeWithPermit: https://gnosisscan.io/token/0x8a0bee989c591142414ad67fb604539d917889df#code

thx in advance

The same contract you staked on https://sepolia-optimism.etherscan.io/address/0xe6836325b13819cf38f030108255a5213491a725#writeProxyContract

kkatusic commented 2 weeks ago

https://gnosisscan.io/tx/0x801ecb80e130765822518416633174b5e42a1a7ad1d0e75ab4c003a05f3506e4

Just for me @aminlatifi , how to find on transaction contract that you provide function stakeWithPermit: https://gnosisscan.io/token/0x8a0bee989c591142414ad67fb604539d917889df#code thx in advance

The same contract you staked on https://sepolia-optimism.etherscan.io/address/0xe6836325b13819cf38f030108255a5213491a725#writeProxyContract

But that isn't same chain network, maybe this is above my grade :)

MohammadPCh commented 3 days ago

@aminlatifi @kkatusic Could you please re-review this? Thanks.