tx · JCppjZfE3119Zr8BcwDsr3p4uiAT2bjtfBgqdZd4cJdK 3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H: -0.01000000 Waves 2022.11.04 15:19 [2302361] smart account 3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H > SELF 0.00000000 Waves
{ "type": 13, "id": "JCppjZfE3119Zr8BcwDsr3p4uiAT2bjtfBgqdZd4cJdK", "fee": 1000000, "feeAssetId": null, "timestamp": 1667564389877, "version": 2, "chainId": 84, "sender": "3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H", "senderPublicKey": "BDeCphaaC4MZvfmbJqQZ78EvuEBZTJ1VEW7fbxue8BUu", "proofs": [ "5hKx6SRGFLhcEtng68wPUkxc2hKWYRc3sXZrcgXYx2xNVgyLgHLV9kdPpuuf96KKXi1rF7J2656LqVgsoxd31VS9" ], "script": "base64:AAIDAAAAAAAAABMIARIFCgMBAQgSAwoBCBIDCgEIAAAAAQAAAAASbWF4QXVjdGlvbkR1cmF0aW9uCQAAaAAAAAIAAAAAAAAABaAAAAAAAAAAAB4AAAADAAAAAWkBAAAADHN0YXJ0QXVjdGlvbgAAAAMAAAAIZHVyYXRpb24AAAAKc3RhcnRQcmljZQAAAAxwcmljZUFzc2V0SWQEAAAACWF1Y3Rpb25JZAkAAlgAAAABCAUAAAABaQAAAA10cmFuc2FjdGlvbklkBAAAAAllbmRIZWlnaHQJAABkAAAAAggFAAAACWxhc3RCbG9jawAAAAZoZWlnaHQFAAAACGR1cmF0aW9uBAAAAANwbXQJAQAAAAdleHRyYWN0AAAAAQgFAAAAAWkAAAAHcGF5bWVudAMJAABmAAAAAgUAAAAIZHVyYXRpb24FAAAAEm1heEF1Y3Rpb25EdXJhdGlvbgkAAAIAAAABCQABLAAAAAICAAAAKER1cmF0aW9uIGlzIHRvbyBsb25nLiBNdXN0IGJlIGxlc3MgdGhhbiAJAAGkAAAAAQUAAAASbWF4QXVjdGlvbkR1cmF0aW9uCQEAAAAIV3JpdGV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yBQAAAAlsb3RBbW91bnQFAAAACGxvdEFzc2V0CQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMFAAAADW9yZ2FuaXplckFkZHIFAAAACXdpbkFtb3VudAUAAAAKcHJpY2VBc3NldAUAAAADbmlsAAAAAK2i3zY=", "height": 2302361, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: G2jpkvs23rvUiNtwGXFhXnAka56MmC7u5spY7akq24Uv Next: DsMjkGrzCzAT6gPs1qEqLYfAQJccqP8TeLQQkR9eXAPv Full:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let kUserPayment = "Payment" | |
5 | - | ||
6 | - | let kWon = "Won" | |
7 | - | ||
8 | - | func randomize (bytes,range) = { | |
9 | - | let hash = sha256(bytes) | |
10 | - | let index = toInt(hash) | |
11 | - | (index % range) | |
12 | - | } | |
13 | - | ||
14 | - | ||
15 | - | func counting (bytes) = { | |
16 | - | let count = randomize(bytes, 10) | |
17 | - | if ((count >= 4)) | |
18 | - | then BooleanEntry(kWon, false) | |
19 | - | else BooleanEntry(kWon, true) | |
20 | - | } | |
21 | - | ||
4 | + | let maxAuctionDuration = (1440 * 30) | |
22 | 5 | ||
23 | 6 | @Callable(i) | |
24 | - | func parseStruct () = if ((i.caller != this)) | |
25 | - | then throw("Only owner") | |
26 | - | else { | |
27 | - | let winnerStruct = counting(i.transactionId) | |
28 | - | [winnerStruct] | |
29 | - | } | |
7 | + | func startAuction (duration,startPrice,priceAssetId) = { | |
8 | + | let auctionId = toBase58String(i.transactionId) | |
9 | + | let endHeight = (lastBlock.height + duration) | |
10 | + | let pmt = extract(i.payment) | |
11 | + | if ((duration > maxAuctionDuration)) | |
12 | + | then throw(("Duration is too long. Must be less than " + toString(maxAuctionDuration))) | |
13 | + | else WriteSet([DataEntry(auctionId, endHeight), DataEntry((auctionId + "_organizer"), toBase58String(i.caller.bytes)), DataEntry((auctionId + "_lot_assetId"), if (isDefined(pmt.assetId)) | |
14 | + | then toBase58String(value(pmt.assetId)) | |
15 | + | else "WAVES"), DataEntry((auctionId + "_lot_amount"), pmt.amount), DataEntry((auctionId + "_startPrice"), startPrice), DataEntry((auctionId + "_priceAssetId"), priceAssetId)]) | |
16 | + | } | |
30 | 17 | ||
31 | 18 | ||
32 | 19 | ||
33 | 20 | @Callable(i) | |
34 | - | func startGame () = { | |
35 | - | let amount = value(i.payments[0].amount) | |
36 | - | if ((i.payments[0].assetId != unit)) | |
37 | - | then throw("Pay in waves") | |
38 | - | else { | |
39 | - | let nullInitStore = invoke(this, "parseStruct", nil, nil) | |
40 | - | if ((nullInitStore == nullInitStore)) | |
41 | - | then { | |
42 | - | let won = valueOrErrorMessage(getBoolean(this, kWon), "Storage read error") | |
43 | - | if (won) | |
44 | - | then [ScriptTransfer(i.caller, (amount * 2), unit)] | |
45 | - | else nil | |
46 | - | } | |
47 | - | else throw("Strict value is not equal to itself.") | |
48 | - | } | |
21 | + | func bid (auctionId) = { | |
22 | + | let pmt = extract(i.payment) | |
23 | + | let pmtAssetIdStr = if (isDefined(pmt.assetId)) | |
24 | + | then toBase58String(value(pmt.assetId)) | |
25 | + | else "WAVES" | |
26 | + | let callerAddressStr = toBase58String(i.caller.bytes) | |
27 | + | let endHeight = getIntegerValue(this, auctionId) | |
28 | + | let startPrice = getIntegerValue(this, (auctionId + "_startPrice")) | |
29 | + | let priceAssetId = getStringValue(this, (auctionId + "_priceAssetId")) | |
30 | + | let winAmount = getInteger(this, (auctionId + "_winAmount")) | |
31 | + | let winner = getString(this, (auctionId + "_winner")) | |
32 | + | let bidFromTheSameUser = if (isDefined(winner)) | |
33 | + | then (value(winner) == callerAddressStr) | |
34 | + | else false | |
35 | + | let totalBidAmount = (pmt.amount + (if (bidFromTheSameUser) | |
36 | + | then value(winAmount) | |
37 | + | else 0)) | |
38 | + | if ((lastBlock.height >= endHeight)) | |
39 | + | then throw("Auction already finished") | |
40 | + | else if ((priceAssetId != pmtAssetIdStr)) | |
41 | + | then throw((("Bid must be in asset '" + priceAssetId) + "'")) | |
42 | + | else if (if (if (isDefined(winAmount)) | |
43 | + | then (value(winAmount) >= totalBidAmount) | |
44 | + | else false) | |
45 | + | then true | |
46 | + | else if (!(isDefined(winAmount))) | |
47 | + | then (startPrice >= totalBidAmount) | |
48 | + | else false) | |
49 | + | then throw(("Bid must be more then " + toString(if (isDefined(winAmount)) | |
50 | + | then value(winAmount) | |
51 | + | else startPrice))) | |
52 | + | else if (if (bidFromTheSameUser) | |
53 | + | then true | |
54 | + | else !(isDefined(winner))) | |
55 | + | then WriteSet([DataEntry((auctionId + "_winner"), callerAddressStr), DataEntry((auctionId + "_winAmount"), totalBidAmount)]) | |
56 | + | else { | |
57 | + | let previousBidderAddr = addressFromStringValue(value(winner)) | |
58 | + | let priceAsset = if (if ((priceAssetId == "WAVES")) | |
59 | + | then true | |
60 | + | else (priceAssetId == "")) | |
61 | + | then unit | |
62 | + | else fromBase58String(priceAssetId) | |
63 | + | ScriptResult(WriteSet([DataEntry((auctionId + "_winner"), callerAddressStr), DataEntry((auctionId + "_winAmount"), totalBidAmount)]), TransferSet([ScriptTransfer(previousBidderAddr, value(winAmount), priceAsset)])) | |
64 | + | } | |
65 | + | } | |
66 | + | ||
67 | + | ||
68 | + | ||
69 | + | @Callable(i) | |
70 | + | func withdraw (auctionId) = { | |
71 | + | let pmt = extract(i.payment) | |
72 | + | let pmtAssetIdStr = if (isDefined(pmt.assetId)) | |
73 | + | then toBase58String(value(pmt.assetId)) | |
74 | + | else "WAVES" | |
75 | + | let callerAddressStr = toBase58String(i.caller.bytes) | |
76 | + | let endHeight = getIntegerValue(this, auctionId) | |
77 | + | let organizer = getStringValue(this, (auctionId + "_organizer")) | |
78 | + | let winner = getString(this, (auctionId + "_winner")) | |
79 | + | let lotAssetId = getStringValue(this, (auctionId + "_lot_assetId")) | |
80 | + | let lotAmount = getIntegerValue(this, (auctionId + "_lot_amount")) | |
81 | + | let priceAssetId = getStringValue(this, (auctionId + "_priceAssetId")) | |
82 | + | let winAmount = getIntegerValue(this, (auctionId + "_winAmount")) | |
83 | + | let lotAsset = if ((lotAssetId == "WAVES")) | |
84 | + | then unit | |
85 | + | else fromBase58String(lotAssetId) | |
86 | + | let priceAsset = if (if ((priceAssetId == "WAVES")) | |
87 | + | then true | |
88 | + | else (priceAssetId == "")) | |
89 | + | then unit | |
90 | + | else fromBase58String(priceAssetId) | |
91 | + | let winnerAddr = addressFromStringValue(value(winner)) | |
92 | + | let organizerAddr = addressFromStringValue(value(organizer)) | |
93 | + | let betAmount = getInteger(this, ((auctionId + "_bidder_") + callerAddressStr)) | |
94 | + | if ((endHeight > lastBlock.height)) | |
95 | + | then throw("Auction is not finished yet") | |
96 | + | else if (!(isDefined(winner))) | |
97 | + | then if (isDefined(getString(this, (auctionId + "_lot_passed")))) | |
98 | + | then throw("Organizer has already got his lot back") | |
99 | + | else ScriptResult(WriteSet([DataEntry((auctionId + "_lot_passed"), organizer)]), TransferSet([ScriptTransfer(organizerAddr, lotAmount, lotAsset)])) | |
100 | + | else if (isDefined(getString(this, (auctionId + "_lot_passed")))) | |
101 | + | then throw("Lot is already passed to the winner, and organizer got his reward") | |
102 | + | else ScriptResult(WriteSet([DataEntry((auctionId + "_lot_passed"), toBase58String(winnerAddr.bytes))]), TransferSet([ScriptTransfer(winnerAddr, lotAmount, lotAsset), ScriptTransfer(organizerAddr, winAmount, priceAsset)])) | |
49 | 103 | } | |
50 | 104 | ||
51 | 105 |
github/deemru/w8io/026f985 29.38 ms ◑