-
Notifications
You must be signed in to change notification settings - Fork 231
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,39 +1,65 @@ | ||||||||||||||||||
(async () => { | ||||||||||||||||||
|
||||||||||||||||||
const { createPublicClient, http } = require('viem'); | ||||||||||||||||||
const { optimismSepolia } = require('viem/chains'); | ||||||||||||||||||
const { publicActionsL1, publicActionsL2} = require('viem/op-stack'); | ||||||||||||||||||
|
||||||||||||||||||
const transactionHash = process.env.TUTORIAL_TRANSACTION_HASH | ||||||||||||||||||
|
||||||||||||||||||
const l1Provider = createPublicClient({ chain: sepolia, transport: http("https://rpc.ankr.com/eth_sepolia") }).extend(publicActionsL1()) | ||||||||||||||||||
const l2Provider = createPublicClient({ chain: optimismSepolia, transport: http("https://sepolia.optimism.io") }).extend(publicActionsL2()); | ||||||||||||||||||
|
||||||||||||||||||
console.log('Waiting for message to be provable...') | ||||||||||||||||||
await l1Provider.getWithdrawalStatus({ | ||||||||||||||||||
receipt, | ||||||||||||||||||
targetChain: l2Provider.chain, | ||||||||||||||||||
}) | ||||||||||||||||||
|
||||||||||||||||||
console.log('Proving message...') | ||||||||||||||||||
const receipt = await l2Provider.getTransactionReceipt(transactionHash) | ||||||||||||||||||
const output = await l1Provider.waitToProve({ | ||||||||||||||||||
receipt, | ||||||||||||||||||
targetChain: l2Provider.chain, | ||||||||||||||||||
}) | ||||||||||||||||||
|
||||||||||||||||||
console.log('Waiting for message to be relayable...') | ||||||||||||||||||
await l1Provider.getWithdrawalStatus({ | ||||||||||||||||||
receipt, | ||||||||||||||||||
targetChain: l2Provider.chain, | ||||||||||||||||||
}) | ||||||||||||||||||
|
||||||||||||||||||
console.log('Relaying message...') | ||||||||||||||||||
const [message] = getWithdrawals(receipt) | ||||||||||||||||||
await l1Provider.waitToFinalize({ withdrawalHash: message.withdrawalHash, targetChain: l2Provider.chain }) | ||||||||||||||||||
|
||||||||||||||||||
console.log('Waiting for message to be relayed...') | ||||||||||||||||||
await l1Provider.getWithdrawalStatus({ receipt, targetChain: l2Provider.chain }) | ||||||||||||||||||
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"); | ||||||||||||||||||
Comment on lines
+3
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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
Suggested change
🧰 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) |
||||||||||||||||||
|
||||||||||||||||||
const l1Provider = createPublicClient({ chain: sepolia, transport: http("https://eth-sepolia.g.alchemy.com/v2/***") }).extend(publicActionsL1()) | ||||||||||||||||||
const l2Provider = createPublicClient({ chain: optimismSepolia, transport: http("https://opt-sepolia.g.alchemy.com/v2/***") }).extend(publicActionsL2()) | ||||||||||||||||||
const account = privateKeyToAccount(process.env.TUTORIAL_PRIVATE_KEY) | ||||||||||||||||||
|
||||||||||||||||||
const l1Wallet = createWalletClient({ | ||||||||||||||||||
chain: sepolia, | ||||||||||||||||||
transport: http("https://eth-sepolia.g.alchemy.com/v2/***") | ||||||||||||||||||
}).extend(walletActionsL1()) | ||||||||||||||||||
|
||||||||||||||||||
const l2Wallet = createWalletClient({ | ||||||||||||||||||
chain: optimismSepolia, | ||||||||||||||||||
transport: http("https://opt-sepolia.g.alchemy.com/v2/***") | ||||||||||||||||||
}).extend(walletActionsL2()) | ||||||||||||||||||
|
||||||||||||||||||
const receipt = await l2Provider.getTransactionReceipt({ | ||||||||||||||||||
hash: process.env.TUTORIAL_TRANSACTION_HASH | ||||||||||||||||||
}) | ||||||||||||||||||
|
||||||||||||||||||
console.log('Waiting for message to be provable...') | ||||||||||||||||||
await l1Provider.getWithdrawalStatus({ | ||||||||||||||||||
receipt, | ||||||||||||||||||
targetChain: l2Provider.chain, | ||||||||||||||||||
}) | ||||||||||||||||||
|
||||||||||||||||||
console.log('Proving message...') | ||||||||||||||||||
const { output, withdrawal } = await l1Provider.waitToProve({ | ||||||||||||||||||
receipt, | ||||||||||||||||||
targetChain: l2Provider.chain, | ||||||||||||||||||
}) | ||||||||||||||||||
|
||||||||||||||||||
const args = await l2Provider.buildProveWithdrawal({ | ||||||||||||||||||
account, | ||||||||||||||||||
output, | ||||||||||||||||||
withdrawal, | ||||||||||||||||||
}) | ||||||||||||||||||
|
||||||||||||||||||
const hash = await l1Wallet.proveWithdrawal(args) | ||||||||||||||||||
|
||||||||||||||||||
console.log('Waiting for message to be relayable...') | ||||||||||||||||||
await l1Provider.getWithdrawalStatus({ | ||||||||||||||||||
receipt, | ||||||||||||||||||
targetChain: l2Provider.chain, | ||||||||||||||||||
}) | ||||||||||||||||||
|
||||||||||||||||||
console.log('Relaying message...') | ||||||||||||||||||
const [message] = getWithdrawals(receipt) | ||||||||||||||||||
await l1Provider.waitToFinalize({ withdrawalHash: message.withdrawalHash, targetChain: l2Provider.chain }) | ||||||||||||||||||
Comment on lines
+53
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add missing import or definition for The function Ensure that +const { getWithdrawals } = require('viem/op-stack') Or define the function if it is missing. 📝 Committable suggestion
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
const finalizeHash = await l1Wallet.finalizeWithdrawal({ | ||||||||||||||||||
targetChain: l2Wallet.chain, | ||||||||||||||||||
withdrawal, | ||||||||||||||||||
}) | ||||||||||||||||||
|
||||||||||||||||||
console.log('Waiting for message to be relayed...') | ||||||||||||||||||
await l1Provider.getWithdrawalStatus({ receipt, targetChain: l2Provider.chain }) | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
})() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.