Browse Source

Merge commit 'ab745d3b0eb89d67db1ed953020c665be3d072ed' into develop

Conflicts:
	libjsqrc/ethereumjs/.travis.yml
	libjsqrc/ethereumjs/README.md
	libjsqrc/ethereumjs/dist/ethereum.js
	libjsqrc/ethereumjs/dist/ethereum.js.map
	libjsqrc/ethereumjs/lib/abi.js
	libjsqrc/ethereumjs/package.json
cl-refactor
Gav Wood 10 years ago
parent
commit
4c2de6d004
  1. 2
      alethzero/MainWin.cpp
  2. 5
      libethereum/Client.cpp
  3. 4
      libjsqrc/ethereumjs/.travis.yml
  4. 24
      libjsqrc/ethereumjs/README.md
  5. 12
      libjsqrc/ethereumjs/dist/ethereum.js
  6. 4
      libjsqrc/ethereumjs/dist/ethereum.js.map
  7. 2
      libjsqrc/ethereumjs/dist/ethereum.min.js
  8. 12
      libjsqrc/ethereumjs/lib/abi.js
  9. 6
      libjsqrc/ethereumjs/package.json
  10. 37
      libjsqrc/ethereumjs/test/abi.parsers.js
  11. 18
      libjsqrc/ethereumjs/test/db.methods.js
  12. 42
      libjsqrc/ethereumjs/test/eth.methods.js
  13. 2
      libjsqrc/ethereumjs/test/mocha.opts
  14. 19
      libjsqrc/ethereumjs/test/shh.methods.js
  15. 15
      libjsqrc/ethereumjs/test/utils.js
  16. 18
      libjsqrc/ethereumjs/test/web3.methods.js

2
alethzero/MainWin.cpp

@ -1274,7 +1274,7 @@ void Main::on_transactionQueue_currentItemChanged()
auto r = receipt.rlp(); auto r = receipt.rlp();
s << "<div>Receipt: " << toString(RLP(r)) << "</div>"; s << "<div>Receipt: " << toString(RLP(r)) << "</div>";
s << "<div>Receipt-Hex: <span style=\"font-family: Monospace,Lucida Console,Courier,Courier New,sans-serif; font-size: small\">" << toHex(receipt.rlp()) << "</span></div>"; s << "<div>Receipt-Hex: <span style=\"font-family: Monospace,Lucida Console,Courier,Courier New,sans-serif; font-size: small\">" << toHex(receipt.rlp()) << "</span></div>";
s << renderDiff(ethereum()->diff(i, -1)); s << renderDiff(ethereum()->diff(i, 0));
// s << "Pre: " << fs.rootHash() << "<br/>"; // s << "Pre: " << fs.rootHash() << "<br/>";
// s << "Post: <b>" << ts.rootHash() << "</b>"; // s << "Post: <b>" << ts.rootHash() << "</b>";
} }

5
libethereum/Client.cpp

@ -159,9 +159,10 @@ void Client::clearPending()
WriteGuard l(x_stateDB); WriteGuard l(x_stateDB);
if (!m_postMine.pending().size()) if (!m_postMine.pending().size())
return; return;
for (unsigned i = 0; i < m_postMine.pending().size(); ++i) // for (unsigned i = 0; i < m_postMine.pending().size(); ++i)
appendFromNewPending(m_postMine.logBloom(i), changeds); // appendFromNewPending(m_postMine.logBloom(i), changeds);
changeds.insert(PendingChangedFilter); changeds.insert(PendingChangedFilter);
m_tq.clear();
m_postMine = m_preMine; m_postMine = m_preMine;
} }

4
libjsqrc/ethereumjs/.travis.yml

@ -8,4 +8,6 @@ before_script:
script: script:
- "jshint *.js lib" - "jshint *.js lib"
after_script: after_script:
- npm run-script gulp - npm run-script build
- npm test

24
libjsqrc/ethereumjs/README.md

