BCD

Tezos Contract Explorer
Search Networks Deploy
  • Home
  • /
  • Seoulnet
  • /
  • KT1PHuJ...dT1r
operations (1)Storage Code Interact Tokens Fork Views Details
Latest
​x
106
 
1
{ parameter (or (pair %manage_authorization (string %action) (address %user))
2
                (or (map %update_metadata string string)
3
                    (or
4
                      (pair %set_nested_record
5
                        (pair %metadata (timestamp %created_at) (list %tags string))
6
                        (set %permissions string))
7
                      (pair %add_user_record (string %name) (nat %age) (bool %active))))) ;
8
  storage (pair
9
            (big_map %user_records address
10
                                   (pair (string %name) (nat %age) (bool %active)))
11
            (map %metadata_map string string)
12
            (map %complex_data address
13
                               (pair
14
                                 (pair %metadata (timestamp %created_at)
15
                                                 (list %tags string))
16
                                 (set %permissions string)))
17
            (set %authorized_users address)
18
            (timestamp %last_updated)) ;
19
  code { LAMBDA unit timestamp { DROP ; NOW } ;
20
         SWAP ;
21
         UNPAIR ;
22
         IF_LEFT
23
           { PUSH string "add" ;
24
             DUP 2 ;
25
             CAR ;
26
             COMPARE ;
27
             EQ ;
28
             IF
29
               { DUP 2 ;
30
                 GET 7 ;
31
                 PUSH bool True ;
32
                 DIG 2 ;
33
                 CDR ;
34
                 UPDATE ;
35
                 UPDATE 7 ;
36
                 UNIT ;
37
                 DIG 2 ;
38
                 SWAP ;
39
                 EXEC ;
40
                 UPDATE 8 ;
41
                 NIL operation ;
42
                 PAIR }
43
               { PUSH string "remove" ;
44
                 DUP 2 ;
45
                 CAR ;
46
                 COMPARE ;
47
                 EQ ;
48
                 IF
49
                   { DUP 2 ;
50
                     GET 7 ;
51
                     PUSH bool False ;
52
                     DIG 2 ;
53
                     CDR ;
54
                     UPDATE ;
55
                     UPDATE 7 ;
56
                     UNIT ;
57
                     DIG 2 ;
58
                     SWAP ;
59
                     EXEC ;
60
                     UPDATE 8 ;
61
                     NIL operation ;
62
                     PAIR }
63
                   { DROP 3 ;
64
                     PUSH string "Invalid action. Use 'add' or 'remove'" ;
65
                     FAILWITH } } }
66
           { IF_LEFT
67
               { UPDATE 3 ; UNIT ; DIG 2 ; SWAP ; EXEC ; UPDATE 8 }
68
               { IF_LEFT
69
                   { SENDER ;
70
                     DUP 3 ;
71
                     DIG 3 ;
72
                     GET 5 ;
73
                     DIG 3 ;
74
                     SOME ;
75
                     DIG 3 ;
76
                     UPDATE ;
77
                     UPDATE 5 ;
78
                     UNIT ;
79
                     DIG 2 ;
80
                     SWAP ;
81
                     EXEC ;
82
                     UPDATE 8 }
83
                   { SENDER ;
84
                     DUP 3 ;
85
                     DIG 3 ;
86
                     CAR ;
87
                     DIG 3 ;
88
                     SOME ;
89
                     DIG 3 ;
90
                     UPDATE ;
91
                     UPDATE 1 ;
92
                     UNIT ;
93
                     DIG 2 ;
94
                     SWAP ;
95
                     EXEC ;
96
                     UPDATE 8 } } ;
97
             NIL operation ;
98
             PAIR } } ;
99
  view "get_user_record" address
100
        (option (pair (string %name) (nat %age) (bool %active)))
101
        { UNPAIR ; SWAP ; CAR ; SWAP ; GET } ;
102
  view "get_nested_record" address
103
        (option (pair (pair %metadata (timestamp %created_at) (list %tags string))
104
                     (set %permissions string)))
105
        { UNPAIR ; SWAP ; GET 5 ; SWAP ; GET } ;
106
  view "get_all_metadata" unit (map string string) { CDR ; GET 3 } }