Closed IvantheTricourne closed 4 years ago
Currently only missing the ability to do a custom query (i.e., w/ query params) to get balances for accounts.
EDIT: Resolved. HttpApiData codecs now use proper text formatting.
Current issue:
HttpApiData
codecs aren't working as intended
λ> let addr = Address "8148e31f7f9bce0cc5a38192116799aa4558e80f"
λ> (HasCodec.decode . HasCodec.encode $ addr) :: Either Text Address
Right (Address HexString "0x8148e31f7f9bce0cc5a38192116799aa4558e80f") -- correct
λ> (parseQueryParam . toQueryParam $ addr) :: Either Text Address
Right (Address HexString "0xefbfbd48efbfbd1f7fefbfbdefbfbd0cc5a3efbfbdefbfbd1167efbfbdefbfbd4558efbfbd0f")
This leads me to believe that cs
resolves into something that doesn't work, given that these codecs are defined based on HasCodec
instances of the Address
type.
instance HasCodec Address where
decode = Right . addressFromBytes
encode = addressToBytes
instance ToHttpApiData Address where
toQueryParam = cs . HasCodec.encode
instance FromHttpApiData Address where
parseQueryParam = HasCodec.decode . cs
EDIT: cs
resolves to the following:
instance ConvertibleStrings StrictText StrictByteString where
convertString = Data.Text.Encoding.encodeUtf8
instance ConvertibleStrings StrictByteString StrictText where
convertString = Data.Text.Encoding.decodeUtf8With Data.Text.Encoding.Error.lenientDecode
Closing until #200 is merged into master.
Closes #189.