tx · G6DAxYWgrrwBWBFg4uwSHuQHzqxV8y7fjyjruXmhRAJf

3MzFjVphaDKp1oZjd5KmCYou3wCzCzTmEFe:  -0.00300000 Waves

2022.09.20 15:36 [2237468] smart account 3MzFjVphaDKp1oZjd5KmCYou3wCzCzTmEFe > SELF 0.00000000 Waves

{ "type": 13, "id": "G6DAxYWgrrwBWBFg4uwSHuQHzqxV8y7fjyjruXmhRAJf", "fee": 300000, "feeAssetId": null, "timestamp": 1663677393747, "version": 2, "chainId": 84, "sender": "3MzFjVphaDKp1oZjd5KmCYou3wCzCzTmEFe", "senderPublicKey": "FFVf3kC6HkjRMmf8W6Zr2bNKhJ5EN5W1vG44GbgvHd9Z", "proofs": [ "4qLqGQ5S7NYbjQf5mjHzogGCRg6Ycd6AxFxkZfxgHYBeE94yMVxsX9DLkYFkkfEkPP6c9FLnE9kXoDvNgRMcDQMt" ], "script": "base64:AAIDAAAAAAAAAA4IARIDCgEIEgUKAwgBCAAAAA0AAAAABE5PTkUCAAAABG5vbmUBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAA251bQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAADbnVtAQAAAAtnZXRTdHJCeUtleQAAAAEAAAADa2V5BAAAAANzdHIEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEFAAAABE5PTkUFAAAAA3N0cgEAAAAPZ2V0S2V5SXRlbVByaWNlAAAAAQAAAARpdGVtCQABLAAAAAIFAAAABGl0ZW0CAAAABl9wcmljZQEAAAARZ2V0VmFsdWVJdGVtUHJpY2UAAAABAAAABGl0ZW0JAQAAAA5nZXROdW1iZXJCe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WVyQWRkcmVzcwkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzBAAAAARpdGVtCQEAAAAKZ2V0S2V5SXRlbQAAAAIFAAAAD3N1cHBsaWVyQWRkcmVzcwUAAAAFdGl0bGUDCQAAZwAAAAIAAAAAAAAAAAAFAAAABXByaWNlCQAAAgAAAAECAAAAK3B1cmNoYXNlIGNhbm5vdCBiZSBsZXNzIHRoYW4gdGhlIGl0ZW0gcHJpY2UDCQEAAAACIT0AAAACCQEAAAAUZ2V0VmFsdWVJdGVtU3VwcGxpZXIAAAABBQAAAARpdGVtBQAAAAROT05FCQAAAgAAAAECAAAAGFRoZSBpdGVtIGFscmVhZHkgZXhpdHN0cwkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAEmdldEtleUl0ZW1TdXBwbGllcgAAAAEFAAAABGl0ZW0FAAAAD3N1cHBsaWVyQWRkcmVzcwkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAD2dldEtleUl0ZW1QcmljZQAAAAEFAAAABGl0ZW0FAAAABXByaWNlCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAOZ2V0S2V5SXRlbURhdGEAAAABBQAAAARpdGVtBQAAAARkYXRhBQAAAANuaWwAAAAARGwzEQ==", "height": 2237468, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Gt2NH17aJycRZQR3UqjybJQXiPRQrhjg422VcCQxBJRX Next: 7AZAbkKJcjr7Cduct2433dDyb9Bgnxuz484Gxs4qugUV 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 getInteger(this, key) {
19+ case a: Int =>
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 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)
2375 }
2476
2577
78+
79+@Callable(i)
80+func addItem (title,price,data) = {
81+ let supplierAddress = toBase58String(i.caller.bytes)
82+ let item = getKeyItem(supplierAddress, title)
83+ if ((0 >= price))
84+ then throw("purchase cannot be less than the item price")
85+ else if ((getValueItemSupplier(item) != NONE))
86+ then throw("The item already exitsts")
87+ else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
88+ }
89+
90+
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 getInteger(this, key) {
19+ case a: Int =>
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 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)
759 func purchase (CouponType) = {
860 let pmt = extract(i.payment)
961 if (isDefined(pmt.assetId))
1062 then throw("can use WAVES only at the moment")
1163 else {
1264 let customerAddress = toBase58String(i.caller.bytes)
1365 let price = match getInteger(this, (("Item_" + CouponType) + "_coupon_price")) {
1466 case a: Int =>
1567 a
1668 case _ =>
1769 0
1870 }
1971 if ((pmt.amount != price))
2072 then throw("Purchase amount should be equal to price ")
2173 else WriteSet([DataEntry(((("status: purchase_item_" + CouponType) + "_customer_") + customerAddress), "confirmed"), DataEntry(((("price: purchase_item_" + CouponType) + "_customer_") + customerAddress), price)])
2274 }
2375 }
2476
2577
78+
79+@Callable(i)
80+func addItem (title,price,data) = {
81+ let supplierAddress = toBase58String(i.caller.bytes)
82+ let item = getKeyItem(supplierAddress, title)
83+ if ((0 >= price))
84+ then throw("purchase cannot be less than the item price")
85+ else if ((getValueItemSupplier(item) != NONE))
86+ then throw("The item already exitsts")
87+ else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)])
88+ }
89+
90+

github/deemru/w8io/026f985 
25.84 ms