tx · E3xmChHohnbUeaqyMdKQhNz3PwfiJsU9z7YfhZocYGfK

3Mza1UcSrYad2hGwnxRpxbquAoP4ee7kS7X:  -0.01400000 Waves

2019.07.16 17:35 [588507] smart account 3Mza1UcSrYad2hGwnxRpxbquAoP4ee7kS7X > SELF 0.00000000 Waves

{ "type": 13, "id": "E3xmChHohnbUeaqyMdKQhNz3PwfiJsU9z7YfhZocYGfK", "fee": 1400000, "feeAssetId": null, "timestamp": 1563287724513, "version": 1, "sender": "3Mza1UcSrYad2hGwnxRpxbquAoP4ee7kS7X", "senderPublicKey": "BDzd4V6bFqvL3bMmceVKyprt22wBJBe683pvQ2t5NMU5", "proofs": [ "4RscZHnwDwNmNpWywXS99gKHsa6svdzgC1zwLuaF9BvUQmSs8T7vRUkwsJTWDkzZneJYYfE5XdgJxMdhmzJ2jBPa" ], "script": "base64:AAIDAAAAAAAAAAAAAAANAAAAAAROT05FAgAAAARub25lAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAAD2dldEtleUl0ZW1QcmljZQAAAAEAAAAEaXRlbQkAASwAAAACBQAAAARpdGVtAgAAAAZfcHJpY2UBAAAAEWdldFZhbHVlSXRlbVByaWNlAAAAAQAAAARpdGVtCQEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABCQEAAAAPZ2V0S2V5SXRlbVByaWNlA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ABXByaWNlCQEAAAARZ2V0VmFsdWVJdGVtUHJpY2UAAAABBQAAAARpdGVtBAAAAA9zdXBwbGllckFkZHJlc3MJAQAAABRnZXRWYWx1ZUl0ZW1TdXBwbGllcgAAAAEFAAAABGl0ZW0DCQAAZgAAAAIFAAAABXByaWNlCAUAAAADcG10AAAABmFtb3VudAkAAAIAAAABAgAAAC5hYW5rb29wYmVkcmFnIGthbiBuaWV0IGxhZ2VyIHppam4gZGFuIGRlIHByaWpzAwkAAGYAAAACCAUAAAADcG10AAAABmFtb3VudAUAAAAFcHJpY2UJAAACAAAAAQIAAAAuYWFua29vcGJlZHJhZyBrYW4gbmlldCBob2dlciB6aWpuIGRhbiBkZSBwcmlqcwkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAFWdldEtleVVzZXJJdGVtQ291bnRlcgAAAAIFAAAAC3VzZXJBZGRyZXNzBQAAAARpdGVtCQAAZAAAAAIJAQAAABdnZXRWYWx1ZVVzZXJJdGVtQ291bnRlcgAAAAIFAAAAC3VzZXJBZGRyZXNzBQAAAARpdGVtAAAAAAAAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAVZ2V0S2V5QmFsYW5jZVN1cHBsaWVyAAAAAQUAAAAPc3VwcGxpZXJBZGRyZXNzCQAAZAAAAAIJAQAAABdnZXRWYWx1ZUJhbGFuY2VTdXBwbGllcgAAAAEFAAAAD3N1cHBsaWVyQWRkcmVzcwgFAAAAA3BtdAAAAAZhbW91bnQFAAAAA25pbAAAAAAj6GEV", "chainId": 84, "height": 588507, "spentComplexity": 0 } View: original | compacted Prev: DuSJ3cDg9HpAXk1nJy5sK8VGRh2wppmscqijChwN6evT Next: HPsUPVMYQzWd99n9Bn9vxKEx1VNpCVhUfymgX4smvgMe Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let NONE = "none"
5+
6+func getNumberByKey (key) = {
7+ let num = match getInteger(this, key) {
8+ case a: Int =>
9+ a
10+ case _ =>
11+ 0
12+ }
13+ num
14+ }
15+
16+
17+func getStrByKey (key) = {
18+ let str = match getString(this, key) {
19+ case a: String =>
20+ a
21+ case _ =>
22+ NONE
23+ }
24+ str
25+ }
26+
27+
28+func getKeyItemPrice (item) = (item + "_price")
29+
30+
31+func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
32+
33+
34+func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
35+
36+
37+func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
38+
39+
40+func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
41+
42+
43+func getKeyItemSupplier (item) = (item + "_owner")
44+
45+
46+func getKeyItemData (item) = getStrByKey(getKeyItemSupplier(item))
47+
48+
49+func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
50+
51+
52+func getKeyBalanceSupplier (account) = (account + "_balance")
53+
54+
55+func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
456
557
658 @Callable(i)
7-func purchase (product) = {
59+func addItem (title,price,data) = {
60+ let supplierAddress = toBase58String(i.caller.bytes)
61+ let item = getKeyItem(supplierAddress, title)
62+ if ((0 >= price))
63+ then throw("aankoopbedrag mag niet lager zijn dan de prijs van het product")
64+ else if ((getValueItemSupplier(item) != NONE))
65+ then throw("een item bestaat al")
66+ else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
67+ }
68+
69+
70+
71+@Callable(i)
72+func purchase (item) = {
873 let pmt = extract(i.payment)
974 if (isDefined(pmt.assetId))
1075 then throw("Can use WAVES only at the moment")
1176 else {
12- let customerAddress = toBase58String(i.caller.bytes)
13- let price = match getInteger(this, ("item_" + "item_coupon_price")) {
14- case a: Int =>
15- a
16- case _ =>
17- 0
18- }
77+ let userAddress = toBase58String(i.caller.bytes)
78+ let price = getValueItemPrice(item)
79+ let supplierAddress = getValueItemSupplier(item)
1980 if ((price > pmt.amount))
2081 then throw("aankoopbedrag kan niet lager zijn dan de prijs")
2182 else if ((pmt.amount > price))
2283 then throw("aankoopbedrag kan niet hoger zijn dan de prijs")
23- else WriteSet([DataEntry((("status:purchase_item_" + "_customer_") + customerAddress), "confirmed"), DataEntry((("price:purchase_item_" + "_customer_") + customerAddress), price)])
84+ else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))])
2485 }
2586 }
2687
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let NONE = "none"
5+
6+func getNumberByKey (key) = {
7+ let num = match getInteger(this, key) {
8+ case a: Int =>
9+ a
10+ case _ =>
11+ 0
12+ }
13+ num
14+ }
15+
16+
17+func getStrByKey (key) = {
18+ let str = match getString(this, key) {
19+ case a: String =>
20+ a
21+ case _ =>
22+ NONE
23+ }
24+ str
25+ }
26+
27+
28+func getKeyItemPrice (item) = (item + "_price")
29+
30+
31+func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
32+
33+
34+func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
35+
36+
37+func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
38+
39+
40+func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title)))))
41+
42+
43+func getKeyItemSupplier (item) = (item + "_owner")
44+
45+
46+func getKeyItemData (item) = getStrByKey(getKeyItemSupplier(item))
47+
48+
49+func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
50+
51+
52+func getKeyBalanceSupplier (account) = (account + "_balance")
53+
54+
55+func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
456
557
658 @Callable(i)
7-func purchase (product) = {
59+func addItem (title,price,data) = {
60+ let supplierAddress = toBase58String(i.caller.bytes)
61+ let item = getKeyItem(supplierAddress, title)
62+ if ((0 >= price))
63+ then throw("aankoopbedrag mag niet lager zijn dan de prijs van het product")
64+ else if ((getValueItemSupplier(item) != NONE))
65+ then throw("een item bestaat al")
66+ else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
67+ }
68+
69+
70+
71+@Callable(i)
72+func purchase (item) = {
873 let pmt = extract(i.payment)
974 if (isDefined(pmt.assetId))
1075 then throw("Can use WAVES only at the moment")
1176 else {
12- let customerAddress = toBase58String(i.caller.bytes)
13- let price = match getInteger(this, ("item_" + "item_coupon_price")) {
14- case a: Int =>
15- a
16- case _ =>
17- 0
18- }
77+ let userAddress = toBase58String(i.caller.bytes)
78+ let price = getValueItemPrice(item)
79+ let supplierAddress = getValueItemSupplier(item)
1980 if ((price > pmt.amount))
2081 then throw("aankoopbedrag kan niet lager zijn dan de prijs")
2182 else if ((pmt.amount > price))
2283 then throw("aankoopbedrag kan niet hoger zijn dan de prijs")
23- else WriteSet([DataEntry((("status:purchase_item_" + "_customer_") + customerAddress), "confirmed"), DataEntry((("price:purchase_item_" + "_customer_") + customerAddress), price)])
84+ else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))])
2485 }
2586 }
2687
2788

github/deemru/w8io/026f985 
34.95 ms