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

Fix Missing Steps in "Communicating between OP Stack and Ethereum in Solidity" Tutorial #1326

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

krofax
Copy link
Collaborator

@krofax krofax commented Feb 6, 2025

Description

Summary

This PR addresses Issue #1217 by adding missing steps and updating outdated instructions in the "Communicating between OP Stack and Ethereum in Solidity" tutorial. The changes ensure that the tutorial aligns with the latest Viem APIs and correctly guides users through the withdrawal proving process.

Changes Introduced

  1. Updated Import Statements
  • Added missing imports for Viem modules .
  1. Removed Hardcoded transactionHash Reference
  • Removed const transactionHash = process.env.TUTORIAL_TRANSACTION_HASH, as it was incorrectly referenced later.
  • Instead, a new method for retrieving the transaction receipt has been introduced in Step 12.
  1. Updated RPC Provider and Wallet Initialization
  • Replaced older provider setup with createPublicClient and .extend(publicActionsL1()) / .extend(publicActionsL2()).
  • Updated wallet setup to use createWalletClient and .extend(walletActionsL1()).
  1. Added Proper Transaction Receipt Retrieval
  • Introduced await l2Provider.getTransactionReceipt({ hash: process.env.TUTORIAL_TRANSACTION_HASH }) to ensure proper receipt handling.

Tests

Additional context

Include a link to any github issues that this may close in the following form:

@krofax krofax requested a review from a team as a code owner February 6, 2025 17:07
Copy link

netlify bot commented Feb 6, 2025

Deploy Preview for docs-optimism ready!

Name Link
🔨 Latest commit 9a480c6
🔍 Latest deploy log https://app.netlify.com/sites/docs-optimism/deploys/67a4ec37f56a82000893d1dc
😎 Deploy Preview https://deploy-preview-1326--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 bot commented Feb 6, 2025

📝 Walkthrough

Walkthrough

The changes update the cross-domain Solidity tutorial by modifying content and code examples across two files. In the Markdown file, the heading “Import Viem” is changed to “Import viem,” and additional code snippets are added to demonstrate building parameters for proving a withdrawal on L2 and relaying messages on L1. In the JavaScript file, updates emphasize wallet operations and transaction handling using the viem library. Notable modifications include creating an account via process.env.TUTORIAL_PRIVATE_KEY, initializing wallet clients for L1 and L2 with extended wallet actions, and enhancing the control flow for message proofing and withdrawal finalization. No changes have been made to exported or public entities.

Sequence Diagram(s)

sequenceDiagram
    participant U as User/Developer
    participant A as Account Manager
    participant L2 as L2Wallet
    participant L1 as L1Wallet
    participant ETH as Ethereum Provider

    U->>A: Provide private key (process.env.TUTORIAL_PRIVATE_KEY)
    A-->>U: Return account object
    U->>L2: Initialize l2Wallet (with walletActionsL2)
    U->>L1: Initialize l1Wallet (with walletActionsL1)
    U->>L2: Trigger buildProveWithdrawal
    L2-->>U: Return withdrawal proof parameters
    U->>L1: Relay message for withdrawal finalization
    L1->>ETH: Invoke finalizeWithdrawal method
    ETH-->>L1: Return transaction receipt
    L1-->>U: Confirm finalization
Loading

Possibly related issues

Possibly related PRs

Suggested reviewers

  • brokewhale
  • ZakAyesh
  • cpengilly
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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
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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e3e5453 and 9a480c6.

