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 API support for queries for protocol params. #2263

Merged
merged 5 commits into from
Jan 11, 2021
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
4 changes: 2 additions & 2 deletions cardano-api/src/Cardano/Api/Address.hs
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,12 @@ data StakeAddress where
data PaymentCredential
= PaymentCredentialByKey (Hash PaymentKey)
| PaymentCredentialByScript ScriptHash
deriving (Eq, Show)
deriving (Eq, Ord, Show)

data StakeCredential
= StakeCredentialByKey (Hash StakeKey)
| StakeCredentialByScript ScriptHash
deriving (Eq, Show)
deriving (Eq, Ord, Show)

data StakeAddressReference
= StakeAddressByValue StakeCredential
Expand Down
17 changes: 14 additions & 3 deletions cardano-api/src/Cardano/Api/NetworkId.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ module Cardano.Api.NetworkId (
NetworkId(..),
NetworkMagic(..),
toNetworkMagic,
mainnetNetworkMagic,

-- * Internal conversion functions
toByronProtocolMagicId,
toByronNetworkMagic,
toByronRequiresNetworkMagic,
toShelleyNetwork,
fromShelleyNetwork,
) where

import Prelude
Expand All @@ -35,9 +37,12 @@ data NetworkId = Mainnet

toNetworkMagic :: NetworkId -> NetworkMagic
toNetworkMagic (Testnet nm) = nm
toNetworkMagic Mainnet = NetworkMagic
. Byron.unProtocolMagicId
$ Byron.mainnetProtocolMagicId
toNetworkMagic Mainnet = mainnetNetworkMagic

mainnetNetworkMagic :: NetworkMagic
mainnetNetworkMagic = NetworkMagic
. Byron.unProtocolMagicId
$ Byron.mainnetProtocolMagicId


-- ----------------------------------------------------------------------------
Expand Down Expand Up @@ -65,3 +70,9 @@ toShelleyNetwork :: NetworkId -> Shelley.Network
toShelleyNetwork Mainnet = Shelley.Mainnet
toShelleyNetwork (Testnet _) = Shelley.Testnet

fromShelleyNetwork :: Shelley.Network -> NetworkMagic -> NetworkId
fromShelleyNetwork Shelley.Testnet nm = Testnet nm
fromShelleyNetwork Shelley.Mainnet nm
| nm == mainnetNetworkMagic = Mainnet
| otherwise = error "fromShelleyNetwork Mainnet: wrong mainnet network magic"

Loading