tx · CqurD1t5fXia3gNo2VhjzjyRjoRaN8qaoUJ9jmfq51eb

3MxS2LBsPnEGA6AetWPqWTZjmQu8zUySd2c:  -0.01000000 Waves

2021.07.07 13:53 [1603094] smart account 3MxS2LBsPnEGA6AetWPqWTZjmQu8zUySd2c > SELF 0.00000000 Waves

{ "type": 13, "id": "CqurD1t5fXia3gNo2VhjzjyRjoRaN8qaoUJ9jmfq51eb", "fee": 1000000, "feeAssetId": null, "timestamp": 1625655211206, "version": 2, "chainId": 84, "sender": "3MxS2LBsPnEGA6AetWPqWTZjmQu8zUySd2c", "senderPublicKey": "9dJbLdKrkcPAEacPHvgivaqbGgimy4WN2MRrE6XXWFQu", "proofs": [ "WD5mbhucMz4nVnYFRaYyTWZZ9S2Yr5qiEnVxvGUHAoncJUBuT44KPnA4fccr3NQ2QsEDUAqwYVDLwpWcEwLfXYr" ], "script": "base64:AAIFAAAAAAAAAxkIAhIFCgMIAQgSAwoBCBIAEgQKAggIGgoKAmExEgROT05FGhQKAmEyEg5nZXROdW1iZXJCeUtleRoJCgJhMxIDa2V5GgkKAmE0EgNudW0aDQoCYTUSByRtYXRjaDAaBwoCYTYSAWEaEQoCYTcSC2dldFN0ckJ5S2V5GgkKAmE4EgNzdHIaFQoCYTkSD2dldEtleUl0ZW1QcmljZRoKCgJiMRIEaXRlbRoXCgJiMhIRZ2V0VmFsdWVJdGVtUHJpY2UaGwoCYjMSFWdldEtleVVzZXJJdGVtQ291bnRlchoKCgJiNBIEdXNlchodCgJiNRIXZ2V0VmFsdWVVc2VySXRlbUNvdW50ZXIaEAoCYjYSCmdldEtleUl0ZW0aDgoCYjcSCHN1cHBsaWVyGgsKAmI4EgV0aXRsZRoUCgJiORIOZ2V0S2V5SXRlbURhdGEaGAoCYzESEmdldEtleUl0ZW1TdXBwbGllchoaCgJjMhIUZ2V0VmFsdWVJdGVtU3VwcGxpZXIaGwoCYzMSFWdldEtleUJhbGFuY2VTdXBwbGllchoNCgJjNBIHYWNjb3VudBodCg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JAQAAAAIhPQAAAAIFAAAAAmU2BQAAAAJjNwcJAAACAAAAAQIAAAACYjMJAARMAAAAAgkBAAAAC1N0cmluZ0VudHJ5AAAAAgkBAAAAAmM5AAAAAgUAAAACYjEFAAAAAmI0BQAAAAJlNAkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkBAAAAAmQyAAAAAQUAAAACYjEJAABkAAAAAgUAAAACZTUAAAAAAAAAAAEJAARMAAAAAgkBAAAAC1N0cmluZ0VudHJ5AAAAAgkBAAAAAmQ0AAAAAQUAAAACYjEDCQAAAAAAAAIFAAAAAmU1BQAAAAJjNgUAAAACYzgFAAAAAmM3BQAAAANuaWwAAAAAi5WyIQ==", "height": 1603094, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DaK6zVzuZ5sb2buBKj1q6LgKmeJi5C8SGQSqF6UdE13a Next: 61U3aAp2SgVJPoUPDTmsTjZfoEQn8Y9ZzV1NCwxTWJoc Diff:
OldNewDifferences
5555 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
5656
5757
58+let VOTERS = 3
59+
60+let VOTING = "voting"
61+
62+let REVEAL = "reveal"
63+
64+func getKeyCommit (item,user) = (((item + "_") + user) + "_commit")
65+
66+
67+func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user))
68+
69+
70+func getKeyCommitsCount (item) = (item + "_comcnt")
71+
72+
73+func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item))
74+
75+
76+func getKeyItemStatus (item) = (item + "_status")
77+
78+
79+func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item))
80+
81+
5882 @Callable(i)
5983 func addItem (title,price,data) = {
6084 let supplierAddress = toBase58String(i.caller.bytes)
97121 }
98122
99123
124+
125+@Callable(i)
126+func voteCommit (item,hash) = {
127+ let user = toBase58String(i.caller.bytes)
128+ let commits = getValueCommitsCount(item)
129+ let status = getValueItemStatus(item)
130+ if ((commits >= VOTERS))
131+ then throw("Reached max num of voters")
132+ else if ((getValueCommit(item, user) != NONE))
133+ then throw("b1")
134+ else if ((getKeyItemSupplier(item) == NONE))
135+ then throw("b2")
136+ else if (if ((status != NONE))
137+ then (status != VOTING)
138+ else false)
139+ then throw("b3")
140+ else [StringEntry(getKeyCommit(item, user), hash), IntegerEntry(getKeyCommitsCount(item), (commits + 1)), StringEntry(getKeyItemStatus(item), if ((commits == VOTERS))
141+ then REVEAL
142+ else VOTING)]
143+ }
144+
145+
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let NONE = "none"
55
66 func getNumberByKey (key) = {
77 let num = match getInteger(this, key) {
88 case a: Int =>
99 a
1010 case _ =>
1111 0
1212 }
1313 num
1414 }
1515
1616
1717 func getStrByKey (key) = {
1818 let str = match getString(this, key) {
1919 case a: String =>
2020 a
2121 case _ =>
2222 NONE
2323 }
2424 str
2525 }
2626
2727
2828 func getKeyItemPrice (item) = (item + "_price")
2929
3030
3131 func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
3232
3333
3434 func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
3535
3636
3737 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
3838
3939
4040 func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
4141
4242
4343 func getKeyItemData (item) = (item + "_data")
4444
4545
4646 func getKeyItemSupplier (item) = (item + "_owner")
4747
4848
4949 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
5050
5151
5252 func getKeyBalanceSupplier (account) = (account + "_balance")
5353
5454
5555 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
5656
5757
58+let VOTERS = 3
59+
60+let VOTING = "voting"
61+
62+let REVEAL = "reveal"
63+
64+func getKeyCommit (item,user) = (((item + "_") + user) + "_commit")
65+
66+
67+func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user))
68+
69+
70+func getKeyCommitsCount (item) = (item + "_comcnt")
71+
72+
73+func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item))
74+
75+
76+func getKeyItemStatus (item) = (item + "_status")
77+
78+
79+func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item))
80+
81+
5882 @Callable(i)
5983 func addItem (title,price,data) = {
6084 let supplierAddress = toBase58String(i.caller.bytes)
6185 let item = getKeyItem(supplierAddress, title)
6286 if ((0 >= price))
6387 then throw("Purchase amount cannot be less than item price")
6488 else if ((getValueItemSupplier(item) != NONE))
6589 then throw("an item already exists")
6690 else [StringEntry(getKeyItemSupplier(item), supplierAddress), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data)]
6791 }
6892
6993
7094
7195 @Callable(i)
7296 func purchase (item) = {
7397 let pmt = i.payments[0]
7498 if (isDefined(pmt.assetId))
7599 then throw("WAVES ONLY HHEUAWHEUAS")
76100 else {
77101 let userAddress = toBase58String(i.caller.bytes)
78102 let price = getValueItemPrice(item)
79103 let supplierAddress = getValueItemSupplier(item)
80104 if ((price > pmt.amount))
81105 then throw("Purchase amount cannot be less than item price")
82106 else if ((supplierAddress == NONE))
83107 then throw("Supplier does not exist")
84108 else [IntegerEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), IntegerEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))]
85109 }
86110 }
87111
88112
89113
90114 @Callable(i)
91115 func withdraw () = {
92116 let supplierAddress = toBase58String(i.caller.bytes)
93117 let balance = getValueBalanceSupplier(supplierAddress)
94118 if ((0 >= balance))
95119 then throw("insuficient balance")
96120 else [IntegerEntry(getKeyBalanceSupplier(supplierAddress), 0), ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]
97121 }
98122
99123
124+
125+@Callable(i)
126+func voteCommit (item,hash) = {
127+ let user = toBase58String(i.caller.bytes)
128+ let commits = getValueCommitsCount(item)
129+ let status = getValueItemStatus(item)
130+ if ((commits >= VOTERS))
131+ then throw("Reached max num of voters")
132+ else if ((getValueCommit(item, user) != NONE))
133+ then throw("b1")
134+ else if ((getKeyItemSupplier(item) == NONE))
135+ then throw("b2")
136+ else if (if ((status != NONE))
137+ then (status != VOTING)
138+ else false)
139+ then throw("b3")
140+ else [StringEntry(getKeyCommit(item, user), hash), IntegerEntry(getKeyCommitsCount(item), (commits + 1)), StringEntry(getKeyItemStatus(item), if ((commits == VOTERS))
141+ then REVEAL
142+ else VOTING)]
143+ }
144+
145+

github/deemru/w8io/026f985 
41.05 ms