tx · C61ebeiM7iWGYJUJUebHmLWEMcbNizcbDkpqYELujFpe

3Mzz3QCpMamT89CaFaovqXpnCdiUaKtLZ4D:  -0.01400000 Waves

2019.06.22 18:06 [553411] smart account 3Mzz3QCpMamT89CaFaovqXpnCdiUaKtLZ4D > SELF 0.00000000 Waves

{ "type": 13, "id": "C61ebeiM7iWGYJUJUebHmLWEMcbNizcbDkpqYELujFpe", "fee": 1400000, "feeAssetId": null, "timestamp": 1561216022722, "version": 1, "sender": "3Mzz3QCpMamT89CaFaovqXpnCdiUaKtLZ4D", "senderPublicKey": "BJRaSW2saRv7CcFs3mSYpaVFQSFpZq9rGKnCcRKuKgWv", "proofs": [ "43TwVeb3tiimzg6Xscu218XYF1GYRCaLsCWjjVx7xexvifma8KtTE4kxCRcqe1tPJwFW7ABL2EMmH3KDiVuC2GaX" ], "script": "base64:AAIDAAAAAAAAAAAAAAAdAAAAAAROT05FAgAAAARub25lAAAAAAZWT1RFUlMAAAAAAAAAAAMAAAAABlFVT1JVTQAAAAAAAAAAAgAAAAAGVk9USU5HAgAAAAZ2b3RpbmcAAAAABlJFVkVBTAIAAAAGcmV2ZWFsAAAAAAhGRUFUVVJFRAIAAAAIZmVhdHVyZWQAAAAACERFTElTVEVEAgAAAAhkZWxpc3RlZAEAAAAKZ2V0S2V5SXRlbQAAAAIAAAAIc3VwcGxpZXIAAAAFdGl0bGUJAAEsAAAAAgIAAAAFaXRlbV8JAAJYAAAAAQkAAfcAAAABCQABmwAAAAEJAAEsAAAAAgUAAAAIc3VwcGxpZXIFAAAABXRpdGxlAQAAABJnZXRLZXlJdGVtU3VwcGxpZXIAAAABAAAABGl0ZW0JAAEsAAAAAgUAAAAEaXRlbQIAAAAGX293bmVyAQAAABVnZXRLZXlCYWxhbmNlU3VwcGxpZXIAAAABAAAABGl0ZW0JAAEsAAAAAgUAAAAEaXRlbQIAAAAIX2JhbGFuY2UBAAAAD2dldEtleUl0ZW1QcmljZQAAAAEAAAAEaXRlbQkAASwAAAAC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AZwAAAAIFAAAAB2NvbW1pdHMFAAAABlZPVEVSUwkAAAIAAAABAgAAAAltYXggdm90ZXMDCQEAAAACIT0AAAACCQEAAAAOZ2V0VmFsdWVDb21taXQAAAACBQAAAARpdGVtBQAAAAR1c2VyBQAAAAROT05FCQAAAgAAAAECAAAAFGFscmVhZHkgcGFydGljaXBhdGVkAwkAAAAAAAACCQEAAAASZ2V0S2V5SXRlbVN1cHBsaWVyAAAAAQUAAAAEaXRlbQUAAAAETk9ORQkAAAIAAAABAgAAAAlub3QgZXhpc3QDAwkBAAAAAiE9AAAAAgUAAAAGc3RhdHVzBQAAAAROT05FCQEAAAACIT0AAAACBQAAAAZzdGF0dXMFAAAABlZPVElORwcJAAACAAAAAQIAAAAMbm90IHBvc3NpYmxlCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAMZ2V0S2V5Q29tbWl0AAAAAgUAAAAEaXRlbQUAAAAEdXNlcgUAAAAEaGFzaAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAEmdldEtleUNvbW1pdHNDb3VudAAAAAEFAAAABGl0ZW0JAABkAAAAAgUAAAAHY29tbWl0cwAAAAAAAAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAEGdldEtleUl0ZW1TdGF0dXMAAAABBQAAAARpdGVtAwkAAAAAAAACBQAAAAdjb21taXRzBQAAAAZWT1RFUlMFAAAABlJFVkVBTAUAAAAGVk9USU5HBQAAAANuaWwAAAAAkzpzfg==", "chainId": 84, "height": 553411, "spentComplexity": 0 } View: original | compacted Prev: 5Aoq76tGWqzsEqxcGnjCgH7a69CvCm7jyV6jF6KXGYGa Next: 7FbgU7APpeQemGDYYZ9Kgh1xpN6Cahwh9JihgpgAGkBY Diff:
OldNewDifferences
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let NONE = "none"
5+
6+let VOTERS = 3
7+
8+let QUORUM = 2
9+
10+let VOTING = "voting"
11+
12+let REVEAL = "reveal"
13+
14+let FEATURED = "featured"
15+
16+let DELISTED = "delisted"
517
618 func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
719
5365
5466
5567 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
68+
69+
70+func getKeyCommit (item,user) = (((item + "_") + user) + "_commit")
71+
72+
73+func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user))
74+
75+
76+func getKeyCommitsCount (item) = (item + "_comcnt")
77+
78+
79+func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item))
80+
81+
82+func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal")
83+
84+
85+func getValueReveal (item,user) = getStrByKey(getKeyCommit(item, user))
86+
87+
88+func getKeyItemStatus (item) = (item + "_status")
89+
90+
91+func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item))
92+
93+
94+func getKeyVoteCount (item,vote) = ((item + "_res:") + vote)
95+
96+
97+func getValueVoteCount (item,vote) = getStrByKey(getKeyVoteCount(item, vote))
5698
5799
58100 @Callable(i)
122164 }
123165
124166
167+
168+@Callable(i)
169+func voteCommit (item,hash) = {
170+ let user = toBase58String(i.caller.bytes)
171+ let commits = getValueCommitsCount(item)
172+ let status = getValueItemStatus(item)
173+ if ((commits >= VOTERS))
174+ then throw("max votes")
175+ else if ((getValueCommit(item, user) != NONE))
176+ then throw("already participated")
177+ else if ((getKeyItemSupplier(item) == NONE))
178+ then throw("not exist")
179+ else if (if ((status != NONE))
180+ then (status != VOTING)
181+ else false)
182+ then throw("not possible")
183+ else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if ((commits == VOTERS))
184+ then REVEAL
185+ else VOTING)])
186+ }
187+
188+
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let NONE = "none"
5+
6+let VOTERS = 3
7+
8+let QUORUM = 2
9+
10+let VOTING = "voting"
11+
12+let REVEAL = "reveal"
13+
14+let FEATURED = "featured"
15+
16+let DELISTED = "delisted"
517
618 func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
719
820
921 func getKeyItemSupplier (item) = (item + "_owner")
1022
1123
1224 func getKeyBalanceSupplier (item) = (item + "_balance")
1325
1426
1527 func getKeyItemPrice (item) = (item + "_price")
1628
1729
1830 func getKeyItemData (item) = (item + "_data")
1931
2032
2133 func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
2234
2335
2436 func getStrByKey (key) = {
2537 let str = match getString(this, key) {
2638 case a: String =>
2739 a
2840 case _ =>
2941 NONE
3042 }
3143 str
3244 }
3345
3446
3547 func getNumberByKey (key) = {
3648 let num = match getInteger(this, key) {
3749 case a: Int =>
3850 a
3951 case _ =>
4052 0
4153 }
4254 num
4355 }
4456
4557
4658 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
4759
4860
4961 func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
5062
5163
5264 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
5365
5466
5567 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
68+
69+
70+func getKeyCommit (item,user) = (((item + "_") + user) + "_commit")
71+
72+
73+func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user))
74+
75+
76+func getKeyCommitsCount (item) = (item + "_comcnt")
77+
78+
79+func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item))
80+
81+
82+func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal")
83+
84+
85+func getValueReveal (item,user) = getStrByKey(getKeyCommit(item, user))
86+
87+
88+func getKeyItemStatus (item) = (item + "_status")
89+
90+
91+func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item))
92+
93+
94+func getKeyVoteCount (item,vote) = ((item + "_res:") + vote)
95+
96+
97+func getValueVoteCount (item,vote) = getStrByKey(getKeyVoteCount(item, vote))
5698
5799
58100 @Callable(i)
59101 func purchaseOld (type) = {
60102 let pmt = extract(i.payment)
61103 if (isDefined(pmt.assetId))
62104 then throw("can use WAVES only at the moment")
63105 else {
64106 let customerAddress = toBase58String(i.caller.bytes)
65107 let price = match getInteger(this, (("item_" + type) + "_coupon_price")) {
66108 case a: Int =>
67109 a
68110 case _ =>
69111 0
70112 }
71113 if ((price > pmt.amount))
72114 then throw("purschase amount cannot be less than item price")
73115 else if ((pmt.amount > price))
74116 then throw("purchase amount cannot be higher than item price")
75117 else WriteSet([DataEntry(((("status:purchase_item_" + type) + "_customer_") + customerAddress), "confirmed"), DataEntry(((("price:purchase_item_" + type) + "_customer_") + customerAddress), price)])
76118 }
77119 }
78120
79121
80122
81123 @Callable(i)
82124 func addItem (title,price,data) = {
83125 let supplierAddress = toBase58String(i.caller.bytes)
84126 let item = getKeyItem(supplierAddress, title)
85127 if ((0 >= price))
86128 then throw("purchase amount cannot be less than item price")
87129 else if ((getValueItemSupplier(item) != NONE))
88130 then throw("an items is already exist")
89131 else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
90132 }
91133
92134
93135
94136 @Callable(i)
95137 func purchase (item) = {
96138 let pmt = extract(i.payment)
97139 if (isDefined(pmt.assetId))
98140 then throw("WAVES tokens only at the moment")
99141 else {
100142 let userAddress = toBase58String(i.caller.bytes)
101143 let price = getValueItemPrice(item)
102144 let supplierAddress = getValueItemSupplier(item)
103145 if ((price > pmt.amount))
104146 then throw("purchase amount cannot be less than item price")
105147 else if ((pmt.amount > price))
106148 then throw("purchase amount cannot be higher than item price")
107149 else if ((supplierAddress == NONE))
108150 then throw("supplier does not exist")
109151 else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))])
110152 }
111153 }
112154
113155
114156
115157 @Callable(i)
116158 func withdraw () = {
117159 let supplierAddress = toBase58String(i.caller.bytes)
118160 let balance = getValueBalanceSupplier(supplierAddress)
119161 if ((0 >= balance))
120162 then throw("insufficient balance")
121163 else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]))
122164 }
123165
124166
167+
168+@Callable(i)
169+func voteCommit (item,hash) = {
170+ let user = toBase58String(i.caller.bytes)
171+ let commits = getValueCommitsCount(item)
172+ let status = getValueItemStatus(item)
173+ if ((commits >= VOTERS))
174+ then throw("max votes")
175+ else if ((getValueCommit(item, user) != NONE))
176+ then throw("already participated")
177+ else if ((getKeyItemSupplier(item) == NONE))
178+ then throw("not exist")
179+ else if (if ((status != NONE))
180+ then (status != VOTING)
181+ else false)
182+ then throw("not possible")
183+ else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if ((commits == VOTERS))
184+ then REVEAL
185+ else VOTING)])
186+ }
187+
188+

github/deemru/w8io/026f985 
35.31 ms