Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2733 from 0xProject/feat/sol-compiler/0.7.x-pr-2710
Browse files Browse the repository at this point in the history
sol-compiler: support 0.7x (#2710)
  • Loading branch information
dorothy-zbornak committed Oct 19, 2020
2 parents 3aaa0ad + a0cd727 commit 1cad43b
Show file tree
Hide file tree
Showing 40 changed files with 113 additions and 34 deletions.
2 changes: 1 addition & 1 deletion contracts/asset-proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"@0x/tslint-config": "^4.1.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"@types/node": "12.12.54",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion contracts/broker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"@0x/web3-wrapper": "^7.2.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"@types/node": "12.12.54",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion contracts/coordinator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"@0x/web3-wrapper": "^7.2.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"@types/node": "12.12.54",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion contracts/dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@0x/tslint-config": "^4.1.0",
"@0x/types": "^3.2.0",
"@0x/utils": "^5.5.1",
"@types/node": "*",
"@types/node": "12.12.54",
"ethereum-types": "^3.2.0",
"ethers": "~4.0.4",
"npm-run-all": "^4.1.2",
Expand Down
2 changes: 1 addition & 1 deletion contracts/erc1155/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"@0x/typescript-typings": "^5.1.1",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"@types/node": "12.12.54",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion contracts/erc20/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@0x/web3-wrapper": "^7.2.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"@types/node": "12.12.54",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion contracts/erc721/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"@0x/web3-wrapper": "^7.2.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"@types/node": "12.12.54",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion contracts/exchange-forwarder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"@0x/web3-wrapper": "^7.2.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"@types/node": "12.12.54",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion contracts/exchange-libs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"@0x/web3-wrapper": "^7.2.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"@types/node": "12.12.54",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion contracts/exchange/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"@0x/web3-wrapper": "^7.2.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"@types/node": "12.12.54",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion contracts/extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"@0x/web3-wrapper": "^7.2.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"@types/node": "12.12.54",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion contracts/integrations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"@azure/core-asynciterator-polyfill": "^1.0.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"@types/node": "12.12.54",
"@types/seedrandom": "^2.4.28",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
Expand Down
2 changes: 1 addition & 1 deletion contracts/multisig/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"@0x/web3-wrapper": "^7.2.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"@types/node": "12.12.54",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion contracts/staking/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@0x/types": "^3.2.0",
"@0x/web3-wrapper": "^7.2.0",
"@types/lodash": "4.14.104",
"@types/node": "*",
"@types/node": "12.12.54",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion contracts/test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"@types/js-combinatorics": "^0.5.29",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"@types/node": "12.12.54",
"bn.js": "^4.11.8",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
Expand Down
2 changes: 1 addition & 1 deletion contracts/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"@types/bn.js": "^4.11.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"@types/node": "12.12.54",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/0x.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"@0x/tslint-config": "^4.1.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"@types/sinon": "^2.2.2",
"awesome-typescript-loader": "^5.2.1",
"chai": "^4.0.1",
Expand Down Expand Up @@ -88,6 +87,7 @@
"@0x/typescript-typings": "^5.1.1",
"@0x/utils": "^5.5.1",
"@0x/web3-wrapper": "^7.2.0",
"@types/node": "12.12.54",
"@types/web3-provider-engine": "^14.0.0",
"ethereum-types": "^3.2.0",
"ethers": "~4.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/abi-gen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"@types/glob": "5.0.35",
"@types/mkdirp": "^0.5.2",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"@types/node": "12.12.54",
"@types/tmp": "^0.0.33",
"@types/yargs": "^11.0.0",
"chai": "^4.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/asset-swapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"@0x/types": "^3.2.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"@types/node": "12.12.54",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts-gen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"devDependencies": {
"@0x/tslint-config": "^4.1.0",
"@types/mkdirp": "^0.5.2",
"@types/node": "*",
"@types/node": "12.12.54",
"@types/prettier": "^1.15.2",
"shx": "^0.2.2",
"tslint": "5.11.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/ethereum-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"typescript": "3.0.1"
},
"dependencies": {
"@types/node": "*",
"@types/node": "12.12.54",
"bignumber.js": "~9.0.0"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/instant/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"@types/enzyme-adapter-react-16": "^1.0.3",
"@types/jest": "^23.3.5",
"@types/lodash": "4.14.104",
"@types/node": "*",
"@types/node": "12.12.54",
"@types/react": "16.4.16",
"@types/react-dom": "16.0.6",
"@types/react-redux": "^6.0.9",
Expand Down
2 changes: 1 addition & 1 deletion packages/json-schemas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"homepage": "https://github.com/0xProject/0x-monorepo/packages/json-schemas/README.md",
"dependencies": {
"@0x/typescript-typings": "^5.1.1",
"@types/node": "*",
"@types/node": "12.12.54",
"jsonschema": "^1.2.0",
"lodash.values": "^4.3.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/monorepo-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"devDependencies": {
"@types/glob": "5.0.35",
"@types/mkdirp": "^0.5.2",
"@types/node": "*",
"@types/node": "12.12.54",
"@types/rimraf": "^2.0.2",
"@types/semver": "5.5.0",
"@types/yargs": "^11.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/order-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@types/bn.js": "^4.11.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"@types/node": "12.12.54",
"@types/web3-provider-engine": "^14.0.0",
"chai": "^4.0.1",
"ethereum-types": "^3.2.0",
Expand Down
9 changes: 9 additions & 0 deletions packages/sol-compiler/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
[
{
"version": "4.2.0",
"changes": [
{
"note": "Add solidity 0.7.x suppoert",
"pr": 2710
}
]
},
{
"timestamp": 1594788383,
"version": "4.1.1",
Expand Down
4 changes: 4 additions & 0 deletions packages/sol-compiler/src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { ContractContentsByPath, ImportPrefixRemappings, SolcWrapper } from './s
import { SolcWrapperV04 } from './solc_wrapper_v04';
import { SolcWrapperV05 } from './solc_wrapper_v05';
import { SolcWrapperV06 } from './solc_wrapper_v06';
import { SolcWrapperV07 } from './solc_wrapper_v07';

export type TYPE_ALL_FILES_IDENTIFIER = '*';
export const ALL_CONTRACTS_IDENTIFIER = '*';
Expand Down Expand Up @@ -366,6 +367,9 @@ export class Compiler {
if (solcVersion.startsWith('0.6')) {
return new SolcWrapperV06(solcVersion, this._opts);
}
if (solcVersion.startsWith('0.7')) {
return new SolcWrapperV07(solcVersion, this._opts);
}
throw new Error(`Missing Solc wrapper implementation for version ${solcVersion}`);
}

Expand Down
3 changes: 3 additions & 0 deletions packages/sol-compiler/src/solc_wrapper_v07.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { SolcWrapperV06 } from './solc_wrapper_v06';

export const SolcWrapperV07 = SolcWrapperV06;
2 changes: 1 addition & 1 deletion packages/sol-compiler/src/utils/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export async function compileDockerAsync(
'solc', '--standard-json',
];
return new Promise<solc.StandardOutput>((accept, reject) => {
const p = spawn('docker', dockerArgs, { shell: true, stdio: ['pipe', 'inherit', 'inherit'] });
const p = spawn('docker', dockerArgs, { shell: true, stdio: ['pipe', 'pipe', 'inherit'] });
p.stdin.write(standardInputStr);
p.stdin.end();
let fullOutput = '';
Expand Down
24 changes: 24 additions & 0 deletions packages/sol-compiler/test/compiler_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { fsWrapper } from '../src/utils/fs_wrapper';

import { exchange_binary } from './fixtures/exchange_bin';
import { v6_contract_binary } from './fixtures/v6_contract_bin';
import { v7_contract_binary } from './fixtures/v7_contract_bin';
import { chaiSetup } from './util/chai_setup';
import { constants } from './util/constants';

Expand Down Expand Up @@ -138,4 +139,27 @@ describe('#Compiler', function(): void {
const expectedBinaryWithoutMetadata = hexUtils.slice(v6_contract_binary, 0, -METADATA_SIZE);
expect(actualBinaryWithoutMetadata).to.eq(expectedBinaryWithoutMetadata);
});
it('should compile a V0.7 contract', async () => {
compilerOpts.contracts = ['V7Contract'];

const artifactPath = `${artifactsDir}/V7Contract.json`;
if (fsWrapper.doesPathExistSync(artifactPath)) {
await fsWrapper.removeFileAsync(artifactPath);
}

await new Compiler(compilerOpts).compileAsync();

const opts = {
encoding: 'utf8',
};
const exchangeArtifactString = await fsWrapper.readFileAsync(artifactPath, opts);
const exchangeArtifact: ContractArtifact = JSON.parse(exchangeArtifactString);
const actualBinaryWithoutMetadata = hexUtils.slice(
exchangeArtifact.compilerOutput.evm.bytecode.object,
0,
-METADATA_SIZE,
);
const expectedBinaryWithoutMetadata = hexUtils.slice(v7_contract_binary, 0, -METADATA_SIZE);
expect(actualBinaryWithoutMetadata).to.eq(expectedBinaryWithoutMetadata);
});
});
37 changes: 37 additions & 0 deletions packages/sol-compiler/test/fixtures/contracts/V7Contract.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

pragma solidity 0.7.0;


contract V7Contract {

uint256 private _privateNumber;

constructor(uint256 privateNumber) public {
_privateNumber = privateNumber;
}

fallback() external {
revert('nope');
}

receive() payable external {
// no-op
}
}
2 changes: 2 additions & 0 deletions packages/sol-compiler/test/fixtures/v7_contract_bin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const v7_contract_binary =
'0x6080604052348015600f57600080fd5b5060405161011238038061011283398181016040526020811015603157600080fd5b8101908080519060200190929190505050806000819055505060ba806100586000396000f3fe608060405236600a57005b348015601557600080fd5b506040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260048152602001807f6e6f70650000000000000000000000000000000000000000000000000000000081525060200191505060405180910390fdfea2646970667358221220d498aaab2683da1af2092969c6d8a0c3d992a9a9a0a5d19b54b5e704ab8fd5e364736f6c63430007000033';
2 changes: 1 addition & 1 deletion packages/sol-coverage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"devDependencies": {
"@0x/ts-doc-gen": "^0.0.22",
"@0x/tslint-config": "^4.1.0",
"@types/node": "*",
"@types/node": "12.12.54",
"@types/web3-provider-engine": "^14.0.0",
"npm-run-all": "^4.1.2",
"nyc": "^11.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/sol-profiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"devDependencies": {
"@0x/ts-doc-gen": "^0.0.22",
"@0x/tslint-config": "^4.1.0",
"@types/node": "*",
"@types/node": "12.12.54",
"@types/web3-provider-engine": "^14.0.0",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/sol-trace/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@0x/ts-doc-gen": "^0.0.22",
"@0x/tslint-config": "^4.1.0",
"@types/loglevel": "^1.5.3",
"@types/node": "*",
"@types/node": "12.12.54",
"@types/web3-provider-engine": "^14.0.0",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/sol-tracing-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"@types/loglevel": "^1.5.3",
"@types/mkdirp": "^0.5.2",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"@types/node": "12.12.54",
"@types/rimraf": "^2.0.2",
"chai": "^4.0.1",
"copyfiles": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/sra-spec/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"devDependencies": {
"@0x/tslint-config": "^4.1.0",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"@types/node": "12.12.54",
"chai": "^4.0.1",
"chokidar-cli": "^1.2.0",
"copyfiles": "^2.0.0",
Expand Down

0 comments on commit 1cad43b

Please sign in to comment.