Assign Function Accessrules
To specify the access rules for each function use the enable_function_auth! macro at the top of your blueprint code.
note
NOTE
If the enable_function_auth! macro is not used that all functions will default to rule!(allow_all) AccessRule.
#[blueprint]
mod my_token_sale {
enable_function_auth! { // #1
create_component => rule!(allow_all); // #2
create_special_component => rule!(require(XRD)); // #3
}
struct MyTokenSale { .. }
impl MyTokenSale {
pub fn create_component() -> Global<MyTokenSale> { .. }
pub fn create_special_component() -> Global<MyTokenSale> { .. }
..
}
}
-
Each
pubfunction inimpl MyTokenSale { .. }must be assigned an AccessRule if theenable_function_auth!macro is used. Non-pubfunctions are never accessible. -
rule!(allow_all)specifies that anyone may call thecreate_componentfunction -
rule!(require(XRD))specifies that only a caller who has a proof of XRD in their AuthZone may call thecreate_special_componentfunction