tx · 8H1ayE7nm48vp3Rn6eMhteBorsxKc8rGKTMvS31on4qt 3ND6EFqVoR6r9jWRL87nSf2Zs5AMiNnGWD3: -0.01000000 Waves 2021.07.08 14:29 [1604565] smart account 3ND6EFqVoR6r9jWRL87nSf2Zs5AMiNnGWD3 > SELF 0.00000000 Waves
{ "type": 13, "id": "8H1ayE7nm48vp3Rn6eMhteBorsxKc8rGKTMvS31on4qt", "fee": 1000000, "feeAssetId": null, "timestamp": 1625743769676, "version": 2, "chainId": 84, "sender": "3ND6EFqVoR6r9jWRL87nSf2Zs5AMiNnGWD3", "senderPublicKey": "KUUrvP3E8GJqJe8m89JhbWoFxA5Y6ZArXcUs6XDthT6", "proofs": [ "5dcmRSN8CAQhL8NrxYuCVDMpg4rqEYZsGng7ZF3efFdMPDtDZpFxUe3KyeAnR2FgGoZ4RFCrdgYu4umqyMxiQmdb" ], "script": "base64:AAIDAAAAAAAAAz0IARIFCgMIAQgSBAoCCAgSBQoDCAgIGgoKAmExEgROT05FGgwKAmEyEgZWT1RFUlMaDAoCYTMSBlFVT1JVTRoOCgJhNBIIRkVBVFVSRUQaDgoCYTUSCERFTElTVEVEGgwKAmE2EgZWT1RJTkcaDAoCYTcSBlJFVkVBTBoUCgJhOBIOZ2V0U3RyaW5nQnlLZXkaCQoCYTkSA2tleRoNCgJiMRIHJG1hdGNoMBoHCgJiMhIBYRoVCgJiMxIPZ2V0SW50ZWdlckJ5S2V5GhAKAmI0EgpnZXRLZXlJdGVtGg4KAmI1EghzdXBwbGllchoLCgJiNhIFdGl0bGUaEwoCYjcSDXN1cHBsaWVyVGl0bGUaGAoCYjgSEmdldEtleUl0ZW1TdXBwbGllchoKCgJiORIEaXRlbRoVCgJjMRIPZ2V0S2V5SXRlbVByaWNlGhQKAmMyEg5nZXRLZXlJdGVtRGF0YRoSCgJjMxIMZ2V0S2V5Q29tbWl0GgoKAmM0EgR1c2VyGhgKAmM1EhJnZXRLZXlDb21taXRzQ291bnQaEgoCYzYSDGdldE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iOQUAAAACYzQFAAAAAmExCQAAAgAAAAECAAAAEVlvdSBWb3RlZCBBbHJlYWR5AwMJAQAAAAIhPQAAAAIFAAAAAmU1BQAAAAJhNgkBAAAAAiE9AAAAAgUAAAACZTUFAAAAAmE3BwkAAAIAAAABAgAAACZWb3RpbmcgaXMgbm90IGFjdGl2ZSBmb3IgdGhpcyBpdGVtIG5vdwMDCQEAAAACIT0AAAACBQAAAAJjOQUAAAACYTQJAQAAAAIhPQAAAAIFAAAAAmM5BQAAAAJhNQcJAAACAAAAAQIAAAAjUHJvdmlkZWQgdm90aW5nIG9wdGlvbiBpcyBpbmNvcnJlY3QEAAAAAmU2AwkAAGcAAAACBQAAAAJlOAUAAAACYTMFAAAAAmM5BQAAAAJhNwkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAAmM2AAAAAgUAAAACYjkFAAAAAmM0BQAAAAJjOQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAAmM4AAAAAgUAAAACYjkFAAAAAmM5BQAAAAJlOAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAAmM3AAAAAQUAAAACYjkFAAAAAmU2BQAAAANuaWwAAAAAwMOmkg==", "height": 1604565, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8bQBiW1Ls5PgrUgZGde395t6gyaUzUYsCT9WTAwS2hpE Next: 2BaQqHwYrXmhqq2UrR91KMH1mA3vSuxc3ZAg7hvbgEFq Diff:
Old | New | Differences | |
---|---|---|---|
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let a = "NONE" | |
5 | 5 | ||
6 | - | func b (c,d) = { | |
7 | - | let e = (c + d) | |
8 | - | ("item_" + toBase58String(sha256(toBytes(e)))) | |
6 | + | let b = 3 | |
7 | + | ||
8 | + | let c = 2 | |
9 | + | ||
10 | + | let d = "featured" | |
11 | + | ||
12 | + | let e = "delisted" | |
13 | + | ||
14 | + | let f = "voting" | |
15 | + | ||
16 | + | let g = "reveal" | |
17 | + | ||
18 | + | func h (i) = { | |
19 | + | let j = getString(this, i) | |
20 | + | if ($isInstanceOf(j, "String")) | |
21 | + | then { | |
22 | + | let k = j | |
23 | + | k | |
24 | + | } | |
25 | + | else a | |
9 | 26 | } | |
10 | 27 | ||
11 | 28 | ||
12 | - | func f (g) = (g + "_owner") | |
13 | - | ||
14 | - | ||
15 | - | func h (g) = (g + "_price") | |
16 | - | ||
17 | - | ||
18 | - | func i (g) = (g + "_data") | |
19 | - | ||
20 | - | ||
21 | - | func j (g) = { | |
22 | - | let k = { | |
23 | - | let l = getString(this, (g + "_owner")) | |
24 | - | if ($isInstanceOf(l, "String")) | |
25 | - | then { | |
26 | - | let m = l | |
27 | - | m | |
28 | - | } | |
29 | - | else a | |
30 | - | } | |
31 | - | k | |
29 | + | func l (i) = { | |
30 | + | let j = getInteger(this, i) | |
31 | + | if ($isInstanceOf(j, "Int")) | |
32 | + | then { | |
33 | + | let k = j | |
34 | + | k | |
35 | + | } | |
36 | + | else 0 | |
32 | 37 | } | |
33 | 38 | ||
34 | 39 | ||
35 | - | @Callable(n) | |
36 | - | func addItem (d,o,p) = { | |
37 | - | let q = toBase58String(n.caller.bytes) | |
38 | - | let g = b(q, d) | |
39 | - | if ((0 >= o)) | |
40 | + | func m (n,o) = { | |
41 | + | let p = (n + o) | |
42 | + | ("item_" + toBase58String(sha256(toBytes(p)))) | |
43 | + | } | |
44 | + | ||
45 | + | ||
46 | + | func q (r) = (r + "_owner") | |
47 | + | ||
48 | + | ||
49 | + | func s (r) = (r + "_price") | |
50 | + | ||
51 | + | ||
52 | + | func t (r) = (r + "_data") | |
53 | + | ||
54 | + | ||
55 | + | func u (r,v) = (((r + "_") + v) + "_commit") | |
56 | + | ||
57 | + | ||
58 | + | func w (r) = (r + "_cmtcnt") | |
59 | + | ||
60 | + | ||
61 | + | func x (r,v) = (((r + "_") + v) + "_reveal") | |
62 | + | ||
63 | + | ||
64 | + | func y (r) = (r + "_status") | |
65 | + | ||
66 | + | ||
67 | + | func z (r,A) = ((r + "_res:") + A) | |
68 | + | ||
69 | + | ||
70 | + | func B (C) = h(q(C)) | |
71 | + | ||
72 | + | ||
73 | + | func D (r,v) = h(u(r, v)) | |
74 | + | ||
75 | + | ||
76 | + | func E (r) = l(w(r)) | |
77 | + | ||
78 | + | ||
79 | + | func F (r,v) = h(x(r, v)) | |
80 | + | ||
81 | + | ||
82 | + | func G (r) = h(y(r)) | |
83 | + | ||
84 | + | ||
85 | + | func H (r,A) = l(z(r, A)) | |
86 | + | ||
87 | + | ||
88 | + | @Callable(I) | |
89 | + | func addItem (o,J,K) = { | |
90 | + | let L = toBase58String(I.caller.bytes) | |
91 | + | let r = m(L, o) | |
92 | + | if ((0 >= J)) | |
40 | 93 | then throw("purchase amount cannot be less than item price") | |
41 | - | else if (( | |
94 | + | else if ((B(r) != a)) | |
42 | 95 | then throw("An item already exists") | |
43 | - | else WriteSet([DataEntry(f(g), q), DataEntry(h(g), o), DataEntry(i(g), p)]) | |
96 | + | else WriteSet([DataEntry(q(r), L), DataEntry(s(r), J), DataEntry(t(r), K)]) | |
97 | + | } | |
98 | + | ||
99 | + | ||
100 | + | ||
101 | + | @Callable(I) | |
102 | + | func voteCommit (r,M) = { | |
103 | + | let v = toBase58String(I.caller.bytes) | |
104 | + | let N = E(r) | |
105 | + | let O = G(r) | |
106 | + | if ((N >= b)) | |
107 | + | then throw("Reached max number of voters") | |
108 | + | else if ((D(r, v) != a)) | |
109 | + | then throw("Your Voted already") | |
110 | + | else if ((B(q(r)) == a)) | |
111 | + | then throw("Item Does not exist") | |
112 | + | else if (if ((O != a)) | |
113 | + | then (O != f) | |
114 | + | else false) | |
115 | + | then throw("Voting is not active for this Item now") | |
116 | + | else { | |
117 | + | let P = if ((N == b)) | |
118 | + | then g | |
119 | + | else f | |
120 | + | WriteSet([DataEntry(u(r, v), M), DataEntry(w(r), (N + 1)), DataEntry(y(r), P)]) | |
121 | + | } | |
122 | + | } | |
123 | + | ||
124 | + | ||
125 | + | ||
126 | + | @Callable(I) | |
127 | + | func voteReveal (r,A,Q) = { | |
128 | + | let v = toBase58String(I.caller.bytes) | |
129 | + | let O = G(r) | |
130 | + | let R = (H(r, A) + 1) | |
131 | + | let S = ((r + A) + Q) | |
132 | + | if ((toBase58String(sha256(toBytes(S))) != D(r, v))) | |
133 | + | then throw("Reveal data is not valid") | |
134 | + | else if ((b > E(r))) | |
135 | + | then throw("Max Number of Voters not reached") | |
136 | + | else if ((F(r, v) != a)) | |
137 | + | then throw("You Voted Already") | |
138 | + | else if (if ((O != f)) | |
139 | + | then (O != g) | |
140 | + | else false) | |
141 | + | then throw("Voting is not active for this item now") | |
142 | + | else if (if ((A != d)) | |
143 | + | then (A != e) | |
144 | + | else false) | |
145 | + | then throw("Provided voting option is incorrect") | |
146 | + | else { | |
147 | + | let P = if ((R >= c)) | |
148 | + | then A | |
149 | + | else g | |
150 | + | WriteSet([DataEntry(x(r, v), A), DataEntry(z(r, A), R), DataEntry(y(r), P)]) | |
151 | + | } | |
44 | 152 | } | |
45 | 153 | ||
46 | 154 |
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 | - | func b (c,d) = { | |
7 | - | let e = (c + d) | |
8 | - | ("item_" + toBase58String(sha256(toBytes(e)))) | |
6 | + | let b = 3 | |
7 | + | ||
8 | + | let c = 2 | |
9 | + | ||
10 | + | let d = "featured" | |
11 | + | ||
12 | + | let e = "delisted" | |
13 | + | ||
14 | + | let f = "voting" | |
15 | + | ||
16 | + | let g = "reveal" | |
17 | + | ||
18 | + | func h (i) = { | |
19 | + | let j = getString(this, i) | |
20 | + | if ($isInstanceOf(j, "String")) | |
21 | + | then { | |
22 | + | let k = j | |
23 | + | k | |
24 | + | } | |
25 | + | else a | |
9 | 26 | } | |
10 | 27 | ||
11 | 28 | ||
12 | - | func f (g) = (g + "_owner") | |
13 | - | ||
14 | - | ||
15 | - | func h (g) = (g + "_price") | |
16 | - | ||
17 | - | ||
18 | - | func i (g) = (g + "_data") | |
19 | - | ||
20 | - | ||
21 | - | func j (g) = { | |
22 | - | let k = { | |
23 | - | let l = getString(this, (g + "_owner")) | |
24 | - | if ($isInstanceOf(l, "String")) | |
25 | - | then { | |
26 | - | let m = l | |
27 | - | m | |
28 | - | } | |
29 | - | else a | |
30 | - | } | |
31 | - | k | |
29 | + | func l (i) = { | |
30 | + | let j = getInteger(this, i) | |
31 | + | if ($isInstanceOf(j, "Int")) | |
32 | + | then { | |
33 | + | let k = j | |
34 | + | k | |
35 | + | } | |
36 | + | else 0 | |
32 | 37 | } | |
33 | 38 | ||
34 | 39 | ||
35 | - | @Callable(n) | |
36 | - | func addItem (d,o,p) = { | |
37 | - | let q = toBase58String(n.caller.bytes) | |
38 | - | let g = b(q, d) | |
39 | - | if ((0 >= o)) | |
40 | + | func m (n,o) = { | |
41 | + | let p = (n + o) | |
42 | + | ("item_" + toBase58String(sha256(toBytes(p)))) | |
43 | + | } | |
44 | + | ||
45 | + | ||
46 | + | func q (r) = (r + "_owner") | |
47 | + | ||
48 | + | ||
49 | + | func s (r) = (r + "_price") | |
50 | + | ||
51 | + | ||
52 | + | func t (r) = (r + "_data") | |
53 | + | ||
54 | + | ||
55 | + | func u (r,v) = (((r + "_") + v) + "_commit") | |
56 | + | ||
57 | + | ||
58 | + | func w (r) = (r + "_cmtcnt") | |
59 | + | ||
60 | + | ||
61 | + | func x (r,v) = (((r + "_") + v) + "_reveal") | |
62 | + | ||
63 | + | ||
64 | + | func y (r) = (r + "_status") | |
65 | + | ||
66 | + | ||
67 | + | func z (r,A) = ((r + "_res:") + A) | |
68 | + | ||
69 | + | ||
70 | + | func B (C) = h(q(C)) | |
71 | + | ||
72 | + | ||
73 | + | func D (r,v) = h(u(r, v)) | |
74 | + | ||
75 | + | ||
76 | + | func E (r) = l(w(r)) | |
77 | + | ||
78 | + | ||
79 | + | func F (r,v) = h(x(r, v)) | |
80 | + | ||
81 | + | ||
82 | + | func G (r) = h(y(r)) | |
83 | + | ||
84 | + | ||
85 | + | func H (r,A) = l(z(r, A)) | |
86 | + | ||
87 | + | ||
88 | + | @Callable(I) | |
89 | + | func addItem (o,J,K) = { | |
90 | + | let L = toBase58String(I.caller.bytes) | |
91 | + | let r = m(L, o) | |
92 | + | if ((0 >= J)) | |
40 | 93 | then throw("purchase amount cannot be less than item price") | |
41 | - | else if (( | |
94 | + | else if ((B(r) != a)) | |
42 | 95 | then throw("An item already exists") | |
43 | - | else WriteSet([DataEntry(f(g), q), DataEntry(h(g), o), DataEntry(i(g), p)]) | |
96 | + | else WriteSet([DataEntry(q(r), L), DataEntry(s(r), J), DataEntry(t(r), K)]) | |
97 | + | } | |
98 | + | ||
99 | + | ||
100 | + | ||
101 | + | @Callable(I) | |
102 | + | func voteCommit (r,M) = { | |
103 | + | let v = toBase58String(I.caller.bytes) | |
104 | + | let N = E(r) | |
105 | + | let O = G(r) | |
106 | + | if ((N >= b)) | |
107 | + | then throw("Reached max number of voters") | |
108 | + | else if ((D(r, v) != a)) | |
109 | + | then throw("Your Voted already") | |
110 | + | else if ((B(q(r)) == a)) | |
111 | + | then throw("Item Does not exist") | |
112 | + | else if (if ((O != a)) | |
113 | + | then (O != f) | |
114 | + | else false) | |
115 | + | then throw("Voting is not active for this Item now") | |
116 | + | else { | |
117 | + | let P = if ((N == b)) | |
118 | + | then g | |
119 | + | else f | |
120 | + | WriteSet([DataEntry(u(r, v), M), DataEntry(w(r), (N + 1)), DataEntry(y(r), P)]) | |
121 | + | } | |
122 | + | } | |
123 | + | ||
124 | + | ||
125 | + | ||
126 | + | @Callable(I) | |
127 | + | func voteReveal (r,A,Q) = { | |
128 | + | let v = toBase58String(I.caller.bytes) | |
129 | + | let O = G(r) | |
130 | + | let R = (H(r, A) + 1) | |
131 | + | let S = ((r + A) + Q) | |
132 | + | if ((toBase58String(sha256(toBytes(S))) != D(r, v))) | |
133 | + | then throw("Reveal data is not valid") | |
134 | + | else if ((b > E(r))) | |
135 | + | then throw("Max Number of Voters not reached") | |
136 | + | else if ((F(r, v) != a)) | |
137 | + | then throw("You Voted Already") | |
138 | + | else if (if ((O != f)) | |
139 | + | then (O != g) | |
140 | + | else false) | |
141 | + | then throw("Voting is not active for this item now") | |
142 | + | else if (if ((A != d)) | |
143 | + | then (A != e) | |
144 | + | else false) | |
145 | + | then throw("Provided voting option is incorrect") | |
146 | + | else { | |
147 | + | let P = if ((R >= c)) | |
148 | + | then A | |
149 | + | else g | |
150 | + | WriteSet([DataEntry(x(r, v), A), DataEntry(z(r, A), R), DataEntry(y(r), P)]) | |
151 | + | } | |
44 | 152 | } | |
45 | 153 | ||
46 | 154 |
github/deemru/w8io/026f985 33.71 ms ◑