-
Notifications
You must be signed in to change notification settings - Fork 326
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
Hevm abi encode #868
base: master
Are you sure you want to change the base?
Hevm abi encode #868
Conversation
`hevm abiencode` now accepts solidity interface definitions: hevm abiencode --abi "f(bool b, uint x, Data(bytes[], string))" New commands `hevm normalise` and `hevm selector` to give the canonical signature and signature hash for a given --abi.
New command `hevm abidecode`, allowing for decoding of e.g. function calldata or returndata, given an ABI.
New command `hevm abi` to generate ABI json from a Solidity fragment. Works with functions, events and errors. Examples: seth abi "f(bool)" seth abi "function hello()" seth abi "event SomeEvent(bool x, string indexed s)" seth abi "error SomeError(string)"
CI failing because I broke The current
Here we should probably have instead:
|
in | ||
if (abiSelector == dataSelector) then | ||
pack $ show values | ||
pack $ intercalate "\n" (show <$> V.toList values) |
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.
pack $ intercalate "\n" (show <$> V.toList values) | |
pack $ unlines (show <$> V.toList values) |
and sim
Right (Nothing, Just event, _) -> render (JSON.toJSON event) | ||
Right (Nothing, Nothing, Just err) -> render (JSON.toJSON err) | ||
where | ||
render = decodeUtf8 . Lazy.toStrict . encoder |
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.
render = decodeUtf8 . Lazy.toStrict . encoder | |
render :: ToJSON a => a -> Text | |
render = decodeUtf8 . Lazy.toStrict . encoder |
ish
makeArray t "" = AbiArrayDynamicType t | ||
makeArray t s = AbiArrayType (read s) t | ||
|
||
parseBasicType :: ReadP AbiType |
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 would be nice to have in ABI.hs next to the show instance for AbiType. We can also easily quickcheck the roundtrip
lgtm |
Nearly complete. Fixes #861.
(...)
ortuple(...)
orWhatever(...)
--abi
argument for hevm now accepts solidity fragments as well as jsonhevm abi
-> output json for a given solidity fragment (functions, events and errors)hevm normalise
-> canonical signature for a given abihevm selector
-> signature hash for a given abi (cc @mds1)hevm abidecode
-> decode calldata and/or returndata given an abiNote:
hevm abidecode
, and therefore the results ofseth call
, will be quoted with"..."
. Previously string results were unquotedhevm abidecode
are now wrapped in[...]
. Previously the output was just comma separated elements.uint[][] [[1, 2], [3, 4]]
was output as1, 2, 3, 4
. This is now fixed.seth abi-encode
was renamed toseth --abi-encode
for consistency with--abi-decode
and now outputs the full calldata including signature.Todo:
seth --decode-events
to use hevm