Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop' into feature/revert-strings
Browse files Browse the repository at this point in the history
  • Loading branch information
dekz authored Jun 5, 2018
2 parents 6210a54 + 3f11e63 commit 415e3c5
Show file tree
Hide file tree
Showing 19 changed files with 1,072 additions and 1,403 deletions.
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
language: node_js
node_js:
- "node"
- "lts/boron"
- "lts/carbon"

addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-4.7
- g++-4.7
- gcc-5
- g++-5

before_install:
- if [ $TRAVIS_OS_NAME == "linux" ]; then
export CC="gcc-4.7";
export CXX="g++-4.7";
export LINK="gcc-4.7";
export LINKXX="g++-4.7";
export CC="gcc-5";
export CXX="g++-5";
export LINK="gcc-5";
export LINKXX="g++-5";
fi
- nvm --version
- node --version
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This is the core code that powers the Ganache application and the the Ganache co

# INSTALL

`ganache-core` is written in Javascript and distributed as a Node package via `npm`. Make sure you have Node.js (>= v6.11.5) installed, and your environment is capable of installing and compiling `npm` modules.
`ganache-core` is written in Javascript and distributed as a Node package via `npm`. Make sure you have Node.js (>= v8.9.0) installed, and your environment is capable of installing and compiling `npm` modules.

**macOS** Make sure you have the XCode Command Line Tools installed. These are needed in general to be able to compile most C based languages on your machine, as well as many npm modules.

Expand Down
2 changes: 1 addition & 1 deletion lib/blockchain_double.js
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ BlockchainDouble.prototype.processTransactionTrace = function(hash, params, call
if (isMemoryEnabled) {
// Get memory and break it up into 32-byte words.
// Note we may possibly have to pad the final word.
memory = (new Buffer(event.memory)).toString("hex");
memory = (Buffer.from(event.memory)).toString("hex");
memory = memory.match(/.{1,64}/g) || [];

if (memory.length > 0) {
Expand Down
18 changes: 15 additions & 3 deletions lib/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ Provider.prototype.send = function(payload, callback) {
if (self.options.verbose) {
self.options.logger.log(" < " + JSON.stringify(response, null, 2).split("\n").join("\n < "));
}

callback(response.error ? err : null, response);
};

Expand Down Expand Up @@ -184,7 +183,7 @@ Provider.prototype.cleanUpErrorObject = function(err, response) {
return _.merge(response, errorObject)
}

// helper list of RPC methods which execute code and respond with a transaction has as their result
// helper list of RPC methods which execute code and respond with a transaction hash as their result
let transactionMethods = [
'eth_sendTransaction',
'eth_sendRawTransaction',
Expand All @@ -204,7 +203,6 @@ Provider.prototype.reportErrorInResponse = function(request, err, response) {
// field to prevent poorly-written clients which assume that the existence of
// the "result" field implies no errors from breaking.
if (self._isTransactionRequest(request)) {

if (err instanceof RuntimeError) {
// Make sure we always return the transaction hash on failed transactions so
// the caller can get their tx receipt. This breaks JSONRPC 2.0, but it's how
Expand All @@ -222,6 +220,20 @@ Provider.prototype.reportErrorInResponse = function(request, err, response) {
}
}

if (request.method === 'eth_call') {
if (err instanceof RuntimeError) {
if (self.options.vmErrorsOnRPCResponse) {
if(!response.error.data) {
response.error.data = {}
}
response.error.data[err.hashes[0]] = err.results[err.hashes[0]]
} else {
response.result = err.results[err.hashes[0]].return || '0x'
delete response.error
}
}
}

return self.cleanUpErrorObject(err, response)
}

Expand Down
6 changes: 3 additions & 3 deletions lib/statemanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ StateManager.prototype.getCode = function(address, number, callback) {
}

StateManager.prototype.queueRawTransaction = function(rawTx, callback) {
var data = new Buffer(utils.stripHexPrefix(rawTx), 'hex');
var data = Buffer.from(utils.stripHexPrefix(rawTx), 'hex');

var tx = new FakeTransaction(data);
var txParams = {
Expand Down Expand Up @@ -461,9 +461,9 @@ StateManager.prototype.sign = function(address, dataToSign) {
}

var secretKey = account.secretKey;
var msg = new Buffer(dataToSign.replace('0x',''), 'hex');
var msg = Buffer.from(dataToSign.replace('0x',''), 'hex');
var msgHash = utils.hashPersonalMessage(msg);
var sgn = utils.ecsign(msgHash, new Buffer(secretKey));
var sgn = utils.ecsign(msgHash, Buffer.from(secretKey));
return utils.toRpcSig(sgn.v, sgn.r, sgn.s);
};

Expand Down
2 changes: 1 addition & 1 deletion lib/subproviders/geth_api_double.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function GethApiDouble(options, provider) {

callbacks.forEach(function(callback) {
setImmediate(function() {
callback();
callback(self.initialization_error, self.state);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/random.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
buf.push(rng()*255);
}

return new Buffer(buf);
return Buffer.from(buf);
},

randomAlphaNumericString: function(length, rng) {
Expand Down
1 change: 1 addition & 0 deletions lib/utils/runtimeerror.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ RuntimeError.prototype.combine = function(transactions, vm_output) {
this.results[hash] = {
error: result.vm.exceptionError.error || result.vm.exceptionError,
program_counter: result.vm.runState.programCounter,
return: to.hex(result.vm.return),
reason: reason
};
}
Expand Down
4 changes: 4 additions & 0 deletions lib/utils/to.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ module.exports = {
}
}

if (typeof val == "boolean") {
val = val ? 1 : 0;
}

if (typeof val == "number") {
val = utils.intToHex(val);
}
Expand Down
Loading

0 comments on commit 415e3c5

Please sign in to comment.