View Functions and Asserts

Get functions have been implemented to provide easy access to objects and data within the module.


#[view]
public fun usdk_address(): address {
object::create_object_address(&@stablecoin, ASSET_SYMBOL)
}
#[view]
public fun metadata(): Object<Metadata> {
object::address_to_object(usdk_address())
}

We also have assert functions to provide re-usable and cleaner code.


fun assert_is_minter(minter: &signer) acquires Roles {
let roles = borrow_global<Roles>(usdk_address());
let minter = signer::address_of(minter);
assert!(minter == roles.master_minter || vector::contains(&roles.minters, &minter), EUNAUTHORIZED);
}
fun assert_not_denylisted(account: address) acquires State {
let state = borrow_global<State>(usdk_address());
assert!(!smart_table::contains(&state.denylist, account), EBLACKLISTED);
}