Skip to content

Commit

Permalink
Merge pull request #67 from aragon/OS-1109/update-commons-contracts-t…
Browse files Browse the repository at this point in the history
…o-use-commons-config

feat: update commons contracts to use commons config
  • Loading branch information
clauBv23 authored Mar 13, 2024
2 parents bb86a7b + acf3cdc commit 96b2eda
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 78 deletions.
6 changes: 3 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# GENERAL

## The network used for testing purposes
NETWORK_NAME="mainnet" # ["mainnet", "goerli", "polygon", "polygonMumbai"]
NETWORK_NAME="mainnet" # ["mainnet", "sepolia", "polygon", "mumbai","baseMainnet", "baseGoerli", "baseSepolia", "arbitrum", "arbitrumSepolia"]

# CONTRACTS

## Hex encoded private keys separated by a comma `,`a
PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" # Default hardhat account 0 private key. DON'T USE FOR DEPLOYMENTS

## Infura credentials
INFURA_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
## RPC alchemy credentials
ALCHEMY_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"

## Gas Reporting
REPORT_GAS='true'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/contracts-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
if: ${{ needs.check_tag.outputs.package == 'contracts' }}
uses: ./.github/workflows/contracts-tests.yml
secrets:
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}

publish:
needs: [check_tag, tests]
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/contracts-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
workflow_call:
secrets:
INFURA_API_KEY:
ALCHEMY_API_KEY:
required: true
push:

Expand Down Expand Up @@ -32,14 +32,14 @@ jobs:
- name: 'Build the contracts'
run: 'yarn build'
env:
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}

- name: 'Build the typechain'
run: 'yarn typechain'
env:
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}

- name: 'Test the contracts and generate the coverage report'
run: 'yarn coverage >> $GITHUB_STEP_SUMMARY'
env:
INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}
8 changes: 8 additions & 0 deletions contracts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [UPCOMING]

### Added

### Changed

- Updated hardhat configuration to use the `commons- config` networks.

## v1.4.0

### Added
Expand Down
80 changes: 16 additions & 64 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import {
addRpcUrlToNetwork,
networks as osxCommonsNetworks,
getNetworkByNameOrAlias,
} from '@aragon/osx-commons-configs';
import '@nomicfoundation/hardhat-chai-matchers';
import '@nomicfoundation/hardhat-network-helpers';
import '@nomicfoundation/hardhat-toolbox';
import '@nomiclabs/hardhat-etherscan';
import '@openzeppelin/hardhat-upgrades';
import '@typechain/hardhat';
import {config as dotenvConfig} from 'dotenv';
import {ethers} from 'ethers';
import 'hardhat-deploy';
import 'hardhat-gas-reporter';
import {extendEnvironment, HardhatUserConfig} from 'hardhat/config';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {HardhatUserConfig} from 'hardhat/config';
import type {NetworkUserConfig} from 'hardhat/types';
import {resolve} from 'path';
import 'solidity-coverage';
Expand All @@ -18,69 +21,23 @@ import 'solidity-docgen';
const dotenvConfigPath: string = process.env.DOTENV_CONFIG_PATH || '../.env';
dotenvConfig({path: resolve(__dirname, dotenvConfigPath)});

