geniusyield / atlas

Application backend for Plutus smart contracts on Cardano
https://atlas-app.io
Apache License 2.0
67 stars 18 forks source link

Invalid kupo value JSON decoder #319

Closed t4ccer closed 4 months ago

t4ccer commented 4 months ago

JSON decoder for KupoValue is invalid. It expect assets keys to be always in form <cs>.<tn> but when token name is empty kupo omits the dot as well. KupoValue uses GYValue parser under the hood.

Atlas version 09ab04bb6c6eb393ec4cae3fa078c38b59ab2b0f Kupo version 2.8.0

Error:

KupoApiError "UtxoByRef" (DecodeFailure "Error in $[0].value.assets: .: not enough input" (Response {responseStatusCode = Status {statusCode = 200, statusMessage = "OK"}, responseHeaders = fromList [("Transfer-Encoding","chunked"),("Date","Mon, 08 Jul 2024 19:44:20 GMT"),("Server","kupo"),("X-Most-Recent-Checkpoint","53811823"),("ETag","aa9c60907ba7f70a2a723080b214c16cb3e58f617f3cc727cc5c1a6aa7e3d086"),("Content-Type","application/json;charset=utf-8"),("Access-Control-Allow-Origin","*")], responseHttpVersion = HTTP/1.1, responseBody = "[{\"transaction_index\":3,\"transaction_id\":\"3113b2ed36da9d0e8277f43e4cd53503e0552be2ae50b95100023e5158099542\",\"output_index\":3,\"address\":\"addr_test1wrpfqv65kts4aaz0tftafwv95fh460lnc5s7h69hckd06lgq7su4r\",\"value\":{\"coins\":1762790,\"assets\":{\"604eed076ac858d58278d943f3ae79f9a0ea958712cd50dda49c0a8b\":1}},\"datum_hash\":\"8ffb085299340929a6c62686374f8f86fd873da55c523fd88fd2981e6fc74e10\",\"datum_type\":\"inline\",\"script_hash\":null,\"created_at\":{\"slot_no\":53784599,\"header_hash\":\"0c09cf6f26ea010673d1226b5e0cf5150863cf4c513a083f53afe0822da4770d\"},\"spent_at\":null}]"}))

I've patched GYValue parser to be more flexible here but the actual (non-breaking) fix would be probably to implement a proper parser for kupo values that does not change GYValue as others depend on JSON instances already.

sourabhxyz commented 4 months ago

Thanks for identifying it! It should be fixed by this PR, please have a look.