tx · 9DQntgwT3Hrh8LNV6uVE6X8pKLqedSgzsjwr3c2tSqN3

3MtELerncMfYVZvRuEeMvgvsj7jUnshXWuw:  -0.01400000 Waves

2019.11.02 22:15 [747651] smart account 3MtELerncMfYVZvRuEeMvgvsj7jUnshXWuw > SELF 0.00000000 Waves

{ "type": 13, "id": "9DQntgwT3Hrh8LNV6uVE6X8pKLqedSgzsjwr3c2tSqN3", "fee": 1400000, "feeAssetId": null, "timestamp": 1572722087234, "version": 1, "sender": "3MtELerncMfYVZvRuEeMvgvsj7jUnshXWuw", "senderPublicKey": "FXsc9LG44fGFsWEUFctaZ8pr75ZoWQuPc75fhhG6CQb7", "proofs": [ "4oKGfmwABFb1SadK5HkvxvRuuGcbR8idvzzJ25h2JMPHD26QEF8Krc1WYwua3qS5YShcVse5tnsTYP5G9J1FaBBE" ], "script": "base64:AAIDAAAAAAAAABYIARIDCgEIEgUKAwgBCBIAEgQKAggIAAAAIAAAAAALYWxpY2VQdWJLZXkBAAAAINfsQvR9fqXlDzGc04eGbOwG0sh9xqqQFwH/8Axi/ldeAAAAAAlib2JQdWJLZXkBAAAAIOwSkxfPNRumLYV/QyOtvoP1Xrqg0wLIbWQvZrWRxCZVAAAAAAxjb29wZXJQdWJLZXkBAAAAIIBJjl+IC6h/Eyp/ki/D97TEbqOcKJDZv13sTNCgJKkiAAAAAAROT05FAgAAAARub25lAAAAAAZWT1RFUlMAAAAAAAAAAAMAAAAABlFVT1JVTQAAAAAAAAAAAgAAAAAGVk9USU5HAgAAAAZ2b3RpbmcAAAAABlJFVkVBTAIAAAAGcmV2ZWFsAAAAAAhGRUFUVVJFRAIAAAAIZmVhdHVyZWQAAAAACERFTElTVEVEAgAAAAhkZWxpc3RlZAEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAA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FqhUuj5UZ1MjKU52 Diff:
OldNewDifferences
88 let cooperPubKey = base58'9dnEr8G5eVHGJ5LkzueoK512pE3XBYBpe2ReLVcsrawT'
99
1010 let NONE = "none"
11+
12+let VOTERS = 3
13+
14+let QUORUM = 2
15+
16+let VOTING = "voting"
17+
18+let REVEAL = "reveal"
19+
20+let FEATURED = "featured"
21+
22+let DELISTED = "delisted"
1123
1224 func getNumberByKey (key) = {
1325 let num = match getInteger(this, key) {
2941 }
3042 str
3143 }
44+
45+
46+func getKeyCommit (item,user) = (((item + "_") + user) + "_commit")
47+
48+
49+func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user))
50+
51+
52+func getKeyCommitsCount (item) = (item + "_comcnt")
53+
54+
55+func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item))
56+
57+
58+func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal")
59+
60+
61+func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user))
62+
63+
64+func getKeyItemStatus (item) = (item + "_status")
65+
66+
67+func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item))
68+
69+
70+func getKeyVoteCount (item,vote) = ((item + "_res:") + vote)
71+
72+
73+func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote))
3274
3375
3476 func getKeyItemPrice (item) = (item + "_price")
102144 if ((0 >= balance))
103145 then throw("insufficient balance")
104146 else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]))
147+ }
148+
149+
150+
151+@Callable(i)
152+func voteCommit (item,hash) = {
153+ let user = toBase58String(i.caller.bytes)
154+ let commits = getValueCommitsCount(item)
155+ let status = getValueItemStatus(item)
156+ if ((commits >= VOTERS))
157+ then throw("Reached max number of voters")
158+ else if ((getValueCommit(item, user) != NONE))
159+ then throw("User has aready participated")
160+ else if ((getKeyItemSupplier(item) == NONE))
161+ then throw("Item does not exist")
162+ else if (if ((status != NONE))
163+ then (status != VOTING)
164+ else false)
165+ then throw("Voting is not possible")
166+ else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if ((commits == VOTERS))
167+ then REVEAL
168+ else VOTING)])
105169 }
106170
107171
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let alicePubKey = base58'FXsc9LG44fGFsWEUFctaZ8pr75ZoWQuPc75fhhG6CQb7'
55
66 let bobPubKey = base58'GtXeMqkP3JUjRf7EDptgqdEu5wkrkG4d2sbfUi5hYQVi'
77
88 let cooperPubKey = base58'9dnEr8G5eVHGJ5LkzueoK512pE3XBYBpe2ReLVcsrawT'
99
1010 let NONE = "none"
11+
12+let VOTERS = 3
13+
14+let QUORUM = 2
15+
16+let VOTING = "voting"
17+
18+let REVEAL = "reveal"
19+
20+let FEATURED = "featured"
21+
22+let DELISTED = "delisted"
1123
1224 func getNumberByKey (key) = {
1325 let num = match getInteger(this, key) {
1426 case a: Int =>
1527 a
1628 case _ =>
1729 0
1830 }
1931 num
2032 }
2133
2234
2335 func getStrByKey (key) = {
2436 let str = match getString(this, key) {
2537 case a: String =>
2638 a
2739 case _ =>
2840 NONE
2941 }
3042 str
3143 }
44+
45+
46+func getKeyCommit (item,user) = (((item + "_") + user) + "_commit")
47+
48+
49+func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user))
50+
51+
52+func getKeyCommitsCount (item) = (item + "_comcnt")
53+
54+
55+func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item))
56+
57+
58+func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal")
59+
60+
61+func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user))
62+
63+
64+func getKeyItemStatus (item) = (item + "_status")
65+
66+
67+func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item))
68+
69+
70+func getKeyVoteCount (item,vote) = ((item + "_res:") + vote)
71+
72+
73+func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote))
3274
3375
3476 func getKeyItemPrice (item) = (item + "_price")
3577
3678
3779 func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
3880
3981
4082 func getKeyUserItemCounter (user,item) = (((item + "user") + user) + "_cnt")
4183
4284
4385 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
4486
4587
4688 func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
4789
4890
4991 func getKeyItemData (item) = (item + "_data")
5092
5193
5294 func getKeyItemSupplier (item) = (item + "_owner")
5395
5496
5597 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
5698
5799
58100 func getKeyBalanceSupplier (account) = (account + "_balance")
59101
60102
61103 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
62104
63105
64106 @Callable(i)
65107 func purchase (item) = {
66108 let pmt = extract(i.payment)
67109 if (isDefined(pmt.assetId))
68110 then throw("Can use WAVES only at the moment")
69111 else {
70112 let customerAddress = toBase58String(i.caller.bytes)
71113 let price = getValueItemPrice(item)
72114 let supplierAddress = getValueItemSupplier(item)
73115 if ((price > pmt.amount))
74116 then throw("Purchase amount can not be less than item price")
75117 else if ((pmt.amount > price))
76118 then throw("Purchase amount can not be more than item price")
77119 else if ((supplierAddress == NONE))
78120 then throw("Supplier does not exist")
79121 else WriteSet([DataEntry(getKeyUserItemCounter(customerAddress, item), (getValueUserItemCounter(customerAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))])
80122 }
81123 }
82124
83125
84126
85127 @Callable(i)
86128 func addItem (title,price,data) = {
87129 let supplierAddress = toBase58String(i.caller.bytes)
88130 let item = getKeyItem(supplierAddress, title)
89131 if ((0 >= price))
90132 then throw("purchase amount can not be less than item price")
91133 else if ((getValueItemSupplier(item) != NONE))
92134 then throw("An item is already")
93135 else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
94136 }
95137
96138
97139
98140 @Callable(i)
99141 func withdraw () = {
100142 let supplierAddress = toBase58String(i.caller.bytes)
101143 let balance = getValueBalanceSupplier(supplierAddress)
102144 if ((0 >= balance))
103145 then throw("insufficient balance")
104146 else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]))
147+ }
148+
149+
150+
151+@Callable(i)
152+func voteCommit (item,hash) = {
153+ let user = toBase58String(i.caller.bytes)
154+ let commits = getValueCommitsCount(item)
155+ let status = getValueItemStatus(item)
156+ if ((commits >= VOTERS))
157+ then throw("Reached max number of voters")
158+ else if ((getValueCommit(item, user) != NONE))
159+ then throw("User has aready participated")
160+ else if ((getKeyItemSupplier(item) == NONE))
161+ then throw("Item does not exist")
162+ else if (if ((status != NONE))
163+ then (status != VOTING)
164+ else false)
165+ then throw("Voting is not possible")
166+ else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if ((commits == VOTERS))
167+ then REVEAL
168+ else VOTING)])
105169 }
106170
107171
108172 @Verifier(tx)
109173 func verify () = {
110174 let Alice1 = sigVerify(tx.bodyBytes, tx.proofs[0], alicePubKey)
111175 let Alice2 = sigVerify(tx.bodyBytes, tx.proofs[1], alicePubKey)
112176 let Alice3 = sigVerify(tx.bodyBytes, tx.proofs[2], alicePubKey)
113177 let Bob1 = sigVerify(tx.bodyBytes, tx.proofs[0], bobPubKey)
114178 let Bob2 = sigVerify(tx.bodyBytes, tx.proofs[1], bobPubKey)
115179 let Bob3 = sigVerify(tx.bodyBytes, tx.proofs[2], bobPubKey)
116180 let Cooper1 = sigVerify(tx.bodyBytes, tx.proofs[0], cooperPubKey)
117181 let Cooper2 = sigVerify(tx.bodyBytes, tx.proofs[1], cooperPubKey)
118182 let Cooper3 = sigVerify(tx.bodyBytes, tx.proofs[2], cooperPubKey)
119183 let AliceAndBob = if (if (if (if (if (if (Alice1)
120184 then Bob2
121185 else false)
122186 then true
123187 else if (Alice1)
124188 then Bob3
125189 else false)
126190 then true
127191 else if (Alice2)
128192 then Bob1
129193 else false)
130194 then true
131195 else if (Alice2)
132196 then Bob3
133197 else false)
134198 then true
135199 else if (Alice3)
136200 then Bob1
137201 else false)
138202 then true
139203 else if (Alice3)
140204 then Bob2
141205 else false
142206 let AliceAndCooper = if (if (if (if (if (if (Cooper1)
143207 then Alice2
144208 else false)
145209 then true
146210 else if (Cooper1)
147211 then Alice3
148212 else false)
149213 then true
150214 else if (Cooper2)
151215 then Alice1
152216 else false)
153217 then true
154218 else if (Cooper2)
155219 then Alice3
156220 else false)
157221 then true
158222 else if (Cooper3)
159223 then Alice1
160224 else false)
161225 then true
162226 else if (Cooper3)
163227 then Alice2
164228 else false
165229 let BobAndCooper = if (if (if (if (if (if (Bob1)
166230 then Cooper2
167231 else false)
168232 then true
169233 else if (Bob1)
170234 then Cooper3
171235 else false)
172236 then true
173237 else if (Bob2)
174238 then Cooper1
175239 else false)
176240 then true
177241 else if (Bob2)
178242 then Cooper3
179243 else false)
180244 then true
181245 else if (Bob3)
182246 then Cooper1
183247 else false)
184248 then true
185249 else if (Bob3)
186250 then Cooper2
187251 else false
188252 match tx {
189253 case d: SetScriptTransaction =>
190254 true
191255 case _ =>
192256 if (if (AliceAndBob)
193257 then true
194258 else AliceAndCooper)
195259 then true
196260 else BobAndCooper
197261 }
198262 }
199263

github/deemru/w8io/169f3d6 
58.13 ms