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:AAIDAAAAAAAAAAAAAAAbAAAAAAROT05FAgAAAARub25lAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAAD2dldEtleUl0ZW1QcmljZQAAAAEAAAAEaXRlbQkAASwAAAACBQAAAARpdGVtAgAAAAZfcHJpY2UBAAAAEWdldFZhbHVlSXRlbVByaWNlAAAAAQAAAARpdGVtCQEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABCQEAAAAPZ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AAAAAACBQAAAAdjb21taXRzBQAAAAZWT1RFUlMFAAAABlJFVkVBTAUAAAAGVk9USU5HBQAAAANuaWwAAAAA4+oOkQ==", "chainId": 84, "height": 571235, "spentComplexity": 0 } View: original | compacted Prev: Hx2b7Bapg92KEj9zdFwqs2Kfh61drkyoBaL6ZDfr9W1B Next: FkmqyCfdivCSWpQWJqJZFKvqxsYfr7LSe2EuopUC2JFX Diff:
Old | New | Differences | |
---|---|---|---|
55 | 55 | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
56 | 56 | ||
57 | 57 | ||
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 | + | ||
58 | 94 | @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)]) | |
65 | 112 | } | |
66 | 113 | ||
67 | 114 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let NONE = "none" | |
5 | 5 | ||
6 | 6 | func getNumberByKey (key) = { | |
7 | 7 | let num = match getInteger(this, key) { | |
8 | 8 | case a: Int => | |
9 | 9 | a | |
10 | 10 | case _ => | |
11 | 11 | 0 | |
12 | 12 | } | |
13 | 13 | num | |
14 | 14 | } | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func getStrByKey (key) = { | |
18 | 18 | let str = match getString(this, key) { | |
19 | 19 | case a: String => | |
20 | 20 | a | |
21 | 21 | case _ => | |
22 | 22 | NONE | |
23 | 23 | } | |
24 | 24 | str | |
25 | 25 | } | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func getKeyItemPrice (item) = (item + "_price") | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func getKeyItemData (item) = (item + "_data") | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func getKeyItemSupplier (item) = (item + "_owner") | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func getKeyBalanceSupplier (account) = (account + "_balance") | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
56 | 56 | ||
57 | 57 | ||
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 | + | ||
58 | 94 | @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)]) | |
65 | 112 | } | |
66 | 113 | ||
67 | 114 |
github/deemru/w8io/026f985 43.85 ms ◑