cardano-rpc
Safe HaskellNone
LanguageHaskell2010

Cardano.Rpc.Server.Internal.UtxoRpc.Type

Description

Umbrella module for the conversions between cardano-api types and their UTxO RPC protobuf counterparts. The conversions live in the Type.* submodules; this module re-exports them so that existing importers keep working unchanged.

Synopsis

Documentation

anyUtxoDataUtxoRpcToUtxo :: forall era m. (HasCallStack, MonadThrow m) => Era era -> [Proto AnyUtxoData] -> m (UTxO era) Source #

metadatumToUtxoRpcMetadatum :: Metadatum -> Proto Metadatum Source #

Convert a ledger metadatum to the UTxO RPC Metadatum message. The UTxO RPC encoding only supports signed 64-bit metadata integers, while the ledger rules allow any integer with an 8-byte magnitude, i.e. within [-(2^64 - 1), 2^64 - 1]. Values outside of the Int64 range are therefore clamped to minBound and maxBound respectively. Consumers which need full fidelity should decode the native_bytes CBOR of the transaction instead.

txToUtxoRpcTx :: IsShelleyBasedEra era => Tx 'TopTx (ShelleyLedgerEra era) -> Proto Tx Source #

Convert a ledger transaction to the UTxO RPC Tx message. Populates hash, fee, successful, inputs, outputs, reference inputs, validity, mint, withdrawals, collateral, certificates, witnesses, auxiliary data and governance proposals, with spending, withdrawal and certificate redeemers wired to their respective entries. Era-gated fields are read through the any-era getters, whose Nothing maps to the proto default; the ShelleyBasedEra witness is recovered from IsShelleyBasedEra and brings the any-era reading classes into scope.

anyEraTxConstraints :: ShelleyBasedEra era -> ((IsShelleyBasedEra era, AnyEraTx (ShelleyLedgerEra era)) => a) -> a Source #

Bring the constraints of txToUtxoRpcTx into scope for a Shelley-based era: the uniform any-era transaction reading classes of cardano-ledger-api, whose era-gated getters return Nothing where the era predates a field, and IsShelleyBasedEra to recover the witness. Unlike the eon constraint bundles this dispatch is total, including Dijkstra.

utxoRpcTxOutputToTxOut :: forall era m. (HasCallStack, MonadThrow m, IsEra era) => Proto TxOutput -> m (TxOut CtxUTxO era) Source #

protocolParamsToUtxoRpcPParams :: Era era -> PParams (LedgerEra era) -> Proto PParams Source #

Convert full ledger protocol parameters to the UTxO RPC PParams message. All parameters are set.

utxoRpcRationalNumberToRational :: Proto RationalNumber -> Maybe Rational Source #

Convert a protobuf RationalNumber into a Rational.

Fails with Nothing when the denominator is zero, which is also the default value of the protobuf field when it is omitted.

utxoRpcChainPointMsgToChainPoint :: (HasCallStack, MonadThrow m) => Proto ChainPoint -> m (ChainPoint, WithOrigin BlockNo, UTCTime) Source #

Inverse of mkChainPointMsg. Note: Origin and At (BlockNo 0) both encode to height=0, so the decode always maps 0 back to Origin.

scriptWitnessIndexToRedeemerPurpose :: ScriptWitnessIndex -> (Proto RedeemerPurpose, Word32) Source #

Map a ScriptWitnessIndex to the corresponding proto RedeemerPurpose and the numeric index within that purpose.

scriptExecutionErrorToEvalReport :: ScriptWitnessIndex -> ScriptExecutionError -> Proto EvalReport Source #

Convert a ScriptExecutionError into a proto EvalReport with the redeemer purpose and 0-based index that produced the error.

mkProtoRedeemer Source #

Arguments

:: (PlutusScriptPurpose, Word32)

Redeemer purpose and index

-> ExecutionUnits

Execution units consumed

-> Maybe (ScriptData, ByteString)

Plutus data payload and its CBOR bytes

-> Proto Redeemer 

Assemble a proto Redeemer from evaluation results and transaction witness data.

mkProtoTxEval Source #

Arguments

:: Coin

Computed minimum fee

-> Map ScriptWitnessIndex (Either ScriptExecutionError ([Text], ExecutionUnits))

Per-redeemer evaluation results: script traces and execution units on success, or a script execution error on failure

-> Map ScriptWitnessIndex (ScriptData, ByteString)

Redeemer Plutus data extracted from the transaction witness set, keyed by script witness index, with decoded payload and CBOR bytes.

-> Proto TxEval 

Assemble a proto TxEval response from the computed fee, per-redeemer evaluation results, and redeemer Plutus data from the transaction witness set.