| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Cardano.Api.Serialise.TextEnvelope
Synopsis
- class SerialiseAsCBOR a => HasTextEnvelope a where
- textEnvelopeTypeInEra :: HasTextEnvelope (f era) => CardanoEra era -> AsType (f era) -> TextEnvelopeType
- data TextEnvelope = TextEnvelope {}
- newtype TextEnvelopeType = TextEnvelopeType String
- newtype TextEnvelopeDescr = TextEnvelopeDescr String
- textEnvelopeRawCBOR :: TextEnvelope -> ByteString
- data TextEnvelopeError
- serialiseToTextEnvelope :: HasTextEnvelope a => Maybe TextEnvelopeDescr -> a -> TextEnvelope
- deserialiseFromTextEnvelope :: HasTextEnvelope a => TextEnvelope -> Either TextEnvelopeError a
- readFileTextEnvelope :: HasTextEnvelope a => File content 'In -> IO (Either (FileError TextEnvelopeError) a)
- writeFileTextEnvelope :: HasTextEnvelope a => File content 'Out -> Maybe TextEnvelopeDescr -> a -> IO (Either (FileError ()) ())
- writeFileTextEnvelopeWithOwnerPermissions :: HasTextEnvelope a => File content 'Out -> Maybe TextEnvelopeDescr -> a -> IO (Either (FileError ()) ())
- readTextEnvelopeFromFile :: FilePath -> IO (Either (FileError TextEnvelopeError) TextEnvelope)
- readTextEnvelopeOfTypeFromFile :: TextEnvelopeType -> FilePath -> IO (Either (FileError TextEnvelopeError) TextEnvelope)
- textEnvelopeToJSON :: HasTextEnvelope a => Maybe TextEnvelopeDescr -> a -> ByteString
- serialiseTextEnvelope :: TextEnvelope -> ByteString
- legacyComparison :: TextEnvelopeType -> TextEnvelopeType -> Bool
- data FromSomeType (c :: Type -> Constraint) b where
- FromSomeType :: forall (c :: Type -> Constraint) a b. c a => AsType a -> (a -> b) -> FromSomeType c b
- deserialiseFromTextEnvelopeAnyOf :: [FromSomeType HasTextEnvelope b] -> TextEnvelope -> Either TextEnvelopeError b
- decodeTextEnvelopeJSON :: ByteString -> Either TextEnvelopeError TextEnvelope
- deserialiseFromTextEnvelopeJSON :: HasTextEnvelope a => ByteString -> Either TextEnvelopeError a
- deserialiseFromTextEnvelopeJSONAnyOf :: [FromSomeType HasTextEnvelope b] -> ByteString -> Either TextEnvelopeError b
- readFileTextEnvelopeAnyOf :: [FromSomeType HasTextEnvelope b] -> File content 'In -> IO (Either (FileError TextEnvelopeError) b)
- data family AsType t
- data TextEnvelopeCddlError
- data FromSomeTypeCDDL c b where
- FromCDDLTx :: forall b. Text -> (InAnyShelleyBasedEra Tx -> b) -> FromSomeTypeCDDL TextEnvelope b
- FromCDDLWitness :: forall b. Text -> (InAnyShelleyBasedEra KeyWitness -> b) -> FromSomeTypeCDDL TextEnvelope b
- cddlTypeToEra :: Text -> Either TextEnvelopeCddlError AnyShelleyBasedEra
- readFileTextEnvelopeCddlAnyOf :: [FromSomeTypeCDDL TextEnvelope b] -> FilePath -> IO (Either (FileError TextEnvelopeCddlError) b)
- deserialiseFromTextEnvelopeCddlAnyOf :: [FromSomeTypeCDDL TextEnvelope b] -> TextEnvelope -> Either TextEnvelopeCddlError b
- writeTxFileTextEnvelope :: ShelleyBasedEra era -> File content 'Out -> Tx era -> IO (Either (FileError ()) ())
- writeTxFileTextEnvelopeCddl :: ShelleyBasedEra era -> File content 'Out -> Tx era -> IO (Either (FileError ()) ())
- writeTxFileTextEnvelopeCanonical :: ShelleyBasedEra era -> File content 'Out -> Tx era -> IO (Either (FileError ()) ())
- writeTxFileTextEnvelopeCanonicalCddl :: ShelleyBasedEra era -> File content 'Out -> Tx era -> IO (Either (FileError ()) ())
- writeTxWitnessFileTextEnvelope :: ShelleyBasedEra era -> File () 'Out -> KeyWitness era -> IO (Either (FileError ()) ())
- writeTxWitnessFileTextEnvelopeCddl :: ShelleyBasedEra era -> File () 'Out -> KeyWitness era -> IO (Either (FileError ()) ())
- deserialiseByronTxCddl :: TextEnvelope -> Either TextEnvelopeCddlError (ATxAux ByteString)
- serialiseWitnessLedgerCddl :: ShelleyBasedEra era -> KeyWitness era -> TextEnvelope
- deserialiseWitnessLedgerCddl :: ShelleyBasedEra era -> TextEnvelope -> Either TextEnvelopeCddlError (KeyWitness era)
- serialiseByronTx :: ATxAux ByteString -> TextEnvelope
- deserialiseByronTx :: TextEnvelope -> Either TextEnvelopeError (ATxAux ByteString)
- writeByronTxFileTextEnvelopeCddl :: File content 'Out -> ATxAux ByteString -> IO (Either (FileError ()) ())
TextEnvelope Serialisation
class SerialiseAsCBOR a => HasTextEnvelope a where Source #
Minimal complete definition
Methods
textEnvelopeType :: AsType a -> TextEnvelopeType Source #
Instances
textEnvelopeTypeInEra :: HasTextEnvelope (f era) => CardanoEra era -> AsType (f era) -> TextEnvelopeType Source #
data TextEnvelope Source #
A TextEnvelope is a structured envelope for serialised binary values
with an external format with a semi-readable textual format.
It contains a "type" field, e.g. "PublicKeyByron" or "TxSignedShelley" to indicate the type of the encoded data. This is used as a sanity check and to help readers.
It also contains a "title" field which is free-form, and could be used to indicate the role or purpose to a reader.
Constructors
| TextEnvelope | |
Fields | |
Instances
| FromJSON TextEnvelope Source # | |||||
Defined in Cardano.Api.Serialise.TextEnvelope.Internal | |||||
| ToJSON TextEnvelope Source # | |||||
Defined in Cardano.Api.Serialise.TextEnvelope.Internal Methods toJSON :: TextEnvelope -> Value # toEncoding :: TextEnvelope -> Encoding # toJSONList :: [TextEnvelope] -> Value # toEncodingList :: [TextEnvelope] -> Encoding # omitField :: TextEnvelope -> Bool # | |||||
| HasTypeProxy TextEnvelope Source # | |||||
Defined in Cardano.Api.Serialise.TextEnvelope.Internal Associated Types
Methods proxyToAsType :: Proxy TextEnvelope -> AsType TextEnvelope Source # | |||||
| Eq TextEnvelope Source # | |||||
Defined in Cardano.Api.Serialise.TextEnvelope.Internal Methods (==) :: TextEnvelope -> TextEnvelope -> Bool Source # (/=) :: TextEnvelope -> TextEnvelope -> Bool Source # | |||||
| Show TextEnvelope Source # | |||||
Defined in Cardano.Api.Serialise.TextEnvelope.Internal | |||||
| data AsType TextEnvelope Source # | |||||
Defined in Cardano.Api.Serialise.TextEnvelope.Internal | |||||
newtype TextEnvelopeType Source #
Constructors
| TextEnvelopeType String |
Instances
newtype TextEnvelopeDescr Source #
Constructors
| TextEnvelopeDescr String |
Instances
data TextEnvelopeError Source #
The errors that the pure TextEnvelope parsing/decoding functions can return.
Constructors
Instances
serialiseToTextEnvelope :: HasTextEnvelope a => Maybe TextEnvelopeDescr -> a -> TextEnvelope Source #
deserialiseFromTextEnvelope :: HasTextEnvelope a => TextEnvelope -> Either TextEnvelopeError a Source #
readFileTextEnvelope :: HasTextEnvelope a => File content 'In -> IO (Either (FileError TextEnvelopeError) a) Source #
writeFileTextEnvelope :: HasTextEnvelope a => File content 'Out -> Maybe TextEnvelopeDescr -> a -> IO (Either (FileError ()) ()) Source #
Write a value to a file in the text envelope format.
Note that this does not set conservative file permissions: the file is
created with the default permissions which should be restricted with umask. When writing sensitive data such as
signing keys, use writeFileTextEnvelopeWithOwnerPermissions instead,
which tries to restrict access to the file owner where the platform
supports it (see its documentation for the exact guarantees).
writeFileTextEnvelopeWithOwnerPermissions :: HasTextEnvelope a => File content 'Out -> Maybe TextEnvelopeDescr -> a -> IO (Either (FileError ()) ()) Source #
Like writeFileTextEnvelope, but the file is created so that only its
owner has access to it, to the extent the platform allows it:
- On POSIX systems, the file is created with
0600permissions (read and write for the file owner only, further filtered by the process'sumask), and its ownership is set to the current (real) user. If the file already exists, it is truncated, but its permission bits are left unchanged. - On Windows, the contents are written to a freshly created temporary file which is then renamed to the target path. This guarantees the file is owned by the current user, but no explicit ACL is set: the file inherits the access control list of the target directory.
- On WASM, this is currently a no-op: no file is written at all.
Use this when writing sensitive data such as signing keys.
readTextEnvelopeFromFile :: FilePath -> IO (Either (FileError TextEnvelopeError) TextEnvelope) Source #
readTextEnvelopeOfTypeFromFile :: TextEnvelopeType -> FilePath -> IO (Either (FileError TextEnvelopeError) TextEnvelope) Source #
textEnvelopeToJSON :: HasTextEnvelope a => Maybe TextEnvelopeDescr -> a -> ByteString Source #
serialiseTextEnvelope :: TextEnvelope -> ByteString Source #
Serialise text envelope to pretty JSON
legacyComparison :: TextEnvelopeType -> TextEnvelopeType -> Bool Source #
This is a backwards-compatibility patch to ensure that old envelopes
generated by serialiseTxLedgerCddl can be deserialised after switching
to the serialiseToTextEnvelope.
Reading one of several key types
data FromSomeType (c :: Type -> Constraint) b where Source #
Constructors
| FromSomeType :: forall (c :: Type -> Constraint) a b. c a => AsType a -> (a -> b) -> FromSomeType c b |
deserialiseFromTextEnvelopeAnyOf :: [FromSomeType HasTextEnvelope b] -> TextEnvelope -> Either TextEnvelopeError b Source #
decodeTextEnvelopeJSON :: ByteString -> Either TextEnvelopeError TextEnvelope Source #
Decode a JSON-encoded TextEnvelope from a strict ByteString (UTF-8).
Returns TextEnvelopeAesonDecodeError if the JSON parsing fails.
deserialiseFromTextEnvelopeJSON :: HasTextEnvelope a => ByteString -> Either TextEnvelopeError a Source #
Deserialise a value from a JSON-encoded text envelope ByteString (UTF-8).
This performs no file I/O. Returns TextEnvelopeAesonDecodeError for JSON
parse failures, or downstream errors from deserialiseFromTextEnvelope for
type mismatches and CBOR decoding failures.
deserialiseFromTextEnvelopeJSONAnyOf :: [FromSomeType HasTextEnvelope b] -> ByteString -> Either TextEnvelopeError b Source #
Like deserialiseFromTextEnvelopeJSON but accepts multiple target types.
This performs no file I/O. Returns TextEnvelopeAesonDecodeError for JSON
parse failures, or downstream errors from deserialiseFromTextEnvelopeAnyOf
for type mismatches and CBOR decoding failures.
readFileTextEnvelopeAnyOf :: [FromSomeType HasTextEnvelope b] -> File content 'In -> IO (Either (FileError TextEnvelopeError) b) Source #
Data family instances
A family of singleton types used in this API to indicate which type to use where it would otherwise be ambiguous or merely unclear.
Values of this type are passed to deserialisation functions for example.
Instances
CDDL Serialisation
data TextEnvelopeCddlError Source #
Constructors
Instances
data FromSomeTypeCDDL c b where Source #
This GADT allows us to deserialise a tx or key witness without having to provide the era.
Constructors
| FromCDDLTx | |
Fields
| |
| FromCDDLWitness | |
Fields
| |
cddlTypeToEra :: Text -> Either TextEnvelopeCddlError AnyShelleyBasedEra Source #
Deprecated: Use textEnvelopeTypeToEra instead.
Reading one of several transaction or key witness types
readFileTextEnvelopeCddlAnyOf :: [FromSomeTypeCDDL TextEnvelope b] -> FilePath -> IO (Either (FileError TextEnvelopeCddlError) b) Source #
Deprecated: Use readFileTextEnvelopeAnyOf instead.
deserialiseFromTextEnvelopeCddlAnyOf :: [FromSomeTypeCDDL TextEnvelope b] -> TextEnvelope -> Either TextEnvelopeCddlError b Source #
Deprecated: Use deserialiseFromTextEnvelopeAnyOf instead.
writeTxFileTextEnvelope :: ShelleyBasedEra era -> File content 'Out -> Tx era -> IO (Either (FileError ()) ()) Source #
writeTxFileTextEnvelopeCddl :: ShelleyBasedEra era -> File content 'Out -> Tx era -> IO (Either (FileError ()) ()) Source #
Deprecated: Use writeTxFileTextEnvelope instead.
writeTxFileTextEnvelopeCanonical :: ShelleyBasedEra era -> File content 'Out -> Tx era -> IO (Either (FileError ()) ()) Source #
Write transaction in the text envelope format. The CBOR will be in canonical format according to RFC 7049. It is also a requirement of CIP-21, which is not fully implemented.
writeTxFileTextEnvelopeCanonicalCddl :: ShelleyBasedEra era -> File content 'Out -> Tx era -> IO (Either (FileError ()) ()) Source #
Deprecated: Use writeTxFileTextEnvelopeCanonical instead.
Write transaction in the text envelope format. The CBOR will be in canonical format according to RFC 7049. It is also a requirement of CIP-21, which is not fully implemented.
writeTxWitnessFileTextEnvelope :: ShelleyBasedEra era -> File () 'Out -> KeyWitness era -> IO (Either (FileError ()) ()) Source #
writeTxWitnessFileTextEnvelopeCddl :: ShelleyBasedEra era -> File () 'Out -> KeyWitness era -> IO (Either (FileError ()) ()) Source #
Deprecated: Use writeTxWitnessFileTextEnvelope instead.
deserialiseByronTxCddl :: TextEnvelope -> Either TextEnvelopeCddlError (ATxAux ByteString) Source #
Deprecated: Use deserialiseByronTx instead.
serialiseWitnessLedgerCddl :: ShelleyBasedEra era -> KeyWitness era -> TextEnvelope Source #
Deprecated: Use serialiseWitnessLedger instead.
deserialiseWitnessLedgerCddl :: ShelleyBasedEra era -> TextEnvelope -> Either TextEnvelopeCddlError (KeyWitness era) Source #
Deprecated: Use deserialiseWitnessLedger instead.
Byron tx serialization
writeByronTxFileTextEnvelopeCddl :: File content 'Out -> ATxAux ByteString -> IO (Either (FileError ()) ()) Source #
Deprecated: Use writeByronTxFileTextEnvelope instead.