tx · 3JyvVexJAg7yTwqPJGPyVDigVgXafJq8mULgu5T62eat

3MrDcz4LFFjPhXdtu7YCqFSnHc3pD1tcWLa:  -0.01400000 Waves

2019.08.17 12:31 [634920] smart account 3MrDcz4LFFjPhXdtu7YCqFSnHc3pD1tcWLa > SELF 0.00000000 Waves

{ "type": 13, "id": "3JyvVexJAg7yTwqPJGPyVDigVgXafJq8mULgu5T62eat", "fee": 1400000, "feeAssetId": null, "timestamp": 1566034329651, "version": 1, "sender": "3MrDcz4LFFjPhXdtu7YCqFSnHc3pD1tcWLa", "senderPublicKey": "DMndfYeRYfHnVPek52VfuzXJS3A6UJRZrSJX6PMqMMjD", "proofs": [ "2Fy1Hppi2dodYnc8AAKah1YQxzXXkFdFYCXBntbR7fZMq6Rwq6TGS2UwPTVSeUYZ5gmBpRBuSss5UbMy9z3qEggo" ], "script": "base64:AAIDAAAAAAAAAAAAAAAHAAAAAAx3YXZlc0Fzc2V0SWQBAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAhnZXRQcmljZQAAAAEAAAAEZGF0YQkABLEAAAABCQAAyQAAAAIFAAAABGRhdGEAAAAAAAAAAAgBAAAACGdldFN0b2NrAAAAAQAAAARkYXRhCQAEsQAAAAEJAADJAAAAAgkAAMoAAAACBQAAAARkYXRhAAAAAAAAAAAIAAAAAAAAAAAIAQAAAA5nZXRBbW91bnRBc3NldAAAAAEAAAAEZGF0YQkAAMkAAAACCQAAygAAAAIFAAAABGRhdGEJAABkAAAAAgkAAGQAAAACAAAAAAAAAAAIAAAAAAAAAAAIAAAAAAAAAAAgAAAAAAAAAAAgAQAAAAlnZXRTZWxsZXIAAAABAAAABGRhdGEJAADKAAAAAgUAAAAEZGF0YQkAAGQAAAACCQAAZAAAAAIJAABkAAAAAgAAAAAAAAAACAAAAAAAAAAACAAAAAAAAAAAIAAAAAAAAAAAIAEAAAANZ2V0UHJpY2VBc3NldAAAAAEAAAAEZGF0YQQAAAACcHI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Y2VBc3NldAgFAAAAAXAAAAAHYXNzZXRJZAkAAAIAAAABAgAAABZJbnZhbGlkIHBheW1lbnQgYXNzZXQuCQEAAAAMU2NyaXB0UmVzdWx0AAAAAgkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJc2VyaWFsaXplAAAABgUAAAAFbG90SWQFAAAABXByaWNlCQAAZQAAAAIFAAAABXN0b2NrBQAAAAthbW91bnRUb0J1eQUAAAAKcHJpY2VBc3NldAUAAAALYW1vdW50QXNzZXQFAAAABnNlbGxlcgUAAAADbmlsCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgUAAAALYW1vdW50VG9CdXkFAAAAC2Ftb3VudEFzc2V0CQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMJAQAAABRhZGRyZXNzRnJvbVB1YmxpY0tleQAAAAEFAAAABnNlbGxlcgUAAAAFcHJpY2UFAAAACnByaWNlQXNzZXQFAAAAA25pbAAAAAA6h7OJ", "chainId": 84, "height": 634920, "spentComplexity": 0 } View: original | compacted Prev: 6rr5gB1aUUUfoLkEUaB8v9sF6Ry6sofR6sK8StZdPD5u Next: none Diff:
OldNewDifferences
6565 @Callable(i)
6666 func cancel (lotId) = {
6767 let data = extract(getBinary(this, lotId))
68- let price = toInt(take(data, 8))
69- let amount = toInt(take(drop(data, 0), 8))
70- let priceAsset = take(drop(data, (8 + 8)), 32)
71- let amountAsset = take(drop(data, ((8 + 8) + 32)), 32)
72- let seller = drop(data, (((8 + 8) + 32) + 32))
68+ let price = getPrice(data)
69+ let stock = getStock(data)
70+ let priceAsset = getPriceAsset(data)
71+ let amountAsset = getAmountAsset(data)
72+ let seller = getSeller(data)
7373 if ((seller != i.callerPublicKey))
7474 then throw("Only seller can cancel the lot.")
75- else ScriptResult(WriteSet([serialize(lotId, price, 0, priceAsset, amountAsset, seller)]), TransferSet([ScriptTransfer(addressFromPublicKey(seller), amount, amountAsset)]))
75+ else ScriptResult(WriteSet([serialize(lotId, price, 0, priceAsset, amountAsset, seller)]), TransferSet([ScriptTransfer(addressFromPublicKey(seller), stock, amountAsset)]))
7676 }
7777
7878
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let wavesAssetId = base58'11111111111111111111111111111111'
55
66 func getPrice (data) = toInt(take(data, 8))
77
88
99 func getStock (data) = toInt(take(drop(data, 8), 8))
1010
1111
1212 func getAmountAsset (data) = take(drop(data, ((8 + 8) + 32)), 32)
1313
1414
1515 func getSeller (data) = drop(data, (((8 + 8) + 32) + 32))
1616
1717
1818 func getPriceAsset (data) = {
1919 let pr = take(drop(data, (8 + 8)), 32)
2020 if ((pr == wavesAssetId))
2121 then unit
2222 else pr
2323 }
2424
2525
2626 func serialize (lotId,price,stock,priceAsset,amountAsset,seller) = {
2727 let idAsString = match lotId {
2828 case s: String =>
2929 s
3030 case bv: ByteVector =>
3131 toBase58String(bv)
3232 case _ =>
3333 throw()
3434 }
3535 let priceAssetBytes = match priceAsset {
3636 case u: Unit =>
3737 wavesAssetId
3838 case bv: ByteVector =>
3939 bv
4040 case _ =>
4141 throw()
4242 }
4343 DataEntry(idAsString, ((((toBytes(price) + toBytes(stock)) + priceAssetBytes) + amountAsset) + seller))
4444 }
4545
4646
4747 @Callable(i)
4848 func sell (price,priceAsset) = {
4949 let p = extract(i.payment)
5050 if (if ((p.assetId == unit))
5151 then true
5252 else (p.assetId == wavesAssetId))
5353 then throw("Invalid asset to sell.")
5454 else if ((size(priceAsset) != 32))
5555 then throw((("Invalid asset: " + toBase58String(priceAsset)) + ", expected price asset size should be 32."))
5656 else if ((0 >= price))
5757 then throw((("Invalid price: " + toString(price)) + ", expected price should be greater than zero."))
5858 else if ((0 >= p.amount))
5959 then throw((("Invalid amount for sell: " + toString(p.amount)) + ", expected amount should be greater than zero."))
6060 else WriteSet([serialize(i.transactionId, price, p.amount, priceAsset, extract(extract(i.payment).assetId), i.callerPublicKey)])
6161 }
6262
6363
6464
6565 @Callable(i)
6666 func cancel (lotId) = {
6767 let data = extract(getBinary(this, lotId))
68- let price = toInt(take(data, 8))
69- let amount = toInt(take(drop(data, 0), 8))
70- let priceAsset = take(drop(data, (8 + 8)), 32)
71- let amountAsset = take(drop(data, ((8 + 8) + 32)), 32)
72- let seller = drop(data, (((8 + 8) + 32) + 32))
68+ let price = getPrice(data)
69+ let stock = getStock(data)
70+ let priceAsset = getPriceAsset(data)
71+ let amountAsset = getAmountAsset(data)
72+ let seller = getSeller(data)
7373 if ((seller != i.callerPublicKey))
7474 then throw("Only seller can cancel the lot.")
75- else ScriptResult(WriteSet([serialize(lotId, price, 0, priceAsset, amountAsset, seller)]), TransferSet([ScriptTransfer(addressFromPublicKey(seller), amount, amountAsset)]))
75+ else ScriptResult(WriteSet([serialize(lotId, price, 0, priceAsset, amountAsset, seller)]), TransferSet([ScriptTransfer(addressFromPublicKey(seller), stock, amountAsset)]))
7676 }
7777
7878
7979
8080 @Callable(i)
8181 func buy (lotId,amountToBuy) = {
8282 let data = extract(getBinary(this, lotId))
8383 let price = getPrice(data)
8484 let stock = getStock(data)
8585 let priceAsset = getPriceAsset(data)
8686 let amountAsset = getAmountAsset(data)
8787 let seller = getSeller(data)
8888 let p = extract(i.payment)
8989 if ((0 >= stock))
9090 then throw("Lot is closed or cancelled, 0 items in stock.")
9191 else if ((p.assetId == wavesAssetId))
9292 then throw("Invalid payment asset.")
9393 else if ((0 >= amountToBuy))
9494 then throw((("Invalid amount to buy: " + toString(amountToBuy)) + ", expected amount should be greater than zero."))
9595 else if (((amountToBuy * price) != p.amount))
9696 then throw((((("Invalid payment amount: " + toString(p.amount)) + ", expected amount should be: ") + toString((amountToBuy * price))) + "."))
9797 else if ((amountToBuy > stock))
9898 then throw("Not enough items in stock.")
9999 else if ((priceAsset != p.assetId))
100100 then throw("Invalid payment asset.")
101101 else ScriptResult(WriteSet([serialize(lotId, price, (stock - amountToBuy), priceAsset, amountAsset, seller)]), TransferSet([ScriptTransfer(i.caller, amountToBuy, amountAsset), ScriptTransfer(addressFromPublicKey(seller), price, priceAsset)]))
102102 }
103103
104104

github/deemru/w8io/026f985 
39.30 ms