pub struct AddressableEntity { /* private fields */ }
Expand description
Methods and type signatures supported by a contract.
Implementations§
Source§impl AddressableEntity
impl AddressableEntity
Sourcepub fn new(
package_hash: PackageHash,
byte_code_hash: ByteCodeHash,
protocol_version: ProtocolVersion,
main_purse: URef,
associated_keys: AssociatedKeys,
action_thresholds: ActionThresholds,
entity_kind: EntityKind,
) -> Self
pub fn new( package_hash: PackageHash, byte_code_hash: ByteCodeHash, protocol_version: ProtocolVersion, main_purse: URef, associated_keys: AssociatedKeys, action_thresholds: ActionThresholds, entity_kind: EntityKind, ) -> Self
AddressableEntity
constructor.
Sourcepub fn entity_addr(&self, entity_hash: AddressableEntityHash) -> EntityAddr
pub fn entity_addr(&self, entity_hash: AddressableEntityHash) -> EntityAddr
Get the entity addr for this entity from the corresponding hash.
pub fn entity_kind(&self) -> EntityKind
Sourcepub fn package_hash(&self) -> PackageHash
pub fn package_hash(&self) -> PackageHash
Hash for accessing contract package
Sourcepub fn byte_code_hash(&self) -> ByteCodeHash
pub fn byte_code_hash(&self) -> ByteCodeHash
Hash for accessing contract WASM
Sourcepub fn protocol_version(&self) -> ProtocolVersion
pub fn protocol_version(&self) -> ProtocolVersion
Get the protocol version this header is targeting.
Sourcepub fn main_purse(&self) -> URef
pub fn main_purse(&self) -> URef
Returns main purse.
Sourcepub fn main_purse_add_only(&self) -> URef
pub fn main_purse_add_only(&self) -> URef
Returns an AccessRights::ADD
-only version of the main purse’s URef
.
Sourcepub fn associated_keys(&self) -> &AssociatedKeys
pub fn associated_keys(&self) -> &AssociatedKeys
Returns associated keys.
Sourcepub fn action_thresholds(&self) -> &ActionThresholds
pub fn action_thresholds(&self) -> &ActionThresholds
Returns action thresholds.
Sourcepub fn add_associated_key(
&mut self,
account_hash: AccountHash,
weight: Weight,
) -> Result<(), AddKeyFailure>
pub fn add_associated_key( &mut self, account_hash: AccountHash, weight: Weight, ) -> Result<(), AddKeyFailure>
Adds an associated key to an addressable entity.
Sourcepub fn remove_associated_key(
&mut self,
account_hash: AccountHash,
) -> Result<(), RemoveKeyFailure>
pub fn remove_associated_key( &mut self, account_hash: AccountHash, ) -> Result<(), RemoveKeyFailure>
Removes an associated key from an addressable entity.
Verifies that removing the key will not cause the remaining weight to fall below any action thresholds.
Sourcepub fn update_associated_key(
&mut self,
account_hash: AccountHash,
weight: Weight,
) -> Result<(), UpdateKeyFailure>
pub fn update_associated_key( &mut self, account_hash: AccountHash, weight: Weight, ) -> Result<(), UpdateKeyFailure>
Updates an associated key.
Returns an error if the update would result in a violation of the key management thresholds.
Sourcepub fn set_action_threshold(
&mut self,
action_type: ActionType,
weight: Weight,
) -> Result<(), SetThresholdFailure>
pub fn set_action_threshold( &mut self, action_type: ActionType, weight: Weight, ) -> Result<(), SetThresholdFailure>
Sets new action threshold for a given action type for the addressable entity.
Returns an error if the new action threshold weight is greater than the total weight of the account’s associated keys.
Sourcepub fn set_action_threshold_unchecked(
&mut self,
action_type: ActionType,
threshold: Weight,
) -> Result<(), SetThresholdFailure>
pub fn set_action_threshold_unchecked( &mut self, action_type: ActionType, threshold: Weight, ) -> Result<(), SetThresholdFailure>
Sets a new action threshold for a given action type for the account without checking against the total weight of the associated keys.
This should only be called when authorized by an administrator account.
Returns an error if setting the action would cause the ActionType::Deployment
threshold to
be greater than any of the other action types.
Sourcepub fn can_set_threshold(
&self,
new_threshold: Weight,
) -> Result<(), SetThresholdFailure>
pub fn can_set_threshold( &self, new_threshold: Weight, ) -> Result<(), SetThresholdFailure>
Verifies if user can set action threshold.
Checks whether all authorization keys are associated with this addressable entity.
Sourcepub fn can_deploy_with(
&self,
authorization_keys: &BTreeSet<AccountHash>,
) -> bool
pub fn can_deploy_with( &self, authorization_keys: &BTreeSet<AccountHash>, ) -> bool
Checks whether the sum of the weights of all authorization keys is greater or equal to deploy threshold.
Sourcepub fn can_manage_keys_with(
&self,
authorization_keys: &BTreeSet<AccountHash>,
) -> bool
pub fn can_manage_keys_with( &self, authorization_keys: &BTreeSet<AccountHash>, ) -> bool
Checks whether the sum of the weights of all authorization keys is greater or equal to key management threshold.
Sourcepub fn can_upgrade_with(
&self,
authorization_keys: &BTreeSet<AccountHash>,
) -> bool
pub fn can_upgrade_with( &self, authorization_keys: &BTreeSet<AccountHash>, ) -> bool
Checks whether the sum of the weights of all authorization keys is greater or equal to upgrade management threshold.
Sourcepub fn byte_code_addr(&self) -> HashAddr
pub fn byte_code_addr(&self) -> HashAddr
Addr for accessing wasm bytes
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 AddressableEntity
is compatible with a given ProtocolVersion
.
Sourcepub fn kind(&self) -> EntityKind
pub fn kind(&self) -> EntityKind
Returns the kind of AddressableEntity
.
Sourcepub fn is_account_kind(&self) -> bool
pub fn is_account_kind(&self) -> bool
Is this an account?
Sourcepub fn entity_key(&self, entity_hash: AddressableEntityHash) -> Key
pub fn entity_key(&self, entity_hash: AddressableEntityHash) -> Key
Key for the addressable entity
Sourcepub fn extract_access_rights(
&self,
entity_hash: AddressableEntityHash,
named_keys: &NamedKeys,
) -> ContextAccessRights
pub fn extract_access_rights( &self, entity_hash: AddressableEntityHash, named_keys: &NamedKeys, ) -> ContextAccessRights
Extracts the access rights from the named keys of the addressable entity.
Trait Implementations§
Source§impl Clone for AddressableEntity
impl Clone for AddressableEntity
Source§fn clone(&self) -> AddressableEntity
fn clone(&self) -> AddressableEntity
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl DataSize for AddressableEntity
impl DataSize for AddressableEntity
Source§const IS_DYNAMIC: bool = true
const IS_DYNAMIC: bool = true
true
, the type has a heap size that can vary at runtime, depending on the actual value.Source§const STATIC_HEAP_SIZE: usize = 0usize
const STATIC_HEAP_SIZE: usize = 0usize
IS_DYNAMIC
is false, this is
the total amount of heap memory occupied by the value. Otherwise this is a lower bound.Source§fn estimate_heap_size(&self) -> usize
fn estimate_heap_size(&self) -> usize
Source§impl Debug for AddressableEntity
impl Debug for AddressableEntity
Source§impl Default for AddressableEntity
impl Default for AddressableEntity
Source§impl<'de> Deserialize<'de> for AddressableEntity
impl<'de> Deserialize<'de> for AddressableEntity
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<Account> for AddressableEntity
impl From<Account> for AddressableEntity
Source§impl From<AddressableEntity> for (PackageHash, ByteCodeHash, ProtocolVersion, URef, AssociatedKeys, ActionThresholds)
impl From<AddressableEntity> for (PackageHash, ByteCodeHash, ProtocolVersion, URef, AssociatedKeys, ActionThresholds)
Source§fn from(entity: AddressableEntity) -> Self
fn from(entity: AddressableEntity) -> Self
Source§impl From<AddressableEntity> for StoredValue
impl From<AddressableEntity> for StoredValue
Source§fn from(value: AddressableEntity) -> StoredValue
fn from(value: AddressableEntity) -> StoredValue
Source§impl From<Contract> for AddressableEntity
impl From<Contract> for AddressableEntity
Source§impl FromBytes for AddressableEntity
impl FromBytes for AddressableEntity
Source§impl JsonSchema for AddressableEntity
impl JsonSchema for AddressableEntity
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moreSource§impl PartialEq for AddressableEntity
impl PartialEq for AddressableEntity
Source§impl Serialize for AddressableEntity
impl Serialize for AddressableEntity
Source§impl ToBytes for AddressableEntity
impl ToBytes for AddressableEntity
Source§fn serialized_length(&self) -> usize
fn serialized_length(&self) -> usize
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 AddressableEntity
impl TryFrom<StoredValue> for AddressableEntity
Source§type Error = TypeMismatch
type Error = TypeMismatch
impl Eq for AddressableEntity
impl StructuralPartialEq for AddressableEntity
Auto Trait Implementations§
impl Freeze for AddressableEntity
impl RefUnwindSafe for AddressableEntity
impl Send for AddressableEntity
impl Sync for AddressableEntity
impl Unpin for AddressableEntity
impl UnwindSafe for AddressableEntity
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more