Crate casper_types

Source
Expand description

Types used to allow creation of Wasm contracts and tests for use on the Casper Platform.

Re-exports§

pub use account::Account;
pub use global_state::Pointer;
pub use runtime_footprint::RuntimeFootprint;
pub use system::mint::METHOD_TRANSFER;
pub use crypto::*;

Modules§

account
Contains types and constants associated with user accounts.
addressable_entity
Data types for supporting contract headers feature.
api_error
Contains ApiError and associated helper functions.
bytesrepr
Contains serialization and deserialization code for types used throughout the system.
checksummed_hex
Checksummed hex encoding following an EIP-55-like scheme.
contract_messages
Data types for interacting with contract level messages.
contracts
Data types for supporting contract headers feature.
crypto
Cryptographic types and operations on them
execution
Types related to execution of deploys.
file_utilsstd-fs-io
Utilities for handling reading from and writing to files.
genstesting or gens
Contains functions for generating arbitrary values for use by Proptest.
global_state
Types for global state.
runtime_footprint
serde_option_time_diffstd
A module for the [serde(with = serde_option_time_diff)] attribute, to serialize and deserialize Option<TimeDiff> treating None as 0.
system
System modules, formerly known as “system contracts”
testingtesting
An RNG for testing purposes.

Macros§

runtime_args
Macro that makes it easier to construct named arguments.

Structs§

