@@ -87,7 +87,6 @@ import Cardano.Serialization.Lib (toBytes)
87
87
import Cardano.Types
88
88
( AssetClass (AssetClass)
89
89
, AuxiliaryData
90
- , CostModel
91
90
, DataHash
92
91
, GeneralTransactionMetadata (GeneralTransactionMetadata)
93
92
, Language (PlutusV3, PlutusV2, PlutusV1)
@@ -195,7 +194,13 @@ import Ctl.Internal.Types.EraSummaries
195
194
, EraSummaryParameters
196
195
)
197
196
import Ctl.Internal.Types.ProtocolParameters
198
- ( ProtocolParameters (ProtocolParameters)
197
+ ( CostModelV1
198
+ , CostModelV2
199
+ , ProtocolParameters (ProtocolParameters)
200
+ , convertPlutusV1CostModel
201
+ , convertPlutusV2CostModel
202
+ , convertPlutusV3CostModel
203
+ , convertUnnamedPlutusCostModel
199
204
)
200
205
import Ctl.Internal.Types.Rational (Rational , reduce )
201
206
import Ctl.Internal.Types.Rational as Rational
@@ -235,7 +240,6 @@ import Effect.Aff.Class (liftAff)
235
240
import Effect.Class (liftEffect )
236
241
import Effect.Exception (error )
237
242
import Foreign.Object (Object )
238
- import Foreign.Object (values ) as Object
239
243
import Foreign.Object as ForeignObject
240
244
import JS.BigInt (fromString , toNumber ) as BigInt
241
245
import Prim.TypeError (class Warn , Text )
@@ -1517,8 +1521,8 @@ type BlockfrostProtocolParametersRaw =
1517
1521
, "protocol_minor_ver" :: UInt
1518
1522
, "min_pool_cost" :: Stringed BigNum
1519
1523
, "cost_models" ::
1520
- { "PlutusV1" :: Object Cardano.Int
1521
- , "PlutusV2" :: Object Cardano.Int
1524
+ { "PlutusV1" :: { | CostModelV1 }
1525
+ , "PlutusV2" :: { | CostModelV2 }
1522
1526
, "PlutusV3" :: Object Cardano.Int
1523
1527
}
1524
1528
, "price_mem" :: FiniteBigNumber
@@ -1594,6 +1598,12 @@ instance DecodeAeson BlockfrostProtocolParameters where
1594
1598
raw.min_fee_ref_script_cost_per_byte
1595
1599
)
1596
1600
one
1601
+ let plutusV3CostModelRaw = raw.cost_models." PlutusV3"
1602
+ plutusV3CostModel <-
1603
+ note (AtKey " cost_models" $ AtKey " PlutusV3" $ TypeMismatch " CostModel" )
1604
+ ( convertPlutusV3CostModel plutusV3CostModelRaw
1605
+ <|> convertUnnamedPlutusCostModel plutusV3CostModelRaw
1606
+ )
1597
1607
pure $ BlockfrostProtocolParameters $ ProtocolParameters
1598
1608
{ protocolVersion: raw.protocol_major_ver /\ raw.protocol_minor_ver
1599
1609
-- The following two parameters were removed from Babbage
@@ -1613,9 +1623,9 @@ instance DecodeAeson BlockfrostProtocolParameters where
1613
1623
, treasuryCut
1614
1624
, coinsPerUtxoByte: coinsPerUtxoByte
1615
1625
, costModels: Map .fromFoldable
1616
- [ PlutusV1 /\ convertPlutusCostModel raw.cost_models." PlutusV1"
1617
- , PlutusV2 /\ convertPlutusCostModel raw.cost_models." PlutusV2"
1618
- , PlutusV3 /\ convertPlutusCostModel raw.cost_models. " PlutusV3 "
1626
+ [ PlutusV1 /\ convertPlutusV1CostModel raw.cost_models." PlutusV1"
1627
+ , PlutusV2 /\ convertPlutusV2CostModel raw.cost_models." PlutusV2"
1628
+ , PlutusV3 /\ plutusV3CostModel
1619
1629
]
1620
1630
, prices
1621
1631
, maxTxExUnits:
@@ -1635,9 +1645,6 @@ instance DecodeAeson BlockfrostProtocolParameters where
1635
1645
, drepDeposit: Coin $ unwrap raw.drep_deposit
1636
1646
, refScriptCoinsPerByte
1637
1647
}
1638
- where
1639
- convertPlutusCostModel :: Object Cardano.Int -> CostModel
1640
- convertPlutusCostModel = wrap <<< Object .values
1641
1648
1642
1649
-- ------------------------------------------------------------------------------
1643
1650
-- BlockfrostRewards
0 commit comments