tx · 5f5eCzdCeHc4DmjmD5RQRoLpHBDZacEjwVzPABPiWxSe 3MvU8vDCk4NkA1Ag4vE3mETA4U9ioFh6VEM: -0.02000000 Waves 2020.01.30 10:15 [876773] smart account 3MvU8vDCk4NkA1Ag4vE3mETA4U9ioFh6VEM > SELF 0.00000000 Waves
{ "type": 13, "id": "5f5eCzdCeHc4DmjmD5RQRoLpHBDZacEjwVzPABPiWxSe", "fee": 2000000, "feeAssetId": null, "timestamp": 1580368395072, "version": 1, "sender": "3MvU8vDCk4NkA1Ag4vE3mETA4U9ioFh6VEM", "senderPublicKey": "LknnJnwRo6xRdriHmjgVbRDgpexijZFTYBU3Lw4HBS1", "proofs": [ "37heJDYDZUrHNVK2M2gcPK5YUJrqPx2AMyCD3cLh2JjXsseCyy8Xb18U9s2uxHhi2YVD2xcMQiUoyUfSVyScqkKH" ], "script": "base64:AAIDAAAAAAAAACEIARIDCgEIEgQKAgEBEgMKAQgSAwoBCBIDCgEIEgMKAQgAAAABAAAAAA9hdWN0aW9uRHVyYXRpb24JAABoAAAAAgAAAAAAAAAFoAAAAAAAAAAAHgAAAAYAAAABaQEAAAAMcmVnaXN0cmF0aW9uAAAAAQAAAAh1c2VyTmFtZQkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzBQAAAAh1c2VyTmFtZQUAAAADbmlsAAAAAWkBAAAADGJlZ2luQXVjdGlvbgAAAAIAAAAIbWluUHJpY2UAAAAIZHVyYXRpb24DCQAAZgAAAAIFAAAACGR1cmF0aW9uBQAAAA9hdWN0aW9uRHVyYXRpb24JAAACAAAAAQkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAABNTcGVjaWZpZWQgZHVyYXRpb24oCQABpAAAAAEFAAAACGR1cmF0aW9uAgAAAB8pIGV4Y2VlZHMgdGhlIG1heGltdW0gZHVyYXRpb24oCQ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AAAQIAAAAYQXVjdGlvbiBpcyBzdGlsbCBydW5uaW5nAwkAAAAAAAACBQAAAA1jYWxsZXJBZGRyZXNzAwkBAAAACWlzRGVmaW5lZAAAAAEFAAAADWhpZ2hlc3RCaWRkZXIJAQAAAAV2YWx1ZQAAAAEFAAAADWhpZ2hlc3RCaWRkZXIAAAAAAAAAAAAJAAACAAAAAQIAAAAoV2lubmVyIGNhbid0IHdpdGhkcmF3IHRoZSBmcm96ZW4gYmFsYW5jZQMDCQEAAAABIQAAAAEJAQAAAAlpc0RlZmluZWQAAAABBQAAABh0aGlzQXVjdGlvbkZyb3plbkJhbGFuY2UGCQAAAAAAAAIFAAAAGHRoaXNBdWN0aW9uRnJvemVuQmFsYW5jZQAAAAAAAAAAAAkAAAIAAAABAgAAAApObyBCYWxhbmNlCQEAAAAMU2NyaXB0UmVzdWx0AAAAAgkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACCQABLAAAAAIFAAAACWF1Y3Rpb25JZAUAAAANY2FsbGVyQWRkcmVzcwIAAAAOX2Zyb3plbkJhbGFuY2UAAAAAAAAAAAAFAAAAA25pbAkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCQEAAAAcQGV4dHJVc2VyKGFkZHJlc3NGcm9tU3RyaW5nKQAAAAEFAAAADWNhbGxlckFkZHJlc3MJAQAAAAV2YWx1ZQAAAAEFAAAAGHRoaXNBdWN0aW9uRnJvemVuQmFsYW5jZQUAAAAEdW5pdAUAAAADbmlsAAAAAHdWW8w=", "chainId": 84, "height": 876773, "spentComplexity": 0 } View: original | compacted Prev: 5X52GTmaLN6mJyxK7KqepaWvoNLAmP5zmgkhHf7HQn2J Next: none Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let auctionDuration = (1440 * 1) | |
4 | + | let auctionDuration = (1440 * 30) | |
5 | + | ||
6 | + | @Callable(i) | |
7 | + | func registration (userName) = WriteSet([DataEntry(toBase58String(i.caller.bytes), userName)]) | |
8 | + | ||
9 | + | ||
5 | 10 | ||
6 | 11 | @Callable(i) | |
7 | 12 | func beginAuction (minPrice,duration) = if ((duration > auctionDuration)) | |
25 | 30 | let minPrice = getIntegerValue(this, (auctionId + "_minPrice")) | |
26 | 31 | let highestBidAmt = getInteger(this, (auctionId + "_highestBidAmt")) | |
27 | 32 | let highestBidder = getString(this, (auctionId + "_highestBidder")) | |
28 | - | let bidFromTheSameUser = if (isDefined(highestBidder)) | |
29 | - | then (value(highestBidder) == callerAddress) | |
30 | - | else false | |
31 | - | let totalBidAmount = (pmt.amount + (if (bidFromTheSameUser) | |
32 | - | then value(highestBidAmt) | |
33 | + | let thisAuctionFrozenBalance = getInteger(this, ((auctionId + callerAddress) + "_frozenBalance")) | |
34 | + | let totalBidAmount = (pmt.amount + (if (isDefined(thisAuctionFrozenBalance)) | |
35 | + | then value(thisAuctionFrozenBalance) | |
33 | 36 | else 0)) | |
34 | 37 | if (!(isDefined(getString(this, auctionId)))) | |
35 | - | then throw(" | |
38 | + | then throw("Invalid auction Id") | |
36 | 39 | else if ((lastBlock.height >= endTime)) | |
37 | 40 | then throw("Auction Completed") | |
38 | 41 | else if (if (if (!(isDefined(highestBidAmt))) | |
45 | 48 | then throw(("Bid must be more then " + (if (!(isDefined(highestBidAmt))) | |
46 | 49 | then toString(minPrice) | |
47 | 50 | 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 | - | } | |
51 | + | else WriteSet([DataEntry((auctionId + "_highestBidder"), callerAddress), DataEntry((auctionId + "_highestBidAmt"), totalBidAmount), DataEntry(((auctionId + callerAddress) + "_frozenBalance"), totalBidAmount)]) | |
56 | 52 | } | |
57 | 53 | ||
58 | 54 | ||
59 | 55 | ||
60 | 56 | @Callable(i) | |
61 | - | func withdraw (auctionId) = { | |
62 | - | let pmt = extract(i.payment) | |
57 | + | func ownerWithdraw (auctionId) = { | |
63 | 58 | let callerAddress = toBase58String(i.caller.bytes) | |
64 | 59 | let endTime = getIntegerValue(this, (auctionId + "_endTime")) | |
65 | - | let owner = | |
60 | + | let owner = getString(this, (auctionId + "_owner")) | |
66 | 61 | let highestBidder = getString(this, (auctionId + "_highestBidder")) | |
67 | 62 | let itemId = getStringValue(this, (auctionId + "_itemId")) | |
68 | - | let highestBidAmt = getIntegerValue(this, (auctionId + "_highestBidAmt")) | |
63 | + | let highestBidAmt = getInteger(this, (auctionId + "_highestBidAmt")) | |
64 | + | let ownerAddr = addressFromStringValue(value(owner)) | |
65 | + | let itemAddr = fromBase58String(itemId) | |
66 | + | if (if ((callerAddress != owner)) | |
67 | + | then true | |
68 | + | else !(isDefined(getString(this, auctionId)))) | |
69 | + | then throw(if (!(isDefined(getString(this, auctionId)))) | |
70 | + | then "Invalid auction Id" | |
71 | + | else "Access Denied") | |
72 | + | else if ((endTime > lastBlock.height)) | |
73 | + | then throw("Auction is still running") | |
74 | + | else if (!(isDefined(highestBidder))) | |
75 | + | then if (isDefined(getBoolean(this, (auctionId + "_ownerWithdrawStatus")))) | |
76 | + | then throw("Item already withdrawn") | |
77 | + | else ScriptResult(WriteSet([DataEntry((auctionId + "_ownerWithdrawStatus"), true)]), TransferSet([ScriptTransfer(ownerAddr, 1, itemAddr)])) | |
78 | + | else if (isDefined(getBoolean(this, (auctionId + "_ownerWithdrawStatus")))) | |
79 | + | then throw("The bid amount is already transfered") | |
80 | + | else ScriptResult(WriteSet([DataEntry((auctionId + "_ownerWithdrawStatus"), true)]), TransferSet([ScriptTransfer(ownerAddr, ((value(highestBidAmt) / 100) * 95), unit)])) | |
81 | + | } | |
82 | + | ||
83 | + | ||
84 | + | ||
85 | + | @Callable(i) | |
86 | + | func winnerWithdraw (auctionId) = { | |
87 | + | let callerAddress = toBase58String(i.caller.bytes) | |
88 | + | let endTime = getIntegerValue(this, (auctionId + "_endTime")) | |
89 | + | let highestBidder = getString(this, (auctionId + "_highestBidder")) | |
90 | + | let itemId = getStringValue(this, (auctionId + "_itemId")) | |
91 | + | let highestBidAmt = getInteger(this, (auctionId + "_highestBidAmt")) | |
69 | 92 | 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)])) | |
93 | + | let itemAddr = fromBase58String(itemId) | |
94 | + | if (!(isDefined(getString(this, auctionId)))) | |
95 | + | then throw("Invalid auction Id") | |
96 | + | else if ((callerAddress != if (isDefined(highestBidder)) | |
97 | + | then value(highestBidder) | |
98 | + | else throw("Nobody won this item"))) | |
99 | + | then throw("Access Denied") | |
100 | + | else if ((endTime > lastBlock.height)) | |
101 | + | then throw("Auction is still running") | |
102 | + | else if (isDefined(getBoolean(this, (auctionId + "_winnerWithdrawStatus")))) | |
103 | + | then throw("The item already transfered") | |
104 | + | else ScriptResult(WriteSet([DataEntry((auctionId + "_winnerWithdrawStatus"), true)]), TransferSet([ScriptTransfer(highestBidderAddr, 1, itemAddr)])) | |
105 | + | } | |
106 | + | ||
107 | + | ||
108 | + | ||
109 | + | @Callable(i) | |
110 | + | func participantWithdraw (auctionId) = { | |
111 | + | let callerAddress = toBase58String(i.caller.bytes) | |
112 | + | let endTime = getIntegerValue(this, (auctionId + "_endTime")) | |
113 | + | let highestBidder = getString(this, (auctionId + "_highestBidder")) | |
114 | + | let thisAuctionFrozenBalance = getInteger(this, ((auctionId + callerAddress) + "_frozenBalance")) | |
115 | + | if (!(isDefined(getString(this, auctionId)))) | |
116 | + | then throw("Invalid auction Id") | |
117 | + | else if ((endTime > lastBlock.height)) | |
118 | + | then throw("Auction is still running") | |
119 | + | else if ((callerAddress == (if (isDefined(highestBidder)) | |
120 | + | then value(highestBidder) | |
121 | + | else 0))) | |
122 | + | then throw("Winner can't withdraw the frozen balance") | |
123 | + | else if (if (!(isDefined(thisAuctionFrozenBalance))) | |
124 | + | then true | |
125 | + | else (thisAuctionFrozenBalance == 0)) | |
126 | + | then throw("No Balance") | |
127 | + | else ScriptResult(WriteSet([DataEntry(((auctionId + callerAddress) + "_frozenBalance"), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(callerAddress), value(thisAuctionFrozenBalance), unit)])) | |
81 | 128 | } | |
82 | 129 | ||
83 | 130 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let auctionDuration = (1440 * 1) | |
4 | + | let auctionDuration = (1440 * 30) | |
5 | + | ||
6 | + | @Callable(i) | |
7 | + | func registration (userName) = WriteSet([DataEntry(toBase58String(i.caller.bytes), userName)]) | |
8 | + | ||
9 | + | ||
5 | 10 | ||
6 | 11 | @Callable(i) | |
7 | 12 | func beginAuction (minPrice,duration) = if ((duration > auctionDuration)) | |
8 | 13 | then throw((((("Specified duration(" + toString(duration)) + ") exceeds the maximum duration(") + toString(auctionDuration)) + ")")) | |
9 | 14 | else { | |
10 | 15 | let auctionId = toBase58String(i.transactionId) | |
11 | 16 | let endTime = (lastBlock.height + duration) | |
12 | 17 | let pmt = extract(i.payment) | |
13 | 18 | WriteSet([DataEntry(auctionId, auctionId), DataEntry((auctionId + "_endTime"), endTime), DataEntry((auctionId + "_owner"), toBase58String(i.caller.bytes)), DataEntry((auctionId + "_itemId"), if (isDefined(pmt.assetId)) | |
14 | 19 | then toBase58String(value(pmt.assetId)) | |
15 | 20 | else throw("Item not atached")), DataEntry((auctionId + "_minPrice"), minPrice)]) | |
16 | 21 | } | |
17 | 22 | ||
18 | 23 | ||
19 | 24 | ||
20 | 25 | @Callable(i) | |
21 | 26 | func bid (auctionId) = { | |
22 | 27 | let pmt = extract(i.payment) | |
23 | 28 | let callerAddress = toBase58String(i.caller.bytes) | |
24 | 29 | let endTime = getIntegerValue(this, (auctionId + "_endTime")) | |
25 | 30 | let minPrice = getIntegerValue(this, (auctionId + "_minPrice")) | |
26 | 31 | let highestBidAmt = getInteger(this, (auctionId + "_highestBidAmt")) | |
27 | 32 | let highestBidder = getString(this, (auctionId + "_highestBidder")) | |
28 | - | let bidFromTheSameUser = if (isDefined(highestBidder)) | |
29 | - | then (value(highestBidder) == callerAddress) | |
30 | - | else false | |
31 | - | let totalBidAmount = (pmt.amount + (if (bidFromTheSameUser) | |
32 | - | then value(highestBidAmt) | |
33 | + | let thisAuctionFrozenBalance = getInteger(this, ((auctionId + callerAddress) + "_frozenBalance")) | |
34 | + | let totalBidAmount = (pmt.amount + (if (isDefined(thisAuctionFrozenBalance)) | |
35 | + | then value(thisAuctionFrozenBalance) | |
33 | 36 | else 0)) | |
34 | 37 | if (!(isDefined(getString(this, auctionId)))) | |
35 | - | then throw(" | |
38 | + | then throw("Invalid auction Id") | |
36 | 39 | else if ((lastBlock.height >= endTime)) | |
37 | 40 | then throw("Auction Completed") | |
38 | 41 | else if (if (if (!(isDefined(highestBidAmt))) | |
39 | 42 | then (minPrice >= totalBidAmount) | |
40 | 43 | else false) | |
41 | 44 | then true | |
42 | 45 | else if (isDefined(highestBidAmt)) | |
43 | 46 | then (value(highestBidAmt) >= totalBidAmount) | |
44 | 47 | else false) | |
45 | 48 | then throw(("Bid must be more then " + (if (!(isDefined(highestBidAmt))) | |
46 | 49 | then toString(minPrice) | |
47 | 50 | 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 | - | } | |
51 | + | else WriteSet([DataEntry((auctionId + "_highestBidder"), callerAddress), DataEntry((auctionId + "_highestBidAmt"), totalBidAmount), DataEntry(((auctionId + callerAddress) + "_frozenBalance"), totalBidAmount)]) | |
56 | 52 | } | |
57 | 53 | ||
58 | 54 | ||
59 | 55 | ||
60 | 56 | @Callable(i) | |
61 | - | func withdraw (auctionId) = { | |
62 | - | let pmt = extract(i.payment) | |
57 | + | func ownerWithdraw (auctionId) = { | |
63 | 58 | let callerAddress = toBase58String(i.caller.bytes) | |
64 | 59 | let endTime = getIntegerValue(this, (auctionId + "_endTime")) | |
65 | - | let owner = | |
60 | + | let owner = getString(this, (auctionId + "_owner")) | |
66 | 61 | let highestBidder = getString(this, (auctionId + "_highestBidder")) | |
67 | 62 | let itemId = getStringValue(this, (auctionId + "_itemId")) | |
68 | - | let highestBidAmt = getIntegerValue(this, (auctionId + "_highestBidAmt")) | |
63 | + | let highestBidAmt = getInteger(this, (auctionId + "_highestBidAmt")) | |
64 | + | let ownerAddr = addressFromStringValue(value(owner)) | |
65 | + | let itemAddr = fromBase58String(itemId) | |
66 | + | if (if ((callerAddress != owner)) | |
67 | + | then true | |
68 | + | else !(isDefined(getString(this, auctionId)))) | |
69 | + | then throw(if (!(isDefined(getString(this, auctionId)))) | |
70 | + | then "Invalid auction Id" | |
71 | + | else "Access Denied") | |
72 | + | else if ((endTime > lastBlock.height)) | |
73 | + | then throw("Auction is still running") | |
74 | + | else if (!(isDefined(highestBidder))) | |
75 | + | then if (isDefined(getBoolean(this, (auctionId + "_ownerWithdrawStatus")))) | |
76 | + | then throw("Item already withdrawn") | |
77 | + | else ScriptResult(WriteSet([DataEntry((auctionId + "_ownerWithdrawStatus"), true)]), TransferSet([ScriptTransfer(ownerAddr, 1, itemAddr)])) | |
78 | + | else if (isDefined(getBoolean(this, (auctionId + "_ownerWithdrawStatus")))) | |
79 | + | then throw("The bid amount is already transfered") | |
80 | + | else ScriptResult(WriteSet([DataEntry((auctionId + "_ownerWithdrawStatus"), true)]), TransferSet([ScriptTransfer(ownerAddr, ((value(highestBidAmt) / 100) * 95), unit)])) | |
81 | + | } | |
82 | + | ||
83 | + | ||
84 | + | ||
85 | + | @Callable(i) | |
86 | + | func winnerWithdraw (auctionId) = { | |
87 | + | let callerAddress = toBase58String(i.caller.bytes) | |
88 | + | let endTime = getIntegerValue(this, (auctionId + "_endTime")) | |
89 | + | let highestBidder = getString(this, (auctionId + "_highestBidder")) | |
90 | + | let itemId = getStringValue(this, (auctionId + "_itemId")) | |
91 | + | let highestBidAmt = getInteger(this, (auctionId + "_highestBidAmt")) | |
69 | 92 | 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)])) | |
93 | + | let itemAddr = fromBase58String(itemId) | |
94 | + | if (!(isDefined(getString(this, auctionId)))) | |
95 | + | then throw("Invalid auction Id") | |
96 | + | else if ((callerAddress != if (isDefined(highestBidder)) | |
97 | + | then value(highestBidder) | |
98 | + | else throw("Nobody won this item"))) | |
99 | + | then throw("Access Denied") | |
100 | + | else if ((endTime > lastBlock.height)) | |
101 | + | then throw("Auction is still running") | |
102 | + | else if (isDefined(getBoolean(this, (auctionId + "_winnerWithdrawStatus")))) | |
103 | + | then throw("The item already transfered") | |
104 | + | else ScriptResult(WriteSet([DataEntry((auctionId + "_winnerWithdrawStatus"), true)]), TransferSet([ScriptTransfer(highestBidderAddr, 1, itemAddr)])) | |
105 | + | } | |
106 | + | ||
107 | + | ||
108 | + | ||
109 | + | @Callable(i) | |
110 | + | func participantWithdraw (auctionId) = { | |
111 | + | let callerAddress = toBase58String(i.caller.bytes) | |
112 | + | let endTime = getIntegerValue(this, (auctionId + "_endTime")) | |
113 | + | let highestBidder = getString(this, (auctionId + "_highestBidder")) | |
114 | + | let thisAuctionFrozenBalance = getInteger(this, ((auctionId + callerAddress) + "_frozenBalance")) | |
115 | + | if (!(isDefined(getString(this, auctionId)))) | |
116 | + | then throw("Invalid auction Id") | |
117 | + | else if ((endTime > lastBlock.height)) | |
118 | + | then throw("Auction is still running") | |
119 | + | else if ((callerAddress == (if (isDefined(highestBidder)) | |
120 | + | then value(highestBidder) | |
121 | + | else 0))) | |
122 | + | then throw("Winner can't withdraw the frozen balance") | |
123 | + | else if (if (!(isDefined(thisAuctionFrozenBalance))) | |
124 | + | then true | |
125 | + | else (thisAuctionFrozenBalance == 0)) | |
126 | + | then throw("No Balance") | |
127 | + | else ScriptResult(WriteSet([DataEntry(((auctionId + callerAddress) + "_frozenBalance"), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(callerAddress), value(thisAuctionFrozenBalance), unit)])) | |
81 | 128 | } | |
82 | 129 | ||
83 | 130 |
github/deemru/w8io/169f3d6 46.93 ms ◑