tx · 4XamF6khEMBHypq4b3rWsPUNDyhp5gT1wVJkmthEgqv9 3MxssetYXJfiGwzo9pqChsSwYj3tCYq5FFH: -0.00400000 Waves 2022.09.25 16:53 [2244753] smart account 3MxssetYXJfiGwzo9pqChsSwYj3tCYq5FFH > SELF 0.00000000 Waves
{ "type": 13, "id": "4XamF6khEMBHypq4b3rWsPUNDyhp5gT1wVJkmthEgqv9", "fee": 400000, "feeAssetId": null, "timestamp": 1664114035770, "version": 2, "chainId": 84, "sender": "3MxssetYXJfiGwzo9pqChsSwYj3tCYq5FFH", "senderPublicKey": "46sMMaC9rMPQdyTE87RpcnevTY9oheuDqzfnuQzoyCtv", "proofs": [ "4shpQQ8PLQe7QQrCwzyFLGnR4dmh6ha16xC4aLDZpNhtM5q1x5GD8yE7JBn9As2Uv7KjRU7KwfF3LRSbDjwNnHAk" ], "script": "base64:BgIYCAISBwoFAQEBAQESBAoCAQgSBQoDAQgBCgERZ2V0SW50ZWdlck9yVGhyb3cCB2FkZHJlc3MDa2V5CQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJoIAgUHYWRkcmVzcwUDa2V5CQCsAgIJAKwCAgkArAICAgxDYW4ndCByZWFkICcFA2tleQINJyBhdCBhZGRyZXNzIAkApQgBBQdhZGRyZXNzARNnZXRJbnRlZ2VyT3JEZWZhdWx0AwdhZGRyZXNzA2tleQdkZWZhdWx0CQELdmFsdWVPckVsc2UCCQCaCAIFB2FkZHJlc3MFA2tleQUHZGVmYXVsdAERcGFyc2VJbnRPckRlZmF1bHQCCG1heWJlSW50B2RlZmF1bHQJAQt2YWx1ZU9yRWxzZQIJALYJAQUIbWF5YmVJbnQFB2RlZmF1bHQACGF1Y1N0YXJ0CQERZ2V0SW50ZWdlck9yVGhyb3cCBQR0aGlzAg5pbml0X3RpbWVzdGFtcAALYmlkRHVyYXRpb24JARFnZXRJbnRlZ2VyT3JUaHJvdwIFBHRoaXMCDGJpZF9kdXJhdGlvbgAOcmV2ZWFsRHVyYXRpb24J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YWx1ZQEJAJ0IAgUEdGhpcwkBBXZhbHVlAQUSdG9wQmlkZGVyUmV2ZWFsS2V5BAx0b3BCaWRBbW91bnQJAQ1wYXJzZUludFZhbHVlAQkAkQMCCQC1CQIFDXRvcEJpZGRlckRhdGECASwAAQMDCQBmAgUJYmlkQW1vdW50BQx0b3BCaWRBbW91bnQJAGcCBQdkZXBvc2l0BQliaWRBbW91bnQHCQDNCAIFCXJldmVhbEJpZAkBC1N0cmluZ0VudHJ5AgUGdG9wS2V5BQlyZXZlYWxLZXkFCXJldmVhbEJpZAkAzQgCBQlyZXZlYWxCaWQJAQtTdHJpbmdFbnRyeQIFBnRvcEtleQUJcmV2ZWFsS2V5ALc7Jnk=", "height": 2244753, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DjNupLd74zpzo19usda4tfG3rAEAo1eNw6DDKj5orhag Next: 9wjTV58BXSA33YMHQzzcEzFiKfMKzJW7RwfK4iNzwJhH Diff:
Old | New | Differences | |
---|---|---|---|
72 | 72 | let keyMainPart = ((((toString(auctionId) + "_") + address) + "_") + hash) | |
73 | 73 | let revealKey = ("reveal_" + keyMainPart) | |
74 | 74 | let topKey = ((("top_" + toString(auctionId)) + "_") + name) | |
75 | - | let deposit = valueOrErrorMessage(getInteger(this, ("bid_" + keyMainPart)), ("Bid doesn't exists" + hash)) | |
76 | - | let $ | |
77 | - | let currentAuctionId = $ | |
78 | - | let currentPeriod = $ | |
75 | + | let deposit = valueOrErrorMessage(getInteger(this, ("bid_" + keyMainPart)), ("Bid doesn't exists " + hash)) | |
76 | + | let $t029192976 = calcAuctionData() | |
77 | + | let currentAuctionId = $t029192976._1 | |
78 | + | let currentPeriod = $t029192976._2 | |
79 | 79 | if ((currentAuctionId != auctionId)) | |
80 | 80 | then throw("Auctions is already over") | |
81 | 81 | else if ((currentPeriod != "reveal")) |
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 | @Callable(inv) | |
39 | 39 | func init (timestamp,bidDuration,revealDuration,errorFee,minimalBid) = if ((this != inv.caller)) | |
40 | 40 | then throw("only self calls are allowed") | |
41 | 41 | else [IntegerEntry("init_timestamp", timestamp), IntegerEntry("bid_duration", bidDuration), IntegerEntry("reveal_duration", revealDuration), IntegerEntry("error_fee", errorFee), IntegerEntry("minimal_bid", minimalBid)] | |
42 | 42 | ||
43 | 43 | ||
44 | 44 | ||
45 | 45 | @Callable(inv) | |
46 | 46 | func bid (auctionId,hash) = { | |
47 | 47 | let address = toString(inv.caller) | |
48 | 48 | let bidKey = ((((("bid_" + toString(auctionId)) + "_") + address) + "_") + hash) | |
49 | 49 | let pmt = if (if ((size(inv.payments) == 1)) | |
50 | 50 | then (inv.payments[0].assetId == unit) | |
51 | 51 | else false) | |
52 | 52 | then inv.payments[0].amount | |
53 | 53 | else throw("Single payment required") | |
54 | 54 | let $t021152172 = calcAuctionData() | |
55 | 55 | let currentAuctionId = $t021152172._1 | |
56 | 56 | let currentPeriod = $t021152172._2 | |
57 | 57 | if ((currentAuctionId != auctionId)) | |
58 | 58 | then throw("Auctions is already over") | |
59 | 59 | else if ((currentPeriod != "bid")) | |
60 | 60 | then throw("Bid period is over") | |
61 | 61 | else if (isDefined(getInteger(this, bidKey))) | |
62 | 62 | then throw("Bid with exact amount already presented") | |
63 | 63 | else [IntegerEntry(bidKey, pmt)] | |
64 | 64 | } | |
65 | 65 | ||
66 | 66 | ||
67 | 67 | ||
68 | 68 | @Callable(inv) | |
69 | 69 | func reveal (auctionId,name,bidAmount) = { | |
70 | 70 | let address = toString(inv.caller) | |
71 | 71 | let hash = calcHash(name, bidAmount) | |
72 | 72 | let keyMainPart = ((((toString(auctionId) + "_") + address) + "_") + hash) | |
73 | 73 | let revealKey = ("reveal_" + keyMainPart) | |
74 | 74 | let topKey = ((("top_" + toString(auctionId)) + "_") + name) | |
75 | - | let deposit = valueOrErrorMessage(getInteger(this, ("bid_" + keyMainPart)), ("Bid doesn't exists" + hash)) | |
76 | - | let $ | |
77 | - | let currentAuctionId = $ | |
78 | - | let currentPeriod = $ | |
75 | + | let deposit = valueOrErrorMessage(getInteger(this, ("bid_" + keyMainPart)), ("Bid doesn't exists " + hash)) | |
76 | + | let $t029192976 = calcAuctionData() | |
77 | + | let currentAuctionId = $t029192976._1 | |
78 | + | let currentPeriod = $t029192976._2 | |
79 | 79 | if ((currentAuctionId != auctionId)) | |
80 | 80 | then throw("Auctions is already over") | |
81 | 81 | else if ((currentPeriod != "reveal")) | |
82 | 82 | then throw("Reveal period is over") | |
83 | 83 | else if (isDefined(getString(this, revealKey))) | |
84 | 84 | then throw("Bid is already revealed") | |
85 | 85 | else { | |
86 | 86 | let revealBid = [StringEntry(revealKey, ((((toString(deposit) + ",") + toString(bidAmount)) + ",") + name))] | |
87 | 87 | let topBidderRevealKey = getString(this, topKey) | |
88 | 88 | if (isDefined(topBidderRevealKey)) | |
89 | 89 | then { | |
90 | 90 | let topBidderData = value(getString(this, value(topBidderRevealKey))) | |
91 | 91 | let topBidAmount = parseIntValue(split(topBidderData, ",")[1]) | |
92 | 92 | if (if ((bidAmount > topBidAmount)) | |
93 | 93 | then (deposit >= bidAmount) | |
94 | 94 | else false) | |
95 | 95 | then (revealBid :+ StringEntry(topKey, revealKey)) | |
96 | 96 | else revealBid | |
97 | 97 | } | |
98 | 98 | else (revealBid :+ StringEntry(topKey, revealKey)) | |
99 | 99 | } | |
100 | 100 | } | |
101 | 101 | ||
102 | 102 |
github/deemru/w8io/169f3d6 41.80 ms ◑