tx · Bncev1n8cEdz9ABj8oaz8ihrtpJFNuCrfocwgo4n98Go 3N6s7QBCvgnCNbR7r4rajA9DsejGtshaLLa: -0.01500000 Waves 2019.12.20 18:57 [817485] smart account 3N6s7QBCvgnCNbR7r4rajA9DsejGtshaLLa > SELF 0.00000000 Waves
{ "type": 13, "id": "Bncev1n8cEdz9ABj8oaz8ihrtpJFNuCrfocwgo4n98Go", "fee": 1500000, "feeAssetId": null, "timestamp": 1576857192154, "version": 1, "sender": "3N6s7QBCvgnCNbR7r4rajA9DsejGtshaLLa", "senderPublicKey": "5wpzgifs7AQAB2xctYK9m7gDenQv4yCCiLcTgKQTcz9Z", "proofs": [ "3s1vP4dccQ8sGZNJ67zMYfCqLjeBVsT1Z332TQpQGiHVb5JEtdHbACNk9xHAyvjYcmF6qezCsbF9iH5AFiQwanES" ], "script": "base64:AAIDAAAAAAAAABcIARIECgIBARIDCgEIEgMKAQgSAwoBCAAAAAEAAAAAD2F1Y3Rpb25EdXJhdGlvbgkAAGgAAAACAAAAAAAAAAWgAAAAAAAAAAABAAAABAAAAAFpAQAAAAxiZWdpbkF1Y3Rpb24AAAACAAAACG1pblByaWNlAAAACGR1cmF0aW9uAwkAAGYAAAACBQAAAAhkdXJhdGlvbgUAAAAPYXVjdGlvbkR1cmF0aW9uCQAAAgAAAAEJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAEsAAAAAgIAAAATU3BlY2lmaWVkIGR1cmF0aW9uKAkAAaQAAAABBQAAAAhkdXJhdGlvbgIAAAAfKSBleGNlZWRzIHRoZSBtYXhpbXVtIGR1cmF0aW9uKAkAAaQAAAABBQAAAA9hdWN0aW9uRHVyYXRpb24CAAAAASkEAAAACWF1Y3Rpb25JZAkAAlgAAAABCAUAAAABaQAAAA10cmFuc2FjdGlvbklkBAAAAAdlbmRUaW1lCQAAZAAAAAIIBQAAAAlsYXN0QmxvY2sAAAAGaGVpZ2h0BQAAAAhkdXJhdGlvbgQAAAADcG10CQEAAAAHZXh0cm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EyDNbHyhd6K4 Diff:
Old | New | Differences | |
---|---|---|---|
101 | 101 | else if ((endTime > lastBlock.height)) | |
102 | 102 | then throw("Auction is not finished yet") | |
103 | 103 | else if (isDefined(getBoolean(this, (auctionId + "_winnerWithdrawStatus")))) | |
104 | - | then throw("The | |
104 | + | then throw("The item already transfered") | |
105 | 105 | else ScriptResult(WriteSet([DataEntry((auctionId + "_winnerWithdrawStatus"), true)]), TransferSet([ScriptTransfer(highestBidderAddr, 1, itemAddr)])) | |
106 | 106 | } | |
107 | 107 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let auctionDuration = (1440 * 1) | |
5 | 5 | ||
6 | 6 | @Callable(i) | |
7 | 7 | func beginAuction (minPrice,duration) = if ((duration > auctionDuration)) | |
8 | 8 | then throw((((("Specified duration(" + toString(duration)) + ") exceeds the maximum duration(") + toString(auctionDuration)) + ")")) | |
9 | 9 | else { | |
10 | 10 | let auctionId = toBase58String(i.transactionId) | |
11 | 11 | let endTime = (lastBlock.height + duration) | |
12 | 12 | let pmt = extract(i.payment) | |
13 | 13 | WriteSet([DataEntry(auctionId, auctionId), DataEntry((auctionId + "_endTime"), endTime), DataEntry((auctionId + "_owner"), toBase58String(i.caller.bytes)), DataEntry((auctionId + "_itemId"), if (isDefined(pmt.assetId)) | |
14 | 14 | then toBase58String(value(pmt.assetId)) | |
15 | 15 | else throw("Item not atached")), DataEntry((auctionId + "_minPrice"), minPrice)]) | |
16 | 16 | } | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | ||
20 | 20 | @Callable(i) | |
21 | 21 | func bid (auctionId) = { | |
22 | 22 | let pmt = extract(i.payment) | |
23 | 23 | let callerAddress = toBase58String(i.caller.bytes) | |
24 | 24 | let endTime = getIntegerValue(this, (auctionId + "_endTime")) | |
25 | 25 | let minPrice = getIntegerValue(this, (auctionId + "_minPrice")) | |
26 | 26 | let highestBidAmt = getInteger(this, (auctionId + "_highestBidAmt")) | |
27 | 27 | let highestBidder = getString(this, (auctionId + "_highestBidder")) | |
28 | 28 | let bidFromTheSameUser = if (isDefined(highestBidder)) | |
29 | 29 | then (value(highestBidder) == callerAddress) | |
30 | 30 | else false | |
31 | 31 | let totalBidAmount = (pmt.amount + (if (bidFromTheSameUser) | |
32 | 32 | then value(highestBidAmt) | |
33 | 33 | else 0)) | |
34 | 34 | if (!(isDefined(getString(this, auctionId)))) | |
35 | 35 | then throw("Auction Id not found") | |
36 | 36 | else if ((lastBlock.height >= endTime)) | |
37 | 37 | then throw("Auction Completed") | |
38 | 38 | else if (if (if (!(isDefined(highestBidAmt))) | |
39 | 39 | then (minPrice >= totalBidAmount) | |
40 | 40 | else false) | |
41 | 41 | then true | |
42 | 42 | else if (isDefined(highestBidAmt)) | |
43 | 43 | then (value(highestBidAmt) >= totalBidAmount) | |
44 | 44 | else false) | |
45 | 45 | then throw(("Bid must be more then " + (if (!(isDefined(highestBidAmt))) | |
46 | 46 | then toString(minPrice) | |
47 | 47 | else toString(value(highestBidAmt))))) | |
48 | 48 | else if (!(isDefined(highestBidder))) | |
49 | 49 | then WriteSet([DataEntry((auctionId + "_highestBidder"), callerAddress), DataEntry((auctionId + "_highestBidAmt"), totalBidAmount)]) | |
50 | 50 | else if (bidFromTheSameUser) | |
51 | 51 | then WriteSet([DataEntry((auctionId + "_highestBidAmt"), totalBidAmount)]) | |
52 | 52 | else { | |
53 | 53 | let previousBidder = addressFromStringValue(value(highestBidder)) | |
54 | 54 | ScriptResult(WriteSet([DataEntry((auctionId + "_highestBidder"), callerAddress), DataEntry((auctionId + "_highestBidAmt"), totalBidAmount)]), TransferSet([ScriptTransfer(previousBidder, value(highestBidAmt), unit)])) | |
55 | 55 | } | |
56 | 56 | } | |
57 | 57 | ||
58 | 58 | ||
59 | 59 | ||
60 | 60 | @Callable(i) | |
61 | 61 | func ownerWithdraw (auctionId) = { | |
62 | 62 | let callerAddress = toBase58String(i.caller.bytes) | |
63 | 63 | let endTime = getIntegerValue(this, (auctionId + "_endTime")) | |
64 | 64 | let owner = getStringValue(this, (auctionId + "_owner")) | |
65 | 65 | let highestBidder = getString(this, (auctionId + "_highestBidder")) | |
66 | 66 | let itemId = getStringValue(this, (auctionId + "_itemId")) | |
67 | 67 | let highestBidAmt = getIntegerValue(this, (auctionId + "_highestBidAmt")) | |
68 | 68 | let highestBidderAddr = addressFromStringValue(value(highestBidder)) | |
69 | 69 | let ownerAddr = addressFromStringValue(value(owner)) | |
70 | 70 | let itemAddr = fromBase58String(value(itemId)) | |
71 | 71 | if ((callerAddress != value(owner))) | |
72 | 72 | then throw("Access Denied") | |
73 | 73 | else if ((endTime > lastBlock.height)) | |
74 | 74 | then throw("Auction is not finished yet") | |
75 | 75 | else if (!(isDefined(highestBidder))) | |
76 | 76 | then if (isDefined(getBoolean(this, (auctionId + "_ownerWithdrawStatus")))) | |
77 | 77 | then throw("Item already withdrawn") | |
78 | 78 | else ScriptResult(WriteSet([DataEntry((auctionId + "_ownerWithdrawStatus"), true)]), TransferSet([ScriptTransfer(ownerAddr, 1, itemAddr)])) | |
79 | 79 | else if (isDefined(getBoolean(this, (auctionId + "_ownerWithdrawStatus")))) | |
80 | 80 | then throw("The bid amount is already transfered") | |
81 | 81 | else ScriptResult(WriteSet([DataEntry((auctionId + "_ownerWithdrawStatus"), true)]), TransferSet([ScriptTransfer(ownerAddr, ((highestBidAmt / 100) * 95), unit)])) | |
82 | 82 | } | |
83 | 83 | ||
84 | 84 | ||
85 | 85 | ||
86 | 86 | @Callable(i) | |
87 | 87 | func winnerWithdraw (auctionId) = { | |
88 | 88 | let callerAddress = toBase58String(i.caller.bytes) | |
89 | 89 | let endTime = getIntegerValue(this, (auctionId + "_endTime")) | |
90 | 90 | let owner = getStringValue(this, (auctionId + "_owner")) | |
91 | 91 | let highestBidder = getString(this, (auctionId + "_highestBidder")) | |
92 | 92 | let itemId = getStringValue(this, (auctionId + "_itemId")) | |
93 | 93 | let highestBidAmt = getIntegerValue(this, (auctionId + "_highestBidAmt")) | |
94 | 94 | let highestBidderAddr = addressFromStringValue(value(highestBidder)) | |
95 | 95 | let ownerAddr = addressFromStringValue(value(owner)) | |
96 | 96 | let itemAddr = fromBase58String(value(itemId)) | |
97 | 97 | if ((callerAddress != if (isDefined(highestBidder)) | |
98 | 98 | then value(highestBidder) | |
99 | 99 | else throw("Nobody won this item"))) | |
100 | 100 | then throw("Access Denied") | |
101 | 101 | else if ((endTime > lastBlock.height)) | |
102 | 102 | then throw("Auction is not finished yet") | |
103 | 103 | else if (isDefined(getBoolean(this, (auctionId + "_winnerWithdrawStatus")))) | |
104 | - | then throw("The | |
104 | + | then throw("The item already transfered") | |
105 | 105 | else ScriptResult(WriteSet([DataEntry((auctionId + "_winnerWithdrawStatus"), true)]), TransferSet([ScriptTransfer(highestBidderAddr, 1, itemAddr)])) | |
106 | 106 | } | |
107 | 107 | ||
108 | 108 |
github/deemru/w8io/026f985 44.45 ms ◑