Skip to content

Commit

Permalink
[Test] Release marketplace contracts on testnet and add to contracts …
Browse files Browse the repository at this point in the history
…package (#1150)

* feat(deploy): deploy to testnets

* chore(build): hardhat build

* feat(pack): release, test, bump updated contracts

* chore(gha): updated env vars

* chore(pnpm): updated lock file

* fix(build): build error, replaced util with viem

* fix(pnpm): root dir ethers resolution

* chore(pnpm): updated lockfile

* fix(pnpm): overrides

* chore(build): resolving build issues sdk

* chore(refactor): dep resolution bug - del eth v5

* fix(test): mock ipfs in minting, remove timeout
  • Loading branch information
bitbeckers authored Nov 3, 2023
1 parent d48f2ba commit d01c7b0
Show file tree
Hide file tree
Showing 104 changed files with 11,385 additions and 1,888 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ env:
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
NEXT_PUBLIC_SUPABASE_TABLE: ${{ vars.NEXT_PUBLIC_SUPABASE_TABLE }}
NEXT_PUBLIC_WALLETCONNECT_ID: ${{ secrets.NEXT_PUBLIC_WALLETCONNECT_ID }}
GOERLI_RPC_URL: ${{ vars.GOERLI_RPC_URL }}
MAINNET_RPC_URL: ${{ vars.MAINNET_RPC_URL }}
INFURA_API_KEY: ${{ vars.INFURA_API_KEY }}
ALCHEMY_API_KEY: ${{ vars.ALCHEMY_API_KEY }}
DOCKER_PLATFORM: "amd64"

# Trigger the workflow when:
Expand Down
15 changes: 9 additions & 6 deletions contracts/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
MNEMONIC="test test test test test test test test test test test junk"
MNEMONIC_CELO=="test test test test test test test test test test test junk"
INFURA_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"

# RPCs
MAINNET_RPC_URL=""
OPTIMISM_RPC_URL=""
GOERLI_RPC_URL=""
ALCHEMY_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"

# OpenZeppelin
OPENZEPPELIN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
Expand All @@ -18,6 +14,13 @@ OPTIMISTIC_ETHERSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
CELOSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"

# Unused, ignore below
POLYGONSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
REPORT_GAS=false
CMC_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"

# Marketplace
OWNER_ADDRESS="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
TRANSFER_MANAGER_SALT="bbbbbbbbbbbbbb"
LOOKSRARE_PROTOCOL_SALT="cccccccccccccc"
STRATEGY_COLLECTION_OFFER_SALT="dddddddddddddd"
PROTOCOL_FEE_RECIPIENT_ADDRESS="eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"

2 changes: 1 addition & 1 deletion contracts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
**/deployments/localhost
**/out*
**/typechain
**/src/types
**/types
**/cache**
**/abi
**/rollup-cache
Expand Down
18 changes: 14 additions & 4 deletions contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[profile.default]
auto_detect_solc = true
allow_paths = ["../node_modules", "lib"]
allow_paths = ["../node_modules", "node_modules", "lib"]
bytecode_hash = "none"
force = false
fuzz = { runs = 1025 }
Expand All @@ -13,17 +13,27 @@ optimizer = true
optimizer_runs = 5_000
out = "out"
src = "src"
script = "scripts/deployment"
test = "test/foundry"
no_match_test = "testCannotExecuteOrderIfInvalidUserGlobal"

[profile.ci]
fuzz = { runs = 1024 }
verbosity = 1

[etherscan]
mainnet = { key = "${ETHERSCAN_API_KEY}" }
goerli = { key = "${ETHERSCAN_API_KEY}" }
optimism = { key = "${OPTIMISTIC_ETHERSCAN_API_KEY}" }
sepolia = { key = "${ETHERSCAN_API_KEY}" }
celo = { key = "${CELOSCAN_API_KEY}" }

[rpc_endpoints]
mainnet = "${MAINNET_RPC_URL}"
goerli = "${GOERLI_RPC_URL}"
optimism = "${OPTIMISM_RPC_URL}"
mainnet = "https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
goerli = "https://eth-goerli.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
optimism = "https://opt-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
sepolia = "https://sepolia.infura.io/v3/${INFURA_API_KEY}"
celo = "https://forno.celo.org"

[fmt]
number_underscore = "thousands"
Expand Down
80 changes: 43 additions & 37 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import "@nomicfoundation/hardhat-chai-matchers";
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import "@nomiclabs/hardhat-ethers";
import "@nomicfoundation/hardhat-chai-matchers";
import "@openzeppelin/hardhat-upgrades";
import "@openzeppelin/hardhat-defender";

import "@primitivefi/hardhat-dodoc";
import { config as dotenvConfig } from "dotenv";
Expand Down Expand Up @@ -34,17 +33,20 @@ const dotenvConfigPath: string = process.env.DOTENV_PATH ?? fs.existsSync("./.en
dotenvConfig({ path: resolve(__dirname, dotenvConfigPath) });

// Ensure that we have all the environment variables we need.
const mnemonic = requireEnv(process.env.MNEMONIC, "MNEMONIC");
const mnemonic_celo = requireEnv(process.env.MNEMONIC_CELO, "MNEMONIC_CELO");
const infuraApiKey = requireEnv(process.env.INFURA_API_KEY, "INFURA_API_KEY");
const optimismRpcUrl = requireEnv(process.env.OPTIMISM_RPC_URL, "OPTIMISM_RPC_URL");
const MNEMONIC = requireEnv(process.env.MNEMONIC, "MNEMONIC");
const MNEMONIC_CELO = requireEnv(process.env.MNEMONIC_CELO, "MNEMONIC_CELO");
const INFURA_API_KEY = requireEnv(process.env.INFURA_API_KEY, "INFURA_API_KEY");
const ALCHEMY_API_KEY = requireEnv(process.env.ALCHEMY_API_KEY, "ALCHEMY_API_KEY");

const etherscanApiKey = requireEnv(process.env.ETHERSCAN_API_KEY, "ETHERSCAN_API_KEY");
const optimisticEtherscanApiKey = requireEnv(process.env.OPTIMISTIC_ETHERSCAN_API_KEY, "OPTIMISTIC_ETHERSCAN_API_KEY");
const celoscanApiKey = requireEnv(process.env.CELOSCAN_API_KEY, "CELOSCAN_API_KEY");
const ETHERSCAN_API_KEY = requireEnv(process.env.ETHERSCAN_API_KEY, "ETHERSCAN_API_KEY");
const OPTIMISTIC_ETHERSCAN_API_KEY = requireEnv(
process.env.OPTIMISTIC_ETHERSCAN_API_KEY,
"OPTIMISTIC_ETHERSCAN_API_KEY",
);
const CELOSCAN_API_KEY = requireEnv(process.env.CELOSCAN_API_KEY, "CELOSCAN_API_KEY");

const ozApiKey = requireEnv(process.env.OPENZEPPELIN_API_KEY, "OPENZEPPELIN_API_KEY");
const ozSecretKey = requireEnv(process.env.OPENZEPPELIN_SECRET_KEY, "OPENZEPPELIN_SECRET_KEY");
const OPENZEPPELIN_API_KEY = requireEnv(process.env.OPENZEPPELIN_API_KEY, "OPENZEPPELIN_API_KEY");
const OPENZEPPELIN_SECRET_KEY = requireEnv(process.env.OPENZEPPELIN_SECRET_KEY, "OPENZEPPELIN_SECRET_KEY");

/**
* Maps a key to the chain ID
Expand All @@ -64,23 +66,30 @@ const chainIds = {
};

function getChainConfig(chain: keyof typeof chainIds) {
const jsonRpcUrl = "https://" + chain + ".infura.io/v3/" + infuraApiKey;
const jsonRpcUrl = "https://" + chain + ".infura.io/v3/" + INFURA_API_KEY;
let config = {
accounts: {
count: 10,
mnemonic,
mnemonic: MNEMONIC,
path: "m/44'/60'/0'/0",
},
chainId: chainIds[chain],
url: jsonRpcUrl,
};

if (chain === "optimism-mainnet") {
config = {
...config,
url: `https://opt-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`,
};
}

if (chain === "celo-mainnet") {
config = {
...config,
accounts: {
count: 10,
mnemonic: mnemonic_celo,
mnemonic: MNEMONIC_CELO,
path: "m/44'/52752'/0'/0",
},
};
Expand All @@ -89,18 +98,18 @@ function getChainConfig(chain: keyof typeof chainIds) {
return config;
}

const config = {
const config: HardhatUserConfig = {
abiExporter: {
path: "./src/abi",
path: "./abi",
runOnCompile: true,
clear: true,
flat: true,
format: "minimal",
except: ["@openzeppelin"],
},
defender: {
apiKey: ozApiKey!,
apiSecret: ozSecretKey!,
apiKey: OPENZEPPELIN_API_KEY!,
apiSecret: OPENZEPPELIN_SECRET_KEY!,
useDefenderDeploy: true,
},
dodoc: {
Expand All @@ -111,10 +120,10 @@ const config = {
},
etherscan: {
apiKey: {
goerli: etherscanApiKey!,
sepolia: etherscanApiKey!,
optimisticEthereum: optimisticEtherscanApiKey!,
celo: celoscanApiKey!,
goerli: ETHERSCAN_API_KEY!,
sepolia: ETHERSCAN_API_KEY!,
optimisticEthereum: OPTIMISTIC_ETHERSCAN_API_KEY!,
celo: CELOSCAN_API_KEY!,
},
customChains: [
{
Expand All @@ -133,7 +142,7 @@ const config = {
// metamask can't transfer when connected to hardhat's network.
initialBaseFeePerGas: 0,
accounts: {
mnemonic,
mnemonic: MNEMONIC,
},
chainId: chainIds.hardhat,
},
Expand All @@ -145,32 +154,30 @@ const config = {
sepolia: getChainConfig("sepolia"),
mainnet: getChainConfig("mainnet"),
"optimism-goerli": getChainConfig("optimism-goerli"),
"optimism-mainnet": {
...getChainConfig("optimism-mainnet"),
url: optimismRpcUrl,
},
"optimism-mainnet": getChainConfig("optimism-mainnet"),
},
paths: {
cache: "./cache_hardhat", // Use a different cache for Hardhat than Foundry
sources: "./src/protocol",
sources: "./src",
tests: "./test",
},
preprocess: {
eachLine: () => ({
eachLine: (hre) => ({
transform: (line: string) => {
if (line.match(/^\s*import /i)) {
getRemappings().forEach(([find, replace]) => {
if (line.match(find)) {
line = line.replace(find, replace);
for (const [from, to] of getRemappings()) {
if (line.includes(from)) {
line = line.replace(from, to);
break;
}
});
}
}
return line;
},
}),
},
solidity: {
version: "0.8.16",
version: "0.8.17",
settings: {
optimizer: {
enabled: true,
Expand All @@ -179,8 +186,7 @@ const config = {
},
},
typechain: {
outDir: "./src/types",
target: "ethers-v5",
outDir: "./types",
},
};

Expand Down
42 changes: 15 additions & 27 deletions contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@hypercerts-org/contracts",
"description": "EVM compatible protocol for managing impact claims",
"version": "0.8.11",
"version": "0.9.0",
"author": {
"name": "Hypercerts Foundation",
"url": "https://github.com/hypercerts-org/hypercerts"
Expand All @@ -26,50 +26,33 @@
"files": [
"dist",
"README.md",
"package.json",
"contracts"
"package.json"
],
"devDependencies": {
"@chainlink/contracts": "^0.8.0",
"@commitlint/cli": "^17.1.2",
"@commitlint/config-conventional": "^17.1.0",
"@dlsl/hardhat-markup": "^1.0.0-rc.7",
"@ethersproject/abi": "^5.7.0",
"@ethersproject/bytes": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@looksrare/contracts-libs": "^3.4.0",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.5",
"@nomicfoundation/hardhat-network-helpers": "^1.0.7",
"@nomicfoundation/hardhat-toolbox": "^2.0.0",
"@nomiclabs/hardhat-ethers": "^2.2.1",
"@nomiclabs/hardhat-etherscan": "^3.1.3",
"@nomicfoundation/hardhat-toolbox": "^3.0.0",
"@openzeppelin/contracts": "<5.0.0",
"@openzeppelin/hardhat-defender": "^1.8.2",
"@openzeppelin/hardhat-upgrades": "^1.28",
"@openzeppelin/hardhat-upgrades": "2.3.3",
"@primitivefi/hardhat-dodoc": "^0.2.3",
"@rollup/plugin-commonjs": "^24.0.1",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.1",
"@trivago/prettier-plugin-sort-imports": "^3.3.0",
"@typechain/ethers-v5": "^11.1.1",
"@typechain/hardhat": "^9.0.0",
"@types/chai": "^4.3.4",
"@types/mocha": "9.1.0",
"@types/node": "^18.11.11",
"@typescript-eslint/eslint-plugin": "^5.38.0",
"@typescript-eslint/parser": "^5.38.0",
"chai": "^4.3.7",
"commitizen": "^4.2.5",
"copyfiles": "^2.4.1",
"cross-env": "^7.0.3",
"cz-conventional-changelog": "^3.3.0",
"dotenv": "^16.0.2",
"eslint": "^8.23.1",
"eslint-config-prettier": "^8.5.0",
"ethers": "^5.7.2",
"hardhat": "2.13.1",
"ethers": "^6.8.0",
"hardhat-abi-exporter": "^2.10.1",
"hardhat-gas-reporter": "^1.0.9",
"hardhat-preprocessor": "^0.1.5",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
Expand Down Expand Up @@ -100,14 +83,16 @@
"template"
],
"scripts": {
"build": "hardhat compile && pnpm tsc -p tsconfig.build.json && rollup -c && pnpm copy:contracts",
"build:forge": "forge build",
"clean": "rimraf cache out dist src/typechain src/abi",
"copy:contracts": "copyfiles -u 1 ./src/**/*.sol ./src/*.sol ./contracts",
"build": "pnpm clean && hardhat compile && pnpm tsc -p tsconfig.build.json && rollup -c",
"build:forge": "pnpm clean && forge build",
"clean": "rimraf abi artifacts build cache cache_hardhat dist out types",
"deploy:marketplace:goerli": "forge script scripts/deployment/Deployment.s.sol:Deployment --broadcast --verify --fork-url goerli",
"deploy:marketplace:sepolia": "forge script scripts/deployment/Deployment.s.sol:Deployment --broadcast --verify --fork-url sepolia",
"deploy:marketplace:test": "pnpm deploy:marketplace:goerli && pnpm deploy:marketplace:sepolia",
"deploy:marketplace:dryrun": "forge script scripts/deployment/Deployment.s.sol:Deployment --fork-url",
"docs": "hardhat dodoc",
"lint": "pnpm lint:sol && pnpm prettier:check",
"lint:sol": "forge fmt --check && solhint \"./{src,test/protocol,test/marketplace}/**/*.sol\"",
"prebuild": "pnpm clean",
"prepublish": "pnpm build",
"prettier": "prettier --config \"./.prettierrc.yml\" --write \"**/*.{json,md,ts,yml}\"",
"prettier:check": "prettier --config \"./.prettierrc.yml\" --check \"**/*.{json,md,ts,yml}\"",
Expand All @@ -117,5 +102,8 @@
"test:hardhat": "hardhat test",
"test:gas": "forge test --match-path test/foundry/PerformanceTesting.t.sol --gas-report",
"hardhat": "hardhat"
},
"dependencies": {
"hardhat": "^2.18.3"
}
}
4 changes: 2 additions & 2 deletions contracts/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import nodePolyfills from "rollup-plugin-node-polyfills";

export default [
{
input: `build/index.js`,
input: `build/src/index.js`,
plugins: [
autoExternal(),
nodePolyfills(),
Expand All @@ -33,7 +33,7 @@ export default [
],
},
{
input: `build/index.d.ts`,
input: `build/src/index.d.ts`,
plugins: [json(), dts()],
output: {
file: `dist/index.d.ts`,
Expand Down
Loading

0 comments on commit d01c7b0

Please sign in to comment.