errors.gno
1.54 Kb · 34 lines
1package access
2
3import (
4 "strconv"
5
6 "gno.land/p/onbloc/access/manager"
7)
8
9const (
10 ErrAccessManagerUnauthorizedAccount = "access manager unauthorized account"
11 ErrAccessManagerUnauthorizedCall = "access manager unauthorized call"
12 ErrSpoofedRealm = "rlm does not match the current crossing frame"
13)
14
15// AccessManagerUnauthorizedAccountError formats an account-role authorization error.
16// Union references:
17// https://github.com/unionlabs/union/blob/8cff0ff34f6baa4cdb1e4650a08985dd05de0c5a/lib/access-manager-types/src/manager/error.rs#L26-L30
18// https://github.com/unionlabs/union/blob/8cff0ff34f6baa4cdb1e4650a08985dd05de0c5a/cosmwasm/access-manager/src/contract.rs#L832-L840
19func AccessManagerUnauthorizedAccountError(caller address, requiredRole manager.RoleId) string {
20 return ErrAccessManagerUnauthorizedAccount +
21 ": " + caller.String() +
22 " must have role " + strconv.FormatUint(uint64(requiredRole), 10)
23}
24
25// AccessManagerUnauthorizedCallError formats a target-selector authorization error.
26// Union references:
27// https://github.com/unionlabs/union/blob/8cff0ff34f6baa4cdb1e4650a08985dd05de0c5a/lib/access-manager-types/src/manager/error.rs#L32-L37
28// https://github.com/unionlabs/union/blob/8cff0ff34f6baa4cdb1e4650a08985dd05de0c5a/cosmwasm/access-manager/src/contract.rs#L526-L534
29func AccessManagerUnauthorizedCallError(caller address, target string, selector manager.Selector) string {
30 return ErrAccessManagerUnauthorizedCall +
31 ": " + caller.String() +
32 " is not authorized to call " + string(selector) +
33 " on " + target
34}