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