Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bridging ETH to OP Mainnet With Viem #906

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

Bridging ETH to OP Mainnet With Viem #906

wants to merge 29 commits into from

Conversation

krofax
Copy link
Contributor

@krofax krofax commented Sep 18, 2024

Description

This tutorial explains how you can use the Viem to bridge ETH from L1 (Ethereum or Sepolia) to L2 (OP Mainnet or OP Sepolia), it deprecates the Optimism SDK.

Tests

Please describe any tests you've added. If you've added no tests, or left important behavior untested, please explain why not.

Additional context

Add any other context about the problem you're solving.

Metadata

@krofax krofax requested a review from a team as a code owner September 18, 2024 00:53
Copy link
Contributor

coderabbitai bot commented Sep 18, 2024

Walkthrough

The changes in this pull request involve a comprehensive update to a tutorial on bridging Ethereum (ETH) to the Optimism (OP) Mainnet. All references to the deprecated Optimism SDK have been replaced with the viem library. The tutorial has been restructured to include new prerequisites, installation instructions, and enhanced content organization with tabs. Additionally, important considerations regarding security, gas costs, and best practices have been integrated to improve user guidance.

Changes

File Path Change Summary
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx Updated tutorial to replace Optimism SDK with viem library, added prerequisites, installation steps, and enhanced structure with tabs. Included new safety and best practice considerations.
public/tutorials/cross-dom-bridge-eth.js Refactored code to use viem library, defined depositETH and withdrawETH functions, and improved error handling and logging for transaction processes.
.github/workflows/tutorials.yml Removed the cross-dom-bridge-erc20 job and its dependencies; adjusted remaining jobs accordingly.
package.json Added viem dependency with version ^2.21.18.

Possibly related issues

  • ethereum-optimism/docs#904: This issue discusses creating alternate snippets for the tutorial using Viem, which aligns with the changes made in this PR.
  • ethereum-optimism/docs#591: This issue aims to update SDK tutorials to use Viem, directly related to the changes in this PR.
  • ethereum-optimism/docs#592: Similar to the previous issue, this one focuses on updating ERC-20 bridging tutorials to use Viem.
  • ethereum-optimism/docs#593: This issue targets updating tutorials for viewing deposits and withdrawals to use Viem, consistent with the broader transition reflected in this PR.
  • ethereum-optimism/docs#595: This issue focuses on updating estimating transaction costs to use Viem, relevant to the tutorial's context.
  • ethereum-optimism/docs#596: This issue involves updating using the Optimism SDK for chain operators to Viem, connecting to the tutorial's updates.

Possibly related PRs

  • Added banner and notice page for SDK deprecation  #928: The changes in this PR address the deprecation of the Optimism SDK and the transition to the viem library, which directly relates to the main PR's updates that replace the Optimism SDK with viem in the tutorial and code examples.

Suggested reviewers

  • cpengilly

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Sep 18, 2024

Deploy Preview for docs-optimism ready!

Name Link
🔨 Latest commit 490990a
🔍 Latest deploy log https://app.netlify.com/sites/docs-optimism/deploys/67051f36769e320008a2bdcb
😎 Deploy Preview https://deploy-preview-906--docs-optimism.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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (2)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (2)

66-83: Well done!

The "Configure Environment Variables" section provides clear instructions for setting up the .env file and storing the necessary environment variables securely. The example format is easy to understand.

Consider rephrasing this sentence to improve clarity:

-You need a private key in order to sign transactions.
+You need a private key to sign transactions.

The alternative wording is more concise and avoids unnecessary wordiness.

Tools
LanguageTool

[style] ~68-~68: Consider a shorter alternative to avoid wordiness.
Context: ...riables} You need a private key in order to sign transactions. Create a .env fi...

(IN_ORDER_TO_PREMIUM)


351-567: Comprehensive and well-structured!

The withdrawETH section is well-organized and follows a similar structure to the depositETH section, making it easy to follow and understand. The code blocks are properly formatted and include helpful comments explaining each step.

The "Important Considerations" section provides valuable information for users to keep in mind when working with withdrawals, such as the challenge period, gas costs, private key handling, and RPC endpoint security.

The "Next Steps" section encourages users to further explore and build upon the concepts learned in the tutorial, promoting continuous learning and development.

Consider rephrasing this sentence to strengthen the wording:

-[Standard Bridge guide](/builders/app-developers/bridging/standard-bridge) if you want to learn more about how the bridge work
+[Standard Bridge guide](/builders/app-developers/bridging/standard-bridge) if you want to learn more about how the bridge works

Adding the missing "s" at the end of "work" improves the grammar and clarity of the sentence.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between db75b7e and 3409081.

Files selected for processing (2)
  • pages/builders/app-developers/tutorials/_meta.json (1 hunks)
  • pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1 hunks)
Additional context used
Path-based instructions (1)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1)

Pattern **/*.mdx: "ALWAYS review Markdown content THOROUGHLY with the following criteria:

  • Use proper nouns in place of personal pronouns like 'We' and 'Our' to maintain consistency in communal documentation.
  • Avoid gender-specific language and use the imperative form.
  • Monitor capitalization for emphasis. Use bold for prominence instead of all caps or italics.
  • Ensure proper nouns are capitalized in sentences.
  • Apply the Oxford comma.
  • Use proper title case for headers, buttons, tab names, page names, and links. Sentence case should be used for body content and short phrases, even in links.
  • Use correct spelling and grammar at all times (IMPORTANT).
    "
LanguageTool
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx

[style] ~17-~17: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~68-~68: Consider a shorter alternative to avoid wordiness.
Context: ...riables} You need a private key in order to sign transactions. Create a .env fi...

(IN_ORDER_TO_PREMIUM)

Additional comments not posted (9)
pages/builders/app-developers/tutorials/_meta.json (1)

4-4: Approved: Tutorial title update provides more specificity and introduces Viem as the bridging tool.

The change in the tutorial title from "Bridging ETH With the Optimism SDK" to "Bridging ETH to OP Mainnet With Viem" offers several improvements:

  1. It clearly specifies that the tutorial focuses on bridging ETH to the Optimism (OP) Mainnet, providing users with a more precise understanding of the tutorial's scope.
  2. It introduces Viem as the tool being used for the bridging process, indicating that the tutorial has been updated to leverage a different library or approach compared to the previous version, which used the Optimism SDK.

This update aligns with the PR summary, which highlights the transition from the Optimism SDK to Viem for bridging ETH. By providing a more specific and accurate title, users can better grasp the tutorial's content and the tools being utilized.

pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (8)

2-4: LGTM!

The updated title and description accurately reflect the purpose of the tutorial. The usage of proper nouns is correct.


19-28: Looks good!

The new "Prerequisites" section clearly outlines the requirements for following the tutorial. The language is concise and uses the imperative form.


29-64: Great job!

The "Required Dependencies" section provides clear instructions for setting up the project and installing the necessary dependencies. The code blocks are properly formatted with the correct language identifiers.


86-88: Important warning!

The callout box effectively warns users about the importance of keeping their private keys secure and avoiding committing them to version control. The language is clear and emphasizes the significance of the warning.


92-105: Excellent!

The "Import Dependencies" section provides clear instructions for importing the necessary dependencies into the project. The code block is properly formatted and uses the correct import statements from the viem library and dotenv.


113-170: Fantastic organization!

The use of tabs to organize the content for setting session variables greatly improves the readability and clarity of the tutorial. The code blocks are properly formatted and provide clear examples of how to set up the necessary variables and clients. The accompanying explanations are concise and informative.


172-204: Helpful information!

The section for getting ETH on Sepolia provides clear instructions and a helpful link to a faucet for obtaining the necessary ETH to follow the tutorial. The code block for checking wallet balances is properly formatted and includes informative comments.


206-337: Excellent breakdown!

The depositETH section is well-organized using tabs and steps, making it easy to understand the process. The code blocks are properly formatted and include helpful comments explaining each step. Providing the full code in a separate tab offers a comprehensive view of the depositETH function and its dependencies.

Copy link
Contributor

@brokewhale brokewhale left a comment

Choose a reason for hiding this comment

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

Honestly, I think there might be a bit of a flow break in this tutorial when viewed from an absolute beginner's perspective. It'd be really helpful if we could make the steps as straightforward and easy to follow as possible.

The full code snippet approach is awesome. If we can have something like the CLI approach, along with a full code snippet, that would be fantastic.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3409081 and 5b33b41.

Files selected for processing (1)
  • pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1 hunks)
Additional context used
Path-based instructions (1)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1)

Pattern **/*.mdx: "ALWAYS review Markdown content THOROUGHLY with the following criteria:

  • Use proper nouns in place of personal pronouns like 'We' and 'Our' to maintain consistency in communal documentation.
  • Avoid gender-specific language and use the imperative form.
  • Monitor capitalization for emphasis. Use bold for prominence instead of all caps or italics.
  • Ensure proper nouns are capitalized in sentences.
  • Apply the Oxford comma.
  • Use proper title case for headers, buttons, tab names, page names, and links. Sentence case should be used for body content and short phrases, even in links.
  • Use correct spelling and grammar at all times (IMPORTANT).
    "
LanguageTool
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx

[style] ~15-~15: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~60-~60: Consider a shorter alternative to avoid wordiness.
Context: ...riables} You need a private key in order to sign transactions. Create a .env fi...

(IN_ORDER_TO_PREMIUM)

Additional comments not posted (8)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (8)

2-4: LGTM! Title and description are clear and accurate.

The updated title and description accurately reflect the tutorial's focus on using Viem for bridging ETH between L1 and L2. The language is concise and informative.


33-79: LGTM! Project setup instructions are clear and comprehensive.

The project setup instructions are well-structured, providing a step-by-step guide for initializing the project, installing dependencies, and setting up environment variables. The use of pnpm is consistent with the PR objectives, and the security warning about private keys is appropriately emphasized.

Tools
LanguageTool

[style] ~60-~60: Consider a shorter alternative to avoid wordiness.
Context: ...riables} You need a private key in order to sign transactions. Create a .env fi...

(IN_ORDER_TO_PREMIUM)


104-163: LGTM! Session variables setup is well-structured and clear.

The session variables setup section effectively uses Tabs to organize different setup steps. The code snippets for creating accounts, RPC providers, and wallet clients are correct and well-explained. The step-by-step approach makes it easy for users to follow along and understand each part of the setup process.


179-333: LGTM! Deposit ETH section is comprehensive and well-structured.

The "Deposit ETH" section effectively uses Tabs to organize the content, providing both step-by-step instructions and a full code example. The code snippets are clear, well-commented, and accurate. The inclusion of a callout for smart contract wallet users is a helpful addition for edge cases.


335-541: LGTM! Withdraw ETH section is comprehensive and well-structured.

The "Withdraw ETH" section effectively uses Tabs to organize the content, providing both step-by-step instructions and a full code example. The code snippets are clear, well-commented, and accurate. The inclusion of a callout about the challenge period on OP Sepolia is a helpful addition for users to understand the withdrawal process.


543-548: LGTM! Important considerations are well-summarized.

The "Important Considerations" section effectively highlights key points about the challenge period, gas costs, and security considerations. The information is concise, relevant, and provides valuable guidance for users implementing the bridging functionality.


553-557: LGTM! Next steps provide a good conclusion and direction for further development.

The "Next Steps" section effectively summarizes what the user has learned and suggests valuable improvements for production use. The mention of applying the same process to Ethereum and OP Mainnet is a helpful reminder of the tutorial's broader applicability.


9-24: ⚠️ Potential issue

Fix typo in Viem import statement.

The introduction and prerequisites are well-structured and informative. However, there's a minor typo in the Viem import statement.

Please update the import statement as follows:

-import { getL2TransactionHashes, publicActionsL2, walletActionsL1, getL2TransactionHashes } from 'viem/op-stack'
+import { getL2TransactionHashes, publicActionsL2, walletActionsL1 } from 'viem/op-stack'

The getL2TransactionHashes function is imported twice, which is unnecessary.

Likely invalid or redundant comment.

Tools
LanguageTool

[style] ~15-~15: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)

@krofax
Copy link
Contributor Author

krofax commented Sep 24, 2024

