Skip to content

Commit

Permalink
Merge branch 'IntersectMBO#5050-1.35-backport' into release/1.35
Browse files Browse the repository at this point in the history
  • Loading branch information
KtorZ committed Apr 25, 2023
2 parents f0b4ac8 + 5814f3b commit f51d277
Show file tree
Hide file tree
Showing 34 changed files with 1,573 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cardano-api/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

### Features

- New 'Governance.Poll' API implementing [CIP-0094](https://github.com/cardano-foundation/CIPs/pull/496) ([PR 5050](https://github.com/input-output-hk/cardano-node/pull/5050))

## 1.35.4 -- October 2022

- Expose `Key` interface via `Cardano.Api.Shelley` ([PR4048](https://github.com/input-output-hk/cardano-node/pull/4048))
- Append, not prepend change output when balancing a transaction ([PR4343](https://github.com/input-output-hk/cardano-node/pull/4343))

- Expose convenience functions `executeQueryCardanoMode`, `determineEra`, `constructBalancedTx` and `queryStateForBalancedTx` ([PR 4446](https://github.com/input-output-hk/cardano-node/pull/4446))

## 1.35.3 -- August 2022
Expand Down
1 change: 1 addition & 0 deletions cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ library
Cardano.Api.Error
Cardano.Api.Fees
Cardano.Api.GenesisParameters
Cardano.Api.Governance.Poll
Cardano.Api.Hash
Cardano.Api.HasTypeProxy
Cardano.Api.IPC
Expand Down
55 changes: 54 additions & 1 deletion cardano-api/gen/Gen/Cardano/Api/Typed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,18 @@ module Gen.Cardano.Api.Typed
, genValueForMinting

, genRational

, genGovernancePoll
, genGovernancePollAnswer
, genGovernancePollWitness
) where

import Cardano.Api hiding (txIns)
import qualified Cardano.Api as Api
import Cardano.Api.Byron (KeyWitness (ByronKeyWitness),
WitnessNetworkIdOrByronAddress (..))
import Cardano.Api.Shelley (Hash (ScriptDataHash), KESPeriod (KESPeriod),
import Cardano.Api.Shelley (Hash (..), KESPeriod (KESPeriod),
GovernancePoll (..), GovernancePollAnswer (..), GovernancePollWitness (..),
OperationalCertificateIssueCounter (OperationalCertificateIssueCounter),
PlutusScript (PlutusScriptSerialised), ProtocolParameters (ProtocolParameters),
ReferenceScript (..), ReferenceTxInsScriptsInlineDatumsSupportedInEra (..),
Expand All @@ -83,8 +88,10 @@ import Data.String
import qualified Data.Text as Text

import qualified Cardano.Binary as CBOR
import qualified Cardano.Crypto.DSIGN as DSIGN
import qualified Cardano.Crypto.Hash as Crypto
import qualified Cardano.Crypto.Seed as Crypto
import qualified Cardano.Crypto.VRF as VRF
import qualified Cardano.Ledger.Shelley.TxBody as Ledger (EraIndependentTxBody)
import qualified PlutusCore as Plutus

Expand All @@ -96,6 +103,7 @@ import qualified Cardano.Crypto.Hash.Class as CRYPTO
import Cardano.Ledger.Alonzo.Language (Language (..))
import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo
import Cardano.Ledger.SafeHash (unsafeMakeSafeHash)
import Cardano.Ledger.Keys (VKey(..))

import Gen.Cardano.Api.Metadata (genTxMetadata)
import Test.Cardano.Chain.UTxO.Gen (genVKWitness)
Expand Down Expand Up @@ -879,3 +887,48 @@ genHashScriptData = ScriptDataHash . unsafeMakeSafeHash . mkDummyHash <$> Gen.in

genScriptDataSupportedInAlonzoEra :: Gen (ScriptDataSupportedInEra AlonzoEra)
genScriptDataSupportedInAlonzoEra = pure ScriptDataInAlonzoEra

genGovernancePoll :: Gen GovernancePoll
genGovernancePoll =
GovernancePoll
<$> Gen.text (Range.linear 1 255) Gen.unicodeAll
<*> Gen.list (Range.constant 1 10) (Gen.text (Range.linear 1 255) Gen.unicodeAll)
<*> optional (Gen.word (Range.constant 0 100))

genGovernancePollAnswer :: Gen GovernancePollAnswer
genGovernancePollAnswer =
GovernancePollAnswer
<$> genGovernancePollHash
<*> Gen.word (Range.constant 0 10)
where
genGovernancePollHash =
GovernancePollHash . mkDummyHash <$> Gen.int (Range.linear 0 10)

genGovernancePollWitness :: Gen GovernancePollWitness
genGovernancePollWitness =
Gen.choice
[ GovernancePollWitnessVRF
<$> fmap
unsafeDeserialiseVerKeyVRF
(Gen.bytes $ Range.singleton 32)
<*> fmap
unsafeDeserialiseCertVRF
(Gen.bytes $ Range.singleton 80)
, GovernancePollWitnessColdKey
<$> fmap
(VKey . unsafeDeserialiseVerKeyDSIGN)
(Gen.bytes $ Range.singleton 32)
<*> fmap
(DSIGN.SignedDSIGN . unsafeDeserialiseSigDSIGN)
(Gen.bytes $ Range.singleton 64)
]
where
unsafeDeserialiseVerKeyVRF =
fromMaybe (panic "unsafeDeserialiseVerKeyVRF") . VRF.rawDeserialiseVerKeyVRF
unsafeDeserialiseCertVRF =
fromMaybe (panic "unsafeDeserialiseCertVRF") . VRF.rawDeserialiseCertVRF

unsafeDeserialiseVerKeyDSIGN =
fromMaybe (panic "unsafeDeserialiseVerKeyDSIGN") . DSIGN.rawDeserialiseVerKeyDSIGN
unsafeDeserialiseSigDSIGN =
fromMaybe (panic "unsafeDeserialiseSigDSIGN") . DSIGN.rawDeserialiseSigDSIGN
4 changes: 4 additions & 0 deletions cardano-api/src/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,14 @@ module Cardano.Api (
-- * Transaction metadata
-- | Embedding additional structured data within transactions.
TxMetadata(..),
AsTxMetadata(..),

-- ** Constructing metadata
TxMetadataValue(..),
makeTransactionMetadata,
mergeTransactionMetadata,
metaTextChunks,
metaBytesChunks,

-- ** Validating metadata
validateTxMetadata,
Expand Down
Loading

0 comments on commit f51d277

Please sign in to comment.