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