@ -50,13 +50,35 @@ web3.eth.coinbase.then(function(result){
For another example see `example/index.html`. For another example see `example/index.html`.
## Contribute!
### Requirements
* Node.js
* npm
* gulp (build)
* mocha (tests)
```bash
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
sudo apt-get install nodejs-legacy
```
## Building ## Building
* `gulp build` ```bash (gulp)
npm run-script build
```
### Testing ### Testing
```bash (mocha)
npm test
```
**Please note this repo is in it's early stage.** **Please note this repo is in it's early stage.**
If you'd like to run a WebSocket ethereum node check out If you'd like to run a WebSocket ethereum node check out

12
libjsqrc/ethereumjs/dist/ethereum.js

@ -93,6 +93,12 @@ var setupInputTypes = function () {
} }
var padding = calcPadding(type, expected); var padding = calcPadding(type, expected);
if (padding > 32)
return false; // not allowed to be so big.
padding = 32; // override as per the new ABI.
if (prefix === "string")
return web3.fromAscii(value, padding).substr(2);
if (typeof value === "number") if (typeof value === "number")
value = value.toString(16); value = value.toString(16);
else if (typeof value === "string") else if (typeof value === "string")
@ -111,6 +117,8 @@ var setupInputTypes = function () {
return false; return false;
} }
padding = 32; //override as per the new ABI.
return padLeft(formatter ? formatter(value) : value, padding * 2); return padLeft(formatter ? formatter(value) : value, padding * 2);
}; };
}; };
@ -166,12 +174,16 @@ var setupOutputTypes = function () {
} }
var padding = calcPadding(type, expected); var padding = calcPadding(type, expected);
if (padding > 32)
return -1; // not allowed to be so big.
padding = 32; // override as per the new ABI.
return padding * 2; return padding * 2;
}; };
}; };
var namedType = function (name, padding) { var namedType = function (name, padding) {
return function (type) { return function (type) {
padding = 32; // override as per the new ABI.
return name === type ? padding * 2 : -1; return name === type ? padding * 2 : -1;
}; };
}; };

4
libjsqrc/ethereumjs/dist/ethereum.js.map

File diff suppressed because one or more lines are too long

2
libjsqrc/ethereumjs/dist/ethereum.min.js

File diff suppressed because one or more lines are too long

12
libjsqrc/ethereumjs/lib/abi.js

@ -92,6 +92,12 @@ var setupInputTypes = function () {
} }
var padding = calcPadding(type, expected); var padding = calcPadding(type, expected);
if (padding > 32)
return false; // not allowed to be so big.
padding = 32; // override as per the new ABI.
if (prefix === "string")
return web3.fromAscii(value, padding).substr(2);
if (typeof value === "number") if (typeof value === "number")
value = value.toString(16); value = value.toString(16);
else if (typeof value === "string") else if (typeof value === "string")
@ -110,6 +116,8 @@ var setupInputTypes = function () {
return false; return false;
} }
padding = 32; //override as per the new ABI.
return padLeft(formatter ? formatter(value) : value, padding * 2); return padLeft(formatter ? formatter(value) : value, padding * 2);
}; };
}; };
@ -165,12 +173,16 @@ var setupOutputTypes = function () {
} }
var padding = calcPadding(type, expected); var padding = calcPadding(type, expected);
if (padding > 32)
return -1; // not allowed to be so big.
padding = 32; // override as per the new ABI.
return padding * 2; return padding * 2;
}; };
}; };
var namedType = function (name, padding) { var namedType = function (name, padding) {
return function (type) { return function (type) {
padding = 32; // override as per the new ABI.
return name === type ? padding * 2 : -1; return name === type ? padding * 2 : -1;
}; };
}; };

6
libjsqrc/ethereumjs/package.json

