Authorization zone
The authorization zone holds fungible and nonfungible proofs that are then automatically used to perform authorization checks for function/method calls.
Additionally, the authorization zone also contains functionality that allows fungible and nonfungible proofs to be constructed out of the proofs that are currently in the authorization zone.
Method: push()
The method signature is push(proof: Proof, api: &mut Y)
.
This method is used to push a proof to the authorization zone. There are no checks performed for this; the proofs are simply pushed to the AuthZone
field of this blueprint, which contains a vector of proofs.
Method: pop()
The method signature is pop(api: &mut Y)
.
This method is used to pop a proof from the authorization zone. There are no checks performed for this. If there are no proofs in the authorization zone, then None
is returned.
Method: create_proof_of_amount()
The method signature is create_proof_of_amount(resource_address: ResourceAddress, amount: Decimal, api: &mut Y)
.
This method composes a new proof out of all the proofs in the authorization zone whose resource address matches the specified resource_address
.
It ensures that the amount
passed in can be satisfied by the proofs in the authorization zone.
A new proof is created and returned to the caller.
Method: create_proof_of_all()
The method signature is create_proof_of_all(resource_address: ResourceAddress, api: &mut Y)
.
This method is the same as create_proof_of_amount()
, except it creates a proof with the maximum amount of the specified resource in the authorization zone.
Method: create_proof_of_non_fungibles()
The method signature is create_proof_of_all(resource_address: ResourceAddress, ids: IndexSet<NonFungibleLocalId>, api: &mut Y)
.
This method is the same as the create_proof_of_amount()
, except it only works for nonfungible proofs and ensures that all nonfungible IDs specified in the ids
index set exist in the authorization zone's list of proofs.
Method: drop_proofs()
The method signature is drop_proofs(api: &mut Y)
.
This method drops all proofs from this authorization zone.
Method: drop_signature_proofs()
The method signature is drop_signature_proofs(api: &mut Y)
.
This method removes all signature proofs from this authorization zone.
Method: drop_regular_proofs()
The method signature is drop_regular_proofs(api: &mut Y)
.
This method drops all non-signature proofs from this authorization zone.
Method: drain()
The method signature is drain(api: &mut Y)
.
This method removes all non-signature proofs from this authorization zone and returns them to the caller.
Method: assert_access_rule()
The method signature is assert_access_rule(access_rule: AccessRule, api: &mut Y)
.
This method is used to ensure that the proofs in the current authorization zone can be used to authorize the specified access_rule
.
The access_rule
specifies what proof needs to exist in this authorization zone. In this case, there are five types of proofs:
The Require(ResourceOrNonFungible)
rule is used to ensure that the authorization zone contains a specific fungible resource or a specific nonfungible resource ID. The AmountOf(Decimal, ResourceAddress)
rule is used to ensure that a specific amount of the resource specified by the ResourceAddress
exists in this authorization zone; CountOf(...)
is used to ensure that at least a specified amount of resources (which are specified in the vector) exist in this authorization zone; AllOf(...)
is used to ensure that all of the resources specified in the vector exist in this authorization zone, and finally AnyOf(...)
is used to ensure that at least one of the resources specified in the vector exist in this authorization zone.