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
Conversation
thanks for that! we will push it. |
src/app/execution/txHelper.js
Outdated
// 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') { | ||
return a.name.localeCompare(b.name) |
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
localeCompare()
is the only native string-comparison function in Javascript; would you rather multiple separate calls to check greater, less, and equal?
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.
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:
- a manual implementation
- or setting the locale to ASCII English upfront
would be needed, because certain languages consider di/trigraphs with different sorting order.
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.
Please add a case for a.name === undefined
(case for fallback/constructor).
@MidnightLightning are you interested in finishing this? Would be a good feature to merge. |
a812f36
to
a7df88a
Compare
@axic Thanks for the reminder; updated now! |
@MidnightLightning could you rebase? |
a7df88a
to
ec8d84b
Compare
@yann300 Rebased now. |
sorry, there are some
|
@yann300 Coding standard errors fixed now. |
great! thanks |
@yann300 Any further changes needed on this one? GitHub's still indicating you as a reviewer have changes requested. |
@@ -32,20 +32,20 @@ module.exports = { | |||
}, | |||
|
|||
sortAbiFunction: function (contractabi) { |
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.
@yann300 anything left on this? |
moved, thanks @MidnightLightning |
Having two separate
sort
calls doesn't actually preserve the ordering of the first sort (by name) so only the second (constant vs. not) was being sorted on properly. This fix first checks to see if the two items have differentconstant
values, and only if theirconstant
values are the same does it then sort by name.