📒 Files selected for processing (2)
  • pages/builders/app-developers/tutorials/cross-dom-solidity.mdx (3 hunks)
  • public/tutorials/cross-dom-solidity.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.mdx`: "ALWAYS review Markdown content THOROUGHLY with ...

**/*.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. Avoid using all caps, italics, or bold for emphasis.
  • Ensure proper nouns are capitalized in sentences.
  • Apply the Oxford comma.
  • Use proper title case for 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).
  • For H1, H2, and H3 headers:
    1. Use sentence case, capitalizing only the first word.
    2. Preserve the capitalization of proper nouns, technical terms, and acronyms as defined in the 'nouns.txt' file located in the root directory of the project.
    3. Do not automatically lowercase words that appear in the 'nouns.txt' file, regardless of their position in the header.
  • Flag any headers that seem to inconsistently apply these rules for manual review.
  • When reviewing capitalization, always refer to the 'nouns.txt' file for the correct capitalization of proper nouns and technical terms specific to the project.
    "
  • pages/builders/app-developers/tutorials/cross-dom-solidity.mdx
🪛 ESLint
public/tutorials/cross-dom-solidity.js

[error] 3-3: Extra semicolon.

(semi)


[error] 4-4: Extra semicolon.

(semi)


[error] 5-5: Extra semicolon.

(semi)


[error] 6-6: Extra semicolon.

(semi)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: pr-workflow

Comment on lines +3 to +6
const { createPublicClient, http, createWalletClient } = require("viem");
const { optimismSepolia, sepolia } = require("viem/chains");
const { publicActionsL1, publicActionsL2, walletActionsL1, walletActionsL2 } = require("viem/op-stack");
const { privateKeyToAccount } = require("viem/accounts");
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove unnecessary semicolons to fix linting errors.

Lines 3-6 contain extra semicolons that should be removed to comply with the project's coding style guidelines and fix the linting errors.

Apply this diff to remove the unnecessary semicolons:

-const { createPublicClient, http, createWalletClient } = require("viem");
-const { optimismSepolia, sepolia } = require("viem/chains");
-const { publicActionsL1, publicActionsL2, walletActionsL1, walletActionsL2 } = require("viem/op-stack");
-const { privateKeyToAccount } = require("viem/accounts");
+const { createPublicClient, http, createWalletClient } = require("viem")
+const { optimismSepolia, sepolia } = require("viem/chains")
+const { publicActionsL1, publicActionsL2, walletActionsL1, walletActionsL2 } = require("viem/op-stack")
+const { privateKeyToAccount } = require("viem/accounts")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const { createPublicClient, http, createWalletClient } = require("viem");
const { optimismSepolia, sepolia } = require("viem/chains");
const { publicActionsL1, publicActionsL2, walletActionsL1, walletActionsL2 } = require("viem/op-stack");
const { privateKeyToAccount } = require("viem/accounts");
const { createPublicClient, http, createWalletClient } = require("viem")
const { optimismSepolia, sepolia } = require("viem/chains")
const { publicActionsL1, publicActionsL2, walletActionsL1, walletActionsL2 } = require("viem/op-stack")
const { privateKeyToAccount } = require("viem/accounts")
🧰 Tools
🪛 ESLint

[error] 3-3: Extra semicolon.

(semi)


[error] 4-4: Extra semicolon.

(semi)


[error] 5-5: Extra semicolon.

(semi)


[error] 6-6: Extra semicolon.

(semi)

Comment on lines +53 to +54
const [message] = getWithdrawals(receipt)
await l1Provider.waitToFinalize({ withdrawalHash: message.withdrawalHash, targetChain: l2Provider.chain })
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add missing import or definition for getWithdrawals.

The function getWithdrawals is used but not defined or imported. This will lead to a runtime error.

Ensure that getWithdrawals is properly defined or imported. If it's from an external module, add the necessary import statement, for example:

+const { getWithdrawals } = require('viem/op-stack')

Or define the function if it is missing.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const [message] = getWithdrawals(receipt)
await l1Provider.waitToFinalize({ withdrawalHash: message.withdrawalHash, targetChain: l2Provider.chain })
+const { getWithdrawals } = require('viem/op-stack')
const [message] = getWithdrawals(receipt)
await l1Provider.waitToFinalize({ withdrawalHash: message.withdrawalHash, targetChain: l2Provider.chain })

@@ -176,27 +176,22 @@ Start the Node.js REPL with the `node` command.
node
```

{<h3>Import Viem</h3>}
{<h3>Import viem</h3>}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Capitalize proper noun 'Viem' in the header.

In the header {<h3>Import viem</h3>}, 'Viem' is a proper noun and should be capitalized to maintain consistency and adhere to the project's style guidelines.

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