Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing lenses and ToCapture instances #46

Merged
merged 3 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion blockfrost-api/src/Blockfrost/API/Cardano/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Blockfrost.API.Cardano.Utils
import Data.Text
import Servant.API
import Servant.API.Generic
import Servant.Docs (DocCapture (..), ToCapture (..))

import Blockfrost.Types.Cardano.Utils
import Blockfrost.Types.Shared.CBOR
Expand All @@ -23,7 +24,7 @@ data UtilsAPI route =
:> "xpub"
:> Capture "xpub" Text
:> Capture "role" Integer
:> Capture "Index" Integer
:> Capture "index" Integer
:> Get '[JSON] DerivedAddress

, _txEvaluate
Expand All @@ -48,3 +49,12 @@ data UtilsAPI route =
:> Post '[JSON] TxEval

} deriving (Generic)

instance ToCapture (Capture "role" Integer) where
toCapture _ = DocCapture "role" "Account role"

instance ToCapture (Capture "index" Integer) where
toCapture _ = DocCapture "index" "Address index"

instance ToCapture (Capture "xpub" Text) where
toCapture _ = DocCapture "xpub" "Hexadecimal xpub"
11 changes: 11 additions & 0 deletions blockfrost-api/src/Blockfrost/Lens.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ makeFields ''AccountDelegation
makeFields ''AccountRegistration
makeFields ''AccountWithdrawal
makeFields ''AccountMir
makeFields ''AddressAssociatedTotal

makeLensesWith blockfrostFieldRules ''AddressInfo
makeLensesWith blockfrostFieldRules ''AddressInfoExtended
makeFields ''AddressDetails
makeFields ''AddressUtxo
makeFields ''AddressTransaction
Expand All @@ -32,6 +34,7 @@ makeFields ''AssetMetadata
makeFields ''AssetHistory
makeFields ''AssetTransaction
makeFields ''AssetAddress
makeFields ''MetadataMediaFile

makeFields ''Block

Expand All @@ -53,6 +56,7 @@ makeFieldsNoPrefix ''NetworkEraSummary
makeFieldsNoPrefix ''NetworkEraBound
makeFieldsNoPrefix ''NetworkEraParameters

makeFields ''Pool
makeFields ''PoolEpoch
makeFields ''PoolInfo
makeFields ''PoolHistory
Expand All @@ -77,6 +81,12 @@ makeFields ''TransactionMetaJSON
makeFields ''TransactionMetaCBOR
makeFields ''TransactionRedeemer

makeFields ''DerivedAddress
makeFields ''TxEval
makeFields ''TxEvalBudget
makeFields ''TxEvalResult
makeFields ''TxEvalInput

makeLensesWith blockfrostFieldRules ''IPFSAdd
makeLensesWith blockfrostFieldRules ''IPFSPinChange
makeLensesWith blockfrostFieldRules ''IPFSPin
Expand All @@ -88,3 +98,4 @@ makeFields ''NutlinkTicker
-- * Shared
makeFields ''BlockIndex
makePrisms ''Amount
makePrisms ''AmountExtended