tx · 8YVQTvj68zepSUv9UznKyuNaQGYJYwQPRxwvoDivMJA 3MpjwMAGCaNqNFRa34foE5sTfV6zb76bYja: -0.01000010 Waves 2021.07.07 16:42 [1603249] smart account 3MpjwMAGCaNqNFRa34foE5sTfV6zb76bYja > SELF 0.00000000 Waves
{ "type": 13, "id": "8YVQTvj68zepSUv9UznKyuNaQGYJYwQPRxwvoDivMJA", "fee": 1000010, "feeAssetId": null, "timestamp": 1625665410990, "version": 2, "chainId": 84, "sender": "3MpjwMAGCaNqNFRa34foE5sTfV6zb76bYja", "senderPublicKey": "7Cy4wXHvgCRHP6MMhu9tTdayLHr9P9Dc342DVcCoCPzm", "proofs": [ "4538zkyXPMkzFYuKkeRazdoMqLT9k48dVyY1YCThT31hxQDVNbbvqvkAJPAwMJEQqkthD5kXBUTL1oCkzQFgwEg3" ], "script": "base64:AAIFAAAAAAAAAlEIAhIECgIICBIFCgMICAgaDAoCYTESBlZPVEVSUxoMCgJhMhIGUVVPUlVNGgwKAmEzEgZWT1RJTkcaDAoCYTQSBlJFVkVBTBoOCgJhNRIIRkVBVFVSRUQaDgoCYTYSCERFTElTVEVEGgoKAmE3EgROT05FGhQKAmE4Eg5nZXROdW1iZXJCeUtleRoJCgJhORIDa2V5GgkKAmIxEgNudW0aDQoCYjISByRtYXRjaDAaBwoCYjMSAWEaEQoCYjQSC2dldFN0ckJ5S2V5GgkKAmI1EgNzdHIaGAoCYjYSEmdldEtleUl0ZW1TdXBwbGllchoKCgJiNxIEaXRlbRoSCgJiOBIMZ2V0S2V5Q29tbWl0GgoKAmI5EgR1c2VyGhQKAmMxEg5nZXRWYWx1ZUNvbW1pdBoYCgJjMhISZ2V0S2V5Q29tbWl0c0NvdW50GhoKAmMzEhRnZXRWYWx1ZUNvbW1pdHNDb3VudBoSCgJjNBIMZ2V0S2V5UmV2ZWFsGhQKAmM1Eg5nZXRWYWx1ZVJldmVhbBoWCgJjNhIQZ2V0S2V5SXRlbVN0YXR1cxoYCgJjNxISZ2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kBAAAAAiE9AAAAAgUAAAACYzkFAAAAAmE2BwkAAAIAAAABAgAAABF2b3RlIGhhcyBmaW5pc2hlZAkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACCQEAAAACYzQAAAACBQAAAAJiNwUAAAACYjkFAAAAAmM5CQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACCQEAAAACYzgAAAACBQAAAAJiNwUAAAACYzkFAAAAAmQ3CQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAIJAQAAAAJjNgAAAAEFAAAAAmI3AwkAAGcAAAACBQAAAAJkNwUAAAACYTIFAAAAAmM5BQAAAAJhNAUAAAADbmlsAAAAABsO9M0=", "height": 1603249, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DwFK241mEgQAXuVhGhBdwJkQdwmeZ1X8F3iTQ4RvM2uu Next: GHW7a3uPTqoVsjsSsVqXxaUB1F5sMfeFbaFrqL61PVZA Diff:
Old | New | Differences | |
---|---|---|---|
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let VOTERS = 3 | |
5 | 5 | ||
6 | + | let QUORUM = 2 | |
7 | + | ||
6 | 8 | let VOTING = "voting" | |
7 | 9 | ||
8 | 10 | let REVEAL = "reveal" | |
11 | + | ||
12 | + | let FEATURED = "featured" | |
13 | + | ||
14 | + | let DELISTED = "delisted" | |
9 | 15 | ||
10 | 16 | let NONE = "none" | |
11 | 17 | ||
46 | 52 | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
47 | 53 | ||
48 | 54 | ||
55 | + | func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal") | |
56 | + | ||
57 | + | ||
58 | + | func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user)) | |
59 | + | ||
60 | + | ||
49 | 61 | func getKeyItemStatus (item) = (item + "_status") | |
50 | 62 | ||
51 | 63 | ||
52 | 64 | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
65 | + | ||
66 | + | ||
67 | + | func getKeyVoteCount (item,vote) = ((item + "_res:") + vote) | |
68 | + | ||
69 | + | ||
70 | + | func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote)) | |
53 | 71 | ||
54 | 72 | ||
55 | 73 | @Callable(i) | |
73 | 91 | } | |
74 | 92 | ||
75 | 93 | ||
94 | + | ||
95 | + | @Callable(i) | |
96 | + | func voteReveal (item,vote,salt) = { | |
97 | + | let user = toBase58String(i.caller.bytes) | |
98 | + | let status = getValueItemStatus(item) | |
99 | + | let newVoteCount = (getValueVoteCount(item, vote) + 1) | |
100 | + | if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user))) | |
101 | + | then throw("reveal data is not valid") | |
102 | + | else if ((VOTERS > getValueCommitsCount(item))) | |
103 | + | then throw("max number of voters hasn't reached yet") | |
104 | + | else if ((getValueReveal(item, user) != NONE)) | |
105 | + | then throw("user has already participated") | |
106 | + | else if (if ((status != VOTING)) | |
107 | + | then (status != REVEAL) | |
108 | + | else false) | |
109 | + | then throw("wrong status") | |
110 | + | else if (if ((vote != FEATURED)) | |
111 | + | then (vote != DELISTED) | |
112 | + | else false) | |
113 | + | then throw("vote has finished") | |
114 | + | else [StringEntry(getKeyReveal(item, user), vote), IntegerEntry(getKeyVoteCount(item, vote), newVoteCount), StringEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM)) | |
115 | + | then vote | |
116 | + | else REVEAL)] | |
117 | + | } | |
118 | + | ||
119 | + |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let VOTERS = 3 | |
5 | 5 | ||
6 | + | let QUORUM = 2 | |
7 | + | ||
6 | 8 | let VOTING = "voting" | |
7 | 9 | ||
8 | 10 | let REVEAL = "reveal" | |
11 | + | ||
12 | + | let FEATURED = "featured" | |
13 | + | ||
14 | + | let DELISTED = "delisted" | |
9 | 15 | ||
10 | 16 | let NONE = "none" | |
11 | 17 | ||
12 | 18 | func getNumberByKey (key) = { | |
13 | 19 | let num = match getInteger(this, key) { | |
14 | 20 | case a: Int => | |
15 | 21 | a | |
16 | 22 | case _ => | |
17 | 23 | 0 | |
18 | 24 | } | |
19 | 25 | num | |
20 | 26 | } | |
21 | 27 | ||
22 | 28 | ||
23 | 29 | func getStrByKey (key) = { | |
24 | 30 | let str = match getString(this, key) { | |
25 | 31 | case a: String => | |
26 | 32 | a | |
27 | 33 | case _ => | |
28 | 34 | NONE | |
29 | 35 | } | |
30 | 36 | str | |
31 | 37 | } | |
32 | 38 | ||
33 | 39 | ||
34 | 40 | func getKeyItemSupplier (item) = (item + "_data") | |
35 | 41 | ||
36 | 42 | ||
37 | 43 | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
38 | 44 | ||
39 | 45 | ||
40 | 46 | func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user)) | |
41 | 47 | ||
42 | 48 | ||
43 | 49 | func getKeyCommitsCount (item) = (item + "_comcnt") | |
44 | 50 | ||
45 | 51 | ||
46 | 52 | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
47 | 53 | ||
48 | 54 | ||
55 | + | func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal") | |
56 | + | ||
57 | + | ||
58 | + | func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user)) | |
59 | + | ||
60 | + | ||
49 | 61 | func getKeyItemStatus (item) = (item + "_status") | |
50 | 62 | ||
51 | 63 | ||
52 | 64 | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
65 | + | ||
66 | + | ||
67 | + | func getKeyVoteCount (item,vote) = ((item + "_res:") + vote) | |
68 | + | ||
69 | + | ||
70 | + | func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote)) | |
53 | 71 | ||
54 | 72 | ||
55 | 73 | @Callable(i) | |
56 | 74 | func voteCommit (item,hash) = { | |
57 | 75 | let user = toBase58String(i.caller.bytes) | |
58 | 76 | let commits = getValueCommitsCount(item) | |
59 | 77 | let status = getValueItemStatus(item) | |
60 | 78 | if ((commits >= VOTERS)) | |
61 | 79 | then throw("osiągnięto maksymaną liczbę głosujących") | |
62 | 80 | else if ((getValueCommit(item, user) != NONE)) | |
63 | 81 | then throw("użtykownik już głosuje") | |
64 | 82 | else if ((getKeyItemSupplier(item) == NONE)) | |
65 | 83 | then throw("nie istnieje taki przedmiot") | |
66 | 84 | else if (if ((status != NONE)) | |
67 | 85 | then (status != VOTING) | |
68 | 86 | else false) | |
69 | 87 | then throw("głosowanie nie jest możliwe") | |
70 | 88 | else [StringEntry(getKeyCommit(item, user), hash), IntegerEntry(getKeyCommitsCount(item), (commits + 1)), StringEntry(getKeyItemStatus(item), if ((commits == VOTERS)) | |
71 | 89 | then REVEAL | |
72 | 90 | else VOTING)] | |
73 | 91 | } | |
74 | 92 | ||
75 | 93 | ||
94 | + | ||
95 | + | @Callable(i) | |
96 | + | func voteReveal (item,vote,salt) = { | |
97 | + | let user = toBase58String(i.caller.bytes) | |
98 | + | let status = getValueItemStatus(item) | |
99 | + | let newVoteCount = (getValueVoteCount(item, vote) + 1) | |
100 | + | if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user))) | |
101 | + | then throw("reveal data is not valid") | |
102 | + | else if ((VOTERS > getValueCommitsCount(item))) | |
103 | + | then throw("max number of voters hasn't reached yet") | |
104 | + | else if ((getValueReveal(item, user) != NONE)) | |
105 | + | then throw("user has already participated") | |
106 | + | else if (if ((status != VOTING)) | |
107 | + | then (status != REVEAL) | |
108 | + | else false) | |
109 | + | then throw("wrong status") | |
110 | + | else if (if ((vote != FEATURED)) | |
111 | + | then (vote != DELISTED) | |
112 | + | else false) | |
113 | + | then throw("vote has finished") | |
114 | + | else [StringEntry(getKeyReveal(item, user), vote), IntegerEntry(getKeyVoteCount(item, vote), newVoteCount), StringEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM)) | |
115 | + | then vote | |
116 | + | else REVEAL)] | |
117 | + | } | |
118 | + | ||
119 | + |
github/deemru/w8io/169f3d6 40.53 ms ◑