cardano-wallet-core-2022.7.1: The Wallet Backend for a Cardano node.
Copyright © 2020-2021 IOHK
License Apache-2.0
Safe Haskell None
Language Haskell2010

Cardano.Wallet.Unsafe

Description

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

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.

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 #

Decode a bech32-encoded Text into an Address , or fail.

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.

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.

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.