Honestly, I think there might be a bit of a flow break in this tutorial when viewed from an absolute beginner's perspective. It'd be really helpful if we could make the steps as straightforward and easy to follow as possible.

The full code snippet approach is awesome. If we can have something like the CLI approach, along with a full code snippet, that would be fantastic.

What do you mean by a CLI approach?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (4)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (2)

15-15: Consider strengthening the wording.

To improve clarity and directness, consider revising the phrase "if you want to learn" to "to learn" in the following sentence:

-Make sure to check out the [Standard Bridge guide](/builders/app-developers/bridging/standard-bridge) if you want to learn more about how the bridge works under the hood.
+Make sure to check out the [Standard Bridge guide](/builders/app-developers/bridging/standard-bridge) to learn more about how the bridge works under the hood.

This change makes the sentence more concise and direct.

🧰 Tools
LanguageTool

[style] ~15-~15: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


60-60: Simplify wording to avoid wordiness.

Consider revising the phrase "in order to" to make the sentence more concise:

-You need a private key in order to sign transactions.
+You need a private key to sign transactions.

This change maintains the meaning while making the sentence more direct.

🧰 Tools
LanguageTool

[style] ~60-~60: Consider a shorter alternative to avoid wordiness.
Context: ...riables} You need a private key in order to sign transactions. Create a .env fi...

(IN_ORDER_TO_PREMIUM)

public/tutorials/cross-dom-bridge-eth.js (2)

36-42: Add input validation for the 'amount' parameter

Currently, the depositETH function does not validate the amount input. Validating inputs helps prevent errors and ensures that the function behaves as expected.

Consider adding input validation at the start of the function:

 async function depositETH(amount) {
+    if (isNaN(amount) || Number(amount) <= 0) {
+        throw new Error('Invalid amount. Please enter a positive number.');
+    }
     try {
         // Build the deposit transaction parameters

This will alert the user if an invalid amount is provided.


63-65: Provide more detailed error handling

While the current catch block logs the error, providing more contextual information can aid in debugging.

Enhance the error handling with additional details:

 } catch (error) {
-    console.error('Error during deposit:', error);
+    console.error('Error during ETH deposit:', error.message);
+    if (error.response) {
+        console.error('Response data:', error.response.data);
+    }
 }

This will output the error message and any response data if available.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5b33b41 and 4b884a3.

📒 Files selected for processing (2)
  • pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1 hunks)
  • public/tutorials/cross-dom-bridge-eth.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1)

Pattern **/*.mdx: "ALWAYS review Markdown content THOROUGHLY with the following criteria:

  • Use proper nouns in place of personal pronouns like 'We' and 'Our' to maintain consistency in communal documentation.
  • Avoid gender-specific language and use the imperative form.
  • Monitor capitalization for emphasis. Use bold for prominence instead of all caps or italics.
  • Ensure proper nouns are capitalized in sentences.
  • Apply the Oxford comma.
  • Use proper title case for headers, buttons, tab names, page names, and links. Sentence case should be used for body content and short phrases, even in links.
  • Use correct spelling and grammar at all times (IMPORTANT).
    "
LanguageTool
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx

[style] ~15-~15: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~60-~60: Consider a shorter alternative to avoid wordiness.
Context: ...riables} You need a private key in order to sign transactions. Create a .env fi...

(IN_ORDER_TO_PREMIUM)

🔇 Additional comments not posted (3)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (2)

2-4: LGTM: Title and description are clear and follow guidelines.

The title uses proper title case, and the description effectively communicates the purpose of the tutorial. Good job!


1-548: Excellent tutorial on bridging ETH using Viem!

This tutorial provides a comprehensive guide for bridging ETH between L1 and L2 using the Viem library. The content is well-structured, with clear explanations and code snippets that follow best practices. The inclusion of important considerations and next steps adds valuable context for users.

Great job on creating an informative and user-friendly tutorial!

🧰 Tools
LanguageTool

[style] ~15-~15: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~60-~60: Consider a shorter alternative to avoid wordiness.
Context: ...riables} You need a private key in order to sign transactions. Create a .env fi...

(IN_ORDER_TO_PREMIUM)

public/tutorials/cross-dom-bridge-eth.js (1)

45-45: Verify the availability of 'depositTransaction' method on 'walletClientL1'

The method depositTransaction might not be available on the walletClientL1 if it's not properly extended with the necessary actions.

Run the following script to confirm if depositTransaction is a method available on walletClientL1:

Ensure that walletActionsL1() includes the depositTransaction method.

public/tutorials/cross-dom-bridge-eth.js Outdated Show resolved Hide resolved
public/tutorials/cross-dom-bridge-eth.js Outdated Show resolved Hide resolved
public/tutorials/cross-dom-bridge-eth.js Outdated Show resolved Hide resolved
krofax and others added 2 commits September 25, 2024 16:45
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (4)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (4)

11-12: Consider elaborating on Viem's safety features.

The introduction provides a good context for using Viem. To make it more informative, consider briefly mentioning specific safety features that Viem provides to prevent common mistakes. This will give readers a clearer understanding of Viem's advantages.


21-24: Specify the exact minimum Node.js version required.

The prerequisites are clear and relevant. However, for Node.js, consider specifying the exact minimum version required (e.g., "Node.js version 14.0.0 or later") instead of just saying "version 14 or later". This will help users ensure they have a compatible environment.


70-74: Consider using a more generic name for the private key variable.

The environment variables are set up correctly. However, the name TUTORIAL_PRIVATE_KEY might be confusing in a real-world scenario. Consider using a more generic name like WALLET_PRIVATE_KEY or simply PRIVATE_KEY. This will make the code more reusable outside of the tutorial context.


165-168: Consider making the "Get ETH on Sepolia" section more prominent.

The information about obtaining test ETH is crucial for users following the tutorial. Consider making this section more noticeable, perhaps by using a callout or adding a clear heading. This will ensure that users don't miss this important step.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4b884a3 and 8d10886.

📒 Files selected for processing (2)
  • pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1 hunks)
  • public/tutorials/cross-dom-bridge-eth.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • public/tutorials/cross-dom-bridge-eth.js
🧰 Additional context used
📓 Path-based instructions (1)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1)

Pattern **/*.mdx: "ALWAYS review Markdown content THOROUGHLY with the following criteria:

  • Use proper nouns in place of personal pronouns like 'We' and 'Our' to maintain consistency in communal documentation.
  • Avoid gender-specific language and use the imperative form.
  • Monitor capitalization for emphasis. Use bold for prominence instead of all caps or italics.
  • Ensure proper nouns are capitalized in sentences.
  • Apply the Oxford comma.
  • Use proper title case for headers, buttons, tab names, page names, and links. Sentence case should be used for body content and short phrases, even in links.
  • Use correct spelling and grammar at all times (IMPORTANT).
    "
LanguageTool
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx

[style] ~15-~15: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~60-~60: Consider a shorter alternative to avoid wordiness.
Context: ...riables} You need a private key in order to sign transactions. Create a .env fi...

(IN_ORDER_TO_PREMIUM)


[uncategorized] ~172-~172: Possible missing comma found.
Context: ...osit ETH Now that you have some ETH on L1 you can deposit that ETH into the `L1St...

(AI_HYDRA_LEO_MISSING_COMMA)

GitHub Check: lint
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx

[warning] 537-537:
Marker style should be *


[warning] 537-537:
Incorrect list-item indent: add 2 spaces


[warning] 538-538:
Marker style should be *


[warning] 538-538:
Incorrect list-item indent: add 2 spaces


[warning] 539-539:
Marker style should be *


[warning] 539-539:
Incorrect list-item indent: add 2 spaces


[warning] 540-540:
Marker style should be *


[warning] 540-540:
Incorrect list-item indent: add 2 spaces

🔇 Additional comments not posted (5)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (5)

2-4: Title and description accurately reflect the tutorial content.

The updated title and description clearly communicate the purpose of the tutorial, which is to use Viem for bridging ETH between L1 and L2. This change aligns well with the tutorial's content.


55-56: Dependency installation command is correct and complete.

The pnpm add viem dotenv command correctly installs the necessary dependencies for the tutorial. This ensures that users have all the required packages to follow along.


88-95: Imports and dotenv configuration are correct and complete.

The necessary modules from viem and other packages are correctly imported. The dotenv configuration is properly set up, ensuring that environment variables will be loaded. This provides a solid foundation for the rest of the tutorial.


174-318: Deposit ETH function is well-structured and includes necessary safeguards.

The deposit function is explained in a clear, step-by-step manner. It includes proper error handling and logging, which is crucial for debugging and user feedback. The callout about smart contract wallets is a valuable addition for safety. This section provides a comprehensive guide for users to deposit ETH.


332-532: Withdraw ETH function is comprehensive and well-explained.

The withdrawal process is explained in great detail, including all necessary steps such as proving and finalizing the withdrawal. The inclusion of information about the challenge period is crucial for users to understand the complete process. This section provides a thorough guide for withdrawing ETH from L2 to L1.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (2)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (2)

17-29: Consider clarifying the pnpm installation command.

The prerequisites section is comprehensive and relevant. However, the pnpm installation command could be more explicit about its global nature.

Consider updating the pnpm installation command for clarity:

-npm install -g pnpm
+npm install --global pnpm

This change makes it more evident that pnpm is being installed globally.


330-531: Consider adding more context to the withdrawal process.

The deposit and withdrawal sections provide detailed steps and code snippets, which is excellent. However, the withdrawal process, particularly the waiting periods, could benefit from additional explanation.

Consider adding brief explanations for the following steps in the withdrawal process:

  1. Why the waitToProve step is necessary.
  2. The purpose of the proveWithdrawal step.
  3. Why there's a waiting period before finalization and how long it typically takes.

This additional context will help users better understand the withdrawal process and set appropriate expectations for transaction times.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8d10886 and e1968a9.

📒 Files selected for processing (2)
  • pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1 hunks)
  • public/tutorials/cross-dom-bridge-eth.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • public/tutorials/cross-dom-bridge-eth.js
🧰 Additional context used
📓 Path-based instructions (1)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1)

Pattern **/*.mdx: "ALWAYS review Markdown content THOROUGHLY with the following criteria:

  • Use proper nouns in place of personal pronouns like 'We' and 'Our' to maintain consistency in communal documentation.
  • Avoid gender-specific language and use the imperative form.
  • Monitor capitalization for emphasis. Use bold for prominence instead of all caps or italics.
  • Ensure proper nouns are capitalized in sentences.
  • Apply the Oxford comma.
  • Use proper title case for headers, buttons, tab names, page names, and links. Sentence case should be used for body content and short phrases, even in links.
  • Use correct spelling and grammar at all times (IMPORTANT).
    "
🪛 LanguageTool
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx

[style] ~15-~15: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~60-~60: Consider a shorter alternative to avoid wordiness.
Context: ...riables} You need a private key in order to sign transactions. Create a .env fi...

(IN_ORDER_TO_PREMIUM)


[uncategorized] ~172-~172: Possible missing comma found.
Context: ...osit ETH Now that you have some ETH on L1 you can deposit that ETH into the `L1St...

(AI_HYDRA_LEO_MISSING_COMMA)

🔇 Additional comments (3)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (3)

2-12: LGTM! Clear and informative introduction.

The title, description, and introduction effectively communicate the purpose of the tutorial and highlight the use of the viem/op-stack library. The content is well-structured and provides a good overview for the reader.


33-79: LGTM! Well-structured setup instructions.

The project setup section provides clear, step-by-step instructions for initializing the project, installing dependencies, and configuring environment variables. The security warning about private keys is an important inclusion.

🧰 Tools
🪛 LanguageTool

[style] ~60-~60: Consider a shorter alternative to avoid wordiness.
Context: ...riables} You need a private key in order to sign transactions. Create a .env fi...

(IN_ORDER_TO_PREMIUM)


1-548: Overall, an excellent and comprehensive tutorial.

This tutorial provides a thorough guide for bridging ETH between L1 and L2 using Viem. The content is well-structured, with clear explanations and code examples. The suggested improvements, if implemented, will further enhance the tutorial's clarity and user-friendliness.

