Skip to content

Commit

Permalink
Merge #3415
Browse files Browse the repository at this point in the history
3415: Light-mode: protocol parameters contain era infos. r=Unisay a=Unisay

Protocol  parameters contain information on when each era starts also in light mode.

Before:
```
http http://localhost:8090/v2/network/parameters | jq .eras
{
  "allegra": null,
  "alonzo": null,
  "babbage": null,
  "byron": null,
  "mary": null,
  "shelley": null
}
```

After:
```
http http://localhost:8090/v2/network/parameters | jq .eras
{
  "allegra": {
    "epoch_number": 102,
    "epoch_start_time": "2020-12-15T20:20:16Z"
  },
  "alonzo": {
    "epoch_number": 154,
    "epoch_start_time": "2021-09-01T20:20:16Z"
  },
  "babbage": null,
  "byron": {
    "epoch_number": 0,
    "epoch_start_time": "2019-07-24T20:20:16Z"
  },
  "mary": {
    "epoch_number": 112,
    "epoch_start_time": "2021-02-03T20:20:16Z"
  },
  "shelley": {
    "epoch_number": 74,
    "epoch_start_time": "2020-07-28T20:20:16Z"
  }
}
```

### Issue Number

ADP-1827


Co-authored-by: Yuriy Lazaryev <[email protected]>
  • Loading branch information
iohk-bors[bot] and Unisay authored Aug 1, 2022
2 parents b50d5c3 + bb4b4c8 commit 62eede3
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions lib/shelley/src/Cardano/Wallet/Shelley/Network/Blockfrost.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ import Prelude
import Cardano.Api
( AnyCardanoEra (..)
, AnyPlutusScriptVersion (AnyPlutusScriptVersion)
, CardanoEra (..)
, ExecutionUnitPrices (priceExecutionMemory, priceExecutionSteps)
, ExecutionUnits (executionMemory, executionSteps)
, IsCardanoEra
, NetworkId (..)
, PlutusScriptVersion (PlutusScriptV1)
, ShelleyBasedEra (ShelleyBasedEraAlonzo)
Expand Down Expand Up @@ -89,6 +91,7 @@ import Cardano.Wallet.Primitive.Types
, DelegationCertificate (..)
, EpochLength (EpochLength)
, EpochNo (..)
, EraInfo (..)
, ExecutionUnitPrices (..)
, ExecutionUnits (..)
, FeePolicy (LinearFee)
Expand All @@ -106,7 +109,6 @@ import Cardano.Wallet.Primitive.Types
, TxParameters (..)
, WithOrigin (At)
, chainPointFromBlockHeader
, emptyEraInfo
, executionMemory
, executionSteps
, fromFederationPercentage
Expand Down Expand Up @@ -874,7 +876,7 @@ fromBlockfrostPP network [email protected]{..} = do
_protocolParamsNOpt <?#> "NOpt"

pure ProtocolParameters
{ eras = emptyEraInfo
{ eras = protocolParametersEras (Fixture.eraBoundaries network)
, txParameters =
TxParameters
{ getFeePolicy =
Expand Down Expand Up @@ -965,6 +967,24 @@ fromBlockfrostPP network [email protected]{..} = do
Just $ intCast maxCollateralInputs
}
, .. }
where
protocolParametersEras :: [(AnyCardanoEra, EpochNo)] -> EraInfo EpochNo
protocolParametersEras eraEpochs =
EraInfo
{ byron = lookupEpochNo ByronEra
, shelley = lookupEpochNo ShelleyEra
, allegra = lookupEpochNo AllegraEra
, mary = lookupEpochNo MaryEra
, alonzo = lookupEpochNo AlonzoEra
, babbage = Nothing
-- Commented out until Babbage era epoch boundary happen,
-- otherwise API response contains some
-- epoch_start_time from the future (e.g. 2024-11-24T20:20:16Z)
-- lookupEpochNo BabbageEra
}
where
lookupEpochNo :: IsCardanoEra e => CardanoEra e -> Maybe EpochNo
lookupEpochNo era = lookup (AnyCardanoEra era) eraEpochs

-- | Selects a minimum UTxO function that is appropriate for the current era.
--
Expand Down

0 comments on commit 62eede3

Please sign in to comment.