tx · 4teELnsVnyY8cpsfBLt2qg8eMfmtr2E2mR8vToU2PMXP

3Mz9ndf12uVKYMqYmwUr81wcNLYEgr82ei6:  -0.01400000 Waves

2019.11.16 22:40 [768102] smart account 3Mz9ndf12uVKYMqYmwUr81wcNLYEgr82ei6 > SELF 0.00000000 Waves

{ "type": 13, "id": "4teELnsVnyY8cpsfBLt2qg8eMfmtr2E2mR8vToU2PMXP", "fee": 1400000, "feeAssetId": null, "timestamp": 1573933223437, "version": 1, "sender": "3Mz9ndf12uVKYMqYmwUr81wcNLYEgr82ei6", "senderPublicKey": "8bmUdC19peGBa1TGeRZaZfpuDG6yKaGYBd8FQvcBLAXR", "proofs": [ "3AiPTLmwTuKnzJfCrBmyyrHJqvvrrJ1tp8JxgPmK8XqrVFuYifGkjcdb4AKj6S64g4SNL3oyV6VRvPe8L3j18WhE" ], "script": "base64:AAIDAAAAAAAAAAkIARIFCgMICAgAAAAdAAAAAAROT05FAgAAAARub25lAAAAAAZWT1RFUlMAAAAAAAAAAAMAAAAABlFVT1JVTQAAAAAAAAAAAgAAAAAGVk9USU5HAgAAAAZ2b3RpbmcAAAAABlJFVkVBTAIAAAAGcmV2ZWFsAAAAAAhGRUFUVVJFRAIAAAAIZmVhdHVyZWQAAAAACERFTElTVEVEAgAAAAhkZWxpc3RlZAEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAA251bQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAA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TAcJAAACAAAAAQIAAAAMd3Jvbmcgc3RhdHVzAwMJAQAAAAIhPQAAAAIFAAAABHZvdGUFAAAACEZFQVRVUkVECQEAAAACIT0AAAACBQAAAAR2b3RlBQAAAAhERUxJU1RFRAcJAAACAAAAAQIAAAAKd3Jvbmcgdm90ZQMDCQAAAAAAAAIFAAAABnN0YXR1cwUAAAAIRkVBVFVSRUQGCQAAAAAAAAIFAAAABnN0YXR1cwUAAAAIREVMSVNURUQJAAACAAAAAQIAAAARdm90ZSBoYXMgZmluaXNoZWQJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAAAxnZXRLZXlSZXZlYWwAAAACBQAAAARpdGVtBQAAAAR1c2VyBQAAAAR2b3RlCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAPZ2V0S2V5Vm90ZUNvdW50AAAAAgUAAAAEaXRlbQUAAAAEdm90ZQUAAAAMbmV3Vm90ZUNvdW50CQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAQZ2V0S2V5SXRlbVN0YXR1cwAAAAEFAAAABGl0ZW0DCQAAZwAAAAIFAAAADG5ld1ZvdGVDb3VudAUAAAAGUVVPUlVNBQAAAAR2b3RlBQAAAAZSRVZFQUwFAAAAA25pbAAAAACQveNY", "chainId": 84, "height": 768102, "spentComplexity": 0 } View: original | compacted Prev: CbG2SFGC41RXzayu92DDGmMNxZmZYAeBVZp6xLcc1k4z Next: none Diff:
OldNewDifferences
9898
9999
100100 @Callable(i)
101-func voteCommit (item,hash) = {
101+func voteReveal (item,vote,salt) = {
102102 let user = toBase58String(i.caller.bytes)
103- let commits = getValueCommitsCount(item)
104103 let status = getValueItemStatus(item)
105- if ((commits >= VOTERS))
106- then throw("reahced max voters")
107- else if ((getValueCommit(item, user) != NONE))
108- then throw("user already voted")
109- else if ((getKeyItemSupp(item) == NONE))
110- then throw("item does not exist")
111- else if (if ((status != NONE))
112- then (status != VOTING)
104+ let newVoteCount = (getValueVoteCount(item, vote) + 1)
105+ if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user)))
106+ then throw("reveal data is not valid")
107+ else if ((VOTERS > getValueCommitsCount(item)))
108+ then throw("max num of votes hasn't reached yet")
109+ else if ((getValueReveal(item, user) != NONE))
110+ then throw("user has already participated")
111+ else if (if ((status != VOTING))
112+ then (status != REVEAL)
113113 else false)
114- then throw("vote is not possible")
115- else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if ((commits == VOTERS))
116- then REVEAL
117- else VOTING)])
114+ then throw("wrong status")
115+ else if (if ((vote != FEATURED))
116+ then (vote != DELISTED)
117+ else false)
118+ then throw("wrong vote")
119+ else if (if ((status == FEATURED))
120+ then true
121+ else (status == DELISTED))
122+ then throw("vote has finished")
123+ else WriteSet([DataEntry(getKeyReveal(item, user), vote), DataEntry(getKeyVoteCount(item, vote), newVoteCount), DataEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM))
124+ then vote
125+ else REVEAL)])
118126 }
119127
120128
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let NONE = "none"
55
66 let VOTERS = 3
77
88 let QUORUM = 2
99
1010 let VOTING = "voting"
1111
1212 let REVEAL = "reveal"
1313
1414 let FEATURED = "featured"
1515
1616 let DELISTED = "delisted"
1717
1818 func getStrByKey (key) = {
1919 let str = match getString(this, key) {
2020 case a: String =>
2121 a
2222 case _ =>
2323 NONE
2424 }
2525 str
2626 }
2727
2828
2929 func getNumberByKey (key) = {
3030 let num = match getInteger(this, key) {
3131 case a: Int =>
3232 a
3333 case _ =>
3434 0
3535 }
3636 num
3737 }
3838
3939
4040 func getKeyCommit (item,user) = (((item + "_") + user) + "_commit")
4141
4242
4343 func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user))
4444
4545
4646 func getKeyCommitsCount (item) = (item + "_comcnt")
4747
4848
4949 func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item))
5050
5151
5252 func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal")
5353
5454
5555 func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user))
5656
5757
5858 func getKeyItemStatus (item) = (item + "_status")
5959
6060
6161 func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item))
6262
6363
6464 func getKeyVoteCount (item,vote) = ((item + "_res:") + vote)
6565
6666
6767 func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote))
6868
6969
7070 func getKeyItemPrice (item) = (item + "_price")
7171
7272
7373 func getKeyItemData (item) = (item + "_data")
7474
7575
7676 func getKeyItemSupp (item) = (item + "_owner")
7777
7878
7979 func getKeyItem (supp,title) = ("item_" + toBase58String(sha256(toBytes((supp + title)))))
8080
8181
8282 func getValueItemSupp (item) = getStrByKey(getKeyItemSupp(item))
8383
8484
8585 func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
8686
8787
8888 func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
8989
9090
9191 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
9292
9393
9494 func getKeySuppBalance (supp) = (supp + "_balance")
9595
9696
9797 func getValueSuppBalance (supp) = getNumberByKey(getKeySuppBalance(supp))
9898
9999
100100 @Callable(i)
101-func voteCommit (item,hash) = {
101+func voteReveal (item,vote,salt) = {
102102 let user = toBase58String(i.caller.bytes)
103- let commits = getValueCommitsCount(item)
104103 let status = getValueItemStatus(item)
105- if ((commits >= VOTERS))
106- then throw("reahced max voters")
107- else if ((getValueCommit(item, user) != NONE))
108- then throw("user already voted")
109- else if ((getKeyItemSupp(item) == NONE))
110- then throw("item does not exist")
111- else if (if ((status != NONE))
112- then (status != VOTING)
104+ let newVoteCount = (getValueVoteCount(item, vote) + 1)
105+ if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user)))
106+ then throw("reveal data is not valid")
107+ else if ((VOTERS > getValueCommitsCount(item)))
108+ then throw("max num of votes hasn't reached yet")
109+ else if ((getValueReveal(item, user) != NONE))
110+ then throw("user has already participated")
111+ else if (if ((status != VOTING))
112+ then (status != REVEAL)
113113 else false)
114- then throw("vote is not possible")
115- else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if ((commits == VOTERS))
116- then REVEAL
117- else VOTING)])
114+ then throw("wrong status")
115+ else if (if ((vote != FEATURED))
116+ then (vote != DELISTED)
117+ else false)
118+ then throw("wrong vote")
119+ else if (if ((status == FEATURED))
120+ then true
121+ else (status == DELISTED))
122+ then throw("vote has finished")
123+ else WriteSet([DataEntry(getKeyReveal(item, user), vote), DataEntry(getKeyVoteCount(item, vote), newVoteCount), DataEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM))
124+ then vote
125+ else REVEAL)])
118126 }
119127
120128

github/deemru/w8io/169f3d6 
37.15 ms