-
Notifications
You must be signed in to change notification settings - Fork 3
/
ticketer.tz
140 lines (139 loc) · 4.19 KB
/
ticketer.tz
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
{ parameter
(or (pair %withdraw (address %receiver) (ticket %ticket (pair nat (option bytes))))
(nat %deposit)) ;
storage
(pair (big_map %metadata string bytes)
(or %token (address %fa12) (pair %fa2 address nat))
(pair %content nat (option bytes))
(nat %total_supply)) ;
code { LAMBDA
(pair (or address (pair address nat)) nat address address)
operation
{ UNPAIR 4 ;
IF_LEFT
{ CONTRACT %transfer (pair (address %from) (address %to) (nat %value)) ;
IF_NONE { PUSH string "INVALID_FA12" ; FAILWITH } {} ;
PUSH mutez 0 ;
DIG 2 ;
DIG 4 ;
DIG 4 ;
PAIR 3 ;
TRANSFER_TOKENS }
{ UNPAIR ;
CONTRACT %transfer
(list (pair (address %from_) (list %txs (pair (address %to_) (nat %token_id) (nat %amount))))) ;
IF_NONE { PUSH string "INVALID_FA2" ; FAILWITH } {} ;
PUSH mutez 0 ;
NIL (pair address (list (pair address nat nat))) ;
NIL (pair address nat nat) ;
DIG 5 ;
DIG 5 ;
DIG 7 ;
PAIR 3 ;
CONS ;
DIG 4 ;
PAIR ;
CONS ;
TRANSFER_TOKENS } } ;
LAMBDA
unit
unit
{ PUSH mutez 0 ;
AMOUNT ;
COMPARE ;
GT ;
IF { DROP ; PUSH string "XTZ_DEPOSIT_DISALLOWED" ; FAILWITH } {} } ;
DIG 2 ;
UNPAIR ;
IF_LEFT
{ UNPAIR ;
SWAP ;
READ_TICKET ;
SWAP ;
DROP ;
UNPAIR ;
SWAP ;
UNPAIR ;
DUP 5 ;
GET 5 ;
SWAP ;
COMPARE ;
EQ ;
IF {} { PUSH string "UNEXPECTED_TKT_CONTENT" ; FAILWITH } ;
SELF_ADDRESS ;
DUP 3 ;
COMPARE ;
NEQ ;
IF { PUSH string "UNAUTHORIZED_TKTR" ; FAILWITH } {} ;
UNIT ;
DIG 5 ;
SWAP ;
EXEC ;
DROP ;
DUP 4 ;
GET 6 ;
DUP 2 ;
COMPARE ;
GT ;
IF { PUSH string "TOTAL_SUPPLY_EXCEEDED" ; FAILWITH }
{ DUP ; DUP 5 ; GET 6 ; SUB ; ABS } ;
DIG 4 ;
SWAP ;
UPDATE 6 ;
DUG 3 ;
DUP 4 ;
GET 3 ;
PAIR 4 ;
DIG 2 ;
SWAP ;
EXEC ;
SWAP ;
NIL operation }
{ UNIT ;
DIG 3 ;
SWAP ;
EXEC ;
DROP ;
DUP ;
DUP 3 ;
GET 6 ;
ADD ;
PUSH nat
115792089237316195423570985008687907853269984665640564039457584007913129639936 ;
DUP 2 ;
COMPARE ;
GE ;
IF { DIG 2 ; DROP 2 ; PUSH string "TOTAL_SUPPLY_EXCEED_MAX" ; FAILWITH }
{ DIG 2 ; SWAP ; UPDATE 6 } ;
SELF_ADDRESS ;
SENDER ;
DUP 4 ;
DUP 4 ;
GET 5 ;
TICKET ;
IF_NONE { PUSH string "TKT_CREATION_FAILED" ; FAILWITH } {} ;
DIG 2 ;
DUP 3 ;
DIG 5 ;
DUP 6 ;
GET 3 ;
PAIR 4 ;
DIG 4 ;
SWAP ;
EXEC ;
DIG 2 ;
CONTRACT (ticket (pair nat (option bytes))) ;
IF_NONE { PUSH string "FAILED_TO_GET_TKT_ENTRYPOINT" ; FAILWITH } {} ;
PUSH mutez 0 ;
DIG 3 ;
TRANSFER_TOKENS ;
DIG 2 ;
NIL operation ;
DIG 2 ;
CONS } ;
DIG 2 ;
CONS ;
PAIR } ;
view "get_total_supply" unit nat { CDR ; GET 6 } ;
view "get_content" unit (pair nat (option bytes)) { CDR ; GET 5 } ;
view "get_token" unit (or (address %fa12) (pair %fa2 address nat)) { CDR ; GET 3 } }