Copyright | © 2020-2021 IOHK |
---|---|
License | Apache-2.0 |
Safe Haskell | None |
Language | Haskell2010 |
Conversion functions which don't have error handling. These are quite convenient to use for jobs like testing, debugging, etc.
But these "unsafe" functions should not be used in application code, unless it's certain that the error case will never happen.
Synopsis
- unsafeRight :: ( Buildable e, HasCallStack ) => Either e a -> a
- unsafeFromHex :: forall b. ( HasCallStack , ByteArray b) => ByteString -> b
- unsafeFromHexText :: HasCallStack => Text -> ByteString
- unsafeFromBase64 :: HasCallStack => ByteString -> ByteString
- unsafeFromHexFile :: HasCallStack => FilePath -> IO ByteString
- unsafeDecodeAddress :: forall n. ( HasCallStack , DecodeAddress n) => Text -> Address
- unsafeDecodeHex :: HasCallStack => Get a -> ByteString -> a
- unsafeFromText :: ( FromText a, HasCallStack ) => Text -> a
- unsafeRunExceptT :: ( MonadFail m, Show e) => ExceptT e m a -> m a
- unsafeXPrv :: HasCallStack => ByteString -> XPrv
- unsafeXPub :: HasCallStack => ByteString -> XPub
- unsafeDeserialiseCbor :: HasCallStack => ( forall s. Decoder s a) -> ByteString -> a
- unsafeBech32DecodeFile :: HasCallStack => FilePath -> IO ByteString
- unsafeBech32Decode :: HasCallStack => Text -> ByteString
- unsafeMkPercentage :: HasCallStack => Rational -> Percentage
- unsafeIntToWord :: forall from to. ( HasCallStack , Integral from, Bounded to, Integral to, Typeable from, Typeable to, Show from) => from -> to
- someDummyMnemonic :: forall mw ent csz. ( HasCallStack , ValidEntropySize ent, ValidChecksumSize ent csz, ValidMnemonicSentence mw, ent ~ EntropySize mw, mw ~ MnemonicWords ent) => Proxy mw -> SomeMnemonic
- unsafeMkMnemonic :: forall mw n csz. ( ConsistentEntropy n mw csz, EntropySize mw ~ n, HasCallStack ) => [ Text ] -> Mnemonic mw
- unsafeMkEntropy :: forall ent csz. ( HasCallStack , ValidEntropySize ent, ValidChecksumSize ent csz) => ByteString -> Entropy ent
- unsafeMkSomeMnemonicFromEntropy :: forall mw ent csz. ( HasCallStack , ValidEntropySize ent, ValidChecksumSize ent csz, ValidMnemonicSentence mw, ent ~ EntropySize mw, mw ~ MnemonicWords ent) => Proxy mw -> ByteString -> SomeMnemonic
Documentation
unsafeRight :: ( Buildable e, HasCallStack ) => Either e a -> a Source #
Take the right side of an
Either
value. Crash badly if it was a left.
unsafeFromHex :: forall b. ( HasCallStack , ByteArray b) => ByteString -> b Source #
Decode an hex-encoded
ByteString
into raw bytes, or fail.
unsafeFromHexText :: HasCallStack => Text -> ByteString Source #
Decode hex-encoded
Text
into a
ByteString
, or fail. This variant of
unsafeFromHex
may be easier to use because it's not polymorphic.
unsafeFromBase64 :: HasCallStack => ByteString -> ByteString Source #
Decode a base64-encoded
ByteString
into raw bytes, or fail.
unsafeFromHexFile :: HasCallStack => FilePath -> IO ByteString Source #
Load a hex string from file. Any non-hexadecimal characters are ignored.
unsafeDecodeAddress :: forall n. ( HasCallStack , DecodeAddress n) => Text -> Address Source #
unsafeDecodeHex :: HasCallStack => Get a -> ByteString -> a Source #
Run a decoder on a hex-encoded
ByteString
, or fail.
unsafeFromText :: ( FromText a, HasCallStack ) => Text -> a Source #
Decode the given data-type from a textual representation, or fail.
unsafeRunExceptT :: ( MonadFail m, Show e) => ExceptT e m a -> m a Source #
Run an
ExceptT
and throws the error if any. This makes sense only if
called after checking for an invariant or, after ensuring that preconditions
for meeting the underlying error have been discarded.
unsafeXPrv :: HasCallStack => ByteString -> XPrv Source #
Build a
XPrv
from a bytestring
unsafeXPub :: HasCallStack => ByteString -> XPub Source #
Build a
XPub
from a bytestring
unsafeDeserialiseCbor :: HasCallStack => ( forall s. Decoder s a) -> ByteString -> a Source #
CBOR deserialise without error handling - handy for prototypes or testing.
unsafeBech32DecodeFile :: HasCallStack => FilePath -> IO ByteString Source #
Load the data part of a bech32-encoded string from file. These files often
come from
jcli
. Only the first line of the file is read.
unsafeBech32Decode :: HasCallStack => Text -> ByteString Source #
Get the data part of a bech32-encoded string, ignoring the human-readable part.
unsafeMkPercentage :: HasCallStack => Rational -> Percentage Source #
unsafeIntToWord :: forall from to. ( HasCallStack , Integral from, Bounded to, Integral to, Typeable from, Typeable to, Show from) => from -> to Source #
Convert an integer type of any range to a machine word.
Only use it for values which have come from the ledger, and should fit in the given type, according to the spec.
If this conversion would under/overflow, there is not much we can do except to hastily exit.
someDummyMnemonic :: forall mw ent csz. ( HasCallStack , ValidEntropySize ent, ValidChecksumSize ent csz, ValidMnemonicSentence mw, ent ~ EntropySize mw, mw ~ MnemonicWords ent) => Proxy mw -> SomeMnemonic Source #
A dummy
SomeMnemonic
for testing.
Could have been named
dummySomeMnemonic
, but this way it sounds more like
valid english.
unsafeMkMnemonic :: forall mw n csz. ( ConsistentEntropy n mw csz, EntropySize mw ~ n, HasCallStack ) => [ Text ] -> Mnemonic mw Source #
Build
Mnemonic
from literals
unsafeMkEntropy :: forall ent csz. ( HasCallStack , ValidEntropySize ent, ValidChecksumSize ent csz) => ByteString -> Entropy ent Source #
unsafeMkSomeMnemonicFromEntropy :: forall mw ent csz. ( HasCallStack , ValidEntropySize ent, ValidChecksumSize ent csz, ValidMnemonicSentence mw, ent ~ EntropySize mw, mw ~ MnemonicWords ent) => Proxy mw -> ByteString -> SomeMnemonic Source #