AccessRights
A struct which behaves like a set of bitflags to define access rights associated with a URef.
AccountConfigstd
Configuration of an individial account in accounts.toml
AccountsConfigstd
Configuration values associated with accounts.toml
AddressableEntity
Methods and type signatures supported by a contract.
AddressableEntityHash
A newtype wrapping a HashAddr which references an AddressableEntity in the global state.
AdministratorAccountstd
Special account in the system that is useful only for some private chains.
Approval
A struct containing a signature of a transaction hash and the public key of the signer.
ApprovalsHash
The cryptographic hash of the bytesrepr-encoded set of approvals for a single [``].
AuctionCostsstd
Description of the costs of calling auction entrypoints.
AuctionStateDeprecated
Data structure summarizing auction contract data.
AvailableBlockRange
An unbroken, inclusive range of blocks.
BlockBodyV1
The body portion of a block. Version 1.
BlockBodyV2
The body portion of a block. Version 2.
BlockHash
The cryptographic hash of a Block.
BlockHashAndHeight
The block hash and height of a given block.
BlockHeaderV1
The header portion of a block.
BlockHeaderV2
The header portion of a block.
BlockHeaderWithSignatures
A block header and collection of signatures of a given block.
BlockSignaturesV1
A collection of signatures for a single block, along with the associated block’s hash and era ID.
BlockSignaturesV2
A collection of signatures for a single block, along with the associated block’s hash and era ID.
BlockSyncStatus
The status of syncing an individual block.
BlockSynchronizerStatus
The status of the block synchronizer.
BlockTime
A newtype wrapping a u64 which represents the block time.
BlockV1
A block after execution, with the resulting global state root hash. This is the core component of the Casper linear blockchain. Version 1.
BlockV2
A block after execution, with the resulting global state root hash. This is the core component of the Casper linear blockchain. Version 2.
BlockWithSignatures
A block and signatures for that block.
BrTableCoststd
Definition of a cost table for a Wasm br_table opcode.
ByteCode
A container for contract’s Wasm bytes.
ByteCodeHash
A newtype wrapping a HashAddr which is the raw bytes of the ByteCodeHash
CLTypeMismatch
Error while converting a CLValue into a given type.
CLValue
A Casper value, i.e. a value which can be stored and manipulated by smart contracts.
CLValueDictionary
Wraps a CLValue for storage in a dictionary.
ChainNameDigest
A cryptographic hash of a chain name.
Chainspecstd
A collection of configuration settings describing the state of the system at genesis and after upgrades to basic system functionality occurring after genesis.
ChainspecRawBytesstd
The raw bytes of the chainspec.toml, genesis accounts.toml, and global_state.toml files.
ChainspecRegistrystd
The chainspec registry.
ChecksumRegistry
The checksum registry.
ChunkWithProof
Represents a chunk of data with attached proof.
ContextAccessRights
Access rights for a given runtime context.
Contract
Methods and type signatures supported by a contract.
ContractWasm
A container for contract’s WASM bytes.
ContractWasmHash
A newtype wrapping a HashAddr which is the raw bytes of the ContractWasmHash
ControlFlowCostsstd
Definition of a cost table for a Wasm control flow opcodes.
CoreConfigstd
Configuration values associated with the core protocol.
DelegatorConfigstd
Configuration values related to a delegator.
Deploy
A signed smart contract.
DeployConfigstd
Configuration values associated with deploys.
DeployExcessiveSizeError
Error returned when a Deploy is too large.
DeployHash
The cryptographic hash of a Deploy.
DeployHeader
The header portion of a Deploy.
DeployId
The unique identifier of a Deploy, comprising its DeployHash and ApprovalsHash.
DeployInfo
Information relating to the given Deploy.
Digest
The output of the hash function.
DisplayIter
A helper to allow Display printing the items of an iterator with a comma and space between each.
EntityEntryPoint
Type signature of a method. Order of arguments matter since can be referenced by index as well as name.
EntityVersionKey
Major element of ProtocolVersion combined with EntityVersion.
EntityVersions
Collection of entity versions.
EntryPoints
Collection of named entry points.
EraEndV1
Information related to the end of an era, and validator weights for the following era.
EraEndV2
Information related to the end of an era, and validator weights for the following era.
EraId
Era ID newtype.
EraReport
Equivocation, reward and validator inactivity information.
ExecutionInfo
The block hash and height in which a given deploy was executed, along with the execution result if known.
FinalitySignatureId
An identifier for a FinalitySignature.
FinalitySignatureV1
A validator’s signature of a block, confirming it is finalized.
FinalitySignatureV2
A validator’s signature of a block, confirming it is finalized.
Gas
The Gas struct represents a U512 amount of gas.
GenesisConfigstd
Represents the details of a genesis process.
GenesisValidatorstd
Represents details about genesis account’s validator status.
GlobalStateUpdatestd
Type storing the information about modifications to be applied to the global state.
GlobalStateUpdateConfigstd
Type storing global state update entries.
Group
A (labelled) “user group”. Each method of a versioned contract may be associated with one or more user groups which are allowed to call it.
Groups
Collection of named groups.
HandlePaymentCostsstd
Description of the costs of calling handle_payment entrypoints.
HighwayConfigstd
Configuration values relevant to Highway consensus.
HoldsEpoch
Holds epoch type.
HostFunctionstd
Representation of a host function cost.
HostFunctionCostsV1std
Definition of a host function cost table.
HostFunctionCostsV2std
Definition of a host function cost table.
HostFunctionV2std
Representation of a host function cost.
IndexedMerkleProof
A Merkle proof of the given chunk.
JsonBlockWithSignaturesstd and json-schema
A JSON-friendly representation of a block and the signatures for that block.
JsonEraValidatorsDeprecated
The validators for the given era.
JsonValidatorWeightsDeprecated
A validator’s weight.
MessageLimitsstd
Configuration for messages limits.
MintCostsstd
Description of the costs of calling mint entry points.
Motes
A struct representing a number of Motes.
NamedArg
Named arguments to a contract.
NamedKeys
A collection of named keys.
NetworkConfigstd
Configuration values associated with the network.
NextUpgradestd
Information about the next protocol upgrade.
OpcodeCostsstd
Definition of a cost table for Wasm opcodes.
Package
Entity definition, metadata, and security container.
PackageHash
A newtype wrapping a HashAddr which references a Package in the global state.
Parameter
Parameter to a method
PeerEntry
Node peer entry.
Peers
Map of peer IDs to network addresses.
ProtocolConfigstd
Configuration values associated with the protocol.
ProtocolUpgradeConfigstd
Represents the configuration of a protocol upgrade.
ProtocolVersion
A newtype wrapping a SemVer which represents a Casper Platform protocol version.
RewardedSignatures
Describes finality signatures that will be rewarded in a block. Consists of a vector of SingleBlockRewardedSignatures, each of which describes signatures for a single ancestor block. The first entry represents the signatures for the parent block, the second for the parent of the parent, and so on.
RuntimeArgs
Represents a collection of arguments passed to a smart contract.
SemVer
A struct for semantic versioning.
SingleBlockRewardedSignatures
List of identifiers for finality signatures for a particular past block.
StandardPaymentCostsstd
Description of the costs of calling standard payment entry points.
StorageCostsstd
Represents a cost table for storage costs.
StoredValueTypeMismatch
An error struct representing a type mismatch in StoredValue operations.
SystemConfigstd
Definition of costs in the system.
SystemHashRegistry
The system entity registry.
TestBlockBuilderstd and testing
A helper to build the blocks with various properties required for tests.
TestBlockV1Builderstd and testing
A helper to build the blocks with various properties required for tests.
TimeDiff
A time difference between two timestamps.
Timestamp
A timestamp type, representing a concrete moment in time.
TransactionConfigstd
Configuration values associated with Transactions.
TransactionId
The unique identifier of a Transaction, comprising its TransactionHash and ApprovalsHash.
TransactionLaneDefinitionstd
Structured limits imposed on a transaction lane
TransactionV1
A unit of work sent by a client to the network, which when executed can cause global state to be altered.
TransactionV1Configstd
Configuration values associated with V1 Transactions.
TransactionV1ExcessiveSizeError
Error returned when a transaction is too large.
TransactionV1Hash
The cryptographic hash of a TransactionV1.
TransactionV1Payload
Structure aggregating internal data of V1 transaction.
TransferAddr
A newtype wrapping a [u8; TRANSFER_ADDR_LENGTH] which is the raw bytes of the transfer address.
TransferV1
Represents a version 1 transfer from one purse to another.
TransferV2
Represents a version 2 transfer from one purse to another.
U128
Little-endian large integer type
U256
Little-endian large integer type
U512
Little-endian large integer type
URef
Represents an unforgeable reference, containing an address in the network’s global storage and the AccessRights of the reference.
VacancyConfigstd
The configuration to determine gas price based on block vacancy.
ValidatorConfigstd
Validator account configuration.
WasmConfigstd
Configuration of the Wasm execution environment.
WasmV1Configstd
Configuration of the Wasm execution environment for V1 execution machine.
WasmV2Configstd
Configuration of the Wasm execution environment for V2 execution machine.

