tx · 7TZqgJzJLpyJ1K8BoNf1DFVLP9iXHPqwV8j9Myxk8xU5

3NBXRmoaNi1RVTa9JvuXhCeU1kTPGXdbCP7:  -0.01400000 Waves

2019.07.05 00:02 [571235] smart account 3NBXRmoaNi1RVTa9JvuXhCeU1kTPGXdbCP7 > SELF 0.00000000 Waves

{ "type": 13, "id": "7TZqgJzJLpyJ1K8BoNf1DFVLP9iXHPqwV8j9Myxk8xU5", "fee": 1400000, "feeAssetId": null, "timestamp": 1562274204567, "version": 1, "sender": "3NBXRmoaNi1RVTa9JvuXhCeU1kTPGXdbCP7", "senderPublicKey": "97dwMYPb6V2WyfYZoeFDjc6tbk4b5XRPKkEBgPLC9v4K", "proofs": [ "2Yyphi6n9vArPZMJT8m8nou9x8RZLZtiGfSPgAi4D6yqKsM6WHzpmDA6b4xcH7P3p4ejarQBGEUZuFTMs3KFvsRh" ], "script": "base64:AAIDAAAAAAAAAAAAAAAbAAAAAAROT05FAgAAAARub25lAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAAD2dldEtleUl0ZW1QcmljZQAAAAEAAAAEaXRlbQkAASwAAAACBQAAAARpdGVtAgAAAAZfcHJpY2UBAAAAEWdldFZhbHVlSXRlbVByaWNlAAAAAQAAAARpdGVtCQEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABCQEAAAAP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AAAAAAACBQAAAAdjb21taXRzBQAAAAZWT1RFUlMFAAAABlJFVkVBTAUAAAAGVk9USU5HBQAAAANuaWwAAAAA4+oOkQ==", "chainId": 84, "height": 571235, "spentComplexity": 0 } View: original | compacted Prev: Hx2b7Bapg92KEj9zdFwqs2Kfh61drkyoBaL6ZDfr9W1B Next: FkmqyCfdivCSWpQWJqJZFKvqxsYfr7LSe2EuopUC2JFX Diff:
OldNewDifferences
5555 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
5656
5757
58+let VOTERS = 3
59+
60+let QUORUM = 2
61+
62+let VOTING = "voting"
63+
64+let REVEAL = "reveal"
65+
66+let FEATURED = "featured"
67+
68+let DELISTED = "delisted"
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 getKeyItemStatus (item) = (item + "_status")
83+
84+
85+func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item))
86+
87+
88+func getKeyVoteCount (item,vote) = ((item + "_res:") + vote)
89+
90+
91+func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote))
92+
93+
5894 @Callable(i)
59-func withdraw () = {
60- let supplierAddress = toBase58String(i.caller.bytes)
61- let balance = getValueBalanceSupplier(supplierAddress)
62- if ((0 >= balance))
63- then throw("insufficient balance")
64- else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]))
95+func voteCommit (item,hash) = {
96+ let user = toBase58String(i.caller.bytes)
97+ let commits = getValueCommitsCount(item)
98+ let status = getValueItemStatus(item)
99+ if ((commits >= VOTERS))
100+ then throw("reached max num of voters")
101+ else if ((getValueCommit(item, user) != NONE))
102+ then throw("user has already participated")
103+ else if ((getKeyItemSupplier(item) == NONE))
104+ then throw("item does not exist")
105+ else if (if ((status != NONE))
106+ then (status != VOTING)
107+ else false)
108+ then throw("voting is not possible")
109+ else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if ((commits == VOTERS))
110+ then REVEAL
111+ else VOTING)])
65112 }
66113
67114
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
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 QUORUM = 2
61+
62+let VOTING = "voting"
63+
64+let REVEAL = "reveal"
65+
66+let FEATURED = "featured"
67+
68+let DELISTED = "delisted"
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 getKeyItemStatus (item) = (item + "_status")
83+
84+
85+func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item))
86+
87+
88+func getKeyVoteCount (item,vote) = ((item + "_res:") + vote)
89+
90+
91+func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote))
92+
93+
5894 @Callable(i)
59-func withdraw () = {
60- let supplierAddress = toBase58String(i.caller.bytes)
61- let balance = getValueBalanceSupplier(supplierAddress)
62- if ((0 >= balance))
63- then throw("insufficient balance")
64- else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)]))
95+func voteCommit (item,hash) = {
96+ let user = toBase58String(i.caller.bytes)
97+ let commits = getValueCommitsCount(item)
98+ let status = getValueItemStatus(item)
99+ if ((commits >= VOTERS))
100+ then throw("reached max num of voters")
101+ else if ((getValueCommit(item, user) != NONE))
102+ then throw("user has already participated")
103+ else if ((getKeyItemSupplier(item) == NONE))
104+ then throw("item does not exist")
105+ else if (if ((status != NONE))
106+ then (status != VOTING)
107+ else false)
108+ then throw("voting is not possible")
109+ else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if ((commits == VOTERS))
110+ then REVEAL
111+ else VOTING)])
65112 }
66113
67114

github/deemru/w8io/026f985 
43.85 ms