diff --git a/blockfrost-api/CHANGELOG.md b/blockfrost-api/CHANGELOG.md index 75b1b7c..a513d07 100644 --- a/blockfrost-api/CHANGELOG.md +++ b/blockfrost-api/CHANGELOG.md @@ -1,5 +1,8 @@ # Version [0.2.0.0](https://github.com/blockfrost/blockfrost-haskell/compare/0.1.0.0...0.2.0.0) (2021-10-14) +* Breaking changes + * `AddressUTXO` renamed to `AddressUtxo` along with its fields + * Alonzo additions * `collateral` field to `UtxoInput` * `redeemerCount` field to `Transaction` diff --git a/blockfrost-api/src/Blockfrost/API/Cardano/Addresses.hs b/blockfrost-api/src/Blockfrost/API/Cardano/Addresses.hs index f5fcd6b..33cbd35 100644 --- a/blockfrost-api/src/Blockfrost/API/Cardano/Addresses.hs +++ b/blockfrost-api/src/Blockfrost/API/Cardano/Addresses.hs @@ -37,7 +37,7 @@ data AddressesAPI route = :> "utxos" :> Pagination :> Sorting - :> Get '[JSON] [AddressUTXO] + :> Get '[JSON] [AddressUtxo] , _addressTransactions :: route :- Summary "Address transactions" diff --git a/blockfrost-api/src/Blockfrost/Lens.hs b/blockfrost-api/src/Blockfrost/Lens.hs index 77fc23c..dbf51aa 100644 --- a/blockfrost-api/src/Blockfrost/Lens.hs +++ b/blockfrost-api/src/Blockfrost/Lens.hs @@ -22,7 +22,7 @@ makeFields ''AccountMir makeLensesWith blockfrostFieldRules ''AddressInfo makeFields ''AddressDetails -makeFields ''AddressUTXO +makeFields ''AddressUtxo makeFields ''AddressTransaction makeFields ''AssetInfo diff --git a/blockfrost-api/src/Blockfrost/Types/Cardano/Addresses.hs b/blockfrost-api/src/Blockfrost/Types/Cardano/Addresses.hs index a5a363a..70bf5d0 100644 --- a/blockfrost-api/src/Blockfrost/Types/Cardano/Addresses.hs +++ b/blockfrost-api/src/Blockfrost/Types/Cardano/Addresses.hs @@ -4,7 +4,7 @@ module Blockfrost.Types.Cardano.Addresses ( AddressInfo (..) , AddressType (..) , AddressDetails (..) - , AddressUTXO (..) + , AddressUtxo (..) , AddressTransaction (..) ) where @@ -79,36 +79,36 @@ instance ToSample AddressDetails where ] -- | UTxOs of the address -data AddressUTXO = AddressUTXO - { _addressUTXOTxHash :: TxHash -- ^ Transaction hash of the UTXO - , _addressUTXOOutputIndex :: Integer -- ^ UTXO index in the transaction - , _addressUTXOAmount :: [Amount] -- ^ Amounts of Lovelaces or tokens - , _addressUTXOBlock :: BlockHash -- ^ Block hash of the UTXO - , _addressUTXODataHash :: Maybe Text -- ^ Block hash of the UTXO +data AddressUtxo = AddressUtxo + { _addressUtxoTxHash :: TxHash -- ^ Transaction hash of the UTXO + , _addressUtxoOutputIndex :: Integer -- ^ UTXO index in the transaction + , _addressUtxoAmount :: [Amount] -- ^ Amounts of Lovelaces or tokens + , _addressUtxoBlock :: BlockHash -- ^ Block hash of the UTXO + , _addressUtxoDataHash :: Maybe Text -- ^ Block hash of the UTXO } deriving stock (Show, Eq, Generic) deriving (FromJSON, ToJSON) - via CustomJSON '[FieldLabelModifier '[StripPrefix "_addressUTXO", CamelToSnake]] AddressUTXO + via CustomJSON '[FieldLabelModifier '[StripPrefix "_addressUtxo", CamelToSnake]] AddressUtxo -instance ToSample AddressUTXO where +instance ToSample AddressUtxo where toSamples = pure $ samples - [ AddressUTXO - { _addressUTXOTxHash = "39a7a284c2a0948189dc45dec670211cd4d72f7b66c5726c08d9b3df11e44d58" - , _addressUTXOOutputIndex = 0 - , _addressUTXOAmount = [ AdaAmount 42000000 ] - , _addressUTXOBlock = "7eb8e27d18686c7db9a18f8bbcfe34e3fed6e047afaa2d969904d15e934847e6" - , _addressUTXODataHash = Just "9e478573ab81ea7a8e31891ce0648b81229f408d596a3483e6f4f9b92d3cf710" + [ AddressUtxo + { _addressUtxoTxHash = "39a7a284c2a0948189dc45dec670211cd4d72f7b66c5726c08d9b3df11e44d58" + , _addressUtxoOutputIndex = 0 + , _addressUtxoAmount = [ AdaAmount 42000000 ] + , _addressUtxoBlock = "7eb8e27d18686c7db9a18f8bbcfe34e3fed6e047afaa2d969904d15e934847e6" + , _addressUtxoDataHash = Just "9e478573ab81ea7a8e31891ce0648b81229f408d596a3483e6f4f9b92d3cf710" } - , AddressUTXO - { _addressUTXOTxHash = "4c4e67bafa15e742c13c592b65c8f74c769cd7d9af04c848099672d1ba391b49" - , _addressUTXOOutputIndex = 0 - , _addressUTXOAmount = [ AdaAmount 729235000 ] - , _addressUTXOBlock = "953f1b80eb7c11a7ffcd67cbd4fde66e824a451aca5a4065725e5174b81685b7" - , _addressUTXODataHash = Nothing + , AddressUtxo + { _addressUtxoTxHash = "4c4e67bafa15e742c13c592b65c8f74c769cd7d9af04c848099672d1ba391b49" + , _addressUtxoOutputIndex = 0 + , _addressUtxoAmount = [ AdaAmount 729235000 ] + , _addressUtxoBlock = "953f1b80eb7c11a7ffcd67cbd4fde66e824a451aca5a4065725e5174b81685b7" + , _addressUtxoDataHash = Nothing } - , AddressUTXO - { _addressUTXOTxHash = "768c63e27a1c816a83dc7b07e78af673b2400de8849ea7e7b734ae1333d100d2" - , _addressUTXOOutputIndex = 1 - , _addressUTXOAmount = + , AddressUtxo + { _addressUtxoTxHash = "768c63e27a1c816a83dc7b07e78af673b2400de8849ea7e7b734ae1333d100d2" + , _addressUtxoOutputIndex = 1 + , _addressUtxoAmount = [ AdaAmount 42000000 , AssetAmount $ Money.mkSomeDiscrete @@ -116,8 +116,8 @@ instance ToSample AddressUTXO where unitScale 12 ] - , _addressUTXOBlock = "5c571f83fe6c784d3fbc223792627ccf0eea96773100f9aedecf8b1eda4544d7" - , _addressUTXODataHash = Nothing + , _addressUtxoBlock = "5c571f83fe6c784d3fbc223792627ccf0eea96773100f9aedecf8b1eda4544d7" + , _addressUtxoDataHash = Nothing } ] diff --git a/blockfrost-api/test/Cardano/Addresses.hs b/blockfrost-api/test/Cardano/Addresses.hs index 26da74d..f9d477e 100644 --- a/blockfrost-api/test/Cardano/Addresses.hs +++ b/blockfrost-api/test/Cardano/Addresses.hs @@ -33,9 +33,9 @@ spec_sample = do Right addressDetailsExpected it "parses address utxos sample" $ do - eitherDecode addressUTXOsSample + eitherDecode addressUtxosSample `shouldBe` - Right addressUTXOsExpected + Right addressUtxosExpected it "parses address transactions sample" $ do eitherDecode addressTransactionsSample @@ -121,7 +121,7 @@ addressDetailsExpected = ] -addressUTXOsSample = [r| +addressUtxosSample = [r| [ { "tx_hash": "39a7a284c2a0948189dc45dec670211cd4d72f7b66c5726c08d9b3df11e44d58", @@ -169,25 +169,25 @@ addressUTXOsSample = [r| ] |] -addressUTXOsExpected = - [ AddressUTXO - { _addressUTXOTxHash = "39a7a284c2a0948189dc45dec670211cd4d72f7b66c5726c08d9b3df11e44d58" - , _addressUTXOOutputIndex = 0 - , _addressUTXOAmount = [ AdaAmount 42000000 ] - , _addressUTXOBlock = "7eb8e27d18686c7db9a18f8bbcfe34e3fed6e047afaa2d969904d15e934847e6" - , _addressUTXODataHash = Just "9e478573ab81ea7a8e31891ce0648b81229f408d596a3483e6f4f9b92d3cf710" +addressUtxosExpected = + [ AddressUtxo + { _addressUtxoTxHash = "39a7a284c2a0948189dc45dec670211cd4d72f7b66c5726c08d9b3df11e44d58" + , _addressUtxoOutputIndex = 0 + , _addressUtxoAmount = [ AdaAmount 42000000 ] + , _addressUtxoBlock = "7eb8e27d18686c7db9a18f8bbcfe34e3fed6e047afaa2d969904d15e934847e6" + , _addressUtxoDataHash = Just "9e478573ab81ea7a8e31891ce0648b81229f408d596a3483e6f4f9b92d3cf710" } - , AddressUTXO - { _addressUTXOTxHash = "4c4e67bafa15e742c13c592b65c8f74c769cd7d9af04c848099672d1ba391b49" - , _addressUTXOOutputIndex = 0 - , _addressUTXOAmount = [ AdaAmount 729235000 ] - , _addressUTXOBlock = "953f1b80eb7c11a7ffcd67cbd4fde66e824a451aca5a4065725e5174b81685b7" - , _addressUTXODataHash = Nothing + , AddressUtxo + { _addressUtxoTxHash = "4c4e67bafa15e742c13c592b65c8f74c769cd7d9af04c848099672d1ba391b49" + , _addressUtxoOutputIndex = 0 + , _addressUtxoAmount = [ AdaAmount 729235000 ] + , _addressUtxoBlock = "953f1b80eb7c11a7ffcd67cbd4fde66e824a451aca5a4065725e5174b81685b7" + , _addressUtxoDataHash = Nothing } - , AddressUTXO - { _addressUTXOTxHash = "768c63e27a1c816a83dc7b07e78af673b2400de8849ea7e7b734ae1333d100d2" - , _addressUTXOOutputIndex = 1 - , _addressUTXOAmount = + , AddressUtxo + { _addressUtxoTxHash = "768c63e27a1c816a83dc7b07e78af673b2400de8849ea7e7b734ae1333d100d2" + , _addressUtxoOutputIndex = 1 + , _addressUtxoAmount = [ AdaAmount 42000000 , AssetAmount $ Money.mkSomeDiscrete @@ -195,8 +195,8 @@ addressUTXOsExpected = unitScale 12 ] - , _addressUTXOBlock = "5c571f83fe6c784d3fbc223792627ccf0eea96773100f9aedecf8b1eda4544d7" - , _addressUTXODataHash = Nothing + , _addressUtxoBlock = "5c571f83fe6c784d3fbc223792627ccf0eea96773100f9aedecf8b1eda4544d7" + , _addressUtxoDataHash = Nothing } ]