Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

events refactor #174

Merged
merged 26 commits into from
Apr 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
99a3696
events refactor, function.js
debris Apr 20, 2015
ea6bda4
event refactor in progress
debris Apr 20, 2015
9d8a51d
event.js refactored
debris Apr 20, 2015
a88be00
docs
debris Apr 20, 2015
501e3bc
utils cleanup
debris Apr 20, 2015
eeb0bc0
Merge branch 'develop' into events_refactor
debris Apr 20, 2015
d38f5a2
Merge branch 'develop' into events_refactor
debris Apr 21, 2015
c8e5768
fixed log fields
debris Apr 21, 2015
f84a68c
changed the way functions are being called
debris Apr 21, 2015
d411492
call && sendTransaction
debris Apr 21, 2015
836529a
Merge branch 'develop' into events_refactor
debris Apr 21, 2015
e910736
eth_filter complex topics, #175
debris Apr 21, 2015
983e4b1
removed signature.js
debris Apr 22, 2015
888a970
coder.encodeParam, coder.decodeParam tests template
debris Apr 22, 2015
f767a9a
removed unused formatOutputHash, renamed formatXXXString to formatXXX…
debris Apr 22, 2015
76ced9a
basic tests for event encoding
debris Apr 22, 2015
4482d5b
Merge branch 'develop' into events_refactor
debris Apr 22, 2015
5f2eb33
fixed filters encoding null
debris Apr 22, 2015
1ac1ef9
cleaned event.encode test
debris Apr 22, 2015
9158ac7
removed unused function
debris Apr 22, 2015
93b323f
removed unused function findIndex from utils
debris Apr 22, 2015
b5eabd8
proper formatting event options
debris Apr 22, 2015
9f7d6a9
anonymous events implementation && tests
debris Apr 22, 2015
7c16dbf
one additional test for event encode
debris Apr 22, 2015
3d3db61
tests for decoding event logs
debris Apr 22, 2015
960e9c9
test for explicit sendTransaction && call
debris Apr 22, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
766 changes: 391 additions & 375 deletions dist/web3-light.js

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions dist/web3-light.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion dist/web3-light.min.js

Large diffs are not rendered by default.

766 changes: 391 additions & 375 deletions dist/web3.js

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions dist/web3.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions dist/web3.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/event_inc.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
var contract;

var update = function (err, x) {
document.getElementById('result').innerText = JSON.stringify(x);
document.getElementById('result').innerText = JSON.stringify(x, null, 2);
};