Enums§

ActivationPointstd
The first era to which the associated protocol version applies.
AddressableEntityIdentifier
Identifier for the contract object within a TransactionTarget::Stored or an ExecutableDeployItem.
ApiError
Errors which can be encountered while running a smart contract.
Block
A block after execution.
BlockBody
The versioned body portion of a block. It encapsulates different variants of the BlockBody struct.
BlockGlobalAddr
Address for singleton values associated to specific block. These are values which are calculated or set during the execution of a block such as the block timestamp, or the total count of messages emitted during the execution of the block, and so on.
BlockGlobalAddrTag
Serialization tag for BlockGlobalAddr variants.
BlockHeader
The versioned header portion of a block. It encapsulates different variants of the BlockHeader struct.
BlockHeaderWithSignaturesValidationError
An error which can result from validating a BlockHeaderWithSignatures.
BlockIdentifier
Identifier for possible ways to retrieve a block.
BlockSignatures
A collection of signatures for a single block, along with the associated block’s hash and era ID.
BlockSignaturesMergeError
An error returned during an attempt to merge two incompatible BlockSignaturesV1.
BlockValidationError
An error that can arise when validating a block’s cryptographic integrity using its hashes.
ByteCodeAddr
An address for ByteCode records stored in global state.
ByteCodeKind
The type of Byte code.
CLType
Casper types, i.e. types which can be stored and manipulated by smart contracts.
CLValueError
Error relating to CLValue operations.
ChunkWithProofVerificationError
Error validating a chunk with proof.
ConsensusProtocolNamestd
Consensus protocol name.
ContractRuntimeTag
DeployDecodeFromJsonError
Error while decoding a Deploy from JSON.
DeployError
Errors other than validation failures relating to Deploys.
DigestError
Possible hashing errors.
EntityAddr
The address for an AddressableEntity which contains the 32 bytes and tagging information.
EntityKind
The type of Package.
EntryPointAccess
Enum describing the possible access control options for a contract entry point (method).
EntryPointAddr
The entry point address.
EntryPointPayment
An enum specifying who pays for the invocation and execution of the entrypoint.
EntryPointType
Context of method execution
EntryPointValue
The encaspulated representation of entrypoints.
EraEnd
The versioned era end of a block, storing the data for a switch block. It encapsulates different variants of the EraEnd struct.
ExecutableDeployItem
The executable component of a Deploy.
ExecutableDeployItemIdentifier
Identifier for an ExecutableDeployItem.
FeeHandlingstd
Defines how fees are handled in the system.
FinalitySignature
A validator’s signature of a block, confirming it is finalized.
GenesisAccountstd
This enum represents possible states of a genesis account.
GlobalStateIdentifier
Identifier for possible ways to query Global State
GlobalStateUpdateErrorstd
Error loading global state update file.
GrantedAccess
Used to indicate if a granted URef was already held by the context.
HoldBalanceHandlingstd
Defines how a given network handles holds when calculating available balances. There may be multiple types of holds (such as Processing and Gas currently, and potentially other kinds in the future), and each type of hold can differ on how it applies to available balance calculation.
InitiatorAddr
The address of the initiator of a crate::Transaction.
InvalidDeploy
A representation of the way in which a deploy failed validation checks.
InvalidTransaction
A representation of the way in which a transaction failed validation checks.
InvalidTransactionV1
Returned when a TransactionV1 fails validation.
Key
The key under which data (e.g. CLValues, smart contracts, user accounts) are stored in global state.
KeyFromStrError
Errors produced when converting a String into a Key.
KeyTag
LegacyRequiredFinalitystd
Which finality a legacy block needs during a fast sync.
MerkleConstructionError
Error during the construction of a Merkle proof.
MerkleVerificationError
Error validating a Merkle proof of a chunk.
PackageIdentifier
Identifier for the package object within a TransactionTarget::Stored or an ExecutableDeployItem.
PackageStatus
A enum to determine the lock status of the package.
ParseSemVerError
Parsing error when creating a SemVer.
Phase
The phase in which a given contract is executing.
PricingHandlingstd
Defines what pricing mode a network allows. Correlates to the PricingMode of a crate::Transaction. Nodes will not accept transactions whose pricing mode does not match.
PricingMode
The pricing mode of a Transaction.
PricingModeError
Errors that can occur when calling PricingMode functions
RefundHandlingstd
Defines how refunds are calculated.
Rewards
Rewards distributed to validators.
StoredValue
A value stored in Global State.
StoredValueTag
Tag used to discriminate between different variants of StoredValue.
Transaction
A versioned wrapper for a transaction or deploy.
TransactionArgs
The arguments of a transaction, which can be either a named set of runtime arguments or a chunked bytes.
TransactionEntryPoint
The entry point of a crate::Transaction.
TransactionHash
A versioned wrapper for a transaction hash or deploy hash.
TransactionInvocationTarget
The identifier of a crate::TransactionTarget::Stored.
TransactionRuntimeParams
TransactionScheduling
The scheduling mode of a crate::Transaction.
TransactionTarget
The execution target of a crate::Transaction.
TransactionV1DecodeFromJsonError
Error while decoding a TransactionV1 from JSON.
TransactionV1Error
Errors other than validation failures relating to Transactions.
Transfer
A versioned wrapper for a transfer.
TransferFromStrError
Error returned when decoding a TransferAddr from a formatted string.
TransferTarget
The various types which can be used as the target runtime argument of a native transfer.
TransferredTo
The result of a successful transfer between purses.
UIntParseError
Error type for parsing U128, U256, U512 from a string.
URefFromStrError
Error while parsing a URef from a formatted string.
ValidatorChange
A change to a validator’s status between two eras.
VersionCheckResult
The result of ProtocolVersion::check_next_version.

