Skip to content

Commit

Permalink
[runtime-web] fixing HttpApiData for AssetId to handle TokenNames con…
Browse files Browse the repository at this point in the history
…taining `.`
  • Loading branch information
nhenin committed Aug 27, 2023
1 parent 9bf7160 commit 4ce99d6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions marlowe-runtime-web/src/Language/Marlowe/Runtime/Web/Types.hs
Expand Up @@ -246,9 +246,9 @@ instance ToParamSchema AssetId where
& pattern ?~ "^[a-fA-F0-9]*\\..*$"

instance FromHttpApiData AssetId where
parseUrlPiece piece = case splitOn "." piece of
[policyId, tokenName] -> AssetId <$> parseUrlPiece policyId <*> parseUrlPiece tokenName
_ -> Left "Expected ^[a-fA-F0-9]*\\..*$"
parseUrlPiece piece = case T.breakOn "." piece of
(_, "") -> Left "Expected ^[a-fA-F0-9]*(\\.).*$"
(policyId, tokenNameStartingWitPeriodCharacter) -> AssetId <$> parseUrlPiece policyId <*> parseUrlPiece (T.drop 1 tokenNameStartingWitPeriodCharacter)

instance ToHttpApiData AssetId where
toUrlPiece AssetId{..} = toUrlPiece policyId <> "." <> toUrlPiece assetName
Expand Down

0 comments on commit 4ce99d6

Please sign in to comment.