tx · 7hFmwEj7tsA1GPPDmqEX7hzjYL2U2T7T2acC183P1CJT 3MzvMg5dRiLMVdHJ3v4AfeCXttmaSPHdoVN: -0.01400000 Waves 2019.11.17 22:59 [769590] smart account 3MzvMg5dRiLMVdHJ3v4AfeCXttmaSPHdoVN > SELF 0.00000000 Waves
{ "type": 13, "id": "7hFmwEj7tsA1GPPDmqEX7hzjYL2U2T7T2acC183P1CJT", "fee": 1400000, "feeAssetId": null, "timestamp": 1574020832361, "version": 1, "sender": "3MzvMg5dRiLMVdHJ3v4AfeCXttmaSPHdoVN", "senderPublicKey": "GvoCzLxrhCgZzNLksqhf43ehht8jTASRqtGBmXaNn7Jq", "proofs": [ "3rLXqGgRkaueNM5vQNe14nSx7cGTmjPS4AS2ycXcgrdwK4PSmqgxkPRLXJ8KrzmYypwF8Mb77UkwVn3LWrZPec3z" ], "script": "base64:AAIDAAAAAAAAABsIARIAEgMKAQESBQoDCAEIEgMKAQgSBAoCCAgAAAAdAAAAAAROT05FAgAAAARub25lAAAAAAZWT1RFUlMAAAAAAAAAAAMAAAAABlFVT1JVTQAAAAAAAAAAAgAAAAAGVk9USU5HAgAAAAZ2b3RpbmcAAAAABlJFVkVBTAIAAAAGcmV2ZWFsAAAAAAhGRUFUVVJFRAIAAAAIZmVhdHVyZWQAAAAACERFTElTVEVEAgAAAAhkZWxpc3RlZAEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAAAC2dldFN0ckJ5S2V5AAAAAQAAAANrZXkEAAAAA3N0cgQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAA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wMJAQAAAAIhPQAAAAIJAQAAAA5nZXRWYWx1ZUNvbW1pdAAAAAIFAAAABGl0ZW0FAAAABHVzZXIFAAAABE5PTkUJAAACAAAAAQIAAAAddXNlciBoYXMgYWxyZWFkeSBwYXJ0aWNpcGF0ZWQDCQAAAAAAAAIJAQAAABJnZXRLZXlJdGVtU3VwcGxpZXIAAAABBQAAAARpdGVtBQAAAAROT05FCQAAAgAAAAECAAAAE2l0ZW0gZG9lcyBub3QgZXhpc3QDAwkBAAAAAiE9AAAAAgUAAAAGc3RhdHVzBQAAAAROT05FCQEAAAACIT0AAAACBQAAAAZzdGF0dXMFAAAABlZPVElORwcJAAACAAAAAQIAAAAWdm90aW5nIGlzIG5vdCBwb3NzaWJsZQkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAADGdldEtleUNvbW1pdAAAAAIFAAAABGl0ZW0FAAAABHVzZXIFAAAABGhhc2gJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAABJnZXRLZXlDb21taXRzQ291bnQAAAABBQAAAARpdGVtCQAAZAAAAAIFAAAAB2NvbW1pdHMAAAAAAAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAABBnZXRLZXlJdGVtU3RhdHVzAAAAAQUAAAAEaXRlbQMJAAAAAAAAAgUAAAAHY29tbWl0cwUAAAAGVk9URVJTBQAAAAZSRVZFQUwFAAAABlZPVElORwUAAAADbmlsAAAAAALT8r0=", "chainId": 84, "height": 769590, "spentComplexity": 0 } View: original | compacted Prev: D41TLMtkcGZvmDMKpiW65tFGTht3f45Rao9FGtFJuk3r Next: FbSw7a8c85bkSpU2acvUEje6n1Q7PTAko4mK8j64e3LS Diff:
Old | New | Differences | |
---|---|---|---|
52 | 52 | func r (s,p) = (((p + "_") + s) + "_cnt") | |
53 | 53 | ||
54 | 54 | ||
55 | - | func t ( | |
55 | + | func t (s,p) = h(r(s, p)) | |
56 | 56 | ||
57 | 57 | ||
58 | - | func | |
58 | + | func u (v,w) = ("item_" + toBase58String(sha256(toBytes((v + w))))) | |
59 | 59 | ||
60 | 60 | ||
61 | - | func x (p) = (p + "_ | |
61 | + | func x (p) = (p + "_data") | |
62 | 62 | ||
63 | 63 | ||
64 | - | func y (p) = | |
64 | + | func y (p) = (p + "_owner") | |
65 | 65 | ||
66 | 66 | ||
67 | - | func z ( | |
67 | + | func z (p) = m(y(p)) | |
68 | 68 | ||
69 | 69 | ||
70 | - | func | |
70 | + | func A (B) = (B + "_balance") | |
71 | 71 | ||
72 | 72 | ||
73 | - | func C ( | |
73 | + | func C (B) = h(A(B)) | |
74 | 74 | ||
75 | 75 | ||
76 | - | func D (p,s) = | |
76 | + | func D (p,s) = (((p + "_") + s) + "_commit") | |
77 | 77 | ||
78 | 78 | ||
79 | - | func E (p) = (p | |
79 | + | func E (p,s) = m(D(p, s)) | |
80 | 80 | ||
81 | 81 | ||
82 | - | func F (p) = | |
82 | + | func F (p) = (p + "_comctn") | |
83 | 83 | ||
84 | 84 | ||
85 | - | func G (p | |
85 | + | func G (p) = h(F(p)) | |
86 | 86 | ||
87 | 87 | ||
88 | - | func H (p,s) = | |
88 | + | func H (p,s) = (((p + "_") + s) + "_reveal") | |
89 | 89 | ||
90 | 90 | ||
91 | - | func I (p) = (p | |
91 | + | func I (p,s) = m(H(p, s)) | |
92 | 92 | ||
93 | 93 | ||
94 | - | func J (p) = | |
94 | + | func J (p) = (p + "_status") | |
95 | 95 | ||
96 | 96 | ||
97 | - | func K (p | |
97 | + | func K (p) = m(J(p)) | |
98 | 98 | ||
99 | 99 | ||
100 | - | func | |
100 | + | func L (p,M) = ((p + "_res:") + M) | |
101 | 101 | ||
102 | 102 | ||
103 | - | @Callable(N) | |
103 | + | func N (p,M) = h(L(p, M)) | |
104 | + | ||
105 | + | ||
106 | + | @Callable(O) | |
104 | 107 | func deposit () = { | |
105 | - | let | |
106 | - | if (isDefined( | |
108 | + | let P = extract(O.payment) | |
109 | + | if (isDefined(P.assetId)) | |
107 | 110 | then throw("can hold waves only at the moment") | |
108 | 111 | else { | |
109 | - | let | |
110 | - | let | |
111 | - | let k = getInteger(this, | |
112 | + | let Q = toBase58String(O.caller.bytes) | |
113 | + | let R = { | |
114 | + | let k = getInteger(this, Q) | |
112 | 115 | if ($isInstanceOf(k, "Int")) | |
113 | 116 | then { | |
114 | 117 | let l = k | |
116 | 119 | } | |
117 | 120 | else 0 | |
118 | 121 | } | |
119 | - | let | |
120 | - | let k = getString(this, ("wl_sts_" + | |
122 | + | let S = { | |
123 | + | let k = getString(this, ("wl_sts_" + Q)) | |
121 | 124 | if ($isInstanceOf(k, "String")) | |
122 | 125 | then { | |
123 | 126 | let l = k | |
125 | 128 | } | |
126 | 129 | else throw("User has not been whitelisted") | |
127 | 130 | } | |
128 | - | let | |
129 | - | WriteSet([DataEntry( | |
131 | + | let T = (R + P.amount) | |
132 | + | WriteSet([DataEntry(Q, T)]) | |
130 | 133 | } | |
131 | 134 | } | |
132 | 135 | ||
133 | 136 | ||
134 | 137 | ||
135 | - | @Callable( | |
136 | - | func withdraw ( | |
137 | - | let | |
138 | - | let | |
139 | - | let k = getInteger(this, | |
138 | + | @Callable(O) | |
139 | + | func withdraw (U) = { | |
140 | + | let Q = toBase58String(O.caller.bytes) | |
141 | + | let R = { | |
142 | + | let k = getInteger(this, Q) | |
140 | 143 | if ($isInstanceOf(k, "Int")) | |
141 | 144 | then { | |
142 | 145 | let l = k | |
144 | 147 | } | |
145 | 148 | else 0 | |
146 | 149 | } | |
147 | - | let | |
148 | - | if ((0 > | |
150 | + | let T = (R - U) | |
151 | + | if ((0 > U)) | |
149 | 152 | then throw("Can't withdraw negative amount") | |
150 | - | else if ((0 > | |
153 | + | else if ((0 > T)) | |
151 | 154 | then throw("Not enough balance") | |
152 | - | else ScriptResult(WriteSet([DataEntry( | |
155 | + | else ScriptResult(WriteSet([DataEntry(Q, T)]), TransferSet([ScriptTransfer(O.caller, U, unit)])) | |
153 | 156 | } | |
154 | 157 | ||
155 | 158 | ||
156 | 159 | ||
157 | - | @Callable( | |
158 | - | func addItem ( | |
159 | - | let | |
160 | - | let p = | |
161 | - | if ((0 >= | |
160 | + | @Callable(O) | |
161 | + | func addItem (w,V,W) = { | |
162 | + | let X = toBase58String(O.caller.bytes) | |
163 | + | let p = u(X, w) | |
164 | + | if ((0 >= V)) | |
162 | 165 | then throw("purchase amount cannot be less than item price") | |
163 | - | else if (( | |
166 | + | else if ((z(p) != a)) | |
164 | 167 | then throw("an item is already exist") | |
165 | - | else WriteSet([DataEntry( | |
168 | + | else WriteSet([DataEntry(y(p), X), DataEntry(o(p), V), DataEntry(x(p), W)]) | |
166 | 169 | } | |
167 | 170 | ||
168 | 171 | ||
169 | 172 | ||
170 | - | @Callable(N) | |
171 | - | func voteCommit (p,X) = { | |
172 | - | let s = toBase58String(N.caller.bytes) | |
173 | - | let Y = F(p) | |
174 | - | let Z = J(p) | |
175 | - | if ((Y >= b)) | |
173 | + | @Callable(O) | |
174 | + | func purchase (p) = { | |
175 | + | let P = extract(O.payment) | |
176 | + | if (isDefined(P.assetId)) | |
177 | + | then throw("WAVES tokens only at the moment") | |
178 | + | else { | |
179 | + | let Y = toBase58String(O.caller.bytes) | |
180 | + | let V = q(p) | |
181 | + | let X = z(p) | |
182 | + | if ((V > P.amount)) | |
183 | + | then throw("purchase amount cannot be less than item price") | |
184 | + | else if ((P.amount > V)) | |
185 | + | then throw("purchase amount cannot be higher than item price") | |
186 | + | else if ((X == a)) | |
187 | + | then throw("supplier does not exist") | |
188 | + | else WriteSet([DataEntry(r(Y, p), (t(Y, p) + 1)), DataEntry(A(X), (C(X) + P.amount))]) | |
189 | + | } | |
190 | + | } | |
191 | + | ||
192 | + | ||
193 | + | ||
194 | + | @Callable(O) | |
195 | + | func voteCommit (p,Z) = { | |
196 | + | let s = toBase58String(O.caller.bytes) | |
197 | + | let aa = G(p) | |
198 | + | let ab = K(p) | |
199 | + | if ((aa >= b)) | |
176 | 200 | then throw("reached max num of voters") | |
177 | - | else if (( | |
201 | + | else if ((E(p, s) != a)) | |
178 | 202 | then throw("user has already participated") | |
179 | - | else if (( | |
203 | + | else if ((y(p) == a)) | |
180 | 204 | then throw("item does not exist") | |
181 | - | else if (if (( | |
182 | - | then ( | |
205 | + | else if (if ((ab != a)) | |
206 | + | then (ab != d) | |
183 | 207 | else false) | |
184 | 208 | then throw("voting is not possible") | |
185 | - | else WriteSet([DataEntry( | |
209 | + | else WriteSet([DataEntry(D(p, s), Z), DataEntry(F(p), (aa + 1)), DataEntry(J(p), if ((aa == b)) | |
186 | 210 | then e | |
187 | 211 | else d)]) | |
188 | 212 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let a = "none" | |
5 | 5 | ||
6 | 6 | let b = 3 | |
7 | 7 | ||
8 | 8 | let c = 2 | |
9 | 9 | ||
10 | 10 | let d = "voting" | |
11 | 11 | ||
12 | 12 | let e = "reveal" | |
13 | 13 | ||
14 | 14 | let f = "featured" | |
15 | 15 | ||
16 | 16 | let g = "delisted" | |
17 | 17 | ||
18 | 18 | func h (i) = { | |
19 | 19 | let j = { | |
20 | 20 | let k = getInteger(this, i) | |
21 | 21 | if ($isInstanceOf(k, "Int")) | |
22 | 22 | then { | |
23 | 23 | let l = k | |
24 | 24 | l | |
25 | 25 | } | |
26 | 26 | else 0 | |
27 | 27 | } | |
28 | 28 | j | |
29 | 29 | } | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func m (i) = { | |
33 | 33 | let n = { | |
34 | 34 | let k = getString(this, i) | |
35 | 35 | if ($isInstanceOf(k, "String")) | |
36 | 36 | then { | |
37 | 37 | let l = k | |
38 | 38 | l | |
39 | 39 | } | |
40 | 40 | else a | |
41 | 41 | } | |
42 | 42 | n | |
43 | 43 | } | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func o (p) = (p + "_price") | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func q (p) = h(o(p)) | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func r (s,p) = (((p + "_") + s) + "_cnt") | |
53 | 53 | ||
54 | 54 | ||
55 | - | func t ( | |
55 | + | func t (s,p) = h(r(s, p)) | |
56 | 56 | ||
57 | 57 | ||
58 | - | func | |
58 | + | func u (v,w) = ("item_" + toBase58String(sha256(toBytes((v + w))))) | |
59 | 59 | ||
60 | 60 | ||
61 | - | func x (p) = (p + "_ | |
61 | + | func x (p) = (p + "_data") | |
62 | 62 | ||
63 | 63 | ||
64 | - | func y (p) = | |
64 | + | func y (p) = (p + "_owner") | |
65 | 65 | ||
66 | 66 | ||
67 | - | func z ( | |
67 | + | func z (p) = m(y(p)) | |
68 | 68 | ||
69 | 69 | ||
70 | - | func | |
70 | + | func A (B) = (B + "_balance") | |
71 | 71 | ||
72 | 72 | ||
73 | - | func C ( | |
73 | + | func C (B) = h(A(B)) | |
74 | 74 | ||
75 | 75 | ||
76 | - | func D (p,s) = | |
76 | + | func D (p,s) = (((p + "_") + s) + "_commit") | |
77 | 77 | ||
78 | 78 | ||
79 | - | func E (p) = (p | |
79 | + | func E (p,s) = m(D(p, s)) | |
80 | 80 | ||
81 | 81 | ||
82 | - | func F (p) = | |
82 | + | func F (p) = (p + "_comctn") | |
83 | 83 | ||
84 | 84 | ||
85 | - | func G (p | |
85 | + | func G (p) = h(F(p)) | |
86 | 86 | ||
87 | 87 | ||
88 | - | func H (p,s) = | |
88 | + | func H (p,s) = (((p + "_") + s) + "_reveal") | |
89 | 89 | ||
90 | 90 | ||
91 | - | func I (p) = (p | |
91 | + | func I (p,s) = m(H(p, s)) | |
92 | 92 | ||
93 | 93 | ||
94 | - | func J (p) = | |
94 | + | func J (p) = (p + "_status") | |
95 | 95 | ||
96 | 96 | ||
97 | - | func K (p | |
97 | + | func K (p) = m(J(p)) | |
98 | 98 | ||
99 | 99 | ||
100 | - | func | |
100 | + | func L (p,M) = ((p + "_res:") + M) | |
101 | 101 | ||
102 | 102 | ||
103 | - | @Callable(N) | |
103 | + | func N (p,M) = h(L(p, M)) | |
104 | + | ||
105 | + | ||
106 | + | @Callable(O) | |
104 | 107 | func deposit () = { | |
105 | - | let | |
106 | - | if (isDefined( | |
108 | + | let P = extract(O.payment) | |
109 | + | if (isDefined(P.assetId)) | |
107 | 110 | then throw("can hold waves only at the moment") | |
108 | 111 | else { | |
109 | - | let | |
110 | - | let | |
111 | - | let k = getInteger(this, | |
112 | + | let Q = toBase58String(O.caller.bytes) | |
113 | + | let R = { | |
114 | + | let k = getInteger(this, Q) | |
112 | 115 | if ($isInstanceOf(k, "Int")) | |
113 | 116 | then { | |
114 | 117 | let l = k | |
115 | 118 | l | |
116 | 119 | } | |
117 | 120 | else 0 | |
118 | 121 | } | |
119 | - | let | |
120 | - | let k = getString(this, ("wl_sts_" + | |
122 | + | let S = { | |
123 | + | let k = getString(this, ("wl_sts_" + Q)) | |
121 | 124 | if ($isInstanceOf(k, "String")) | |
122 | 125 | then { | |
123 | 126 | let l = k | |
124 | 127 | l | |
125 | 128 | } | |
126 | 129 | else throw("User has not been whitelisted") | |
127 | 130 | } | |
128 | - | let | |
129 | - | WriteSet([DataEntry( | |
131 | + | let T = (R + P.amount) | |
132 | + | WriteSet([DataEntry(Q, T)]) | |
130 | 133 | } | |
131 | 134 | } | |
132 | 135 | ||
133 | 136 | ||
134 | 137 | ||
135 | - | @Callable( | |
136 | - | func withdraw ( | |
137 | - | let | |
138 | - | let | |
139 | - | let k = getInteger(this, | |
138 | + | @Callable(O) | |
139 | + | func withdraw (U) = { | |
140 | + | let Q = toBase58String(O.caller.bytes) | |
141 | + | let R = { | |
142 | + | let k = getInteger(this, Q) | |
140 | 143 | if ($isInstanceOf(k, "Int")) | |
141 | 144 | then { | |
142 | 145 | let l = k | |
143 | 146 | l | |
144 | 147 | } | |
145 | 148 | else 0 | |
146 | 149 | } | |
147 | - | let | |
148 | - | if ((0 > | |
150 | + | let T = (R - U) | |
151 | + | if ((0 > U)) | |
149 | 152 | then throw("Can't withdraw negative amount") | |
150 | - | else if ((0 > | |
153 | + | else if ((0 > T)) | |
151 | 154 | then throw("Not enough balance") | |
152 | - | else ScriptResult(WriteSet([DataEntry( | |
155 | + | else ScriptResult(WriteSet([DataEntry(Q, T)]), TransferSet([ScriptTransfer(O.caller, U, unit)])) | |
153 | 156 | } | |
154 | 157 | ||
155 | 158 | ||
156 | 159 | ||
157 | - | @Callable( | |
158 | - | func addItem ( | |
159 | - | let | |
160 | - | let p = | |
161 | - | if ((0 >= | |
160 | + | @Callable(O) | |
161 | + | func addItem (w,V,W) = { | |
162 | + | let X = toBase58String(O.caller.bytes) | |
163 | + | let p = u(X, w) | |
164 | + | if ((0 >= V)) | |
162 | 165 | then throw("purchase amount cannot be less than item price") | |
163 | - | else if (( | |
166 | + | else if ((z(p) != a)) | |
164 | 167 | then throw("an item is already exist") | |
165 | - | else WriteSet([DataEntry( | |
168 | + | else WriteSet([DataEntry(y(p), X), DataEntry(o(p), V), DataEntry(x(p), W)]) | |
166 | 169 | } | |
167 | 170 | ||
168 | 171 | ||
169 | 172 | ||
170 | - | @Callable(N) | |
171 | - | func voteCommit (p,X) = { | |
172 | - | let s = toBase58String(N.caller.bytes) | |
173 | - | let Y = F(p) | |
174 | - | let Z = J(p) | |
175 | - | if ((Y >= b)) | |
173 | + | @Callable(O) | |
174 | + | func purchase (p) = { | |
175 | + | let P = extract(O.payment) | |
176 | + | if (isDefined(P.assetId)) | |
177 | + | then throw("WAVES tokens only at the moment") | |
178 | + | else { | |
179 | + | let Y = toBase58String(O.caller.bytes) | |
180 | + | let V = q(p) | |
181 | + | let X = z(p) | |
182 | + | if ((V > P.amount)) | |
183 | + | then throw("purchase amount cannot be less than item price") | |
184 | + | else if ((P.amount > V)) | |
185 | + | then throw("purchase amount cannot be higher than item price") | |
186 | + | else if ((X == a)) | |
187 | + | then throw("supplier does not exist") | |
188 | + | else WriteSet([DataEntry(r(Y, p), (t(Y, p) + 1)), DataEntry(A(X), (C(X) + P.amount))]) | |
189 | + | } | |
190 | + | } | |
191 | + | ||
192 | + | ||
193 | + | ||
194 | + | @Callable(O) | |
195 | + | func voteCommit (p,Z) = { | |
196 | + | let s = toBase58String(O.caller.bytes) | |
197 | + | let aa = G(p) | |
198 | + | let ab = K(p) | |
199 | + | if ((aa >= b)) | |
176 | 200 | then throw("reached max num of voters") | |
177 | - | else if (( | |
201 | + | else if ((E(p, s) != a)) | |
178 | 202 | then throw("user has already participated") | |
179 | - | else if (( | |
203 | + | else if ((y(p) == a)) | |
180 | 204 | then throw("item does not exist") | |
181 | - | else if (if (( | |
182 | - | then ( | |
205 | + | else if (if ((ab != a)) | |
206 | + | then (ab != d) | |
183 | 207 | else false) | |
184 | 208 | then throw("voting is not possible") | |
185 | - | else WriteSet([DataEntry( | |
209 | + | else WriteSet([DataEntry(D(p, s), Z), DataEntry(F(p), (aa + 1)), DataEntry(J(p), if ((aa == b)) | |
186 | 210 | then e | |
187 | 211 | else d)]) | |
188 | 212 | } | |
189 | 213 | ||
190 | 214 |
github/deemru/w8io/169f3d6 81.13 ms ◑