-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.ride
More file actions
70 lines (48 loc) · 1.78 KB
/
main.ride
File metadata and controls
70 lines (48 loc) · 1.78 KB
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
{-# STDLIB_VERSION 3 #-}
{-# CONTENT_TYPE DAPP #-}
{-# SCRIPT_TYPE ACCOUNT #-}
func signerIsAllowedToSign(voterPublicKey: ByteVector) = {
let auditor1open = base58'6B7r4pWd3dB79ojogTFvQ2tspsav6gsL4iWqzsRG2rhR'
let factory1open = base58'BGr3aRnHxWYKViZ9AKkqE7CdczJtRGk2vCzbGF5mX7dp'
if (voterPublicKey != auditor1open && voterPublicKey != factory1open )
then
false
else
true
}
func isAuditor(voterPublicKey: ByteVector) = {
let auditor1open = base58'6B7r4pWd3dB79ojogTFvQ2tspsav6gsL4iWqzsRG2rhR'
if (voterPublicKey != auditor1open)
then
false
else
true
}
@Callable(i)
func sign(theVote: Int) = {
if (!signerIsAllowedToSign(i.callerPublicKey))
then
throw("У вас нет прав доступа")
else
let dataFromStorage = this.getInteger(i.callerPublicKey.toBase58String())
let getAuditor = this.getStringValue("Auditor")
let getFactory = this.getStringValue("Factory")
if (dataFromStorage.isDefined())
then
throw("Ваша подпись уже поставлена")
else
WriteSet([DataEntry(i.callerPublicKey.toBase58String(), theVote)])
}
@Callable(i)
func record(theInteger: Int) = {
let auditor1open = base58'6B7r4pWd3dB79ojogTFvQ2tspsav6gsL4iWqzsRG2rhR'
let factory1open = base58'BGr3aRnHxWYKViZ9AKkqE7CdczJtRGk2vCzbGF5mX7dp'
### Master open key
#let myOpen = base58'FUCE44aWkQuFEKpfWRe3zoW8pGN2caDm1vqoK55FTnLP'
let myOpen = base58'FUCE44aWkQuFEKpfWRe3zoW8pGN2caDm1vqoK55FTnLP'
if (i.callerPublicKey != myOpen)
then
throw("Вы не можете добавлять данные, вы не заказчик")
else
WriteSet([DataEntry("auditor", auditor1open), DataEntry("factory", factory1open)])
}