tx · EigQthiRcwfkBtqGUVjmvMan6w8tvR4AEjRxD8abDnBX 3N2nCHvKXtFH8RUsGQB4LVEwVEWfTsT5i2B: -0.01400000 Waves 2019.07.14 21:23 [585772] smart account 3N2nCHvKXtFH8RUsGQB4LVEwVEWfTsT5i2B > SELF 0.00000000 Waves
{ "type": 13, "id": "EigQthiRcwfkBtqGUVjmvMan6w8tvR4AEjRxD8abDnBX", "fee": 1400000, "feeAssetId": null, "timestamp": 1563128630922, "version": 1, "sender": "3N2nCHvKXtFH8RUsGQB4LVEwVEWfTsT5i2B", "senderPublicKey": "6NXakHCUpkyyHNuwDVZ4gYubvvbuP2qL6v2WzJhniSN1", "proofs": [ "3496ezq83cmZkDaTmU5VxsFV4Ekw4WEzQaBnDbp24RLiCMf2j6KyKEPPGDh6Fy7jysdzHUxfTzM7Pc9zvB4nJsWV" ], "script": "base64:AAIDAAAAAAAAAAAAAAAdAAAAAAZWT1RFUlMAAAAAAAAAAAQAAAAABlFVT1JVTQAAAAAAAAAAAgAAAAAGVk9USU5HAgAAAAZ2b3RpbmcAAAAABlJFVkVBTAIAAAAGcmV2ZWFsAAAAAAhGRUFUVVJFRAIAAAAIZmVhdHVyZWQAAAAACERFTElTVEVEAgAAAAhkZWxpc3RlZAAAAAAETk9ORQIAAAAEbm9uZQEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAAAC2dldFN0ckJ5S2V5AAAAAQAAAANrZXkEAAAAA3N0cgQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQUAAAAETk9OR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laSB2b3RhbnRpIG5vbiDDqCBzdGF0byByYWdnaXVudG8DCQEAAAACIT0AAAACCQEAAAAOZ2V0VmFsdWVSZXZlYWwAAAACBQAAAARpdGVtBQAAAAR1c2VyBQAAAAROT05FCQAAAgAAAAECAAAAK2wndXRlbnRlIGhhIGdpw6AgcGFydGVjaXBhdG8gYWxsYSB2b3RhemlvbmUDAwkBAAAAAiE9AAAAAgUAAAAGc3RhdHVzBQAAAAZSRVZFQUwJAQAAAAIhPQAAAAIFAAAABnN0YXR1cwUAAAAGVk9USU5HBwkAAAIAAAABAgAAAAxTdGF0byBlcnJhdG8DAwkBAAAAAiE9AAAAAgUAAAAEdm90ZQUAAAAIRkVBVFVSRUQJAQAAAAIhPQAAAAIFAAAABHZvdGUFAAAACERFTElTVEVEBwkAAAIAAAABAgAAAAtWb3RvIGVycmF0bwMDCQAAAAAAAAIFAAAABnN0YXR1cwUAAAAIRkVBVFVSRUQGCQAAAAAAAAIFAAAABnN0YXR1cwUAAAAIREVMSVNURUQJAAACAAAAAQIAAAAbTGEgdm90YXppb25lIHNpIMOoIGNvbmNsdXNhCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAMZ2V0S2V5UmV2ZWFsAAAAAgUAAAAEaXRlbQUAAAAEdXNlcgUAAAAEdm90ZQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAD2dldEtleVZvdGVDb3VudAAAAAIFAAAABGl0ZW0FAAAABHZvdGUFAAAADG5ld1ZvdGVDb3VudAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAEGdldEtleUl0ZW1TdGF0dXMAAAABBQAAAARpdGVtAwkAAGcAAAACBQAAAAxuZXdWb3RlQ291bnQFAAAABlFVT1JVTQUAAAAGVk9USU5HBQAAAAZSRVZFQUwFAAAAA25pbAAAAABcoM7w", "chainId": 84, "height": 585772, "spentComplexity": 0 } View: original | compacted Prev: BxAEFqLpLBmo8f6CiSvR8bTZPV5huyXPYvesVwkSBmJc Next: B4W5ixJoUcMmMq8uWTFLKxieQJmpjbE7UgW8Vo32Tat5 Diff:
Old | New | Differences | |
---|---|---|---|
111 | 111 | else if (if ((status != NONE)) | |
112 | 112 | then (status != VOTING) | |
113 | 113 | else false) | |
114 | - | then throw("Votazione non possibile") | |
114 | + | then throw(("Votazione non possibile " + status)) | |
115 | 115 | else { | |
116 | 116 | let newCommits = (commits + 1) | |
117 | 117 | WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), newCommits), DataEntry(getKeyItemStatus(item), if ((newCommits == VOTERS)) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let VOTERS = 4 | |
5 | 5 | ||
6 | 6 | let QUORUM = 2 | |
7 | 7 | ||
8 | 8 | let VOTING = "voting" | |
9 | 9 | ||
10 | 10 | let REVEAL = "reveal" | |
11 | 11 | ||
12 | 12 | let FEATURED = "featured" | |
13 | 13 | ||
14 | 14 | let DELISTED = "delisted" | |
15 | 15 | ||
16 | 16 | let NONE = "none" | |
17 | 17 | ||
18 | 18 | func getNumberByKey (key) = { | |
19 | 19 | let num = match getInteger(this, key) { | |
20 | 20 | case a: Int => | |
21 | 21 | a | |
22 | 22 | case _ => | |
23 | 23 | 0 | |
24 | 24 | } | |
25 | 25 | num | |
26 | 26 | } | |
27 | 27 | ||
28 | 28 | ||
29 | 29 | func getStrByKey (key) = { | |
30 | 30 | let str = match getString(this, key) { | |
31 | 31 | case a: String => | |
32 | 32 | a | |
33 | 33 | case _ => | |
34 | 34 | NONE | |
35 | 35 | } | |
36 | 36 | str | |
37 | 37 | } | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user)) | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func getKeyCommitsCount (item) = (item + "_commit_count") | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal") | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user)) | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | func getKeyItemStatus (item) = (item + "_status") | |
59 | 59 | ||
60 | 60 | ||
61 | 61 | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
62 | 62 | ||
63 | 63 | ||
64 | 64 | func getKeyVoteCount (item,vote) = ((item + "_res_") + vote) | |
65 | 65 | ||
66 | 66 | ||
67 | 67 | func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote)) | |
68 | 68 | ||
69 | 69 | ||
70 | 70 | func getKeyItemPrice (item) = (item + "_price") | |
71 | 71 | ||
72 | 72 | ||
73 | 73 | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
77 | 77 | ||
78 | 78 | ||
79 | 79 | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
80 | 80 | ||
81 | 81 | ||
82 | 82 | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
83 | 83 | ||
84 | 84 | ||
85 | 85 | func getKeyItemData (item) = (item + "_data") | |
86 | 86 | ||
87 | 87 | ||
88 | 88 | func getKeyItemSupplier (item) = (item + "_owner") | |
89 | 89 | ||
90 | 90 | ||
91 | 91 | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
92 | 92 | ||
93 | 93 | ||
94 | 94 | func getKeyBalanceSupplier (account) = (account + "_balance") | |
95 | 95 | ||
96 | 96 | ||
97 | 97 | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
98 | 98 | ||
99 | 99 | ||
100 | 100 | @Callable(i) | |
101 | 101 | func voteCommit (item,hash) = { | |
102 | 102 | let user = toBase58String(i.caller.bytes) | |
103 | 103 | let commits = getValueCommitsCount(item) | |
104 | 104 | let status = getValueItemStatus(item) | |
105 | 105 | if ((commits >= VOTERS)) | |
106 | 106 | then throw("Raggiunto il numero massimo di voti") | |
107 | 107 | else if ((getValueCommit(item, user) != NONE)) | |
108 | 108 | then throw("Hai già espresso un voto per questo articolo") | |
109 | 109 | else if ((getKeyItemSupplier(item) == NONE)) | |
110 | 110 | then throw("L'articolo che vuoi votare non esiste") | |
111 | 111 | else if (if ((status != NONE)) | |
112 | 112 | then (status != VOTING) | |
113 | 113 | else false) | |
114 | - | then throw("Votazione non possibile") | |
114 | + | then throw(("Votazione non possibile " + status)) | |
115 | 115 | else { | |
116 | 116 | let newCommits = (commits + 1) | |
117 | 117 | WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), newCommits), DataEntry(getKeyItemStatus(item), if ((newCommits == VOTERS)) | |
118 | 118 | then REVEAL | |
119 | 119 | else VOTING)]) | |
120 | 120 | } | |
121 | 121 | } | |
122 | 122 | ||
123 | 123 | ||
124 | 124 | ||
125 | 125 | @Callable(i) | |
126 | 126 | func voteReveal (item,vote,salt) = { | |
127 | 127 | let user = toBase58String(i.caller.bytes) | |
128 | 128 | let status = getValueItemStatus(item) | |
129 | 129 | let newVoteCount = (getValueVoteCount(item, vote) + 1) | |
130 | 130 | if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user))) | |
131 | 131 | then throw("Reveal data is not valid") | |
132 | 132 | else if ((VOTERS > getValueCommitsCount(item))) | |
133 | 133 | then throw("Il numero massimo dei votanti non è stato raggiunto") | |
134 | 134 | else if ((getValueReveal(item, user) != NONE)) | |
135 | 135 | then throw("l'utente ha già partecipato alla votazione") | |
136 | 136 | else if (if ((status != REVEAL)) | |
137 | 137 | then (status != VOTING) | |
138 | 138 | else false) | |
139 | 139 | then throw("Stato errato") | |
140 | 140 | else if (if ((vote != FEATURED)) | |
141 | 141 | then (vote != DELISTED) | |
142 | 142 | else false) | |
143 | 143 | then throw("Voto errato") | |
144 | 144 | else if (if ((status == FEATURED)) | |
145 | 145 | then true | |
146 | 146 | else (status == DELISTED)) | |
147 | 147 | then throw("La votazione si è conclusa") | |
148 | 148 | else WriteSet([DataEntry(getKeyReveal(item, user), vote), DataEntry(getKeyVoteCount(item, vote), newVoteCount), DataEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM)) | |
149 | 149 | then VOTING | |
150 | 150 | else REVEAL)]) | |
151 | 151 | } | |
152 | 152 | ||
153 | 153 |
github/deemru/w8io/026f985 42.80 ms ◑