Skip to content

Commit

Permalink
api: rename AddressUTXO to AddressUtxo
Browse files Browse the repository at this point in the history
  • Loading branch information
sorki committed Oct 11, 2021
1 parent cc07dfd commit 9be1f5d
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 51 deletions.
3 changes: 3 additions & 0 deletions 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`
Expand Down
2 changes: 1 addition & 1 deletion blockfrost-api/src/Blockfrost/API/Cardano/Addresses.hs
Expand Up @@ -37,7 +37,7 @@ data AddressesAPI route =
:> "utxos"
:> Pagination
:> Sorting
:> Get '[JSON] [AddressUTXO]
:> Get '[JSON] [AddressUtxo]
, _addressTransactions
:: route
:- Summary "Address transactions"
Expand Down
2 changes: 1 addition & 1 deletion blockfrost-api/src/Blockfrost/Lens.hs
Expand Up @@ -22,7 +22,7 @@ makeFields ''AccountMir

makeLensesWith blockfrostFieldRules ''AddressInfo
makeFields ''AddressDetails
makeFields ''AddressUTXO
makeFields ''AddressUtxo
makeFields ''AddressTransaction

makeFields ''AssetInfo
Expand Down
54 changes: 27 additions & 27 deletions blockfrost-api/src/Blockfrost/Types/Cardano/Addresses.hs
Expand Up @@ -4,7 +4,7 @@ module Blockfrost.Types.Cardano.Addresses
( AddressInfo (..)
, AddressType (..)
, AddressDetails (..)
, AddressUTXO (..)
, AddressUtxo (..)
, AddressTransaction (..)
) where

Expand Down Expand Up @@ -79,45 +79,45 @@ 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
"b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a76e7574636f696e"
unitScale
12
]
, _addressUTXOBlock = "5c571f83fe6c784d3fbc223792627ccf0eea96773100f9aedecf8b1eda4544d7"
, _addressUTXODataHash = Nothing
, _addressUtxoBlock = "5c571f83fe6c784d3fbc223792627ccf0eea96773100f9aedecf8b1eda4544d7"
, _addressUtxoDataHash = Nothing
}
]

Expand Down
44 changes: 22 additions & 22 deletions blockfrost-api/test/Cardano/Addresses.hs
Expand Up @@ -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
Expand Down Expand Up @@ -121,7 +121,7 @@ addressDetailsExpected =
]


addressUTXOsSample = [r|
addressUtxosSample = [r|
[
{
"tx_hash": "39a7a284c2a0948189dc45dec670211cd4d72f7b66c5726c08d9b3df11e44d58",
Expand Down Expand Up @@ -169,34 +169,34 @@ 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
"b0d07d45fe9514f80213f4020e5a61241458be626841cde717cb38a76e7574636f696e"
unitScale
12
]
, _addressUTXOBlock = "5c571f83fe6c784d3fbc223792627ccf0eea96773100f9aedecf8b1eda4544d7"
, _addressUTXODataHash = Nothing
, _addressUtxoBlock = "5c571f83fe6c784d3fbc223792627ccf0eea96773100f9aedecf8b1eda4544d7"
, _addressUtxoDataHash = Nothing
}
]

Expand Down

0 comments on commit 9be1f5d

Please sign in to comment.