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