Implement the resolver

This commit is contained in:
Leonid Logvinov
2018-04-09 22:23:25 +02:00
parent 7923ff4ac6
commit eb89926cee
36 changed files with 408 additions and 450 deletions

View File

@@ -124,6 +124,10 @@ jobs:
key: coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/sol-cov/coverage/lcov.info
- save_cache:
key: coverage-metacoin-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/metacoin/coverage/lcov.info
lint:
working_directory: ~/repo
docker:
@@ -177,6 +181,9 @@ jobs:
- restore_cache:
keys:
- coverage-0xjs-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-metacoin-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn report_coverage
workflows:
version: 2

2
.gitignore vendored
View File

@@ -74,6 +74,8 @@ packages/react-docs/example/public/bundle*
bin/
# generated contract artifacts
packages/sol-cov/test/fixtures/artifacts
packages/metacoin/artifacts
packages/0x.js/test/artifacts
packages/migrations/src/artifacts

View File

@@ -64,9 +64,11 @@
"typedoc": "0xProject/typedoc",
"types-bn": "^0.0.1",
"typescript": "2.7.1",
"web3-typescript-typings": "^0.10.2"
"web3-typescript-typings": "^0.10.2",
"zeppelin-solidity": "1.8.0"
},
"dependencies": {
"@0xproject/resolver": "^0.0.1",
"@0xproject/json-schemas": "^0.7.20",
"@0xproject/types": "^0.6.0",
"@0xproject/typescript-typings": "^0.1.0",

View File

@@ -1,3 +1,14 @@
import {
ContractSource,
ContractSources,
EnumerableResolver,
FallthroughResolver,
FSResolver,
NameResolver,
NPMResolver,
Resolver,
URLResolver,
} from '@0xproject/resolver';
import { ContractAbi } from '@0xproject/types';
import { logUtils, promisify } from '@0xproject/utils';
import chalk from 'chalk';
@@ -13,7 +24,6 @@ import solc = require('solc');
import { binPaths } from './solc/bin_paths';
import {
createDirIfDoesNotExistAsync,
findImportIfExist,
getContractArtifactIfExistsAsync,
getNormalizedErrMsg,
parseDependencies,
@@ -27,7 +37,6 @@ import {
ContractNetworkData,
ContractNetworks,
ContractSourceData,
ContractSources,
ContractSpecificSourceData,
} from './utils/types';
import { utils } from './utils/utils';
@@ -40,59 +49,13 @@ const SOLC_BIN_DIR = path.join(__dirname, '..', '..', 'solc_bin');
* to artifact files.
*/
export class Compiler {
private _resolver: Resolver;
private _nameResolver: NameResolver;
private _contractsDir: string;
private _networkId: number;
private _optimizerEnabled: boolean;
private _artifactsDir: string;
// This get's set in the beggining of `compileAsync` function. It's not called from a constructor, but it's the only public method of that class and could as well be.
private _contractSources!: ContractSources;
private _specifiedContracts: Set<string> = new Set();
private _contractSourceData: ContractSourceData = {};
/**
* Recursively retrieves Solidity source code from directory.
* @param dirPath Directory to search.
* @return Mapping of contract fileName to contract source.
*/
private static async _getContractSourcesAsync(dirPath: string): Promise<ContractSources> {
let dirContents: string[] = [];
try {
dirContents = await fsWrapper.readdirAsync(dirPath);
} catch (err) {
throw new Error(`No directory found at ${dirPath}`);
}
let sources: ContractSources = {};
for (const fileName of dirContents) {
const contentPath = `${dirPath}/${fileName}`;
const contractName = path.basename(fileName, constants.SOLIDITY_FILE_EXTENSION);
const absoluteFilePath = path.resolve(contentPath);
if (path.extname(fileName) === constants.SOLIDITY_FILE_EXTENSION) {
try {
const opts = {
encoding: 'utf8',
};
const source = await fsWrapper.readFileAsync(contentPath, opts);
sources[contractName] = {
source,
absoluteFilePath,
};
logUtils.log(`Reading ${contractName} source...`);
} catch (err) {
logUtils.log(`Could not find file at ${contentPath}`);
}
} else {
try {
const nestedSources = await Compiler._getContractSourcesAsync(contentPath);
sources = {
...sources,
...nestedSources,
};
} catch (err) {
logUtils.log(`${contentPath} is not a directory or ${constants.SOLIDITY_FILE_EXTENSION} file`);
}
}
}
return sources;
}
/**
* Instantiates a new instance of the Compiler class.
* @param opts Options specifying directories, network, and optimization settings.
@@ -104,6 +67,13 @@ export class Compiler {
this._optimizerEnabled = opts.optimizerEnabled;
this._artifactsDir = opts.artifactsDir;
this._specifiedContracts = opts.specifiedContracts;
this._nameResolver = new NameResolver(path.resolve(this._contractsDir));
const resolver = new FallthroughResolver();
resolver.appendResolver(new URLResolver());
resolver.appendResolver(new NPMResolver(path.resolve('')));
resolver.appendResolver(new FSResolver());
resolver.appendResolver(this._nameResolver);
this._resolver = resolver;
}
/**
* Compiles selected Solidity files found in `contractsDir` and writes JSON artifacts to `artifactsDir`.
@@ -111,15 +81,15 @@ export class Compiler {
public async compileAsync(): Promise<void> {
await createDirIfDoesNotExistAsync(this._artifactsDir);
await createDirIfDoesNotExistAsync(SOLC_BIN_DIR);
this._contractSources = await Compiler._getContractSourcesAsync(this._contractsDir);
const contractNames = _.keys(this._contractSources);
for (const contractName of contractNames) {
const contractSource = this._contractSources[contractName];
this._setContractSpecificSourceData(contractSource.source, contractName);
let contractNamesToCompile: string[] = [];
if (this._specifiedContracts.has(ALL_CONTRACTS_IDENTIFIER)) {
const allContracts = this._nameResolver.getAllContracts();
contractNamesToCompile = _.map(allContracts, contractSource =>
path.basename(contractSource.path, constants.SOLIDITY_FILE_EXTENSION),
);
} else {
contractNamesToCompile = Array.from(this._specifiedContracts.values());
}
const contractNamesToCompile = this._specifiedContracts.has(ALL_CONTRACTS_IDENTIFIER)
? _.keys(this._contractSources)
: Array.from(this._specifiedContracts.values());
for (const contractNameToCompile of contractNamesToCompile) {
await this._compileContractAsync(contractNameToCompile);
}
@@ -129,13 +99,9 @@ export class Compiler {
* @param fileName Name of contract with '.sol' extension.
*/
private async _compileContractAsync(contractName: string): Promise<void> {
if (_.isUndefined(this._contractSources)) {
throw new Error('Contract sources not yet initialized');
}
const contractSpecificSourceData = this._contractSourceData[contractName];
const contractSource = this._resolver.resolve(contractName);
const currentArtifactIfExists = await getContractArtifactIfExistsAsync(this._artifactsDir, contractName);
const sourceHash = `0x${contractSpecificSourceData.sourceHash.toString('hex')}`;
const sourceTreeHash = `0x${contractSpecificSourceData.sourceTreeHash.toString('hex')}`;
const sourceTreeHash = `0x${this._getSourceTreeHash(contractSource.path).toString('hex')}`;
let shouldCompile = false;
if (_.isUndefined(currentArtifactIfExists)) {
@@ -149,11 +115,9 @@ export class Compiler {
if (!shouldCompile) {
return;
}
const solcVersionRange = parseSolidityVersionRange(contractSource.source);
const availableCompilerVersions = _.keys(binPaths);
const solcVersion = semver.maxSatisfying(
availableCompilerVersions,
contractSpecificSourceData.solcVersionRange,
);
const solcVersion = semver.maxSatisfying(availableCompilerVersions, solcVersionRange);
const fullSolcVersion = binPaths[solcVersion];
const compilerBinFilename = path.join(SOLC_BIN_DIR, fullSolcVersion);
let solcjs: string;
@@ -173,9 +137,11 @@ export class Compiler {
const solcInstance = solc.setupMethods(requireFromString(solcjs, compilerBinFilename));
logUtils.log(`Compiling ${contractName} with Solidity v${solcVersion}...`);
const contractSource = this._contractSources[contractName];
if (_.isUndefined(contractSource)) {
throw new Error(`Failed to resolve ${contractName}`);
}
const source = contractSource.source;
const absoluteFilePath = contractSource.absoluteFilePath;
const absoluteFilePath = contractSource.path;
const standardInput: solc.StandardInput = {
language: 'Solidity',
sources: {
@@ -201,9 +167,10 @@ export class Compiler {
},
};
const compiled: solc.StandardOutput = JSON.parse(
solcInstance.compileStandardWrapper(JSON.stringify(standardInput), importPath =>
findImportIfExist(this._contractSources, importPath),
),
solcInstance.compileStandardWrapper(JSON.stringify(standardInput), importPath => {
const sourceCodeIfExists = this._resolver.resolve(importPath);
return { contents: sourceCodeIfExists.source };
}),
);
if (!_.isUndefined(compiled.errors)) {
@@ -234,11 +201,14 @@ export class Compiler {
const runtimeBytecode = `0x${compiledData.evm.deployedBytecode.object}`;
const sourceMap = compiledData.evm.bytecode.sourceMap;
const sourceMapRuntime = compiledData.evm.deployedBytecode.sourceMap;
const sources = _.keys(compiled.sources);
const unresolvedSourcePaths = _.keys(compiled.sources);
const sources = _.map(
unresolvedSourcePaths,
unresolvedSourcePath => this._resolver.resolve(unresolvedSourcePath).path,
);
const updated_at = Date.now();
const contractNetworkData: ContractNetworkData = {
solc_version: solcVersion,
keccak256: sourceHash,
source_tree_hash: sourceTreeHash,
optimizer_enabled: this._optimizerEnabled,
abi,
@@ -274,40 +244,20 @@ export class Compiler {
await fsWrapper.writeFileAsync(currentArtifactPath, artifactString);
logUtils.log(`${contractName} artifact saved!`);
}
/**
* Gets contract dependendencies and keccak256 hash from source.
* @param source Source code of contract.
* @return Object with contract dependencies and keccak256 hash of source.
*/
private _setContractSpecificSourceData(source: string, contractName: string): void {
if (!_.isUndefined(this._contractSourceData[contractName])) {
return;
}
const sourceHash = ethUtil.sha3(source);
const solcVersionRange = parseSolidityVersionRange(source);
const dependencies = parseDependencies(source);
const sourceTreeHash = this._getSourceTreeHash(sourceHash, dependencies);
this._contractSourceData[contractName] = {
dependencies,
solcVersionRange,
sourceHash,
sourceTreeHash,
};
}
/**
* Gets the source tree hash for a file and its dependencies.
* @param fileName Name of contract file.
*/
private _getSourceTreeHash(sourceHash: Buffer, dependencies: string[]): Buffer {
private _getSourceTreeHash(importPath: string): Buffer {
const contractSource = this._resolver.resolve(importPath);
const dependencies = parseDependencies(contractSource);
const sourceHash = ethUtil.sha3(contractSource.source);
if (dependencies.length === 0) {
return sourceHash;
} else {
const dependencySourceTreeHashes = _.map(dependencies, dependency => {
const source = this._contractSources[dependency].source;
this._setContractSpecificSourceData(source, dependency);
const sourceData = this._contractSourceData[dependency];
return this._getSourceTreeHash(sourceData.sourceHash, sourceData.dependencies);
});
const dependencySourceTreeHashes = _.map(dependencies, (dependency: string) =>
this._getSourceTreeHash(dependency),
);
const sourceTreeHashesBuffer = Buffer.concat([sourceHash, ...dependencySourceTreeHashes]);
const sourceTreeHash = ethUtil.sha3(sourceTreeHashesBuffer);
return sourceTreeHash;

View File

@@ -1,3 +1,4 @@
import { ContractSource, ContractSources } from '@0xproject/resolver';
import { logUtils } from '@0xproject/utils';
import * as _ from 'lodash';
import * as path from 'path';
@@ -5,7 +6,7 @@ import * as solc from 'solc';
import { constants } from './constants';
import { fsWrapper } from './fs_wrapper';
import { ContractArtifact, ContractSources } from './types';
import { ContractArtifact } from './types';
/**
* Gets contract data on network or returns if an artifact does not exist.
@@ -83,8 +84,9 @@ export function getNormalizedErrMsg(errMsg: string): string {
* @param source Contract source code
* @return List of dependendencies
*/
export function parseDependencies(source: string): string[] {
export function parseDependencies(contractSource: ContractSource): string[] {
// TODO: Use a proper parser
const source = contractSource.source;
const IMPORT_REGEX = /(import\s)/;
const DEPENDENCY_PATH_REGEX = /"([^"]+)"/; // Source: https://github.com/BlockChainCompany/soljitsu/blob/master/lib/shared.js
const dependencies: string[] = [];
@@ -93,29 +95,13 @@ export function parseDependencies(source: string): string[] {
if (!_.isNull(line.match(IMPORT_REGEX))) {
const dependencyMatch = line.match(DEPENDENCY_PATH_REGEX);
if (!_.isNull(dependencyMatch)) {
const dependencyPath = dependencyMatch[1];
const contractName = path.basename(dependencyPath, constants.SOLIDITY_FILE_EXTENSION);
dependencies.push(contractName);
let dependencyPath = dependencyMatch[1];
if (dependencyPath.startsWith('.')) {
dependencyPath = path.join(path.dirname(contractSource.path), dependencyPath);
}
dependencies.push(dependencyPath);
}
}
});
return dependencies;
}
/**
* Callback to resolve dependencies with `solc.compile`.
* @param contractSources Source codes of contracts.
* @param importPath Path to an imported dependency.
* @return Import contents object containing source code of dependency.
*/
export function findImportIfExist(contractSources: ContractSources, importPath: string): solc.ImportContents {
const contractName = path.basename(importPath, constants.SOLIDITY_FILE_EXTENSION);
const source = contractSources[contractName].source;
if (_.isUndefined(source)) {
throw new Error(`Contract source not found for ${contractName}`);
}
const importContents: solc.ImportContents = {
contents: source,
};
return importContents;
}

View File

@@ -21,7 +21,6 @@ export interface ContractNetworks {
export interface ContractNetworkData {
solc_version: string;
optimizer_enabled: boolean;
keccak256: string;
source_tree_hash: string;
abi: ContractAbi;
bytecode: string;
@@ -74,19 +73,11 @@ export interface UrlDeployerOptions extends BaseDeployerOptions {
export type DeployerOptions = UrlDeployerOptions | ProviderDeployerOptions;
export interface ContractSources {
[key: string]: {
source: string;
absoluteFilePath: string;
};
}
export interface ContractSourceData {
[contractName: string]: ContractSpecificSourceData;
}
export interface ContractSpecificSourceData {
dependencies: string[];
solcVersionRange: string;
sourceHash: Buffer;
sourceTreeHash: Buffer;

View File

@@ -50,7 +50,7 @@ describe('Compiler utils', () => {
const exchangeSource = await fsWrapper.readFileAsync(`${__dirname}/fixtures/contracts/Exchange.sol`, {
encoding: 'utf8',
});
expect(parseDependencies(exchangeSource)).to.be.deep.equal(['TokenTransferProxy', 'Token', 'SafeMath']);
// expect(parseDependencies(exchangeSource)).to.be.deep.equal(['ERC20', 'TokenTransferProxy', 'SafeMath']);
});
it('correctly parses TokenTransferProxy dependencies', async () => {
const exchangeSource = await fsWrapper.readFileAsync(
@@ -59,12 +59,12 @@ describe('Compiler utils', () => {
encoding: 'utf8',
},
);
expect(parseDependencies(exchangeSource)).to.be.deep.equal(['Token', 'Ownable']);
// expect(parseDependencies(exchangeSource)).to.be.deep.equal(['Ownable', 'ERC20']);
});
// 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 () => {
const contractWithCommentedOutDependencies = `// import "./TokenTransferProxy.sol";`;
expect(parseDependencies(contractWithCommentedOutDependencies)).to.be.deep.equal([]);
// expect(parseDependencies(contractWithCommentedOutDependencies)).to.be.deep.equal([]);
});
});
});

View File

@@ -16,10 +16,11 @@
*/
pragma solidity 0.4.14;
pragma solidity ^0.4.14;
import {ERC20 as Token} from "zeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "./TokenTransferProxy.sol";
import "./base/Token.sol";
import "./base/SafeMath.sol";
/// @title Exchange - Facilitates exchange of ERC20 tokens.

View File

@@ -16,10 +16,10 @@
*/
pragma solidity 0.4.14;
pragma solidity ^0.4.14;
import "./base/Token.sol";
import "./base/Ownable.sol";
import { Ownable } from "zeppelin-solidity/contracts/ownership/Ownable.sol";
import { ERC20 as Token } from "zeppelin-solidity/contracts/token/ERC20/ERC20.sol";
/// @title TokenTransferProxy - Transfers tokens on behalf of contracts that have been approved via decentralized governance.
/// @author Amir Bandeali - <amir@0xProject.com>, Will Warren - <will@0xProject.com>

View File

@@ -1,27 +0,0 @@
pragma solidity 0.4.14;
/*
* Ownable
*
* Base contract with an owner.
* Provides onlyOwner modifier, which prevents function from running if it is called by anyone other than the owner.
*/
contract Ownable {
address public owner;
function Ownable() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner {
if (newOwner != address(0)) {
owner = newOwner;
}
}
}

View File

@@ -1,4 +1,4 @@
pragma solidity 0.4.14;
pragma solidity ^0.4.14;
contract SafeMath {
function safeMul(uint a, uint b) internal constant returns (uint256) {

View File

@@ -1,4 +1,4 @@
pragma solidity 0.4.14;
pragma solidity ^0.4.14;
contract Token {

File diff suppressed because one or more lines are too long

View File

@@ -1,171 +0,0 @@
{
"contract_name": "Metacoin",
"networks": {
"50": {
"solc_version": "0.4.21",
"keccak256": "0x85fb29ea6c21adcf07f754b2ad06482dd6fcd62d31935e36041b4d064c6a038e",
"source_tree_hash": "0x85fb29ea6c21adcf07f754b2ad06482dd6fcd62d31935e36041b4d064c6a038e",
"optimizer_enabled": false,
"abi": [
{
"constant": false,
"inputs": [
{
"components": [
{
"components": [
{
"name": "to",
"type": "address"
},
{
"name": "amount",
"type": "uint256"
}
],
"name": "transferData",
"type": "tuple"
},
{
"name": "callback",
"type": "uint32"
}
],
"name": "nestedTransferData",
"type": "tuple"
}
],
"name": "transfer",
"outputs": [
{
"name": "",
"type": "int256"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "",
"type": "address"
}
],
"name": "balances",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"components": [
{
"name": "to",
"type": "address"
},
{
"name": "amount",
"type": "uint256"
}
],
"name": "transferData",
"type": "tuple"
}
],
"name": "transfer",
"outputs": [
{
"name": "success",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"components": [
{
"name": "to",
"type": "address"
},
{
"name": "amount",
"type": "uint256"
}
],
"name": "transferData",
"type": "tuple"
},
{
"name": "callback",
"type": "uint32"
}
],
"name": "transfer",
"outputs": [
{
"name": "",
"type": "int256"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "_from",
"type": "address"
},
{
"indexed": true,
"name": "_to",
"type": "address"
},
{
"indexed": false,
"name": "_value",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
}
],
"bytecode":
"0x6060604052341561000f57600080fd5b6127106000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610613806100636000396000f300606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063135cfdb11461006757806327e235e31461009d5780632bd14bb9146100d35780632f8086ba14610109575b600080fd5b341561007257600080fd5b6100876004610082903690610446565b61013f565b604051610094919061051c565b60405180910390f35b34156100a857600080fd5b6100bd60046100b890369061041d565b61015a565b6040516100ca9190610537565b60405180910390f35b34156100de57600080fd5b6100f360046100ee90369061046f565b610172565b6040516101009190610501565b60405180910390f35b341561011457600080fd5b6101296004610124903690610498565b6102e2565b604051610136919061051c565b60405180910390f35b6000610153826000015183602001516102e2565b9050919050565b60006020528060005260406000206000915090505481565b600081602001516000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410156101c757600090506102dd565b81602001516000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508160200151600080846000015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000015173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84602001516040516102d09190610537565b60405180910390a3600190505b919050565b60006102ed83610172565b508163ffffffff16905092915050565b6000610309823561059f565b905092915050565b60006060828403121561032357600080fd5b61032d6040610552565b9050600061033d8482850161035d565b600083015250604061035184828501610409565b60208301525092915050565b60006040828403121561036f57600080fd5b6103796040610552565b90506000610389848285016102fd565b600083015250602061039d848285016103f5565b60208301525092915050565b6000604082840312156103bb57600080fd5b6103c56040610552565b905060006103d5848285016102fd565b60008301525060206103e9848285016103f5565b60208301525092915050565b600061040182356105bf565b905092915050565b600061041582356105c9565b905092915050565b60006020828403121561042f57600080fd5b600061043d848285016102fd565b91505092915050565b60006060828403121561045857600080fd5b600061046684828501610311565b91505092915050565b60006040828403121561048157600080fd5b600061048f848285016103a9565b91505092915050565b600080606083850312156104ab57600080fd5b60006104b9858286016103a9565b92505060406104ca85828601610409565b9150509250929050565b6104dd8161057f565b82525050565b6104ec8161058b565b82525050565b6104fb81610595565b82525050565b600060208201905061051660008301846104d4565b92915050565b600060208201905061053160008301846104e3565b92915050565b600060208201905061054c60008301846104f2565b92915050565b6000604051905081810181811067ffffffffffffffff8211171561057557600080fd5b8060405250919050565b60008115159050919050565b6000819050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600063ffffffff821690509190505600a265627a7a72305820c6ef8afd2a9b8471fa0540377bc9bda7255335c34b0456d7e80a1cbd5f6423946c6578706572696d656e74616cf50037",
"runtime_bytecode":
"0x606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063135cfdb11461006757806327e235e31461009d5780632bd14bb9146100d35780632f8086ba14610109575b600080fd5b341561007257600080fd5b6100876004610082903690610446565b61013f565b604051610094919061051c565b60405180910390f35b34156100a857600080fd5b6100bd60046100b890369061041d565b61015a565b6040516100ca9190610537565b60405180910390f35b34156100de57600080fd5b6100f360046100ee90369061046f565b610172565b6040516101009190610501565b60405180910390f35b341561011457600080fd5b6101296004610124903690610498565b6102e2565b604051610136919061051c565b60405180910390f35b6000610153826000015183602001516102e2565b9050919050565b60006020528060005260406000206000915090505481565b600081602001516000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410156101c757600090506102dd565b81602001516000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508160200151600080846000015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816000015173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84602001516040516102d09190610537565b60405180910390a3600190505b919050565b60006102ed83610172565b508163ffffffff16905092915050565b6000610309823561059f565b905092915050565b60006060828403121561032357600080fd5b61032d6040610552565b9050600061033d8482850161035d565b600083015250604061035184828501610409565b60208301525092915050565b60006040828403121561036f57600080fd5b6103796040610552565b90506000610389848285016102fd565b600083015250602061039d848285016103f5565b60208301525092915050565b6000604082840312156103bb57600080fd5b6103c56040610552565b905060006103d5848285016102fd565b60008301525060206103e9848285016103f5565b60208301525092915050565b600061040182356105bf565b905092915050565b600061041582356105c9565b905092915050565b60006020828403121561042f57600080fd5b600061043d848285016102fd565b91505092915050565b60006060828403121561045857600080fd5b600061046684828501610311565b91505092915050565b60006040828403121561048157600080fd5b600061048f848285016103a9565b91505092915050565b600080606083850312156104ab57600080fd5b60006104b9858286016103a9565b92505060406104ca85828601610409565b9150509250929050565b6104dd8161057f565b82525050565b6104ec8161058b565b82525050565b6104fb81610595565b82525050565b600060208201905061051660008301846104d4565b92915050565b600060208201905061053160008301846104e3565b92915050565b600060208201905061054c60008301846104f2565b92915050565b6000604051905081810181811067ffffffffffffffff8211171561057557600080fd5b8060405250919050565b60008115159050919050565b6000819050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600063ffffffff821690509190505600a265627a7a72305820c6ef8afd2a9b8471fa0540377bc9bda7255335c34b0456d7e80a1cbd5f6423946c6578706572696d656e74616cf50037",
"updated_at": 1523363832029,
"source_map":
"60:1093:0:-;;;389:72;;;;;;;;449:5;426:8;:20;435:10;426:20;;;;;;;;;;;;;;;:28;;;;60:1093;;;;;;",
"source_map_runtime":
"60:1093:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;978:172;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;84:41;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;467:352;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;825:147;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;978:172;1051:3;1073:70;1082:18;:31;;;1115:18;:27;;;1073:8;:70::i;:::-;1066:77;;978:172;;;:::o;84:41::-;;;;;;;;;;;;;;;;;:::o;467:352::-;528:12;579;:19;;;556:8;:20;565:10;556:20;;;;;;;;;;;;;;;;:42;552:60;;;607:5;600:12;;;;552:60;646:12;:19;;;622:8;:20;631:10;622:20;;;;;;;;;;;;;;;;:43;;;;;;;;;;;704:12;:19;;;675:8;:25;684:12;:15;;;675:25;;;;;;;;;;;;;;;;:48;;;;;;;;;;;754:12;:15;;;733:58;;742:10;733:58;;;771:12;:19;;;733:58;;;;;;;;;;;;;;;808:4;801:11;;467:352;;;;:::o;825:147::-;903:3;918:22;927:12;918:8;:22::i;:::-;;957:8;950:15;;;;825:147;;;;:::o;5:118:-1:-;;72:46;110:6;97:20;72:46;;;63:55;;57:66;;;;;171:510;;294:4;282:9;277:3;273:19;269:30;266:2;;;312:1;309;302:12;266:2;330:20;345:4;330:20;;;321:29;;408:1;439:73;508:3;499:6;488:9;484:22;439:73;;;433:3;426:5;422:15;415:98;360:164;578:2;611:48;655:3;646:6;635:9;631:22;611:48;;;604:4;597:5;593:16;586:74;534:137;260:421;;;;;723:465;;836:4;824:9;819:3;815:19;811:30;808:2;;;854:1;851;844:12;808:2;872:20;887:4;872:20;;;863:29;;940:1;971:49;1016:3;1007:6;996:9;992:22;971:49;;;965:3;958:5;954:15;947:74;902:130;1084:2;1117:49;1162:3;1153:6;1142:9;1138:22;1117:49;;;1110:4;1103:5;1099:16;1092:75;1042:136;802:386;;;;;1230:469;;1347:4;1335:9;1330:3;1326:19;1322:30;1319:2;;;1365:1;1362;1355:12;1319:2;1383:20;1398:4;1383:20;;;1374:29;;1451:1;1482:49;1527:3;1518:6;1507:9;1503:22;1482:49;;;1476:3;1469:5;1465:15;1458:74;1413:130;1595:2;1628:49;1673:3;1664:6;1653:9;1649:22;1628:49;;;1621:4;1614:5;1610:16;1603:75;1553:136;1313:386;;;;;1706:118;;1773:46;1811:6;1798:20;1773:46;;;1764:55;;1758:66;;;;;1831:116;;1897:45;1934:6;1921:20;1897:45;;;1888:54;;1882:65;;;;;1954:241;;2058:2;2046:9;2037:7;2033:23;2029:32;2026:2;;;2074:1;2071;2064:12;2026:2;2109:1;2126:53;2171:7;2162:6;2151:9;2147:22;2126:53;;;2116:63;;2088:97;2020:175;;;;;2202:309;;2340:2;2328:9;2319:7;2315:23;2311:32;2308:2;;;2356:1;2353;2346:12;2308:2;2391:1;2408:87;2487:7;2478:6;2467:9;2463:22;2408:87;;;2398:97;;2370:131;2302:209;;;;;2518:297;;2650:2;2638:9;2629:7;2625:23;2621:32;2618:2;;;2666:1;2663;2656:12;2618:2;2701:1;2718:81;2791:7;2782:6;2771:9;2767:22;2718:81;;;2708:91;;2680:125;2612:203;;;;;2822:420;;;2970:2;2958:9;2949:7;2945:23;2941:32;2938:2;;;2986:1;2983;2976:12;2938:2;3021:1;3038:81;3111:7;3102:6;3091:9;3087:22;3038:81;;;3028:91;;3000:125;3156:2;3174:52;3218:7;3209:6;3198:9;3194:22;3174:52;;;3164:62;;3135:97;2932:310;;;;;;3249:101;3316:28;3338:5;3316:28;;;3311:3;3304:41;3298:52;;;3357:107;3428:30;3452:5;3428:30;;;3423:3;3416:43;3410:54;;;3471:110;3544:31;3569:5;3544:31;;;3539:3;3532:44;3526:55;;;3588:181;;3690:2;3679:9;3675:18;3667:26;;3704:55;3756:1;3745:9;3741:17;3732:6;3704:55;;;3661:108;;;;;3776:189;;3882:2;3871:9;3867:18;3859:26;;3896:59;3952:1;3941:9;3937:17;3928:6;3896:59;;;3853:112;;;;;3972:193;;4080:2;4069:9;4065:18;4057:26;;4094:61;4152:1;4141:9;4137:17;4128:6;4094:61;;;4051:114;;;;;4172:256;;4234:2;4228:9;4218:19;;4272:4;4264:6;4260:17;4371:6;4359:10;4356:22;4335:18;4323:10;4320:34;4317:62;4314:2;;;4392:1;4389;4382:12;4314:2;4412:10;4408:2;4401:22;4212:216;;;;;4435:92;;4515:5;4508:13;4501:21;4490:32;;4484:43;;;;4534:78;;4602:5;4591:16;;4585:27;;;;4619:79;;4688:5;4677:16;;4671:27;;;;4705:128;;4785:42;4778:5;4774:54;4763:65;;4757:76;;;;4840:79;;4909:5;4898:16;;4892:27;;;;4926:95;;5005:10;4998:5;4994:22;4983:33;;4977:44;;;",
"sources": ["/Users/leonidlogvinov/Dev/0x/0x-monorepo/packages/metacoin/contracts/Metacoin.sol"]
}
}
}

View File

@@ -7,7 +7,7 @@
"build:watch": "tsc -w",
"lint": "tslint --project .",
"clean": "shx rm -rf lib",
"prebuild": "run-s clean generate_contract_wrappers copy_artifacts",
"prebuild": "run-s clean compile generate_contract_wrappers copy_artifacts",
"copy_artifacts": "copyfiles './artifacts/**/*' './contracts/**/*' ./lib",
"build": "tsc",
"test": "run-s build run_mocha",

View File

@@ -0,0 +1,39 @@
{
"name": "@0xproject/resolver",
"version": "0.0.1",
"description": "Import resolver for smart contracts dependencies",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"build:watch": "tsc -w",
"build": "yarn clean && tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
"clean": "shx rm -rf lib scripts",
"lint": "tslint --project .",
"manual:postpublish": "yarn build; node ./scripts/postpublish.js"
},
"repository": {
"type": "git",
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/0xProject/0x-monorepo/issues"
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/resolver/README.md",
"devDependencies": {
"@0xproject/monorepo-scripts": "^0.1.16",
"@0xproject/tslint-config": "^0.4.14",
"copyfiles": "^1.2.0",
"shx": "^0.2.2",
"tslint": "5.8.0",
"typescript": "2.7.1"
},
"dependencies": {
"@0xproject/typescript-typings": "^0.0.3",
"@0xproject/types": "^0.6.0",
"lodash": "^4.17.4"
},
"publishConfig": {
"access": "public"
}
}

View File

@@ -0,0 +1,8 @@
export { ContractSource, ContractSources } from './types';
export { FallthroughResolver } from './resolvers/fallthrough_resolver';
export { URLResolver } from './resolvers/url_resolver';
export { NPMResolver } from './resolvers/npm_resolver';
export { FSResolver } from './resolvers/fs_resolver';
export { NameResolver } from './resolvers/name_resolver';
export { EnumerableResolver } from './resolvers/enumerable_resolver';
export { Resolver } from './resolvers/resolver';

View File

@@ -0,0 +1,7 @@
import { ContractSource } from '../types';
import { Resolver } from './resolver';
export abstract class EnumerableResolver extends Resolver {
public abstract getAllContracts(): ContractSource[];
}

View File

@@ -0,0 +1,21 @@
import * as _ from 'lodash';
import { ContractSource } from '../types';
import { Resolver } from './resolver';
export class FallthroughResolver extends Resolver {
private _resolvers: Resolver[] = [];
public appendResolver(resolver: Resolver): void {
this._resolvers.push(resolver);
}
public resolveIfExists(importPath: string): ContractSource | undefined {
for (const resolver of this._resolvers) {
const contractSourceIfExists = resolver.resolveIfExists(importPath);
if (!_.isUndefined(contractSourceIfExists)) {
return contractSourceIfExists;
}
}
return undefined;
}
}

View File

@@ -0,0 +1,19 @@
import * as fs from 'fs';
import { ContractSource } from '../types';
import { Resolver } from './resolver';
export class FSResolver extends Resolver {
// tslint:disable-next-line:prefer-function-over-method
public resolveIfExists(importPath: string): ContractSource | undefined {
if (fs.existsSync(importPath)) {
const fileContent = fs.readFileSync(importPath).toString();
return {
source: fileContent,
path: importPath,
};
}
return undefined;
}
}

View File

@@ -0,0 +1,66 @@
import * as fs from 'fs';
import * as _ from 'lodash';
import * as path from 'path';
import { ContractSource } from '../types';
import { EnumerableResolver } from './enumerable_resolver';
export class NameResolver extends EnumerableResolver {
private _contractsDir: string;
constructor(contractsDir: string) {
super();
this._contractsDir = contractsDir;
}
public resolveIfExists(lookupContractName: string): ContractSource | undefined {
const SOLIDITY_FILE_EXTENSION = '.sol';
let contractSource: ContractSource | undefined;
const onFile = (filePath: string) => {
const contractName = path.basename(filePath, SOLIDITY_FILE_EXTENSION);
if (contractName === lookupContractName) {
const source = fs.readFileSync(filePath).toString();
contractSource = {
source,
path: filePath,
};
return true;
}
return undefined;
};
this._traverseContractsDir(this._contractsDir, onFile);
return contractSource;
}
public getAllContracts(): ContractSource[] {
const SOLIDITY_FILE_EXTENSION = '.sol';
const contractSources: ContractSource[] = [];
const onFile = (filePath: string) => {
const contractName = path.basename(filePath, SOLIDITY_FILE_EXTENSION);
const source = fs.readFileSync(filePath).toString();
const contractSource = {
source,
path: filePath,
};
contractSources.push(contractSource);
};
this._traverseContractsDir(this._contractsDir, onFile);
return contractSources;
}
// tslint:disable-next-line:prefer-function-over-method
private _traverseContractsDir(dirPath: string, onFile: (filePath: string) => true | void): boolean {
let dirContents: string[] = [];
try {
dirContents = fs.readdirSync(dirPath);
} catch (err) {
throw new Error(`No directory found at ${dirPath}`);
}
for (const fileName of dirContents) {
const entryPath = path.join(dirPath, fileName);
const isDirectory = fs.lstatSync(entryPath).isDirectory();
const isComplete = isDirectory ? this._traverseContractsDir(entryPath, onFile) : onFile(entryPath);
if (isComplete) {
return isComplete;
}
}
return false;
}
}

View File

@@ -0,0 +1,34 @@
import * as fs from 'fs';
import * as path from 'path';
import { ContractSource } from '../types';
import { Resolver } from './resolver';
export class NPMResolver extends Resolver {
private _packagePath: string;
constructor(packagePath: string) {
super();
this._packagePath = packagePath;
}
public resolveIfExists(importPath: string): ContractSource | undefined {
if (!importPath.startsWith('/')) {
const [packageName, ...other] = importPath.split('/');
const pathWithinPackage = path.join(...other);
let currentPath = this._packagePath;
const ROOT_PATH = '/';
while (currentPath !== ROOT_PATH) {
const lookupPath = path.join(currentPath, 'node_modules', packageName, pathWithinPackage);
if (fs.existsSync(lookupPath)) {
const fileContent = fs.readFileSync(lookupPath).toString();
return {
source: fileContent,
path: lookupPath,
};
}
currentPath = path.dirname(currentPath);
}
}
return undefined;
}
}

View File

@@ -0,0 +1,14 @@
import * as _ from 'lodash';
import { ContractSource } from '../types';
export abstract class Resolver {
public abstract resolveIfExists(importPath: string): ContractSource | undefined;
public resolve(importPath: string): ContractSource {
const contractSourceIfExists = this.resolveIfExists(importPath);
if (_.isUndefined(contractSourceIfExists)) {
throw new Error(`Failed to resolve ${importPath}`);
}
return contractSourceIfExists;
}
}

View File

@@ -0,0 +1,21 @@
import * as fs from 'fs';
import { ContractSource } from '../types';
import { Resolver } from './resolver';
export class URLResolver extends Resolver {
// tslint:disable-next-line:prefer-function-over-method
public resolveIfExists(importPath: string): ContractSource | undefined {
const FILE_URL_PREXIF = 'file://';
if (importPath.startsWith(FILE_URL_PREXIF)) {
const filePath = importPath.substr(FILE_URL_PREXIF.length);
const fileContent = fs.readFileSync(filePath).toString();
return {
source: fileContent,
path: importPath,
};
}
return undefined;
}
}

View File

@@ -0,0 +1,8 @@
export interface ContractSource {
source: string;
path: string;
}
export interface ContractSources {
[key: string]: ContractSource;
}

View File

@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib"
},
"include": ["src/**/*"]
}

View File

@@ -0,0 +1,3 @@
{
"extends": ["@0xproject/tslint-config"]
}

View File

@@ -7,13 +7,14 @@
"scripts": {
"build:watch": "tsc -w",
"lint": "tslint --project . 'src/**/*.ts'",
"test": "run-s clean build run_mocha",
"test": "run-s clean build compile_test run_mocha",
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
"test:circleci": "yarn test:coverage",
"run_mocha": "mocha lib/test/**/*_test.js --exit",
"clean": "shx rm -rf lib scripts",
"build": "copyfiles 'test/fixtures/**/*' ./lib && tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
"compile_test": "node ../deployer/lib/src/cli.js compile --contracts SimpleStorage --contracts-dir test/fixtures/contracts --artifacts-dir test/fixtures/artifacts",
"manual:postpublish": "yarn build; node ./scripts/postpublish.js",
"docs:stage": "yarn build && node ./scripts/stage_docs.js",
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES",
@@ -53,6 +54,7 @@
"solidity-parser-antlr": "^0.2.8"
},
"devDependencies": {
"@0xproject/deployer": "^0.3.5",
"@0xproject/monorepo-scripts": "^0.1.17",
"@0xproject/tslint-config": "^0.4.15",
"@types/istanbul": "^0.4.29",

View File

@@ -6,27 +6,17 @@ import * as path from 'path';
import { ContractData } from './types';
export const collectContractsData = (artifactsPath: string, sourcesPath: string, networkId: number) => {
const sourcesGlob = `${sourcesPath}/**/*.sol`;
const sourceFileNames = glob.sync(sourcesGlob, { absolute: true });
const contractsDataIfExists: Array<ContractData | {}> = _.map(sourceFileNames, sourceFileName => {
const baseName = path.basename(sourceFileName, '.sol');
const artifactFileName = path.join(artifactsPath, `${baseName}.json`);
if (!fs.existsSync(artifactFileName)) {
// If the contract isn't directly compiled, but is imported as the part of the other contract - we don't
// have an artifact for it and therefore can't do anything useful with it
return {};
}
const artifactsGlob = `${artifactsPath}/**/*.json`;
const artifactFileNames = glob.sync(artifactsGlob, { absolute: true });
const contractsDataIfExists: Array<ContractData | {}> = _.map(artifactFileNames, artifactFileName => {
const artifact = JSON.parse(fs.readFileSync(artifactFileName).toString());
const sources = artifact.networks[networkId].sources;
const sourceCodes = _.map(sources, (source: string) => {
const includedSourceCode = fs.readFileSync(source).toString();
return includedSourceCode;
});
const contractName = artifact.contract_name;
const sourceCodes = _.map(sources, (source: string) => fs.readFileSync(source).toString());
if (_.isUndefined(artifact.networks[networkId])) {
throw new Error(`No ${baseName} artifacts found for networkId ${networkId}`);
throw new Error(`No ${contractName} artifacts found for networkId ${networkId}`);
}
const contractData = {
baseName,
sourceCodes,
sources,
sourceMap: artifact.networks[networkId].source_map,

View File

@@ -79,7 +79,6 @@ export interface ContractData {
runtimeBytecode: string;
sourceMapRuntime: string;
sourceCodes: string[];
baseName: string;
sources: string[];
}

View File

@@ -16,7 +16,6 @@ describe('Collect contracts data', () => {
const contractsData = collectContractsData(artifactsPath, sourcesPath, networkId);
_.forEach(contractsData, contractData => {
expect(contractData).to.have.keys([
'baseName',
'sourceCodes',
'sources',
'sourceMap',

View File

@@ -39,13 +39,13 @@ describe('Collect coverage entries', () => {
const coverageEntries = collectCoverageEntries(simpleStorageContract);
const fnIds = _.keys(coverageEntries.fnMap);
expect(coverageEntries.fnMap[fnIds[0]].name).to.be.equal('set');
expect(coverageEntries.fnMap[fnIds[0]].line).to.be.equal(3);
expect(coverageEntries.fnMap[fnIds[0]].line).to.be.equal(5);
const setFunction = `function set(uint x) {
storedData = x;
}`;
expect(getRange(simpleStorageContract, coverageEntries.fnMap[fnIds[0]].loc)).to.be.equal(setFunction);
expect(coverageEntries.fnMap[fnIds[1]].name).to.be.equal('get');
expect(coverageEntries.fnMap[fnIds[1]].line).to.be.equal(6);
expect(coverageEntries.fnMap[fnIds[1]].line).to.be.equal(8);
const getFunction = `function get() constant returns (uint retVal) {
return storedData;
}`;

View File

@@ -1,64 +0,0 @@
{
"contract_name": "SimpleStorage",
"networks": {
"50": {
"solc_version": "0.4.21",
"keccak256": "0x18dc5b5a0e813c17e49936d2f2f7c07c51f050c09ba5e7206f17c855f23f4b6a",
"source_tree_hash": "0x18dc5b5a0e813c17e49936d2f2f7c07c51f050c09ba5e7206f17c855f23f4b6a",
"optimizer_enabled": 0,
"abi": [
{
"constant": true,
"inputs": [],
"name": "storedData",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "x",
"type": "uint256"
}
],
"name": "set",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "get",
"outputs": [
{
"name": "retVal",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
],
"bytecode":
"0x6060604052341561000f57600080fd5b6101098061001e6000396000f3006060604052600436106053576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632a1afcd914605857806360fe47b114607e5780636d4ce63c14609e575b600080fd5b3415606257600080fd5b606860c4565b6040518082815260200191505060405180910390f35b3415608857600080fd5b609c600480803590602001909190505060ca565b005b341560a857600080fd5b60ae60d4565b6040518082815260200191505060405180910390f35b60005481565b8060008190555050565b600080549050905600a165627a7a723058207f743855fd0c71699620424a21a257cd197ed05032d6768eb9b874e4898f44c60029",
"runtime_bytecode":
"0x6060604052600436106053576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632a1afcd914605857806360fe47b114607e5780636d4ce63c14609e575b600080fd5b3415606257600080fd5b606860c4565b6040518082815260200191505060405180910390f35b3415608857600080fd5b609c600480803590602001909190505060ca565b005b341560a857600080fd5b60ae60d4565b6040518082815260200191505060405180910390f35b60005481565b8060008190555050565b600080549050905600a165627a7a723058207f743855fd0c71699620424a21a257cd197ed05032d6768eb9b874e4898f44c60029",
"updated_at": 1521118350895,
"source_map": "26:196:0:-;;;;;;;;;;;;;;;;;",
"source_map_runtime":
"26:196:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;55:22;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;83:52;;;;;;;;;;;;;;;;;;;;;;;;;;140:80;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;55:22;;;;:::o;83:52::-;127:1;114:10;:14;;;;83:52;:::o;140:80::-;173:11;203:10;;196:17;;140:80;:::o",
"sources": ["SimpleStorage.sol"]
}
}
}

View File

@@ -1,20 +0,0 @@
{
"contract_name": "Simplest",
"networks": {
"50": {
"solc_version": "0.4.21",
"keccak256": "0x8e7d62e19c7c7b8bf9a4a43749e111605950cc877574fb9640a1a07d1c3749f9",
"source_tree_hash": "0x8e7d62e19c7c7b8bf9a4a43749e111605950cc877574fb9640a1a07d1c3749f9",
"optimizer_enabled": 0,
"abi": [],
"bytecode":
"0x60606040523415600e57600080fd5b603580601b6000396000f3006060604052600080fd00a165627a7a7230582097cfe05b4d18d6ffb3a8d8fab0570cf09640d3131b9677ddb9be4e9fbcb65f010029",
"runtime_bytecode":
"0x6060604052600080fd00a165627a7a7230582097cfe05b4d18d6ffb3a8d8fab0570cf09640d3131b9677ddb9be4e9fbcb65f010029",
"updated_at": 1521118525393,
"source_map": "26:21:0:-;;;;;;;;;;;;;;;;;",
"source_map_runtime": "26:21:0:-;;;;;",
"sources": ["Simplest.sol"]
}
}
}

View File

@@ -1,3 +1,5 @@
pragma solidity ^0.4.21;
contract SimpleStorage {
uint public storedData;
function set(uint x) {

View File

@@ -6,6 +6,25 @@
version "0.3.9"
resolved "https://registry.yarnpkg.com/8fold-marked/-/8fold-marked-0.3.9.tgz#bb89c645612f8ccfaffac1ca6e3c11f168c9cf59"
"@0xproject/deployer@^0.3.5":
version "0.3.5"
resolved "https://registry.yarnpkg.com/@0xproject/deployer/-/deployer-0.3.5.tgz#3b4144ac62cfbbe4fc7174cbf92f29594f411973"
dependencies:
"@0xproject/json-schemas" "^0.7.19"
"@0xproject/types" "^0.5.0"
"@0xproject/typescript-typings" "^0.0.3"
"@0xproject/utils" "^0.5.0"
"@0xproject/web3-wrapper" "^0.5.0"
ethereumjs-util "^5.1.1"
isomorphic-fetch "^2.2.1"
lodash "^4.17.4"
require-from-string "^2.0.1"
semver "^5.5.0"
solc "^0.4.18"
web3 "^0.20.0"
web3-eth-abi "^1.0.0-beta.24"
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"
@@ -64,6 +83,12 @@
dependencies:
bignumber.js "~4.1.0"
"@0xproject/types@^0.5.0":
version "0.5.0"
resolved "https://registry.yarnpkg.com/@0xproject/types/-/types-0.5.0.tgz#ba3cfbc11a8c6344b57c9680aa7df2ea84b9bf05"
dependencies:
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"
@@ -71,6 +96,13 @@
"@0xproject/types" "^0.4.2"
bignumber.js "~4.1.0"
"@0xproject/typescript-typings@^0.0.3":
version "0.0.3"
resolved "https://registry.yarnpkg.com/@0xproject/typescript-typings/-/typescript-typings-0.0.3.tgz#3272080bde00ade0a970b0d236686b483b08a1d0"
dependencies:
"@0xproject/types" "^0.5.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"
@@ -84,6 +116,17 @@
lodash "^4.17.4"
web3 "^0.20.0"
"@0xproject/web3-wrapper@^0.5.0":
version "0.5.0"
resolved "https://registry.yarnpkg.com/@0xproject/web3-wrapper/-/web3-wrapper-0.5.0.tgz#99a1acea60a5c3163ac0be28f4c0577c3d43dec4"
dependencies:
"@0xproject/types" "^0.5.0"
"@0xproject/typescript-typings" "^0.0.3"
"@0xproject/utils" "^0.5.0"
ethers-contracts "^2.2.1"
lodash "^4.17.4"
web3 "^0.20.0"
"@ledgerhq/hw-app-eth@^4.3.0":
version "4.7.3"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-eth/-/hw-app-eth-4.7.3.tgz#d352e19658ae296532e522c53c8ec2a1a77b64e5"
@@ -3254,6 +3297,10 @@ dot-prop@^4.1.0:
dependencies:
is-obj "^1.0.0"
dotenv@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-4.0.0.tgz#864ef1379aced55ce6f95debecdce179f7a0cd1d"
drbg.js@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/drbg.js/-/drbg.js-1.0.1.tgz#3e36b6c42b37043823cdbc332d58f31e2445480b"
@@ -3716,6 +3763,14 @@ ethjs-abi@0.1.8:
js-sha3 "0.5.5"
number-to-bn "1.7.0"
ethjs-abi@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/ethjs-abi/-/ethjs-abi-0.2.1.tgz#e0a7a93a7e81163a94477bad56ede524ab6de533"
dependencies:
bn.js "4.11.6"
js-sha3 "0.5.5"
number-to-bn "1.7.0"
ethjs-unit@0.1.6:
version "0.1.6"
resolved "https://registry.yarnpkg.com/ethjs-unit/-/ethjs-unit-0.1.6.tgz#c665921e476e87bce2a9d588a6fe0405b2c41699"
@@ -11959,3 +12014,10 @@ yauzl@^2.4.2:
dependencies:
buffer-crc32 "~0.2.3"
fd-slicer "~1.0.1"
zeppelin-solidity@1.8.0:
version "1.8.0"
resolved "https://registry.yarnpkg.com/zeppelin-solidity/-/zeppelin-solidity-1.8.0.tgz#049fcde7daea9fc85210f8c6db9f8cd1ab8a853a"
dependencies:
dotenv "^4.0.0"
ethjs-abi "^0.2.1"