Key strengths:

  1. Clear introduction and prerequisites
  2. Well-organized setup instructions
  3. Detailed explanations of deposit and withdrawal processes

Areas for improvement:

  1. Removing duplicate imports
  2. Correcting the L2 wallet client setup
  3. Adding more context to the withdrawal process
  4. Enhancing the Next Steps section

Great job on creating this valuable resource for developers!

🧰 Tools
🪛 LanguageTool

[style] ~15-~15: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~60-~60: Consider a shorter alternative to avoid wordiness.
Context: ...riables} You need a private key in order to sign transactions. Create a .env fi...

(IN_ORDER_TO_PREMIUM)


[uncategorized] ~172-~172: Possible missing comma found.
Context: ...osit ETH Now that you have some ETH on L1 you can deposit that ETH into the `L1St...

(AI_HYDRA_LEO_MISSING_COMMA)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e1968a9 and 27d7848.

📒 Files selected for processing (1)
  • pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1)

Pattern **/*.mdx: "ALWAYS review Markdown content THOROUGHLY with the following criteria:

  • Use proper nouns in place of personal pronouns like 'We' and 'Our' to maintain consistency in communal documentation.
  • Avoid gender-specific language and use the imperative form.
  • Monitor capitalization for emphasis. Use bold for prominence instead of all caps or italics.
  • Ensure proper nouns are capitalized in sentences.
  • Apply the Oxford comma.
  • Use proper title case for headers, buttons, tab names, page names, and links. Sentence case should be used for body content and short phrases, even in links.
  • Use correct spelling and grammar at all times (IMPORTANT).
    "
🪛 LanguageTool
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx

[style] ~15-~15: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~60-~60: Consider a shorter alternative to avoid wordiness.
Context: ...riables} You need a private key in order to sign transactions. Create a .env fi...

(IN_ORDER_TO_PREMIUM)


[uncategorized] ~172-~172: Possible missing comma found.
Context: ...osit ETH Now that you have some ETH on L1 you can deposit that ETH into the `L1St...

(AI_HYDRA_LEO_MISSING_COMMA)

🔇 Additional comments (6)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (6)

2-4: LGTM: Title and description accurately reflect the tutorial content.

The updated title and description clearly communicate the purpose of the tutorial, which is to bridge ETH using Viem. This change aligns well with the tutorial's content.


9-29: LGTM: Comprehensive introduction and prerequisites.

The introduction clearly explains the purpose of the tutorial and the use of the Viem library. The prerequisites are well-defined, including necessary background knowledge and tools. The inclusion of pnpm installation instructions is helpful for users who may not have it installed.

🧰 Tools
🪛 LanguageTool

[style] ~15-~15: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


33-79: LGTM: Clear and comprehensive project setup instructions.

The project setup instructions are well-structured and easy to follow. They cover all necessary steps, including project initialization, dependency installation, and environment variable setup. The warning about private key security is a crucial reminder for users.

🧰 Tools
🪛 LanguageTool

[style] ~60-~60: Consider a shorter alternative to avoid wordiness.
Context: ...riables} You need a private key in order to sign transactions. Create a .env fi...

(IN_ORDER_TO_PREMIUM)


172-316: LGTM: Comprehensive and clear ETH deposit instructions.

The ETH deposit section provides clear, step-by-step instructions with accompanying code snippets. The use of tabs to separate the step-by-step process from the full code example is helpful for users with different levels of experience. The code appears correct and follows best practices.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~172-~172: Possible missing comma found.
Context: ...osit ETH Now that you have some ETH on L1 you can deposit that ETH into the `L1St...

(AI_HYDRA_LEO_MISSING_COMMA)


330-531: LGTM: Detailed and accurate ETH withdrawal instructions.

The ETH withdrawal section provides a comprehensive guide to the withdrawal process, including building the transaction, proving the withdrawal, and finalizing it. The step-by-step instructions with code snippets are clear and easy to follow. The inclusion of a full code example is beneficial for users who prefer to see the entire process at once.


1-548: Overall, a well-structured and informative tutorial with minor improvements needed.

This tutorial on bridging ETH to OP Mainnet using Viem is comprehensive and well-organized. It covers all necessary steps from setup to execution, providing clear instructions and code examples throughout. The use of Tabs and Steps components enhances readability and user experience.

A few minor issues were identified:

  1. A duplicate import in the dependencies section.
  2. An incorrect extension in the L2 wallet client setup.
  3. Formatting inconsistencies in the Important Considerations section.
  4. The Next Steps section could be more engaging and actionable.

Addressing these issues will further improve the quality of this already valuable tutorial. Great job on creating a resource that will be helpful for developers working with Layer 2 solutions!

🧰 Tools
🪛 LanguageTool

[style] ~15-~15: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~60-~60: Consider a shorter alternative to avoid wordiness.
Context: ...riables} You need a private key in order to sign transactions. Create a .env fi...

(IN_ORDER_TO_PREMIUM)


[uncategorized] ~172-~172: Possible missing comma found.
Context: ...osit ETH Now that you have some ETH on L1 you can deposit that ETH into the `L1St...

(AI_HYDRA_LEO_MISSING_COMMA)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (1)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1)

504-511: Improve formatting in the Important Considerations section

The content of this section is crucial for users to understand the implications of bridging ETH. To improve readability and consistency, update the formatting as follows:

 <Callout type="warning">
-  *   **Challenge Period**: The 7-day waiting period is crucial for security.
-  *   **Gas Costs**: Withdrawals involve transactions on both L2 and L1, each incurring gas fees.
-  *   **Private Key Handling**: Use secure key management practices in real applications.
-  *   **RPC Endpoint Security**: Keep your Alchemy API key (or any RPC endpoint) secure.
+  * **Challenge Period**: The 7-day waiting period is crucial for security.
+  * **Gas Costs**: Withdrawals involve transactions on both L2 and L1, each incurring gas fees.
+  * **Private Key Handling**: Use secure key management practices in real applications.
+  * **RPC Endpoint Security**: Keep your Alchemy API key (or any RPC endpoint) secure.
 </Callout>

This change ensures consistent list item formatting and improves readability.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 27d7848 and 5dec40d.

📒 Files selected for processing (1)
  • pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1)

Pattern **/*.mdx: "ALWAYS review Markdown content THOROUGHLY with the following criteria:

  • Use proper nouns in place of personal pronouns like 'We' and 'Our' to maintain consistency in communal documentation.
  • Avoid gender-specific language and use the imperative form.
  • Monitor capitalization for emphasis. Use bold for prominence instead of all caps or italics.
  • Ensure proper nouns are capitalized in sentences.
  • Apply the Oxford comma.
  • Use proper title case for headers, buttons, tab names, page names, and links. Sentence case should be used for body content and short phrases, even in links.
  • Use correct spelling and grammar at all times (IMPORTANT).
    "
🪛 LanguageTool
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx

[style] ~17-~17: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~23-~23: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...are included in Viem by default. If you want to use a network that isn't included by de...

(REP_WANT_TO_VB)

🪛 GitHub Check: lint
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx

[warning] 27-27:
Incorrect list-item indent: add 2 spaces


[warning] 28-28:
Incorrect list-item indent: add 2 spaces

🔇 Additional comments (2)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (2)

2-4: LGTM: Updated metadata and imports for Viem tutorial

The title, description, and imports have been correctly updated to reflect the transition from the Optimism SDK to Viem for bridging ETH. This change aligns well with the tutorial's new focus.

Also applies to: 10-14


Line range hint 1-519: Overall: Excellent tutorial on bridging ETH with Viem

This tutorial provides a comprehensive and well-structured guide for bridging ETH using Viem. The transition from the Optimism SDK to Viem has been handled effectively, with clear explanations and code examples. The step-by-step instructions for both depositing and withdrawing ETH are detailed and easy to follow.

Key strengths:

  1. Clear introduction and setup instructions
  2. Comprehensive code examples for deposit and withdrawal functions
  3. Important considerations highlighted for users
  4. Helpful next steps for further development

The suggested improvements in the previous comments will further enhance the quality and user-friendliness of this tutorial. Great job on creating a valuable resource for developers working with OP Stack and Viem!

🧰 Tools
🪛 LanguageTool

[style] ~80-~80: Consider a shorter alternative to avoid wordiness.
Context: ...our Environment You need a private key in order to sign transactions. Set your private key...

(IN_ORDER_TO_PREMIUM)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Outside diff range and nitpick comments (7)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (7)

12-14: Clear introduction to Viem, with a minor suggestion.

The introduction to Viem is well-written and informative. It clearly explains what Viem is and its purpose in the context of this tutorial.

Consider adding a brief mention of the advantages of using Viem over the previously used Optimism SDK to provide context for the change.


21-23: Informative section on supported networks, with a minor style suggestion.

This section provides valuable information about the networks supported by Viem, which is crucial for users of this tutorial.

To improve readability, consider rephrasing the last sentence to avoid repetition:

- If you want to use a network that isn't included by default, you can add it to Viem's chain configurations.
+ For networks not included by default, you can add them to Viem's chain configurations.
🧰 Tools
🪛 LanguageTool

[style] ~23-~23: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...are included in Viem by default. If you want to use a network that isn't included by de...

(REP_WANT_TO_VB)


51-54: Clear installation instructions with a suggestion for improvement.

The updated installation instructions correctly include Viem and dotenv, which are essential for this tutorial. The use of pnpm for package management is consistent with the earlier dependencies section.

Consider adding a brief explanation of why dotenv is being installed, such as:

Install `viem` for Ethereum interactions, and `dotenv` for securely managing environment variables like private keys and RPC URLs.

This addition would help users understand the purpose of each package.


144-210: Well-structured and clear deposit ETH guide.

The deposit ETH section is well-organized, using Tabs and Steps components effectively. The step-by-step instructions are clear and easy to follow, with appropriate code snippets and explanations.

To improve clarity, consider adding a brief explanation of the buildDepositTransaction function's purpose before the code snippet in step 2. For example:

The `buildDepositTransaction` function prepares the necessary parameters for depositing ETH from L1 to L2, including the amount to deposit and the recipient address on L2.

This addition would help users understand the function's role in the deposit process.


251-281: Well-structured depositETH function with room for improved error handling.

The depositETH function effectively encapsulates the entire deposit process, including transaction building, execution, and confirmation on both L1 and L2. The use of a try-catch block for error handling is appropriate.

Consider enhancing the error handling to provide more specific information about where in the process an error occurred. For example:

async function depositETH(amount) {
    try {
        // ... (existing code)
    } catch (error) {
        if (error.message.includes('buildDepositTransaction')) {
            console.error('Error building deposit transaction:', error);
        } else if (error.message.includes('depositTransaction')) {
            console.error('Error sending deposit transaction:', error);
        } else if (error.message.includes('waitForTransactionReceipt')) {
            console.error('Error waiting for transaction receipt:', error);
        } else {
            console.error('Unexpected error during deposit:', error);
        }
    }
}

This more detailed error handling will make it easier to diagnose issues during the deposit process.


298-406: Comprehensive and well-structured withdraw ETH guide.

The withdraw ETH section is thorough and well-organized, using Tabs and Steps components effectively. The step-by-step instructions cover the entire withdrawal process, including initiation, proving, and finalization. The explanation of the challenge period is crucial for user understanding.

To improve user experience during the long waiting periods, consider adding more detailed progress updates. For example:

console.log('Waiting for withdrawal to be ready to prove...');
const { output, withdrawal } = await publicClientL1.waitToProve({
    receipt,
    targetChain: walletClientL2.chain
});
console.log('Withdrawal ready to prove. Building prove arguments...');

// ... (rest of the function)

console.log('Waiting for the challenge period (up to 7 days on mainnet)...');
const awaitWithdrawal = await publicClientL1.waitToFinalize({
    targetChain: walletClientL2.chain,
    withdrawalHash: withdrawal.withdrawalHash,
});
console.log('Challenge period completed. Finalizing withdrawal...');

These additional log messages will keep the user informed about the progress of their withdrawal, especially during the long challenge period.


446-496: Comprehensive withdrawETH function with opportunities for improvement.

The withdrawETH function effectively encapsulates the entire withdrawal process, including initiation, proving, and finalization. The use of a try-catch block for error handling is appropriate.

Consider the following improvements:

  1. Enhance error handling to provide more specific information:
try {
    // ... (existing code)
} catch (error) {
    if (error.message.includes('buildWithdrawalTransaction')) {
        console.error('Error building withdrawal transaction:', error);
    } else if (error.message.includes('initiateWithdrawal')) {
        console.error('Error initiating withdrawal:', error);
    } else if (error.message.includes('waitToProve')) {
        console.error('Error waiting to prove withdrawal:', error);
    } else if (error.message.includes('proveWithdrawal')) {
        console.error('Error proving withdrawal:', error);
    } else if (error.message.includes('waitToFinalize')) {
        console.error('Error waiting to finalize withdrawal:', error);
    } else if (error.message.includes('finalizeWithdrawal')) {
        console.error('Error finalizing withdrawal:', error);
    } else {
        console.error('Unexpected error during withdrawal:', error);
    }
}
  1. Add more detailed progress updates to improve user experience:
console.log('Initiating withdrawal...');
const hash = await walletClientL2.initiateWithdrawal(args);
console.log(`Withdrawal initiated. Transaction hash: ${hash}`);

// ... (existing code)

console.log('Waiting for withdrawal to be ready to prove (this may take up to 1 hour)...');
const { output, withdrawal } = await publicClientL1.waitToProve({
    receipt,
    targetChain: walletClientL2.chain
});
console.log('Withdrawal ready to prove. Proceeding with proof...');

// ... (rest of the function with similar progress updates)

These improvements will provide better error diagnostics and keep users informed about the progress of their withdrawal.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5dec40d and f9da7ef.

📒 Files selected for processing (1)
  • pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1)

Pattern **/*.mdx: "ALWAYS review Markdown content THOROUGHLY with the following criteria:

  • Use proper nouns in place of personal pronouns like 'We' and 'Our' to maintain consistency in communal documentation.
  • Avoid gender-specific language and use the imperative form.
  • Monitor capitalization for emphasis. Use bold for prominence instead of all caps or italics.
  • Ensure proper nouns are capitalized in sentences.
  • Apply the Oxford comma.
  • Use proper title case for headers, buttons, tab names, page names, and links. Sentence case should be used for body content and short phrases, even in links.
  • Use correct spelling and grammar at all times (IMPORTANT).
    "
