tx · 5E3iA3mmGDQhoFLTmV5ChfParNXddyYRwFcU8ji6Pi8K 3Mrik3RqY2jPfkkG7R7UiHLBXGGa3jfMpyT: -0.01400000 Waves 2019.08.28 00:27 [650142] smart account 3Mrik3RqY2jPfkkG7R7UiHLBXGGa3jfMpyT > SELF 0.00000000 Waves
{ "type": 13, "id": "5E3iA3mmGDQhoFLTmV5ChfParNXddyYRwFcU8ji6Pi8K", "fee": 1400000, "feeAssetId": null, "timestamp": 1566941242074, "version": 1, "sender": "3Mrik3RqY2jPfkkG7R7UiHLBXGGa3jfMpyT", "senderPublicKey": "Di8Ucr8vDr6jZNa27iAQxGMYEW9WSuF6MCBaM3fe9coP", "proofs": [ "59JNTQfAGQpDiohuHHMgwuMuZkRLmthJ2Yum2TFZHZ4U6JgXP5qFCN2vQFJnPzE8UHNKJPLk6EAnPYRsKcxErMov" ], "script": "base64:AAIDAAAAAAAAAAAAAAAdAAAAAAROT05FAgAAAARub25lAAAAAAZWT1RFUlMAAAAAAAAAAAMAAAAABlFVT1JVTQAAAAAAAAAAAgAAAAAGVk9USU5HAgAAAAZ2b3RpbmcAAAAABlJFVkVBTAIAAAAGcmV2ZWFsAAAAAAhGRUFUVVJFRAIAAAAIZmVhdHVyZWQAAAAACERFTElTVEVEAgAAAAhkZWxpc3RlZAEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAAAC2dldFN0ckJ5S2V5AAAAAQAAAANrZXkEAAAAA3N0cgQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQUAAAAETk9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k9URVJTCQAAAgAAAAECAAAAHHJlYWNoZWQgbWF4IG51bWJlciBvZiB2b3RlcnMDCQEAAAACIT0AAAACCQEAAAAOZ2V0VmFsdWVDb21taXQAAAACBQAAAARpdGVtBQAAAAR1c2VyBQAAAAROT05FCQAAAgAAAAECAAAAHXVzZXIgaGFzIHBhcnRpY2lwYXRlZCBhbHJlYWR5AwkAAAAAAAACCQEAAAASZ2V0S2V5SXRlbVN1cHBsaWVyAAAAAQUAAAAEaXRlbQUAAAAETk9ORQkAAAIAAAABAgAAABNpdGVtIGRvZXNuJ3QgZXhpc3RzAwMJAQAAAAIhPQAAAAIFAAAABnN0YXR1cwUAAAAETk9ORQkBAAAAAiE9AAAAAgUAAAAGc3RhdHVzBQAAAAZWT1RJTkcHCQAAAgAAAAECAAAAFnZvdGluZyBpcyBub3QgcG9zc2libGUJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAAAxnZXRLZXlDb21taXQAAAACBQAAAARpdGVtBQAAAAR1c2VyBQAAAARoYXNoCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAARZ2V0S2V5Q29tbWl0Q291bnQAAAABBQAAAARpdGVtCQAAZAAAAAIFAAAAB2NvbW1pdHMAAAAAAAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAABBnZXRLZXlJdGVtU3RhdHVzAAAAAQUAAAAEaXRlbQMJAAAAAAAAAgUAAAAHY29tbWl0cwkAAGUAAAACBQAAAAZWT1RFUlMAAAAAAAAAAAEFAAAABlJFVkVBTAUAAAAGVk9USU5HBQAAAANuaWwAAAAALK7foQ==", "chainId": 84, "height": 650142, "spentComplexity": 0 } View: original | compacted Prev: 2KTtPtvqHXAVTPviVruN7Qjkc8DkubBjAWKJnM9xb5Ve Next: 8eP6mHWecBPbeTfkeMpKTWCUnK5veAg1z2j1HzbTrFiH 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,q) = ("item_" + toBase58String(sha256(toBytes((p + q))))) | |
35 | 47 | ||
36 | 48 | ||
37 | - | func | |
49 | + | func r (s) = (s + "_price") | |
38 | 50 | ||
39 | 51 | ||
40 | - | func | |
52 | + | func t (s) = (s + "_data") | |
41 | 53 | ||
42 | 54 | ||
43 | - | func | |
55 | + | func u (s) = (s + "_owner") | |
44 | 56 | ||
45 | 57 | ||
46 | - | func | |
58 | + | func v (w) = (w + "_balance") | |
47 | 59 | ||
48 | 60 | ||
49 | - | func | |
61 | + | func x (y,s) = (((s + "_") + y) + "_cnt") | |
50 | 62 | ||
51 | 63 | ||
52 | - | func | |
64 | + | func z (s,y) = (((s + "_") + y) + "_commit") | |
53 | 65 | ||
54 | 66 | ||
55 | - | func | |
67 | + | func A (s) = (s + "_comcnt") | |
56 | 68 | ||
57 | 69 | ||
58 | - | func | |
70 | + | func B (s,y) = (((s + "_") + y) + "_reveal") | |
59 | 71 | ||
60 | 72 | ||
61 | - | func | |
73 | + | func C (s) = (s + "_status") | |
62 | 74 | ||
63 | 75 | ||
64 | - | @Callable(x) | |
65 | - | func addItem (k,y,z) = { | |
66 | - | let A = toBase58String(x.caller.bytes) | |
67 | - | let m = i(A, k) | |
68 | - | if ((0 >= y)) | |
76 | + | func D (s,E) = ((s + "_res:") + E) | |
77 | + | ||
78 | + | ||
79 | + | func F (s) = h(r(s)) | |
80 | + | ||
81 | + | ||
82 | + | func G (s) = m(u(s)) | |
83 | + | ||
84 | + | ||
85 | + | func H (w) = h(v(w)) | |
86 | + | ||
87 | + | ||
88 | + | func I (y,s) = h(x(y, s)) | |
89 | + | ||
90 | + | ||
91 | + | func J (s,y) = m(z(s, y)) | |
92 | + | ||
93 | + | ||
94 | + | func K (s) = h(A(s)) | |
95 | + | ||
96 | + | ||
97 | + | func L (s,y) = m(B(s, y)) | |
98 | + | ||
99 | + | ||
100 | + | func M (s) = m(C(s)) | |
101 | + | ||
102 | + | ||
103 | + | func N (s,E) = h(D(s, E)) | |
104 | + | ||
105 | + | ||
106 | + | @Callable(O) | |
107 | + | func addItem (q,P,Q) = { | |
108 | + | let R = toBase58String(O.caller.bytes) | |
109 | + | let s = o(R, q) | |
110 | + | if ((0 >= P)) | |
69 | 111 | then throw("Purchase amount cannot be less than or equal 0") | |
70 | - | else if (( | |
112 | + | else if ((G(s) != a)) | |
71 | 113 | then throw("Item exists already") | |
72 | - | else WriteSet([DataEntry( | |
114 | + | else WriteSet([DataEntry(u(s), R), DataEntry(r(s), P), DataEntry(t(s), Q)]) | |
73 | 115 | } | |
74 | 116 | ||
75 | 117 | ||
76 | 118 | ||
77 | - | @Callable( | |
78 | - | func purchase ( | |
79 | - | let | |
80 | - | if (isDefined( | |
119 | + | @Callable(O) | |
120 | + | func purchase (s) = { | |
121 | + | let S = extract(O.payment) | |
122 | + | if (isDefined(S.assetId)) | |
81 | 123 | then throw("WAVES 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 = F(s) | |
127 | + | let R = G(s) | |
128 | + | if ((P > S.amount)) | |
87 | 129 | then throw("purchase amount cannot be less than item price") | |
88 | - | else if (( | |
130 | + | else if ((S.amount > P)) | |
89 | 131 | then throw("purchase amount cannot be higher than item price") | |
90 | - | else if (( | |
132 | + | else if ((R == a)) | |
91 | 133 | then throw("supplier doesn't exists") | |
92 | - | else WriteSet([DataEntry( | |
134 | + | else WriteSet([DataEntry(x(T, s), (I(T, s) + 1)), DataEntry(v(R), (H(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 = H(R) | |
144 | + | if ((0 >= U)) | |
103 | 145 | then throw("insufficient funds") | |
104 | - | else ScriptResult(WriteSet([DataEntry(p(A), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(A), D, unit)])) | |
146 | + | else ScriptResult(WriteSet([DataEntry(v(R), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(R), U, unit)])) | |
147 | + | } | |
148 | + | ||
149 | + | ||
150 | + | ||
151 | + | @Callable(O) | |
152 | + | func voteCommit (s,V) = { | |
153 | + | let y = toBase58String(O.caller.bytes) | |
154 | + | let W = K(s) | |
155 | + | let X = M(s) | |
156 | + | if ((W == b)) | |
157 | + | then throw("reached max number of voters") | |
158 | + | else if ((J(s, y) != a)) | |
159 | + | then throw("user has participated already") | |
160 | + | else if ((u(s) == a)) | |
161 | + | then throw("item doesn't exists") | |
162 | + | else if (if ((X != a)) | |
163 | + | then (X != d) | |
164 | + | else false) | |
165 | + | then throw("voting is not possible") | |
166 | + | else WriteSet([DataEntry(z(s, y), V), DataEntry(A(s), (W + 1)), DataEntry(C(s), if ((W == (b - 1))) | |
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,q) = ("item_" + toBase58String(sha256(toBytes((p + q))))) | |
35 | 47 | ||
36 | 48 | ||
37 | - | func | |
49 | + | func r (s) = (s + "_price") | |
38 | 50 | ||
39 | 51 | ||
40 | - | func | |
52 | + | func t (s) = (s + "_data") | |
41 | 53 | ||
42 | 54 | ||
43 | - | func | |
55 | + | func u (s) = (s + "_owner") | |
44 | 56 | ||
45 | 57 | ||
46 | - | func | |
58 | + | func v (w) = (w + "_balance") | |
47 | 59 | ||
48 | 60 | ||
49 | - | func | |
61 | + | func x (y,s) = (((s + "_") + y) + "_cnt") | |
50 | 62 | ||
51 | 63 | ||
52 | - | func | |
64 | + | func z (s,y) = (((s + "_") + y) + "_commit") | |
53 | 65 | ||
54 | 66 | ||
55 | - | func | |
67 | + | func A (s) = (s + "_comcnt") | |
56 | 68 | ||
57 | 69 | ||
58 | - | func | |
70 | + | func B (s,y) = (((s + "_") + y) + "_reveal") | |
59 | 71 | ||
60 | 72 | ||
61 | - | func | |
73 | + | func C (s) = (s + "_status") | |
62 | 74 | ||
63 | 75 | ||
64 | - | @Callable(x) | |
65 | - | func addItem (k,y,z) = { | |
66 | - | let A = toBase58String(x.caller.bytes) | |
67 | - | let m = i(A, k) | |
68 | - | if ((0 >= y)) | |
76 | + | func D (s,E) = ((s + "_res:") + E) | |
77 | + | ||
78 | + | ||
79 | + | func F (s) = h(r(s)) | |
80 | + | ||
81 | + | ||
82 | + | func G (s) = m(u(s)) | |
83 | + | ||
84 | + | ||
85 | + | func H (w) = h(v(w)) | |
86 | + | ||
87 | + | ||
88 | + | func I (y,s) = h(x(y, s)) | |
89 | + | ||
90 | + | ||
91 | + | func J (s,y) = m(z(s, y)) | |
92 | + | ||
93 | + | ||
94 | + | func K (s) = h(A(s)) | |
95 | + | ||
96 | + | ||
97 | + | func L (s,y) = m(B(s, y)) | |
98 | + | ||
99 | + | ||
100 | + | func M (s) = m(C(s)) | |
101 | + | ||
102 | + | ||
103 | + | func N (s,E) = h(D(s, E)) | |
104 | + | ||
105 | + | ||
106 | + | @Callable(O) | |
107 | + | func addItem (q,P,Q) = { | |
108 | + | let R = toBase58String(O.caller.bytes) | |
109 | + | let s = o(R, q) | |
110 | + | if ((0 >= P)) | |
69 | 111 | then throw("Purchase amount cannot be less than or equal 0") | |
70 | - | else if (( | |
112 | + | else if ((G(s) != a)) | |
71 | 113 | then throw("Item exists already") | |
72 | - | else WriteSet([DataEntry( | |
114 | + | else WriteSet([DataEntry(u(s), R), DataEntry(r(s), P), DataEntry(t(s), Q)]) | |
73 | 115 | } | |
74 | 116 | ||
75 | 117 | ||
76 | 118 | ||
77 | - | @Callable( | |
78 | - | func purchase ( | |
79 | - | let | |
80 | - | if (isDefined( | |
119 | + | @Callable(O) | |
120 | + | func purchase (s) = { | |
121 | + | let S = extract(O.payment) | |
122 | + | if (isDefined(S.assetId)) | |
81 | 123 | then throw("WAVES 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 = F(s) | |
127 | + | let R = G(s) | |
128 | + | if ((P > S.amount)) | |
87 | 129 | then throw("purchase amount cannot be less than item price") | |
88 | - | else if (( | |
130 | + | else if ((S.amount > P)) | |
89 | 131 | then throw("purchase amount cannot be higher than item price") | |
90 | - | else if (( | |
132 | + | else if ((R == a)) | |
91 | 133 | then throw("supplier doesn't exists") | |
92 | - | else WriteSet([DataEntry( | |
134 | + | else WriteSet([DataEntry(x(T, s), (I(T, s) + 1)), DataEntry(v(R), (H(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 = H(R) | |
144 | + | if ((0 >= U)) | |
103 | 145 | then throw("insufficient funds") | |
104 | - | else ScriptResult(WriteSet([DataEntry(p(A), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(A), D, unit)])) | |
146 | + | else ScriptResult(WriteSet([DataEntry(v(R), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(R), U, unit)])) | |
147 | + | } | |
148 | + | ||
149 | + | ||
150 | + | ||
151 | + | @Callable(O) | |
152 | + | func voteCommit (s,V) = { | |
153 | + | let y = toBase58String(O.caller.bytes) | |
154 | + | let W = K(s) | |
155 | + | let X = M(s) | |
156 | + | if ((W == b)) | |
157 | + | then throw("reached max number of voters") | |
158 | + | else if ((J(s, y) != a)) | |
159 | + | then throw("user has participated already") | |
160 | + | else if ((u(s) == a)) | |
161 | + | then throw("item doesn't exists") | |
162 | + | else if (if ((X != a)) | |
163 | + | then (X != d) | |
164 | + | else false) | |
165 | + | then throw("voting is not possible") | |
166 | + | else WriteSet([DataEntry(z(s, y), V), DataEntry(A(s), (W + 1)), DataEntry(C(s), if ((W == (b - 1))) | |
167 | + | then e | |
168 | + | else d)]) | |
105 | 169 | } | |
106 | 170 | ||
107 | 171 |
github/deemru/w8io/026f985 52.01 ms ◑