diff --git a/CHANGELOG.md b/CHANGELOG.md index b27996e8..cca37838 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## Next + +* `utxosAtAddresses` doesn't throw error when querying for empty addresses list against Maestro provider. + ## 0.14.1 * Added `utxosWithAsset` for efficiently querying of UTxOs containing a specified asset. diff --git a/src/GeniusYield/Providers/Maestro.hs b/src/GeniusYield/Providers/Maestro.hs index 9973eb28..24214581 100644 --- a/src/GeniusYield/Providers/Maestro.hs +++ b/src/GeniusYield/Providers/Maestro.hs @@ -313,7 +313,12 @@ maestroUtxosAtAddresses :: Maestro.MaestroEnv 'Maestro.V1 -> [GYAddress] -> IO G maestroUtxosAtAddresses env addrs = do let addrsInText = map addressToText addrs -- Here one would not get `MaestroNotFound` error. - addrUtxos <- handleMaestroError locationIdent <=< try $ Maestro.allPages (flip (Maestro.utxosAtMultiAddresses env (Just False) (Just False)) $ coerce addrsInText) + addrUtxos <- + if null addrs + then + pure [] + else + handleMaestroError locationIdent <=< try $ Maestro.allPages (flip (Maestro.utxosAtMultiAddresses env (Just False) (Just False)) $ coerce addrsInText) either (throwIO . MspvDeserializeFailure locationIdent) (pure . utxosFromList) (traverse utxoFromMaestro addrUtxos) where