🪛 LanguageTool
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx

[style] ~17-~17: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~23-~23: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...are included in Viem by default. If you want to use a network that isn't included by de...

(REP_WANT_TO_VB)


[uncategorized] ~86-~86: Possible missing comma found.
Context: ...o interact with Viem. To start the Node REPL run the following command in your termi...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~235-~235: A punctuation mark might be missing here.
Context: ...sport: http("https://sepolia.optimism.io"), }).extend(walletActionsL1()); // Cre...

(AI_EN_LECTOR_MISSING_PUNCTUATION)

🪛 GitHub Check: lint
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx

[warning] 27-27:
Incorrect list-item indent: add 2 spaces


[warning] 28-28:
Incorrect list-item indent: add 2 spaces

🔇 Additional comments (2)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (2)

2-4: Title and description accurately reflect the tutorial's content.

The updated title and description clearly communicate the tutorial's focus on using Viem for bridging ETH between layers. This change aligns well with the tutorial's new content.


32-33: Clear introduction to using Viem in the tutorial.

This section effectively introduces Viem and provides context for its use in the tutorial. The explanation of Viem as a Node.js library is helpful for users to understand the environment they'll be working in.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (6)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (6)

17-17: Minor grammatical correction needed.

Change "work" to "works" for proper subject-verb agreement.

-Make sure to check out the [Standard Bridge guide](/builders/app-developers/bridging/standard-bridge) if you want to learn more about how the bridge work under the hood.
+Make sure to check out the [Standard Bridge guide](/builders/app-developers/bridging/standard-bridge) if you want to learn more about how the bridge works under the hood.
🧰 Tools
🪛 LanguageTool

[style] ~17-~17: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


27-28: Correct list item indentation.

The list items for dependencies should be indented with 2 spaces for consistency with Markdown formatting standards.

-* [node](https://nodejs.org/en/)
-* [pnpm](https://pnpm.io/installation)
+  * [node](https://nodejs.org/en/)
+  * [pnpm](https://pnpm.io/installation)
🧰 Tools
🪛 GitHub Check: lint

[warning] 27-27:
Incorrect list-item indent: add 2 spaces


[warning] 28-28:
Incorrect list-item indent: add 2 spaces


86-86: Add missing comma.

Add a comma after "To start the Node REPL" for better readability and correct punctuation.

-To start the Node REPL run the following command in your terminal:
+To start the Node REPL, run the following command in your terminal:
🧰 Tools
🪛 LanguageTool

[uncategorized] ~86-~86: Possible missing comma found.
Context: ...o interact with Viem. To start the Node REPL run the following command in your termi...

(AI_HYDRA_LEO_MISSING_COMMA)


101-101: Remove duplicate import of getL2TransactionHashes.

The getL2TransactionHashes function is imported twice. Remove the duplicate import to keep the code clean.

-const { getL2TransactionHashes, publicActionsL2, walletActionsL1, getL2TransactionHashes } = require('viem/op-stack');
+const { getL2TransactionHashes, publicActionsL2, walletActionsL1 } = require('viem/op-stack');

142-142: Add missing comma.

Add a comma after "Now that you have some ETH on L1" for better readability and correct punctuation.

-Now that you have some ETH on L1 you can deposit that ETH into the `L1StandardBridge` contract.
+Now that you have some ETH on L1, you can deposit that ETH into the `L1StandardBridge` contract.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~142-~142: Possible missing comma found.
Context: ...osit ETH Now that you have some ETH on L1 you can deposit that ETH into the `L1St...

(AI_HYDRA_LEO_MISSING_COMMA)


503-506: Correct list item formatting in Callout.

The list items inside the Callout component should use a single asterisk without extra spaces for consistent Markdown formatting.

<Callout type="warning">
-  *   **Challenge Period**: The 7-day waiting period is crucial for security.
-  *   **Gas Costs**: Withdrawals involve transactions on both L2 and L1, each incurring gas fees.
-  *   **Private Key Handling**: Use secure key management practices in real applications.
-  *   **RPC Endpoint Security**: Keep your Alchemy API key (or any RPC endpoint) secure.
+  * **Challenge Period**: The 7-day waiting period is crucial for security.
+  * **Gas Costs**: Withdrawals involve transactions on both L2 and L1, each incurring gas fees.
+  * **Private Key Handling**: Use secure key management practices in real applications.
+  * **RPC Endpoint Security**: Keep your Alchemy API key (or any RPC endpoint) secure.
</Callout>
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f9da7ef and 92314e9.

📒 Files selected for processing (1)
  • pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1)

Pattern **/*.mdx: "ALWAYS review Markdown content THOROUGHLY with the following criteria:

  • Use proper nouns in place of personal pronouns like 'We' and 'Our' to maintain consistency in communal documentation.
  • Avoid gender-specific language and use the imperative form.
  • Monitor capitalization for emphasis. Use bold for prominence instead of all caps or italics.
  • Ensure proper nouns are capitalized in sentences.
  • Apply the Oxford comma.
  • Use proper title case for headers, buttons, tab names, page names, and links. Sentence case should be used for body content and short phrases, even in links.
  • Use correct spelling and grammar at all times (IMPORTANT).
    "
🪛 LanguageTool
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx

[style] ~17-~17: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~23-~23: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...are included in Viem by default. If you want to use a network that isn't included by de...

(REP_WANT_TO_VB)


[uncategorized] ~86-~86: Possible missing comma found.
Context: ...o interact with Viem. To start the Node REPL run the following command in your termi...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~142-~142: Possible missing comma found.
Context: ...osit ETH Now that you have some ETH on L1 you can deposit that ETH into the `L1St...

(AI_HYDRA_LEO_MISSING_COMMA)

🪛 GitHub Check: lint
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx

[warning] 27-27:
Incorrect list-item indent: add 2 spaces


[warning] 28-28:
Incorrect list-item indent: add 2 spaces

🔇 Additional comments (1)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1)

131-131: ⚠️ Potential issue

Correct the L2 wallet client setup.

The L2 wallet client is incorrectly using walletActionsL1() instead of walletActionsL2(). This could lead to unexpected behavior when interacting with the L2 network.

-}).extend(walletActionsL1());
+}).extend(walletActionsL2());

Likely invalid or redundant comment.

@krofax
Copy link
Contributor Author

krofax commented Oct 2, 2024

@brokewhale You can check out this tutorial now.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (4)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (4)

27-28: Correct indentation for prerequisites list.

The prerequisites and project setup instructions are clear and appropriate. However, there's a minor formatting issue with the list items for Node.js and pnpm.

Please update the indentation as follows:

