Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

getters.gno

3.36 Kb · 75 lines
 1package access
 2
 3import "gno.land/p/onbloc/access/manager"
 4
 5// HasRole returns role membership status for account.
 6// Union reference:
 7// https://github.com/unionlabs/union/blob/8cff0ff34f6baa4cdb1e4650a08985dd05de0c5a/cosmwasm/access-manager/src/contract.rs#L1172-L1197
 8func HasRole(role manager.RoleId, account address) manager.HasRoleResult {
 9	return accessState.HasRole(role, account)
10}
11
12// GetRoleAdmin returns the admin role configured for role.
13// Union reference:
14// https://github.com/unionlabs/union/blob/8cff0ff34f6baa4cdb1e4650a08985dd05de0c5a/cosmwasm/access-manager/src/contract.rs#L1119-L1126
15func GetRoleAdmin(role manager.RoleId) manager.RoleId {
16	return accessState.GetRoleAdmin(role)
17}
18
19// GetRoleGrantDelay returns the grant delay configured for role.
20// Union reference:
21// https://github.com/unionlabs/union/blob/8cff0ff34f6baa4cdb1e4650a08985dd05de0c5a/cosmwasm/access-manager/src/contract.rs#L1137-L1145
22func GetRoleGrantDelay(role manager.RoleId) uint32 {
23	return accessState.GetRoleGrantDelay(role)
24}
25
26// GetRoleGrantDelayEffect returns when role's scheduled grant delay change takes effect.
27// No Union equivalent.
28func GetRoleGrantDelayEffect(role manager.RoleId) manager.TimePoint {
29	return accessState.GetRoleGrantDelayEffect(role)
30}
31
32// GetFunctionRole returns the selector role for targetPath.
33// Union reference:
34// https://github.com/unionlabs/union/blob/8cff0ff34f6baa4cdb1e4650a08985dd05de0c5a/cosmwasm/access-manager/src/contract.rs#L1091-L1107
35func GetFunctionRole(targetPath string, selector manager.Selector) manager.RoleId {
36	return GetTargetFunctionRole(targetPath, selector)
37}
38
39// GetTargetFunctionRole returns the selector role for targetPath.
40// Union reference:
41// https://github.com/unionlabs/union/blob/8cff0ff34f6baa4cdb1e4650a08985dd05de0c5a/cosmwasm/access-manager/src/contract.rs#L1091-L1107
42func GetTargetFunctionRole(targetPath string, selector manager.Selector) manager.RoleId {
43	return accessState.GetTargetFunctionRole(targetPath, selector)
44}
45
46// IsTargetClosed reports whether targetPath is closed.
47// Union reference:
48// https://github.com/unionlabs/union/blob/8cff0ff34f6baa4cdb1e4650a08985dd05de0c5a/cosmwasm/access-manager/src/contract.rs#L1082-L1089
49func IsTargetClosed(targetPath string) bool {
50	return accessState.IsTargetClosed(targetPath)
51}
52
53// CanCall reports whether caller can call selector on targetPath.
54// Union reference:
55// https://github.com/unionlabs/union/blob/8cff0ff34f6baa4cdb1e4650a08985dd05de0c5a/cosmwasm/access-manager/src/contract.rs#L1033-L1068
56func CanCall(targetPath string, selector manager.Selector, caller address) manager.CanCallResult {
57	return accessState.CanCall(caller, targetPath, selector)
58}
59
60// IsAuthorized reports immediate call authorization for targetPath.
61// Union reference:
62// https://github.com/unionlabs/union/blob/8cff0ff34f6baa4cdb1e4650a08985dd05de0c5a/cosmwasm/access-manager/src/contract.rs#L1033-L1068
63func IsAuthorized(targetPath string, selector manager.Selector, caller address) bool {
64	return accessState.IsAuthorized(caller, targetPath, selector)
65}
66
67// CanAdminRole reports whether caller can administer role.
68func CanAdminRole(role manager.RoleId, caller address) manager.CanCallResult {
69	return accessState.CanAdminRole(role, caller)
70}
71
72// CanManageTarget reports whether caller can manage target configuration.
73func CanManageTarget(caller address) manager.CanCallResult {
74	return accessState.CanManageTarget(caller)
75}