tx · 6xGLTZue8e9aXVLTqTWDWGotF94RJWK9F4YwWRoB7mms 3MxssetYXJfiGwzo9pqChsSwYj3tCYq5FFH: -0.00500000 Waves 2022.09.25 20:39 [2244975] smart account 3MxssetYXJfiGwzo9pqChsSwYj3tCYq5FFH > SELF 0.00000000 Waves
{ "type": 13, "id": "6xGLTZue8e9aXVLTqTWDWGotF94RJWK9F4YwWRoB7mms", "fee": 500000, "feeAssetId": null, "timestamp": 1664127581360, "version": 2, "chainId": 84, "sender": "3MxssetYXJfiGwzo9pqChsSwYj3tCYq5FFH", "senderPublicKey": "46sMMaC9rMPQdyTE87RpcnevTY9oheuDqzfnuQzoyCtv", "proofs": [ "4T8nxvtwLboxFmJAmnMXY4pjsgViHtgSoLCCF4ZYcuX8vFz6EHoG2e5eM4qYxvWuuytu4xCaYDSpojVBkXsSXhgL" ], "script": "base64:BgIkCAISBwoFAQEBAQESBAoCAQgSBQoDAQgBEgQKAgEYEgQKAgEYCwERZ2V0SW50ZWdlck9yVGhyb3cCB2FkZHJlc3MDa2V5CQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJoIAgUHYWRkcmVzcwUDa2V5CQCsAgIJAKwCAgkArAICAgxDYW4ndCByZWFkICcFA2tleQINJyBhdCBhZGRyZXNzIAkApQgBBQdhZGRyZXNzARNnZXRJbnRlZ2VyT3JEZWZhdWx0AwdhZGRyZXNzA2tleQdkZWZhdWx0CQELdmFsdWVPckVsc2UCCQCaCAIFB2FkZHJlc3MFA2tleQUHZGVmYXVsdAERcGFyc2VJbnRPckRlZmF1bHQCCG1heWJlSW50B2RlZmF1bHQJAQt2YWx1ZU9yRWxzZQIJALYJAQUIbWF5YmVJbnQFB2RlZmF1bHQACGF1Y1N0YXJ0CQERZ2V0SW50ZWdlck9yVGhyb3cCBQR0aGlzAg5pbml0X3RpbWVzdGFtcAALYmlkRHVyYXRpb24JARFnZXRJbnRlZ2VyT3JUaHJvdwIFBHRoaXMCDGJpZF9kdXJhdGlvbgAOcmV2Z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AwMDCQBmAgUJYmlkQW1vdW50BQx0b3BCaWRBbW91bnQJAGcCBQdkZXBvc2l0BQliaWRBbW91bnQHCQAAAgUJYXVjdGlvbklkBQx0b3BBdWN0aW9uSWQHCQDNCAIFCXJldmVhbEJpZAkBC1N0cmluZ0VudHJ5AgUGdG9wS2V5BQlyZXZlYWxLZXkFCXJldmVhbEJpZAMJAGcCBQdkZXBvc2l0BQliaWRBbW91bnQJAM0IAgUJcmV2ZWFsQmlkCQELU3RyaW5nRW50cnkCBQZ0b3BLZXkFCXJldmVhbEtleQUJcmV2ZWFsQmlkA2ludgEIZmluYWxpemUCCWF1Y3Rpb25JZAZoYXNoZXMEB2FkZHJlc3MIBQNpbnYGY2FsbGVyCQENd3JhcEZpbmFsbGl6ZQMFCWF1Y3Rpb25JZAUGaGFzaGVzBQdhZGRyZXNzA2ludgEOZmluYWxpemVPcmlnaW4CCWF1Y3Rpb25JZAZoYXNoZXMEB2FkZHJlc3MIBQNpbnYMb3JpZ2luQ2FsbGVyCQENd3JhcEZpbmFsbGl6ZQMFCWF1Y3Rpb25JZAUGaGFzaGVzBQdhZGRyZXNzAKPHFBc=", "height": 2244975, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: C6SMm233V6fiwz69ZX7nbYk3AdVXthZ8cFiMkoQYsgpb Next: D9r9AcdsTGQt4SjWSAktJsqH7D6bQLhy6BeHf534iYUn Diff:
Old | New | Differences | |
---|---|---|---|
45 | 45 | let revealKey = ("reveal_" + keyMainPart) | |
46 | 46 | let revealedBid = getString(this, revealKey) | |
47 | 47 | let $t018422137 = { | |
48 | - | let bidValues = split(valueOrErrorMessage(revealedBid, (("Bid with hash " + hash) + " not found")), " | |
48 | + | let bidValues = split(valueOrErrorMessage(revealedBid, (("Bid with hash " + hash) + " not found")), "_") | |
49 | 49 | $Tuple3(parseIntValue(bidValues[0]), parseIntValue(bidValues[1]), bidValues[2]) | |
50 | 50 | } | |
51 | 51 | let deposit = $t018422137._1 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func getIntegerOrThrow (address,key) = valueOrErrorMessage(getInteger(address, key), ((("Can't read '" + key) + "' at address ") + toString(address))) | |
5 | 5 | ||
6 | 6 | ||
7 | 7 | func getIntegerOrDefault (address,key,default) = valueOrElse(getInteger(address, key), default) | |
8 | 8 | ||
9 | 9 | ||
10 | 10 | func parseIntOrDefault (maybeInt,default) = valueOrElse(parseInt(maybeInt), default) | |
11 | 11 | ||
12 | 12 | ||
13 | 13 | let aucStart = getIntegerOrThrow(this, "init_timestamp") | |
14 | 14 | ||
15 | 15 | let bidDuration = getIntegerOrThrow(this, "bid_duration") | |
16 | 16 | ||
17 | 17 | let revealDuration = getIntegerOrThrow(this, "reveal_duration") | |
18 | 18 | ||
19 | 19 | let errorFee = getIntegerOrThrow(this, "error_fee") | |
20 | 20 | ||
21 | 21 | let minimalBid = getIntegerOrThrow(this, "minimal_bid") | |
22 | 22 | ||
23 | 23 | func calcAuctionData () = { | |
24 | 24 | let auctionDuration = (bidDuration + revealDuration) | |
25 | 25 | let currentAuctionId = ((lastBlock.timestamp - aucStart) / auctionDuration) | |
26 | 26 | let currentPeriodStart = ((currentAuctionId * auctionDuration) + aucStart) | |
27 | 27 | let currentAuctionTime = (lastBlock.timestamp - currentPeriodStart) | |
28 | 28 | let period = if ((currentAuctionTime > bidDuration)) | |
29 | 29 | then "reveal" | |
30 | 30 | else "bid" | |
31 | 31 | $Tuple2(currentAuctionId, period) | |
32 | 32 | } | |
33 | 33 | ||
34 | 34 | ||
35 | 35 | func calcHash (name,amount) = toBase58String(blake2b256_16Kb(keccak256_16Kb((toBytes(name) + toBytes(amount))))) | |
36 | 36 | ||
37 | 37 | ||
38 | 38 | func wrapFinallize (auctionId,hashes,address) = { | |
39 | 39 | let addressStr = toString(address) | |
40 | 40 | let indices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
41 | 41 | func foldRefund (acc,index) = { | |
42 | 42 | let hash = hashes[index] | |
43 | 43 | let keyMainPart = ((((toString(auctionId) + "_") + addressStr) + "_") + hash) | |
44 | 44 | let bidKey = ("bid_" + keyMainPart) | |
45 | 45 | let revealKey = ("reveal_" + keyMainPart) | |
46 | 46 | let revealedBid = getString(this, revealKey) | |
47 | 47 | let $t018422137 = { | |
48 | - | let bidValues = split(valueOrErrorMessage(revealedBid, (("Bid with hash " + hash) + " not found")), " | |
48 | + | let bidValues = split(valueOrErrorMessage(revealedBid, (("Bid with hash " + hash) + " not found")), "_") | |
49 | 49 | $Tuple3(parseIntValue(bidValues[0]), parseIntValue(bidValues[1]), bidValues[2]) | |
50 | 50 | } | |
51 | 51 | let deposit = $t018422137._1 | |
52 | 52 | let bid = $t018422137._2 | |
53 | 53 | let name = $t018422137._3 | |
54 | 54 | let topKey = ("top_" + name) | |
55 | 55 | let winnerLink = valueOrErrorMessage(getString(this, topKey), "Auction winner has not been determined") | |
56 | 56 | let winnerAuctionId = parseIntValue(split(winnerLink, "_")[1]) | |
57 | 57 | let refundAmont = if (if ((bid > deposit)) | |
58 | 58 | then true | |
59 | 59 | else (winnerAuctionId != auctionId)) | |
60 | 60 | then (deposit - fraction(deposit, 10, 100)) | |
61 | 61 | else if ((winnerLink == revealKey)) | |
62 | 62 | then (deposit - bid) | |
63 | 63 | else deposit | |
64 | 64 | let result = [DeleteEntry(revealKey), DeleteEntry(bidKey), ScriptTransfer(address, refundAmont, unit)] | |
65 | 65 | (acc ++ result) | |
66 | 66 | } | |
67 | 67 | ||
68 | 68 | let $l = indices | |
69 | 69 | let $s = size($l) | |
70 | 70 | let $acc0 = nil | |
71 | 71 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
72 | 72 | then $a | |
73 | 73 | else foldRefund($a, $l[$i]) | |
74 | 74 | ||
75 | 75 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
76 | 76 | then $a | |
77 | 77 | else throw("List size exceeds 10") | |
78 | 78 | ||
79 | 79 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
80 | 80 | } | |
81 | 81 | ||
82 | 82 | ||
83 | 83 | @Callable(inv) | |
84 | 84 | func init (timestamp,bidDuration,revealDuration,errorFee,minimalBid) = if ((this != inv.caller)) | |
85 | 85 | then throw("only self calls are allowed") | |
86 | 86 | else [IntegerEntry("init_timestamp", timestamp), IntegerEntry("bid_duration", bidDuration), IntegerEntry("reveal_duration", revealDuration), IntegerEntry("error_fee", errorFee), IntegerEntry("minimal_bid", minimalBid)] | |
87 | 87 | ||
88 | 88 | ||
89 | 89 | ||
90 | 90 | @Callable(inv) | |
91 | 91 | func bid (auctionId,hash) = { | |
92 | 92 | let address = toString(inv.caller) | |
93 | 93 | let bidKey = ((((("bid_" + toString(auctionId)) + "_") + address) + "_") + hash) | |
94 | 94 | let pmt = if (if ((size(inv.payments) == 1)) | |
95 | 95 | then (inv.payments[0].assetId == unit) | |
96 | 96 | else false) | |
97 | 97 | then inv.payments[0].amount | |
98 | 98 | else throw("Single payment required") | |
99 | 99 | let $t036083665 = calcAuctionData() | |
100 | 100 | let currentAuctionId = $t036083665._1 | |
101 | 101 | let currentPeriod = $t036083665._2 | |
102 | 102 | if ((currentAuctionId != auctionId)) | |
103 | 103 | then throw("Auctions is already over") | |
104 | 104 | else if ((currentPeriod != "bid")) | |
105 | 105 | then throw("Bid period is over") | |
106 | 106 | else if (isDefined(getInteger(this, bidKey))) | |
107 | 107 | then throw("Bid with exact amount already presented") | |
108 | 108 | else [IntegerEntry(bidKey, pmt)] | |
109 | 109 | } | |
110 | 110 | ||
111 | 111 | ||
112 | 112 | ||
113 | 113 | @Callable(inv) | |
114 | 114 | func reveal (auctionId,name,bidAmount) = { | |
115 | 115 | let address = toString(inv.caller) | |
116 | 116 | let hash = calcHash(name, bidAmount) | |
117 | 117 | let keyMainPart = ((((toString(auctionId) + "_") + address) + "_") + hash) | |
118 | 118 | let revealKey = ("reveal_" + keyMainPart) | |
119 | 119 | let topKey = ("top_" + name) | |
120 | 120 | let deposit = valueOrErrorMessage(getInteger(this, ("bid_" + keyMainPart)), ("Bid doesn't exists " + hash)) | |
121 | 121 | let $t043874444 = calcAuctionData() | |
122 | 122 | let currentAuctionId = $t043874444._1 | |
123 | 123 | let currentPeriod = $t043874444._2 | |
124 | 124 | if ((currentAuctionId != auctionId)) | |
125 | 125 | then throw("Auctions is already over") | |
126 | 126 | else if ((currentPeriod != "reveal")) | |
127 | 127 | then throw("Reveal period is over") | |
128 | 128 | else if (isDefined(getString(this, revealKey))) | |
129 | 129 | then throw("Bid is already revealed") | |
130 | 130 | else { | |
131 | 131 | let revealBid = [StringEntry(revealKey, ((((toString(deposit) + ",") + toString(bidAmount)) + ",") + name))] | |
132 | 132 | let topBidderRevealKey = getString(this, topKey) | |
133 | 133 | if (isDefined(topBidderRevealKey)) | |
134 | 134 | then { | |
135 | 135 | let topBidderKey = value(topBidderRevealKey) | |
136 | 136 | let topBidderData = value(getString(this, topBidderKey)) | |
137 | 137 | let topBidAmount = parseIntValue(split(topBidderData, ",")[1]) | |
138 | 138 | let topAuctionId = parseIntValue(split(topBidderKey, "_")[1]) | |
139 | 139 | if (if (if ((bidAmount > topBidAmount)) | |
140 | 140 | then (deposit >= bidAmount) | |
141 | 141 | else false) | |
142 | 142 | then (auctionId == topAuctionId) | |
143 | 143 | else false) | |
144 | 144 | then (revealBid :+ StringEntry(topKey, revealKey)) | |
145 | 145 | else revealBid | |
146 | 146 | } | |
147 | 147 | else if ((deposit >= bidAmount)) | |
148 | 148 | then (revealBid :+ StringEntry(topKey, revealKey)) | |
149 | 149 | else revealBid | |
150 | 150 | } | |
151 | 151 | } | |
152 | 152 | ||
153 | 153 | ||
154 | 154 | ||
155 | 155 | @Callable(inv) | |
156 | 156 | func finalize (auctionId,hashes) = { | |
157 | 157 | let address = inv.caller | |
158 | 158 | wrapFinallize(auctionId, hashes, address) | |
159 | 159 | } | |
160 | 160 | ||
161 | 161 | ||
162 | 162 | ||
163 | 163 | @Callable(inv) | |
164 | 164 | func finalizeOrigin (auctionId,hashes) = { | |
165 | 165 | let address = inv.originCaller | |
166 | 166 | wrapFinallize(auctionId, hashes, address) | |
167 | 167 | } | |
168 | 168 | ||
169 | 169 |
github/deemru/w8io/fabc49c 67.52 ms ◑