tx · 7XriJkRMmLnsPcv5Zc78Q9KGZoFDFY1YiFkvZjxkQvy6 3MzFjVphaDKp1oZjd5KmCYou3wCzCzTmEFe: -0.00700000 Waves 2022.09.28 16:16 [2249013] smart account 3MzFjVphaDKp1oZjd5KmCYou3wCzCzTmEFe > SELF 0.00000000 Waves
{ "type": 13, "id": "7XriJkRMmLnsPcv5Zc78Q9KGZoFDFY1YiFkvZjxkQvy6", "fee": 700000, "feeAssetId": null, "timestamp": 1664370984342, "version": 2, "chainId": 84, "sender": "3MzFjVphaDKp1oZjd5KmCYou3wCzCzTmEFe", "senderPublicKey": "FFVf3kC6HkjRMmf8W6Zr2bNKhJ5EN5W1vG44GbgvHd9Z", "proofs": [ "5ks3BVquihFkbBLCLLC26caM2bbFmwvce8ccMMSXfjwjvSWqxG81vdF9Vam2pBMhMERnqq2D7YQFoq5xgJn2uXD4" ], "script": "base64:AAIDAAAAAAAAAB8IARIDCgEIEgUKAwgBCBIAEgQKAggIEgUKAwgICBIAAAAAHgAAAAAETk9ORQIAAAAEbm9uZQAAAAAGd2F2ZWluAQAAACBLhiHTf+rXkwiBnk1C0Lx5Vb91PWJg6NhmCwWOSYBbuAEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAAAC2dldFN0ckJ5S2V5AAAAAQAAAANrZXkEAAAAA3N0cgQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQUAAAAETk9ORQUAAAADc3RyAQAAAA9nZXRLZXlJdGVtUHJpY2UAAAABAAAABGl0ZW0JAAEsAAAAAgUA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EwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAD2dldEtleVZvdGVDb3VudAAAAAIFAAAABGl0ZW0FAAAABHZvdGUFAAAADG5ld1ZvdGVDb3VudAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAEGdldEtleUl0ZW1TdGF0dXMAAAABBQAAAARpdGVtAwkAAGcAAAACBQAAAAxuZXdWb3RlQ291bnQFAAAABVFPUlVNBQAAAAR2b3RlBQAAAAZSRVZFQUwFAAAAA25pbAAAAAFpAQAAAAdkZXBvc2l0AAAAAAQAAAADcG10CQEAAAAHZXh0cmFjdAAAAAEIBQAAAAFpAAAAB3BheW1lbnQDCQEAAAACIT0AAAACCAUAAAADcG10AAAAB2Fzc2V0SWQFAAAABndhdmVpbgkAAAIAAAABAgAAACJTb3JyeSwgb25seSBXQVZXRUlOIGZvciB0aGUgbW9tZW50BAAAAApjdXJyZW50S2V5CQACWAAAAAEICAUAAAABaQAAAAZjYWxsZXIAAAAFYnl0ZXMEAAAADWN1cnJlbnRBbW91bnQEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAAKY3VycmVudEtleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABAAAAAluZXdBbW91bnQJAABkAAAAAgUAAAANY3VycmVudEFtb3VudAgFAAAAA3BtdAAAAAZhbW91bnQJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAACmN1cnJlbnRLZXkFAAAACW5ld0Ftb3VudAUAAAADbmlsAAAAAASW+dQ=", "height": 2249013, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9XdLjo5eNnZaZQ8VUQAX1Tu3dgabPUc7HrJyPhRWuYCS Next: none Diff:
Old | New | Differences | |
---|---|---|---|
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let NONE = "none" | |
5 | + | ||
6 | + | let wavein = base58'65pCrqjE5ZYunnfcodoG1mG1Kk26DNp7raSSSN1mwDAF' | |
5 | 7 | ||
6 | 8 | func getNumberByKey (key) = { | |
7 | 9 | let num = match getInteger(this, key) { | |
191 | 193 | } | |
192 | 194 | ||
193 | 195 | ||
196 | + | ||
197 | + | @Callable(i) | |
198 | + | func deposit () = { | |
199 | + | let pmt = extract(i.payment) | |
200 | + | if ((pmt.assetId != wavein)) | |
201 | + | then throw("Sorry, only WAVWEIN for the moment") | |
202 | + | else { | |
203 | + | let currentKey = toBase58String(i.caller.bytes) | |
204 | + | let currentAmount = match getInteger(this, currentKey) { | |
205 | + | case a: Int => | |
206 | + | a | |
207 | + | case _ => | |
208 | + | 0 | |
209 | + | } | |
210 | + | let newAmount = (currentAmount + pmt.amount) | |
211 | + | WriteSet([DataEntry(currentKey, newAmount)]) | |
212 | + | } | |
213 | + | } | |
214 | + | ||
215 | + |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let NONE = "none" | |
5 | + | ||
6 | + | let wavein = base58'65pCrqjE5ZYunnfcodoG1mG1Kk26DNp7raSSSN1mwDAF' | |
5 | 7 | ||
6 | 8 | func getNumberByKey (key) = { | |
7 | 9 | let num = match getInteger(this, key) { | |
8 | 10 | case a: Int => | |
9 | 11 | a | |
10 | 12 | case _ => | |
11 | 13 | 0 | |
12 | 14 | } | |
13 | 15 | num | |
14 | 16 | } | |
15 | 17 | ||
16 | 18 | ||
17 | 19 | func getStrByKey (key) = { | |
18 | 20 | let str = match getString(this, key) { | |
19 | 21 | case a: String => | |
20 | 22 | a | |
21 | 23 | case _ => | |
22 | 24 | NONE | |
23 | 25 | } | |
24 | 26 | str | |
25 | 27 | } | |
26 | 28 | ||
27 | 29 | ||
28 | 30 | func getKeyItemPrice (item) = (item + "_price") | |
29 | 31 | ||
30 | 32 | ||
31 | 33 | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
32 | 34 | ||
33 | 35 | ||
34 | 36 | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
35 | 37 | ||
36 | 38 | ||
37 | 39 | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
38 | 40 | ||
39 | 41 | ||
40 | 42 | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
41 | 43 | ||
42 | 44 | ||
43 | 45 | func getKeyItemData (item) = (item + "_data") | |
44 | 46 | ||
45 | 47 | ||
46 | 48 | func getKeyItemSupplier (item) = (item + "_owner") | |
47 | 49 | ||
48 | 50 | ||
49 | 51 | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
50 | 52 | ||
51 | 53 | ||
52 | 54 | func getKeyBalanceSupplier (account) = (account + "_balance") | |
53 | 55 | ||
54 | 56 | ||
55 | 57 | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
56 | 58 | ||
57 | 59 | ||
58 | 60 | let VOTERS = 3 | |
59 | 61 | ||
60 | 62 | let QORUM = 2 | |
61 | 63 | ||
62 | 64 | let VOTING = "voting" | |
63 | 65 | ||
64 | 66 | let REVEAL = "reveal" | |
65 | 67 | ||
66 | 68 | let FEATURED = "featured" | |
67 | 69 | ||
68 | 70 | let DELISTED = "delisted" | |
69 | 71 | ||
70 | 72 | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
71 | 73 | ||
72 | 74 | ||
73 | 75 | func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user)) | |
74 | 76 | ||
75 | 77 | ||
76 | 78 | func getKeyCommitsCount (item) = (item + "_comcnt") | |
77 | 79 | ||
78 | 80 | ||
79 | 81 | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
80 | 82 | ||
81 | 83 | ||
82 | 84 | func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal") | |
83 | 85 | ||
84 | 86 | ||
85 | 87 | func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user)) | |
86 | 88 | ||
87 | 89 | ||
88 | 90 | func getKeyItemStatus (item) = (item + "_status") | |
89 | 91 | ||
90 | 92 | ||
91 | 93 | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
92 | 94 | ||
93 | 95 | ||
94 | 96 | func getKeyVoteCount (item,vote) = ((item + "_res:") + vote) | |
95 | 97 | ||
96 | 98 | ||
97 | 99 | func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote)) | |
98 | 100 | ||
99 | 101 | ||
100 | 102 | @Callable(i) | |
101 | 103 | func purchase (item) = { | |
102 | 104 | let pmt = extract(i.payment) | |
103 | 105 | if (isDefined(pmt.assetId)) | |
104 | 106 | then throw("can use WAVES only at the moment") | |
105 | 107 | else { | |
106 | 108 | let userAddress = toBase58String(i.caller.bytes) | |
107 | 109 | let price = getValueItemPrice(item) | |
108 | 110 | let supplierAddress = getValueItemSupplier(item) | |
109 | 111 | if ((pmt.amount != price)) | |
110 | 112 | then throw("Purchase amount should be equal to price ") | |
111 | 113 | else if ((supplierAddress == NONE)) | |
112 | 114 | then throw("The supplier does not exist") | |
113 | 115 | else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))]) | |
114 | 116 | } | |
115 | 117 | } | |
116 | 118 | ||
117 | 119 | ||
118 | 120 | ||
119 | 121 | @Callable(i) | |
120 | 122 | func addItem (title,price,data) = { | |
121 | 123 | let supplierAddress = toBase58String(i.caller.bytes) | |
122 | 124 | let item = getKeyItem(supplierAddress, title) | |
123 | 125 | if ((0 >= price)) | |
124 | 126 | then throw("purchase cannot be less than the item price") | |
125 | 127 | else if ((getValueItemSupplier(item) != NONE)) | |
126 | 128 | then throw("The item already exitsts") | |
127 | 129 | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) | |
128 | 130 | } | |
129 | 131 | ||
130 | 132 | ||
131 | 133 | ||
132 | 134 | @Callable(i) | |
133 | 135 | func withdraw () = { | |
134 | 136 | let supplierAddress = toBase58String(i.caller.bytes) | |
135 | 137 | let balance = getValueBalanceSupplier(supplierAddress) | |
136 | 138 | if ((0 >= balance)) | |
137 | 139 | then throw("insufficeient balance") | |
138 | 140 | else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)])) | |
139 | 141 | } | |
140 | 142 | ||
141 | 143 | ||
142 | 144 | ||
143 | 145 | @Callable(i) | |
144 | 146 | func voteCommit (item,hash) = { | |
145 | 147 | let user = toBase58String(i.caller.bytes) | |
146 | 148 | let commits = getValueCommitsCount(item) | |
147 | 149 | let status = getValueItemStatus(item) | |
148 | 150 | if ((commits >= VOTERS)) | |
149 | 151 | then throw("reached max num of voters") | |
150 | 152 | else if ((getValueCommit(item, user) != NONE)) | |
151 | 153 | then throw("The user has participated already") | |
152 | 154 | else if ((getKeyItemSupplier(item) == NONE)) | |
153 | 155 | then throw("item does not exist") | |
154 | 156 | else if (if ((status != NONE)) | |
155 | 157 | then (status != VOTING) | |
156 | 158 | else false) | |
157 | 159 | then throw("voting is not possible") | |
158 | 160 | else WriteSet([DataEntry(getKeyCommit(item, user), hash), DataEntry(getKeyCommitsCount(item), (commits + 1)), DataEntry(getKeyItemStatus(item), if ((commits == VOTERS)) | |
159 | 161 | then REVEAL | |
160 | 162 | else VOTING)]) | |
161 | 163 | } | |
162 | 164 | ||
163 | 165 | ||
164 | 166 | ||
165 | 167 | @Callable(i) | |
166 | 168 | func voteReveal (item,vote,salt) = { | |
167 | 169 | let user = toBase58String(i.caller.bytes) | |
168 | 170 | let status = getValueItemStatus(item) | |
169 | 171 | let newVoteCount = (getValueVoteCount(item, vote) + 1) | |
170 | 172 | if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user))) | |
171 | 173 | then throw("reveal data is not valid") | |
172 | 174 | else if ((VOTERS > getValueCommitsCount(item))) | |
173 | 175 | then throw("max num of voters hasn't reached yet") | |
174 | 176 | else if ((getValueReveal(item, user) != NONE)) | |
175 | 177 | then throw("the user has already participated") | |
176 | 178 | else if (if ((status != VOTING)) | |
177 | 179 | then (status != REVEAL) | |
178 | 180 | else false) | |
179 | 181 | then throw("Wrong status") | |
180 | 182 | else if (if ((vote != FEATURED)) | |
181 | 183 | then (vote != DELISTED) | |
182 | 184 | else false) | |
183 | 185 | then throw("wrong vote") | |
184 | 186 | else if (if ((status == FEATURED)) | |
185 | 187 | then true | |
186 | 188 | else (status == DELISTED)) | |
187 | 189 | then throw("vote has finished") | |
188 | 190 | else WriteSet([DataEntry(getKeyReveal(item, user), vote), DataEntry(getKeyVoteCount(item, vote), newVoteCount), DataEntry(getKeyItemStatus(item), if ((newVoteCount >= QORUM)) | |
189 | 191 | then vote | |
190 | 192 | else REVEAL)]) | |
191 | 193 | } | |
192 | 194 | ||
193 | 195 | ||
196 | + | ||
197 | + | @Callable(i) | |
198 | + | func deposit () = { | |
199 | + | let pmt = extract(i.payment) | |
200 | + | if ((pmt.assetId != wavein)) | |
201 | + | then throw("Sorry, only WAVWEIN for the moment") | |
202 | + | else { | |
203 | + | let currentKey = toBase58String(i.caller.bytes) | |
204 | + | let currentAmount = match getInteger(this, currentKey) { | |
205 | + | case a: Int => | |
206 | + | a | |
207 | + | case _ => | |
208 | + | 0 | |
209 | + | } | |
210 | + | let newAmount = (currentAmount + pmt.amount) | |
211 | + | WriteSet([DataEntry(currentKey, newAmount)]) | |
212 | + | } | |
213 | + | } | |
214 | + | ||
215 | + |
github/deemru/w8io/169f3d6 40.39 ms ◑