hevm 0.17 → 0.20
raw patch · 5 files changed
+44/−8 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ EVM.Solidity: [_constructorInputs] :: SolcContract -> [(Text, AbiType)]
+ EVM.Solidity: constructorInputs :: Lens' SolcContract [(Text, AbiType)]
- EVM.Solidity: SolcContract :: W256 -> W256 -> ByteString -> ByteString -> Text -> Map Word32 Method -> Map W256 Event -> Seq SrcMap -> Seq SrcMap -> Value -> SolcContract
+ EVM.Solidity: SolcContract :: W256 -> W256 -> ByteString -> ByteString -> Text -> [(Text, AbiType)] -> Map Word32 Method -> Map W256 Event -> Seq SrcMap -> Seq SrcMap -> Value -> SolcContract
Files
- CHANGELOG.md +11/−0
- hevm.cabal +1/−1
- src/EVM.hs +8/−0
- src/EVM/Solidity.hs +15/−2
- src/EVM/TTY.hs +9/−5
CHANGELOG.md view
@@ -1,5 +1,16 @@ # hevm changelog +## 0.20 - 2018-10-27+ - Parse constructor inputs from Solidity AST++## 0.19 - 2018-10-09+ - Enable experimental 'cheat' address, allowing for modification of the+ EVM environment from within the tests. Currently just the block+ timestamp can be adjusted.++## 0.18 - 2018-10-09+ - Fix [duplicate address bug](https://github.com/dapphub/dapptools/issues/70)+ ## 0.17 - 2018-10-05 - Semigroup/Monoid fix
hevm.cabal view
@@ -1,7 +1,7 @@ name: hevm version:- 0.17+ 0.20 synopsis: Ethereum virtual machine evaluator description:
src/EVM.hs view
@@ -871,6 +871,10 @@ ) -> case xTo of n | n > 0 && n <= 8 -> precompiledContract+ n | num n == cheatCode ->+ do+ assign (state . stack) xs+ cheat (xInOffset, xInSize) (xOutOffset, xOutSize) _ -> let availableGas = the state gas@@ -1110,6 +1114,7 @@ initialContract createdCode & set storage (view storage now) & set balance (view balance now)+ & set nonce (view nonce now) resetState :: EVM () resetState = do@@ -1168,6 +1173,9 @@ -- * Cheat codes -- The cheat code is 7109709ecfa91a80626ff3989d68f67f5b1dd12d.+-- Call this address using one of the cheatActions below to do+-- special things, e.g. changing the block timestamp. Beware that+-- these are necessarily hevm specific. cheatCode :: Addr cheatCode = num (keccak "hevm cheat code")
src/EVM/Solidity.hs view
@@ -17,6 +17,7 @@ , abiMap , eventMap , contractName+ , constructorInputs , creationCode , makeSrcMaps , readSolc@@ -76,6 +77,7 @@ , _runtimeCode :: ByteString , _creationCode :: ByteString , _contractName :: Text+ , _constructorInputs :: [(Text, AbiType)] , _abiMap :: Map Word32 Method , _eventMap :: Map W256 Event , _runtimeSrcmap :: Seq SrcMap@@ -229,6 +231,8 @@ let theRuntimeCode = toCode (x ^?! key "bin-runtime" . _String) theCreationCode = toCode (x ^?! key "bin" . _String)+ abis =+ toList ((x ^?! key "abi" . _String) ^?! _Array) in (s, SolcContract { _runtimeCode = theRuntimeCode, _creationCode = theCreationCode,@@ -241,10 +245,19 @@ fromMaybe (error "JSON lacks abstract syntax trees.") (preview (ix (Text.split (== ':') s !! 0) . key "AST") asts),++ _constructorInputs =+ let+ isConstructor y =+ "constructor" == y ^?! key "type" . _String+ in+ case filter isConstructor abis of+ [abi] -> map parseMethodInput (toList (abi ^?! key "inputs" . _Array))+ [] -> [] -- default constructor has zero inputs+ _ -> error "strange: contract has multiple constructors",+ _abiMap = Map.fromList $ let- abis =- toList ((x ^?! key "abi" . _String) ^?! _Array) relevant = filter (\y -> "function" == y ^?! key "type" . _String) abis in flip map relevant $
src/EVM/TTY.hs view
@@ -11,6 +11,7 @@ import Brick.Widgets.List import EVM+import EVM.ABI (abiTypeSolidity) import EVM.Concrete (Word (C)) import EVM.Dapp (DappInfo, dappInfo) import EVM.Dapp (dappUnitTests, dappSolcByName, dappSolcByHash, dappSources)@@ -531,11 +532,14 @@ [ borderWithLabel (txt "Contract information") . padBottom Max . padRight (Pad 2) $ vBox [ txt "Name: " <+> txt (contractNamePart (view contractName solc)) , txt "File: " <+> txt (contractPathPart (view contractName solc))- , txt " "- , txt "Public methods:"- , vBox . flip map (sort (Map.elems (view abiMap solc))) $- \method -> txt (" " <> view methodSignature method)- ]+ , txt " "+ , txt "Constructor inputs:"+ , vBox . flip map (view constructorInputs solc) $+ \(name, abiType) -> txt (" " <> name <> ": " <> abiTypeSolidity abiType)+ , txt "Public methods:"+ , vBox . flip map (sort (Map.elems (view abiMap solc))) $+ \method -> txt (" " <> view methodSignature method)+ ] , borderWithLabel (txt "Storage slots") . padBottom Max . padRight Max $ vBox (map txt (storageLayout dapp solc)) ]