Constants§

ACCESS_RIGHTS_SERIALIZED_LENGTH
The number of bytes in a serialized AccessRights.
AUCTION_LANE_ID
The lane identifier for the native auction interaction.
BLAKE2B_DIGEST_LENGTH
The number of bytes in a Blake2b hash
BLOCKTIME_SERIALIZED_LENGTH
The number of bytes in a serialized BlockTime.
DEFAULT_ADD_BID_COSTstd and testing
Default cost of the add_bid auction entry point.
DEFAULT_ADD_COSTstd and testing
Default cost of the add Wasm opcode.
DEFAULT_BASELINE_MOTES_AMOUNTstd
Default baseline motes amount.
DEFAULT_BIT_COSTstd and testing
Default cost of the bit Wasm opcode.
DEFAULT_CONST_COSTstd and testing
Default cost of the const Wasm opcode.
DEFAULT_CONTROL_FLOW_BLOCK_OPCODEstd and testing
Default cost of the block Wasm opcode.
DEFAULT_CONTROL_FLOW_BR_IF_OPCODEstd and testing
Default cost of the br_if Wasm opcode.
DEFAULT_CONTROL_FLOW_BR_OPCODEstd and testing
Default cost of the br Wasm opcode.
DEFAULT_CONTROL_FLOW_BR_TABLE_MULTIPLIERstd and testing
Default multiplier for the size of targets in br_table Wasm opcode.
DEFAULT_CONTROL_FLOW_BR_TABLE_OPCODEstd and testing
Default fixed cost of the br_table Wasm opcode.
DEFAULT_CONTROL_FLOW_CALL_INDIRECT_OPCODEstd and testing
Default cost of the call_indirect Wasm opcode.
DEFAULT_CONTROL_FLOW_CALL_OPCODEstd and testing
Default cost of the call Wasm opcode.
DEFAULT_CONTROL_FLOW_DROP_OPCODEstd and testing
Default cost of the drop Wasm opcode.
DEFAULT_CONTROL_FLOW_ELSE_OPCODEstd and testing
Default cost of the else Wasm opcode.
DEFAULT_CONTROL_FLOW_END_OPCODEstd and testing
Default cost of the end Wasm opcode.
DEFAULT_CONTROL_FLOW_IF_OPCODEstd and testing
Default cost of the if Wasm opcode.
DEFAULT_CONTROL_FLOW_LOOP_OPCODEstd and testing
Default cost of the loop Wasm opcode.
DEFAULT_CONTROL_FLOW_RETURN_OPCODEstd and testing
Default cost of the return Wasm opcode.
DEFAULT_CONTROL_FLOW_SELECT_OPCODEstd and testing
Default cost of the select Wasm opcode.
DEFAULT_CONVERSION_COSTstd and testing
Default cost of the conversion Wasm opcode.
DEFAULT_CURRENT_MEMORY_COSTstd and testing
Default cost of the current_memory Wasm opcode.
DEFAULT_DELEGATE_COSTstd and testing
Default cost of the delegate auction entry point.
DEFAULT_DIV_COSTstd and testing
Default cost of the div Wasm opcode.
DEFAULT_ENTRY_POINT_NAME
Default name for an entry point.
DEFAULT_FEE_HANDLINGstd and testing
Default fee handling.
DEFAULT_GAS_HOLD_INTERVALstd
Default gas hold interval.
DEFAULT_GLOBAL_COSTstd and testing
Default cost of the global Wasm opcode.
DEFAULT_GROW_MEMORY_COSTstd and testing
Default cost of the grow_memory Wasm opcode.
DEFAULT_HOST_FUNCTION_NEW_DICTIONARYstd
Host function cost unit for a new dictionary.
DEFAULT_INTEGER_COMPARISON_COSTstd and testing
Default cost of the integer_comparison Wasm opcode.
DEFAULT_LARGE_TRANSACTION_GAS_LIMITstd and testing
Default gas limit of standard transactions
DEFAULT_LOAD_COSTstd and testing
Default cost of the load Wasm opcode.
DEFAULT_LOCAL_COSTstd and testing
Default cost of the local Wasm opcode.
DEFAULT_MAX_PAYMENT_MOTESstd and testing
The default maximum number of motes that payment code execution can cost.
DEFAULT_MAX_STACK_HEIGHTstd and testing
Default maximum stack height.
DEFAULT_MINIMUM_BID_AMOUNTstd
Default value for minimum bid amount in motes.
DEFAULT_MIN_TRANSFER_MOTESstd and testing
The default minimum number of motes that can be transferred.
DEFAULT_MUL_COSTstd and testing
Default cost of the mul Wasm opcode.
DEFAULT_NEW_DICTIONARY_COSTstd and testing
Default cost for a new dictionary.
DEFAULT_NOP_COSTstd and testing
Default cost of the nop Wasm opcode.
DEFAULT_REFUND_HANDLINGstd
Default refund handling.
DEFAULT_STORE_COSTstd and testing
Default cost of the store Wasm opcode.
DEFAULT_TRANSFER_COSTstd and testing
Default cost of the transfer mint entry point.
DEFAULT_UNREACHABLE_COSTstd and testing
Default cost of the unreachable Wasm opcode.
DEFAULT_WASM_MAX_MEMORYstd and testing
Default maximum number of pages of the Wasm memory.
DICTIONARY_ITEM_KEY_MAX_LENGTH
The maximum length for a dictionary_item_key.
ENTITY_INITIAL_VERSION
Within each discrete major ProtocolVersion, entity version resets to this value.
INSTALL_UPGRADE_LANE_ID
The lane identifier for the install/upgrade auction interaction.
KEY_DICTIONARY_LENGTH
The number of bytes in a Key::Dictionary.
KEY_HASH_LENGTH
The number of bytes in a Key::Hash.
MINT_LANE_ID
The lane identifier for the native mint interaction.
PHASE_SERIALIZED_LENGTH
The number of bytes in a serialized Phase.
SEM_VER_SERIALIZED_LENGTH
Length of SemVer when serialized
TRANSFER_ADDR_LENGTH
The length of a version 1 transfer address.
UREF_ADDR_LENGTH
The number of bytes in a URef address.
UREF_SERIALIZED_LENGTH
The number of bytes in a serialized URef where the AccessRights are not None.

Statics§

OS_PAGE_SIZEstd
OS page size.

Traits§

CLTyped
A type which can be described as a CLType.
GasLimitedstd
Calculates gas limit.
Tagged
The quality of having a tag

Functions§

calculate_lane_id_for_deploystd
Calculate lane id for deploy
calculate_transaction_lanestd
Calculates the laned based on properties of the transaction
cl_value_to_jsonjson-schema
Returns a best-effort attempt to convert the CLValue into a meaningful JSON value.
handle_stored_dictionary_value
Inspects key argument whether it contains a dictionary variant, and checks if stored_value contains a CLValue, then it will attempt a conversion from the held clvalue into DictionaryValue and returns the real CLValue held by it.
json_pretty_printjson-schema
Serializes the given data structure as a pretty-printed String of JSON using serde_json::to_string_pretty(), but after first reducing any large hex-string values.
named_key_type
Returns the CLType describing a “named key” on the system, i.e. a (String, Key).

Type Aliases§

DictionaryAddr
An alias for Keys dictionary variant.
EntityVersion
Automatically incremented value for a contract version within a major ProtocolVersion.
HashAddr
An alias for Keys hash variant.
HostFunctionCoststd
Representation of argument’s cost.
PackageAddr
An alias for Keys package variant.
Parameters
Collection of entry point parameters.
TransferResult
The result of an attempt to transfer between purses.
URefAddr
The address of a URef (unforgeable reference) on the network.