Rename resolver to sol-resolver

This commit is contained in:
Leonid Logvinov
2018-04-16 16:38:55 +02:00
parent e5cf41b313
commit d8ef76fd5e
20 changed files with 35 additions and 108 deletions

View File

@@ -68,7 +68,7 @@
"zeppelin-solidity": "1.8.0" "zeppelin-solidity": "1.8.0"
}, },
"dependencies": { "dependencies": {
"@0xproject/resolver": "^0.0.1", "@0xproject/sol-resolver": "^0.0.1",
"@0xproject/json-schemas": "^0.7.20", "@0xproject/json-schemas": "^0.7.20",
"@0xproject/types": "^0.6.0", "@0xproject/types": "^0.6.0",
"@0xproject/typescript-typings": "^0.1.0", "@0xproject/typescript-typings": "^0.1.0",

View File

@@ -8,7 +8,7 @@ import {
NPMResolver, NPMResolver,
Resolver, Resolver,
URLResolver, URLResolver,
} from '@0xproject/resolver'; } from '@0xproject/sol-resolver';
import { ContractAbi } from '@0xproject/types'; import { ContractAbi } from '@0xproject/types';
import { logUtils, promisify } from '@0xproject/utils'; import { logUtils, promisify } from '@0xproject/utils';
import chalk from 'chalk'; import chalk from 'chalk';

View File

@@ -1,4 +1,4 @@
import { ContractSource, ContractSources } from '@0xproject/resolver'; import { ContractSource, ContractSources } from '@0xproject/sol-resolver';
import { logUtils } from '@0xproject/utils'; import { logUtils } from '@0xproject/utils';
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as path from 'path'; import * as path from 'path';

View File

@@ -47,24 +47,31 @@ describe('Compiler utils', () => {
}); });
describe('#parseDependencies', () => { describe('#parseDependencies', () => {
it('correctly parses Exchange dependencies', async () => { it('correctly parses Exchange dependencies', async () => {
const exchangeSource = await fsWrapper.readFileAsync(`${__dirname}/fixtures/contracts/Exchange.sol`, { const path = `${__dirname}/fixtures/contracts/Exchange.sol`;
const source = await fsWrapper.readFileAsync(path, {
encoding: 'utf8', encoding: 'utf8',
}); });
expect(parseDependencies(exchangeSource)).to.be.deep.equal(['ERC20', 'TokenTransferProxy', 'SafeMath']); expect(parseDependencies({ source, path })).to.be.deep.equal([
'zeppelin-solidity/contracts/token/ERC20/ERC20.sol',
'/home/circleci/repo/packages/deployer/lib/test/fixtures/contracts/TokenTransferProxy.sol',
'/home/circleci/repo/packages/deployer/lib/test/fixtures/contracts/base/SafeMath.sol',
]);
}); });
it('correctly parses TokenTransferProxy dependencies', async () => { it('correctly parses TokenTransferProxy dependencies', async () => {
const exchangeSource = await fsWrapper.readFileAsync( const path = `${__dirname}/fixtures/contracts/TokenTransferProxy.sol`;
`${__dirname}/fixtures/contracts/TokenTransferProxy.sol`, const source = await fsWrapper.readFileAsync(path, {
{ encoding: 'utf8',
encoding: 'utf8', });
}, expect(parseDependencies({ source, path })).to.be.deep.equal([
); 'zeppelin-solidity/contracts/ownership/Ownable.sol',
expect(parseDependencies(exchangeSource)).to.be.deep.equal(['Ownable', 'ERC20']); 'zeppelin-solidity/contracts/token/ERC20/ERC20.sol',
]);
}); });
// TODO: For now that doesn't work. This will work after we switch to a grammar-based parser // TODO: For now that doesn't work. This will work after we switch to a grammar-based parser
it.skip('correctly parses commented out dependencies', async () => { it.skip('correctly parses commented out dependencies', async () => {
const contractWithCommentedOutDependencies = `// import "./TokenTransferProxy.sol";`; const path = '';
expect(parseDependencies(contractWithCommentedOutDependencies)).to.be.deep.equal([]); const source = `// import "./TokenTransferProxy.sol";`;
expect(parseDependencies({ path, source })).to.be.deep.equal([]);
}); });
}); });
}); });

View File

