tx · 5X52GTmaLN6mJyxK7KqepaWvoNLAmP5zmgkhHf7HQn2J 3MvU8vDCk4NkA1Ag4vE3mETA4U9ioFh6VEM: -0.01500000 Waves 2019.12.14 10:43 [808255] smart account 3MvU8vDCk4NkA1Ag4vE3mETA4U9ioFh6VEM > SELF 0.00000000 Waves
{ "type": 13, "id": "5X52GTmaLN6mJyxK7KqepaWvoNLAmP5zmgkhHf7HQn2J", "fee": 1500000, "feeAssetId": null, "timestamp": 1576309408212, "version": 1, "sender": "3MvU8vDCk4NkA1Ag4vE3mETA4U9ioFh6VEM", "senderPublicKey": "LknnJnwRo6xRdriHmjgVbRDgpexijZFTYBU3Lw4HBS1", "proofs": [ "4C5vTs3HeQhPKFmsJizgiQfee1SATsMS4ThwyskKrFoGXv8X4ERpq8wzpTssAsMv3Lh71rXeMARpYrEvxwDLbbpR" ], "script": "base64:AAIDAAAAAAAAABIIARIECgIBARIDCgEIEgMKAQgAAAABAAAAAA9hdWN0aW9uRHVyYXRpb24JAABoAAAAAgAAAAAAAAAFoAAAAAAAAAAAAQAAAAMAAAABaQEAAAAMYmVnaW5BdWN0aW9uAAAAAgAAAAhtaW5QcmljZQAAAAhkdXJhdGlvbgMJAABmAAAAAgUAAAAIZHVyYXRpb24FAAAAD2F1Y3Rpb25EdXJhdGlvbgkAAAIAAAABCQABLAAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAICAAAAE1NwZWNpZmllZCBkdXJhdGlvbigJAAGkAAAAAQUAAAAIZHVyYXRpb24CAAAAHykgZXhjZWVkcyB0aGUgbWF4aW11bSBkdXJhdGlvbigJAAGkAAAAAQUAAAAPYXVjdGlvbkR1cmF0aW9uAgAAAAEpBAAAAAlhdWN0aW9uSWQJAAJYAAAAAQgFAAAAAWkAAAANdHJhbnNhY3Rpb25JZAQAAAAHZW5kVGltZQkAAGQAAAACCAUAAAAJbGFzdEJsb2NrAAAABmhlaWdodAUAAAAIZHVyYXRpb24EAAAAA3BtdAkBAAAAB2V4dHJh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bnRyeQAAAAIJAAEsAAAAAgUAAAAJYXVjdGlvbklkAgAAAAdfc3RhdHVzBgUAAAADbmlsCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMFAAAAEWhpZ2hlc3RCaWRkZXJBZGRyAAAAAAAAAAABAQAAAAZUH1qCGPEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwUAAAAJb3duZXJBZGRyBQAAAA1oaWdoZXN0QmlkQW10BQAAAAR1bml0BQAAAANuaWwAAAAA7xv6Gg==", "chainId": 84, "height": 808255, "spentComplexity": 0 } View: original | compacted Prev: BWU9gPhpQ9NqbK9FaZnUJKVwsj3jfrFdD3GWFfNDsS3q Next: 5f5eCzdCeHc4DmjmD5RQRoLpHBDZacEjwVzPABPiWxSe Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let auctionDuration = (1440 * 1) | |
5 | + | ||
6 | + | @Callable(i) | |
7 | + | func beginAuction (minPrice,duration) = if ((duration > auctionDuration)) | |
8 | + | then throw((((("Specified duration(" + toString(duration)) + ") exceeds the maximum duration(") + toString(auctionDuration)) + ")")) | |
9 | + | else { | |
10 | + | let auctionId = toBase58String(i.transactionId) | |
11 | + | let endTime = (lastBlock.height + duration) | |
12 | + | let pmt = extract(i.payment) | |
13 | + | WriteSet([DataEntry(auctionId, auctionId), DataEntry((auctionId + "_endTime"), endTime), DataEntry((auctionId + "_owner"), toBase58String(i.caller.bytes)), DataEntry((auctionId + "_itemId"), if (isDefined(pmt.assetId)) | |
14 | + | then toBase58String(value(pmt.assetId)) | |
15 | + | else throw("Item not atached")), DataEntry((auctionId + "_minPrice"), minPrice)]) | |
16 | + | } | |
17 | + | ||
4 | 18 | ||
5 | 19 | ||
6 | 20 | @Callable(i) | |
19 | 33 | else 0)) | |
20 | 34 | if (!(isDefined(getString(this, auctionId)))) | |
21 | 35 | then throw("Auction Id not found") | |
22 | - | else if (( | |
36 | + | else if ((lastBlock.height >= endTime)) | |
23 | 37 | then throw("Auction Completed") | |
24 | - | else if ((100000 >= 1)) | |
25 | - | then throw("Bid must be more then ") | |
26 | - | else WriteSet([DataEntry("Content_Variable", "sss")]) | |
38 | + | else if (if (if (!(isDefined(highestBidAmt))) | |
39 | + | then (minPrice >= totalBidAmount) | |
40 | + | else false) | |
41 | + | then true | |
42 | + | else if (isDefined(highestBidAmt)) | |
43 | + | then (value(highestBidAmt) >= totalBidAmount) | |
44 | + | else false) | |
45 | + | then throw(("Bid must be more then " + (if (!(isDefined(highestBidAmt))) | |
46 | + | then toString(minPrice) | |
47 | + | else toString(value(highestBidAmt))))) | |
48 | + | else if (!(isDefined(highestBidder))) | |
49 | + | then WriteSet([DataEntry((auctionId + "_highestBidder"), callerAddress), DataEntry((auctionId + "_highestBidAmt"), totalBidAmount)]) | |
50 | + | else if (bidFromTheSameUser) | |
51 | + | then WriteSet([DataEntry((auctionId + "_highestBidAmt"), totalBidAmount)]) | |
52 | + | else { | |
53 | + | let previousBidder = addressFromStringValue(value(highestBidder)) | |
54 | + | ScriptResult(WriteSet([DataEntry((auctionId + "_highestBidder"), callerAddress), DataEntry((auctionId + "_highestBidAmt"), totalBidAmount)]), TransferSet([ScriptTransfer(previousBidder, value(highestBidAmt), unit)])) | |
55 | + | } | |
56 | + | } | |
57 | + | ||
58 | + | ||
59 | + | ||
60 | + | @Callable(i) | |
61 | + | func withdraw (auctionId) = { | |
62 | + | let pmt = extract(i.payment) | |
63 | + | let callerAddress = toBase58String(i.caller.bytes) | |
64 | + | let endTime = getIntegerValue(this, (auctionId + "_endTime")) | |
65 | + | let owner = getStringValue(this, (auctionId + "_owner")) | |
66 | + | let highestBidder = getString(this, (auctionId + "_highestBidder")) | |
67 | + | let itemId = getStringValue(this, (auctionId + "_itemId")) | |
68 | + | let highestBidAmt = getIntegerValue(this, (auctionId + "_highestBidAmt")) | |
69 | + | let highestBidderAddr = addressFromStringValue(value(highestBidder)) | |
70 | + | let ownerAddr = addressFromStringValue(value(owner)) | |
71 | + | let itemAddr = addressFromStringValue(value(itemId)) | |
72 | + | if ((endTime > lastBlock.height)) | |
73 | + | then throw("Auction is not finished yet") | |
74 | + | else if (!(isDefined(highestBidder))) | |
75 | + | then if (!(isDefined(getBoolean(this, (auctionId + "_status"))))) | |
76 | + | then throw("Owner already withdrawn the item") | |
77 | + | else ScriptResult(WriteSet([DataEntry((auctionId + "_status"), true)]), TransferSet([ScriptTransfer(ownerAddr, 1, base58'itemAddr')])) | |
78 | + | else if (isDefined(getBoolean(this, (auctionId + "_status")))) | |
79 | + | then throw("The item is transfered to the highest bidder and the bid amount is transfered to the owner") | |
80 | + | else ScriptResult(WriteSet([DataEntry((auctionId + "_status"), true)]), TransferSet([ScriptTransfer(highestBidderAddr, 1, base58'itemAddr'), ScriptTransfer(ownerAddr, highestBidAmt, unit)])) | |
27 | 81 | } | |
28 | 82 | ||
29 | 83 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let auctionDuration = (1440 * 1) | |
5 | + | ||
6 | + | @Callable(i) | |
7 | + | func beginAuction (minPrice,duration) = if ((duration > auctionDuration)) | |
8 | + | then throw((((("Specified duration(" + toString(duration)) + ") exceeds the maximum duration(") + toString(auctionDuration)) + ")")) | |
9 | + | else { | |
10 | + | let auctionId = toBase58String(i.transactionId) | |
11 | + | let endTime = (lastBlock.height + duration) | |
12 | + | let pmt = extract(i.payment) | |
13 | + | WriteSet([DataEntry(auctionId, auctionId), DataEntry((auctionId + "_endTime"), endTime), DataEntry((auctionId + "_owner"), toBase58String(i.caller.bytes)), DataEntry((auctionId + "_itemId"), if (isDefined(pmt.assetId)) | |
14 | + | then toBase58String(value(pmt.assetId)) | |
15 | + | else throw("Item not atached")), DataEntry((auctionId + "_minPrice"), minPrice)]) | |
16 | + | } | |
17 | + | ||
4 | 18 | ||
5 | 19 | ||
6 | 20 | @Callable(i) | |
7 | 21 | func bid (auctionId) = { | |
8 | 22 | let pmt = extract(i.payment) | |
9 | 23 | let callerAddress = toBase58String(i.caller.bytes) | |
10 | 24 | let endTime = getIntegerValue(this, (auctionId + "_endTime")) | |
11 | 25 | let minPrice = getIntegerValue(this, (auctionId + "_minPrice")) | |
12 | 26 | let highestBidAmt = getInteger(this, (auctionId + "_highestBidAmt")) | |
13 | 27 | let highestBidder = getString(this, (auctionId + "_highestBidder")) | |
14 | 28 | let bidFromTheSameUser = if (isDefined(highestBidder)) | |
15 | 29 | then (value(highestBidder) == callerAddress) | |
16 | 30 | else false | |
17 | 31 | let totalBidAmount = (pmt.amount + (if (bidFromTheSameUser) | |
18 | 32 | then value(highestBidAmt) | |
19 | 33 | else 0)) | |
20 | 34 | if (!(isDefined(getString(this, auctionId)))) | |
21 | 35 | then throw("Auction Id not found") | |
22 | - | else if (( | |
36 | + | else if ((lastBlock.height >= endTime)) | |
23 | 37 | then throw("Auction Completed") | |
24 | - | else if ((100000 >= 1)) | |
25 | - | then throw("Bid must be more then ") | |
26 | - | else WriteSet([DataEntry("Content_Variable", "sss")]) | |
38 | + | else if (if (if (!(isDefined(highestBidAmt))) | |
39 | + | then (minPrice >= totalBidAmount) | |
40 | + | else false) | |
41 | + | then true | |
42 | + | else if (isDefined(highestBidAmt)) | |
43 | + | then (value(highestBidAmt) >= totalBidAmount) | |
44 | + | else false) | |
45 | + | then throw(("Bid must be more then " + (if (!(isDefined(highestBidAmt))) | |
46 | + | then toString(minPrice) | |
47 | + | else toString(value(highestBidAmt))))) | |
48 | + | else if (!(isDefined(highestBidder))) | |
49 | + | then WriteSet([DataEntry((auctionId + "_highestBidder"), callerAddress), DataEntry((auctionId + "_highestBidAmt"), totalBidAmount)]) | |
50 | + | else if (bidFromTheSameUser) | |
51 | + | then WriteSet([DataEntry((auctionId + "_highestBidAmt"), totalBidAmount)]) | |
52 | + | else { | |
53 | + | let previousBidder = addressFromStringValue(value(highestBidder)) | |
54 | + | ScriptResult(WriteSet([DataEntry((auctionId + "_highestBidder"), callerAddress), DataEntry((auctionId + "_highestBidAmt"), totalBidAmount)]), TransferSet([ScriptTransfer(previousBidder, value(highestBidAmt), unit)])) | |
55 | + | } | |
56 | + | } | |
57 | + | ||
58 | + | ||
59 | + | ||
60 | + | @Callable(i) | |
61 | + | func withdraw (auctionId) = { | |
62 | + | let pmt = extract(i.payment) | |
63 | + | let callerAddress = toBase58String(i.caller.bytes) | |
64 | + | let endTime = getIntegerValue(this, (auctionId + "_endTime")) | |
65 | + | let owner = getStringValue(this, (auctionId + "_owner")) | |
66 | + | let highestBidder = getString(this, (auctionId + "_highestBidder")) | |
67 | + | let itemId = getStringValue(this, (auctionId + "_itemId")) | |
68 | + | let highestBidAmt = getIntegerValue(this, (auctionId + "_highestBidAmt")) | |
69 | + | let highestBidderAddr = addressFromStringValue(value(highestBidder)) | |
70 | + | let ownerAddr = addressFromStringValue(value(owner)) | |
71 | + | let itemAddr = addressFromStringValue(value(itemId)) | |
72 | + | if ((endTime > lastBlock.height)) | |
73 | + | then throw("Auction is not finished yet") | |
74 | + | else if (!(isDefined(highestBidder))) | |
75 | + | then if (!(isDefined(getBoolean(this, (auctionId + "_status"))))) | |
76 | + | then throw("Owner already withdrawn the item") | |
77 | + | else ScriptResult(WriteSet([DataEntry((auctionId + "_status"), true)]), TransferSet([ScriptTransfer(ownerAddr, 1, base58'itemAddr')])) | |
78 | + | else if (isDefined(getBoolean(this, (auctionId + "_status")))) | |
79 | + | then throw("The item is transfered to the highest bidder and the bid amount is transfered to the owner") | |
80 | + | else ScriptResult(WriteSet([DataEntry((auctionId + "_status"), true)]), TransferSet([ScriptTransfer(highestBidderAddr, 1, base58'itemAddr'), ScriptTransfer(ownerAddr, highestBidAmt, unit)])) | |
27 | 81 | } | |
28 | 82 | ||
29 | 83 |
github/deemru/w8io/026f985 34.45 ms ◑