-* [node](https://nodejs.org/en/)
-* [pnpm](https://pnpm.io/installation)
+  * [node](https://nodejs.org/en/)
+  * [pnpm](https://pnpm.io/installation)

This change will ensure consistent formatting throughout the document.

Also applies to: 32-54

🧰 Tools
🪛 GitHub Check: lint

[warning] 27-27:
Incorrect list-item indent: add 2 spaces


[warning] 28-28:
Incorrect list-item indent: add 2 spaces


142-498: Enhance error handling in deposit and withdrawal functions.

The deposit and withdrawal functions are well-implemented using Viem methods. To improve robustness, consider enhancing the error handling in both functions.

For the depositETH function:

 async function depositETH(amount) {
     try {
         // ... (existing code)
     } catch (error) {
-        console.error('Error during deposit:', error);
+        if (error.message.includes('buildDepositTransaction')) {
+            console.error('Error building deposit transaction:', error);
+        } else if (error.message.includes('depositTransaction')) {
+            console.error('Error sending deposit transaction:', error);
+        } else if (error.message.includes('waitForTransactionReceipt')) {
+            console.error('Error waiting for transaction receipt:', error);
+        } else {
+            console.error('Unexpected error during deposit:', error);
+        }
     }
 }

Apply a similar pattern to the withdrawETH function, categorizing errors based on the specific step where they occur.

This change will provide more specific error messages, making it easier to debug issues in different parts of the deposit and withdrawal processes.


500-506: Fix formatting in the Important Considerations section.

The content of this section effectively highlights crucial points for users. However, there's a minor formatting issue with the list item indentation.

Please update the formatting as follows:

<Callout type="warning">
-  *   **Challenge Period**: The 7-day waiting period is crucial for security.
-  *   **Gas Costs**: Withdrawals involve transactions on both L2 and L1, each incurring gas fees.
-  *   **Private Key Handling**: Use secure key management practices in real applications.
-  *   **RPC Endpoint Security**: Keep your Alchemy API key (or any RPC endpoint) secure.
+  * **Challenge Period**: The 7-day waiting period is crucial for security.
+  * **Gas Costs**: Withdrawals involve transactions on both L2 and L1, each incurring gas fees.
+  * **Private Key Handling**: Use secure key management practices in real applications.
+  * **RPC Endpoint Security**: Keep your Alchemy API key (or any RPC endpoint) secure.
</Callout>

This change ensures consistent formatting and improves readability.


511-515: Enhance the Next Steps section for better engagement.

Consider expanding the Next Steps section to provide more comprehensive guidance and encourage further learning. Here's a suggested structure:

  1. Start with a congratulatory message.
  2. Provide a numbered list of specific, actionable next steps.
  3. Encourage exploration of more complex scenarios or additional Viem features.
  4. End with a call-to-action, such as inviting readers to share their projects or ask questions in a community forum.

Example:

## Next Steps

Congratulations on successfully bridging ETH using Viem! You've taken a significant step in working with Layer 2 solutions. To continue your journey:

1. Develop a user interface for easier interaction with these bridging functions.
2. Implement robust error handling and retry mechanisms for production use.
3. Explore bridging other tokens, such as ERC-20, using similar techniques.
4. Dive deeper into Viem's documentation to discover more advanced features.

Remember, the same process you've learned works for Ethereum and OP Mainnet. We encourage you to experiment with different scenarios and share your projects with the community. If you have any questions or want to showcase your work, join our community forum at [insert forum link].

Happy coding!

This structure provides a more motivating conclusion to the tutorial and clearer direction for further learning.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 92314e9 and c02ab8f.

📒 Files selected for processing (1)
  • pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1)

Pattern **/*.mdx: "ALWAYS review Markdown content THOROUGHLY with the following criteria:

  • Use proper nouns in place of personal pronouns like 'We' and 'Our' to maintain consistency in communal documentation.
  • Avoid gender-specific language and use the imperative form.
  • Monitor capitalization for emphasis. Use bold for prominence instead of all caps or italics.
  • Ensure proper nouns are capitalized in sentences.
  • Apply the Oxford comma.
  • Use proper title case for headers, buttons, tab names, page names, and links. Sentence case should be used for body content and short phrases, even in links.
  • Use correct spelling and grammar at all times (IMPORTANT).
    "
🪛 LanguageTool
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx

[style] ~17-~17: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~23-~23: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...are included in Viem by default. If you want to use a network that isn't included by de...

(REP_WANT_TO_VB)

🪛 GitHub Check: lint
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx

[warning] 27-27:
Incorrect list-item indent: add 2 spaces


[warning] 28-28:
Incorrect list-item indent: add 2 spaces

🔇 Additional comments (2)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (2)

2-4: LGTM! Clear and informative introduction.

The updated title, description, and introduction effectively communicate the purpose of the tutorial and introduce Viem as the new tool for bridging ETH. The explanation of Viem as a TypeScript interface for Ethereum is concise and informative.

Also applies to: 10-14


Line range hint 1-515: Overall, an excellent tutorial with minor improvements suggested.

This tutorial on bridging ETH using Viem is well-structured, informative, and provides clear step-by-step instructions. The transition from the Optimism SDK to Viem has been handled effectively, with comprehensive explanations of the new methods and processes.

Key strengths:

  1. Clear introduction and explanation of Viem's role.
  2. Well-organized code snippets with explanations.
  3. Comprehensive coverage of both deposit and withdrawal processes.

Suggested improvements:

  1. Minor formatting fixes for list indentations.
  2. Enhanced error handling in deposit and withdrawal functions.
  3. Expanded Next Steps section for better user engagement.

Implementing these suggestions will further improve an already strong tutorial, making it even more valuable for developers looking to work with Layer 2 solutions using Viem.

🧰 Tools
🪛 LanguageTool

[style] ~76-~76: Consider a shorter alternative to avoid wordiness.
Context: ...our Environment You need a private key in order to sign transactions. Set your private key...

(IN_ORDER_TO_PREMIUM)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (7)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (7)

2-4: LGTM! Clear and informative introduction.

The updated title, description, and introduction accurately reflect the transition to using Viem for bridging ETH. The explanation of Viem's role is concise and informative.

Consider rephrasing the last sentence of the introduction for better flow:

-It offers an easy way to add bridging functionality to your JavaScript-based application.
+It provides a straightforward way to implement bridging functionality in your JavaScript-based applications.

Also applies to: 9-13


20-22: LGTM! Informative network support and dependencies sections.

The explanation of supported networks is clear and helpful. The dependencies are correctly listed.

Improve the formatting of the dependencies list for better readability:

-*   [node](https://nodejs.org/en/)
-*   [pnpm](https://pnpm.io/installation)
+  * [node](https://nodejs.org/en/)
+  * [pnpm](https://pnpm.io/installation)

Also applies to: 27-28

🧰 Tools
🪛 LanguageTool

[style] ~22-~22: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...are included in Viem by default. If you want to use a network that isn't included by de...

(REP_WANT_TO_VB)


31-54: LGTM! Clear project setup instructions.

The step-by-step guide for creating a demo project is well-structured and easy to follow. The use of the Steps component enhances readability.

Consider updating the heading of step 3 for accuracy:

-  {<h3>Install the Optimism SDK</h3>}
+  {<h3>Install Dependencies</h3>}

This change better reflects the actual step of installing Viem and dotenv.


Line range hint 63-91: LGTM! Helpful setup instructions for ETH and environment.

The instructions for obtaining Sepolia ETH, setting up the environment variable, and starting the Node REPL are clear and concise.

Correct a minor grammatical issue in the Node REPL section:

-To start the Node REPL run the following command in your terminal:
+To start the Node REPL, run the following command in your terminal:
🧰 Tools
🪛 LanguageTool

[style] ~73-~73: Consider a shorter alternative to avoid wordiness.
Context: ...our Environment You need a private key in order to sign transactions. Set your private key...

(IN_ORDER_TO_PREMIUM)


140-281: LGTM! Comprehensive deposit instructions with room for improvement.

The deposit process is well-explained with clear step-by-step instructions. The use of tabs for full code and individual steps enhances readability.

Consider enhancing the error handling in the depositETH function:

 async function depositETH(amount) {
     try {
         // ... (existing code)
     } catch (error) {
-        console.error('Error during deposit:', error);
+        if (error.message.includes('buildDepositTransaction')) {
+            console.error('Error building deposit transaction:', error);
+        } else if (error.message.includes('depositTransaction')) {
+            console.error('Error sending deposit transaction:', error);
+        } else if (error.message.includes('waitForTransactionReceipt')) {
+            console.error('Error waiting for transaction receipt:', error);
+        } else {
+            console.error('Unexpected error during deposit:', error);
+        }
     }
 }

This change will provide more specific error messages, making it easier to debug issues in different parts of the deposit process.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~140-~140: Possible missing comma found.
Context: ...osit ETH Now that you have some ETH on L1 you can deposit that ETH into the `L1St...

(AI_HYDRA_LEO_MISSING_COMMA)


295-498: LGTM! Well-structured withdrawal process with potential for enhanced user feedback.

The withdrawal process is thoroughly explained with clear step-by-step instructions. The use of tabs for full code and individual steps is helpful.

Consider improving user feedback during the long waiting periods in the withdrawETH function:

 async function withdrawETH(amount) {
     try {
         // ... (existing code)

         console.log('Waiting for withdrawal to be ready to prove...');
         const { output, withdrawal } = await publicClientL1.waitToProve({
             receipt,
             targetChain: walletClientL2.chain
         });
+        console.log('Withdrawal ready to prove. Building prove arguments...');

         // ... (rest of the function)

+        console.log('Waiting for the challenge period (up to 7 days on mainnet)...');
         const awaitWithdrawal = await publicClientL1.waitToFinalize({
             targetChain: walletClientL2.chain,
             withdrawalHash: withdrawal.withdrawalHash,
         });
+        console.log('Challenge period completed. Finalizing withdrawal...');

         // ... (rest of the function)

         console.log('Withdrawal completed successfully!');
     } catch (error) {
         console.error('Error during withdrawal:', error);
     }
 }

These additional log messages will keep the user informed about the progress of their withdrawal, especially during the long challenge period.


500-507: Crucial information highlighted, with a minor formatting issue.

The Important Considerations section effectively uses a Callout component to emphasize critical points about the bridging process. The content covers essential aspects that users need to be aware of, such as the challenge period, gas costs, and security considerations.

There's a minor formatting issue with the list item indentation. Please update the formatting as follows:

<Callout type="warning">
-  *   **Challenge Period**: The 7-day waiting period is crucial for security.
-  *   **Gas Costs**: Withdrawals involve transactions on both L2 and L1, each incurring gas fees.
-  *   **Private Key Handling**: Use secure key management practices in real applications.
-  *   **RPC Endpoint Security**: Keep your Alchemy API key (or any RPC endpoint) secure.
+  * **Challenge Period**: The 7-day waiting period is crucial for security.
+  * **Gas Costs**: Withdrawals involve transactions on both L2 and L1, each incurring gas fees.
+  * **Private Key Handling**: Use secure key management practices in real applications.
+  * **RPC Endpoint Security**: Keep your Alchemy API key (or any RPC endpoint) secure.
</Callout>

This change ensures consistent formatting and improves readability.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c02ab8f and 7c27591.

📒 Files selected for processing (2)
  • pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (4 hunks)
  • words.txt (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1)

Pattern **/*.mdx: "ALWAYS review Markdown content THOROUGHLY with the following criteria:

  • Use proper nouns in place of personal pronouns like 'We' and 'Our' to maintain consistency in communal documentation.
  • Avoid gender-specific language and use the imperative form.
  • Monitor capitalization for emphasis. Use bold for prominence instead of all caps or italics.
  • Ensure proper nouns are capitalized in sentences.
  • Apply the Oxford comma.
  • Use proper title case for headers, buttons, tab names, page names, and links. Sentence case should be used for body content and short phrases, even in links.
  • Use correct spelling and grammar at all times (IMPORTANT).
    "
🪛 LanguageTool
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx

[style] ~16-~16: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~22-~22: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...are included in Viem by default. If you want to use a network that isn't included by de...

(REP_WANT_TO_VB)


[style] ~73-~73: Consider a shorter alternative to avoid wordiness.
Context: ...our Environment You need a private key in order to sign transactions. Set your private key...

(IN_ORDER_TO_PREMIUM)


[uncategorized] ~84-~84: Possible missing comma found.
Context: ...o interact with Viem. To start the Node REPL run the following command in your termi...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~140-~140: Possible missing comma found.
Context: ...osit ETH Now that you have some ETH on L1 you can deposit that ETH into the `L1St...

(AI_HYDRA_LEO_MISSING_COMMA)

words.txt

[duplication] ~365-~365: Möglicher Tippfehler: ein Wort wird wiederholt
Context: ...E verkle VHOSTS vhosts Viem viem Viem's VMDEBUG vmdebug VMODULE vmodule wagmi Warpcast XORI xte...

(GERMAN_WORD_REPEAT_RULE)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Outside diff range and nitpick comments (2)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (2)

11-22: Minor style improvement and suggestion for clarity.

In line 16, consider rephrasing "if you want to learn" to "to learn" for more concise writing.

For the Supported Networks section, consider providing a brief list or link to the specific Superchain networks supported by Viem. This would give readers a clearer understanding of their options without having to navigate away from the tutorial.

🧰 Tools
🪛 LanguageTool

[style] ~16-~16: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~22-~22: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...are included in Viem by default. If you want to use a network that isn't included by de...

(REP_WANT_TO_VB)


Line range hint 26-54: Improve indentation for consistency.

The dependency list items should be indented with two spaces for better consistency with Markdown best practices. Update the list as follows:

-*   [node](https://nodejs.org/en/)
-*   [pnpm](https://pnpm.io/installation)
+  * [node](https://nodejs.org/en/)
+  * [pnpm](https://pnpm.io/installation)

This change will improve the overall formatting consistency of the document.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7c27591 and 87741c3.

📒 Files selected for processing (1)
  • pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1)

Pattern **/*.mdx: "ALWAYS review Markdown content THOROUGHLY with the following criteria:

  • Use proper nouns in place of personal pronouns like 'We' and 'Our' to maintain consistency in communal documentation.
  • Avoid gender-specific language and use the imperative form.
  • Monitor capitalization for emphasis. Use bold for prominence instead of all caps or italics.
  • Ensure proper nouns are capitalized in sentences.
  • Apply the Oxford comma.
  • Use proper title case for headers, buttons, tab names, page names, and links. Sentence case should be used for body content and short phrases, even in links.
  • Use correct spelling and grammar at all times (IMPORTANT).
    "
🪛 LanguageTool
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx

[style] ~16-~16: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~22-~22: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...are included in Viem by default. If you want to use a network that isn't included by de...

(REP_WANT_TO_VB)


[style] ~73-~73: Consider a shorter alternative to avoid wordiness.
Context: ...our Environment You need a private key in order to sign transactions. Set your private key...

(IN_ORDER_TO_PREMIUM)

🔇 Additional comments (4)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (4)

2-4: LGTM: Title and description accurately updated.

The title and description have been appropriately updated to reflect the use of Viem for bridging ETH. The language is clear and concise, providing a good overview of the tutorial's content.


Line range hint 63-80: LGTM: Clear instructions for ETH acquisition and private key setup.

The instructions for getting ETH on Sepolia and setting up the private key are clear and concise. The use of a Callout component for the faucet information is a good practice for highlighting important information.

🧰 Tools
🪛 LanguageTool

[style] ~73-~73: Consider a shorter alternative to avoid wordiness.
Context: ...our Environment You need a private key in order to sign transactions. Set your private key...

(IN_ORDER_TO_PREMIUM)


Line range hint 1-514: LGTM: Comprehensive and well-structured tutorial for bridging ETH with Viem.

This tutorial provides a clear and detailed guide for bridging ETH between Layer 1 and Layer 2 using Viem. The structure is logical, with a good balance of explanations and code examples. The use of Tabs components for step-by-step instructions and full code examples is particularly helpful.

Key strengths:

  1. Clear explanations of complex concepts
  2. Well-organized code examples
  3. Proper use of Markdown and JSX components for improved readability
  4. Comprehensive coverage of both deposit and withdrawal processes

The suggested improvements in the previous comments will further enhance the tutorial's quality and user experience. Overall, this is an excellent resource for developers looking to implement ETH bridging using Viem.


83-130: ⚠️ Potential issue

Fix L2 wallet client setup.

The L2 wallet client setup is incorrect. It's currently using walletActionsL1() instead of walletActionsL2(). Update line 130 as follows:

-}).extend(walletActionsL1());
+}).extend(walletActionsL2());

This change ensures that the L2 wallet client uses the correct actions for L2 transactions.

Likely invalid or redundant comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (5)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (5)

2-13: LGTM! Clear introduction with a minor suggestion.

The updated title, description, and introduction accurately reflect the transition to using Viem for bridging ETH. The explanation of Viem is concise and informative.

Consider rephrasing line 11 to avoid repetition:

-This tutorial explains how you can use [Viem](https://viem.sh) to bridge ETH from L1 (Ethereum or Sepolia) to L2 (OP Mainnet or OP Sepolia).
+This tutorial demonstrates how to bridge ETH from L1 (Ethereum or Sepolia) to L2 (OP Mainnet or OP Sepolia) using [Viem](https://viem.sh).

Line range hint 20-28: Fix formatting in the Dependencies section.

The Supported Networks section provides clear information about Viem's compatibility with Superchain networks. However, the formatting in the Dependencies section needs adjustment for consistency with Markdown best practices.

Update the Dependencies list as follows:

 ## Dependencies

-*   [node](https://nodejs.org/en/)
-*   [pnpm](https://pnpm.io/installation)
+* [node](https://nodejs.org/en/)
+* [pnpm](https://pnpm.io/installation)

This change ensures proper indentation and consistent list item formatting.

🧰 Tools
🪛 LanguageTool

[style] ~16-~16: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~22-~22: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...are included in Viem by default. If you want to use a network that isn't included by de...

(REP_WANT_TO_VB)


Line range hint 56-76: Improve security practices for handling private keys.

The instructions for getting ETH on Sepolia and creating a new wallet are helpful. However, the method of exporting the private key as an environment variable poses a security risk.

Consider using a more secure method for handling private keys:

  1. Instead of exporting the private key directly, use a .env file to store sensitive information.
  2. Add a note about never committing the .env file to version control.
  3. Update the code to use a library like dotenv to load environment variables.

Example:

-export TUTORIAL_PRIVATE_KEY=0x...
+# Create a .env file in your project root
+# Add the following line to the .env file:
+# TUTORIAL_PRIVATE_KEY=0x...
+
+# In your JavaScript file:
+require('dotenv').config();
+const PRIVATE_KEY = process.env.TUTORIAL_PRIVATE_KEY;

Also, add a warning about the importance of keeping private keys secure in production environments.

🧰 Tools
🪛 LanguageTool

[style] ~71-~71: Consider a shorter alternative to avoid wordiness.
Context: ...our Environment You need a private key in order to sign transactions. Set your private key...

(IN_ORDER_TO_PREMIUM)


138-279: Enhance error handling and user feedback in the depositETH function.

The Deposit ETH section provides comprehensive instructions and well-structured code. The use of tabs for step-by-step instructions and full code improves readability.

Consider enhancing the depositETH function with more robust error handling and improved user feedback:

  1. Add more specific error handling:
 async function depositETH(amount) {
   try {
     // ... (existing code)
   } catch (error) {
-    console.error('Error during deposit:', error);
+    if (error.message.includes('buildDepositTransaction')) {
+      console.error('Error building deposit transaction:', error);
+    } else if (error.message.includes('depositTransaction')) {
+      console.error('Error sending deposit transaction:', error);
+    } else if (error.message.includes('waitForTransactionReceipt')) {
+      console.error('Error waiting for transaction receipt:', error);
+    } else {
+      console.error('Unexpected error during deposit:', error);
+    }
   }
 }
  1. Add progress updates to keep the user informed:
 async function depositETH(amount) {
   try {
+    console.log('Initiating deposit...');
     // ... (existing code)
+    console.log('Deposit transaction sent. Waiting for confirmation...');
     // ... (existing code)
+    console.log('L1 transaction confirmed. Waiting for L2 confirmation...');
     // ... (existing code)
   } catch (error) {
     // ... (error handling)
   }
 }

These changes will provide more detailed error information and keep the user informed about the progress of their deposit.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~138-~138: Possible missing comma found.
Context: ...osit ETH Now that you have some ETH on L1 you can deposit that ETH into the `L1St...

(AI_HYDRA_LEO_MISSING_COMMA)


288-495: Improve user feedback during the withdrawal process.

The Withdraw ETH section provides comprehensive instructions for the withdrawal process, including initiating, proving, and finalizing the withdrawal. The use of tabs for organization is effective.

Consider enhancing the withdrawETH function with more detailed progress updates to keep the user informed during the long waiting periods:

 async function withdrawETH(amount) {
   try {
+    console.log('Initiating withdrawal...');
     // ... (existing code)

     console.log('Waiting for withdrawal to be ready to prove...');
     const { output, withdrawal } = await publicClientL1.waitToProve({
       receipt,
       targetChain: walletClientL2.chain
     });
+    console.log('Withdrawal ready to prove. Building prove arguments...');

     // ... (rest of the function)

+    console.log('Waiting for the challenge period (up to 7 days on mainnet)...');
     const awaitWithdrawal = await publicClientL1.waitToFinalize({
       targetChain: walletClientL2.chain,
       withdrawalHash: withdrawal.withdrawalHash,
     });
+    console.log('Challenge period completed. Finalizing withdrawal...');

     // ... (rest of the function)

     console.log('Withdrawal completed successfully!');
   } catch (error) {
     console.error('Error during withdrawal:', error);
   }
 }

These additional log messages will keep the user informed about the progress of their withdrawal, especially during the long challenge period.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 87741c3 and 1b8716a.

📒 Files selected for processing (1)
  • pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1)

Pattern **/*.mdx: "ALWAYS review Markdown content THOROUGHLY with the following criteria:

  • Use proper nouns in place of personal pronouns like 'We' and 'Our' to maintain consistency in communal documentation.
  • Avoid gender-specific language and use the imperative form.
  • Monitor capitalization for emphasis. Use bold for prominence instead of all caps or italics.
  • Ensure proper nouns are capitalized in sentences.
  • Apply the Oxford comma.
  • Use proper title case for headers, buttons, tab names, page names, and links. Sentence case should be used for body content and short phrases, even in links.
  • Use correct spelling and grammar at all times (IMPORTANT).
    "
🪛 LanguageTool
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx

[style] ~16-~16: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~22-~22: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...are included in Viem by default. If you want to use a network that isn't included by de...

(REP_WANT_TO_VB)


[style] ~71-~71: Consider a shorter alternative to avoid wordiness.
Context: ...our Environment You need a private key in order to sign transactions. Set your private key...

(IN_ORDER_TO_PREMIUM)


[uncategorized] ~82-~82: Possible missing comma found.
Context: ...o interact with Viem. To start the Node REPL run the following command in your termi...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~138-~138: Possible missing comma found.
Context: ...osit ETH Now that you have some ETH on L1 you can deposit that ETH into the `L1St...

(AI_HYDRA_LEO_MISSING_COMMA)

🔇 Additional comments (1)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1)

31-52: LGTM! Clear and concise project setup instructions.

The Create a Demo Project section provides clear, step-by-step instructions for setting up the project. The use of the component enhances readability and user experience.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🧹 Outside diff range and nitpick comments (7)
public/tutorials/cross-dom-bridge-eth.js (2)

3-10: LGTM! Consider adding input validation for the private key.

The use of environment variables for the private key is a good security practice. However, consider adding input validation to ensure the private key is present and in the correct format.

You could add a check like this:

if (!PRIVATE_KEY || !/^0x[a-fA-F0-9]{64}$/.test(PRIVATE_KEY)) {
  throw new Error('Invalid or missing TUTORIAL_PRIVATE_KEY environment variable');
}

12-23: Consider using a more reliable RPC endpoint for production use.

While the Ankr public RPC endpoint is fine for testing, for production use or higher reliability, consider using a dedicated node provider or running your own node.

You could use environment variables to make the RPC URL configurable:

const L1_RPC_URL = process.env.L1_RPC_URL || 'https://rpc.ankr.com/eth_sepolia';
// Use L1_RPC_URL in the transport configuration
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (5)

19-22: Consider specifying default networks.

The Supported Networks section provides good information about Viem's compatibility. To enhance clarity, consider listing the specific OP Stack networks that are included in Viem by default. This would give readers a clearer understanding of which networks they can use without additional configuration.

🧰 Tools
🪛 LanguageTool

[style] ~22-~22: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...are included in Viem by default. If you want to use a network that isn't included by de...

(REP_WANT_TO_VB)


Line range hint 25-28: Improve formatting of the dependencies list.

For better consistency and readability, consider adjusting the indentation of the list items:

-*   [node](https://nodejs.org/en/)
-*   [pnpm](https://pnpm.io/installation)
+  * [node](https://nodejs.org/en/)
+  * [pnpm](https://pnpm.io/installation)

This change aligns with Markdown best practices and improves the overall document structure.

🧰 Tools
🪛 LanguageTool

[style] ~16-~16: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~22-~22: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...are included in Viem by default. If you want to use a network that isn't included by de...

(REP_WANT_TO_VB)


Line range hint 70-76: Minor grammatical improvement needed.

In the "Add a Private Key to Your Environment" section, there's a minor grammatical issue. Consider the following change:

-You need a private key in order to sign transactions.
+You need a private key to sign transactions.

This change improves conciseness without altering the meaning. Additionally, consider adding a note about the security implications of using environment variables for private keys in a production environment.

🧰 Tools
🪛 LanguageTool

[style] ~71-~71: Consider a shorter alternative to avoid wordiness.
Context: ...our Environment You need a private key in order to sign transactions. Set your private key...

(IN_ORDER_TO_PREMIUM)


80-83: Minor formatting improvement.

In the "Start the Node REPL" section, consider adding a comma for better readability:

-You're going to use the Node REPL to interact with Viem.
+You're going to use the Node REPL to interact with Viem.
-To start the Node REPL run the following command in your terminal:
+To start the Node REPL, run the following command in your terminal:

This small change improves the flow of the sentence.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~82-~82: Possible missing comma found.
Context: ...o interact with Viem. To start the Node REPL run the following command in your termi...

(AI_HYDRA_LEO_MISSING_COMMA)


497-503: Fix formatting in the Important Considerations section.

The use of a Callout component to highlight important considerations is effective. However, the formatting of the list items needs adjustment for consistency with Markdown best practices.

Update the Important Considerations list as follows:

 <Callout type="warning">
-  *   **Challenge Period**: The 7-day waiting period is crucial for security.
-  *   **Gas Costs**: Withdrawals involve transactions on both L2 and L1, each incurring gas fees.
-  *   **Private Key Handling**: Use secure key management practices in real applications.
-  *   **RPC Endpoint Security**: Keep your Alchemy API key (or any RPC endpoint) secure.
+  * **Challenge Period**: The 7-day waiting period is crucial for security.
+  * **Gas Costs**: Withdrawals involve transactions on both L2 and L1, each incurring gas fees.
+  * **Private Key Handling**: Use secure key management practices in real applications.
+  * **RPC Endpoint Security**: Keep your Alchemy API key (or any RPC endpoint) secure.
 </Callout>

This change ensures proper indentation and consistent list item formatting.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1b8716a and b165bc9.

📒 Files selected for processing (2)
  • pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (4 hunks)
  • public/tutorials/cross-dom-bridge-eth.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1)

Pattern **/*.mdx: "ALWAYS review Markdown content THOROUGHLY with the following criteria:

  • Use proper nouns in place of personal pronouns like 'We' and 'Our' to maintain consistency in communal documentation.
  • Avoid gender-specific language and use the imperative form.
  • Monitor capitalization for emphasis. Use bold for prominence instead of all caps or italics.
  • Ensure proper nouns are capitalized in sentences.
  • Apply the Oxford comma.
  • Use proper title case for headers, buttons, tab names, page names, and links. Sentence case should be used for body content and short phrases, even in links.
  • Use correct spelling and grammar at all times (IMPORTANT).
    "
🪛 LanguageTool
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx

[style] ~16-~16: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~22-~22: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...are included in Viem by default. If you want to use a network that isn't included by de...

(REP_WANT_TO_VB)


[style] ~71-~71: Consider a shorter alternative to avoid wordiness.
Context: ...our Environment You need a private key in order to sign transactions. Set your private key...

(IN_ORDER_TO_PREMIUM)


[uncategorized] ~82-~82: Possible missing comma found.
Context: ...o interact with Viem. To start the Node REPL run the following command in your termi...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~138-~138: Possible missing comma found.
Context: ...osit ETH Now that you have some ETH on L1 you can deposit that ETH into the `L1St...

(AI_HYDRA_LEO_MISSING_COMMA)

🔇 Additional comments (5)
public/tutorials/cross-dom-bridge-eth.js (2)

25-36: LGTM! Correct RPC endpoint for Optimism Sepolia.

The use of the official Optimism Sepolia RPC endpoint (https://sepolia.optimism.io) is correct. This addresses the issue raised in a previous review comment.


124-124: Align the withdrawETH call with the suggested interactive approach.

Similar to the depositETH call, immediately calling withdrawETH() might not be ideal for a tutorial.

Please refer to the previous comment about creating a main function for a more interactive approach. This would apply to both depositETH and withdrawETH calls.

pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (3)

1-13: LGTM! Clear and informative introduction.

The updated title, description, and introduction accurately reflect the tutorial's new focus on using Viem for bridging ETH. The explanation of Viem and its purpose is concise and informative.


Line range hint 1-512: Excellent tutorial with minor improvements suggested.

This tutorial provides a comprehensive and well-structured guide to bridging ETH using Viem. The transition from the Optimism SDK to Viem has been handled effectively, with clear explanations and code examples. The use of components like Tabs and Callout enhances readability and user experience.

General suggestions for further improvement:

  1. Consider adding a table of contents at the beginning for easier navigation.
  2. Include a brief section on troubleshooting common issues that users might encounter.
  3. Add links to relevant Viem documentation throughout the tutorial for readers who want to dive deeper into specific concepts.

Overall, with the implementation of the suggested minor improvements in previous comments, this tutorial will serve as an excellent resource for developers looking to work with bridging ETH using Viem.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~82-~82: Possible missing comma found.
Context: ...o interact with Viem. To start the Node REPL run the following command in your termi...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~138-~138: Possible missing comma found.
Context: ...osit ETH Now that you have some ETH on L1 you can deposit that ETH into the `L1St...

(AI_HYDRA_LEO_MISSING_COMMA)


123-128: ⚠️ Potential issue

Correct L2 wallet client setup.

In the L2 wallet client setup, there's an inconsistency. The L2 wallet client is incorrectly using walletActionsL1() instead of walletActionsL2(). Please update as follows:

const walletClientL2 = createWalletClient({
    account,
    chain: optimismSepolia,
    transport: http("https://sepolia.optimism.io"),
-}).extend(walletActionsL1());
+}).extend(walletActionsL2());

