Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Global blockchain state (emulated).
Synopsis
- data ContractState = forall cp st.(ParameterScope cp, StorageScope st) => ContractState {
- csBalance :: Mutez
- csContract :: Contract cp st
- csStorage :: Value st
- csDelegate :: Maybe KeyHash
- data AddressState
- newtype AddressAliases = AddressAliases (Bimap Alias Address)
- lookupAddress :: Alias -> AddressAliases -> Maybe Address
- asBalance :: AddressState -> Mutez
- newtype VotingPowers = VotingPowers (Map KeyHash Natural)
- vpPick :: KeyHash -> VotingPowers -> Natural
- vpTotal :: VotingPowers -> Natural
- mkVotingPowers :: [(KeyHash, Natural)] -> VotingPowers
- mkVotingPowersFromMap :: Map KeyHash Natural -> VotingPowers
- dummyVotingPowers :: VotingPowers
- newtype BigMapCounter = BigMapCounter {}
- bigMapCounter :: Iso' BigMapCounter Natural
- data GState = GState {}
- gsChainIdL :: Lens' GState ChainId
- gsAddressesL :: Lens' GState (Map Address AddressState)
- gsAddressAliasesL :: Lens' GState AddressAliases
- gsVotingPowersL :: Lens' GState VotingPowers
- gsCounterL :: Lens' GState GlobalCounter
- gsBigMapCounterL :: Lens' GState BigMapCounter
- genesisAddresses :: GenesisList Address
- genesisKeyHashes :: GenesisList KeyHash
- genesisAddress :: Address
- genesisAddress1 :: Address
- genesisAddress2 :: Address
- genesisAddress3 :: Address
- genesisAddressN :: forall n. (SingIPeano n, (ToPeano GenesisAddressesNum > ToPeano n) ~ 'True) => Address
- genesisKeyHash :: KeyHash
- genesisSecretKey :: SecretKey
- genesisSecrets :: GenesisList SecretKey
- initGState :: GState
- readGState :: FilePath -> IO GState
- writeGState :: FilePath -> GState -> IO ()
- data GStateUpdate where
- GSAddAddress :: Address -> AddressState -> GStateUpdate
- GSAddAddressAlias :: Alias -> Address -> GStateUpdate
- GSSetStorageValue :: StorageScope st => Address -> Value st -> GStateUpdate
- GSSetBalance :: Address -> Mutez -> GStateUpdate
- GSIncrementCounter :: GStateUpdate
- GSUpdateCounter :: GlobalCounter -> GStateUpdate
- GSSetBigMapCounter :: BigMapCounter -> GStateUpdate
- GSSetDelegate :: Address -> Maybe KeyHash -> GStateUpdate
- data GStateUpdateError
- applyUpdate :: GStateUpdate -> GState -> Either GStateUpdateError GState
- applyUpdates :: [GStateUpdate] -> GState -> Either GStateUpdateError GState
- extractAllContracts :: GState -> TcOriginatedContracts
Auxiliary types
data ContractState Source #
State of a contract with code.
forall cp st.(ParameterScope cp, StorageScope st) => ContractState | |
|
Instances
FromJSON ContractState Source # | |
Defined in Morley.Michelson.Runtime.GState parseJSON :: Value -> Parser ContractState # parseJSONList :: Value -> Parser [ContractState] # | |
ToJSON ContractState Source # | |
Defined in Morley.Michelson.Runtime.GState toJSON :: ContractState -> Value # toEncoding :: ContractState -> Encoding # toJSONList :: [ContractState] -> Value # toEncodingList :: [ContractState] -> Encoding # | |
Show ContractState Source # | |
Defined in Morley.Michelson.Runtime.GState showsPrec :: Int -> ContractState -> ShowS # show :: ContractState -> String # showList :: [ContractState] -> ShowS # | |
Buildable ContractState Source # | |
Defined in Morley.Michelson.Runtime.GState build :: ContractState -> Builder # | |
Eq ContractState Source # | |
Defined in Morley.Michelson.Runtime.GState (==) :: ContractState -> ContractState -> Bool # (/=) :: ContractState -> ContractState -> Bool # |
data AddressState Source #
State of an arbitrary address.
ASSimple Mutez | For contracts without code we store only its balance. |
ASContract ContractState | For contracts with code we store more state represented by
|
Instances
newtype AddressAliases Source #
Instances
FromJSON AddressAliases Source # | |
Defined in Morley.Michelson.Runtime.GState parseJSON :: Value -> Parser AddressAliases # parseJSONList :: Value -> Parser [AddressAliases] # | |
ToJSON AddressAliases Source # | |
Defined in Morley.Michelson.Runtime.GState toJSON :: AddressAliases -> Value # toEncoding :: AddressAliases -> Encoding # toJSONList :: [AddressAliases] -> Value # toEncodingList :: [AddressAliases] -> Encoding # | |
Show AddressAliases Source # | |
Defined in Morley.Michelson.Runtime.GState showsPrec :: Int -> AddressAliases -> ShowS # show :: AddressAliases -> String # showList :: [AddressAliases] -> ShowS # | |
Eq AddressAliases Source # | |
Defined in Morley.Michelson.Runtime.GState (==) :: AddressAliases -> AddressAliases -> Bool # (/=) :: AddressAliases -> AddressAliases -> Bool # |
lookupAddress :: Alias -> AddressAliases -> Maybe Address Source #
asBalance :: AddressState -> Mutez Source #
Extract balance from AddressState
.
newtype VotingPowers Source #
Distribution of voting power among the contracts.
Voting power reflects the ability of bakers to accept, deny or pass new proposals for protocol updates. I.e. each baker has its vote weight.
This datatype definition may change in future, so its internals are not exported.
Instances
FromJSON VotingPowers Source # | |
Defined in Morley.Michelson.Runtime.GState parseJSON :: Value -> Parser VotingPowers # parseJSONList :: Value -> Parser [VotingPowers] # | |
ToJSON VotingPowers Source # | |
Defined in Morley.Michelson.Runtime.GState toJSON :: VotingPowers -> Value # toEncoding :: VotingPowers -> Encoding # toJSONList :: [VotingPowers] -> Value # toEncodingList :: [VotingPowers] -> Encoding # | |
Show VotingPowers Source # | |
Defined in Morley.Michelson.Runtime.GState showsPrec :: Int -> VotingPowers -> ShowS # show :: VotingPowers -> String # showList :: [VotingPowers] -> ShowS # | |
Eq VotingPowers Source # | |
Defined in Morley.Michelson.Runtime.GState (==) :: VotingPowers -> VotingPowers -> Bool # (/=) :: VotingPowers -> VotingPowers -> Bool # |
vpTotal :: VotingPowers -> Natural Source #
Get total voting power.
mkVotingPowers :: [(KeyHash, Natural)] -> VotingPowers Source #
Create voting power distribution.
If some key is encountered multiple times, voting power will be summed up.
mkVotingPowersFromMap :: Map KeyHash Natural -> VotingPowers Source #
Create voting power distribution from map.
dummyVotingPowers :: VotingPowers Source #
Dummy VotingPowers
. We give all the voting power to two genesis addreses
as the addresses holding lot of money. Only two addresses are involved for
simplicity.
newtype BigMapCounter Source #
All big_maps stored in a chain have a globally unique ID.
We use this counter to keep track of how many big_maps have been created so far, and to generate new IDs whenever a new big_map is created.
Instances
GState
Persistent data passed to Morley contracts which can be updated as result of contract execution.
GState | |
|
genesisAddresses :: GenesisList Address Source #
Initially these addresses have a lot of money.
genesisKeyHashes :: GenesisList KeyHash Source #
KeyHash of genesis address.
genesisAddress :: Address Source #
One of genesis addresses.
More genesisAddresses which can be used in tests
genesisAddress1 :: Address Source #
More genesis addresses
genesisAddress2 :: Address Source #
More genesis addresses
genesisAddress3 :: Address Source #
More genesis addresses
genesisAddressN :: forall n. (SingIPeano n, (ToPeano GenesisAddressesNum > ToPeano n) ~ 'True) => Address Source #
More genesis addresses, via a type-level natural
genesisAddressN @7
Note that
, genesisAddress
== genesisAddressN @0
,
etc.genesisAddress1
== genesisAddressN @1
genesisKeyHash :: KeyHash Source #
One of genesis key hashes.
Genesis secret keys
genesisSecretKey :: SecretKey Source #
Secret key assotiated with genesisAddress
.
genesisSecrets :: GenesisList SecretKey Source #
Secrets from which genesis addresses are derived from.
initGState :: GState Source #
Operations on GState
data GStateUpdate where Source #
Updates that can be applied to GState
.
GSAddAddress :: Address -> AddressState -> GStateUpdate | |
GSAddAddressAlias :: Alias -> Address -> GStateUpdate | |
GSSetStorageValue :: StorageScope st => Address -> Value st -> GStateUpdate | |
GSSetBalance :: Address -> Mutez -> GStateUpdate | |
GSIncrementCounter :: GStateUpdate | |
GSUpdateCounter :: GlobalCounter -> GStateUpdate | |
GSSetBigMapCounter :: BigMapCounter -> GStateUpdate | |
GSSetDelegate :: Address -> Maybe KeyHash -> GStateUpdate |
Instances
Show GStateUpdate Source # | |
Defined in Morley.Michelson.Runtime.GState showsPrec :: Int -> GStateUpdate -> ShowS # show :: GStateUpdate -> String # showList :: [GStateUpdate] -> ShowS # | |
Buildable GStateUpdate Source # | |
Defined in Morley.Michelson.Runtime.GState build :: GStateUpdate -> Builder # |
data GStateUpdateError Source #
GStateAddressExists Address | |
GStateUnknownAddress Address | |
GStateNotContract Address | |
GStateStorageNotMatch Address |
Instances
Show GStateUpdateError Source # | |
Defined in Morley.Michelson.Runtime.GState showsPrec :: Int -> GStateUpdateError -> ShowS # show :: GStateUpdateError -> String # showList :: [GStateUpdateError] -> ShowS # | |
Buildable GStateUpdateError Source # | |
Defined in Morley.Michelson.Runtime.GState build :: GStateUpdateError -> Builder # |
applyUpdate :: GStateUpdate -> GState -> Either GStateUpdateError GState Source #
Apply GStateUpdate
to GState
.
applyUpdates :: [GStateUpdate] -> GState -> Either GStateUpdateError GState Source #
Apply a list of GStateUpdate
s to GState
.
extractAllContracts :: GState -> TcOriginatedContracts Source #
Retrieve all contracts stored in GState