types.gno
1.81 Kb ยท 69 lines
1package store
2
3import "gno.land/p/nt/avl"
4
5type Permission uint8
6
7const (
8 _ Permission = iota
9 ReadOnly
10 Write
11)
12
13// KVStore interface for domain-specific storage
14// Each domain creates its own instance of KVStore
15type KVStore interface {
16 // GetDomainAddress returns the domain address
17 GetDomainAddress() address
18
19 // GetAllKeys returns all keys in this store
20 GetAllKeys() ([]string, error)
21
22 // Has checks if a key exists
23 Has(key string) bool
24
25 // Get retrieves a value by key
26 Get(key string) (any, error)
27
28 // GetInt64 retrieves a int64 value by key
29 GetInt64(key string) (int64, error)
30
31 // GetUint64 retrieves a uint64 value by key
32 GetUint64(key string) (uint64, error)
33
34 // GetBool retrieves a bool value by key
35 GetBool(key string) (bool, error)
36
37 // GetString retrieves a string value by key
38 GetString(key string) (string, error)
39
40 // GetAddress retrieves an address value by key
41 GetAddress(key string) (address, error)
42
43 // GetTree retrieves a tree value by key
44 GetTree(key string) (*avl.Tree, error)
45
46 // Set stores a value with the given key
47 Set(key string, value any) error
48
49 // Delete removes a key
50 Delete(key string) error
51
52 // IsReadAuthorized checks if the caller has read permission
53 IsReadAuthorized(caller address) bool
54
55 // IsWriteAuthorized checks if the caller has write permission
56 IsWriteAuthorized(caller address) bool
57
58 // GetAuthorizedCallers returns all authorized callers and their permissions
59 GetAuthorizedCallers() (map[address]Permission, error)
60
61 // AddAuthorizedCaller adds a new authorized caller
62 AddAuthorizedCaller(caller address, permission Permission) error
63
64 // UpdateAuthorizedCaller updates an existing caller's permission
65 UpdateAuthorizedCaller(caller address, permission Permission) error
66
67 // RemoveAuthorizedCaller removes an authorized caller
68 RemoveAuthorizedCaller(caller address) error
69}