Merge pull request #2733 from 0xProject/feat/sol-compiler/0.7.x-pr-2710
sol-compiler: support 0.7x (#2710)
This commit is contained in:
commit
1cad43bf5d
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -41,7 +41,7 @@
|
||||
"typescript": "3.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"@types/node": "12.12.54",
|
||||
"bignumber.js": "~9.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
|
@ -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",
|
||||
|
@ -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"
|
||||
},
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"version": "4.2.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add solidity 0.7.x suppoert",
|
||||
"pr": 2710
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1594788383,
|
||||
"version": "4.1.1",
|
||||
|
@ -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 = '*';
|
||||
@ -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}`);
|
||||
}
|
||||
|
||||
|
3
packages/sol-compiler/src/solc_wrapper_v07.ts
Normal file
3
packages/sol-compiler/src/solc_wrapper_v07.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { SolcWrapperV06 } from './solc_wrapper_v06';
|
||||
|
||||
export const SolcWrapperV07 = SolcWrapperV06;
|
@ -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 = '';
|
||||
|
@ -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';
|
||||
|
||||
@ -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
packages/sol-compiler/test/fixtures/contracts/V7Contract.sol
vendored
Normal file
37
packages/sol-compiler/test/fixtures/contracts/V7Contract.sol
vendored
Normal file
@ -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
packages/sol-compiler/test/fixtures/v7_contract_bin.ts
vendored
Normal file
2
packages/sol-compiler/test/fixtures/v7_contract_bin.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export const v7_contract_binary =
|
||||
'0x6080604052348015600f57600080fd5b5060405161011238038061011283398181016040526020811015603157600080fd5b8101908080519060200190929190505050806000819055505060ba806100586000396000f3fe608060405236600a57005b348015601557600080fd5b506040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260048152602001807f6e6f70650000000000000000000000000000000000000000000000000000000081525060200191505060405180910390fdfea2646970667358221220d498aaab2683da1af2092969c6d8a0c3d992a9a9a0a5d19b54b5e704ab8fd5e364736f6c63430007000033';
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -64,7 +64,7 @@
|
||||
"@types/hdkey": "^0.7.0",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^5.2.7",
|
||||
"@types/node": "*",
|
||||
"@types/node": "12.12.54",
|
||||
"@types/sinon": "^2.2.2",
|
||||
"chai": "^4.0.1",
|
||||
"chai-as-promised": "^7.1.0",
|
||||
|
@ -30,7 +30,7 @@
|
||||
"typescript": "3.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"@types/node": "12.12.54",
|
||||
"bignumber.js": "~9.0.0",
|
||||
"ethereum-types": "^3.2.0"
|
||||
},
|
||||
|
@ -47,7 +47,7 @@
|
||||
"dependencies": {
|
||||
"@0x/types": "^3.2.0",
|
||||
"@0x/typescript-typings": "^5.1.1",
|
||||
"@types/node": "*",
|
||||
"@types/node": "12.12.54",
|
||||
"abortcontroller-polyfill": "^1.1.9",
|
||||
"bignumber.js": "~9.0.0",
|
||||
"chalk": "^2.3.0",
|
||||
|
Loading…
x
Reference in New Issue
Block a user