Skip to content

Commit

Permalink
attempt #3 at fixing TokenName aeson
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Hunter committed May 24, 2022
1 parent ae94a3a commit 9f851d3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Types/TokenName.purs
Expand Up @@ -20,6 +20,7 @@ import Aeson
)
import Data.BigInt (BigInt)
import Data.Bitraversable (ltraverse)
import Data.Char (toCharCode)
import Data.Either (Either(Left), note)
import Data.Map (Map)
import Data.Map (fromFoldable) as Map
Expand All @@ -32,9 +33,9 @@ import Metadata.FromMetadata (class FromMetadata)
import Metadata.ToMetadata (class ToMetadata)
import Serialization.Types (AssetName) as CSL
import ToData (class ToData)
import Types.ByteArray (ByteArray, byteLength, hexToByteArray, byteArrayFromAscii)
import Types.ByteArray (ByteArray, byteLength, hexToByteArray, byteArrayFromAscii, byteArrayFromInt16ArrayUnsafe)
import Types.CborBytes (CborBytes, cborBytesToHex)
import Types.RawBytes (hexToRawBytesUnsafe)
import Data.String.CodeUnits (toCharArray)

newtype TokenName = TokenName CborBytes

Expand All @@ -50,7 +51,7 @@ instance DecodeAeson TokenName where
(Left $ TypeMismatch "Expected object")
(\aes -> do
tkstr <- getField aes "unTokenName"
case (mkTokenName <=< byteArrayFromAscii) tkstr of
case (mkTokenName <<< (byteArrayFromInt16ArrayUnsafe <<< map toCharCode <<< toCharArray)) tkstr of
Nothing -> Left $ TypeMismatch "Invalid TokenName"
Just tknm -> pure tknm)
-- note (TypeMismatch "Invalid TokenName") <<< mkTokenName
Expand Down

0 comments on commit 9f851d3

Please sign in to comment.