Fungible and nonfungible proofs
Both fungible and nonfungible proofs are created whenever the corresponding proof-creation function is called on a fungible bucket or vault.
The created proofs can either be cloned or dropped. Additionally, there are some functions that are called when this proof is moved between call frames or when the node that owns this proof is dropped.
Method: clone()
The method signature is clone(api: &mut Y)
.
This method is used to create a clone of the proof that this method is called on.
When the proof is cloned, both the Moveable
and ProofRefs
fields are copied over. The Moveable
field contains a restricted
variable that determines whether this proof is able to be moved between call frames. The ProofRefs
field contains the total amount of resources that are locked into this proof as well as the containers (which can be buckets or vaults) that the corresponding amount of resources have been locked from.
Additionally, whenever a proof is cloned, the amount of resources that it has locked is duplicated. This means that if a proof contains 100 locked resources, cloning it then means that the cloned proof will also contain 100 locked resources, meaning the total amount of locked resources is now 200.
Method: drop()
The method signature is drop(api: &mut Y)
.
This method is used to drop the proof that it is called on.
Method: on_drop()
The method signature is on_drop(api: &mut Y)
.
This method is not externally callable. It is called when the node that owns this proof is dropped.
It ensures that the resources locked by this proof are unlocked when the owning node is dropped. Otherwise, it would lead to resources staying locked forever with no way to unlock them, as without the owning node, there would be no way to use this proof.
Method: on_move()
The method signature is on_move(is_moving_down: bool, is_to_barrier: bool, destination_blueprint_id: Option<BlueprintId> api: &mut Y)
.
This method is not externally callable. It is called when this proof is being moved between call frames.
If this proof is being moved down into a child call frame, it checks that the proof is being moved to either an auth zone or another globalized component. If so, it checks to ensure that the Moveable
field of the proof states that the proof is unrestricted and able to be moved. Otherwise, the transaction is reverted.
If the proof is able to be moved and it is being moved to another globalized component, then the Moveable
field is modified and made to be restricted so that the proof cannot be moved any further.