tx · FKfSZvKbZ1DuMByKrSahfY7BGgX9Bq74X3XkFNqPdGaB 3MxN6Cszfki941gTcEwXc8ngmbWPTsHoJFq: -0.01400000 Waves 2019.06.22 21:45 [553633] smart account 3MxN6Cszfki941gTcEwXc8ngmbWPTsHoJFq > SELF 0.00000000 Waves
{ "type": 13, "id": "FKfSZvKbZ1DuMByKrSahfY7BGgX9Bq74X3XkFNqPdGaB", "fee": 1400000, "feeAssetId": null, "timestamp": 1561229158987, "version": 1, "sender": "3MxN6Cszfki941gTcEwXc8ngmbWPTsHoJFq", "senderPublicKey": "4fygXNNAjU52sT9N6uq4o9Ck8G75e94ukktN3pd4VxVo", "proofs": [ "5qZ8v5esARSyfPKUWCxMCLCRNNcSwpn2XKe8CoX3TzebC2MVxauYW19mkuJhhr3HMoCkLWWrFapZpUMFgKPfK8WB" ], "script": "base64:AAIDAAAAAAAAAAAAAAAdAAAAAAROT05FAgAAAARub25lAQAAAA9nZXRLZXlJdGVtUHJpY2UAAAABAAAABGl0ZW0JAAEsAAAAAgUAAAAEaXRlbQIAAAAGX3ByaWNlAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAAFWdldEtleVVzZXJJdGVtQ291bnRlcgAAAAIAAAAEdXNlcgAAAARpdGVtCQABLAAAAAIJAAEsAAAAAgkAASwAAAACBQAAAARpdGVtAg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W0FAAAABE5PTkUJAAACAAAAAQIAAAASaXRlbSBkb2Vzbm90IGV4aXN0AwMJAQAAAAIhPQAAAAIFAAAABnN0YXR1cwUAAAAETk9ORQkBAAAAAiE9AAAAAgUAAAAGc3RhdHVzBQAAAAZWb3RpbmcHCQAAAgAAAAECAAAADW5vdCBwb3NzaWxibGUJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAAAxnZXRLZXlDb21taXQAAAACBQAAAARpdGVtBQAAAAR1c2VyBQAAAARoYXNoCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAASZ2V0S2V5Q29tbWl0c0NvdW50AAAAAQUAAAAEaXRlbQkAAGQAAAACBQAAAAdjb21taXRzAAAAAAAAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAQZ2V0S2V5SXRlbVN0YXR1cwAAAAEFAAAABGl0ZW0DCQAAAAAAAAIFAAAAB2NvbW1pdHMFAAAABlZvdGVycwUAAAAGUmV2ZWFsBQAAAAZWb3RpbmcFAAAAA25pbAAAAABJrT0l", "chainId": 84, "height": 553633, "spentComplexity": 0 } View: original | compacted Prev: HeRHzxxTGC5NoPqJLvFtMF9b7mDb9zjEuaZRaw3yGjU6 Next: 42ujvvpHFCiMcy7LXZpHraEq7P2agG58WrsiMxkN77FJ Diff:
Old | New | Differences | |
---|---|---|---|
61 | 61 | func w (v) = d(u(v)) | |
62 | 62 | ||
63 | 63 | ||
64 | - | @Callable(x) | |
65 | - | func additem (q,y,z) = { | |
66 | - | let A = toBase58String(x.caller.bytes) | |
67 | - | let c = 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 (c,l) = (((c + "_") + l) + "_commit") | |
77 | + | ||
78 | + | ||
79 | + | func E (c,l) = i(D(c, l)) | |
80 | + | ||
81 | + | ||
82 | + | func F (c) = (c + "+comcnt") | |
83 | + | ||
84 | + | ||
85 | + | func G (c) = d(F(c)) | |
86 | + | ||
87 | + | ||
88 | + | func H (c,l) = (((c + "_") + l) + "_reveal") | |
89 | + | ||
90 | + | ||
91 | + | func I (c,l) = i(H(c, l)) | |
92 | + | ||
93 | + | ||
94 | + | func J (c) = (c + "_status") | |
95 | + | ||
96 | + | ||
97 | + | func K (c) = i(J(c)) | |
98 | + | ||
99 | + | ||
100 | + | func L (c,M) = ((c + "_res:") + M) | |
101 | + | ||
102 | + | ||
103 | + | func N (c,M) = d(L(c, M)) | |
104 | + | ||
105 | + | ||
106 | + | @Callable(O) | |
107 | + | func additem (q,P,Q) = { | |
108 | + | let R = toBase58String(O.caller.bytes) | |
109 | + | let c = o(R, q) | |
110 | + | if ((0 >= P)) | |
69 | 111 | then throw("purchase amount cannot be less than 0 or 0") | |
70 | 112 | else if ((t(c) != a)) | |
71 | 113 | then throw("an item already exists") | |
72 | - | else WriteSet([DataEntry(s(c), | |
114 | + | else WriteSet([DataEntry(s(c), R), DataEntry(b(c), P), DataEntry(r(c), Q)]) | |
73 | 115 | } | |
74 | 116 | ||
75 | 117 | ||
76 | 118 | ||
77 | - | @Callable( | |
119 | + | @Callable(O) | |
78 | 120 | func purchase (c) = { | |
79 | - | let | |
80 | - | if (isDefined( | |
121 | + | let S = extract(O.payment) | |
122 | + | if (isDefined(S.assetId)) | |
81 | 123 | then throw("Can use 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 = m(c) | |
127 | + | let U = t(c) | |
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 WriteSet([DataEntry(k( | |
132 | + | else WriteSet([DataEntry(k(T, c), (n(T, c) + 1)), DataEntry(u(U), (w(U) + S.amount))]) | |
91 | 133 | } | |
92 | 134 | } | |
93 | 135 | ||
94 | 136 | ||
95 | 137 | ||
96 | - | @Callable( | |
138 | + | @Callable(O) | |
97 | 139 | func withdraw () = { | |
98 | - | let | |
99 | - | let | |
100 | - | if ((0 >= | |
140 | + | let V = toBase58String(O.caller.bytes) | |
141 | + | let W = d("3MqjzNpmZAF3K7W6RRcezbSdWorMAXXwdqo_balance") | |
142 | + | if ((0 >= W)) | |
101 | 143 | then throw("Insufficient Balance xD") | |
102 | - | else ScriptResult(WriteSet([DataEntry(u(E), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(E), F, unit)])) | |
144 | + | else ScriptResult(WriteSet([DataEntry(u(V), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(V), W, unit)])) | |
145 | + | } | |
146 | + | ||
147 | + | ||
148 | + | ||
149 | + | @Callable(O) | |
150 | + | func voteCommit (c,X) = { | |
151 | + | let l = toBase58String(O.caller.bytes) | |
152 | + | let Y = G(c) | |
153 | + | let Z = K(c) | |
154 | + | if ((Y >= x)) | |
155 | + | then throw("Max votes") | |
156 | + | else if ((E(c, l) != a)) | |
157 | + | then throw("already done") | |
158 | + | else if ((s(c) == a)) | |
159 | + | then throw("item doesnot exist") | |
160 | + | else if (if ((Z != a)) | |
161 | + | then (Z != z) | |
162 | + | else false) | |
163 | + | then throw("not possilble") | |
164 | + | else WriteSet([DataEntry(D(c, l), X), DataEntry(F(c), (Y + 1)), DataEntry(J(c), if ((Y == x)) | |
165 | + | then A | |
166 | + | else z)]) | |
103 | 167 | } | |
104 | 168 | ||
105 | 169 |
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) = (c + "_price") | |
7 | 7 | ||
8 | 8 | ||
9 | 9 | func d (e) = { | |
10 | 10 | let f = { | |
11 | 11 | let g = getInteger(this, e) | |
12 | 12 | if ($isInstanceOf(g, "Int")) | |
13 | 13 | then { | |
14 | 14 | let h = g | |
15 | 15 | h | |
16 | 16 | } | |
17 | 17 | else 0 | |
18 | 18 | } | |
19 | 19 | f | |
20 | 20 | } | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | func i (e) = { | |
24 | 24 | let j = { | |
25 | 25 | let g = getString(this, e) | |
26 | 26 | if ($isInstanceOf(g, "String")) | |
27 | 27 | then { | |
28 | 28 | let h = g | |
29 | 29 | h | |
30 | 30 | } | |
31 | 31 | else a | |
32 | 32 | } | |
33 | 33 | j | |
34 | 34 | } | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func k (l,c) = (((c + "_") + l) + "_cnt") | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func m (c) = d(b(c)) | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func n (l,c) = d(k(l, c)) | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func o (p,q) = ("item_" + toBase58String(sha256(toBytes((p + q))))) | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func r (c) = (c + "_data") | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func s (c) = (c + "_owner") | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | func t (c) = i(s(c)) | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | func u (v) = (v + "_balance") | |
59 | 59 | ||
60 | 60 | ||
61 | 61 | func w (v) = d(u(v)) | |
62 | 62 | ||
63 | 63 | ||
64 | - | @Callable(x) | |
65 | - | func additem (q,y,z) = { | |
66 | - | let A = toBase58String(x.caller.bytes) | |
67 | - | let c = 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 (c,l) = (((c + "_") + l) + "_commit") | |
77 | + | ||
78 | + | ||
79 | + | func E (c,l) = i(D(c, l)) | |
80 | + | ||
81 | + | ||
82 | + | func F (c) = (c + "+comcnt") | |
83 | + | ||
84 | + | ||
85 | + | func G (c) = d(F(c)) | |
86 | + | ||
87 | + | ||
88 | + | func H (c,l) = (((c + "_") + l) + "_reveal") | |
89 | + | ||
90 | + | ||
91 | + | func I (c,l) = i(H(c, l)) | |
92 | + | ||
93 | + | ||
94 | + | func J (c) = (c + "_status") | |
95 | + | ||
96 | + | ||
97 | + | func K (c) = i(J(c)) | |
98 | + | ||
99 | + | ||
100 | + | func L (c,M) = ((c + "_res:") + M) | |
101 | + | ||
102 | + | ||
103 | + | func N (c,M) = d(L(c, M)) | |
104 | + | ||
105 | + | ||
106 | + | @Callable(O) | |
107 | + | func additem (q,P,Q) = { | |
108 | + | let R = toBase58String(O.caller.bytes) | |
109 | + | let c = o(R, q) | |
110 | + | if ((0 >= P)) | |
69 | 111 | then throw("purchase amount cannot be less than 0 or 0") | |
70 | 112 | else if ((t(c) != a)) | |
71 | 113 | then throw("an item already exists") | |
72 | - | else WriteSet([DataEntry(s(c), | |
114 | + | else WriteSet([DataEntry(s(c), R), DataEntry(b(c), P), DataEntry(r(c), Q)]) | |
73 | 115 | } | |
74 | 116 | ||
75 | 117 | ||
76 | 118 | ||
77 | - | @Callable( | |
119 | + | @Callable(O) | |
78 | 120 | func purchase (c) = { | |
79 | - | let | |
80 | - | if (isDefined( | |
121 | + | let S = extract(O.payment) | |
122 | + | if (isDefined(S.assetId)) | |
81 | 123 | then throw("Can use 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 = m(c) | |
127 | + | let U = t(c) | |
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 WriteSet([DataEntry(k( | |
132 | + | else WriteSet([DataEntry(k(T, c), (n(T, c) + 1)), DataEntry(u(U), (w(U) + S.amount))]) | |
91 | 133 | } | |
92 | 134 | } | |
93 | 135 | ||
94 | 136 | ||
95 | 137 | ||
96 | - | @Callable( | |
138 | + | @Callable(O) | |
97 | 139 | func withdraw () = { | |
98 | - | let | |
99 | - | let | |
100 | - | if ((0 >= | |
140 | + | let V = toBase58String(O.caller.bytes) | |
141 | + | let W = d("3MqjzNpmZAF3K7W6RRcezbSdWorMAXXwdqo_balance") | |
142 | + | if ((0 >= W)) | |
101 | 143 | then throw("Insufficient Balance xD") | |
102 | - | else ScriptResult(WriteSet([DataEntry(u(E), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(E), F, unit)])) | |
144 | + | else ScriptResult(WriteSet([DataEntry(u(V), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(V), W, unit)])) | |
145 | + | } | |
146 | + | ||
147 | + | ||
148 | + | ||
149 | + | @Callable(O) | |
150 | + | func voteCommit (c,X) = { | |
151 | + | let l = toBase58String(O.caller.bytes) | |
152 | + | let Y = G(c) | |
153 | + | let Z = K(c) | |
154 | + | if ((Y >= x)) | |
155 | + | then throw("Max votes") | |
156 | + | else if ((E(c, l) != a)) | |
157 | + | then throw("already done") | |
158 | + | else if ((s(c) == a)) | |
159 | + | then throw("item doesnot exist") | |
160 | + | else if (if ((Z != a)) | |
161 | + | then (Z != z) | |
162 | + | else false) | |
163 | + | then throw("not possilble") | |
164 | + | else WriteSet([DataEntry(D(c, l), X), DataEntry(F(c), (Y + 1)), DataEntry(J(c), if ((Y == x)) | |
165 | + | then A | |
166 | + | else z)]) | |
103 | 167 | } | |
104 | 168 | ||
105 | 169 |
github/deemru/w8io/026f985 46.89 ms ◑