mirror of https://github.com/status-im/web3.js.git
default log formatter, improved contract test
This commit is contained in:
parent
e9b5da4b1d
commit
f4e5a99be1
|
@ -1128,7 +1128,6 @@ var c = require('./utils/config');
|
|||
var Method = require('./web3/method');
|
||||
var Property = require('./web3/property');
|
||||
|
||||
/// @returns an array of objects describing web3 api methods
|
||||
var web3Methods = [
|
||||
new Method({
|
||||
name: 'sha3',
|
||||
|
@ -1170,7 +1169,9 @@ web3.providers = {};
|
|||
web3.version = {};
|
||||
web3.version.api = version.version;
|
||||
web3.eth = {};
|
||||
web3.eth.filter = function (fil, eventParams, options) {
|
||||
|
||||
/*jshint maxparams:4 */
|
||||
web3.eth.filter = function (fil, eventParams, options, formatter) {
|
||||
|
||||
// if its event, treat it differently
|
||||
// TODO: simplify and remove
|
||||
|
@ -1179,8 +1180,10 @@ web3.eth.filter = function (fil, eventParams, options) {
|
|||
}
|
||||
|
||||
// what outputLogFormatter? that's wrong
|
||||
return new Filter(fil, watches.eth(), formatters.outputLogFormatter);
|
||||
//return new Filter(fil, watches.eth(), formatters.outputLogFormatter);
|
||||
return new Filter(fil, watches.eth(), formatter || formatters.outputLogFormatter);
|
||||
};
|
||||
/*jshint maxparams:3 */
|
||||
|
||||
web3.shh = {};
|
||||
web3.shh.filter = function (fil) {
|
||||
|
@ -1916,10 +1919,10 @@ var outputParser = function (event) {
|
|||
args: {}
|
||||
};
|
||||
|
||||
output.topics = output.topic; // fallback for go-ethereum
|
||||
if (!output.topics) {
|
||||
return result;
|
||||
}
|
||||
output.data = output.data || '';
|
||||
|
||||
var indexedOutputs = filterInputs(event.inputs, true);
|
||||
var indexedData = "0x" + output.topics.slice(1, output.topics.length).map(function (topics) { return topics.slice(2); }).join("");
|
||||
|
@ -2216,7 +2219,6 @@ var outputLogFormatter = function(log){
|
|||
return log;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Formats the input of a whisper post and converts all values to HEX
|
||||
*
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1128,7 +1128,6 @@ var c = require('./utils/config');
|
|||
var Method = require('./web3/method');
|
||||
var Property = require('./web3/property');
|
||||
|
||||
/// @returns an array of objects describing web3 api methods
|
||||
var web3Methods = [
|
||||
new Method({
|
||||
name: 'sha3',
|
||||
|
@ -1170,7 +1169,9 @@ web3.providers = {};
|
|||
web3.version = {};
|
||||
web3.version.api = version.version;
|
||||
web3.eth = {};
|
||||
web3.eth.filter = function (fil, eventParams, options) {
|
||||
|
||||
/*jshint maxparams:4 */
|
||||
web3.eth.filter = function (fil, eventParams, options, formatter) {
|
||||
|
||||
// if its event, treat it differently
|
||||
// TODO: simplify and remove
|
||||
|
@ -1179,8 +1180,10 @@ web3.eth.filter = function (fil, eventParams, options) {
|
|||
}
|
||||
|
||||
// what outputLogFormatter? that's wrong
|
||||
return new Filter(fil, watches.eth(), formatters.outputLogFormatter);
|
||||
//return new Filter(fil, watches.eth(), formatters.outputLogFormatter);
|
||||
return new Filter(fil, watches.eth(), formatter || formatters.outputLogFormatter);
|
||||
};
|
||||
/*jshint maxparams:3 */
|
||||
|
||||
web3.shh = {};
|
||||
web3.shh.filter = function (fil) {
|
||||
|
@ -1916,10 +1919,10 @@ var outputParser = function (event) {
|
|||
args: {}
|
||||
};
|
||||
|
||||
output.topics = output.topic; // fallback for go-ethereum
|
||||
if (!output.topics) {
|
||||
return result;
|
||||
}
|
||||
output.data = output.data || '';
|
||||
|
||||
var indexedOutputs = filterInputs(event.inputs, true);
|
||||
var indexedData = "0x" + output.topics.slice(1, output.topics.length).map(function (topics) { return topics.slice(2); }).join("");
|
||||
|
@ -2216,7 +2219,6 @@ var outputLogFormatter = function(log){
|
|||
return log;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Formats the input of a whisper post and converts all values to HEX
|
||||
*
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -91,7 +91,7 @@ web3.eth.filter = function (fil, eventParams, options, formatter) {
|
|||
|
||||
// what outputLogFormatter? that's wrong
|
||||
//return new Filter(fil, watches.eth(), formatters.outputLogFormatter);
|
||||
return new Filter(fil, watches.eth(), formatter);
|
||||
return new Filter(fil, watches.eth(), formatter || formatters.outputLogFormatter);
|
||||
};
|
||||
/*jshint maxparams:3 */
|
||||
|
||||
|
|
|
@ -140,7 +140,6 @@ var outputLogFormatter = function(log){
|
|||
return log;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Formats the input of a whisper post and converts all values to HEX
|
||||
*
|
||||
|
|
|
@ -33,6 +33,8 @@ var desc = [{
|
|||
"inputs": [
|
||||
{"name":"from","type":"address","indexed":true},
|
||||
{"name":"amount","type":"uint256","indexed":true},
|
||||
{"name":"t1","type":"uint256","indexed":false},
|
||||
{"name":"t2","type":"uint256","indexed":false}
|
||||
],
|
||||
}];
|
||||
|
||||
|
@ -52,7 +54,7 @@ describe('web3.eth.contract', function () {
|
|||
step = 1;
|
||||
assert.equal(payload.jsonrpc, '2.0');
|
||||
assert.equal(payload.method, 'web3_sha3');
|
||||
assert.equal(payload.params[0], web3.fromAscii('Changed(address,uint256)'));
|
||||
assert.equal(payload.params[0], web3.fromAscii('Changed(address,uint256,uint256,uint256)'));
|
||||
} else if (step === 1) {
|
||||
step = 2;
|
||||
provider.injectResult(3);
|
||||
|
@ -73,7 +75,9 @@ describe('web3.eth.contract', function () {
|
|||
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
||||
'0x0000000000000000000000000000000000000000000000000000000000000001'
|
||||
],
|
||||
number: 2
|
||||
number: 2,
|
||||
data: '0x0000000000000000000000000000000000000000000000000000000000000001' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000008'
|
||||
}]]);
|
||||
var r = payload.filter(function (p) {
|
||||
return p.jsonrpc === '2.0' && p.method === 'eth_getFilterChanges' && p.params[0] === 3;
|
||||
|
@ -88,6 +92,8 @@ describe('web3.eth.contract', function () {
|
|||
contract.Changed({from: address}).watch(function(err, result) {
|
||||
assert.equal(result.args.from, address);
|
||||
assert.equal(result.args.amount, 1);
|
||||
assert.equal(result.args.t1, 1);
|
||||
assert.equal(result.args.t2, 8);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue