Fix sort ordering logic

pull/3094/head
yann300 7 years ago committed by GitHub
parent 4ee0f43015
commit 70f63fead1
  1. 21
      remix-lib/src/execution/txHelper.js

@ -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) {

Loading…
Cancel
Save