remove .embark dir

This commit is contained in:
Iuri Matias 2017-12-05 18:17:56 -05:00
parent e2cbc2a488
commit b0019458b4
11 changed files with 1 additions and 751 deletions

View File

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2016
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,162 +0,0 @@
[![Build Status](https://travis-ci.org/ethereum/solc-js.svg?branch=master)](https://travis-ci.org/ethereum/solc-js)
# solc-js
JavaScript bindings for the [Solidity compiler](https://github.com/ethereum/solidity).
Uses the Emscripten compiled Solidity found in the [solc-bin repository](https://github.com/ethereum/solc-bin).
## Node.js Usage
To use the latest stable version of the Solidity compiler via Node.js you can install it via npm:
```bash
npm install solc
```
### Usage on the Command-Line
If this package is installed globally (`npm install -g solc`), a command-line tool called `solcjs` will be available.
To see all the supported features, execute:
```bash
solcjs --help
```
Note: this commandline interface is not compatible with `solc` provided by the Solidity compiler package and thus cannot be
used in combination with an Ethereum client via the `eth.compile.solidity()` RPC method. Please refer to the
[Solidity compiler documentation](https://solidity.readthedocs.io/) for instructions to install `solc`.
### Usage in Projects
#### From early versions
It can also be included and used in other projects:
```javascript
var solc = require('solc');
var input = 'contract x { function g() {} }';
var output = solc.compile(input, 1); // 1 activates the optimiser
for (var contractName in output.contracts) {
// code and ABI that are needed by web3
console.log(contractName + ': ' + output.contracts[contractName].bytecode);
console.log(contractName + '; ' + JSON.parse(output.contracts[contractName].interface));
}
```
#### From version 0.1.6
Starting from version 0.1.6, multiple files are supported with automatic import resolution by the compiler as follows:
```javascript
var solc = require('solc');
var input = {
'lib.sol': 'library L { function f() returns (uint) { return 7; } }',
'cont.sol': 'import "lib.sol"; contract x { function g() { L.f(); } }'
};
var output = solc.compile({sources: input}, 1);
for (var contractName in output.contracts)
console.log(contractName + ': ' + output.contracts[contractName].bytecode);
```
Note that all input files that are imported have to be supplied, the compiler will not load any additional files on its own.
#### From version 0.2.1
Starting from version 0.2.1, a callback is supported to resolve missing imports as follows:
```javascript
var solc = require('solc');
var input = {
'cont.sol': 'import "lib.sol"; contract x { function g() { L.f(); } }'
};
function findImports(path) {
if (path === 'lib.sol')
return { contents: 'library L { function f() returns (uint) { return 7; } }' }
else
return { error: 'File not found' }
}
var output = solc.compile({sources: input}, 1, findImports);
for (var contractName in output.contracts)
console.log(contractName + ': ' + output.contracts[contractName].bytecode);
```
The `compile()` method always returns an object, which can contain `errors`, `sources` and `contracts` fields. `errors` is a list of error mesages.
#### From version 0.4.11
Starting from version 0.4.11 there is a new entry point named `compileStandardWrapper()` which supports Solidity's [standard JSON input and output](https://solidity.readthedocs.io/en/develop/using-the-compiler.html#compiler-input-and-output-json-description). It also maps old compiler output to it.
**Note:**
If you are using Electron, `nodeIntegration` is on for `BrowserWindow` by default. If it is on, Electron will provide a `require` method which will not behave as expected and this may cause calls, such as `require('solc')`, to fail.
To turn off `nodeIntegration`, use the following:
```javascript
new BrowserWindow({
webPreferences: {
nodeIntegration: false
}
});
```
### Using a Legacy Version
In order to compile contracts using a specific version of Solidity, the `solc.useVersion` method is available. This returns a new `solc` object that uses a version of the compiler specified. **Note**: version strings must match the version substring of the files available in `/bin/soljson-*.js`. See below for an example.
```javascript
var solc = require('solc');
// by default the latest version is used
// ie: solc.useVersion('latest')
// getting a legacy version
var solcV011 = solc.useVersion('v0.1.1-2015-08-04-6ff4cd6');
var output = solcV011.compile('contract t { function g() {} }', 1);
```
If the version is not available locally, you can use `solc.loadRemoteVersion(version, callback)` to load it directly from GitHub.
You can also load the "binary" manually and use `setupMethods` to create the familiar wrapper functions described above:
`var solc = solc.setupMethods(require("/my/local/soljson.js"))`.
### Using the Latest Development Snapshot
By default, the npm version is only created for releases. This prevents people from deploying contracts with non-release versions because they are less stable and harder to verify. If you would like to use the latest development snapshot (at your own risk!), you may use the following example code.
```javascript
var solc = require('solc');
// getting the development snapshot
solc.loadRemoteVersion('latest', function(err, solcSnapshot) {
if (err) {
// An error was encountered, display and quit
}
var output = solcSnapshot.compile("contract t { function g() {} }", 1);
});
```
### Linking Bytecode
When using libraries, the resulting bytecode will contain placeholders for the real addresses of the referenced libraries. These have to be updated, via a process called linking, before deploying the contract.
The `linkBytecode` method provides a simple helper for linking:
```javascript
bytecode = solc.linkBytecode(bytecode, { 'MyLibrary': '0x123456...' });
```
Note: in future versions of Solidity a more sophisticated linker architecture will be introduced. Once that changes, this method will still be usable for output created by old versions of Solidity.
### Updating the ABI
The ABI generated by Solidity versions can differ slightly, due to new features introduced. There is a tool included which aims to translate the ABI generated by an older Solidity version to conform to the latest standard.
It can be used as:
```javascript
var abi = require('solc/abi');
var inputABI = [{"constant":false,"inputs":[],"name":"hello","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"}];
var outputABI = abi.update('0.3.6', inputABI)
// Output contains: [{"constant":false,"inputs":[],"name":"hello","outputs":[{"name":"","type":"string"}],"payable":true,"type":"function"},{"type":"fallback","payable":true}]
```

View File

@ -1,48 +0,0 @@
var semver = require('semver');
function update (compilerVersion, abi) {
var hasConstructor = false;
var hasFallback = false;
for (var i = 0; i < abi.length; i++) {
var item = abi[i];
if (item.type === 'constructor') {
hasConstructor = true;
// <0.4.5 assumed every constructor to be payable
if (semver.lt(compilerVersion, '0.4.5')) {
item.payable = true;
}
} else if (item.type === 'fallback') {
hasFallback = true;
}
// add 'payable' to everything
if (semver.lt(compilerVersion, '0.4.0')) {
item.payable = true;
}
}
// 0.1.2 from Aug 2015 had it. The code has it since May 2015 (e7931ade)
if (!hasConstructor && semver.lt(compilerVersion, '0.1.2')) {
abi.push({
type: 'constructor',
payable: true,
inputs: []
});
}
if (!hasFallback && semver.lt(compilerVersion, '0.4.0')) {
abi.push({
type: 'fallback',
payable: true
});
}
return abi;
}
module.exports = {
update: update
};

View File

@ -1,3 +0,0 @@
var wrapper = require('./wrapper.js');
module.exports = wrapper(require('./soljson.js'));

View File

@ -1,54 +0,0 @@
{
"name": "solc",
"version": "0.4.11",
"description": "Solidity compiler",
"main": "index.js",
"bin": {
"solcjs": "solcjs"
},
"scripts": {
"lint": "semistandard",
"prepublish": "./downloadCurrentVersion.js && ./verifyVersion.js",
"test": "tape ./test/index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ethereum/solc-js.git"
},
"keywords": [
"ethereum",
"solidity",
"compiler"
],
"files": [
"abi.js",
"index.js",
"solcjs",
"soljson.js",
"translate.js",
"wrapper.js"
],
"author": "chriseth",
"license": "MIT",
"bugs": {
"url": "https://github.com/ethereum/solc-js/issues"
},
"homepage": "https://github.com/ethereum/solc-js#readme",
"dependencies": {
"fs-extra": "^0.30.0",
"memorystream": "^0.3.1",
"require-from-string": "^1.1.0",
"semver": "^5.3.0",
"yargs": "^4.7.1"
},
"devDependencies": {
"semistandard": "^8.0.0",
"tape": "^4.5.1",
"tape-spawn": "^1.4.2"
},
"semistandard": {
"ignore": [
"soljson.js"
]
}
}

View File

@ -1,108 +0,0 @@
#!/usr/bin/env node
// hold on to any exception handlers that existed prior to this script running, we'll be adding them back at the end
var originalUncaughtExceptionListeners = process.listeners("uncaughtException");
var fs = require('fs-extra');
var path = require('path');
var solc = require('./index.js');
// FIXME: remove annoying exception catcher of Emscripten
// see https://github.com/chriseth/browser-solidity/issues/167
process.removeAllListeners('uncaughtException');
var yargs = require('yargs')
.usage('Usage: $0 [options] [input_file...]')
.option('version', {
describe: 'Show version and exit.',
type: 'boolean'
})
.option('optimize', {
describe: 'Enable bytecode optimizer.',
type: 'boolean'
})
.option('bin', {
describe: 'Binary of the contracts in hex.',
type: 'boolean'
})
.option('abi', {
describe: 'ABI of the contracts.',
type: 'boolean'
})
.option('standard-json', {
describe: 'Turn on Standard JSON Input / Output mode.',
type: 'boolean'
})
.option('output-dir', {
alias: 'o',
describe: 'Output directory for the contracts.',
type: 'string'
})
.global([ 'version', 'optimize' ])
.version(function() { return solc.version(); })
.showHelpOnFail(false, 'Specify --help for available options')
.help()
var argv = yargs.argv;
var files = argv._;
var destination = argv['output-dir'] || '.'
function abort (msg) {
console.log(msg || 'Error occured');
process.exit(1);
}
if (argv['standard-json']) {
if (!solc.supportsStandard) {
abort('Compiler does not support Standard JSON I/O');
}
var size = fs.fstatSync(process.stdin.fd).size;
if (size <= 0) {
abort('Empty input was read');
}
var input = fs.readSync(process.stdin.fd, size)[0];
console.log(solc.compileStandard(input));
process.exit(0);
} else if (files.length === 0) {
console.error('Must provide a file');
process.exit(1);
}
if (!(argv.bin || argv.abi)) {
abort('Invalid option selected');
}
var sources = {};
for (var i = 0; i < files.length; i++) {
try {
sources[ files[i] ] = fs.readFileSync(files[i]).toString();
} catch (e) {
abort('Error reading ' + files[i] + ': ' + e);
}
}
var output = solc.compile({ sources: sources }, argv.optimize ? 1 : 0);
if (!output) {
abort('No output from compiler');
} else if (output['errors']) {
for (var error in output['errors']) {
console.log(output['errors'][error]);
}
}
fs.ensureDirSync (destination);
for (var contractName in output.contracts) {
if (argv.bin) {
fs.writeFileSync(path.join(destination, contractName + '.bin'), output.contracts[contractName].bytecode);
}
if (argv.abi) {
fs.writeFileSync(path.join(destination, contractName + '.abi'), output.contracts[contractName].interface);
}
}
originalUncaughtExceptionListeners.forEach(function (listener) { process.addListener('uncaughtException', listener); });

File diff suppressed because one or more lines are too long

View File

@ -1,115 +0,0 @@
function translateErrors (ret, errors) {
for (var error in errors) {
var type = 'error';
var extractType = /^(.*):(\d+):(\d+):(.*):/;
extractType = extractType.exec(errors[error]);
if (extractType) {
type = extractType[4].trim();
} else if (errors[error].indexOf(': Warning:')) {
type = 'Warning';
} else if (errors[error].indexOf(': Error:')) {
type = 'Error';
}
ret.push({
type: type,
component: 'general',
severity: (type === 'Warning') ? 'warning' : 'error',
message: errors[error],
formattedMessage: errors[error]
});
}
}
function translateGasEstimates (gasEstimates) {
if (gasEstimates === null) {
return 'infinite';
}
if (typeof gasEstimates === 'number') {
return gasEstimates.toString();
}
var gasEstimatesTranslated = {};
for (var func in gasEstimates) {
gasEstimatesTranslated[func] = translateGasEstimates(gasEstimates[func]);
}
return gasEstimatesTranslated;
}
function translateJsonCompilerOutput (output) {
var ret = {};
ret['errors'] = [];
translateErrors(ret['errors'], output['errors']);
ret['contracts'] = {};
for (var contract in output['contracts']) {
// Split name first, can be `contract`, `:contract` or `filename:contract`
var tmp = contract.match(/^(([^:]*):)?([^:]+)$/);
if (tmp.length !== 4) {
// Force abort
return null;
}
var fileName = tmp[2];
if (fileName === undefined) {
// this is the case of `contract`
fileName = '';
}
var contractName = tmp[3];
var contractInput = output['contracts'][contract];
var gasEstimates = contractInput['gasEstimates'];
var contractOutput = {
'abi': JSON.parse(contractInput['interface']),
'metadata': contractInput['metadata'],
'evm': {
'legacyAssembly': contractInput['assembly'],
'bytecode': {
'object': contractInput['bytecode'],
'opcodes': contractInput['opcodes'],
'sourceMap': contractInput['srcmap']
},
'deployedBytecode': {
'object': contractInput['runtimeBytecode'],
'sourceMap': contractInput['srcmapRuntime']
},
'methodIdentifiers': contractInput['functionHashes'],
'gasEstimates': {
'creation': {
'codeDepositCost': translateGasEstimates(gasEstimates['creation'][1]),
'executionCost': translateGasEstimates(gasEstimates['creation'][0])
},
'internal': translateGasEstimates(gasEstimates['internal']),
'external': translateGasEstimates(gasEstimates['external'])
}
}
};
if (!ret['contracts'][fileName]) {
ret['contracts'][fileName] = {};
}
ret['contracts'][fileName][contractName] = contractOutput;
}
var sourceMap = {};
for (var sourceId in output['sourceList']) {
sourceMap[output['sourceList'][sourceId]] = sourceId;
}
ret['sources'] = {};
for (var source in output['sources']) {
ret['sources'][source] = {
id: sourceMap[source],
legacyAST: output['sources'][source]
};
}
return ret;
}
module.exports = {
translateJsonCompilerOutput: translateJsonCompilerOutput
};

View File

@ -1,217 +0,0 @@
var translate = require('./translate.js');
var requireFromString = require('require-from-string');
var https = require('https');
var MemoryStream = require('memorystream');
function setupMethods (soljson) {
var compileJSON = soljson.cwrap('compileJSON', 'string', ['string', 'number']);
var compileJSONMulti = null;
if ('_compileJSONMulti' in soljson) {
compileJSONMulti = soljson.cwrap('compileJSONMulti', 'string', ['string', 'number']);
}
var compileJSONCallback = null;
var compileStandard = null;
if (('_compileJSONCallback' in soljson) || ('_compileStandard' in soljson)) {
var copyString = function (str, ptr) {
var buffer = soljson._malloc(str.length + 1);
soljson.writeStringToMemory(str, buffer);
soljson.setValue(ptr, buffer, '*');
};
var wrapCallback = function (callback) {
return function (path, contents, error) {
var result = callback(soljson.Pointer_stringify(path));
if (typeof result.contents === 'string') {
copyString(result.contents, contents);
}
if (typeof result.error === 'string') {
copyString(result.error, error);
}
};
};
// This calls compile() with args || cb
var runWithReadCallback = function (readCallback, compile, args) {
if (readCallback === undefined) {
readCallback = function (path) {
return {
error: 'File import callback not supported'
};
};
}
var cb = soljson.Runtime.addFunction(wrapCallback(readCallback));
var output;
try {
args.push(cb);
output = compile.apply(undefined, args);
} catch (e) {
soljson.Runtime.removeFunction(cb);
throw e;
}
soljson.Runtime.removeFunction(cb);
return output;
};
var compileInternal = soljson.cwrap('compileJSONCallback', 'string', ['string', 'number', 'number']);
compileJSONCallback = function (input, optimize, readCallback) {
return runWithReadCallback(readCallback, compileInternal, [ input, optimize ]);
};
if ('_compileStandard' in soljson) {
var compileStandardInternal = soljson.cwrap('compileStandard', 'string', ['string', 'number']);
compileStandard = function (input, readCallback) {
return runWithReadCallback(readCallback, compileStandardInternal, [ input ]);
};
}
}
var compile = function (input, optimise, readCallback) {
var result = '';
if (readCallback !== undefined && compileJSONCallback !== null) {
result = compileJSONCallback(JSON.stringify(input), optimise, readCallback);
} else if (typeof input !== 'string' && compileJSONMulti !== null) {
result = compileJSONMulti(JSON.stringify(input), optimise);
} else {
result = compileJSON(input, optimise);
}
return JSON.parse(result);
};
// Expects a Standard JSON I/O but supports old compilers
var compileStandardWrapper = function (input, readCallback) {
if (compileStandard !== null) {
return compileStandard(input, readCallback);
}
function formatFatalError (message) {
return JSON.stringify({
errors: [
{
'type': 'SOLCError',
'component': 'solcjs',
'severity': 'error',
'message': message,
'formattedMessage': 'Error' + message
}
]
});
}
input = JSON.parse(input);
if (input['language'] !== 'Solidity') {
return formatFatalError('Only Solidity sources are supported');
}
if (input['sources'] == null) {
return formatFatalError('No input specified');
}
// Bail out early
if ((input['sources'].length > 1) && (compileJSONMulti === null)) {
return formatFatalError('Multiple sources provided, but compiler only supports single input');
}
function isOptimizerEnabled (input) {
return input['settings'] && input['settings']['optimizer'] && input['settings']['optimizer']['enabled'];
}
function translateSources (input) {
var sources = {};
for (var source in input['sources']) {
if (input['sources'][source]['content'] !== null) {
sources[source] = input['sources'][source]['content'];
} else {
// force failure
return null;
}
}
return sources;
}
function translateOutput (output) {
output = translate.translateJsonCompilerOutput(JSON.parse(output));
if (output == null) {
return formatFatalError('Failed to process output');
}
return JSON.stringify(output);
}
var sources = translateSources(input);
if (sources === null) {
return formatFatalError('Failed to process sources');
}
// Try to wrap around old versions
if (compileJSONCallback !== null) {
return translateOutput(compileJSONCallback(JSON.stringify({ 'sources': sources }), isOptimizerEnabled(input), readCallback));
}
if (compileJSONMulti !== null) {
return translateOutput(compileJSONMulti(JSON.stringify({ 'sources': sources }), isOptimizerEnabled(input)));
}
// Try our luck with an ancient compiler
return translateOutput(compileJSON(sources[0], isOptimizerEnabled(input)));
};
var linkBytecode = function (bytecode, libraries) {
for (var libraryName in libraries) {
// truncate to 37 characters
var internalName = libraryName.slice(0, 36);
// prefix and suffix with __
var libLabel = '__' + internalName + Array(37 - internalName.length).join('_') + '__';
var hexAddress = libraries[libraryName];
if (hexAddress.slice(0, 2) !== '0x' || hexAddress.length > 42) {
throw new Error('Invalid address specified for ' + libraryName);
}
// remove 0x prefix
hexAddress = hexAddress.slice(2);
hexAddress = Array(40 - hexAddress.length + 1).join('0') + hexAddress;
while (bytecode.indexOf(libLabel) >= 0) {
bytecode = bytecode.replace(libLabel, hexAddress);
}
}
return bytecode;
};
var version = soljson.cwrap('version', 'string', []);
return {
version: version,
compile: compile,
compileStandard: compileStandard,
compileStandardWrapper: compileStandardWrapper,
linkBytecode: linkBytecode,
supportsMulti: compileJSONMulti !== null,
supportsImportCallback: compileJSONCallback !== null,
supportsStandard: compileStandard !== null,
// Use the given version if available.
useVersion: function (versionString) {
return setupMethods(require('./bin/soljson-' + versionString + '.js'));
},
// Loads the compiler of the given version from the github repository
// instead of from the local filesystem.
loadRemoteVersion: function (versionString, cb) {
var mem = new MemoryStream(null, {readable: false});
var url = 'https://ethereum.github.io/solc-bin/bin/soljson-' + versionString + '.js';
https.get(url, function (response) {
if (response.statusCode !== 200) {
cb('Error retrieving binary: ' + response.statusMessage);
} else {
response.pipe(mem);
response.on('end', function () {
cb(null, setupMethods(requireFromString(mem.toString(), 'soljson-' + versionString + '.js')));
});
}
}).on('error', function (error) {
cb(error);
});
},
// Use this if you want to add wrapper functions around the pure module.
setupMethods: setupMethods
};
}
module.exports = setupMethods;

1
.gitignore vendored
View File

@ -14,3 +14,4 @@ test_app/node_modules/
test_app/chains.json test_app/chains.json
.idea .idea
.eslintrc.json .eslintrc.json
.embark/