-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
feat: support for script tags, order, integrated deployer inside HRE (#…
…849) * feat: support for script tags, order, integrated deployer inside HRE * chore: rename new project name and update ci noninline library command * chore: add deploy tests in ci * chore: update solc and vyper versions in examples * fix: update deploy cache logic, script load path support for windows * chore: run lint formatter * chore: update readme files --------- Co-authored-by: Marko Arambasic <makiarambasic@gmail.com>
- beta-ethers-v5
- (#849)
- ethers-v5
- (#849)
- kiriya
- (#849)
- kiriyaga-txfusion-deploy-bump
- (#849)
- kiriyaga-txfusion-deployment-type-switch-ethers-v5
- (#849)
- kiriyaga-txfusion-depricate-hardhat-zksync
- (#849)
- kiriyaga-txfusion-hardhat-zksync-bump-ethers-v5
- (#849)
- kiriyaga-txfusion-pnpm-switch
- (#849)
- kiriyaga-txfusion-remove-verify-ethers-v5
- (#849)
- kiriyaga-txfusion-unpublish-npm-support
- (#849)
- kiriyaga-txfusion-update-hardhat-zksync-dependencies
- (#849)
- kiriyaga-txfusion-upgradable-dependency-fix-ethers-v5
- (#849)
- kiriyaga-txfusion-upgradable-deploy-bump
- (#849)
- kiriyaga-txfusion-upgradable-oz-v5-ethers-v5
- (#849)
- kiriyaga-txfusion-upgradable-paymaster-ethers-v5
- (#849)
- kiriyaga-txfusion-valid-oz-contracts-ethers-v5
- (#849)
- nikola-bozin-txfusion-chai-fix-provider-network
- (#849)
- nikola-bozin-txfusion-deprecate-chai-v5
- (#849)
- nikola-bozin-txfusion-e2e-hh-zksync-v5
- (#849)
- nikola-bozin-txfusion-upgrade-update-v5
- (#849)
- release-please--branches--beta-ethers-v5--components--@matterlabs/hardhat-zksync
- (#849)
- release-please--branches--beta-ethers-v5--components--@matterlabs/hardhat-zksync-deploy
- (#849)
- release-please--branches--ethers-v5--components--@matterlabs/hardhat-zksync-chai-matchers
- (#849)
- release-please--branches--ethers-v5--components--@matterlabs/hardhat-zksync-deploy
- (#849)
- release-please--branches--ethers-v5--components--@matterlabs/hardhat-zksync-ethers
- (#849)
- release-please--branches--ethers-v5--components--@matterlabs/hardhat-zksync-upgradable
- (#849)
1 parent
60d7505
commit d8110e1
Showing
59 changed files
with
2,999 additions
and
614 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
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,7 @@ | ||
module.exports = { | ||
extends: [`${__dirname}/../../config/eslint/eslintrc.cjs`], | ||
parserOptions: { | ||
project: `${__dirname}/tsconfig.json`, | ||
sourceType: "module", | ||
}, | ||
}; |
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,4 @@ | ||
cache | ||
artifacts | ||
contracts/tmp | ||
deployments |
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,63 @@ | ||
# zkSync Era deploy environment example | ||
|
||
This project demonstrates how to compile and deploy your contracts in zkSync Era using the Hardhat plugins. | ||
|
||
## Prerequisites | ||
|
||
- node.js 16.x or later. | ||
- yarn. | ||
|
||
## Configuration | ||
|
||
Plugin configuration is located in [`hardhat.config.ts`](./hardhat.config.ts). | ||
You should only change the zkSync network configuration. | ||
|
||
`hardhat.config.ts` example with zkSync network configured with the name `zkSyncNetwork` and `ethNetwork` used as the underlying layer 1 network: | ||
```ts | ||
import "@matterlabs/hardhat-zksync-deploy"; | ||
import { HardhatUserConfig } from 'hardhat/types'; | ||
|
||
const config: HardhatUserConfig = { | ||
networks: { | ||
ethNetwork: { | ||
url: 'http://0.0.0.0:8545', | ||
}, | ||
zkSyncNetwork: { | ||
url: 'http://0.0.0.0:3050', | ||
ethNetwork: 'ethNetwork', | ||
zksync: true, | ||
deployPaths: ['deploy-zkSync', 'deploy'], | ||
accounts: ['0xac1e735be8536c6534bb4f17f06f6afc73b2b5ba84ac2cfb12f7461b20c0bbe3', '0x28a574ab2de8a00364d5dd4b07c4f2f574ef7fcc2a86a197f65abaec836d1959'], | ||
}, | ||
} | ||
}; | ||
|
||
export default config; | ||
``` | ||
|
||
## Usage | ||
|
||
Before using plugins, you need to build them first | ||
|
||
```sh | ||
# Run the following in the *root* of the repo. | ||
yarn | ||
yarn build | ||
``` | ||
|
||
After that you should be able to run plugins: | ||
|
||
```sh | ||
# Run the following in `examples/basic-example` folder. | ||
yarn | ||
yarn hardhat compile | ||
yarn hardhat deploy-zksync | ||
``` | ||
|
||
- `yarn hardhat compile`: compiles all the contracts in the `contracts` folder. | ||
- `yarn hardhat deploy-zksync`: runs all the deploy scripts. | ||
- To run a specific script, add the `--script` argument, e.g. `--script 002_deploy.ts`. | ||
- To run on a specific zkSync network, use standard hardhat `--network` argument, e.g. `--network zkSyncNetworkV2` | ||
(with `zkSyncNetwork` network specified in the `hardhat.config` networks section, with the `zksync` flag set to `true` and `ethNetwork` specified). | ||
|
||
If you don't specify zkSync network (`--network`), `local-setup` with <http://localhost:8545> (Ethereum RPC URL) and <http://localhost:3050> (zkSync RPC URL) will be used. |
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,13 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
pragma abicoder v2; | ||
|
||
contract Constant { | ||
uint c = 42; | ||
constructor() {} | ||
|
||
function getValue() public view returns (uint) { | ||
return c; | ||
} | ||
} |
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,7 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
contract Foo { | ||
string public name = "Foo"; | ||
} |
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 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
contract Greeter { | ||
string greeting; | ||
constructor(string memory _greeting) { | ||
greeting = _greeting; | ||
} | ||
|
||
function greet() public view returns (string memory) { | ||
return greeting; | ||
} | ||
|
||
function setGreeting(string memory _greeting) public { | ||
greeting = _greeting; | ||
} | ||
} |
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,36 @@ | ||
import { HardhatRuntimeEnvironment } from 'hardhat/types'; | ||
import * as ethers from 'ethers'; | ||
import * as zk from 'zksync-ethers'; | ||
import chalk from 'chalk'; | ||
|
||
const deployScript = async function (hre: HardhatRuntimeEnvironment) { | ||
console.info(chalk.yellow(`Running deploy script for the Foo contract`)); | ||
|
||
const zkWallet = await hre.deployer.getWallet(0); | ||
hre.deployer.setWallet(zkWallet); | ||
|
||
// Deposit some funds to L2 in order to be able to perform deposits. | ||
const depositHandle = await zkWallet.deposit({ | ||
to: zkWallet.address, | ||
token: zk.utils.ETH_ADDRESS, | ||
amount: ethers.utils.parseEther('0.01'), | ||
}); | ||
await depositHandle.wait(); | ||
|
||
// Load the artifact we want to deploy. | ||
const artifact = await hre.deployer.loadArtifact('Foo'); | ||
|
||
// Deploy this contract. The returned object will be of a `Contract` type, similarly to ones in `ethers`. | ||
// This contract has no constructor arguments. | ||
const factoryContract = await hre.deployer.deploy(artifact, []); | ||
|
||
// Show the contract info. | ||
const contractAddress = factoryContract.address; | ||
console.info(chalk.green(`${artifact.contractName} was deployed to ${contractAddress}!`)); | ||
} | ||
|
||
export default deployScript; | ||
|
||
deployScript.tags = ['second']; | ||
deployScript.dependencies = ['first']; | ||
deployScript.priority = 800; |
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,29 @@ | ||
const chalk = require('chalk'); | ||
|
||
// An example of a deploy script which will deploy and call a simple contract. | ||
var deployScript = async function (hre) { | ||
console.info(chalk.yellow(`Running deploy script for the Greeter contract`)); | ||
|
||
// Load the artifact we want to deploy. | ||
const artifact = await deployer.loadArtifact('Greeter'); | ||
|
||
// Deploy this contract. The returned object will be of a `Contract` type, similarly to ones in `ethers`. | ||
// `greeting` is an argument for contract constructor. | ||
const greeting = 'Hi there!'; | ||
const greeterContract = await hre.deployer.deploy(artifact, [greeting], true); | ||
|
||
// Show the contract info. | ||
const contractAddress = greeterContract.address; | ||
console.info(chalk.green(`${artifact.contractName} was deployed to ${contractAddress}!`)); | ||
|
||
// Call the deployed contract. | ||
const greetingFromContract = await greeterContract.greet(); | ||
if (greetingFromContract == greeting) { | ||
console.info(chalk.green(`Successful greeting from the contract`)); | ||
} else { | ||
throw new Error(`Contract returned unexpected greeting: ${greetingFromContract}`); | ||
} | ||
}; | ||
|
||
module.exports["default"] = deployScript; | ||
deployScript.priority = 1500; |
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,21 @@ | ||
import { HardhatRuntimeEnvironment } from 'hardhat/types'; | ||
import chalk from 'chalk'; | ||
|
||
const deployScript = async function (hre: HardhatRuntimeEnvironment) { | ||
console.info(chalk.yellow(`Running deploy script for the Constant contract`)); | ||
|
||
// Load the artifact we want to deploy. | ||
const artifact = await hre.deployer.loadArtifact('Constant'); | ||
|
||
// Deploy this contract. The returned object will be of a `Contract` type, similarly to ones in `ethers`. | ||
// This contract has no constructor arguments. | ||
const factoryContract = await hre.deployer.deploy(artifact, []); | ||
|
||
// Show the contract info. | ||
const contractAddress = factoryContract.address; | ||
console.info(chalk.green(`${artifact.contractName} was deployed to ${contractAddress}!`)); | ||
} | ||
|
||
export default deployScript; | ||
|
||
deployScript.tags = ['first']; |
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,21 @@ | ||
import { HardhatRuntimeEnvironment } from 'hardhat/types'; | ||
import chalk from 'chalk'; | ||
|
||
const deployScript = async function (hre: HardhatRuntimeEnvironment) { | ||
console.info(chalk.yellow(`Running deploy script for the Constant contract from deploy folder`)); | ||
|
||
// Load the artifact we want to deploy. | ||
const artifact = await hre.deployer.loadArtifact('Constant'); | ||
|
||
// Deploy this contract. The returned object will be of a `Contract` type, similarly to ones in `ethers`. | ||
// This contract has no constructor arguments. | ||
const factoryContract = await hre.deployer.deploy(artifact, []); | ||
|
||
// Show the contract info. | ||
const contractAddress = factoryContract.address; | ||
console.info(chalk.green(`${artifact.contractName} was deployed to ${contractAddress}!`)); | ||
} | ||
|
||
export default deployScript; | ||
|
||
deployScript.tags = ['first']; |
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,51 @@ | ||
import '@matterlabs/hardhat-zksync-deploy'; | ||
import '@matterlabs/hardhat-zksync-solc'; | ||
|
||
import { HardhatUserConfig } from 'hardhat/config'; | ||
|
||
const config: HardhatUserConfig = { | ||
zksolc: { | ||
compilerSource: 'binary', | ||
settings: { | ||
isSystem: true, | ||
optimizer: { | ||
enabled: true, | ||
}, | ||
} | ||
}, | ||
deployerAccounts: { | ||
'zkSyncNetwork': 1 | ||
}, | ||
defaultNetwork: "zkSyncNetwork", | ||
networks: { | ||
hardhat: { | ||
zksync: true, | ||
}, | ||
ethNetwork: { | ||
url: 'http://0.0.0.0:8545', | ||
}, | ||
zkSyncNetwork: { | ||
url: 'http://0.0.0.0:3050', | ||
ethNetwork: 'ethNetwork', | ||
zksync: true, | ||
deployPaths: ['deploy-zkSync', 'deploy'], | ||
accounts: ['0xac1e735be8536c6534bb4f17f06f6afc73b2b5ba84ac2cfb12f7461b20c0bbe3', '0x28a574ab2de8a00364d5dd4b07c4f2f574ef7fcc2a86a197f65abaec836d1959'], | ||
}, | ||
zkSyncNetworkV2: { | ||
url: 'http://0.0.0.0:3050', | ||
ethNetwork: 'ethNetwork', | ||
zksync: true, | ||
forceDeploy: false, | ||
accounts: { | ||
mnemonic: 'stuff slice staff easily soup parent arm payment cotton trade scatter struggle' | ||
} | ||
} | ||
}, | ||
// Docker image only works for solidity ^0.8.0. | ||
// For earlier versions you need to use binary releases of zksolc. | ||
solidity: { | ||
version: '0.8.17', | ||
}, | ||
}; | ||
|
||
export default config; |
Oops, something went wrong.