Search Apps Documentation Source Content File Folder Download Copy Actions Download

utils.gno

0.65 Kb ยท 29 lines
 1package personal_world
 2
 3import (
 4	"chain/runtime"
 5
 6	"gno.land/r/akkadia/admin"
 7)
 8
 9// assertIsAdmin checks if the given address is the admin
10func assertIsAdmin(address address) {
11	if address != admin.GetAdmin() {
12		panic("admin access required")
13	}
14}
15
16// validateUser validates that caller is a user (not a realm)
17func validateUser() address {
18	prev := runtime.PreviousRealm()
19	if !prev.IsUser() {
20		panic("contract calls not allowed: function must be called directly by user")
21	}
22	return prev.Address()
23}
24
25func assertIsAdminOrOperator(address address) {
26	if !admin.IsAdmin(address) && !admin.IsOperator(address) {
27		panic("admin or operator access required")
28	}
29}