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

Fix sort ordering logic #696

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 12 additions & 9 deletions src/app/execution/txHelper.js
Expand Up @@ -32,20 +32,23 @@ module.exports = {
},

sortAbiFunction: function (contractabi) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you please add a comment above here explaining the order? e.g. constructor, fallback, constant functions, non-constant functions?

Copy link
Author

Choose a reason for hiding this comment

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

@axic Okay, added now.

var abi = contractabi.sort(function (a, b) {
if (a.name > b.name) {
return -1
} else {
// Sorts the list of ABI entries. Constant functions will appear first,
// followed by non-constant functions. Within those t wo groupings, functions
// will be sorted by their names.
return contractabi.sort(function (a, b) {
if (a.constant === true && b.constant !== true) {
return 1
}
}).sort(function (a, b) {
if (a.constant === true) {
} else if (b.constant === true && 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
}
})
return abi
},

getConstructorInterface: function (abi) {
Expand Down