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 new interim governance commands: {create, answer, verify}-poll #5050

Closed
Closed
4 changes: 3 additions & 1 deletion cardano-api/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

- **Breaking change** - `queryExpr` to return `IO (Either UnsupportedNtcVersionError a)` instead of `IO a`.
([PR4788](https://github.com/input-output-hk/cardano-node/pull/4788))

- **Breaking change** - Remove distinction between multisig and timelock scripts([PR4763](https://github.com/input-output-hk/cardano-node/pull/4763))

- **Breaking change** Change return type of `queryNodeLocalState` to new `AcquiringFailure` type.
Expand All @@ -42,6 +42,8 @@

- Auto-balance multi asset transactions ([PR 4450](https://github.com/input-output-hk/cardano-node/pull/4450))

- 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))
Jimbo4350 marked this conversation as resolved.
Show resolved Hide resolved

### Bugs

- Allow reading text envelopes from pipes ([PR 4384](https://github.com/input-output-hk/cardano-node/pull/4384))
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 @@ -67,6 +67,7 @@ library
Cardano.Api.Fees
Cardano.Api.Genesis
Cardano.Api.GenesisParameters
Cardano.Api.Governance.Poll
Cardano.Api.Hash
Cardano.Api.HasTypeProxy
Cardano.Api.InMode
Expand Down
55 changes: 55 additions & 0 deletions cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -106,34 +106,43 @@ module Test.Gen.Cardano.Api.Typed
, genWitnessNetworkIdOrByronAddress

, 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 (..), KESPeriod (KESPeriod),
GovernancePoll (..), GovernancePollAnswer (..), GovernancePollWitness (..),
OperationalCertificateIssueCounter (OperationalCertificateIssueCounter),
PlutusScript (PlutusScriptSerialised), ProtocolParameters (ProtocolParameters),
ReferenceScript (..), ReferenceTxInsScriptsInlineDatumsSupportedInEra (..),
StakeCredential (StakeCredentialByKey), StakePoolKey,
refInsScriptsAndInlineDatsSupportedInEra)


import Control.Applicative (optional)
import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
import qualified Data.ByteString.Short as SBS
import Data.Coerce
import Data.Int (Int64)
import Data.Map.Strict (Map)
import Data.Maybe (fromMaybe)
import Data.Ratio (Ratio, (%))
import Data.String
import Data.Word (Word64)
import Numeric.Natural (Natural)

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 Test.Cardano.Ledger.Alonzo.PlutusScripts as Plutus

Expand All @@ -145,6 +154,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 Test.Cardano.Chain.UTxO.Gen (genVKWitness)
import Test.Cardano.Crypto.Gen (genProtocolMagicId)
Expand Down Expand Up @@ -957,3 +967,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 (error "unsafeDeserialiseVerKeyVRF") . VRF.rawDeserialiseVerKeyVRF
unsafeDeserialiseCertVRF =
fromMaybe (error "unsafeDeserialiseCertVRF") . VRF.rawDeserialiseCertVRF

unsafeDeserialiseVerKeyDSIGN =
fromMaybe (error "unsafeDeserialiseVerKeyDSIGN") . DSIGN.rawDeserialiseVerKeyDSIGN
unsafeDeserialiseSigDSIGN =
fromMaybe (error "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 @@ -335,10 +335,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