@@ -21,14 +21,14 @@ import Network.Ethereum.Web3.Solidity.UInt (UIntN, unUIntN, uIntNFromBigNumber)
21
21
import Network.Ethereum.Web3.Solidity.Vector (Vector )
22
22
import Partial.Unsafe (unsafePartial )
23
23
import Text.Parsing.Parser (ParseError , Parser , ParserT , fail , runParser )
24
- import Text.Parsing.Parser.Token ( hexDigit )
24
+ import Text.Parsing.Parser.String ( anyChar )
25
25
26
26
-- | Class representing values that have an encoding and decoding instance to/from a solidity type.
27
27
class ABIEncode a where
28
28
toDataBuilder :: a -> HexString
29
29
30
30
class ABIDecode a where
31
- fromDataParser :: Parser String a
31
+ fromDataParser :: Parser HexString a
32
32
33
33
instance abiEncodeAlgebra :: ABIEncode BigNumber where
34
34
toDataBuilder = int256HexBuilder
@@ -38,7 +38,7 @@ instance abiDecodeAlgebra :: ABIDecode BigNumber where
38
38
39
39
-- | Parse encoded value, droping the leading `0x`
40
40
fromData :: forall a . ABIDecode a => HexString -> Either ParseError a
41
- fromData = flip runParser fromDataParser <<< unHex
41
+ fromData = flip runParser fromDataParser
42
42
43
43
instance abiEncodeBool :: ABIEncode Boolean where
44
44
toDataBuilder = uInt256HexBuilder <<< fromBool
@@ -156,11 +156,11 @@ uInt256HexBuilder x =
156
156
in padLeft x'
157
157
158
158
-- | Parse as a signed `BigNumber`
159
- int256HexParser :: forall m . Monad m => ParserT String m BigNumber
159
+ int256HexParser :: forall m . Monad m => ParserT HexString m BigNumber
160
160
int256HexParser = toBigNumberFromSignedHexString <$> take 64
161
161
162
162
-- | Parse an unsigned `BigNumber`
163
- uInt256HexParser :: forall m . Monad m => ParserT String m BigNumber
163
+ uInt256HexParser :: forall m . Monad m => ParserT HexString m BigNumber
164
164
uInt256HexParser = toBigNumber <$> take 64
165
165
166
166
-- | Decode a `Boolean` as a BigNumber
@@ -172,5 +172,5 @@ toBool :: BigNumber -> Boolean
172
172
toBool bn = not $ bn == zero
173
173
174
174
-- | Read any number of HexDigits
175
- take :: forall m . Monad m => Int -> ParserT String m HexString
176
- take n = unsafePartial fromJust <<< mkHexString <<< fromCharArray <$> replicateA n hexDigit
175
+ take :: forall m . Monad m => Int -> ParserT HexString m HexString
176
+ take n = unsafePartial fromJust <<< mkHexString <<< fromCharArray <$> replicateA n anyChar
0 commit comments