This change ensures that the L2 wallet client uses the correct actions for L2 transactions.

Likely invalid or redundant comment.

public/tutorials/cross-dom-bridge-eth.js Outdated Show resolved Hide resolved
public/tutorials/cross-dom-bridge-eth.js Outdated Show resolved Hide resolved
public/tutorials/cross-dom-bridge-eth.js Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Outside diff range and nitpick comments (7)
public/tutorials/cross-dom-bridge-eth.js (2)

3-6: Review and remove unused imports.

Some imported functions like formatEther and parseEther are not used in the provided code snippet. It's a good practice to remove unused imports to keep the code clean and prevent potential confusion.

Review the usage of all imported functions and remove any that are not used in the code.


38-39: Consider adding L2 balance check for completeness.

While checking the L1 balance is good, it would be beneficial to also check and log the L2 balance for a complete overview of the user's funds across both layers.

Add an L2 balance check similar to the L1 check:

const l2Balance = await publicClientL2.getBalance({ address: account.address });
console.log(`L2 Balance: ${formatEther(l2Balance)} ETH`);
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (5)

19-22: Consider rephrasing for variety.

The information about supported networks is accurate and helpful. However, consider rephrasing the last sentence to avoid repetition:

- If you want to use a network that isn't included by default, you can add it to Viem's chain configurations.
+ For networks not included by default, you can add them to Viem's chain configurations.

