Safe Haskell | None |
---|---|
Language | Haskell2010 |
Core primitive Tezos types.
Synopsis
- data Mutez
- mkMutez :: Word64 -> Maybe Mutez
- mkMutez' :: Integral i => i -> Either Text Mutez
- unsafeMkMutez :: HasCallStack => Word64 -> Mutez
- toMutez :: Word32 -> Mutez
- addMutez :: Mutez -> Mutez -> Maybe Mutez
- unsafeAddMutez :: HasCallStack => Mutez -> Mutez -> Mutez
- subMutez :: Mutez -> Mutez -> Maybe Mutez
- unsafeSubMutez :: HasCallStack => Mutez -> Mutez -> Mutez
- mulMutez :: Integral a => Mutez -> a -> Maybe Mutez
- divModMutez :: Mutez -> Mutez -> Maybe (Word64, Mutez)
- divModMutezInt :: Integral a => Mutez -> a -> Maybe (Mutez, Mutez)
- mutezToInt64 :: Mutez -> Int64
- zeroMutez :: Mutez
- oneMutez :: Mutez
- prettyTez :: Mutez -> Text
- newtype Timestamp = Timestamp {}
- timestampToSeconds :: Integral a => Timestamp -> a
- timestampFromSeconds :: Integer -> Timestamp
- timestampFromUTCTime :: UTCTime -> Timestamp
- timestampToUTCTime :: Timestamp -> UTCTime
- timestampPlusSeconds :: Timestamp -> Integer -> Timestamp
- formatTimestamp :: Timestamp -> Text
- parseTimestamp :: Text -> Maybe Timestamp
- timestampQuote :: QuasiQuoter
- getCurrentTime :: IO Timestamp
- farFuture :: Timestamp
- farPast :: Timestamp
- newtype ChainId = ChainIdUnsafe {}
- mkChainId :: ByteString -> Maybe ChainId
- mkChainIdUnsafe :: HasCallStack => ByteString -> ChainId
- dummyChainId :: ChainId
- formatChainId :: ChainId -> Text
- mformatChainId :: ChainId -> MText
- parseChainId :: Text -> Either ParseChainIdError ChainId
- chainIdLength :: Int
Mutez
Mutez is a wrapper over integer data type. 1 mutez is 1 token (μTz).
Instances
Bounded Mutez Source # | |
Enum Mutez Source # | |
Eq Mutez Source # | |
Data Mutez Source # | |
Defined in Tezos.Core gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Mutez -> c Mutez # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Mutez # dataTypeOf :: Mutez -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Mutez) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Mutez) # gmapT :: (forall b. Data b => b -> b) -> Mutez -> Mutez # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Mutez -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Mutez -> r # gmapQ :: (forall d. Data d => d -> u) -> Mutez -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Mutez -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Mutez -> m Mutez # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Mutez -> m Mutez # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Mutez -> m Mutez # | |
Ord Mutez Source # | |
Show Mutez Source # | |
Generic Mutez Source # | |
ToJSON Mutez Source # | |
Defined in Tezos.Core | |
FromJSON Mutez Source # | |
NFData Mutez Source # | |
Defined in Tezos.Core | |
Buildable Mutez Source # | |
Defined in Tezos.Core | |
HasCLReader Mutez Source # | |
Defined in Tezos.Core | |
IsoValue Mutez Source # | |
TypeHasDoc Mutez Source # | |
Defined in Michelson.Typed.Haskell.Doc | |
type Rep Mutez Source # | |
Defined in Tezos.Core | |
type ToT Mutez Source # | |
Defined in Michelson.Typed.Haskell.Value | |
type TypeDocFieldDescriptions Mutez Source # | |
Defined in Michelson.Typed.Haskell.Doc |
mkMutez' :: Integral i => i -> Either Text Mutez Source #
Version of mkMutez
that accepts a number of any type.
unsafeMkMutez :: HasCallStack => Word64 -> Mutez Source #
toMutez :: Word32 -> Mutez Source #
Safely create Mutez
.
This is recommended way to create Mutez
from a numeric literal;
you can't construct all valid Mutez
values using this function
but for small values it works neat.
Warnings displayed when trying to construct invalid Natural
or Word
literal are hardcoded for these types in GHC implementation, so we can only
exploit these existing rules.
unsafeAddMutez :: HasCallStack => Mutez -> Mutez -> Mutez Source #
Partial addition of Mutez
, should be used only if you're
sure there'll be no overflow.
unsafeSubMutez :: HasCallStack => Mutez -> Mutez -> Mutez Source #
Partial subtraction of Mutez
, should be used only if you're
sure there'll be no underflow.
divModMutez :: Mutez -> Mutez -> Maybe (Word64, Mutez) Source #
Euclidian division of two Mutez
values.
divModMutezInt :: Integral a => Mutez -> a -> Maybe (Mutez, Mutez) Source #
Euclidian division of Mutez
and a number.
mutezToInt64 :: Mutez -> Int64 Source #
Convert mutez to signed number.
TODO [#423]: try to provide a generic safe conversion method
prettyTez :: Mutez -> Text Source #
>>>
prettyTez (toMutez 420)
"0.00042 ꜩ">>>
prettyTez (toMutez 42000000)
"42 ꜩ"
Timestamp
Time in the real world. Use the functions below to convert it to/from Unix time in seconds.
Instances
timestampToSeconds :: Integral a => Timestamp -> a Source #
timestampPlusSeconds :: Timestamp -> Integer -> Timestamp Source #
Add given amount of seconds to a Timestamp
.
formatTimestamp :: Timestamp -> Text Source #
Display timestamp in human-readable way as used by Michelson. Uses UTC timezone, though maybe we should take it as an argument.
NB: this will render timestamp with up to seconds precision.
timestampQuote :: QuasiQuoter Source #
Quote a value of type Timestamp
in yyyy-mm-ddThh:mm:ss[.sss]Z
format.
>>>
formatTimestamp [timestampQuote| 2019-02-21T16:54:12.2344523Z |]
"2019-02-21T16:54:12Z"
Inspired by 'time-quote' library.
farFuture :: Timestamp Source #
Timestamp which is always greater than result of getCurrentTime
.
Timestamp which is always less than result of getCurrentTime
.
ChainId
Identifier of a network (babylonnet, mainnet, test network or other). Evaluated as hash of the genesis block.
The only operation supported for this type is packing. Use case: multisig contract, for instance, now includes chain ID into signed data "in order to add extra replay protection between the main chain and the test chain".
Instances
Eq ChainId Source # | |
Show ChainId Source # | |
Generic ChainId Source # | |
ToJSON ChainId Source # | |
Defined in Tezos.Core | |
FromJSON ChainId Source # | |
NFData ChainId Source # | |
Defined in Tezos.Core | |
Buildable ChainId Source # | |
Defined in Tezos.Core | |
IsoValue ChainId Source # | |
TypeHasDoc ChainId Source # | |
Defined in Michelson.Typed.Haskell.Doc | |
type Rep ChainId Source # | |
Defined in Tezos.Core type Rep ChainId = D1 ('MetaData "ChainId" "Tezos.Core" "morley-1.12.0-inplace" 'True) (C1 ('MetaCons "ChainIdUnsafe" 'PrefixI 'True) (S1 ('MetaSel ('Just "unChainId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) | |
type ToT ChainId Source # | |
Defined in Michelson.Typed.Haskell.Value | |
type TypeDocFieldDescriptions ChainId Source # | |
Defined in Michelson.Typed.Haskell.Doc |
mkChainIdUnsafe :: HasCallStack => ByteString -> ChainId Source #
Construct chain ID from raw bytes or fail otherwise. Expects exactly 4 bytes.
dummyChainId :: ChainId Source #
Identifier of a pseudo network.
formatChainId :: ChainId -> Text Source #
Pretty print ChainId
as it is displayed e.g. in
tezos-client rpc get chainsmain/chain_id
call.
Example of produced value: NetXUdfLh6Gm88t.
mformatChainId :: ChainId -> MText Source #
chainIdLength :: Int Source #