-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Redo output format with interfaces instead of classes (also some bugfixes) #2180
Conversation
This commit fixes a bug where the debugger couldn't find the compiler for interfaces or abstract contracts. It also fixes an oversight where prerelease versions of 0.5.0 wouldn't be counted as 0.5.0.
…y in event decoder
OK, some last-minute additions:
(If you really don't like the labeled |
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.
Looks good! Definitely nice to see the direction this is going.
I spared you architecture thoughts, but the proliferation of long switch
statements is something we're going to have to deal with in the future.
OK, made the following changes (these are unrelated to Nick's review above):
(Mind you, we'll still crash if this happens outside of strict mode. But the question of how to handle this sort of thing outside of strict mode is, well, a question for another time.)
|
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.
👌
This PR does two things.
Firstly, it redoes the decoder output format with interfaces instead of classes. The format is still the same; just now it's with interfaces and functions instead of classes and method.
The reason it originally used classes was to get
util.inspect.custom
to work. However now instead we handle this problem but having a singleResultInspector
class which contains a singleResult
; instead of inspectingResult
s, when we want to print them we first wrap them in aResultInspector
.Similarly, the
nativize
method is now a function. ThetoSoliditySha3Input
method has been kind of split into two different functions. There's now a mapping key encoder in addition to the ABI encoder; that's what we now use for mapping keys instead oftoSoliditySha3Input
. However,key.ts
also contains a debugging function returning info for printing mapping keys. This is basically like the oldtoSoliditySha3Input
, except it's freed from the constraints of having to actually work as input to that function. :) (So don't use it for that, as it won't work for that anymore!)Secondly, this PR contains two bug fixes regarding compiler versions, one major and one minor. (Don't worry, these both only exist on
next
, notdevelop
.)The first bug fix is that, in order to determine what compiler a given user-defined type was compiled with, we would... do a complicated thing that was wrong, and involved looking it up in the context; this would run into a problem when the type was defined in an interface or abstract contract, as those don't get contexts. Now we do it the right way but just looking up the source ID in
data.info.scopes
and then getting the compiler fromsolidity.info.sources
.The second (really minor) bug fix is that I altered the compiler version check so it won't mistake prerelease versions of 0.5.0 as not being 0.5.x.