if (!process.env.INFURA_API_KEY) {
throw new Error('INFURA_API_KEY in .env not set');
// check alchemy Api key existence
if (process.env.ALCHEMY_API_KEY) {
addRpcUrlToNetwork(process.env.ALCHEMY_API_KEY);
} else {
throw new Error('ALCHEMY_API_KEY in .env not set');
}

const apiUrls: {[index: string]: string} = {
mainnet: 'https://mainnet.infura.io/v3/',
goerli: 'https://goerli.infura.io/v3/',
sepolia: 'https://sepolia.infura.io/v3/',
polygon: 'https://polygon-mainnet.infura.io/v3/',
polygonMumbai: 'https://polygon-mumbai.infura.io/v3/',
base: 'https://mainnet.base.org',
baseGoerli: 'https://goerli.base.org',
arbitrum: 'https://arbitrum-mainnet.infura.io/v3/',
arbitrumGoerli: 'https://arbitrum-goerli.infura.io/v3/',
};

export const networks: {[index: string]: NetworkUserConfig} = {
hardhat: {
chainId: 31337,
forking: {
url: `${
apiUrls[process.env.NETWORK_NAME ? process.env.NETWORK_NAME : 'mainnet']
}${process.env.INFURA_API_KEY}`,
url:
getNetworkByNameOrAlias(process.env.NETWORK_NAME ?? 'mainnet')?.url ||
'',
},
},
mainnet: {
chainId: 1,
url: `${apiUrls.mainnet}${process.env.INFURA_API_KEY}`,
},
goerli: {
chainId: 5,
url: `${apiUrls.goerli}${process.env.INFURA_API_KEY}`,
},
sepolia: {
chainId: 11155111,
url: `${apiUrls.sepolia}${process.env.INFURA_API_KEY}`,
},
polygon: {
chainId: 137,
url: `${apiUrls.polygon}${process.env.INFURA_API_KEY}`,
},
polygonMumbai: {
chainId: 80001,
url: `${apiUrls.polygonMumbai}${process.env.INFURA_API_KEY}`,
},
base: {
chainId: 8453,
url: `${apiUrls.base}`,
gasPrice: ethers.utils.parseUnits('0.001', 'gwei').toNumber(),
},
baseGoerli: {
chainId: 84531,
url: `${apiUrls.baseGoerli}`,
gasPrice: ethers.utils.parseUnits('0.0000001', 'gwei').toNumber(),
},
arbitrum: {
chainId: 42161,
url: `${apiUrls.arbitrum}${process.env.INFURA_API_KEY}`,
},
arbitrumGoerli: {
chainId: 421613,
url: `${apiUrls.arbitrumGoerli}${process.env.INFURA_API_KEY}`,
},
...osxCommonsNetworks,
};

// Uses hardhats private key if none is set. DON'T USE THIS ACCOUNT FOR DEPLOYMENTS
Expand All @@ -89,7 +46,7 @@ const accounts = process.env.PRIVATE_KEY
: ['0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'];

for (const network in networks) {
// special treatement for hardhat
// special treatment for hardhat
if (network.startsWith('hardhat')) {
networks[network].accounts = {
mnemonic: 'test test test test test test test test test test test junk',
Expand All @@ -99,11 +56,6 @@ for (const network in networks) {
networks[network].accounts = accounts;
}

// Extend HardhatRuntimeEnvironment
extendEnvironment((hre: HardhatRuntimeEnvironment) => {
hre.aragonToVerifyContracts = [];
});

const config: HardhatUserConfig = {
defaultNetwork: 'hardhat',
etherscan: {
Expand Down
1 change: 1 addition & 0 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
"devDependencies": {
"@aragon/osx-commons-sdk": "0.0.1-alpha.5",
"@aragon/osx-commons-configs": "0.4.0",
"@aragon/osx-ethers-v1.0.0": "npm:@aragon/[email protected]",
"@aragon/osx-ethers-v1.3.0": "npm:@aragon/[email protected]",
"@ethersproject/abi": "^5.7.0",
Expand Down
9 changes: 8 additions & 1 deletion contracts/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
# yarn lockfile v1


"@aragon/[email protected]":
version "0.4.0"
resolved "https://registry.yarnpkg.com/@aragon/osx-commons-configs/-/osx-commons-configs-0.4.0.tgz#5b6ae025de1ccf7f9a135bfbcb0aa822c774acf9"
integrity sha512-/2wIQCbv/spMRdOjRXK0RrXG1TK5aMcbD73RvMgMwQwSrKcA1dCntUuSxmTm2W8eEtOzs8E1VPjqZk0cXL4SSQ==
dependencies:
tslib "^2.6.2"

"@aragon/[email protected]":
version "0.0.1-alpha.5"
resolved "https://registry.yarnpkg.com/@aragon/osx-commons-sdk/-/osx-commons-sdk-0.0.1-alpha.5.tgz#9808e7c6a441af6459f96016abe07812706d97bf"
Expand Down Expand Up @@ -5230,7 +5237,7 @@ tslib@^1.11.1, tslib@^1.9.3:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==

tslib@^2.3.1, tslib@^2.5.0:
tslib@^2.3.1, tslib@^2.5.0, tslib@^2.6.2:
version "2.6.2"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae"
integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==
Expand Down
2 changes: 1 addition & 1 deletion sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"typescript": "5.2.2"
},
"dependencies": {
"@aragon/osx-commons-configs": "^0.2.0",
"@aragon/osx-commons-configs": "^0.4.0",
"@aragon/osx-ethers": "^1.3.0-rc0.4",
"@aragon/osx-ethers-v1.0.0": "npm:@aragon/[email protected]",
"@aragon/sdk-ipfs": "^1.1.0",
Expand Down
8 changes: 4 additions & 4 deletions sdk/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"@jridgewell/gen-mapping" "^0.3.0"
"@jridgewell/trace-mapping" "^0.3.9"

"@aragon/osx-commons-configs@^0.2.0":
version "0.2.0"
resolved "https://registry.yarnpkg.com/@aragon/osx-commons-configs/-/osx-commons-configs-0.2.0.tgz#32f83596f4a2e9e48aef61cf560c1c5b4d32a049"
integrity sha512-wCFtgmuGCzs8L5mCxVCYQ6uEu69IrofS7q2w7E1Fjk7/nWuSmRUpgmif3ki9BQq1qpOvDu2P+u3UNLnIz8J82g==
"@aragon/osx-commons-configs@^0.4.0":
version "0.4.0"
resolved "https://registry.yarnpkg.com/@aragon/osx-commons-configs/-/osx-commons-configs-0.4.0.tgz#5b6ae025de1ccf7f9a135bfbcb0aa822c774acf9"
integrity sha512-/2wIQCbv/spMRdOjRXK0RrXG1TK5aMcbD73RvMgMwQwSrKcA1dCntUuSxmTm2W8eEtOzs8E1VPjqZk0cXL4SSQ==
dependencies:
tslib "^2.6.2"

Expand Down

0 comments on commit 96b2eda

Please sign in to comment.