tx · 8jmkyYve2ey2uqgxv62N2sSstm4jUoBKbW8Pthdjgeqd

3MtTheYx7F8GojnQXdBq5njwKSWwWDR8Yx3:  -0.01400000 Waves

2020.11.23 12:40 [1277863] smart account 3MtTheYx7F8GojnQXdBq5njwKSWwWDR8Yx3 > SELF 0.00000000 Waves

{ "type": 13, "id": "8jmkyYve2ey2uqgxv62N2sSstm4jUoBKbW8Pthdjgeqd", "fee": 1400000, "feeAssetId": null, "timestamp": 1606124418281, "version": 2, "chainId": 84, "sender": "3MtTheYx7F8GojnQXdBq5njwKSWwWDR8Yx3", "senderPublicKey": "24o2mnMP6y64dijDFoZKhDpV73e1gCFKxQcZ6X9q3z1B", "proofs": [ "4DNZQ5AchL54kKqP4xG2NZSXeVxGx8GYFWjo7oHg3yyPQUrJHkp51dmEYbnDD8E57FuAb85fiHwKe1a3bhER1BEH" ], "script": "base64:AAIEAAAAAAAAABYIAhIDCgEIEgUKAwgBCBIAEgQKAggIAAAAIAAAAAARYWNjb3VudDFQdWJsaWNLZXkBAAAAIPeNeDDs4TWVhR1bzOk94lFsHOraL9B/FRj0XfVMj0hOAAAAABFhY2NvdW50MlB1YmxpY0tleQEAAAAgG1e/aEwKrtMkcq9WyiLLAHtKPJgLd/oAoUXcKuUDIhUAAAAADm90aGVyUHVibGljS2V5AQAAACDnblGJprjxGAm9jEz8V5M0TOEG6bhNvbMQquBNrx0dWgAAAAAETk9ORQIAAAAEbm9uZQAAAAAGVk9URVJTAAAAAAAAAAADAAAAAAZRVU9SVU0AAAAAAAAAAAIAAAAABlZPVElORwIAAAAGdm90aW5nAAAAAAZSRVZFQUwCAAAABnJldmVhbAAAAAAIRkVBVFVSRUQCAAAACGZlYXR1cmVkAAAAAAhERUxJU1RFRAIAAAAIZGVsaXN0ZWQBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAA251bQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRt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PVElORwUAAAADbmlsAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAZnX9N8", "height": 1277863, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 55hNEsKebyqGS8vCw8oeiuQCqf4PRUB5yBvh7WwQxZQG Next: 7XpYiUDLYrdNCBVLJUF7udpMq3jKJdEvvmjxfhmrCnRv Diff:
OldNewDifferences
88 let otherPublicKey = base58'GaQkBG6yLLAarb8wvPrEKnQhFqWomD2ZGT1T4vVx24qw'
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) {
6173 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
6274
6375
76+func getKeyCommit (item,user) = (((item + "_") + user) + "_commit")
77+
78+
79+func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user))
80+
81+
82+func getKeyCommitsCount (item) = (item + "_comcnt")
83+
84+
85+func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item))
86+
87+
88+func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal")
89+
90+
91+func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user))
92+
93+
94+func getKeyItemStatus (item) = (item + "_status")
95+
96+
97+func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item))
98+
99+
100+func getKeyVoteCount (item,vote) = ((item + "_res:") + vote)
101+
102+
103+func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote))
104+
105+
64106 @Callable(i)
65107 func purchase (item) = {
66108 let pmt = value(i.payments)
107149 }
108150
109151
152+
153+@Callable(i)
154+func voteCommit (item,hash) = {
155+ let user = toBase58String(i.caller.bytes)
156+ let commits = getValueCommitsCount(item)
157+ let status = getValueItemStatus(item)
158+ if ((commits >= VOTERS))
159+ then throw("reached max num of voters")
160+ else if ((getValueCommit(item, user) != NONE))
161+ then throw("user has already participated")
162+ else if ((getKeyItemSupplier(item) == NONE))
163+ then throw("item does not exist")
164+ else if (if ((status != NONE))
165+ then (status != VOTING)
166+ else false)
167+ then throw("voting is not possible")
168+ else [StringEntry(getKeyCommit(item, user), hash), IntegerEntry(getKeyCommitsCount(item), (commits + 1)), StringEntry(getKeyItemStatus(item), if ((commits == VOTERS))
169+ then REVEAL
170+ else VOTING)]
171+ }
172+
173+
110174 @Verifier(tx)
111175 func verify () = true
112176
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let account1PublicKey = base58'HfLpRhXtnuCabRyNT6z7soaXcbUpwLUhjyBCVQ4szwzd'
55
66 let account2PublicKey = base58'2qjcWuL7QitmuhkSTM7CnNxurCYXuqJ9ubswLBGmXfDv'
77
88 let otherPublicKey = base58'GaQkBG6yLLAarb8wvPrEKnQhFqWomD2ZGT1T4vVx24qw'
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 }
3244
3345
3446 func getKeyItemPrice (item) = (item + "_price")
3547
3648
3749 func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
3850
3951
4052 func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
4153
4254
4355 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
4456
4557
4658 func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
4759
4860
4961 func getKeyItemData (item) = (item + "_data")
5062
5163
5264 func getKeyItemSupplier (item) = (item + "_owner")
5365
5466
5567 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
5668
5769
5870 func getKeyBalanceSupplier (account) = (account + "_balance")
5971
6072
6173 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
6274
6375
76+func getKeyCommit (item,user) = (((item + "_") + user) + "_commit")
77+
78+
79+func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user))
80+
81+
82+func getKeyCommitsCount (item) = (item + "_comcnt")
83+
84+
85+func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item))
86+
87+
88+func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal")
89+
90+
91+func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user))
92+
93+
94+func getKeyItemStatus (item) = (item + "_status")
95+
96+
97+func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item))
98+
99+
100+func getKeyVoteCount (item,vote) = ((item + "_res:") + vote)
101+
102+
103+func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote))
104+
105+
64106 @Callable(i)
65107 func purchase (item) = {
66108 let pmt = value(i.payments)
67109 if (isDefined(pmt[0].assetId))
68110 then throw("WAVES tokens only")
69111 else {
70112 let userAddress = toBase58String(i.caller.bytes)
71113 let price = getValueItemPrice(item)
72114 let supplierAddress = getValueItemSupplier(item)
73115 if ((price > pmt[0].amount))
74116 then throw("purchase less than item price")
75117 else if ((pmt[0].amount > price))
76118 then throw("purchase amount higher than item price")
77119 else if ((size(pmt) > 1))
78120 then throw("single item only")
79121 else if ((supplierAddress == NONE))
80122 then throw("supplier doesn't exist")
81123 else [IntegerEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), IntegerEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt[0].amount))]
82124 }
83125 }
84126
85127
86128
87129 @Callable(i)
88130 func addItem (title,price,data) = {
89131 let supplierAddress = toBase58String(i.caller.bytes)
90132 let item = getKeyItem(supplierAddress, title)
91133 if ((0 >= price))
92134 then throw("purchase amount cannot be less than item price")
93135 else if ((getValueItemSupplier(item) != NONE))
94136 then throw("an item already exist")
95137 else [StringEntry(getKeyItemSupplier(item), supplierAddress), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data)]
96138 }
97139
98140
99141
100142 @Callable(i)
101143 func withdraw () = {
102144 let supplierAddress = toBase58String(i.caller.bytes)
103145 let balance = getValueBalanceSupplier(supplierAddress)
104146 if ((0 >= balance))
105147 then throw("insufficient balance")
106148 else [IntegerEntry(getKeyBalanceSupplier(supplierAddress), 0), ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]
107149 }
108150
109151
152+
153+@Callable(i)
154+func voteCommit (item,hash) = {
155+ let user = toBase58String(i.caller.bytes)
156+ let commits = getValueCommitsCount(item)
157+ let status = getValueItemStatus(item)
158+ if ((commits >= VOTERS))
159+ then throw("reached max num of voters")
160+ else if ((getValueCommit(item, user) != NONE))
161+ then throw("user has already participated")
162+ else if ((getKeyItemSupplier(item) == NONE))
163+ then throw("item does not exist")
164+ else if (if ((status != NONE))
165+ then (status != VOTING)
166+ else false)
167+ then throw("voting is not possible")
168+ else [StringEntry(getKeyCommit(item, user), hash), IntegerEntry(getKeyCommitsCount(item), (commits + 1)), StringEntry(getKeyItemStatus(item), if ((commits == VOTERS))
169+ then REVEAL
170+ else VOTING)]
171+ }
172+
173+
110174 @Verifier(tx)
111175 func verify () = true
112176

github/deemru/w8io/169f3d6 
29.80 ms