Unverified Commit c1120cfa authored by yann300's avatar yann300 Committed by GitHub

Fix sort ordering logic

parent 0c2ac20d
...@@ -31,20 +31,23 @@ module.exports = { ...@@ -31,20 +31,23 @@ module.exports = {
}, },
sortAbiFunction: function (contractabi) { sortAbiFunction: function (contractabi) {
var abi = contractabi.sort(function (a, b) { // Sorts the list of ABI entries. Constant functions will appear first,
if (a.name > b.name) { // followed by non-constant functions. Within those t wo groupings, functions
return -1 // will be sorted by their names.
} else { return contractabi.sort(function (a, b) {
if (a.constant === true && b.constant !== true) {
return 1 return 1
} } else if (b.constant === true && a.constant !== true) {
}).sort(function (a, b) {
if (a.constant === true) {
return -1 return -1
} else { }
// If we reach here, either a and b are both constant or both not; sort by name then
// special case for fallback and constructor
if (a.type === 'function' && typeof a.name !== 'undefined') {
return a.name.localeCompare(b.name)
} else if (a.type === 'constructor' || a.type === 'fallback') {
return 1 return 1
} }
}) })
return abi
}, },
getConstructorInterface: function (abi) { getConstructorInterface: function (abi) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment