tx · 9Z3DiMwbHP4SkNpsMSPMhgwKHWAWQpKRuixmJi5Fu8be

3MxN6Cszfki941gTcEwXc8ngmbWPTsHoJFq:  -0.01500000 Waves

2019.06.22 10:40 [552935] smart account 3MxN6Cszfki941gTcEwXc8ngmbWPTsHoJFq > SELF 0.00000000 Waves

{ "type": 13, "id": "9Z3DiMwbHP4SkNpsMSPMhgwKHWAWQpKRuixmJi5Fu8be", "fee": 1500000, "feeAssetId": null, "timestamp": 1561189232098, "version": 1, "sender": "3MxN6Cszfki941gTcEwXc8ngmbWPTsHoJFq", "senderPublicKey": "4fygXNNAjU52sT9N6uq4o9Ck8G75e94ukktN3pd4VxVo", "proofs": [ "5TGCSeDpNEc6ZaoYJoz1cFs37FUhkGTxSJgEn5ZiK9ZqzvE6nGeUmnpRR4kaDBVdVRXX8arGifXuxThpivnb1gv5" ], "script": "base64:AAIDAAAAAAAAAAAAAAANAAAAAAROT05FAgAAAARub25lAQAAAA9nZXRLZXlJdGVtUHJpY2UAAAABAAAABGl0ZW0JAAEsAAAAAgUAAAAEaXRlbQIAAAAGX3ByaWNlAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAAFWdldEtleVVzZXJJdGVtQ291bnRlcgAAAAIAAAAEdXNlcgAAAARpdGVtCQABLAAAAAIJAAEsAAAAAgkAASwAAAACBQAAAARp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b3Vwb25fcHJpY2UDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAMJAABmAAAAAgUAAAAFcHJpY2UIBQAAAANwbXQAAAAGYW1vdW50CQAAAgAAAAECAAAAL3B1cmNoYXNlIGFtb3VudCBjYW5ub3QgYmUgbGVzcyB0aGFuIGl0ZW0gcHJpY2UgAwkAAGYAAAACCAUAAAADcG10AAAABmFtb3VudAUAAAAFcHJpY2UJAAACAAAAAQIAAAAwcHVyY2hhc2UgYW1vdW50IGNhbm5vdCBiZSBoaWdoZXIgdGhhbiBpdGVtIHByaWNlCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAABVzdGF0dXM6cHVyY2hhc2VfaXRlbV8FAAAABGl0ZW0CAAAACl9jdXN0b21lcl8FAAAAD2N1c3RvbWVyQWRkcmVzcwIAAAAJY29uZmlybWVkCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAABRwcmljZTpwdXJjaGFzZV9pdGVtXwUAAAAEaXRlbQIAAAAKX2N1c3RvbWVyXwUAAAAPY3VzdG9tZXJBZGRyZXNzBQAAAAVwcmljZQUAAAADbmlsAAAAAMoEwOY=", "chainId": 84, "height": 552935, "spentComplexity": 0 } View: original | compacted Prev: AraUkP3ARw7eQ9vqvUij6GLKFoiFyH7yUFhe8vCUhmbm Next: CWrLUufHmLNSbDeiEJXyBgDDFcBNkrBwR9jRnzUmkLhB Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let NONE = "none"
5+
6+func getKeyItemPrice (item) = (item + "_price")
7+
8+
9+func getNumberByKey (key) = {
10+ let num = match getInteger(this, key) {
11+ case a: Int =>
12+ a
13+ case _ =>
14+ 0
15+ }
16+ num
17+ }
18+
19+
20+func getStrByKey (key) = {
21+ let str = match getString(this, key) {
22+ case a: String =>
23+ a
24+ case _ =>
25+ NONE
26+ }
27+ str
28+ }
29+
30+
31+func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
32+
33+
34+func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
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 getKeyItemData (item) = (item + "_data")
44+
45+
46+func getKeyItemSupplier (item) = (item + "_owner")
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 () = {
59+func additem (title,price,data) = {
60+ let suppad = toBase58String(i.caller.bytes)
61+ let item = getKeyItem(suppad, title)
62+ if ((0 >= price))
63+ then throw("purchase amount cannot be less than 0 or 0")
64+ else if ((getValueItemSupplier(item) != NONE))
65+ then throw("an item already exists")
66+ else WriteSet([DataEntry(getKeyItemSupplier(item), suppad), 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 {
1277 let customerAddress = toBase58String(i.caller.bytes)
13- let price = match getInteger(this, "item_A_coupon_price") {
78+ let price = match getInteger(this, (("item_" + item) + "_coupon_price")) {
1479 case a: Int =>
1580 a
1681 case _ =>
2085 then throw("purchase amount cannot be less than item price ")
2186 else if ((pmt.amount > price))
2287 then throw("purchase amount cannot be higher than item price")
23- else WriteSet([DataEntry(("status:purchase_item_A_customer_" + customerAddress), "confirmed"), DataEntry(("price:purchase_item_A_customer_" + customerAddress), price)])
88+ else WriteSet([DataEntry(((("status:purchase_item_" + item) + "_customer_") + customerAddress), "confirmed"), DataEntry(((("price:purchase_item_" + item) + "_customer_") + customerAddress), price)])
2489 }
2590 }
2691
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let NONE = "none"
5+
6+func getKeyItemPrice (item) = (item + "_price")
7+
8+
9+func getNumberByKey (key) = {
10+ let num = match getInteger(this, key) {
11+ case a: Int =>
12+ a
13+ case _ =>
14+ 0
15+ }
16+ num
17+ }
18+
19+
20+func getStrByKey (key) = {
21+ let str = match getString(this, key) {
22+ case a: String =>
23+ a
24+ case _ =>
25+ NONE
26+ }
27+ str
28+ }
29+
30+
31+func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
32+
33+
34+func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item))
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 getKeyItemData (item) = (item + "_data")
44+
45+
46+func getKeyItemSupplier (item) = (item + "_owner")
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 () = {
59+func additem (title,price,data) = {
60+ let suppad = toBase58String(i.caller.bytes)
61+ let item = getKeyItem(suppad, title)
62+ if ((0 >= price))
63+ then throw("purchase amount cannot be less than 0 or 0")
64+ else if ((getValueItemSupplier(item) != NONE))
65+ then throw("an item already exists")
66+ else WriteSet([DataEntry(getKeyItemSupplier(item), suppad), 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 {
1277 let customerAddress = toBase58String(i.caller.bytes)
13- let price = match getInteger(this, "item_A_coupon_price") {
78+ let price = match getInteger(this, (("item_" + item) + "_coupon_price")) {
1479 case a: Int =>
1580 a
1681 case _ =>
1782 0
1883 }
1984 if ((price > pmt.amount))
2085 then throw("purchase amount cannot be less than item price ")
2186 else if ((pmt.amount > price))
2287 then throw("purchase amount cannot be higher than item price")
23- else WriteSet([DataEntry(("status:purchase_item_A_customer_" + customerAddress), "confirmed"), DataEntry(("price:purchase_item_A_customer_" + customerAddress), price)])
88+ else WriteSet([DataEntry(((("status:purchase_item_" + item) + "_customer_") + customerAddress), "confirmed"), DataEntry(((("price:purchase_item_" + item) + "_customer_") + customerAddress), price)])
2489 }
2590 }
2691
2792

github/deemru/w8io/026f985 
34.90 ms