@@ -1,6 +1,6 @@
/* /*
Copyright 2017 ZeroEx Intl. Copyright 2018 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

View File

@@ -1,6 +1,6 @@
/* /*
Copyright 2017 ZeroEx Intl. Copyright 2018 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

View File

@@ -12,6 +12,7 @@ export const collectContractsData = (artifactsPath: string, sourcesPath: string,
const artifact = JSON.parse(fs.readFileSync(artifactFileName).toString()); const artifact = JSON.parse(fs.readFileSync(artifactFileName).toString());
const sources = artifact.networks[networkId].sources; const sources = artifact.networks[networkId].sources;
const contractName = artifact.contract_name; const contractName = artifact.contract_name;
// We don't compute coverage for dependencies
const sourceCodes = _.map(sources, (source: string) => fs.readFileSync(source).toString()); const sourceCodes = _.map(sources, (source: string) => fs.readFileSync(source).toString());
if (_.isUndefined(artifact.networks[networkId])) { if (_.isUndefined(artifact.networks[networkId])) {
throw new Error(`No ${contractName} artifacts found for networkId ${networkId}`); throw new Error(`No ${contractName} artifacts found for networkId ${networkId}`);

View File

@@ -1,5 +1,5 @@
{ {
"name": "@0xproject/resolver", "name": "@0xproject/sol-resolver",
"version": "0.0.1", "version": "0.0.1",
"description": "Import resolver for smart contracts dependencies", "description": "Import resolver for smart contracts dependencies",
"main": "lib/index.js", "main": "lib/index.js",

101
yarn.lock
View File

@@ -25,41 +25,6 @@
web3-eth-abi "^1.0.0-beta.24" web3-eth-abi "^1.0.0-beta.24"
yargs "^10.0.3" yargs "^10.0.3"
"@0xproject/dev-utils@^0.2.1":
version "0.2.1"
resolved "https://registry.yarnpkg.com/@0xproject/dev-utils/-/dev-utils-0.2.1.tgz#a54465376fd7c8cf58781b02b1790d74fb51e91b"
dependencies:
"@0xproject/subproviders" "^0.7.0"
"@0xproject/types" "^0.3.1"
"@0xproject/utils" "^0.4.1"
ethereumjs-util "^5.1.2"
lodash "^4.17.4"
request-promise-native "^1.0.5"
web3 "^0.20.0"
web3-provider-engine "^13.0.1"
"@0xproject/subproviders@^0.7.0":
version "0.7.0"
resolved "https://registry.yarnpkg.com/@0xproject/subproviders/-/subproviders-0.7.0.tgz#ce3379a85649773e5c08f5fc3239e8ed07f13361"
dependencies:
"@0xproject/assert" "^0.2.0"
"@0xproject/types" "^0.3.1"
"@0xproject/utils" "^0.4.1"
"@ledgerhq/hw-app-eth" "^4.3.0"
"@ledgerhq/hw-transport-u2f" "^4.3.0"
bn.js "^4.11.8"
es6-promisify "^5.0.0"
ethereumjs-tx "^1.3.3"
ethereumjs-util "^5.1.1"
hdkey "^0.7.1"
lodash "^4.17.4"
semaphore-async-await "^1.5.1"
web3 "^0.20.0"
web3-provider-engine "^13.0.1"
web3-typescript-typings "^0.10.0"
optionalDependencies:
"@ledgerhq/hw-transport-node-hid" "^4.3.0"
"@0xproject/tslint-config@0.4.13": "@0xproject/tslint-config@0.4.13":
version "0.4.13" version "0.4.13"
resolved "https://registry.yarnpkg.com/@0xproject/tslint-config/-/tslint-config-0.4.13.tgz#98c71c5ae5e80315a23eda0134cc9f6f4438cac2" resolved "https://registry.yarnpkg.com/@0xproject/tslint-config/-/tslint-config-0.4.13.tgz#98c71c5ae5e80315a23eda0134cc9f6f4438cac2"
@@ -69,33 +34,12 @@
tslint-eslint-rules "^4.1.1" tslint-eslint-rules "^4.1.1"
tslint-react "^3.2.0" tslint-react "^3.2.0"
"@0xproject/types@^0.3.1":
version "0.3.1"
resolved "https://registry.yarnpkg.com/@0xproject/types/-/types-0.3.1.tgz#9a75be6d3a2d41b7ecbd9105c3fdc09f3e3ec297"
dependencies:
bignumber.js "~4.1.0"
web3 "^0.20.0"
web3-typescript-typings "^0.10.0"
"@0xproject/types@^0.4.2":
version "0.4.2"
resolved "https://registry.yarnpkg.com/@0xproject/types/-/types-0.4.2.tgz#83d6ebef60f41e6209acb2656b1d68ff79367ca5"
dependencies:
bignumber.js "~4.1.0"
"@0xproject/types@^0.5.0": "@0xproject/types@^0.5.0":
version "0.5.0" version "0.5.0"
resolved "https://registry.yarnpkg.com/@0xproject/types/-/types-0.5.0.tgz#ba3cfbc11a8c6344b57c9680aa7df2ea84b9bf05" resolved "https://registry.yarnpkg.com/@0xproject/types/-/types-0.5.0.tgz#ba3cfbc11a8c6344b57c9680aa7df2ea84b9bf05"
dependencies: dependencies:
bignumber.js "~4.1.0" bignumber.js "~4.1.0"
"@0xproject/typescript-typings@^0.0.2":
version "0.0.2"
resolved "https://registry.yarnpkg.com/@0xproject/typescript-typings/-/typescript-typings-0.0.2.tgz#b549ea3c81ce2d81b99f05583bdf7c411a3ca90c"
dependencies:
"@0xproject/types" "^0.4.2"
bignumber.js "~4.1.0"
"@0xproject/typescript-typings@^0.0.3": "@0xproject/typescript-typings@^0.0.3":
version "0.0.3" version "0.0.3"
resolved "https://registry.yarnpkg.com/@0xproject/typescript-typings/-/typescript-typings-0.0.3.tgz#3272080bde00ade0a970b0d236686b483b08a1d0" resolved "https://registry.yarnpkg.com/@0xproject/typescript-typings/-/typescript-typings-0.0.3.tgz#3272080bde00ade0a970b0d236686b483b08a1d0"
@@ -103,19 +47,6 @@
"@0xproject/types" "^0.5.0" "@0xproject/types" "^0.5.0"
bignumber.js "~4.1.0" bignumber.js "~4.1.0"
"@0xproject/utils@^0.4.1":
version "0.4.4"
resolved "https://registry.yarnpkg.com/@0xproject/utils/-/utils-0.4.4.tgz#bce4f7a5a46570a69911f4a4ade5d49016330087"
dependencies:
"@0xproject/types" "^0.4.2"
"@0xproject/typescript-typings" "^0.0.2"
"@types/node" "^8.0.53"
bignumber.js "~4.1.0"
ethers-contracts "^2.2.1"
js-sha3 "^0.7.0"
lodash "^4.17.4"
web3 "^0.20.0"
"@0xproject/web3-wrapper@^0.5.0": "@0xproject/web3-wrapper@^0.5.0":
version "0.5.0" version "0.5.0"
resolved "https://registry.yarnpkg.com/@0xproject/web3-wrapper/-/web3-wrapper-0.5.0.tgz#99a1acea60a5c3163ac0be28f4c0577c3d43dec4" resolved "https://registry.yarnpkg.com/@0xproject/web3-wrapper/-/web3-wrapper-0.5.0.tgz#99a1acea60a5c3163ac0be28f4c0577c3d43dec4"
@@ -167,6 +98,12 @@
version "1.0.2" version "1.0.2"
resolved "https://registry.yarnpkg.com/@types/bintrees/-/bintrees-1.0.2.tgz#0dfdce4eeebdf90427bd35b0e79dc248b3d157a6" resolved "https://registry.yarnpkg.com/@types/bintrees/-/bintrees-1.0.2.tgz#0dfdce4eeebdf90427bd35b0e79dc248b3d157a6"
"@types/bip39@^2.4.0":
version "2.4.0"
resolved "https://registry.yarnpkg.com/@types/bip39/-/bip39-2.4.0.tgz#eee31a14abc8ebbb41a1ff14575c447b18346cbc"
dependencies:
"@types/node" "*"
"@types/body-parser@*", "@types/body-parser@^1.16.1": "@types/body-parser@*", "@types/body-parser@^1.16.1":
version "1.16.8" version "1.16.8"
resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.16.8.tgz#687ec34140624a3bec2b1a8ea9268478ae8f3be3" resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.16.8.tgz#687ec34140624a3bec2b1a8ea9268478ae8f3be3"
@@ -1514,7 +1451,7 @@ bintrees@^1.0.2:
version "1.0.2" version "1.0.2"
resolved "https://registry.yarnpkg.com/bintrees/-/bintrees-1.0.2.tgz#49f896d6e858a4a499df85c38fb399b9aff840f8" resolved "https://registry.yarnpkg.com/bintrees/-/bintrees-1.0.2.tgz#49f896d6e858a4a499df85c38fb399b9aff840f8"
bip39@^2.2.0: bip39@^2.2.0, bip39@^2.5.0:
version "2.5.0" version "2.5.0"
resolved "https://registry.yarnpkg.com/bip39/-/bip39-2.5.0.tgz#51cbd5179460504a63ea3c000db3f787ca051235" resolved "https://registry.yarnpkg.com/bip39/-/bip39-2.5.0.tgz#51cbd5179460504a63ea3c000db3f787ca051235"
dependencies: dependencies:
@@ -3700,7 +3637,7 @@ ethereumjs-util@^4.0.1, ethereumjs-util@^4.3.0, ethereumjs-util@^4.4.0:
rlp "^2.0.0" rlp "^2.0.0"
secp256k1 "^3.0.1" secp256k1 "^3.0.1"
ethereumjs-util@^5.0.0, ethereumjs-util@^5.0.1, ethereumjs-util@^5.1.1, ethereumjs-util@^5.1.2, ethereumjs-util@^5.1.3, ethereumjs-util@^5.1.5: ethereumjs-util@^5.0.0, ethereumjs-util@^5.0.1, ethereumjs-util@^5.1.1, ethereumjs-util@^5.1.3, ethereumjs-util@^5.1.5:
version "5.1.5" version "5.1.5"
resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-5.1.5.tgz#2f02575852627d45622426f25ee4a0b5f377f27a" resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-5.1.5.tgz#2f02575852627d45622426f25ee4a0b5f377f27a"
dependencies: dependencies:
@@ -9043,20 +8980,6 @@ request-ip@~1.2.3:
version "1.2.3" version "1.2.3"
resolved "https://registry.yarnpkg.com/request-ip/-/request-ip-1.2.3.tgz#66988f0e22406ec4af630d19b573fe4b447c3b49" resolved "https://registry.yarnpkg.com/request-ip/-/request-ip-1.2.3.tgz#66988f0e22406ec4af630d19b573fe4b447c3b49"
request-promise-core@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/request-promise-core/-/request-promise-core-1.1.1.tgz#3eee00b2c5aa83239cfb04c5700da36f81cd08b6"
dependencies:
lodash "^4.13.1"
request-promise-native@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/request-promise-native/-/request-promise-native-1.0.5.tgz#5281770f68e0c9719e5163fd3fab482215f4fda5"
dependencies:
request-promise-core "1.1.1"
stealthy-require "^1.1.0"
tough-cookie ">=2.3.3"
request@2.81.0: request@2.81.0:
version "2.81.0" version "2.81.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0" resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0"
@@ -9942,10 +9865,6 @@ static-extend@^0.1.1:
version "1.4.0" version "1.4.0"
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.4.0.tgz#bb73d446da2796106efcc1b601a253d6c46bd087" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.4.0.tgz#bb73d446da2796106efcc1b601a253d6c46bd087"
stealthy-require@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b"
stream-browserify@^2.0.1: stream-browserify@^2.0.1:
version "2.0.1" version "2.0.1"
resolved "https://registry.yarnpkg.com/stream-browserify/-/stream-browserify-2.0.1.tgz#66266ee5f9bdb9940a4e4514cafb43bb71e5c9db" resolved "https://registry.yarnpkg.com/stream-browserify/-/stream-browserify-2.0.1.tgz#66266ee5f9bdb9940a4e4514cafb43bb71e5c9db"
@@ -10518,7 +10437,7 @@ touch@^3.1.0:
dependencies: dependencies:
nopt "~1.0.10" nopt "~1.0.10"
tough-cookie@>=2.3.3, tough-cookie@~2.3.0, tough-cookie@~2.3.3: tough-cookie@~2.3.0, tough-cookie@~2.3.3:
version "2.3.4" version "2.3.4"
resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.4.tgz#ec60cee38ac675063ffc97a5c18970578ee83655" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.4.tgz#ec60cee38ac675063ffc97a5c18970578ee83655"
dependencies: dependencies:
@@ -11473,7 +11392,7 @@ web3-shh@1.0.0-beta.33:
web3-core-subscriptions "1.0.0-beta.33" web3-core-subscriptions "1.0.0-beta.33"
web3-net "1.0.0-beta.33" web3-net "1.0.0-beta.33"
web3-typescript-typings@^0.10.0, web3-typescript-typings@^0.10.2: web3-typescript-typings@^0.10.2:
version "0.10.2" version "0.10.2"
resolved "https://registry.yarnpkg.com/web3-typescript-typings/-/web3-typescript-typings-0.10.2.tgz#a9903815d2a8a0dbd73fd5db374070de0bd30497" resolved "https://registry.yarnpkg.com/web3-typescript-typings/-/web3-typescript-typings-0.10.2.tgz#a9903815d2a8a0dbd73fd5db374070de0bd30497"
dependencies: dependencies: