Struct casper_types::Contract
source · pub struct Contract { /* private fields */ }
Expand description
Methods and type signatures supported by a contract.
Implementations§
source§impl Contract
impl Contract
sourcepub fn new(
contract_package_hash: ContractPackageHash,
contract_wasm_hash: ContractWasmHash,
named_keys: NamedKeys,
entry_points: EntryPoints,
protocol_version: ProtocolVersion
) -> Self
pub fn new( contract_package_hash: ContractPackageHash, contract_wasm_hash: ContractWasmHash, named_keys: NamedKeys, entry_points: EntryPoints, protocol_version: ProtocolVersion ) -> Self
Contract
constructor.
sourcepub fn contract_package_hash(&self) -> ContractPackageHash
pub fn contract_package_hash(&self) -> ContractPackageHash
Hash for accessing contract package
sourcepub fn contract_wasm_hash(&self) -> ContractWasmHash
pub fn contract_wasm_hash(&self) -> ContractWasmHash
Hash for accessing contract WASM
sourcepub fn has_entry_point(&self, name: &str) -> bool
pub fn has_entry_point(&self, name: &str) -> bool
Checks whether there is a method with the given name
sourcepub fn entry_point(&self, method: &str) -> Option<&EntryPoint>
pub fn entry_point(&self, method: &str) -> Option<&EntryPoint>
Returns the type signature for the given method
.
sourcepub fn protocol_version(&self) -> ProtocolVersion
pub fn protocol_version(&self) -> ProtocolVersion
Get the protocol version this header is targeting.
sourcepub fn add_entry_point<T: Into<String>>(&mut self, entry_point: EntryPoint)
pub fn add_entry_point<T: Into<String>>(&mut self, entry_point: EntryPoint)
Adds new entry point
sourcepub fn contract_wasm_key(&self) -> Key
pub fn contract_wasm_key(&self) -> Key
Hash for accessing contract bytes
sourcepub fn entry_points(&self) -> &EntryPoints
pub fn entry_points(&self) -> &EntryPoints
Returns immutable reference to methods
sourcepub fn take_named_keys(self) -> NamedKeys
pub fn take_named_keys(self) -> NamedKeys
Takes named_keys
sourcepub fn named_keys(&self) -> &NamedKeys
pub fn named_keys(&self) -> &NamedKeys
Returns a reference to named_keys
sourcepub fn named_keys_append(&mut self, keys: &mut NamedKeys)
pub fn named_keys_append(&mut self, keys: &mut NamedKeys)
Appends keys
to named_keys
sourcepub fn remove_named_key(&mut self, key: &str) -> Option<Key>
pub fn remove_named_key(&mut self, key: &str) -> Option<Key>
Removes given named key.
sourcepub fn set_protocol_version(&mut self, protocol_version: ProtocolVersion)
pub fn set_protocol_version(&mut self, protocol_version: ProtocolVersion)
Set protocol_version.
sourcepub fn is_compatible_protocol_version(
&self,
protocol_version: ProtocolVersion
) -> bool
pub fn is_compatible_protocol_version( &self, protocol_version: ProtocolVersion ) -> bool
Determines if Contract
is compatible with a given ProtocolVersion
.
sourcepub fn extract_access_rights(
&self,
contract_hash: ContractHash
) -> ContextAccessRights
pub fn extract_access_rights( &self, contract_hash: ContractHash ) -> ContextAccessRights
Extracts the access rights from the named keys of the contract.
Trait Implementations§
source§impl From<Contract> for (ContractPackageHash, ContractWasmHash, NamedKeys, EntryPoints, ProtocolVersion)
impl From<Contract> for (ContractPackageHash, ContractWasmHash, NamedKeys, EntryPoints, ProtocolVersion)
source§impl From<Contract> for StoredValue
impl From<Contract> for StoredValue
source§fn from(value: Contract) -> StoredValue
fn from(value: Contract) -> StoredValue
Converts to this type from the input type.
source§impl PartialEq for Contract
impl PartialEq for Contract
source§impl ToBytes for Contract
impl ToBytes for Contract
source§fn serialized_length(&self) -> usize
fn serialized_length(&self) -> usize
Returns the length of the
Vec<u8>
which would be returned from a successful call to
to_bytes()
or into_bytes()
. The data is not actually serialized, so this call is
relatively cheap.source§impl TryFrom<StoredValue> for Contract
impl TryFrom<StoredValue> for Contract
§type Error = TypeMismatch
type Error = TypeMismatch
The type returned in the event of a conversion error.
impl Eq for Contract
impl StructuralEq for Contract
impl StructuralPartialEq for Contract
Auto Trait Implementations§
impl RefUnwindSafe for Contract
impl Send for Contract
impl Sync for Contract
impl Unpin for Contract
impl UnwindSafe for Contract
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more