-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_contract.tz
More file actions
57 lines (56 loc) · 1.78 KB
/
main_contract.tz
File metadata and controls
57 lines (56 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
{ parameter (or (address %claim_share) (map %mint_shares address nat)) ;
storage (pair address (map address (ticket string))) ;
code { UNPAIR ;
IF_LEFT
{ SWAP ;
UNPAIR ;
SWAP ;
NONE (ticket string) ;
DUP 4 ;
GET_AND_UPDATE ;
IF_NONE
{ PUSH string "Given address does not have any share" ; FAILWITH }
{} ;
DIG 3 ;
CONTRACT (ticket string) ;
PUSH string "Contract address or entrypoint is wrong" ;
SWAP ;
IF_NONE { FAILWITH } { SWAP ; DROP } ;
PUSH mutez 0 ;
DIG 2 ;
TRANSFER_TOKENS ;
SWAP ;
DIG 2 ;
PAIR ;
NIL operation ;
DIG 2 ;
CONS }
{ SWAP ;
UNPAIR ;
DUP ;
SENDER ;
COMPARE ;
NEQ ;
IF { PUSH string "Sender is not the admin" ; FAILWITH } {} ;
SWAP ;
DIG 2 ;
ITER { SWAP ;
DUP 2 ;
CDR ;
PUSH string "vote" ;
TICKET ;
PUSH string "Ticket amount cannot be 0" ;
SWAP ;
IF_NONE { FAILWITH } { SWAP ; DROP } ;
SWAP ;
NONE (ticket string) ;
DUP 4 ;
CAR ;
GET_AND_UPDATE ;
IF_NONE
{ SWAP ; DIG 2 ; CAR ; SWAP ; SOME ; SWAP ; UPDATE }
{ DIG 2 ; PAIR ; JOIN_TICKETS ; DIG 2 ; CAR ; UPDATE } } ;
SWAP ;
PAIR ;
NIL operation } ;
PAIR } }