-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5916 from NomicFoundation/fix-viem-problems
Fix hardhat-viem so that it works with EDR simulating Op
- Loading branch information
Showing
15 changed files
with
202 additions
and
68 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { network } from "@ignored/hardhat-vnext"; | ||
|
||
async function sendL2Transaction(networkConfigName: string) { | ||
console.log("Sending transaction using network", networkConfigName); | ||
|
||
const { viem, networkConfig } = await network.connect( | ||
networkConfigName, | ||
"optimism", | ||
); | ||
|
||
if (networkConfig.type === "edr") { | ||
console.log("Using an EDR network simulating Optimism, forking it"); | ||
} else { | ||
console.log("Using an HTTP connection to Optimism"); | ||
} | ||
|
||
const publicClient = await viem.getPublicClient(); | ||
const [senderClient] = await viem.getWalletClients(); | ||
|
||
console.log("Sender:", await senderClient.account.address); | ||
|
||
console.log( | ||
"Sender balance:", | ||
await publicClient.getBalance(senderClient.account), | ||
); | ||
|
||
console.log("Sending 1 wei from", senderClient.account.address, "to itself"); | ||
|
||
console.log("Estimating L1 gas first"); | ||
const l1Gas = await publicClient.estimateL1Gas({ | ||
account: senderClient.account.address, | ||
to: senderClient.account.address, | ||
value: 1n, | ||
}); | ||
|
||
console.log("Estimated L1 gas:", l1Gas); | ||
|
||
console.log("Sending L2 transaction"); | ||
const tx = await senderClient.sendTransaction({ | ||
to: senderClient.account.address, | ||
value: 1n, | ||
}); | ||
|
||
const receipt = await publicClient.waitForTransactionReceipt({ hash: tx }); | ||
|
||
console.log("Transaction receipt:", receipt); | ||
} | ||
|
||
await sendL2Transaction("op"); | ||
console.log(""); | ||
console.log(""); | ||
console.log(""); | ||
await sendL2Transaction("edrOp"); |
2 changes: 1 addition & 1 deletion
2
...ple-project/scripts/send-op-sepolia-tx.ts → v-next/example-project/scripts/send-op-tx.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import assert from "node:assert/strict"; | ||
import { describe, it } from "node:test"; | ||
|
||
import { CustomError } from "../src/error.js"; | ||
|
||
describe("CustomError", () => { | ||
class MockCustomError extends CustomError {} | ||
|
||
it("should not set the `cause` property to `undefined` if not provided", () => { | ||
const error = new MockCustomError("test"); | ||
|
||
assert.ok(!("cause" in error), "The `cause` property shouldn't be present"); | ||
}); | ||
|
||
it("should set the `cause` property to if provided", () => { | ||
const cause = new Error("cause"); | ||
const error = new MockCustomError("test", cause); | ||
|
||
assert.equal( | ||
error.cause, | ||
error.cause, | ||
"The `cause` property should be set to the provided error", | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.