From 39fd8be27bdb3e39b082fa23d49f195a49964543 Mon Sep 17 00:00:00 2001 From: cgewecke Date: Wed, 28 Apr 2021 08:30:06 -0700 Subject: [PATCH 1/3] Configure hardhat, add patch scripts, eth-optimism and hardhat-sizer plugin deps --- .gitignore | 2 ++ hardhat.config.ts | 32 +++++++++++++++++++++++++------- package.json | 13 +++++++++++-- scripts/build.sh | 8 ++++++++ scripts/clean.sh | 12 ++++++++++++ scripts/patch-ovm-compiler.js | 24 ++++++++++++++++++++++++ yarn.lock | 32 +++++++++++++++++++++++++++++++- 7 files changed, 113 insertions(+), 10 deletions(-) create mode 100755 scripts/build.sh create mode 100755 scripts/clean.sh create mode 100644 scripts/patch-ovm-compiler.js diff --git a/.gitignore b/.gitignore index 8b7480d4b..0f18f03b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ .DS_Store /artifacts +/artifacts-ovm /build /cache +/cache-ovm /dist /etherscan /flatten diff --git a/hardhat.config.ts b/hardhat.config.ts index 76ffb9077..f6d673784 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -7,18 +7,26 @@ import "@nomiclabs/hardhat-waffle"; import "hardhat-typechain"; import "solidity-coverage"; import "hardhat-deploy"; +import "hardhat-contract-sizer"; +import "@eth-optimism/plugins/hardhat/compiler"; import "./tasks"; +const defaultMnemonic = "test test test test test test test test test test test junk"; +const OVM = process.env.OVM === "true"; + const config: HardhatUserConfig = { solidity: { version: "0.6.12", settings: { - optimizer: { enabled: true, runs: 200 }, + optimizer: { enabled: true, runs: 1 }, }, }, namedAccounts: { deployer: 0, }, + ovm: { + solcVersion: "0.6.12" + }, networks: { hardhat: { hardfork: "istanbul", @@ -45,19 +53,29 @@ const config: HardhatUserConfig = { // @ts-ignore accounts: [`0x${process.env.PRODUCTION_MAINNET_DEPLOY_PRIVATE_KEY}`], }, - // To update coverage network configuration got o .solcover.js and update param in providerOptions field - coverage: { - url: "http://127.0.0.1:8555", // Coverage launches its own ganache-cli client - timeout: 100000, - }, + optimism: { + url: 'http://127.0.0.1:8545', + accounts: { mnemonic: defaultMnemonic }, + // L2 test account balances not automatically initiated with an ETH balance + gasPrice: 0, + gas: 8000000, + blockGasLimit: 8000000, + // @ts-ignore + ovm: true, + } }, typechain: { outDir: "typechain", target: "ethers-v5", }, mocha: { - timeout: 100000, + grep: "@ovm", + }, + paths: { + artifacts: OVM ? "./artifacts-ovm" : "./artifacts", + cache: OVM ? "./cache-ovm" : "./cache", }, + }; function getHardhatPrivateKeys() { diff --git a/package.json b/package.json index 7cfa5bad0..53a7f1cf0 100644 --- a/package.json +++ b/package.json @@ -15,10 +15,12 @@ "tsconfig.json" ], "scripts": { - "build": "yarn compile && yarn patch-hardhat-typechain && yarn typechain && yarn fix-typechain && yarn transpile-dist", + "build": "./scripts/build.sh", + "build:ovm": "./scripts/build_ovm.sh", "chain": "npx hardhat node --no-deploy", - "clean": "rm -f coverage.json; rm -rf .coverage_cache; rm -rf .coverage_contracts; rm -rf cache; rm -rf coverage; rm -rf typechain; rm -rf artifacts", + "clean": "./scripts/clean.sh", "compile": "npx hardhat compile", + "compile:ovm": "OVM=true hardhat compile --network optimism --force", "coverage": "yarn clean && yarn build && yarn cov:command", "cov:command": "COVERAGE=true node --max-old-space-size=4096 ./node_modules/.bin/hardhat coverage", "etherscan:verify": "hardhat --network kovan etherscan-verify --solc-input --license 'None'", @@ -28,11 +30,16 @@ "lint-sol": "solhint 'contracts/**/*.sol'", "lint-ts": "tslint -c tslint.json -p tsconfig.json --fix", "patch-hardhat-typechain": "node scripts/patch-hardhat-typechain.js", + "patch-ovm-compiler": "node scripts/patch-ovm-compiler.js", "precommit": "lint-staged", "prepare": "yarn build", "prepack": "if [[ \"$(basename \"$PWD\")\" == \"set-protocol-v2-contracts\" ]]; then echo \"CANNOT PUBLISH FROM THIS REPO\"; exit 1; fi;", "rename-extensions": "for f in typechain/*.d.ts; do mv -- \"$f\" \"${f%.d.ts}.ts\"; done", + "size": "hardhat size-contracts", + "size:ovm": "OVM=true hardhat size-contracts", "test": "npx hardhat test --network localhost", + "test:ovm": "OVM=true npx hardhat test --network optimism", + "test:ovm:fast": "TS_NODE_TRANSPILE_ONLY=1 OVM=true npx hardhat test --network optimism --no-compile", "test:clean": "yarn clean && yarn build && yarn test", "transpile": "tsc", "transpile-dist": "tsc -p tsconfig.dist.json", @@ -46,6 +53,7 @@ "license": "MIT", "homepage": "https://github.com/SetProtocol", "devDependencies": { + "@eth-optimism/plugins": "1.0.0-alpha.3", "@ethersproject/bignumber": "^5.0.12", "@ethersproject/providers": "^5.0.17", "@nomiclabs/hardhat-ethers": "^2.0.1", @@ -66,6 +74,7 @@ "ethereum-waffle": "^3.2.1", "ethers": "^5.0.24", "hardhat": "^2.0.6", + "hardhat-contract-sizer": "^2.0.3", "hardhat-deploy": "^0.7.0-beta.39", "hardhat-typechain": "^0.3.4", "husky": "^4.2.5", diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 000000000..ac0e7b8bf --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +yarn compile +yarn patch-hardhat-typechain +yarn patch-ovm-compiler +yarn typechain +yarn fix-typechain +yarn transpile-dist diff --git a/scripts/clean.sh b/scripts/clean.sh new file mode 100755 index 000000000..4c1400d25 --- /dev/null +++ b/scripts/clean.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +rm -rf \ + artifacts \ + artifacts-ovm \ + cache \ + cache-ovm \ + .coverage_cache \ + .coverage_contracts \ + coverage \ + coverage.json \ + typechain \ diff --git a/scripts/patch-ovm-compiler.js b/scripts/patch-ovm-compiler.js new file mode 100644 index 000000000..2d5e52340 --- /dev/null +++ b/scripts/patch-ovm-compiler.js @@ -0,0 +1,24 @@ +const replace = require('replace-in-file'); + +let changedFiles; + +// Step 1: Fix a bug in optimism plugin where empty compilation jobs trigger +// "No input sources specified" error. +const options1 = { + //Glob(s) + files: [ + './node_modules/@eth-optimism/plugins/hardhat/compiler/index.js', + ], + + //Replacement to make (string or regex) + from: /\/\/ Build both inputs separately\./g, + to: 'if (Object.keys(ovmInput.sources).length === 0) return {};', +}; + +try { + changedFiles = replace.sync(options1); + console.log('Patching eth-optimism hardhat plugin compiler file.'); +} +catch (error) { + console.error('Error occurred:', error); +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index ee3df317e..d8c28bc9d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -39,6 +39,13 @@ resolved "https://registry.yarnpkg.com/@ensdomains/resolver/-/resolver-0.2.4.tgz#c10fe28bf5efbf49bff4666d909aed0265efbc89" integrity sha512-bvaTH34PMCbv6anRa9I/0zjLJgY4EuznbEMgbV77JBCQ9KNC46rzi0avuxpOfu+xDjPEtSFGqVEOr5GlUSGudA== +"@eth-optimism/plugins@^1.0.0-alpha.3": + version "1.0.0-alpha.3" + resolved "https://registry.yarnpkg.com/@eth-optimism/plugins/-/plugins-1.0.0-alpha.3.tgz#acda356e1422ed919a21770c3bb03a5576be2e72" + integrity sha512-PWogmjeV3ofH8yx7DV4ZcY6QiRFeWwrLFp0HLlgo5g7k3y/TL/oMjDTDrjuQ0DWQC7iaIQErML70KmBT/mdfLw== + dependencies: + node-fetch "^2.6.1" + "@ethereum-waffle/chai@^3.2.1": version "3.2.1" resolved "https://registry.yarnpkg.com/@ethereum-waffle/chai/-/chai-3.2.1.tgz#5cb542b2a323adf0bc2dda00f48b0eb85944d8ab" @@ -2256,6 +2263,16 @@ cli-cursor@^3.1.0: dependencies: restore-cursor "^3.1.0" +cli-table3@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/cli-table3/-/cli-table3-0.6.0.tgz#b7b1bc65ca8e7b5cef9124e13dc2b21e2ce4faee" + integrity sha512-gnB85c3MGC7Nm9I/FkiasNBOKjOiO1RNuXXarQms37q4QMpWdlbBgD/VnOStA2faG1dpXMv31RFApjX1/QdgWQ== + dependencies: + object-assign "^4.1.0" + string-width "^4.2.0" + optionalDependencies: + colors "^1.1.2" + cli-truncate@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/cli-truncate/-/cli-truncate-2.1.0.tgz#c39e28bf05edcde5be3b98992a22deed5a2b93c7" @@ -2345,6 +2362,11 @@ color-name@~1.1.4: resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== +colors@^1.1.2, colors@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78" + integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA== + combined-stream@^1.0.6, combined-stream@^1.0.8, combined-stream@~1.0.6: version "1.0.8" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" @@ -4431,6 +4453,14 @@ har-validator@~5.1.3: ajv "^6.12.3" har-schema "^2.0.0" +hardhat-contract-sizer@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/hardhat-contract-sizer/-/hardhat-contract-sizer-2.0.3.tgz#604455fd803865f81c29f60364e863eaa19395a7" + integrity sha512-iaixOzWxwOSIIE76cl2uk4m9VXI1hKU3bFt+gl7jDhyb2/JB2xOp5wECkfWqAoc4V5lD4JtjldZlpSTbzX+nPQ== + dependencies: + cli-table3 "^0.6.0" + colors "^1.4.0" + hardhat-deploy@^0.7.0-beta.39: version "0.7.0-beta.39" resolved "https://registry.yarnpkg.com/hardhat-deploy/-/hardhat-deploy-0.7.0-beta.39.tgz#3aeab46164b0cefc990dedbeb611236080fdd122" @@ -6243,7 +6273,7 @@ node-fetch@2.1.2: resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.1.2.tgz#ab884e8e7e57e38a944753cec706f788d1768bb5" integrity sha1-q4hOjn5X44qUR1POxwb3iNF2i7U= -node-fetch@^2.6.0: +node-fetch@^2.6.0, node-fetch@^2.6.1: version "2.6.1" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== From fec8aaf2c91353d2bdd1721980372835eb7e1688 Mon Sep 17 00:00:00 2001 From: cgewecke Date: Wed, 28 Apr 2021 09:44:14 -0700 Subject: [PATCH 2/3] Select initial contract set for ovm compilation / add ovm friendly OZ contracts --- contracts/interfaces/IBasicIssuanceModule.sol | 2 - contracts/interfaces/IController.sol | 2 - contracts/interfaces/IExchangeAdapter.sol | 2 - .../interfaces/IIndexExchangeAdapter.sol | 2 - contracts/interfaces/IIntegrationRegistry.sol | 2 - contracts/interfaces/IManagerIssuanceHook.sol | 2 - contracts/interfaces/IModule.sol | 2 - contracts/interfaces/IModuleIssuanceHook.sol | 2 - contracts/interfaces/IOracle.sol | 2 - contracts/interfaces/IOracleAdapter.sol | 2 - contracts/interfaces/IPriceOracle.sol | 2 - contracts/interfaces/ISetToken.sol | 2 - contracts/interfaces/ISetValuer.sol | 2 - contracts/interfaces/IStreamingFeeModule.sol | 2 - contracts/interfaces/external/ICErc20.sol | 2 - contracts/interfaces/external/ISynth.sol | 2 - .../external/ISynthetixExchanger.sol | 2 - .../interfaces/external/IUniswapV2Pair.sol | 2 - .../interfaces/external/IUniswapV2Router.sol | 2 - contracts/interfaces/external/IWETH.sol | 2 - contracts/lib/AddressArrayUtils.sol | 2 - contracts/lib/ExplicitERC20.sol | 4 +- contracts/lib/PreciseUnitMath.sol | 2 - contracts/lib/Uint256ArrayUtils.sol | 2 - contracts/mocks/OracleMock.sol | 2 - contracts/mocks/StandardTokenMock.sol | 2 - contracts/protocol/Controller.sol | 2 - contracts/protocol/IntegrationRegistry.sol | 2 - contracts/protocol/PriceOracle.sol | 2 - contracts/protocol/SetToken.sol | 4 +- contracts/protocol/SetTokenCreator.sol | 2 - contracts/protocol/SetValuer.sol | 2 - .../exchange/SynthetixExchangeAdapter.sol | 2 - .../exchange/UniswapV2ExchangeAdapterV2.sol | 2 - contracts/protocol/lib/Invoke.sol | 2 - contracts/protocol/lib/ModuleBase.sol | 2 - contracts/protocol/lib/Position.sol | 2 - contracts/protocol/lib/ResourceIdentifier.sol | 2 - .../protocol/modules/BasicIssuanceModule.sol | 2 - .../protocol/modules/StreamingFeeModule.sol | 2 - contracts/protocol/modules/TradeModule.sol | 2 - .../openzeppelin/token/ERC20/SafeERC20.sol | 84 ++++++++ .../contracts/openzeppelin/utils/Address.sol | 186 ++++++++++++++++++ 43 files changed, 272 insertions(+), 84 deletions(-) create mode 100644 external/contracts/openzeppelin/token/ERC20/SafeERC20.sol create mode 100644 external/contracts/openzeppelin/utils/Address.sol diff --git a/contracts/interfaces/IBasicIssuanceModule.sol b/contracts/interfaces/IBasicIssuanceModule.sol index ee1f5ba63..5e6912930 100644 --- a/contracts/interfaces/IBasicIssuanceModule.sol +++ b/contracts/interfaces/IBasicIssuanceModule.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/interfaces/IController.sol b/contracts/interfaces/IController.sol index a9ec1866f..a707fae1f 100644 --- a/contracts/interfaces/IController.sol +++ b/contracts/interfaces/IController.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/interfaces/IExchangeAdapter.sol b/contracts/interfaces/IExchangeAdapter.sol index ea7861796..25dd473bd 100644 --- a/contracts/interfaces/IExchangeAdapter.sol +++ b/contracts/interfaces/IExchangeAdapter.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/interfaces/IIndexExchangeAdapter.sol b/contracts/interfaces/IIndexExchangeAdapter.sol index 952d12854..066884b97 100644 --- a/contracts/interfaces/IIndexExchangeAdapter.sol +++ b/contracts/interfaces/IIndexExchangeAdapter.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/interfaces/IIntegrationRegistry.sol b/contracts/interfaces/IIntegrationRegistry.sol index f68462d9e..ef9876a29 100644 --- a/contracts/interfaces/IIntegrationRegistry.sol +++ b/contracts/interfaces/IIntegrationRegistry.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/interfaces/IManagerIssuanceHook.sol b/contracts/interfaces/IManagerIssuanceHook.sol index 74f51c1d6..aa0ef8f8b 100644 --- a/contracts/interfaces/IManagerIssuanceHook.sol +++ b/contracts/interfaces/IManagerIssuanceHook.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/interfaces/IModule.sol b/contracts/interfaces/IModule.sol index 825b9cf9e..4cfe883a1 100644 --- a/contracts/interfaces/IModule.sol +++ b/contracts/interfaces/IModule.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/interfaces/IModuleIssuanceHook.sol b/contracts/interfaces/IModuleIssuanceHook.sol index 9267d4b1b..e38f8ffe6 100644 --- a/contracts/interfaces/IModuleIssuanceHook.sol +++ b/contracts/interfaces/IModuleIssuanceHook.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/interfaces/IOracle.sol b/contracts/interfaces/IOracle.sol index 3a25758e1..01a84af5e 100644 --- a/contracts/interfaces/IOracle.sol +++ b/contracts/interfaces/IOracle.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/interfaces/IOracleAdapter.sol b/contracts/interfaces/IOracleAdapter.sol index 860e49844..6ea394264 100644 --- a/contracts/interfaces/IOracleAdapter.sol +++ b/contracts/interfaces/IOracleAdapter.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/interfaces/IPriceOracle.sol b/contracts/interfaces/IPriceOracle.sol index 0cd2212a9..1ffe66e60 100644 --- a/contracts/interfaces/IPriceOracle.sol +++ b/contracts/interfaces/IPriceOracle.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/interfaces/ISetToken.sol b/contracts/interfaces/ISetToken.sol index 3ad89bf88..1e2ae1977 100644 --- a/contracts/interfaces/ISetToken.sol +++ b/contracts/interfaces/ISetToken.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; pragma experimental "ABIEncoderV2"; diff --git a/contracts/interfaces/ISetValuer.sol b/contracts/interfaces/ISetValuer.sol index 5f97a5d65..29351c380 100644 --- a/contracts/interfaces/ISetValuer.sol +++ b/contracts/interfaces/ISetValuer.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/interfaces/IStreamingFeeModule.sol b/contracts/interfaces/IStreamingFeeModule.sol index 6af0b5336..dc122b744 100644 --- a/contracts/interfaces/IStreamingFeeModule.sol +++ b/contracts/interfaces/IStreamingFeeModule.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; pragma experimental "ABIEncoderV2"; diff --git a/contracts/interfaces/external/ICErc20.sol b/contracts/interfaces/external/ICErc20.sol index 8c0640495..9c5f41a66 100644 --- a/contracts/interfaces/external/ICErc20.sol +++ b/contracts/interfaces/external/ICErc20.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/interfaces/external/ISynth.sol b/contracts/interfaces/external/ISynth.sol index 8f22c0843..0cc1f1b3c 100644 --- a/contracts/interfaces/external/ISynth.sol +++ b/contracts/interfaces/external/ISynth.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/interfaces/external/ISynthetixExchanger.sol b/contracts/interfaces/external/ISynthetixExchanger.sol index 09e4be9b1..53928de9b 100644 --- a/contracts/interfaces/external/ISynthetixExchanger.sol +++ b/contracts/interfaces/external/ISynthetixExchanger.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/interfaces/external/IUniswapV2Pair.sol b/contracts/interfaces/external/IUniswapV2Pair.sol index d7704d15b..188779427 100644 --- a/contracts/interfaces/external/IUniswapV2Pair.sol +++ b/contracts/interfaces/external/IUniswapV2Pair.sol @@ -10,8 +10,6 @@ See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/interfaces/external/IUniswapV2Router.sol b/contracts/interfaces/external/IUniswapV2Router.sol index c59ab282c..b87a6e95b 100644 --- a/contracts/interfaces/external/IUniswapV2Router.sol +++ b/contracts/interfaces/external/IUniswapV2Router.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/interfaces/external/IWETH.sol b/contracts/interfaces/external/IWETH.sol index a10453200..d325d01a7 100644 --- a/contracts/interfaces/external/IWETH.sol +++ b/contracts/interfaces/external/IWETH.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/lib/AddressArrayUtils.sol b/contracts/lib/AddressArrayUtils.sol index 0b6ea24a0..99e28012b 100644 --- a/contracts/lib/AddressArrayUtils.sol +++ b/contracts/lib/AddressArrayUtils.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/lib/ExplicitERC20.sol b/contracts/lib/ExplicitERC20.sol index 9e3ad6366..e40c75d83 100644 --- a/contracts/lib/ExplicitERC20.sol +++ b/contracts/lib/ExplicitERC20.sol @@ -14,14 +14,12 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; +import { SafeERC20 } from "../../external/contracts/openzeppelin/token/ERC20/SafeERC20.sol"; import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol"; /** diff --git a/contracts/lib/PreciseUnitMath.sol b/contracts/lib/PreciseUnitMath.sol index 1609991c4..32f9b1d0c 100644 --- a/contracts/lib/PreciseUnitMath.sol +++ b/contracts/lib/PreciseUnitMath.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/lib/Uint256ArrayUtils.sol b/contracts/lib/Uint256ArrayUtils.sol index 2bcfcf437..10eb85778 100644 --- a/contracts/lib/Uint256ArrayUtils.sol +++ b/contracts/lib/Uint256ArrayUtils.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/mocks/OracleMock.sol b/contracts/mocks/OracleMock.sol index fbebe71fd..2f8a2aaa1 100644 --- a/contracts/mocks/OracleMock.sol +++ b/contracts/mocks/OracleMock.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/mocks/StandardTokenMock.sol b/contracts/mocks/StandardTokenMock.sol index 36a1e4c2e..ca0337e5d 100644 --- a/contracts/mocks/StandardTokenMock.sol +++ b/contracts/mocks/StandardTokenMock.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/protocol/Controller.sol b/contracts/protocol/Controller.sol index c3863b656..69def47ba 100644 --- a/contracts/protocol/Controller.sol +++ b/contracts/protocol/Controller.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/protocol/IntegrationRegistry.sol b/contracts/protocol/IntegrationRegistry.sol index 128854587..c6ad62d88 100644 --- a/contracts/protocol/IntegrationRegistry.sol +++ b/contracts/protocol/IntegrationRegistry.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/protocol/PriceOracle.sol b/contracts/protocol/PriceOracle.sol index 81a135ddd..25e31ce72 100644 --- a/contracts/protocol/PriceOracle.sol +++ b/contracts/protocol/PriceOracle.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/protocol/SetToken.sol b/contracts/protocol/SetToken.sol index 0d1f73021..c680531ec 100644 --- a/contracts/protocol/SetToken.sol +++ b/contracts/protocol/SetToken.sol @@ -14,14 +14,12 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; pragma experimental "ABIEncoderV2"; -import { Address } from "@openzeppelin/contracts/utils/Address.sol"; +import { Address } from "../../external/contracts/openzeppelin/utils/Address.sol"; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import { SafeCast } from "@openzeppelin/contracts/utils/SafeCast.sol"; import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol"; diff --git a/contracts/protocol/SetTokenCreator.sol b/contracts/protocol/SetTokenCreator.sol index 1a14cfc42..5443cf188 100644 --- a/contracts/protocol/SetTokenCreator.sol +++ b/contracts/protocol/SetTokenCreator.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/protocol/SetValuer.sol b/contracts/protocol/SetValuer.sol index 70eac3f91..c1f96598c 100644 --- a/contracts/protocol/SetValuer.sol +++ b/contracts/protocol/SetValuer.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/protocol/integration/exchange/SynthetixExchangeAdapter.sol b/contracts/protocol/integration/exchange/SynthetixExchangeAdapter.sol index 36ad9bd01..aabd2ca5c 100644 --- a/contracts/protocol/integration/exchange/SynthetixExchangeAdapter.sol +++ b/contracts/protocol/integration/exchange/SynthetixExchangeAdapter.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/protocol/integration/exchange/UniswapV2ExchangeAdapterV2.sol b/contracts/protocol/integration/exchange/UniswapV2ExchangeAdapterV2.sol index d47dbb0cc..056bfbacd 100644 --- a/contracts/protocol/integration/exchange/UniswapV2ExchangeAdapterV2.sol +++ b/contracts/protocol/integration/exchange/UniswapV2ExchangeAdapterV2.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/protocol/lib/Invoke.sol b/contracts/protocol/lib/Invoke.sol index f4c2c01ad..42ab02003 100644 --- a/contracts/protocol/lib/Invoke.sol +++ b/contracts/protocol/lib/Invoke.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/protocol/lib/ModuleBase.sol b/contracts/protocol/lib/ModuleBase.sol index 1333995fd..09cb9c8a7 100644 --- a/contracts/protocol/lib/ModuleBase.sol +++ b/contracts/protocol/lib/ModuleBase.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/protocol/lib/Position.sol b/contracts/protocol/lib/Position.sol index 2819b6002..b73c963f6 100644 --- a/contracts/protocol/lib/Position.sol +++ b/contracts/protocol/lib/Position.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/protocol/lib/ResourceIdentifier.sol b/contracts/protocol/lib/ResourceIdentifier.sol index 1d0cabe96..849d39d80 100644 --- a/contracts/protocol/lib/ResourceIdentifier.sol +++ b/contracts/protocol/lib/ResourceIdentifier.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/protocol/modules/BasicIssuanceModule.sol b/contracts/protocol/modules/BasicIssuanceModule.sol index 4eab149dd..eac9d9e6f 100644 --- a/contracts/protocol/modules/BasicIssuanceModule.sol +++ b/contracts/protocol/modules/BasicIssuanceModule.sol @@ -10,8 +10,6 @@ See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/protocol/modules/StreamingFeeModule.sol b/contracts/protocol/modules/StreamingFeeModule.sol index dd9b93e9b..59313ad2a 100644 --- a/contracts/protocol/modules/StreamingFeeModule.sol +++ b/contracts/protocol/modules/StreamingFeeModule.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/contracts/protocol/modules/TradeModule.sol b/contracts/protocol/modules/TradeModule.sol index 720ccbba2..a5c798f99 100644 --- a/contracts/protocol/modules/TradeModule.sol +++ b/contracts/protocol/modules/TradeModule.sol @@ -14,8 +14,6 @@ limitations under the License. SPDX-License-Identifier: Apache License, Version 2.0 - - // @unsupported: ovm */ pragma solidity 0.6.12; diff --git a/external/contracts/openzeppelin/token/ERC20/SafeERC20.sol b/external/contracts/openzeppelin/token/ERC20/SafeERC20.sol new file mode 100644 index 000000000..f68e6500d --- /dev/null +++ b/external/contracts/openzeppelin/token/ERC20/SafeERC20.sol @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.6.0 <0.8.0; + +// >>>> OPTIMISM +// Copy pasted from OZ v3.3.0 and adapted to use an Optimism patch for oz/utils/Address.sol +// sourced from: https://github.com/derekbar90/optimism-openzeppelin-compat +// blob/66ef793bc49c948dc9430c289f1f9447a3632fa9/patches/@openzeppelin+contracts+3.4.1.patch + +// Optimism does not support the `BALANCE` opcode. Balances are checked +// by querying an address's native WETH balance on the Optimism network + +import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import "@openzeppelin/contracts/math/SafeMath.sol"; +// >>>> OPTIMISM:START_CHANGE +import "../../utils/Address.sol"; +// <<<< OPTIMISM:END_CHANGE + +/** + * @title SafeERC20 + * @dev Wrappers around ERC20 operations that throw on failure (when the token + * contract returns false). Tokens that return no value (and instead revert or + * throw on failure) are also supported, non-reverting calls are assumed to be + * successful. + * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, + * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. + */ +library SafeERC20 { + using SafeMath for uint256; + using Address for address; + + function safeTransfer(IERC20 token, address to, uint256 value) internal { + _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); + } + + function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { + _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); + } + + /** + * @dev Deprecated. This function has issues similar to the ones found in + * {IERC20-approve}, and its usage is discouraged. + * + * Whenever possible, use {safeIncreaseAllowance} and + * {safeDecreaseAllowance} instead. + */ + function safeApprove(IERC20 token, address spender, uint256 value) internal { + // safeApprove should only be called when setting an initial allowance, + // or when resetting it to zero. To increase and decrease it, use + // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' + // solhint-disable-next-line max-line-length + require((value == 0) || (token.allowance(address(this), spender) == 0), + "SafeERC20: approve from non-zero to non-zero allowance" + ); + _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); + } + + function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { + uint256 newAllowance = token.allowance(address(this), spender).add(value); + _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); + } + + function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { + uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); + _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); + } + + /** + * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement + * on the return value: the return value is optional (but if data is returned, it must not be false). + * @param token The token targeted by the call. + * @param data The call data (encoded using abi.encode or one of its variants). + */ + function _callOptionalReturn(IERC20 token, bytes memory data) private { + // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since + // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that + // the target address contains contract code and also asserts for success in the low-level call. + + bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); + if (returndata.length > 0) { // Return data is optional + // solhint-disable-next-line max-line-length + require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); + } + } +} diff --git a/external/contracts/openzeppelin/utils/Address.sol b/external/contracts/openzeppelin/utils/Address.sol new file mode 100644 index 000000000..cfaa15eff --- /dev/null +++ b/external/contracts/openzeppelin/utils/Address.sol @@ -0,0 +1,186 @@ +// >>>> OPTIMISM:START_CHANGE +// Copy pasted from OZ v3.3.0 with an optimism patch sourced from: +// https://github.com/derekbar90/optimism-openzeppelin-compat +// blob/66ef793bc49c948dc9430c289f1f9447a3632fa9/patches/@openzeppelin+contracts+3.4.1.patch + +// Optimsim does not support the `BALANCE` opcode. Balances are checked +// by querying an address's native WETH balance on the Optimism network + +// SPDX-License-Identifier: MIT + +pragma solidity >=0.6.2 <0.8.0; + +import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; + +/** + * @dev Collection of functions related to the address type + */ +library Address { + /** + * @dev Returns true if `account` is a contract. + * + * [IMPORTANT] + * ==== + * It is unsafe to assume that an address for which this function returns + * false is an externally-owned account (EOA) and not a contract. + * + * Among others, `isContract` will return false for the following + * types of addresses: + * + * - an externally-owned account + * - a contract in construction + * - an address where a contract will be created + * - an address where a contract lived, but was destroyed + * ==== + */ + function isContract(address account) internal view returns (bool) { + // This method relies on extcodesize, which returns 0 for contracts in + // construction, since the code is only stored at the end of the + // constructor execution. + + uint256 size; + // solhint-disable-next-line no-inline-assembly + assembly { size := extcodesize(account) } + return size > 0; + } + + /** + * + * @param {Address} _addressToQuery view public returns (uint) + */ + function WETHBalance(address _addressToQuery) view public returns (uint) { + return IERC20(0x4200000000000000000000000000000000000006).balanceOf(_addressToQuery); + } + + /** + * @dev Replacement for Solidity's `transfer`: sends `amount` wei to + * `recipient`, forwarding all available gas and reverting on errors. + * + * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost + * of certain opcodes, possibly making contracts go over the 2300 gas limit + * imposed by `transfer`, making them unable to receive funds via + * `transfer`. {sendValue} removes this limitation. + * + * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. + * + * IMPORTANT: because control is transferred to `recipient`, care must be + * taken to not create reentrancy vulnerabilities. Consider using + * {ReentrancyGuard} or the + * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. + */ + function sendValue(address payable recipient, uint256 amount) internal { + // >>>> OPTIMISM:START_CHANGE + require(WETHBalance(address(this)) >= amount, "Address: insufficient balance"); + // <<<< OPTIMISM:END_CHANGE + // solhint-disable-next-line avoid-low-level-calls, avoid-call-value + (bool success, ) = recipient.call{ value: amount }(""); + require(success, "Address: unable to send value, recipient may have reverted"); + } + + /** + * @dev Performs a Solidity function call using a low level `call`. A + * plain`call` is an unsafe replacement for a function call: use this + * function instead. + * + * If `target` reverts with a revert reason, it is bubbled up by this + * function (like regular Solidity function calls). + * + * Returns the raw returned data. To convert to the expected return value, + * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. + * + * Requirements: + * + * - `target` must be a contract. + * - calling `target` with `data` must not revert. + * + * _Available since v3.1._ + */ + function functionCall(address target, bytes memory data) internal returns (bytes memory) { + return functionCall(target, data, "Address: low-level call failed"); + } + + /** + * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with + * `errorMessage` as a fallback revert reason when `target` reverts. + * + * _Available since v3.1._ + */ + function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { + return functionCallWithValue(target, data, 0, errorMessage); + } + + /** + * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], + * but also transferring `value` wei to `target`. + * + * Requirements: + * + * - the calling contract must have an ETH balance of at least `value`. + * - the called Solidity function must be `payable`. + * + * _Available since v3.1._ + */ + function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { + return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); + } + + /** + * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but + * with `errorMessage` as a fallback revert reason when `target` reverts. + * + * _Available since v3.1._ + */ + function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { + // >>>> OPTIMISM:START_CHANGE + require(WETHBalance(address(this)) >= value, "Address: insufficient balance for call"); + // <<<< OPTIMISM:END_CHANGE + require(isContract(target), "Address: call to non-contract"); + + // solhint-disable-next-line avoid-low-level-calls + (bool success, bytes memory returndata) = target.call{ value: value }(data); + return _verifyCallResult(success, returndata, errorMessage); + } + + /** + * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], + * but performing a static call. + * + * _Available since v3.3._ + */ + function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { + return functionStaticCall(target, data, "Address: low-level static call failed"); + } + + /** + * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], + * but performing a static call. + * + * _Available since v3.3._ + */ + function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { + require(isContract(target), "Address: static call to non-contract"); + + // solhint-disable-next-line avoid-low-level-calls + (bool success, bytes memory returndata) = target.staticcall(data); + return _verifyCallResult(success, returndata, errorMessage); + } + + function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { + if (success) { + return returndata; + } else { + // Look for revert reason and bubble it up if present + if (returndata.length > 0) { + // The easiest way to bubble the revert reason is using memory via assembly + + // solhint-disable-next-line no-inline-assembly + assembly { + let returndata_size := mload(returndata) + revert(add(32, returndata), returndata_size) + } + } else { + revert(errorMessage); + } + } + } +} From 728fe5681041bf96c1807dcee3695678462f5ea2 Mon Sep 17 00:00:00 2001 From: cgewecke Date: Thu, 29 Apr 2021 10:41:43 -0700 Subject: [PATCH 3/3] Minimize circleci (for now) --- .circleci/config.yml | 89 +++----------------------------------------- scripts/build.sh | 6 ++- 2 files changed, 9 insertions(+), 86 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 580f5e7d0..7381ea925 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -31,106 +31,27 @@ jobs: key: compiled-env-{{ .Environment.CIRCLE_SHA1 }} paths: - ~/set-protocol-v2 - test: + + test_ovm: docker: - image: circleci/node:10.16.0 working_directory: ~/set-protocol-v2 - parallelism: 3 steps: - setup_remote_docker: docker_layer_caching: false - - run: - name: Fetch solc version - command: docker pull ethereum/solc:0.6.10 - restore_cache: key: compiled-env-{{ .Environment.CIRCLE_SHA1 }} - run: name: Set Up Environment Variables command: cp .env.default .env - - run: - name: Test RPC - command: yarn chain - background: true - - run: - name: Hardhat Test - command: | - TEST_FILES="$(circleci tests glob "./test/**/*.spec.ts" | circleci tests split --split-by=timings)" - yarn test ${TEST_FILES} - coverage: - docker: - - image: circleci/node:10.11.0 - working_directory: ~/set-protocol-v2 - # When changing the parallelism value, you also - # need to update the `persist_to_workspace` paths - # in this job (below) as well as the list of files passed - # to istanbul-combine in the `report_coverage` job - parallelism: 5 - steps: - - setup_remote_docker: - docker_layer_caching: false - - run: - name: Fetch solc version - command: docker pull ethereum/solc:0.6.10 - - restore_cache: - key: compiled-env-{{ .Environment.CIRCLE_SHA1 }} - - run: - name: Set Up Environment Variables - command: cp .env.default .env - - run: - name: Create shared coverage outputs folder - command: mkdir -p /tmp/coverage - - run: - name: Coverage - command: | - TEST_FILES="{$(circleci tests glob "./test/**/*.spec.ts" | \ - circleci tests split --split-by=timings | xargs | sed -e 's/ /,/g')}" - yarn coverage -- --testfiles "$TEST_FILES" - - run: - name: Save coverage - command: | - cp coverage.json /tmp/coverage/cov_$CIRCLE_NODE_INDEX.json - chmod -R 777 /tmp/coverage/cov_$CIRCLE_NODE_INDEX.json - - persist_to_workspace: - root: /tmp/coverage - paths: - - cov_0.json - - cov_1.json - - cov_2.json - - cov_3.json - - cov_4.json - - report_coverage: - docker: - - image: circleci/node:10.11.0 - working_directory: ~/set-protocol-v2 - steps: - - attach_workspace: - at: /tmp/coverage - - restore_cache: - key: compiled-env-{{ .Environment.CIRCLE_SHA1 }} - - run: - name: Combine coverage reports - command: | - mkdir -p reports - cp -R /tmp/coverage/* . - npx istanbul-combine-updated -r lcov cov_0.json cov_1.json cov_2.json cov_3.json cov_4.json - - run: - name: Upload coverage - command: | - cat coverage/lcov.info | node_modules/.bin/coveralls + # TODO.... workflows: version: 2 build-and-test: jobs: - checkout_and_compile - - test: - requires: - - checkout_and_compile - - coverage: - requires: - - checkout_and_compile - - report_coverage: + - test_ovm: requires: - - coverage + - checkout_and_compile \ No newline at end of file diff --git a/scripts/build.sh b/scripts/build.sh index ac0e7b8bf..909138ce1 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,8 +1,10 @@ #!/usr/bin/env bash -yarn compile +set -o errexit + yarn patch-hardhat-typechain yarn patch-ovm-compiler -yarn typechain +yarn compile +yarn compile:ovm yarn fix-typechain yarn transpile-dist