@ -25,12 +25,14 @@
"jshint": ">=2.5.0", "jshint": ">=2.5.0",
"uglifyify": "^2.6.0", "uglifyify": "^2.6.0",
"unreachable-branch-transform": "^0.1.0", "unreachable-branch-transform": "^0.1.0",
"vinyl-source-stream": "^1.0.0" "vinyl-source-stream": "^1.0.0",
"mocha": ">=2.1.0"
}, },
"scripts": { "scripts": {
"build": "gulp", "build": "gulp",
"watch": "gulp watch", "watch": "gulp watch",
"lint": "gulp lint" "lint": "gulp lint",
"test": "mocha"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

37
libjsqrc/ethereumjs/test/abi.parsers.js

@ -0,0 +1,37 @@
var assert = require('assert');
var abi = require('../lib/abi.js');
describe('abi', function() {
describe('inputParser', function() {
it('should parse ...', function() {
var desc = [{
"name": "multiply",
"inputs": [
{
"name": "a",
"type": "uint256"
}
],
"outputs": [
{
"name": "d",
"type": "uint256"
}
]
}];
var iParser = abi.inputParser(desc);
assert.equal(iParser.multiply(1), "0x000000000000000000000000000000000000000000000000000000000000000001");
});
});
describe('outputParser', function() {
it('parse ...', function() {
});
});
});

18
libjsqrc/ethereumjs/test/db.methods.js

@ -0,0 +1,18 @@
require('es6-promise').polyfill();
var assert = require('assert');
var web3 = require('../index.js');
var u = require('./utils.js');
web3.setProvider(new web3.providers.WebSocketProvider('http://localhost:8080')); // TODO: create some mock provider
describe('web3', function() {
describe('db', function() {
it('should have all methods implemented', function() {
u.methodExists(web3.db, 'put');
u.methodExists(web3.db, 'get');
u.methodExists(web3.db, 'putString');
u.methodExists(web3.db, 'getString');
});
});
});

42
libjsqrc/ethereumjs/test/eth.methods.js

@ -0,0 +1,42 @@
require('es6-promise').polyfill();
var assert = require('assert');
var web3 = require('../index.js');
var u = require('./utils.js');
web3.setProvider(new web3.providers.WebSocketProvider('http://localhost:8080')); // TODO: create some mock provider
describe('web3', function() {
describe('eth', function() {
it('should have all methods implemented', function() {
u.methodExists(web3.eth, 'balanceAt');
u.methodExists(web3.eth, 'stateAt');
u.methodExists(web3.eth, 'storageAt');
u.methodExists(web3.eth, 'countAt');
u.methodExists(web3.eth, 'codeAt');
u.methodExists(web3.eth, 'transact');
u.methodExists(web3.eth, 'call');
u.methodExists(web3.eth, 'block');
u.methodExists(web3.eth, 'transaction');
u.methodExists(web3.eth, 'uncle');
u.methodExists(web3.eth, 'compilers');
u.methodExists(web3.eth, 'lll');
u.methodExists(web3.eth, 'solidity');
u.methodExists(web3.eth, 'serpent');
u.methodExists(web3.eth, 'logs');
});
it('should have all properties implemented', function () {
u.propertyExists(web3.eth, 'coinbase');
u.propertyExists(web3.eth, 'listening');
u.propertyExists(web3.eth, 'mining');
u.propertyExists(web3.eth, 'gasPrice');
u.propertyExists(web3.eth, 'account');
u.propertyExists(web3.eth, 'accounts');
u.propertyExists(web3.eth, 'peerCount');
u.propertyExists(web3.eth, 'defaultBlock');
u.propertyExists(web3.eth, 'number');
});
});
});

2
libjsqrc/ethereumjs/test/mocha.opts

@ -0,0 +1,2 @@
--reporter Spec

19
libjsqrc/ethereumjs/test/shh.methods.js

@ -0,0 +1,19 @@
require('es6-promise').polyfill();
var assert = require('assert');
var web3 = require('../index.js');
var u = require('./utils.js');
web3.setProvider(new web3.providers.WebSocketProvider('http://localhost:8080')); // TODO: create some mock provider
describe('web3', function() {
describe('shh', function() {
it('should have all methods implemented', function() {
u.methodExists(web3.shh, 'post');
u.methodExists(web3.shh, 'newIdentity');
u.methodExists(web3.shh, 'haveIdentity');
u.methodExists(web3.shh, 'newGroup');
u.methodExists(web3.shh, 'addToGroup');
});
});
});

15
libjsqrc/ethereumjs/test/utils.js

@ -0,0 +1,15 @@
var assert = require('assert');
var methodExists = function (object, method) {
assert.equal('function', typeof object[method], 'method ' + method + ' is not implemented');
};
var propertyExists = function (object, property) {
assert.equal('object', typeof object[property], 'property ' + property + ' is not implemented');
};
module.exports = {
methodExists: methodExists,
propertyExists: propertyExists
};

18
libjsqrc/ethereumjs/test/web3.methods.js

@ -0,0 +1,18 @@
require('es6-promise').polyfill();
var assert = require('assert');
var web3 = require('../index.js');
var u = require('./utils.js');
web3.setProvider(new web3.providers.WebSocketProvider('http://localhost:8080')); // TODO: create some mock provider
describe('web3', function() {
it('should have all methods implemented', function() {
u.methodExists(web3, 'sha3');
u.methodExists(web3, 'toAscii');
u.methodExists(web3, 'fromAscii');
u.methodExists(web3, 'toFixed');
u.methodExists(web3, 'fromFixed');
u.methodExists(web3, 'offset');
});
});
Loading…
Cancel
Save