-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,20 +32,20 @@ module.exports = { | |
}, | ||
|
||
sortAbiFunction: function (contractabi) { | ||
var abi = contractabi.sort(function (a, b) { | ||
if (a.name > b.name) { | ||
return -1 | ||
} else { | ||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, this shouldn't be locale specific I think. Also identifiers can be ASCII only. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is only used for display purposes it should be fine, though I'd add a comment. If this would be critical piece of code, either:
would be needed, because certain languages consider di/trigraphs with different sorting order. |
||
} else if (a.type === 'constructor' || a.type === 'fallback') { | ||
return 1 | ||
} | ||
}) | ||
return abi | ||
}, | ||
|
||
getConstructorInterface: function (abi) { | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@axic Okay, added now.