Skip to content

Commit

Permalink
Merge #2263
Browse files Browse the repository at this point in the history
2263: Add API support for queries for protocol params. r=Jimbo4350 a=dcoutts

Several kinds of params:
1. current values of updateable protocol params
2. any pending proposed param updates
3. the non-updateable params fixed in the (Shelley) genesis file


Co-authored-by: Duncan Coutts <duncan@well-typed.com>
  • Loading branch information
iohk-bors[bot] and dcoutts authored Jan 11, 2021
2 parents 8e0501f + b5abac0 commit e3632a3
Show file tree
Hide file tree
Showing 5 changed files with 474 additions and 61 deletions.
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

0 comments on commit e3632a3

Please sign in to comment.