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