pub struct TokenPolicy<T: MoveType> {
pub id: UID,
pub spent_balance: Balance<T>,
pub rules: VecMap<String, VecSet<TypeName>>,
/* private fields */
}
Expand description
TokenPolicy
represents a set of rules that define what actions can be
performed on a Token
and which Rules
must be satisfied for the
action to succeed.
- For the sake of availability,
TokenPolicy
is akey
-only object. - Each
TokenPolicy
is managed by a matchingTokenPolicyCap
. - For an action to become available, there needs to be a record in the
rules
VecMap. To allow an action to be performed freely, there’s anallow
function that can be called by theTokenPolicyCap
owner.
Fields§
§id: UID
§spent_balance: Balance<T>
The balance that is effectively spent by the user on the “spend”
action. However, actual decrease of the supply can only be done by
the TreasuryCap
owner when flush
is called.
This balance is effectively spent and cannot be accessed by anyone
but the TreasuryCap
owner.
rules: VecMap<String, VecSet<TypeName>>
The set of rules that define what actions can be performed on the
token. For each “action” there’s a set of Rules that must be
satisfied for the ActionRequest
to be confirmed.
Implementations§
Source§impl<T: MoveType> TokenPolicy<T>
impl<T: MoveType> TokenPolicy<T>
Source§impl<T: MoveType> TokenPolicy<T>
impl<T: MoveType> TokenPolicy<T>
pub fn move_instance(self, t: <T as MoveType>::TypeTag) -> MoveInstance<Self>
pub fn type_(t: <T as MoveType>::TypeTag) -> TokenPolicyTypeTag<T>
Trait Implementations§
Source§impl<T: Clone + MoveType> Clone for TokenPolicy<T>
impl<T: Clone + MoveType> Clone for TokenPolicy<T>
Source§fn clone(&self) -> TokenPolicy<T>
fn clone(&self) -> TokenPolicy<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<'de, T: MoveType> Deserialize<'de> for TokenPolicy<T>
impl<'de, T: MoveType> Deserialize<'de> for TokenPolicy<T>
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T: MoveType> Display for TokenPolicy<T>
impl<T: MoveType> Display for TokenPolicy<T>
Source§impl<T: MoveType> MoveStruct for TokenPolicy<T>
impl<T: MoveType> MoveStruct for TokenPolicy<T>
type StructTag = TokenPolicyTypeTag<T>
Source§impl<T: MoveType> MoveType for TokenPolicy<T>
impl<T: MoveType> MoveType for TokenPolicy<T>
Source§impl<T> Serialize for TokenPolicy<T>
impl<T> Serialize for TokenPolicy<T>
Source§impl<T: MoveType> StaticAddress for TokenPolicy<T>
impl<T: MoveType> StaticAddress for TokenPolicy<T>
Source§impl<T: MoveType> StaticModule for TokenPolicy<T>
impl<T: MoveType> StaticModule for TokenPolicy<T>
fn module() -> Identifier
Source§impl<T: MoveType> StaticName for TokenPolicy<T>
impl<T: MoveType> StaticName for TokenPolicy<T>
fn name() -> Identifier
Source§impl<T: MoveType + StaticTypeTag> StaticTypeParams for TokenPolicy<T>
impl<T: MoveType + StaticTypeTag> StaticTypeParams for TokenPolicy<T>
fn type_params() -> Vec<TypeTag>
Source§impl<T: MoveType> Tabled for TokenPolicy<T>
impl<T: MoveType> Tabled for TokenPolicy<T>
impl<T: Eq + MoveType> Eq for TokenPolicy<T>
impl<T: MoveType> StructuralPartialEq for TokenPolicy<T>
Auto Trait Implementations§
impl<T> Freeze for TokenPolicy<T>
impl<T> RefUnwindSafe for TokenPolicy<T>where
T: RefUnwindSafe,
impl<T> Send for TokenPolicy<T>where
T: Send,
impl<T> Sync for TokenPolicy<T>where
T: Sync,
impl<T> Unpin for TokenPolicy<T>where
T: Unpin,
impl<T> UnwindSafe for TokenPolicy<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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