var createContract = function () {
Expand Down
4 changes: 2 additions & 2 deletions lib/solidity/coder.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ var coder = new SolidityCoder([
name: 'bytes',
match: 'prefix',
mode: 'bytes',
inputFormatter: f.formatInputString,
outputFormatter: f.formatOutputString
inputFormatter: f.formatInputBytes,
outputFormatter: f.formatOutputBytes
}),
new SolidityType({
name: 'real',
Expand Down
24 changes: 6 additions & 18 deletions lib/solidity/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ var formatInputInt = function (value) {
/**
* Formats input value to byte representation of string
*
* @method formatInputString
* @method formatInputBytes
* @param {String}
* @returns {SolidityParam}
*/
var formatInputString = function (value) {
var formatInputBytes = function (value) {
var result = utils.fromAscii(value, c.ETH_PADDING).substr(2);
return new SolidityParam('', formatInputInt(value.length).value, result);
};
Expand Down Expand Up @@ -141,17 +141,6 @@ var formatOutputUReal = function (param) {
return formatOutputUInt(param).dividedBy(new BigNumber(2).pow(128));
};

/**
* Should be used to format output hash
*
* @method formatOutputHash
* @param {SolidityParam}
* @returns {String} right-aligned output bytes formatted to hex
*/
var formatOutputHash = function (param) {
return "0x" + param.value;
};

/**
* Should be used to format output bool
*
Expand All @@ -166,11 +155,11 @@ var formatOutputBool = function (param) {
/**
* Should be used to format output string
*
* @method formatOutputString
* @method formatOutputBytes
* @param {SolidityParam} left-aligned hex representation of string
* @returns {String} ascii string
*/
var formatOutputString = function (param) {
var formatOutputBytes = function (param) {
// length might also be important!
return utils.toAscii(param.suffix);
};
Expand All @@ -189,16 +178,15 @@ var formatOutputAddress = function (param) {

module.exports = {
formatInputInt: formatInputInt,
formatInputString: formatInputString,
formatInputBytes: formatInputBytes,
formatInputBool: formatInputBool,
formatInputReal: formatInputReal,
formatOutputInt: formatOutputInt,
formatOutputUInt: formatOutputUInt,
formatOutputReal: formatOutputReal,
formatOutputUReal: formatOutputUReal,
formatOutputHash: formatOutputHash,
formatOutputBool: formatOutputBool,
formatOutputString: formatOutputString,
formatOutputBytes: formatOutputBytes,
formatOutputAddress: formatOutputAddress
};

10 changes: 0 additions & 10 deletions lib/solidity/param.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,5 @@ SolidityParam.prototype.shiftArray = function (length) {
return new SolidityParam('', prefix, suffix);
};

/**
* This method should be used to check if param is empty
*
* @method empty
* @return {Bool} true if is empty, otherwise false
*/
SolidityParam.prototype.empty = function () {
return !this.value.length && !this.prefix.length && !this.suffix.length;
};

module.exports = SolidityParam;

30 changes: 1 addition & 29 deletions lib/solidity/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,7 @@ var getConstructor = function (abi, numberOfArgs) {
})[0];
};

/**
* Filters all functions from input abi
*
* @method filterFunctions
* @param {Array} abi
* @returns {Array} abi array with filtered objects of type 'function'
*/
var filterFunctions = function (json) {
return json.filter(function (current) {
return current.type === 'function';
});
};

/**
* Filters all events from input abi
*
* @method filterEvents
* @param {Array} abi
* @returns {Array} abi array with filtered objects of type 'event'
*/
var filterEvents = function (json) {
return json.filter(function (current) {
return current.type === 'event';
});
};

module.exports = {
getConstructor: getConstructor,
filterFunctions: filterFunctions,
filterEvents: filterEvents
getConstructor: getConstructor
};

43 changes: 20 additions & 23 deletions lib/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
You should have received a copy of the GNU Lesser General Public License
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file utils.js
* @authors:
* Marek Kotewicz <marek@ethdev.com>
/**
* @file utils.js
* @author Marek Kotewicz <marek@ethdev.com>
* @date 2015
*/

Expand Down Expand Up @@ -67,22 +67,6 @@ var padLeft = function (string, chars, sign) {
return new Array(chars - string.length + 1).join(sign ? sign : "0") + string;
};

/** Finds first index of array element matching pattern
*
* @method findIndex
* @param {Array}
* @param {Function} pattern
* @returns {Number} index of element
*/
var findIndex = function (array, callback) {
var end = false;
var i = 0;
for (; i < array.length && !end; i++) {
end = callback(array[i]);
}
return end ? i - 1 : -1;
};

/**
* Should be called to get sting from it's hex representation
*
Expand Down Expand Up @@ -142,6 +126,22 @@ var fromAscii = function(str, pad) {
return "0x" + hex;
};

/**
* Should be used to create full function/event name from json abi
*
* @method transformToFullName
* @param {Object} json-abi
* @return {String} full fnction/event name
*/
var transformToFullName = function (json) {
if (json.name.indexOf('(') !== -1) {
return json.name;
}

var typeName = json.inputs.map(function(i){return i.type; }).join();
return json.name + '(' + typeName + ')';
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably call this abi instead of json for clarity.

/**
* Should be called to get display name of contract function
*
Expand Down Expand Up @@ -198,9 +198,6 @@ var fromDecimal = function (value) {
var toHex = function (val) {
/*jshint maxcomplexity:7 */

if(val === null || typeof val === 'undefined')
return val;

if (isBoolean(val))
return fromDecimal(+val);

Expand Down Expand Up @@ -451,12 +448,12 @@ var isJson = function (str) {

module.exports = {
padLeft: padLeft,
findIndex: findIndex,
toHex: toHex,
toDecimal: toDecimal,
fromDecimal: fromDecimal,
toAscii: toAscii,
fromAscii: fromAscii,
transformToFullName: transformToFullName,
extractDisplayName: extractDisplayName,
extractTypeName: extractTypeName,
toWei: toWei,
Expand Down
Loading