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