Skip to content

Commit

Permalink
Merge pull request #62 from f-o-a-m/solc-0.6-support
Browse files Browse the repository at this point in the history
support solc 0.6+ stateMutability instead of constant/payable
  • Loading branch information
iostat committed Oct 3, 2020
2 parents e1349ae + d5bdfa7 commit f155141
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/Data/AbiParser.purs
Expand Up @@ -189,18 +189,31 @@ instance decodeJsonSolidityFunction :: DecodeJson SolidityFunction where
nm <- obj .: "name"
is <- obj .: "inputs"
os <- obj .: "outputs"
c <- obj .: "constant"
p <- obj .: "payable"
let parseStateMutability = do
sm <- obj .: "stateMutability"
str <- decodeJson sm
case str of
"pure" -> pure { constant: true, payable: false }
"view" -> pure { constant: true, payable: false }
"payable" -> pure { constant: false, payable: true }
"nonpayable" -> pure { constant: false, payable: false }
_ -> Left "Expecting \"stateMutabiltiy\" to be one of \"pure\", \"view\", \"payable\", or \"nonpayable\""
let parseConstantPayableFields = do
constant <- obj .: "constant"
payable <- obj .: "payable"
pure { constant, payable }
cp <- parseStateMutability <|> parseConstantPayableFields <|> (Left "Expected a \"stateMutability\" field or a combination of \"constant\" and \"payable\" fields")
pure $ SolidityFunction { name : nm
, inputs : is
, outputs : os
, constant : c
, payable: p
, constant : cp.constant
, payable: cp.payable
, isConstructor: false
, isUnCurried: all (\(FunctionInput fi) -> fi.name /= "") is
&& not (null is)
}


--------------------------------------------------------------------------------
-- | Solidity Constructor Parser
--------------------------------------------------------------------------------
Expand Down

0 comments on commit f155141

Please sign in to comment.