This change adds variety to the writing style.

🧰 Tools
🪛 LanguageTool

[style] ~22-~22: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...are included in Viem by default. If you want to use a network that isn't included by de...

(REP_WANT_TO_VB)


Line range hint 25-28: Fix formatting of the dependencies list.

The dependencies are correctly listed, but the formatting needs adjustment. Please update the list as follows:

-*   [node](https://nodejs.org/en/)
-*   [pnpm](https://pnpm.io/installation)
+* [node](https://nodejs.org/en/)
+* [pnpm](https://pnpm.io/installation)

This change ensures proper indentation and consistent list item formatting.

🧰 Tools
🪛 LanguageTool

[style] ~16-~16: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~22-~22: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...are included in Viem by default. If you want to use a network that isn't included by de...

(REP_WANT_TO_VB)


70-72: Consider rephrasing for conciseness.

The instructions for setting up the private key are clear and follow best practices. However, consider rephrasing the first sentence for conciseness:

- You need a private key in order to sign transactions.
+ You need a private key to sign transactions.

This change reduces wordiness without altering the meaning.

🧰 Tools
🪛 LanguageTool

[style] ~71-~71: Consider a shorter alternative to avoid wordiness.
Context: ...our Environment You need a private key in order to sign transactions. Set your private key...

(IN_ORDER_TO_PREMIUM)


81-82: Add a comma for better readability.

To improve readability, add a comma after "Viem" in the first sentence:

- You're going to use the Node REPL to interact with Viem.
+ You're going to use the Node REPL to interact with Viem, To start the Node REPL run the following command in your terminal:

This change enhances the flow of the sentence.


296-301: Fix formatting in the Important Considerations section.

The use of a Callout component to highlight important considerations is effective. However, the formatting of the list items needs adjustment for consistency with Markdown best practices.

Update the Important Considerations list as follows:

 <Callout type="warning">
-  *   **Challenge Period**: The 7-day withdrawal challenge Period is crucial for security.
-  *   **Gas Costs**: Withdrawals involve transactions on both L2 and L1, each incurring gas fees.
-  *   **Private Key Handling**: Use secure key management practices in real applications.
-  *   **RPC Endpoint Security**: Keep your API key (or any RPC endpoint) secure.
+  * **Challenge Period**: The 7-day withdrawal challenge period is crucial for security.
+  * **Gas Costs**: Withdrawals involve transactions on both L2 and L1, each incurring gas fees.
+  * **Private Key Handling**: Use secure key management practices in real applications.
+  * **RPC Endpoint Security**: Keep your API key (or any RPC endpoint) secure.
 </Callout>

This change ensures proper indentation and consistent list item formatting. Also, note the correction of "Period" to "period" in the first item for consistency.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b165bc9 and 99c70b7.

📒 Files selected for processing (2)
  • pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (4 hunks)
  • public/tutorials/cross-dom-bridge-eth.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1)

Pattern **/*.mdx: "ALWAYS review Markdown content THOROUGHLY with the following criteria:

  • Use proper nouns in place of personal pronouns like 'We' and 'Our' to maintain consistency in communal documentation.
  • Avoid gender-specific language and use the imperative form.
  • Monitor capitalization for emphasis. Use bold for prominence instead of all caps or italics.
  • Ensure proper nouns are capitalized in sentences.
  • Apply the Oxford comma.
  • Use proper title case for headers, buttons, tab names, page names, and links. Sentence case should be used for body content and short phrases, even in links.
  • Use correct spelling and grammar at all times (IMPORTANT).
    "
🪛 LanguageTool
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx

[style] ~16-~16: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~22-~22: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...are included in Viem by default. If you want to use a network that isn't included by de...

(REP_WANT_TO_VB)


[style] ~71-~71: Consider a shorter alternative to avoid wordiness.
Context: ...our Environment You need a private key in order to sign transactions. Set your private key...

(IN_ORDER_TO_PREMIUM)

🔇 Additional comments (6)
public/tutorials/cross-dom-bridge-eth.js (2)

9-10: Good practice: Using environment variables for sensitive data.

Loading the private key from an environment variable is a good security practice. However, ensure that the TUTORIAL_PRIVATE_KEY environment variable is securely set and managed in your execution environment.


13-36: Well-structured client initializations for L1 and L2.

The initialization of separate public and wallet clients for both L1 (Sepolia) and L2 (Optimism Sepolia) is well-structured and clear. This separation enhances readability and maintainability of the code.

pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (4)

1-13: LGTM! Clear and informative introduction.

The title, description, and introduction accurately reflect the transition to using Viem for bridging ETH. The explanation of Viem and its purpose is clear and helpful for users.


136-195: LGTM! Well-structured and comprehensive deposit instructions.

The "Deposit ETH" section is well-organized using the Nextra Tabs component. The step-by-step instructions are clear and accurate, providing a comprehensive guide for users to deposit ETH using Viem.


203-292: LGTM! Comprehensive and well-organized withdrawal instructions.

The "Withdraw ETH" section is excellently structured using the Nextra Tabs component. The step-by-step instructions are clear, accurate, and provide a comprehensive guide for users to withdraw ETH using Viem. The inclusion of important details like waiting periods and transaction confirmations is particularly helpful.


Line range hint 1-309: LGTM! Comprehensive and well-structured tutorial for bridging ETH using Viem.

This tutorial successfully transitions from using the Optimism SDK to Viem for bridging ETH between Layer 1 and Layer 2. The content is well-organized, using Nextra components effectively to improve readability and user experience. The step-by-step instructions for depositing and withdrawing ETH are clear and accurate.

Minor suggestions for improvements have been made in previous comments, including:

  • Rephrasing some sentences for better clarity and variety
  • Fixing formatting issues in lists
  • Enhancing the Next Steps section for better engagement

Once these minor issues are addressed, this tutorial will serve as an excellent resource for developers looking to implement ETH bridging functionality using Viem.

public/tutorials/cross-dom-bridge-eth.js Show resolved Hide resolved
public/tutorials/cross-dom-bridge-eth.js Outdated Show resolved Hide resolved
public/tutorials/cross-dom-bridge-eth.js Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (3)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (3)

Line range hint 26-28: Improve formatting of the dependency list.

For better consistency and readability, consider adjusting the indentation of the list items:

-*   [node](https://nodejs.org/en/)
-*   [pnpm](https://pnpm.io/installation)
+  * [node](https://nodejs.org/en/)
+  * [pnpm](https://pnpm.io/installation)

This change ensures proper indentation and consistent list item formatting.


Line range hint 69-76: Enhance security information for private key handling.

While the instructions for setting the private key as an environment variable are clear, it's important to emphasize the security implications. Consider adding a warning about the risks of exposing private keys and best practices for secure key management.

For example, you could add:

<Callout type="warning">
  Never share your private key or commit it to version control. Always use secure methods to manage and store your private keys in production environments.
</Callout>

This addition will help users understand the importance of secure key management.

🧰 Tools
🪛 LanguageTool

[style] ~71-~71: Consider a shorter alternative to avoid wordiness.
Context: ...our Environment You need a private key in order to sign transactions. Set your private key...

(IN_ORDER_TO_PREMIUM)


296-301: Fix formatting in the Important Considerations section.

The use of a Callout component to highlight important considerations is effective. However, the formatting of the list items needs adjustment for consistency with Markdown best practices.

Update the Important Considerations list as follows:

 <Callout type="warning">
-  *   Challenge Period: The 7-day withdrawal challenge Period is crucial for security.
-  *   Gas Costs: Withdrawals involve transactions on both L2 and L1, each incurring gas fees.
-  *   Private Key Handling: Use secure key management practices in real applications.
-  *   RPC Endpoint Security: Keep your API key (or any RPC endpoint) secure.
+  * **Challenge Period**: The 7-day withdrawal challenge period is crucial for security.
+  * **Gas Costs**: Withdrawals involve transactions on both L2 and L1, each incurring gas fees.
+  * **Private Key Handling**: Use secure key management practices in real applications.
+  * **RPC Endpoint Security**: Keep your API key (or any RPC endpoint) secure.
 </Callout>

This change ensures proper indentation, consistent list item formatting, and emphasizes key terms.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 99c70b7 and cc1c272.

📒 Files selected for processing (1)
  • pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1)

Pattern **/*.mdx: "ALWAYS review Markdown content THOROUGHLY with the following criteria:

  • Use proper nouns in place of personal pronouns like 'We' and 'Our' to maintain consistency in communal documentation.
  • Avoid gender-specific language and use the imperative form.
  • Monitor capitalization for emphasis. Use bold for prominence instead of all caps or italics.
  • Ensure proper nouns are capitalized in sentences.
  • Apply the Oxford comma.
  • Use proper title case for headers, buttons, tab names, page names, and links. Sentence case should be used for body content and short phrases, even in links.
  • Use correct spelling and grammar at all times (IMPORTANT).
    "
🪛 LanguageTool
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx

[style] ~16-~16: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~22-~22: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...are included in Viem by default. If you want to use a network that isn't included by de...

(REP_WANT_TO_VB)


[style] ~71-~71: Consider a shorter alternative to avoid wordiness.
Context: ...our Environment You need a private key in order to sign transactions. Set your private key...

(IN_ORDER_TO_PREMIUM)

🔇 Additional comments (2)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (2)

2-15: LGTM! Clear and informative introduction.

The updated title, description, and introduction accurately reflect the transition to using Viem for bridging ETH. The explanation of Viem and its purpose in this context is clear and helpful for users.


Line range hint 1-309: Excellent tutorial on bridging ETH using Viem!

This tutorial provides a comprehensive and well-structured guide for bridging ETH between L1 and L2 using Viem. The content is clear, informative, and includes all necessary steps and code snippets. The use of tabs for organizing content and the detailed explanations of each step contribute to a positive learning experience.

Some minor suggestions have been made to enhance formatting, error handling, and user engagement. These improvements will further polish an already strong tutorial.

Overall, this guide effectively achieves its goal of teaching developers how to use Viem for bridging ETH, and it serves as a valuable resource for the Optimism developer community.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6719644 and d07ebfe.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • package.json (1 hunks)
🔇 Additional comments (1)
package.json (1)

32-32: LGTM: Viem dependency added successfully.

The addition of the viem dependency (version ^2.21.18) aligns with the PR objectives of using Viem for bridging ETH. This change supports the transition from the Optimism SDK to Viem for this functionality.

package.json Show resolved Hide resolved
@brokewhale
Copy link
Contributor

@brokewhale You can check out this tutorial now.

on it

Copy link
Contributor

@brokewhale brokewhale left a comment

Choose a reason for hiding this comment

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

some reviews for now. Deposit reviewed
some things you should note

  • some codeblocks are broken
  • some are empty
  • on the withdrawal part you might want to rename some of the const to be different from deposit to allow continuity

example
on the deposit side

const args = await publicClientL2.buildDepositTransaction({
    mint: parseEther("0.0001"),
    to: account.address,
});

you can't use args anymore on the withdrawal side unless you want to restart the node

this will error

//Add the same imports used in DepositETH function
const args = await publicClientL2.buildWithdrawalTransaction({
withdrawalAmount: parseEther("0.0001"),
});

instead you can do

const depositArgs = await publicClientL2.buildDepositTransaction({
    mint: parseEther("0.0001"),
    to: account.address,
});

and

//Add the same imports used in DepositETH function
const withdrawalArgs  = await publicClientL2.buildWithdrawalTransaction({
withdrawalAmount: parseEther("0.0001"),
});

and for others too

if the intent is to close the current session and start `node` again while importing all over again then it's fine, but i feel just continuing is better 

public/tutorials/cross-dom-bridge-eth.js Outdated Show resolved Hide resolved
public/tutorials/cross-dom-bridge-eth.js Outdated Show resolved Hide resolved
public/tutorials/cross-dom-bridge-eth.js Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (4)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (4)

Line range hint 24-52: LGTM with a minor formatting suggestion.

The dependencies and project setup instructions are clear and accurate. However, the list items in the Dependencies section need proper indentation.

Please update the formatting as follows:

 ## Dependencies

-*   [node](https://nodejs.org/en/)
-*   [pnpm](https://pnpm.io/installation)
+  * [node](https://nodejs.org/en/)
+  * [pnpm](https://pnpm.io/installation)

This change ensures consistent list item formatting throughout the document.


79-126: LGTM with a minor grammatical suggestion.

The instructions for starting the Node REPL and importing dependencies are clear and accurate. The code snippets for importing and setting up the Viem clients are correct.

However, there's a minor grammatical issue in the sentence about starting the Node REPL. Please update it as follows:

-To start the Node REPL run the following command in your terminal:
+To start the Node REPL, run the following command in your terminal:

This change adds a comma after "REPL" to improve readability.


291-298: LGTM with a minor formatting suggestion.

The "Important Considerations" section provides valuable information for users. However, the list formatting needs adjustment for consistency with Markdown best practices.

Please update the formatting as follows:

 <Callout type="warning">
-  *   Challenge Period: The 7-day withdrawal challenge Period is crucial for security.
-  *   Gas Costs: Withdrawals involve transactions on both L2 and L1, each incurring gas fees.
-  *   Private Key Handling: Use secure key management practices in real applications.
-  *   RPC Endpoint Security: Keep your API key (or any RPC endpoint) secure.
+  * **Challenge Period**: The 7-day withdrawal challenge period is crucial for security.
+  * **Gas Costs**: Withdrawals involve transactions on both L2 and L1, each incurring gas fees.
+  * **Private Key Handling**: Use secure key management practices in real applications.
+  * **RPC Endpoint Security**: Keep your API key (or any RPC endpoint) secure.
 </Callout>

These changes improve consistency and readability.


Line range hint 1-307: Final suggestions for minor improvements.

The tutorial is comprehensive and well-structured. To further enhance its quality, consider the following minor improvements:

  1. Consistency in capitalization: Ensure consistent capitalization of terms like "Layer 1" and "Layer 2" throughout the document.

  2. Code comments: Add brief comments to the code snippets in the full code tabs to explain the purpose of each section.

  3. Error handling: Consider adding a section on error handling and troubleshooting common issues users might encounter during the bridging process.

  4. Version information: Include information about the specific versions of Viem and other dependencies used in the tutorial to help users avoid potential compatibility issues.

These small enhancements will further improve the clarity and usefulness of the tutorial.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d07ebfe and 490990a.

📒 Files selected for processing (2)
  • pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (4 hunks)
  • public/tutorials/cross-dom-bridge-eth.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (1)

Pattern **/*.mdx: "ALWAYS review Markdown content THOROUGHLY with the following criteria:

  • Use proper nouns in place of personal pronouns like 'We' and 'Our' to maintain consistency in communal documentation.
  • Avoid gender-specific language and use the imperative form.
  • Monitor capitalization for emphasis. Use bold for prominence instead of all caps or italics.
  • Ensure proper nouns are capitalized in sentences.
  • Apply the Oxford comma.
  • Use proper title case for headers, buttons, tab names, page names, and links. Sentence case should be used for body content and short phrases, even in links.
  • Use correct spelling and grammar at all times (IMPORTANT).
    "
🪛 LanguageTool
pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx

[style] ~16-~16: Consider using an alternative to strengthen your wording.
Context: ...lopers/bridging/standard-bridge) if you want to learn more about how the bridge work...

(WANT_KEEN)


[style] ~22-~22: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...are included in Viem by default. If you want to use a network that isn't included by de...

(REP_WANT_TO_VB)


[style] ~71-~71: Consider a shorter alternative to avoid wordiness.
Context: ...our Environment You need a private key in order to sign transactions. Set your private key...

(IN_ORDER_TO_PREMIUM)

🔇 Additional comments (12)
public/tutorials/cross-dom-bridge-eth.js (7)

9-10: Good practice: Using environment variable for private key.

Loading the private key from an environment variable (process.env.TUTORIAL_PRIVATE_KEY) is a good security practice. It helps prevent accidental exposure of sensitive information in the codebase.


28-28: Correct use of Optimism Sepolia RPC endpoint.

The L2 RPC endpoint has been correctly updated to 'https://sepolia.optimism.io', addressing the issue raised in a previous review comment.

Also applies to: 35-35


38-39: Useful L1 balance check implementation.

The L1 balance check is correctly implemented and provides valuable information to the user before proceeding with deposits or withdrawals. This is a good practice for improving user experience and preventing potential errors due to insufficient funds.


55-56: Correct handling of multiple L2 transaction hashes.

The code correctly handles the possibility of multiple L2 transaction hashes by destructuring the array returned by getL2TransactionHashes(receipt). This addresses the issue raised in a previous review comment.


50-61: Comprehensive logging enhances debugging and user experience.

The depositETH function includes detailed logging of transaction hashes and confirmations for both L1 and L2. This is excellent for debugging purposes and provides clear feedback to the user about the progress of their deposit.


74-112: Comprehensive logging enhances debugging and user experience.

The withdrawETH function includes detailed logging of transaction hashes and confirmations for each step of the withdrawal process. This is excellent for debugging purposes and provides clear feedback to the user about the progress of their withdrawal.


1-1: 🛠️ Refactor suggestion

Consider removing the IIFE wrapper for better code structure.

The Immediately Invoked Function Expression (IIFE) wrapping the entire code might unnecessarily complicate the tutorial structure. Consider restructuring the code as a module with exported functions for better readability and alignment with modern JavaScript practices.

Also applies to: 115-115

pages/builders/app-developers/tutorials/cross-dom-bridge-eth.mdx (5)

1-15: LGTM! Clear and informative introduction.

The updated title, description, and introduction accurately reflect the tutorial's focus on using Viem for bridging ETH between L1 and L2. The explanation of Viem and its purpose is concise and informative.


Line range hint 60-76: LGTM! Clear instructions for setup.

The instructions for obtaining ETH on Sepolia and setting up the private key in the environment are clear and accurate. The use of a Callout component for the faucet information is helpful.

🧰 Tools
🪛 LanguageTool

[style] ~71-~71: Consider a shorter alternative to avoid wordiness.
Context: ...our Environment You need a private key in order to sign transactions. Set your private key...

(IN_ORDER_TO_PREMIUM)


136-195: LGTM! Well-structured and comprehensive deposit instructions.

The "Deposit ETH" section is well-organized and provides clear, step-by-step instructions. The use of Tabs to separate the step-by-step guide and full code is helpful for users with different preferences. The code snippets for each step are accurate and properly explained.


203-289: LGTM! Comprehensive and well-structured withdrawal instructions.

The "Withdraw ETH" section provides clear, step-by-step instructions for the withdrawal process. The use of Tabs is consistent with the deposit section, offering both detailed steps and full code. The explanations for each step, including the waiting periods and proof requirements, are informative and accurate.


Line range hint 1-307: LGTM! Well-structured and comprehensive tutorial.

The overall structure and flow of the tutorial are excellent. It follows a logical progression from setup to deposit and withdrawal, making it easy for users to follow along. The effective use of Nextra components (Steps, Tabs, and Callout) enhances readability and improves the user experience. The balance between explanations and code snippets is well-maintained throughout the tutorial.

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

Successfully merging this pull request may close these issues.

2 participants