Struct casper_types::Contract

source ·
pub struct Contract { /* private fields */ }
Expand description

Methods and type signatures supported by a contract.

Implementations§

source§

impl Contract

source

pub fn new( contract_package_hash: ContractPackageHash, contract_wasm_hash: ContractWasmHash, named_keys: NamedKeys, entry_points: EntryPoints, protocol_version: ProtocolVersion ) -> Self

Contract constructor.

source

pub fn contract_package_hash(&self) -> ContractPackageHash

Hash for accessing contract package

source

pub fn contract_wasm_hash(&self) -> ContractWasmHash

Hash for accessing contract WASM

source

pub fn has_entry_point(&self, name: &str) -> bool

Checks whether there is a method with the given name

source

pub fn entry_point(&self, method: &str) -> Option<&EntryPoint>

Returns the type signature for the given method.

source

pub fn protocol_version(&self) -> ProtocolVersion

Get the protocol version this header is targeting.

source

pub fn add_entry_point<T: Into<String>>(&mut self, entry_point: EntryPoint)

Adds new entry point

source

pub fn contract_wasm_key(&self) -> Key

Hash for accessing contract bytes

source

pub fn entry_points(&self) -> &EntryPoints

Returns immutable reference to methods

source

pub fn take_named_keys(self) -> NamedKeys

Takes named_keys

source

pub fn named_keys(&self) -> &NamedKeys

Returns a reference to named_keys

source

pub fn named_keys_append(&mut self, keys: &mut NamedKeys)

Appends keys to named_keys

source

pub fn remove_named_key(&mut self, key: &str) -> Option<Key>

Removes given named key.

source

pub fn set_protocol_version(&mut self, protocol_version: ProtocolVersion)

Set protocol_version.

source

pub fn is_compatible_protocol_version( &self, protocol_version: ProtocolVersion ) -> bool

Determines if Contract is compatible with a given ProtocolVersion.

source

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 Clone for Contract

source§

fn clone(&self) -> Contract

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Contract

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Contract

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl From<Contract> for (ContractPackageHash, ContractWasmHash, NamedKeys, EntryPoints, ProtocolVersion)

source§

fn from(contract: Contract) -> Self

Converts to this type from the input type.
source§

impl From<Contract> for StoredValue

source§

fn from(value: Contract) -> StoredValue

Converts to this type from the input type.
source§

impl FromBytes for Contract

source§

fn from_bytes(bytes: &[u8]) -> Result<(Self, &[u8]), Error>

Deserializes the slice into Self.
source§

fn from_vec(bytes: Vec<u8>) -> Result<(Self, Vec<u8>), Error>

Deserializes the Vec<u8> into Self.
source§

impl PartialEq for Contract

source§

fn eq(&self, other: &Contract) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Contract

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl ToBytes for Contract

source§

fn to_bytes(&self) -> Result<Vec<u8>, Error>

Serializes &self to a Vec<u8>.
source§

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§

fn write_bytes(&self, writer: &mut Vec<u8>) -> Result<(), Error>

Writes &self into a mutable writer.
source§

fn into_bytes(self) -> Result<Vec<u8>, Error>where Self: Sized,

Consumes self and serializes to a Vec<u8>.
source§

impl TryFrom<StoredValue> for Contract

§

type Error = TypeMismatch

The type returned in the event of a conversion error.
source§

fn try_from(stored_value: StoredValue) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Eq for Contract

source§

impl StructuralEq for Contract

source§

impl StructuralPartialEq for Contract

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.