forked from celo-org/celo-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
database-rules.bolt
91 lines (76 loc) · 2.11 KB
/
database-rules.bolt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
* Node Types
*/
type Request {
beneficiary: String, // Address or phone number for the request's beneficiary
mobileOS: String | Null,
dollarTxHash: String | Null, // Transaction Hash for the executed Request
goldTxHash: String | Null,
escrowTxHash: String | Null,
status: RequestStatus, // Request Status enum
type: RequestType, // Request Type enum
}
type Account {
pk: String, // Account's private key
address: String, // Accounts's Address
locked: Boolean, // Lock status
}
/**
* Leaf Node Types
*/
type RequestStatus extends String {
validate() {
this == 'Pending' ||
this == 'Working' ||
this == 'Done' ||
this == 'Failed'
}
}
type RequestType extends String {
validate() {
this == 'Faucet' ||
this == 'Invite'
}
}
/**
* Node Paths
*/
path / {
// Only admin access
read() { false }
write() { false }
}
path /{net} {
// Only admin access
read() { false }
write() { false }
}
path /{net}/requests {
// Only admin access
read() { false }
write() { false }
}
path /{net}/requests/{id} is Request {
read() { true }
write() { isAllowed(this) }
}
path /{net}/accounts/{account} is Account {
// Only admin access
read() { false }
write() { false }
}
/**
* Helper Functions
*/
isLoggedIn() { auth != null }
isNew(ref) { prior(ref) == null }
// uid of [email protected] is LFH1B0m3tqdWGSugIvM2EkjARVR2 on celo-faucet
// This account can be seen/modified at https://console.firebase.google.com/project/celo-faucet/authentication/users
//
// uid of [email protected] is ldA2DGvtgWP1xa8QFrtB7BYKc7l2 on celo-faucet-staging
// This account can be seen/modified at https://console.firebase.google.com/project/celo-faucet-staging/authentication/users
isAllowed(ref) {
// TODO(ashishb): In the longer run, it would be better to choose only one uid based on whether
// we are on staging network or the production network.
return auth.uid == "LFH1B0m3tqdWGSugIvM2EkjARVR2" || auth.uid == "ldA2DGvtgWP1xa8QFrtB7BYKc7l2"
}