tx · 4YpctKtJh8wwBX2XmQbKBV4GJx4rnqKhjXWKE4pZDM9b

3N9g8vmJj171kPszhaCUyPDNfNPqaXiFP3Z:  -0.04000000 Waves

2020.06.07 23:19 [1033362] smart account 3N9g8vmJj171kPszhaCUyPDNfNPqaXiFP3Z > SELF 0.00000000 Waves

{ "type": 13, "id": "4YpctKtJh8wwBX2XmQbKBV4GJx4rnqKhjXWKE4pZDM9b", "fee": 4000000, "feeAssetId": null, "timestamp": 1591561206034, "version": 1, "sender": "3N9g8vmJj171kPszhaCUyPDNfNPqaXiFP3Z", "senderPublicKey": "G4tSmURBD4HJkP9Q8xjQhetzYDb1J7Bc581de6M9V7AK", "proofs": [ "2EpcR8i6SyAJGqsQux7GK8VHkWECL4xt7v5Uy6haa2bUc9GxjzryKZ6AjUN8Yupy2X9EnMWTCoxYxjnYBCEFMe9Y" ], "script": "base64:AAIDAAAAAAAAAA4IARIDCgEIEgUKAwgBCAAAAAcAAAAABE5PTkUCAAAABG5vbmUBAAAACmdldEtleUl0ZW0AAAACAAAACHN1cHBsaWVyAAAABXRpdGxlCQABLAAAAAICAAAABWl0ZW1fCQACWAAAAAEJAAH3AAAAAQkAAZsAAAABCQABLAAAAAIFAAAACHN1cHBsaWVyBQAAAAV0aXRsZQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAAEmdldEtleUl0ZW1TdXBwbGllcgAAAAEAAAAEaXRlbQkAASwAAAACBQAAAARpdGVtAgAAAAZfb3duZXIBAAAAFGdldFZhbHVlSXRlbVN1cHBsaWVyAAAAAQAAAARpdGVtCQEAAAALZ2V0U3RyQnlLZXkAAAABCQEAAAASZ2V0S2V5SXRlbVN1cHBsaWVyAAAA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Complexity": 0 } View: original | compacted Prev: DFWPLH6T6C7CXDqBTWGPY8VM3tPiqocXo14H8jCxvw4D Next: none Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let NONE = "none"
5+
6+func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
7+
8+
9+func getStrByKey (key) = {
10+ let str = match getString(this, key) {
11+ case a: String =>
12+ a
13+ case _ =>
14+ NONE
15+ }
16+ str
17+ }
18+
19+
20+func getKeyItemSupplier (item) = (item + "_owner")
21+
22+
23+func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
24+
25+
26+func getKeyItemPrice (item) = (item + "_price")
27+
28+
29+func getKeyItemData (item) = (item + "_data")
430
531
632 @Callable(i)
2551 }
2652
2753
54+
55+@Callable(i)
56+func addItem (title,price,data) = {
57+ let supplierAdreess = toBase58String(i.caller.bytes)
58+ let item = getKeyItem(supplierAdreess, title)
59+ if ((0 >= price))
60+ then throw("purchase amount cannot be less than item price")
61+ else if ((getValueItemSupplier(item) != NONE))
62+ then throw("an item already exist")
63+ else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAdreess), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
64+ }
65+
66+
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let NONE = "none"
5+
6+func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
7+
8+
9+func getStrByKey (key) = {
10+ let str = match getString(this, key) {
11+ case a: String =>
12+ a
13+ case _ =>
14+ NONE
15+ }
16+ str
17+ }
18+
19+
20+func getKeyItemSupplier (item) = (item + "_owner")
21+
22+
23+func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
24+
25+
26+func getKeyItemPrice (item) = (item + "_price")
27+
28+
29+func getKeyItemData (item) = (item + "_data")
430
531
632 @Callable(i)
733 func purchase (item) = {
834 let pmt = extract(i.payment)
935 if (isDefined(pmt.assetId))
1036 then throw("can use WAVES only at the moment")
1137 else {
1238 let customerAdreess = toBase58String(i.caller.bytes)
1339 let price = match getInteger(this, (("item_" + item) + "_coupon_price")) {
1440 case a: Int =>
1541 a
1642 case _ =>
1743 0
1844 }
1945 if ((price > pmt.amount))
2046 then throw("purchase amount cannot be less than item price")
2147 else if ((pmt.amount > price))
2248 then throw("purchase amount cannot be higher than item price")
2349 else WriteSet([DataEntry(((("status:purchase_item_" + item) + "_customer_") + customerAdreess), "confirmed"), DataEntry(((("price:purchase_item_" + item) + "_customer_") + customerAdreess), price)])
2450 }
2551 }
2652
2753
54+
55+@Callable(i)
56+func addItem (title,price,data) = {
57+ let supplierAdreess = toBase58String(i.caller.bytes)
58+ let item = getKeyItem(supplierAdreess, title)
59+ if ((0 >= price))
60+ then throw("purchase amount cannot be less than item price")
61+ else if ((getValueItemSupplier(item) != NONE))
62+ then throw("an item already exist")
63+ else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAdreess), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
64+ }
65+
66+

github/deemru/w8io/169f3d6 
26.94 ms