tx · EYXDPZxqCwJfRiCEymYW1K43BcM3DnwrKxQymrqRPmpb 3N2icgpJnXhcYab7KQrwqWsV4LwSF25C1Ep: -0.01400000 Waves 2019.07.12 13:04 [582362] smart account 3N2icgpJnXhcYab7KQrwqWsV4LwSF25C1Ep > SELF 0.00000000 Waves
{ "type": 13, "id": "EYXDPZxqCwJfRiCEymYW1K43BcM3DnwrKxQymrqRPmpb", "fee": 1400000, "feeAssetId": null, "timestamp": 1562925911850, "version": 1, "sender": "3N2icgpJnXhcYab7KQrwqWsV4LwSF25C1Ep", "senderPublicKey": "BJAeTqNbDSA5FiYihZZaSWvD6XL5XjpqVXbTGerBJjRK", "proofs": [ "GwPYra947jvJokfH7NUYWy1bQeszTTPsLvqdJXjK9yUdbVGE3aQgK8KkmRashKwgEp8WvGBVBzYs4BGFbaAyANM" ], "script": "base64:AAIDAAAAAAAAAAAAAAADAAAAAAd0b2tlbklkAQAAACCU1B7l35UfeySUCJ5Oe8nTMKHr4huFqp+vPk8CQCqTZQEAAAASdXNlckhhc0FkbWluQWNjZXNzAAAAAQAAAAdhZGRyZXNzCQAAAAAAAAIFAAAAB2FkZHJlc3MFAAAABHRoaXMBAAAABGFkZHIAAAACAAAAB3Rva2VuSWQAAAADcGFyCQABLAAAAAIJAAEsAAAAAgkAAlgAAAABBQAAAAd0b2tlbklkAgAAAAFfBQAAAANwYXIAAAADAAAAAWkBAAAAA2JldAAAAAEAAAAHdG9rZW5JZAQAAAAWc3RhcnRUcmFuc2FjdGlvbkhlaWdodAkBAAAAEUBleHRyTmF0aXZlKDEwNTApAAAAAgUAAAAEdGhpcwkBAAAABGFkZHIAAAACBQAAAAd0b2tlbklkAgAAAAVzdGFydAQAAAAJdGltZURlbHRhCQAAZQAAAAIFAAAABmhlaWdodAUAAAAWc3RhcnRUcmFuc2FjdGlvbkhlaWdodAQAAAAGbWF4QmV0CQEAAAAHZXh0cmFjdAAAAAEJAAQaAAAAAgUAAAAEdGhpcwkBAAAABGFkZHIAAAACB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ABmAAAAAgUAAAAFZGVsdGEAAAAAAAAAAAAJAAACAAAAAQkAASwAAAACCQABLAAAAAICAAAAJFRoZSBhdWN0aW9uIGNhbm5vdCBiZSBmaW5pc2hlZCB5ZXQhIAkAAaQAAAABBQAAAAVkZWx0YQIAAAASIG1pbnV0ZXMgcmVtYWluaW5nBAAAAAttYXhCZXRPd25lcgkBAAAAFGFkZHJlc3NGcm9tUHVibGljS2V5AAAAAQkAAZsAAAABCQEAAAARQGV4dHJOYXRpdmUoMTA1MykAAAACBQAAAAR0aGlzCQEAAAAEYWRkcgAAAAIFAAAAB3Rva2VuSWQCAAAAC21heEJldE93bmVyCQEAAAAMU2NyaXB0UmVzdWx0AAAAAgkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAABGFkZHIAAAACBQAAAAd0b2tlbklkAgAAAAVzdGFydAAAAAAAAAAAAAUAAAADbmlsCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMFAAAAC21heEJldE93bmVyAAAAAAAAAAABBQAAAAd0b2tlbklkBQAAAANuaWwAAAAAS8Va3g==", "chainId": 84, "height": 582362, "spentComplexity": 0 } View: original | compacted Prev: j5SYJKcaTsx5Lc6m9PC9fXPCW2FkuU1zw3qLKDrhgJM Next: A8bNzr9FPNdNYqfsPCB55Crq8CD1W83knYwktyjJwMDe Diff:
Old | New | Differences | |
---|---|---|---|
6 | 6 | func userHasAdminAccess (address) = (address == this) | |
7 | 7 | ||
8 | 8 | ||
9 | + | func addr (tokenId,par) = ((toBase58String(tokenId) + "_") + par) | |
10 | + | ||
11 | + | ||
9 | 12 | @Callable(i) | |
10 | - | func bet () = { | |
11 | - | let startTransactionHeight = getIntegerValue(this, "start") | |
13 | + | func bet (tokenId) = { | |
14 | + | let startTransactionHeight = getIntegerValue(this, addr(tokenId, "start")) | |
12 | 15 | let timeDelta = (height - startTransactionHeight) | |
13 | - | let maxBet = extract(getInteger(this, "maxBet")) | |
14 | - | let maxBetOwner = addressFromPublicKey(toBytes(getStringValue(this, "maxBetOwner"))) | |
16 | + | let maxBet = extract(getInteger(this, addr(tokenId, "maxBet"))) | |
17 | + | let maxBetOwner = addressFromPublicKey(toBytes(getStringValue(this, addr(tokenId, "maxBetOwner")))) | |
15 | 18 | let pmt = extract(i.payment) | |
16 | 19 | if ((timeDelta > 2000)) | |
17 | 20 | then throw("The betting was closed") | |
19 | 22 | then { | |
20 | 23 | let price = pmt.amount | |
21 | 24 | if ((price > maxBet)) | |
22 | - | then ScriptResult(WriteSet([DataEntry("maxBet", price), DataEntry("maxBetOwner", toBase58String(i.callerPublicKey) | |
25 | + | then ScriptResult(WriteSet([DataEntry(addr(tokenId, "maxBet"), price), DataEntry(addr(tokenId, "maxBetOwner"), toBase58String(i.callerPublicKey))]), TransferSet([ScriptTransfer(maxBetOwner, maxBet, unit)])) | |
23 | 26 | else throw("Your bet isn't the max bet") | |
24 | 27 | } | |
25 | 28 | else throw("You need to place a bet using waves currency") | |
28 | 31 | ||
29 | 32 | ||
30 | 33 | @Callable(i) | |
31 | - | func start (startPrice) = if (!(userHasAdminAccess(i.caller))) | |
32 | - | then throw("You have no access!") | |
33 | - | else WriteSet([DataEntry("start", height), DataEntry("maxBet", startPrice), DataEntry("maxBetOwner", toBase58String(i.callerPublicKey))]) | |
34 | + | func start (startPrice,auctionDuration) = { | |
35 | + | let pmt = extract(i.payment) | |
36 | + | let tokenIn = pmt.assetId | |
37 | + | if (isDefined(tokenId)) | |
38 | + | then WriteSet([DataEntry(addr(tokenId, "start"), height), DataEntry(addr(tokenId, "startPrice"), startPrice), DataEntry(addr(tokenId, "duration"), auctionDuration), DataEntry(addr(tokenId, "maxBetOwner"), toBase58String(i.callerPublicKey))]) | |
39 | + | else throw("You can't sell waves using the auction") | |
40 | + | } | |
34 | 41 | ||
35 | 42 | ||
36 | 43 | ||
37 | 44 | @Callable(i) | |
38 | - | func finish () = if (!(userHasAdminAccess(i.caller))) | |
39 | - | then throw("You have no access!") | |
40 | - | else { | |
41 | - | let maxBetOwner = addressFromPublicKey(toBytes(getStringValue(this, "maxBetOwner"))) | |
42 | - | ScriptResult(WriteSet([DataEntry("start", 0)]), TransferSet([ScriptTransfer(maxBetOwner, 1, tokenId)])) | |
43 | - | } | |
45 | + | func finish (tokenId) = { | |
46 | + | let length = (getIntegerValue(this, addr(tokenId, "start")) - height) | |
47 | + | let delta = (getIntegerValue(this, addr(tokenId, "duration")) - length) | |
48 | + | if ((delta > 0)) | |
49 | + | then throw((("The auction cannot be finished yet! " + toString(delta)) + " minutes remaining")) | |
50 | + | else { | |
51 | + | let maxBetOwner = addressFromPublicKey(toBytes(getStringValue(this, addr(tokenId, "maxBetOwner")))) | |
52 | + | ScriptResult(WriteSet([DataEntry(addr(tokenId, "start"), 0)]), TransferSet([ScriptTransfer(maxBetOwner, 1, tokenId)])) | |
53 | + | } | |
54 | + | } | |
44 | 55 | ||
45 | 56 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let tokenId = base58'B1xwWnBLB7z79VPr4sq1jBb5GDqs8TeT5jHojTdiwxfE' | |
5 | 5 | ||
6 | 6 | func userHasAdminAccess (address) = (address == this) | |
7 | 7 | ||
8 | 8 | ||
9 | + | func addr (tokenId,par) = ((toBase58String(tokenId) + "_") + par) | |
10 | + | ||
11 | + | ||
9 | 12 | @Callable(i) | |
10 | - | func bet () = { | |
11 | - | let startTransactionHeight = getIntegerValue(this, "start") | |
13 | + | func bet (tokenId) = { | |
14 | + | let startTransactionHeight = getIntegerValue(this, addr(tokenId, "start")) | |
12 | 15 | let timeDelta = (height - startTransactionHeight) | |
13 | - | let maxBet = extract(getInteger(this, "maxBet")) | |
14 | - | let maxBetOwner = addressFromPublicKey(toBytes(getStringValue(this, "maxBetOwner"))) | |
16 | + | let maxBet = extract(getInteger(this, addr(tokenId, "maxBet"))) | |
17 | + | let maxBetOwner = addressFromPublicKey(toBytes(getStringValue(this, addr(tokenId, "maxBetOwner")))) | |
15 | 18 | let pmt = extract(i.payment) | |
16 | 19 | if ((timeDelta > 2000)) | |
17 | 20 | then throw("The betting was closed") | |
18 | 21 | else if (!(isDefined(pmt.assetId))) | |
19 | 22 | then { | |
20 | 23 | let price = pmt.amount | |
21 | 24 | if ((price > maxBet)) | |
22 | - | then ScriptResult(WriteSet([DataEntry("maxBet", price), DataEntry("maxBetOwner", toBase58String(i.callerPublicKey) | |
25 | + | then ScriptResult(WriteSet([DataEntry(addr(tokenId, "maxBet"), price), DataEntry(addr(tokenId, "maxBetOwner"), toBase58String(i.callerPublicKey))]), TransferSet([ScriptTransfer(maxBetOwner, maxBet, unit)])) | |
23 | 26 | else throw("Your bet isn't the max bet") | |
24 | 27 | } | |
25 | 28 | else throw("You need to place a bet using waves currency") | |
26 | 29 | } | |
27 | 30 | ||
28 | 31 | ||
29 | 32 | ||
30 | 33 | @Callable(i) | |
31 | - | func start (startPrice) = if (!(userHasAdminAccess(i.caller))) | |
32 | - | then throw("You have no access!") | |
33 | - | else WriteSet([DataEntry("start", height), DataEntry("maxBet", startPrice), DataEntry("maxBetOwner", toBase58String(i.callerPublicKey))]) | |
34 | + | func start (startPrice,auctionDuration) = { | |
35 | + | let pmt = extract(i.payment) | |
36 | + | let tokenIn = pmt.assetId | |
37 | + | if (isDefined(tokenId)) | |
38 | + | then WriteSet([DataEntry(addr(tokenId, "start"), height), DataEntry(addr(tokenId, "startPrice"), startPrice), DataEntry(addr(tokenId, "duration"), auctionDuration), DataEntry(addr(tokenId, "maxBetOwner"), toBase58String(i.callerPublicKey))]) | |
39 | + | else throw("You can't sell waves using the auction") | |
40 | + | } | |
34 | 41 | ||
35 | 42 | ||
36 | 43 | ||
37 | 44 | @Callable(i) | |
38 | - | func finish () = if (!(userHasAdminAccess(i.caller))) | |
39 | - | then throw("You have no access!") | |
40 | - | else { | |
41 | - | let maxBetOwner = addressFromPublicKey(toBytes(getStringValue(this, "maxBetOwner"))) | |
42 | - | ScriptResult(WriteSet([DataEntry("start", 0)]), TransferSet([ScriptTransfer(maxBetOwner, 1, tokenId)])) | |
43 | - | } | |
45 | + | func finish (tokenId) = { | |
46 | + | let length = (getIntegerValue(this, addr(tokenId, "start")) - height) | |
47 | + | let delta = (getIntegerValue(this, addr(tokenId, "duration")) - length) | |
48 | + | if ((delta > 0)) | |
49 | + | then throw((("The auction cannot be finished yet! " + toString(delta)) + " minutes remaining")) | |
50 | + | else { | |
51 | + | let maxBetOwner = addressFromPublicKey(toBytes(getStringValue(this, addr(tokenId, "maxBetOwner")))) | |
52 | + | ScriptResult(WriteSet([DataEntry(addr(tokenId, "start"), 0)]), TransferSet([ScriptTransfer(maxBetOwner, 1, tokenId)])) | |
53 | + | } | |
54 | + | } | |
44 | 55 | ||
45 | 56 |
github/deemru/w8io/169f3d6 27.62 ms ◑