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

Support zksync #7

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
22 changes: 21 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,24 @@ out/
optimized-out/
.vscode/
broadcast/
.env
.env

# Hardhat files
/cache
/artifacts

# TypeChain files
/typechain
/typechain-types

# solidity-coverage files
/coverage
/coverage.json

# zksync build artifacts
/artifacts-zk
/cache-zk

# zksync local node logs
era_test_node.log
/node_modules
9 changes: 6 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/hats-module"]
path = lib/hats-module
url = https://github.com/hats-protocol/hats-module
[submodule "lib/solady"]
path = lib/solady
url = https://github.com/vectorized/solady
[submodule "lib/hats-protocol"]
path = lib/hats-protocol
url = https://github.com/Hats-Protocol/hats-protocol
[submodule "lib/hats-module"]
path = lib/hats-module
url = https://github.com/alexkeating/hats-module
1 change: 1 addition & 0 deletions deployments-zk/zkSyncLocal/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0x12c

Large diffs are not rendered by default.

106 changes: 53 additions & 53 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -1,71 +1,71 @@
[profile.default]
src = 'src'
out = 'out'
libs = ['lib']
optimizer_runs = 1_000_000
# the following setting ensures that deterministically deployed contracts will always be to the same address
bytecode_hash = "none"
gas_reports = ["MultiClaimsHatter"]
auto_detect_solc = false
solc = "0.8.19"
remappings = [
"ds-test/=lib/forge-std/lib/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"hats-module/=lib/hats-module/src/",
]
# Enable tests to read ir-optimized bytecode precompiled by profile.optimized
fs_permissions = [{ access = "read", path = "./optimized-out" }]
libs = ['lib']
optimizer_runs = 1_000_000
out = 'out'
src = 'src'
# the following setting ensures that deterministically deployed contracts will always be to the same address
auto_detect_solc = false
bytecode_hash = "none"
gas_reports = ["MultiClaimsHatter"]
remappings = [
"ds-test/=lib/forge-std/lib/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"hats-module/=lib/hats-module/src/",
]
solc = "0.8.19"
# Enable tests to read ir-optimized bytecode precompiled by profile.optimized
fs_permissions = [{ access = "read", path = "./optimized-out" }]

# for pre-compiling ir-optimized bytecode that will be later deployed by tests
[profile.optimized]
via_ir = true
out = "optimized-out"
script = "src"
bytecode_hash = "none"
sizes = true
# no need to compile tests with via-ir since they load optimized bytecode directly by default
test = "src"
bytecode_hash = "none"
out = "optimized-out"
script = "src"
sizes = true
via_ir = true
# no need to compile tests with via-ir since they load optimized bytecode directly by default
test = "src"

# for running tests against pre-compiled ir-optimized deployments
[profile.test]
src = "test"
src = "test"

[profile.ci]
fuzz = { runs = 5000 }
invariant = { runs = 1000 }
fuzz = { runs = 5000 }
invariant = { runs = 1000 }

[profile.lite]
fuzz = { runs = 32 }
invariant = { runs = 10 }
# Speed up compilation and tests during development.
optimizer = false
fuzz = { runs = 32 }
invariant = { runs = 10 }
# Speed up compilation and tests during development.
optimizer = false

[fmt]
bracket_spacing = true
int_types = "long"
line_length = 120
multiline_func_header = "attributes_first"
number_underscore = "thousands"
quote_style = "double"
tab_width = 2
wrap_comments = true
bracket_spacing = true
int_types = "long"
line_length = 120
multiline_func_header = "attributes_first"
number_underscore = "thousands"
quote_style = "double"
tab_width = 2
wrap_comments = true

[rpc_endpoints]
arbitrum = "https://arbitrum-mainnet.infura.io/v3/${INFURA_KEY}"
celo = "https://forno.celo.org"
gnosis = "${GC_RPC}"
local = "http://localhost:8545"
mainnet = "https://mainnet.infura.io/v3/${INFURA_KEY}"
optimism = "https://optimism-mainnet.infura.io/v3/${INFURA_KEY}"
polygon = "${POLYGON_RPC}"
sepolia = "https://sepolia.infura.io/v3/${INFURA_KEY}"
arbitrum = "https://arbitrum-mainnet.infura.io/v3/${INFURA_KEY}"
celo = "https://forno.celo.org"
gnosis = "${GC_RPC}"
local = "http://localhost:8545"
mainnet = "https://mainnet.infura.io/v3/${INFURA_KEY}"
optimism = "https://optimism-mainnet.infura.io/v3/${INFURA_KEY}"
polygon = "${POLYGON_RPC}"
sepolia = "https://sepolia.infura.io/v3/${INFURA_KEY}"

[etherscan]
arbitrum = { key = "${ARBISCAN_KEY}", url = "https://api.arbiscan.io/api" }
gnosis = { key = "${GNOSISSCAN_KEY}", url = "https://api.gnosisscan.io/api" }
mainnet = { key = "${ETHERSCAN_KEY}", url = "https://api.etherscan.io/api" }
optimism = { key = "${OPTIMISM_KEY}", url = "https://api-optimistic.etherscan.io/api" }
sepolia = { key = "${ETHERSCAN_KEY}", url = "https://api-sepolia.etherscan.io/api" }
polygon = { key = "${POLYGONSCAN_KEY}", url = "https://api.polygonscan.com/api" }
arbitrum = { key = "${ARBISCAN_KEY}", url = "https://api.arbiscan.io/api" }
gnosis = { key = "${GNOSISSCAN_KEY}", url = "https://api.gnosisscan.io/api" }
mainnet = { key = "${ETHERSCAN_KEY}", url = "https://api.etherscan.io/api" }
optimism = { key = "${OPTIMISM_KEY}", url = "https://api-optimistic.etherscan.io/api" }
polygon = { key = "${POLYGONSCAN_KEY}", url = "https://api.polygonscan.com/api" }
sepolia = { key = "${ETHERSCAN_KEY}", url = "https://api-sepolia.etherscan.io/api" }

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
# See more config options https://github.com/foundry-rs/foundry/tree/master/config
54 changes: 54 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import "@nomicfoundation/hardhat-toolbox";
import "@nomicfoundation/hardhat-foundry";

import "@matterlabs/hardhat-zksync-deploy";
import "@matterlabs/hardhat-zksync-solc";
import "@matterlabs/hardhat-zksync-node";
import "@matterlabs/hardhat-zksync-upgradable";
import "@matterlabs/hardhat-zksync-verify"

import * as dotenv from 'dotenv';
dotenv.config();

const config: HardhatUserConfig = {
solidity: "0.8.19",
zksolc: {
version: "1.4.0",
settings: {
optimizer: {
enabled: true,
},
},
},
paths: {
"sources": "./src",
},
networks: {
hardhat: {
zksync: false,
},
ethNetwork: {
zksync: false,
url: "http://localhost:8545",
},
zkSyncLocal: {
zksync: true,
ethNetwork: "ethNetwork",
url: process.env.ZK_LOCAL_NETWORK_URL ? process.env.ZK_LOCAL_NETWORK_URL : "http://0.0.0.0:8011",
},
mainnet: {
zksync: false,
url: "https://eth-mainnet.g.alchemy.com/v2/SECRET",
},
zkSyncEra: {
zksync: true,
ethNetwork: "mainnet",
url: "https://zksync-mainnet.g.alchemy.com/v2/SECRET",
},
},
defaultNetwork: "zkSyncLocal",
};

export default config;
1 change: 1 addition & 0 deletions lib/hats-protocol
Submodule hats-protocol added at cccb71
Loading