tx · 77M4F3xd1aaD4vU7BA9neS5Cvu94uYyHSjVKwMeD3m65

3MshLEZwkjz17HtsouWjFBXrXkPBVBHD7gm:  -0.01200000 Waves

2022.07.11 14:20 [2135008] smart account 3MshLEZwkjz17HtsouWjFBXrXkPBVBHD7gm > SELF 0.00000000 Waves

{ "type": 13, "id": "77M4F3xd1aaD4vU7BA9neS5Cvu94uYyHSjVKwMeD3m65", "fee": 1200000, "feeAssetId": null, "timestamp": 1657538449939, "version": 2, "chainId": 84, "sender": "3MshLEZwkjz17HtsouWjFBXrXkPBVBHD7gm", "senderPublicKey": "CAYySFNuYSLU5jGWNBottZuyHbvGh2JxucGYSXF3aEi8", "proofs": [ "3LxAHUT8ZtN9Fsnjtdu2Cwf2pLcaGit4KYKxj5KcydWRmbuqK9XmCyJEWh9nZVArP2y3xzDH2LL8U8AhHLpdMa2o" ], "script": "base64:AAIFAAAAAAAAABIIAhIDCgEIEgMKAQESBAoCAQEAAAAHAAAAAAlzZXBhcmF0b3ICAAAAAV8AAAAAD3NlY29uZFNlcGFyYXRvcgIAAAABLwEAAAAWZ2V0QWRkclRvSW50TWFwcGluZ0tleQAAAAIAAAALbWFwcGluZ05hbWUAAAAEYWRkcgkABLkAAAACCQAETAAAAAIFAAAAC21hcHBpbmdOYW1lCQAETAAAAAIFAAAABGFkZHIFAAAAA25pbAUAAAAJc2VwYXJhdG9yAQAAAA9nZXRMaXN0T2ZBcnJheXMAAAACAAAAC21hcHBpbmdOYW1lAAAABGFkZHIJAAS1AAAAAgkBAAAAEUBleHRyTmF0aXZlKDEwNTMpAAAAAgUAAAAEdGhpcwkBAAAAFmdldEFkZHJUb0ludE1hcHBpbmdLZXkAAAACBQAAAAttYXBwaW5nTmFtZQUAAAAEYWRkcgUAAAAJc2VwYXJhdG9yAQAAABhnZXRBZGRyVG9JbnRNYXBwaW5nSW5kZXgAAAACAAAAC21hcHBpbmdOYW1lAAAABGFkZHIJAAGQAAAAAQkBAAAAD2dldExpc3RPZkFycmF5c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yb21BcnJheQAAAAIAAAAFaW5kZXgAAAAHaW5kZXhJbgMJAABnAAAAAgkBAAAAGmdldEFkZHJUb0ludE1hcHBpbmdJbmRleEluAAAAAQUAAAAHaW5kZXhJbgUAAAAHaW5kZXhJbgkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACAgAAAAEyCQABkQAAAAIJAAS1AAAAAgkAAZEAAAACCQEAAAAPZ2V0TGlzdE9mQXJyYXlzAAAAAgIAAAAJbWFwU3RyaW5nCQAEJQAAAAEFAAAABHRoaXMFAAAABWluZGV4BQAAAA9zZWNvbmRTZXBhcmF0b3IFAAAAB2luZGV4SW4FAAAAA25pbAkAAAIAAAABAgAAAAxvdXQgb2YgcmFuZ2UAAAAAWU7fiw==", "height": 2135008, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7Aq7YAn6AevxDSbPRVDsmtHgjZrFdhAb91AyJFPRiodJ Next: ArtvRdD4ygeUSfEYV1BSsBQmKTQ6Z9tX5TnhZgJU6uXy Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let tokenId = base58'CPtoken'
5-
6-let multiplier = 10
7-
8-let amountGetTokens = 1000000
9-
104 let separator = "_"
115
12-func getWhiteListKey (addr) = makeString(["wl", addr], separator)
6+let secondSeparator = "/"
7+
8+func getAddrToIntMappingKey (mappingName,addr) = makeString([mappingName, addr], separator)
139
1410
15-func getWhiteListValue (addr) = getBooleanValue(this, getWhiteListKey(addr))
11+func getListOfArrays (mappingName,addr) = split(getStringValue(this, getAddrToIntMappingKey(mappingName, addr)), separator)
1612
1713
18-func getBlackListKey (addr) = makeString(["bl", addr], separator)
14+func getAddrToIntMappingIndex (mappingName,addr) = size(getListOfArrays("mapString", addr))
1915
2016
21-func getBlackListValue (addr) = valueOrElse(getBoolean(this, getBlackListKey(addr)), false)
17+func getAddrToIntMappingIndexIn (indexIn) = size(split(getListOfArrays("mapString", toString(this))[indexIn], secondSeparator))
2218
2319
24-func getTicketKey (addr) = makeString(["ticket", addr], separator)
25-
26-
27-func getTicketValue (addr) = getBinaryValue(this, getTicketKey(addr))
28-
29-
30-func getItemPriceKey (itemId) = makeString(["item", itemId], separator)
31-
32-
33-func getItemPriceValue (itemId) = getIntegerValue(this, getItemPriceKey(itemId))
34-
35-
36-func getVotingDetailsKey (votingId) = makeString(["votingDetails", votingId], separator)
37-
38-
39-func getItemSoldKey (itemId) = makeString(["sold", "item", itemId], separator)
40-
41-
42-func getVotingEndKey (votingId) = makeString(["votingEnd", votingId], separator)
43-
44-
45-func getVotingEndValue (votingId) = getIntegerValue(this, getVotingEndKey(votingId))
46-
47-
48-func getVotingVariantKey (votingId,variant) = makeString(["votingId", votingId, "variant", toString(variant)], separator)
49-
50-
51-func getVotingVariantValue (votingId,variant) = getIntegerValue(this, getVotingVariantKey(votingId, variant))
52-
53-
54-func getVoterKey (votingId,voterAddr) = makeString(["votingId", votingId, voterAddr], separator)
55-
56-
57-func isAdmin (sender) = {
58- let admin = getString(this, "admin")
59- if (!(isDefined(admin)))
60- then throw("init first")
61- else (addressFromPublicKey(fromBase58String(value(admin))) == sender)
62- }
63-
64-
65-func isEndOfVoting (votingId) = {
66- let now = value(blockInfoByHeight(height)).timestamp
67- let end = getVotingEndValue(votingId)
68- (now >= end)
69- }
70-
71-
72-func isCorrectVoter (votingId,caller) = !(isDefined(getBoolean(this, getVoterKey(votingId, toString(caller)))))
73-
74-
75-func isBlackListed (caller) = getBlackListValue(toString(caller))
76-
77-
78-func calcVotesAmount (votingId,caller,attachment) = {
79- let ticket = getTicketValue(toString(caller))
80- let attachmentAssetId = value(attachment.assetId)
81- if ((ticket == attachmentAssetId))
82- then {
83- let callerBalance = (assetBalance(caller, tokenId) * multiplier)
84- $Tuple4(callerBalance, Burn(value(attachment.assetId), 1), DeleteEntry(getTicketKey(toString(caller))), BooleanEntry(getVoterKey(votingId, toString(caller)), true))
85- }
86- else throw("Wrong attachment asset")
87- }
20+func setAddrToIntMappingValue (mappingName,addr,val) = if ((150 >= size(val)))
21+ then StringEntry(getAddrToIntMappingKey("mapString", addr), val)
22+ else throw("overcrowded")
8823
8924
9025 @Callable(i)
91-func init (pk) = {
92- let admin = getString(this, "admin")
93- if (!(isDefined(admin)))
94- then if ((i.caller == this))
95- then [StringEntry("admin", pk)]
96- else throw("Only admin")
97- else throw("Already inited")
98- }
26+func setStruct (valueInt) = [setAddrToIntMappingValue("mapString", toString(this), valueInt)]
9927
10028
10129
10230 @Callable(i)
103-func startVoting (votingId,votingDesc,period) = if (isAdmin(i.caller))
104- then {
105- let now = value(blockInfoByHeight(height)).timestamp
106-[StringEntry(getVotingDetailsKey(votingId), votingDesc), IntegerEntry(getVotingEndKey(votingId), (now + period)), IntegerEntry(getVotingVariantKey(votingId, 1), 0), IntegerEntry(getVotingVariantKey(votingId, 2), 0), IntegerEntry(getVotingVariantKey(votingId, 3), 0)]
107- }
108- else throw("Only admin")
31+func getArrayFromStruct (index) = if ((getAddrToIntMappingIndex("mapString", toString(this)) >= index))
32+ then [StringEntry("1", getListOfArrays("mapString", toString(this))[index])]
33+ else throw("out of range")
10934
11035
11136
11237 @Callable(i)
113-func issueNft (recipient) = if (if (isAdmin(i.caller))
114- then !(isBlackListed(addressFromStringValue(recipient)))
115- else false)
116- then {
117- let ticketKey = getTicketKey(recipient)
118- if (!(isDefined(getBinary(this, ticketKey))))
119- then {
120- let issue = Issue("Ticket", "Multiplier for voting", 1, 0, false)
121- let id = calculateAssetId(issue)
122-[issue, ScriptTransfer(addressFromStringValue(recipient), 1, id), BinaryEntry(ticketKey, id)]
123- }
124- else throw("Already granted")
125- }
126- else throw("Only admin")
38+func getElementFromArray (index,indexIn) = if ((getAddrToIntMappingIndexIn(indexIn) >= indexIn))
39+ then [StringEntry("2", split(getListOfArrays("mapString", toString(this))[index], secondSeparator)[indexIn])]
40+ else throw("out of range")
12741
128-
129-
130-@Callable(i)
131-func getTokens () = {
132- let key = getWhiteListKey(toString(i.caller))
133- let granted = getWhiteListValue(toString(i.caller))
134- if (!(granted))
135- then [BooleanEntry(key, true), ScriptTransfer(i.caller, amountGetTokens, tokenId)]
136- else throw("Already got")
137- }
138-
139-
140-
141-@Callable(i)
142-func vote (votingId,variant) = if (!(isEndOfVoting(votingId)))
143- then if (isCorrectVoter(votingId, i.caller))
144- then {
145- let votingKey = getVotingVariantKey(votingId, variant)
146- let counter = getVotingVariantValue(votingId, variant)
147- let blackListKey = getBlackListKey(toString(i.caller))
148- if ((size(i.payments) != 1))
149- then {
150- let callerBalance = assetBalance(i.caller, tokenId)
151-[BooleanEntry(blackListKey, false), BooleanEntry(getVoterKey(votingId, toString(i.caller)), true), IntegerEntry(votingKey, (counter + callerBalance))]
152- }
153- else {
154- let $t051845274 = calcVotesAmount(votingId, i.caller, i.payments[0])
155- let voteAmount = $t051845274._1
156- let burn = $t051845274._2
157- let clear = $t051845274._3
158- let record = $t051845274._4
159-[burn, clear, record, BooleanEntry(blackListKey, false), IntegerEntry(votingKey, (counter + voteAmount))]
160- }
161- }
162- else throw("Invalid voter")
163- else throw("Voting is ended")
164-
165-
166-
167-@Callable(i)
168-func joinProgram (patron) = {
169- let validPatron = getWhiteListValue(patron)
170- if (if (validPatron)
171- then !(isBlackListed(i.caller))
172- else false)
173- then {
174- let key = getWhiteListKey(toString(i.caller))
175- let patronKey = getWhiteListKey(patron)
176- let slot = getBoolean(this, key)
177- if (!(isDefined(slot)))
178- then [BooleanEntry(key, true), BooleanEntry(patronKey, false), ScriptTransfer(i.caller, amountGetTokens, tokenId)]
179- else throw("Already in program")
180- }
181- else throw("Wrong patron or caller from blackList")
182- }
183-
184-
185-
186-@Callable(i)
187-func buyItem (itemId) = if (!(isBlackListed(i.caller)))
188- then {
189- let pmt = i.payments[0]
190- let amount = pmt.amount
191- let price = getItemPriceValue(itemId)
192- if (if ((value(pmt.assetId) == tokenId))
193- then (price == amount)
194- else false)
195- then [Burn(tokenId, amount), StringEntry(getItemSoldKey(itemId), toString(i.caller))]
196- else throw("Wrong payment assetId")
197- }
198- else throw("Caller from blackList")
199-
200-
201-@Verifier(tx)
202-func verify () = match tx {
203- case dtx: DataTransaction =>
204- if (!(isDefined(getString(dtx.data, "admin"))))
205- then sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(getStringValue(this, "admin")))
206- else false
207- case mtx: MassTransferTransaction =>
208- sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(getStringValue(this, "admin")))
209- case _ =>
210- sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
211-}
21242

github/deemru/w8io/026f985 
364.17 ms