module EVM.StorageLayout where
import EVM.Dapp (DappInfo, dappAstSrcMap, dappAstIdMap)
import EVM.Solidity (SolcContract, creationSrcmap, SlotType(..))
import EVM.ABI (AbiType (..), parseTypeName)
import Data.Aeson (Value (..))
import Data.Aeson.Lens
import Control.Lens
import Data.Text (Text, unpack, pack, words)
import Data.Foldable (toList)
import Data.Maybe (fromMaybe, isJust)
import qualified Data.List.NonEmpty as NonEmpty
import qualified Data.Sequence as Seq
import Prelude hiding (words)
findContractDefinition :: DappInfo -> SolcContract -> Maybe Value
findContractDefinition :: DappInfo -> SolcContract -> Maybe Value
findContractDefinition DappInfo
dapp SolcContract
solc =
case Seq SrcMap -> ViewL SrcMap
forall a. Seq a -> ViewL a
Seq.viewl (Getting (Seq SrcMap) SolcContract (Seq SrcMap)
-> SolcContract -> Seq SrcMap
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting (Seq SrcMap) SolcContract (Seq SrcMap)
Lens' SolcContract (Seq SrcMap)
creationSrcmap SolcContract
solc) of
SrcMap
firstSrcMap Seq.:< Seq SrcMap
_ ->
(Getting (SrcMap -> Maybe Value) DappInfo (SrcMap -> Maybe Value)
-> DappInfo -> SrcMap -> Maybe Value
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting (SrcMap -> Maybe Value) DappInfo (SrcMap -> Maybe Value)
Lens' DappInfo (SrcMap -> Maybe Value)
dappAstSrcMap DappInfo
dapp) SrcMap
firstSrcMap
ViewL SrcMap
_ ->
Maybe Value
forall a. Maybe a
Nothing
storageLayout :: DappInfo -> SolcContract -> [Text]
storageLayout :: DappInfo -> SolcContract -> [Text]
storageLayout DappInfo
dapp SolcContract
solc =
let
root :: Value
root :: Value
root =
Value -> Maybe Value -> Value
forall a. a -> Maybe a -> a
fromMaybe Value
Null
(DappInfo -> SolcContract -> Maybe Value
findContractDefinition DappInfo
dapp SolcContract
solc)
in
case Getting (First (Vector Value)) Value (Vector Value)
-> Value -> Maybe (Vector Value)
forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview ( Text -> Traversal' Value Value
forall t. AsValue t => Text -> Traversal' t Value
key Text
"attributes"
((Value -> Const (First (Vector Value)) Value)
-> Value -> Const (First (Vector Value)) Value)
-> Getting (First (Vector Value)) Value (Vector Value)
-> Getting (First (Vector Value)) Value (Vector Value)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Traversal' Value Value
forall t. AsValue t => Text -> Traversal' t Value
key Text
"linearizedBaseContracts"
((Value -> Const (First (Vector Value)) Value)
-> Value -> Const (First (Vector Value)) Value)
-> Getting (First (Vector Value)) Value (Vector Value)
-> Getting (First (Vector Value)) Value (Vector Value)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (First (Vector Value)) Value (Vector Value)
forall t. AsValue t => Prism' t (Vector Value)
_Array
) Value
root of
Maybe (Vector Value)
Nothing ->
[]
Just (([Value] -> [Value]
forall a. [a] -> [a]
reverse ([Value] -> [Value])
-> (Vector Value -> [Value]) -> Vector Value -> [Value]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector Value -> [Value]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList) -> [Value]
linearizedBaseContracts) ->
((Value -> [Text]) -> [Value] -> [Text])
-> [Value] -> (Value -> [Text]) -> [Text]
forall a b c. (a -> b -> c) -> b -> a -> c
flip (Value -> [Text]) -> [Value] -> [Text]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap [Value]
linearizedBaseContracts
(\case
Number Scientific
i -> [Text] -> Maybe [Text] -> [Text]
forall a. a -> Maybe a -> a
fromMaybe ([Char] -> [Text]
forall a. HasCallStack => [Char] -> a
error [Char]
"malformed AST JSON") (Maybe [Text] -> [Text]) -> Maybe [Text] -> [Text]
forall a b. (a -> b) -> a -> b
$
Value -> Maybe [Text]
storageVariablesForContract (Value -> Maybe [Text]) -> Maybe Value -> Maybe [Text]
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<<
Getting (First Value) DappInfo Value -> DappInfo -> Maybe Value
forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview ((Map Int Value -> Const (First Value) (Map Int Value))
-> DappInfo -> Const (First Value) DappInfo
Lens' DappInfo (Map Int Value)
dappAstIdMap ((Map Int Value -> Const (First Value) (Map Int Value))
-> DappInfo -> Const (First Value) DappInfo)
-> ((Value -> Const (First Value) Value)
-> Map Int Value -> Const (First Value) (Map Int Value))
-> Getting (First Value) DappInfo Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index (Map Int Value)
-> Traversal' (Map Int Value) (IxValue (Map Int Value))
forall m. Ixed m => Index m -> Traversal' m (IxValue m)
ix (Scientific -> Int
forall a b. (RealFrac a, Integral b) => a -> b
floor Scientific
i)) DappInfo
dapp
Value
_ ->
[Char] -> [Text]
forall a. HasCallStack => [Char] -> a
error [Char]
"malformed AST JSON")
storageVariablesForContract :: Value -> Maybe [Text]
storageVariablesForContract :: Value -> Maybe [Text]
storageVariablesForContract Value
node = do
Text
name <- Getting (First Text) Value Text -> Value -> Maybe Text
forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview (Index Value -> Traversal' Value (IxValue Value)
forall m. Ixed m => Index m -> Traversal' m (IxValue m)
ix Index Value
"attributes" ((Value -> Const (First Text) Value)
-> Value -> Const (First Text) Value)
-> Getting (First Text) Value Text
-> Getting (First Text) Value Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Traversal' Value Value
forall t. AsValue t => Text -> Traversal' t Value
key Text
"name" ((Value -> Const (First Text) Value)
-> Value -> Const (First Text) Value)
-> Getting (First Text) Value Text
-> Getting (First Text) Value Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (First Text) Value Text
forall t. AsPrimitive t => Prism' t Text
_String) Value
node
[Value]
vars <-
(Vector Value -> [Value]) -> Maybe (Vector Value) -> Maybe [Value]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap
((Value -> Bool) -> [Value] -> [Value]
forall a. (a -> Bool) -> [a] -> [a]
filter Value -> Bool
isStorageVariableDeclaration ([Value] -> [Value])
-> (Vector Value -> [Value]) -> Vector Value -> [Value]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector Value -> [Value]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList)
(Getting (First (Vector Value)) Value (Vector Value)
-> Value -> Maybe (Vector Value)
forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview (Index Value -> Traversal' Value (IxValue Value)
forall m. Ixed m => Index m -> Traversal' m (IxValue m)
ix Index Value
"children" ((Value -> Const (First (Vector Value)) Value)
-> Value -> Const (First (Vector Value)) Value)
-> Getting (First (Vector Value)) Value (Vector Value)
-> Getting (First (Vector Value)) Value (Vector Value)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (First (Vector Value)) Value (Vector Value)
forall t. AsValue t => Prism' t (Vector Value)
_Array) Value
node)
[Text] -> Maybe [Text]
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([Text] -> Maybe [Text])
-> ((Value -> Text) -> [Text]) -> (Value -> Text) -> Maybe [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Value -> Text) -> [Value] -> [Text])
-> [Value] -> (Value -> Text) -> [Text]
forall a b c. (a -> b -> c) -> b -> a -> c
flip (Value -> Text) -> [Value] -> [Text]
forall a b. (a -> b) -> [a] -> [b]
map [Value]
vars ((Value -> Text) -> Maybe [Text])
-> (Value -> Text) -> Maybe [Text]
forall a b. (a -> b) -> a -> b
$
\Value
x ->
case Getting (First Text) Value Text -> Value -> Maybe Text
forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview (Text -> Traversal' Value Value
forall t. AsValue t => Text -> Traversal' t Value
key Text
"attributes" ((Value -> Const (First Text) Value)
-> Value -> Const (First Text) Value)
-> Getting (First Text) Value Text
-> Getting (First Text) Value Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Traversal' Value Value
forall t. AsValue t => Text -> Traversal' t Value
key Text
"name" ((Value -> Const (First Text) Value)
-> Value -> Const (First Text) Value)
-> Getting (First Text) Value Text
-> Getting (First Text) Value Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (First Text) Value Text
forall t. AsPrimitive t => Prism' t Text
_String) Value
x of
Just Text
variableName ->
[Text] -> Text
forall a. Monoid a => [a] -> a
mconcat
[ Text
variableName
, Text
" (", Text
name, Text
")"
, Text
"\n", Text
" Type: "
, [Char] -> Text
pack ([Char] -> Text) -> [Char] -> Text
forall a b. (a -> b) -> a -> b
$ SlotType -> [Char]
forall a. Show a => a -> [Char]
show (Value -> SlotType
slotTypeForDeclaration Value
x)
]
Maybe Text
Nothing ->
[Char] -> Text
forall a. HasCallStack => [Char] -> a
error [Char]
"malformed variable declaration"
nodeIs :: Text -> Value -> Bool
nodeIs :: Text -> Value -> Bool
nodeIs Text
t Value
x = Bool
isSourceNode Bool -> Bool -> Bool
&& Bool
hasRightName
where
isSourceNode :: Bool
isSourceNode =
Maybe Value -> Bool
forall a. Maybe a -> Bool
isJust (Getting (First Value) Value Value -> Value -> Maybe Value
forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview (Text -> Traversal' Value Value
forall t. AsValue t => Text -> Traversal' t Value
key Text
"src") Value
x)
hasRightName :: Bool
hasRightName =
Text -> Maybe Text
forall a. a -> Maybe a
Just Text
t Maybe Text -> Maybe Text -> Bool
forall a. Eq a => a -> a -> Bool
== Getting (First Text) Value Text -> Value -> Maybe Text
forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview (Text -> Traversal' Value Value
forall t. AsValue t => Text -> Traversal' t Value
key Text
"name" ((Value -> Const (First Text) Value)
-> Value -> Const (First Text) Value)
-> Getting (First Text) Value Text
-> Getting (First Text) Value Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (First Text) Value Text
forall t. AsPrimitive t => Prism' t Text
_String) Value
x
isStorageVariableDeclaration :: Value -> Bool
isStorageVariableDeclaration :: Value -> Bool
isStorageVariableDeclaration Value
x =
Text -> Value -> Bool
nodeIs Text
"VariableDeclaration" Value
x
Bool -> Bool -> Bool
&& Getting (First Bool) Value Bool -> Value -> Maybe Bool
forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview (Text -> Traversal' Value Value
forall t. AsValue t => Text -> Traversal' t Value
key Text
"attributes" ((Value -> Const (First Bool) Value)
-> Value -> Const (First Bool) Value)
-> Getting (First Bool) Value Bool
-> Getting (First Bool) Value Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Traversal' Value Value
forall t. AsValue t => Text -> Traversal' t Value
key Text
"constant" ((Value -> Const (First Bool) Value)
-> Value -> Const (First Bool) Value)
-> Getting (First Bool) Value Bool
-> Getting (First Bool) Value Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (First Bool) Value Bool
forall t. AsPrimitive t => Prism' t Bool
_Bool) Value
x Maybe Bool -> Maybe Bool -> Bool
forall a. Eq a => a -> a -> Bool
/= Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
True
slotTypeForDeclaration :: Value -> SlotType
slotTypeForDeclaration :: Value -> SlotType
slotTypeForDeclaration Value
node =
case Vector Value -> [Value]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (Vector Value -> [Value]) -> Maybe (Vector Value) -> Maybe [Value]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Getting (First (Vector Value)) Value (Vector Value)
-> Value -> Maybe (Vector Value)
forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview (Text -> Traversal' Value Value
forall t. AsValue t => Text -> Traversal' t Value
key Text
"children" ((Value -> Const (First (Vector Value)) Value)
-> Value -> Const (First (Vector Value)) Value)
-> Getting (First (Vector Value)) Value (Vector Value)
-> Getting (First (Vector Value)) Value (Vector Value)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (First (Vector Value)) Value (Vector Value)
forall t. AsValue t => Prism' t (Vector Value)
_Array) Value
node of
Just (Value
x:[Value]
_) ->
Value -> SlotType
grokDeclarationType Value
x
Maybe [Value]
_ ->
[Char] -> SlotType
forall a. HasCallStack => [Char] -> a
error [Char]
"malformed AST"
grokDeclarationType :: Value -> SlotType
grokDeclarationType :: Value -> SlotType
grokDeclarationType Value
x =
case Getting (First Text) Value Text -> Value -> Maybe Text
forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview (Text -> Traversal' Value Value
forall t. AsValue t => Text -> Traversal' t Value
key Text
"name" ((Value -> Const (First Text) Value)
-> Value -> Const (First Text) Value)
-> Getting (First Text) Value Text
-> Getting (First Text) Value Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (First Text) Value Text
forall t. AsPrimitive t => Prism' t Text
_String) Value
x of
Just Text
"Mapping" ->
case Getting (First (Vector Value)) Value (Vector Value)
-> Value -> Maybe (Vector Value)
forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview (Text -> Traversal' Value Value
forall t. AsValue t => Text -> Traversal' t Value
key Text
"children" ((Value -> Const (First (Vector Value)) Value)
-> Value -> Const (First (Vector Value)) Value)
-> Getting (First (Vector Value)) Value (Vector Value)
-> Getting (First (Vector Value)) Value (Vector Value)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (First (Vector Value)) Value (Vector Value)
forall t. AsValue t => Prism' t (Vector Value)
_Array) Value
x of
Just (Vector Value -> [Value]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList -> [Value]
xs) ->
[Value] -> SlotType
grokMappingType [Value]
xs
Maybe (Vector Value)
_ ->
[Char] -> SlotType
forall a. HasCallStack => [Char] -> a
error [Char]
"malformed AST"
Just Text
_ ->
AbiType -> SlotType
StorageValue (Value -> AbiType
grokValueType Value
x)
Maybe Text
_ ->
[Char] -> SlotType
forall a. HasCallStack => [Char] -> a
error ([Char]
"malformed AST " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ Value -> [Char]
forall a. Show a => a -> [Char]
show Value
x)
grokMappingType :: [Value] -> SlotType
grokMappingType :: [Value] -> SlotType
grokMappingType [Value
s, Value
t] =
case (Value -> SlotType
grokDeclarationType Value
s, Value -> SlotType
grokDeclarationType Value
t) of
(StorageValue AbiType
s', StorageMapping NonEmpty AbiType
t' AbiType
x) ->
NonEmpty AbiType -> AbiType -> SlotType
StorageMapping (AbiType -> NonEmpty AbiType -> NonEmpty AbiType
forall a. a -> NonEmpty a -> NonEmpty a
NonEmpty.cons AbiType
s' NonEmpty AbiType
t') AbiType
x
(StorageValue AbiType
s', StorageValue AbiType
t') ->
NonEmpty AbiType -> AbiType -> SlotType
StorageMapping (AbiType -> NonEmpty AbiType
forall (f :: * -> *) a. Applicative f => a -> f a
pure AbiType
s') AbiType
t'
(StorageMapping NonEmpty AbiType
_ AbiType
_, SlotType
_) ->
[Char] -> SlotType
forall a. HasCallStack => [Char] -> a
error [Char]
"unexpected mapping as mapping key"
grokMappingType [Value]
_ =
[Char] -> SlotType
forall a. HasCallStack => [Char] -> a
error [Char]
"unexpected AST child count for mapping"
grokValueType :: Value -> AbiType
grokValueType :: Value -> AbiType
grokValueType Value
x =
case ( Getting (First Text) Value Text -> Value -> Maybe Text
forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview (Text -> Traversal' Value Value
forall t. AsValue t => Text -> Traversal' t Value
key Text
"name" ((Value -> Const (First Text) Value)
-> Value -> Const (First Text) Value)
-> Getting (First Text) Value Text
-> Getting (First Text) Value Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (First Text) Value Text
forall t. AsPrimitive t => Prism' t Text
_String) Value
x
, Getting (First (Vector Value)) Value (Vector Value)
-> Value -> Maybe (Vector Value)
forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview (Text -> Traversal' Value Value
forall t. AsValue t => Text -> Traversal' t Value
key Text
"children" ((Value -> Const (First (Vector Value)) Value)
-> Value -> Const (First (Vector Value)) Value)
-> Getting (First (Vector Value)) Value (Vector Value)
-> Getting (First (Vector Value)) Value (Vector Value)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (First (Vector Value)) Value (Vector Value)
forall t. AsValue t => Prism' t (Vector Value)
_Array) Value
x
, Getting (First Text) Value Text -> Value -> Maybe Text
forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview (Text -> Traversal' Value Value
forall t. AsValue t => Text -> Traversal' t Value
key Text
"attributes" ((Value -> Const (First Text) Value)
-> Value -> Const (First Text) Value)
-> Getting (First Text) Value Text
-> Getting (First Text) Value Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Traversal' Value Value
forall t. AsValue t => Text -> Traversal' t Value
key Text
"type" ((Value -> Const (First Text) Value)
-> Value -> Const (First Text) Value)
-> Getting (First Text) Value Text
-> Getting (First Text) Value Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (First Text) Value Text
forall t. AsPrimitive t => Prism' t Text
_String) Value
x
) of
(Just Text
"ElementaryTypeName", Maybe (Vector Value)
_, Just Text
typeName) ->
AbiType -> Maybe AbiType -> AbiType
forall a. a -> Maybe a -> a
fromMaybe ([Char] -> AbiType
forall a. HasCallStack => [Char] -> a
error ([Char]
"ungrokked value type: " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ Text -> [Char]
forall a. Show a => a -> [Char]
show Text
typeName))
(Vector AbiType -> Text -> Maybe AbiType
parseTypeName Vector AbiType
forall a. Monoid a => a
mempty ([Text] -> Text
forall a. [a] -> a
head (Text -> [Text]
words Text
typeName)))
(Just Text
"UserDefinedTypeName", Maybe (Vector Value)
_, Maybe Text
_) ->
AbiType
AbiAddressType
(Just Text
"ArrayTypeName", (Vector Value -> [Value]) -> Maybe (Vector Value) -> Maybe [Value]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Vector Value -> [Value]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList -> Just [Value
t], Maybe Text
_)->
AbiType -> AbiType
AbiArrayDynamicType (Value -> AbiType
grokValueType Value
t)
(Just Text
"ArrayTypeName", (Vector Value -> [Value]) -> Maybe (Vector Value) -> Maybe [Value]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Vector Value -> [Value]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList -> Just [Value
t, Value
n], Maybe Text
_)->
case ( Getting (First Text) Value Text -> Value -> Maybe Text
forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview (Text -> Traversal' Value Value
forall t. AsValue t => Text -> Traversal' t Value
key Text
"name" ((Value -> Const (First Text) Value)
-> Value -> Const (First Text) Value)
-> Getting (First Text) Value Text
-> Getting (First Text) Value Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (First Text) Value Text
forall t. AsPrimitive t => Prism' t Text
_String) Value
n
, Getting (First Text) Value Text -> Value -> Maybe Text
forall s (m :: * -> *) a.
MonadReader s m =>
Getting (First a) s a -> m (Maybe a)
preview (Text -> Traversal' Value Value
forall t. AsValue t => Text -> Traversal' t Value
key Text
"attributes" ((Value -> Const (First Text) Value)
-> Value -> Const (First Text) Value)
-> Getting (First Text) Value Text
-> Getting (First Text) Value Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Traversal' Value Value
forall t. AsValue t => Text -> Traversal' t Value
key Text
"value" ((Value -> Const (First Text) Value)
-> Value -> Const (First Text) Value)
-> Getting (First Text) Value Text
-> Getting (First Text) Value Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (First Text) Value Text
forall t. AsPrimitive t => Prism' t Text
_String) Value
n
) of
(Just Text
"Literal", Just (([Char] -> Int
forall a. Read a => [Char] -> a
read ([Char] -> Int) -> (Text -> [Char]) -> Text -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> [Char]
unpack) -> Int
i)) ->
Int -> AbiType -> AbiType
AbiArrayType Int
i (Value -> AbiType
grokValueType Value
t)
(Maybe Text, Maybe Text)
_ ->
[Char] -> AbiType
forall a. HasCallStack => [Char] -> a
error [Char]
"malformed AST"
(Maybe Text, Maybe (Vector Value), Maybe Text)
_ ->
[Char] -> AbiType
forall a. HasCallStack => [Char] -> a
error ([Char]
"unknown value type " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ Value -> [Char]
forall a. Show a => a -> [Char]
show Value
x)