tx · 7At5dpMZZ2gyjnm6wrSaFSGoMBVj4pBV1azMnTVPAwZd 3N72SETEKtTuaA3YNVYWgVEmXKrRrZYXHGo: -0.01000000 Waves 2022.12.02 13:14 [2342595] smart account 3N72SETEKtTuaA3YNVYWgVEmXKrRrZYXHGo > SELF 0.00000000 Waves
{ "type": 13, "id": "7At5dpMZZ2gyjnm6wrSaFSGoMBVj4pBV1azMnTVPAwZd", "fee": 1000000, "feeAssetId": null, "timestamp": 1669976060695, "version": 2, "chainId": 84, "sender": "3N72SETEKtTuaA3YNVYWgVEmXKrRrZYXHGo", "senderPublicKey": "Kwu4LYBMntApXv8t7csxV23Kvc3tvak26wMKK56tA4V", "proofs": [ "4871Rhox3ojMNXH4mfVdSPyo9tjLH4MPmtfeLNc3D2JZ5QPgkJDVonWBkQ48aadgAgdJERjt17ww336thggNRJc6" ], "script": "base64:BgISCAISBAoCAQESAwoBCBIDCgEIAQASbWF4QXVjdGlvbkR1cmF0aW9uAAcDAWkBDHN0YXJ0QXVjdGlvbgIIZHVyYXRpb24Kc3RhcnRQcmljZQQJYXVjdGlvbklkCQDYBAEIBQFpDXRyYW5zYWN0aW9uSWQECWVuZEhlaWdodAkAZAIIBQlsYXN0QmxvY2sGaGVpZ2h0BQhkdXJhdGlvbgQDcG10CQEFdmFsdWUBCQCRAwIIBQFpCHBheW1lbnRzAAADCQBmAgUIZHVyYXRpb24FEm1heEF1Y3Rpb25EdXJhdGlvbgkAAgEJAKwCAgIoRHVyYXRpb24gaXMgdG9vIGxvbmcuIE11c3QgYmUgbGVzcyB0aGFuIAkApAMBBRJtYXhBdWN0aW9uRHVyYXRpb24JAMwIAgkBDEludGVnZXJFbnRyeQIFCWF1Y3Rpb25JZAUJZW5kSGVpZ2h0CQDMCAIJAQtTdHJpbmdFbnRyeQIJAKwCAgUJYXVjdGlvbklkAgpfb3JnYW5pemVyCQDYBAEICAUBaQZjYWxsZXIFYnl0ZXMJAMwIAgkBC1N0cmluZ0VudHJ5AgkArAICBQ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5lckFkZHIFCWxvdEFtb3VudAUIbG90QXNzZXQJAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwUNb3JnYW5pemVyQWRkcgUJd2luQW1vdW50BQpwcmljZUFzc2V0BQNuaWwAwKXLEg==", "height": 2342595, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4WqTPsAurkDKw5Pw24HKqiqe5NAqsYYxzrQYnp7YWWFq Next: GqX7Wqar3CeW3K2XpXcyJNhtHBYqQGhsfKWtZqi63K8b Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let maxAuctionDuration = 7 | |
5 | + | ||
6 | + | @Callable(i) | |
7 | + | func startAuction (duration,startPrice) = { | |
8 | + | let auctionId = toBase58String(i.transactionId) | |
9 | + | let endHeight = (lastBlock.height + duration) | |
10 | + | let pmt = value(i.payments[0]) | |
11 | + | if ((duration > maxAuctionDuration)) | |
12 | + | then throw(("Duration is too long. Must be less than " + toString(maxAuctionDuration))) | |
13 | + | else [IntegerEntry(auctionId, endHeight), StringEntry((auctionId + "_organizer"), toBase58String(i.caller.bytes)), StringEntry((auctionId + "_lot_assetId"), if (isDefined(pmt.assetId)) | |
14 | + | then toBase58String(value(pmt.assetId)) | |
15 | + | else "WAVES"), IntegerEntry((auctionId + "_lot_amount"), pmt.amount), IntegerEntry((auctionId + "_startPrice"), startPrice)] | |
16 | + | } | |
17 | + | ||
4 | 18 | ||
5 | 19 | ||
6 | 20 | @Callable(i) | |
51 | 65 | } | |
52 | 66 | ||
53 | 67 | ||
68 | + | ||
69 | + | @Callable(i) | |
70 | + | func withdraw (auctionId) = { | |
71 | + | let pmt = value(i.payments[0]) | |
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 [StringEntry((auctionId + "_lot_passed"), organizer), 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 [StringEntry((auctionId + "_lot_passed"), toBase58String(winnerAddr.bytes)), ScriptTransfer(winnerAddr, lotAmount, lotAsset), ScriptTransfer(organizerAddr, winAmount, priceAsset)] | |
103 | + | } | |
104 | + | ||
105 | + |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let maxAuctionDuration = 7 | |
5 | + | ||
6 | + | @Callable(i) | |
7 | + | func startAuction (duration,startPrice) = { | |
8 | + | let auctionId = toBase58String(i.transactionId) | |
9 | + | let endHeight = (lastBlock.height + duration) | |
10 | + | let pmt = value(i.payments[0]) | |
11 | + | if ((duration > maxAuctionDuration)) | |
12 | + | then throw(("Duration is too long. Must be less than " + toString(maxAuctionDuration))) | |
13 | + | else [IntegerEntry(auctionId, endHeight), StringEntry((auctionId + "_organizer"), toBase58String(i.caller.bytes)), StringEntry((auctionId + "_lot_assetId"), if (isDefined(pmt.assetId)) | |
14 | + | then toBase58String(value(pmt.assetId)) | |
15 | + | else "WAVES"), IntegerEntry((auctionId + "_lot_amount"), pmt.amount), IntegerEntry((auctionId + "_startPrice"), startPrice)] | |
16 | + | } | |
17 | + | ||
4 | 18 | ||
5 | 19 | ||
6 | 20 | @Callable(i) | |
7 | 21 | func bid (auctionId) = { | |
8 | 22 | let pmt = value(i.payments[0]) | |
9 | 23 | let pmtAssetIdStr = if (isDefined(pmt.assetId)) | |
10 | 24 | then toBase58String(value(pmt.assetId)) | |
11 | 25 | else "WAVES" | |
12 | 26 | let callerAddressStr = toBase58String(i.caller.bytes) | |
13 | 27 | let endHeight = getIntegerValue(this, auctionId) | |
14 | 28 | let startPrice = getIntegerValue(this, (auctionId + "_startPrice")) | |
15 | 29 | let priceAssetId = getStringValue(this, (auctionId + "_priceAssetId")) | |
16 | 30 | let winAmount = getInteger(this, (auctionId + "_winAmount")) | |
17 | 31 | let winner = getString(this, (auctionId + "_winner")) | |
18 | 32 | let bidFromTheSameUser = if (isDefined(winner)) | |
19 | 33 | then (value(winner) == callerAddressStr) | |
20 | 34 | else false | |
21 | 35 | let totalBidAmount = (pmt.amount + (if (bidFromTheSameUser) | |
22 | 36 | then value(winAmount) | |
23 | 37 | else 0)) | |
24 | 38 | if ((lastBlock.height >= endHeight)) | |
25 | 39 | then throw("Auction already finished") | |
26 | 40 | else if ((priceAssetId != pmtAssetIdStr)) | |
27 | 41 | then throw((("Bid must be in asset '" + priceAssetId) + "'")) | |
28 | 42 | else if (if (if (isDefined(winAmount)) | |
29 | 43 | then (value(winAmount) >= totalBidAmount) | |
30 | 44 | else false) | |
31 | 45 | then true | |
32 | 46 | else if (!(isDefined(winAmount))) | |
33 | 47 | then (startPrice >= totalBidAmount) | |
34 | 48 | else false) | |
35 | 49 | then throw(("Bid must be more then " + toString(if (isDefined(winAmount)) | |
36 | 50 | then value(winAmount) | |
37 | 51 | else startPrice))) | |
38 | 52 | else if (if (bidFromTheSameUser) | |
39 | 53 | then true | |
40 | 54 | else !(isDefined(winner))) | |
41 | 55 | then [StringEntry((auctionId + "_winner"), callerAddressStr), IntegerEntry((auctionId + "_winAmount"), totalBidAmount)] | |
42 | 56 | else { | |
43 | 57 | let previousBidderAddr = addressFromStringValue(value(winner)) | |
44 | 58 | let priceAsset = if (if ((priceAssetId == "WAVES")) | |
45 | 59 | then true | |
46 | 60 | else (priceAssetId == "")) | |
47 | 61 | then unit | |
48 | 62 | else fromBase58String(priceAssetId) | |
49 | 63 | [StringEntry((auctionId + "_winner"), callerAddressStr), IntegerEntry((auctionId + "_winAmount"), totalBidAmount), ScriptTransfer(previousBidderAddr, value(winAmount), priceAsset)] | |
50 | 64 | } | |
51 | 65 | } | |
52 | 66 | ||
53 | 67 | ||
68 | + | ||
69 | + | @Callable(i) | |
70 | + | func withdraw (auctionId) = { | |
71 | + | let pmt = value(i.payments[0]) | |
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 [StringEntry((auctionId + "_lot_passed"), organizer), 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 [StringEntry((auctionId + "_lot_passed"), toBase58String(winnerAddr.bytes)), ScriptTransfer(winnerAddr, lotAmount, lotAsset), ScriptTransfer(organizerAddr, winAmount, priceAsset)] | |
103 | + | } | |
104 | + | ||
105 | + |
github/deemru/w8io/026f985 38.50 ms ◑