Search Apps Documentation Source Content File Folder Download Copy Actions Download

assert.gno

0.96 Kb ยท 34 lines
 1package referral
 2
 3import (
 4	prabc "gno.land/p/gnoswap/rbac"
 5
 6	"gno.land/r/gnoswap/access"
 7	_ "gno.land/r/gnoswap/rbac"
 8)
 9
10// validCallerRoles is a list of roles that are authorized to modify referral data.
11// This includes governance contracts, router, position manager, and staker contracts.
12var validCallerRoles = []string{
13	prabc.ROLE_GOVERNANCE.String(),
14	prabc.ROLE_GOV_STAKER.String(),
15	prabc.ROLE_ROUTER.String(),
16	prabc.ROLE_POSITION.String(),
17	prabc.ROLE_STAKER.String(),
18	prabc.ROLE_LAUNCHPAD.String(),
19}
20
21// assertValidCaller checks if the caller address has permission to modify referral data.
22// Only addresses with specific roles defined in validCallerRoles are authorized.
23//
24// Errors:
25//   - ErrUnauthorized: the caller is not authorized to modify referral data
26func assertValidCaller(caller address) {
27	for _, role := range validCallerRoles {
28		if access.IsAuthorized(role, caller) {
29			return
30		}
31	}
32
33	panic(makeErrorWithDetails(ErrUnauthorized, caller.String()))
34}