tx · FbSw7a8c85bkSpU2acvUEje6n1Q7PTAko4mK8j64e3LS

3MzvMg5dRiLMVdHJ3v4AfeCXttmaSPHdoVN:  -0.01400000 Waves

2019.11.21 21:23 [775324] smart account 3MzvMg5dRiLMVdHJ3v4AfeCXttmaSPHdoVN > SELF 0.00000000 Waves

{ "type": 13, "id": "FbSw7a8c85bkSpU2acvUEje6n1Q7PTAko4mK8j64e3LS", "fee": 1400000, "feeAssetId": null, "timestamp": 1574360725942, "version": 1, "sender": "3MzvMg5dRiLMVdHJ3v4AfeCXttmaSPHdoVN", "senderPublicKey": "GvoCzLxrhCgZzNLksqhf43ehht8jTASRqtGBmXaNn7Jq", "proofs": [ "Rth9wE1sKruboJ29r5NgZL1vuNwaj3L7eZpA43To9JAvtvu5vu3Bu5ZLyVciAg2NH9uTiZDP6on1G7Q5E1CYzjx" ], "script": "base64:AAIDAAAAAAAAABgIARIAEgUKAwgBCBIDCgEIEgASBAoCCAgAAAAdAAAAAAROT05FAgAAAARub25lAAAAAAZWT1RFUlMAAAAAAAAAAAMAAAAABlFVT1JVTQAAAAAAAAAAAgAAAAAGVk9USU5HAgAAAAZ2b3RpbmcAAAAABlJFVkVBTAIAAAAGcmV2ZWFsAAAAAAhGRUFUVVJFRAIAAAAIZmVhdHVyZWQAAAAACERFTElTVEVEAgAAAAhkZWxpc3RlZAEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAAAC2dldFN0ckJ5S2V5AAAAAQAAAANrZXkEAAAAA3N0cgQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAAHJG1h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AAAAAAAACCQEAAAASZ2V0S2V5SXRlbVN1cHBsaWVyAAAAAQUAAAAEaXRlbQUAAAAETk9ORQkAAAIAAAABAgAAABNpdGVtIGRvZXMgbm90IGV4aXN0AwMJAQAAAAIhPQAAAAIFAAAABnN0YXR1cwUAAAAETk9ORQkBAAAAAiE9AAAAAgUAAAAGc3RhdHVzBQAAAAZWT1RJTkcHCQAAAgAAAAECAAAAFnZvdGluZyBpcyBub3QgcG9zc2libGUJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAAAxnZXRLZXlDb21taXQAAAACBQAAAARpdGVtBQAAAAR1c2VyBQAAAARoYXNoCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAASZ2V0S2V5Q29tbWl0c0NvdW50AAAAAQUAAAAEaXRlbQkAAGQAAAACBQAAAAdjb21taXRzAAAAAAAAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAQZ2V0S2V5SXRlbVN0YXR1cwAAAAEFAAAABGl0ZW0DCQAAAAAAAAIFAAAAB2NvbW1pdHMFAAAABlZPVEVSUwUAAAAGUkVWRUFMBQAAAAZWT1RJTkcFAAAAA25pbAAAAADpTc1H", "chainId": 84, "height": 775324, "spentComplexity": 0 } View: original | compacted Prev: 7hFmwEj7tsA1GPPDmqEX7hzjYL2U2T7T2acC183P1CJT Next: EKkLaXjqXfijMYr5NBHC41KL5X58M2BwVYPCGJFgKuRC Diff:
OldNewDifferences
136136
137137
138138 @Callable(O)
139-func withdraw (U) = {
140- let Q = toBase58String(O.caller.bytes)
141- let R = {
142- let k = getInteger(this, Q)
143- if ($isInstanceOf(k, "Int"))
144- then {
145- let l = k
146- l
147- }
148- else 0
149- }
150- let T = (R - U)
151- if ((0 > U))
152- then throw("Can't withdraw negative amount")
153- else if ((0 > T))
154- then throw("Not enough balance")
155- else ScriptResult(WriteSet([DataEntry(Q, T)]), TransferSet([ScriptTransfer(O.caller, U, unit)]))
156- }
157-
158-
159-
160-@Callable(O)
161-func addItem (w,V,W) = {
162- let X = toBase58String(O.caller.bytes)
163- let p = u(X, w)
164- if ((0 >= V))
139+func addItem (w,U,V) = {
140+ let W = toBase58String(O.caller.bytes)
141+ let p = u(W, w)
142+ if ((0 >= U))
165143 then throw("purchase amount cannot be less than item price")
166144 else if ((z(p) != a))
167145 then throw("an item is already exist")
168- else WriteSet([DataEntry(y(p), X), DataEntry(o(p), V), DataEntry(x(p), W)])
146+ else WriteSet([DataEntry(y(p), W), DataEntry(o(p), U), DataEntry(x(p), V)])
169147 }
170148
171149
176154 if (isDefined(P.assetId))
177155 then throw("WAVES tokens only at the moment")
178156 else {
179- let Y = toBase58String(O.caller.bytes)
180- let V = q(p)
181- let X = z(p)
182- if ((V > P.amount))
157+ let X = toBase58String(O.caller.bytes)
158+ let U = q(p)
159+ let W = z(p)
160+ if ((U > P.amount))
183161 then throw("purchase amount cannot be less than item price")
184- else if ((P.amount > V))
162+ else if ((P.amount > U))
185163 then throw("purchase amount cannot be higher than item price")
186- else if ((X == a))
164+ else if ((W == a))
187165 then throw("supplier does not exist")
188- else WriteSet([DataEntry(r(Y, p), (t(Y, p) + 1)), DataEntry(A(X), (C(X) + P.amount))])
166+ else WriteSet([DataEntry(r(X, p), (t(X, p) + 1)), DataEntry(A(W), (C(W) + P.amount))])
189167 }
168+ }
169+
170+
171+
172+@Callable(O)
173+func withdraw () = {
174+ let W = toBase58String(O.caller.bytes)
175+ let Y = C(W)
176+ if ((0 >= Y))
177+ then throw("insufficient balbance")
178+ else ScriptResult(WriteSet([DataEntry(A(W), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(W), Y, unit)]))
190179 }
191180
192181
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let a = "none"
55
66 let b = 3
77
88 let c = 2
99
1010 let d = "voting"
1111
1212 let e = "reveal"
1313
1414 let f = "featured"
1515
1616 let g = "delisted"
1717
1818 func h (i) = {
1919 let j = {
2020 let k = getInteger(this, i)
2121 if ($isInstanceOf(k, "Int"))
2222 then {
2323 let l = k
2424 l
2525 }
2626 else 0
2727 }
2828 j
2929 }
3030
3131
3232 func m (i) = {
3333 let n = {
3434 let k = getString(this, i)
3535 if ($isInstanceOf(k, "String"))
3636 then {
3737 let l = k
3838 l
3939 }
4040 else a
4141 }
4242 n
4343 }
4444
4545
4646 func o (p) = (p + "_price")
4747
4848
4949 func q (p) = h(o(p))
5050
5151
5252 func r (s,p) = (((p + "_") + s) + "_cnt")
5353
5454
5555 func t (s,p) = h(r(s, p))
5656
5757
5858 func u (v,w) = ("item_" + toBase58String(sha256(toBytes((v + w)))))
5959
6060
6161 func x (p) = (p + "_data")
6262
6363
6464 func y (p) = (p + "_owner")
6565
6666
6767 func z (p) = m(y(p))
6868
6969
7070 func A (B) = (B + "_balance")
7171
7272
7373 func C (B) = h(A(B))
7474
7575
7676 func D (p,s) = (((p + "_") + s) + "_commit")
7777
7878
7979 func E (p,s) = m(D(p, s))
8080
8181
8282 func F (p) = (p + "_comctn")
8383
8484
8585 func G (p) = h(F(p))
8686
8787
8888 func H (p,s) = (((p + "_") + s) + "_reveal")
8989
9090
9191 func I (p,s) = m(H(p, s))
9292
9393
9494 func J (p) = (p + "_status")
9595
9696
9797 func K (p) = m(J(p))
9898
9999
100100 func L (p,M) = ((p + "_res:") + M)
101101
102102
103103 func N (p,M) = h(L(p, M))
104104
105105
106106 @Callable(O)
107107 func deposit () = {
108108 let P = extract(O.payment)
109109 if (isDefined(P.assetId))
110110 then throw("can hold waves only at the moment")
111111 else {
112112 let Q = toBase58String(O.caller.bytes)
113113 let R = {
114114 let k = getInteger(this, Q)
115115 if ($isInstanceOf(k, "Int"))
116116 then {
117117 let l = k
118118 l
119119 }
120120 else 0
121121 }
122122 let S = {
123123 let k = getString(this, ("wl_sts_" + Q))
124124 if ($isInstanceOf(k, "String"))
125125 then {
126126 let l = k
127127 l
128128 }
129129 else throw("User has not been whitelisted")
130130 }
131131 let T = (R + P.amount)
132132 WriteSet([DataEntry(Q, T)])
133133 }
134134 }
135135
136136
137137
138138 @Callable(O)
139-func withdraw (U) = {
140- let Q = toBase58String(O.caller.bytes)
141- let R = {
142- let k = getInteger(this, Q)
143- if ($isInstanceOf(k, "Int"))
144- then {
145- let l = k
146- l
147- }
148- else 0
149- }
150- let T = (R - U)
151- if ((0 > U))
152- then throw("Can't withdraw negative amount")
153- else if ((0 > T))
154- then throw("Not enough balance")
155- else ScriptResult(WriteSet([DataEntry(Q, T)]), TransferSet([ScriptTransfer(O.caller, U, unit)]))
156- }
157-
158-
159-
160-@Callable(O)
161-func addItem (w,V,W) = {
162- let X = toBase58String(O.caller.bytes)
163- let p = u(X, w)
164- if ((0 >= V))
139+func addItem (w,U,V) = {
140+ let W = toBase58String(O.caller.bytes)
141+ let p = u(W, w)
142+ if ((0 >= U))
165143 then throw("purchase amount cannot be less than item price")
166144 else if ((z(p) != a))
167145 then throw("an item is already exist")
168- else WriteSet([DataEntry(y(p), X), DataEntry(o(p), V), DataEntry(x(p), W)])
146+ else WriteSet([DataEntry(y(p), W), DataEntry(o(p), U), DataEntry(x(p), V)])
169147 }
170148
171149
172150
173151 @Callable(O)
174152 func purchase (p) = {
175153 let P = extract(O.payment)
176154 if (isDefined(P.assetId))
177155 then throw("WAVES tokens only at the moment")
178156 else {
179- let Y = toBase58String(O.caller.bytes)
180- let V = q(p)
181- let X = z(p)
182- if ((V > P.amount))
157+ let X = toBase58String(O.caller.bytes)
158+ let U = q(p)
159+ let W = z(p)
160+ if ((U > P.amount))
183161 then throw("purchase amount cannot be less than item price")
184- else if ((P.amount > V))
162+ else if ((P.amount > U))
185163 then throw("purchase amount cannot be higher than item price")
186- else if ((X == a))
164+ else if ((W == a))
187165 then throw("supplier does not exist")
188- else WriteSet([DataEntry(r(Y, p), (t(Y, p) + 1)), DataEntry(A(X), (C(X) + P.amount))])
166+ else WriteSet([DataEntry(r(X, p), (t(X, p) + 1)), DataEntry(A(W), (C(W) + P.amount))])
189167 }
168+ }
169+
170+
171+
172+@Callable(O)
173+func withdraw () = {
174+ let W = toBase58String(O.caller.bytes)
175+ let Y = C(W)
176+ if ((0 >= Y))
177+ then throw("insufficient balbance")
178+ else ScriptResult(WriteSet([DataEntry(A(W), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(W), Y, unit)]))
190179 }
191180
192181
193182
194183 @Callable(O)
195184 func voteCommit (p,Z) = {
196185 let s = toBase58String(O.caller.bytes)
197186 let aa = G(p)
198187 let ab = K(p)
199188 if ((aa >= b))
200189 then throw("reached max num of voters")
201190 else if ((E(p, s) != a))
202191 then throw("user has already participated")
203192 else if ((y(p) == a))
204193 then throw("item does not exist")
205194 else if (if ((ab != a))
206195 then (ab != d)
207196 else false)
208197 then throw("voting is not possible")
209198 else WriteSet([DataEntry(D(p, s), Z), DataEntry(F(p), (aa + 1)), DataEntry(J(p), if ((aa == b))
210199 then e
211200 else d)])
212201 }
213202
214203

github/deemru/w8io/169f3d6 
51.04 ms