-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into sarah/custom-chain
- Loading branch information
Showing
17 changed files
with
524 additions
and
77 deletions.
There are no files selected for viewing
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,12 @@ | ||
<template> | ||
<span | ||
:id="actionId" | ||
data-test-action | ||
/> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
defineProps<{ | ||
actionId: string; | ||
}>(); | ||
</script> |
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 |
---|---|---|
|
@@ -26,7 +26,7 @@ During the alpha phase, ZKsync Era Test Nodes are currently undergoing developme | |
|
||
First, initialize a new Hardhat TypeScript project: | ||
|
||
<span id="initialize-hardhat-project" data-name="runCommand"></span> | ||
:test-action{actionId="initialize-hardhat-project"} | ||
|
||
```bash | ||
npx hardhat init | ||
|
@@ -36,7 +36,7 @@ Select the `Create a TypeScript project` option and install the sample project's | |
|
||
To install the `hardhat-zksync` plugin, execute the following command: | ||
|
||
<span id="install-hh-zksync" data-name="runCommand" data-command-folder="tests-output/hardhat-project"></span> | ||
:test-action{actionId="install-hh-zksync"} | ||
|
||
::code-group | ||
|
||
|
@@ -52,8 +52,7 @@ yarn add -D @matterlabs/hardhat-zksync | |
|
||
Once installed, add the plugin at the top of your `hardhat.config.ts` file. | ||
|
||
<span id="import-zksync-config" data-name="modifyFile" data-filepath="tests-output/hardhat-project/hardhat.config.ts" | ||
data-at-line="3"></span> | ||
:test-action{actionId="import-zksync-config"} | ||
|
||
```ts [hardhat.config.ts] | ||
import "@matterlabs/hardhat-zksync"; | ||
|
@@ -63,7 +62,7 @@ import "@matterlabs/hardhat-zksync"; | |
|
||
You can now safely run the **ZKsync Era Test Node** with the following command: | ||
|
||
<span id="run-hh-node" data-name="runCommand" data-command-folder="tests-output/hardhat-project" data-pre-command="bun pm2 start '<COMMAND>' --name hh-zknode"></span> | ||
:test-action{actionId="run-hh-node"} | ||
|
||
::code-group | ||
|
||
|
@@ -77,9 +76,8 @@ yarn hardhat node-zksync | |
|
||
:: | ||
|
||
<span id="wait-for-hh-node" data-name="wait" data-timeout="6000"></span> | ||
|
||
<span id="test-hh-node" data-name="checkIfBalanceIsZero" data-network-url="http://127.0.0.1:8011" data-address="0xe2b8Cb53a43a56d4d2AB6131C81Bd76B86D3AFe5"></span> | ||
:test-action{actionId="wait-for-hh-node"} | ||
:test-action{actionId="test-hh-node"} | ||
|
||
::callout{icon="i-heroicons-exclamation-circle"} | ||
We'll want to verify the correctness of our installations and test if we can run a **ZKsync Era Test Node**, | ||
|
@@ -107,8 +105,7 @@ To enable the usage of ZKsync Era Test Node in Hardhat, | |
add the `zksync:true` option to the hardhat network in the `hardhat.config.ts` file | ||
and the `latest` version of `zksolc`: | ||
|
||
<span id="zksync-hh-network" data-name="modifyFile" data-filepath="tests-output/hardhat-project/hardhat.config.ts" | ||
data-at-line="7"></span> | ||
:test-action{actionId="zksync-hh-network"} | ||
|
||
```ts | ||
zksolc: { | ||
|
@@ -128,7 +125,7 @@ it's necessary to use the `hardhat-chai-matchers` plugin. | |
|
||
In the root directory of your project, execute this command: | ||
|
||
<span id="install-chai-ethers" data-name="runCommand" data-command-folder="tests-output/hardhat-project" data-pre-command="<COMMAND>"></span> | ||
:test-action{actionId="install-chai-ethers"} | ||
|
||
::code-group | ||
|
||
|
@@ -144,16 +141,15 @@ yarn add -D @nomicfoundation/hardhat-chai-matchers [email protected] | |
|
||
After installing it, add the plugin at the top of your `hardhat.config.ts` file: | ||
|
||
<span id="import-chai-matchers" data-name="modifyFile" data-filepath="tests-output/hardhat-project/hardhat.config.ts" | ||
data-at-line="4"></span> | ||
:test-action{actionId="import-chai-matchers"} | ||
|
||
```ts [hardhat.config.ts] | ||
import "@nomicfoundation/hardhat-chai-matchers"; | ||
``` | ||
|
||
With the previous steps completed, your `hardhat.config.ts` file should now be properly configured to include settings for local testing. | ||
|
||
<span id="compare-config" data-name="compareToFile" data-filepath="tests-output/hardhat-project/hardhat.config.ts"></span> | ||
:test-action{actionId="compare-config"} | ||
|
||
```ts [hardhat.config.ts] | ||
import { HardhatUserConfig } from "hardhat/config"; | ||
|
@@ -182,15 +178,15 @@ To set up the environment for using chai matchers and writing tests, you'll need | |
|
||
Inside the **contracts** folder, rename the example contract file to **Greeter.sol**. | ||
|
||
<span id="rename-greeter-file" data-name="runCommand" data-command-folder="tests-output/hardhat-project"></span> | ||
:test-action{actionId="rename-greeter-file"} | ||
|
||
```bash | ||
mv contracts/Lock.sol contracts/Greeter.sol | ||
``` | ||
|
||
Now replace the example contract in **Greeter.sol** with the new `Greeter` contract below: | ||
|
||
<span id="create-greeter-contract" data-name="writeToFile" data-filepath="tests-output/hardhat-project/contracts/Greeter.sol"></span> | ||
:test-action{actionId="create-greeter-contract"} | ||
|
||
```solidity [Greeter.sol] | ||
// SPDX-License-Identifier: MIT | ||
|
@@ -223,15 +219,15 @@ Now you can create a test with the `hardhat-chai-matchers` plugin: | |
|
||
Inside the `/test` folder, rename the example test file to `test.ts`. | ||
|
||
<span id="rename-test-file" data-name="runCommand" data-command-folder="tests-output/hardhat-project"></span> | ||
:test-action{actionId="rename-test-file"} | ||
|
||
```bash | ||
mv test/Lock.ts test/test.ts | ||
``` | ||
|
||
Replace the old test with this example showcasing the functionalities of the contract: | ||
|
||
<span id="create-test" data-name="writeToFile" data-filepath="tests-output/hardhat-project/test/test.ts"></span> | ||
:test-action{actionId="create-test"} | ||
|
||
```typescript | ||
import * as hre from "hardhat"; | ||
|
@@ -284,7 +280,7 @@ describe("Greeter", function () { | |
|
||
Execute the following command in your terminal to run the tests: | ||
|
||
<span id="run-test" data-name="runCommand" data-command-folder="tests-output/hardhat-project"></span> | ||
:test-action{actionId="run-test"} | ||
|
||
::code-group | ||
|
||
|
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,18 @@ | ||
import { steps as erc20PaymasterSteps } from './erc20-paymaster'; | ||
import { steps as howToTestContractsSteps } from './how-to-test-contracts'; | ||
|
||
export function getConfig(tutorialName: string) { | ||
let steps; | ||
switch (tutorialName) { | ||
case 'erc20-paymaster': | ||
steps = erc20PaymasterSteps; | ||
break; | ||
case 'how-to-test-contracts': | ||
steps = howToTestContractsSteps; | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
return steps; | ||
} |
Oops, something went wrong.