Skip to content

Commit

Permalink
Fix sort ordering logic
Browse files Browse the repository at this point in the history
  • Loading branch information
MidnightLightning committed Dec 18, 2017
1 parent f4e1f6c commit ec8d84b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/app/execution/txHelper.js
Expand Up @@ -32,16 +32,17 @@ module.exports = {
},

sortAbiFunction: function (contractabi) {
var abi = contractabi.sort(function (a, b) {
if (a.name > b.name) {
return -1
} else {
return 1
return contractabi.sort(function (a, b) {
if (a.constant === true && b.constant !== true) {
return 1;
} else if (b.constant === true && a.constant !== true) {
return -1;
}
}).sort(function (a, b) {
if (a.constant === true) {
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
}
})
Expand Down

0 comments on commit ec8d84b

Please sign in to comment.