tx · FRmorQjgLqKnKqVUpwC286ut3LfSd8GbsZY7H6ByWLnf

3NALrCDqs7qG1VFDKnoi37BqB3bwLAEUzVe:  -0.01000000 Waves

2023.04.25 03:32 [2549352] smart account 3NALrCDqs7qG1VFDKnoi37BqB3bwLAEUzVe > SELF 0.00000000 Waves

{ "type": 13, "id": "FRmorQjgLqKnKqVUpwC286ut3LfSd8GbsZY7H6ByWLnf", "fee": 1000000, "feeAssetId": null, "timestamp": 1682382744466, "version": 2, "chainId": 84, "sender": "3NALrCDqs7qG1VFDKnoi37BqB3bwLAEUzVe", "senderPublicKey": "Caf54v2LJZiGuuBEGwu5vPke58bbNMAtDvcWi53TjtzP", "proofs": [ "4bcSPyY8bQxuuibduagpDXDCurQEFjgsSnDbcjM82nGLeGxQud8fWVq8DhfdDXoZPy5RFHjyv8gQLxpyQQbkpfvZ" ], "script": "base64:BgIJCAISBQoDCAEIDgAETk9ORQIEbm9uZQEOZ2V0TnVtYmVyQnlLZXkBA2tleQQDbnVtBAckbWF0Y2gwCQCaCAIFBHRoaXMFA2tleQMJAAECBQckbWF0Y2gwAgNJbnQEAWEFByRtYXRjaDAFAWEAAAUDbnVtAQtnZXRTdHJCeUtleQEDa2V5BANzdHIEByRtYXRjaDAJAJ0IAgUEdGhpcwUDa2V5AwkAAQIFByRtYXRjaDACBlN0cmluZwQBYQUHJG1hdGNoMAUBYQUETk9ORQUDc3RyAQ9nZXRLZXlJdGVtUHJpY2UBBGl0ZW0JAKwCAgUEaXRlbQIGX3ByaWNlARFnZXRWYWx1ZUl0ZW1QcmljZQEEaXRlbQkBDmdldE51bWJlckJ5S2V5AQkBD2dldEtleUl0ZW1QcmljZQEFBGl0ZW0BFWdldEtleVVzZXJJdGVtQ291bnRlcgIEdXNlcgRpdGVtCQCsAgIJAKwCAgkArAICBQRpdGVtAgFfBQR1c2VyAgRfY250ARdnZXRWYWx1ZVVzZXJJdGVtQ291bnRlcgIEdXNlcgRpdGVtCQEOZ2V0TnVtYmVyQnlL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pZXJBZGRyZXNzCQDMCAIJAQxJbnRlZ2VyRW50cnkCCQEPZ2V0S2V5SXRlbVByaWNlAQUEaXRlbQUFcHJpY2UJAMwIAgkBC1N0cmluZ0VudHJ5AgkBDmdldEtleUl0ZW1EYXRhAQUEaXRlbQUEZGF0YQUDbmlsAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tlecrJsRo=", "height": 2549352, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AmRLSz7PAGvxB3rRiM5puaNbBR7BYxLnPrLHiuw9AQxM Next: none Diff:
OldNewDifferences
1-{-# STDLIB_VERSION 5 #-}
1+{-# STDLIB_VERSION 6 #-}
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 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 getValueItemSpupplier (item) = getStrByKey(getKeyItemSupplier(item))
53+
54+
55+func getKeyBalanceSupplier (account) = (account + "_balance")
56+
57+
58+func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
459
560
661 @Callable(i)
7-func provideLiquidity () = nil
8-
9-
10-
11-@Callable(i)
12-func removeLiquidity () = nil
13-
14-
15-
16-@Callable(i)
17-func trade () = nil
18-
19-
20-
21-@Callable(i)
22-func getLiquidity () = nil
23-
24-
25-
26-@Callable(i)
27-func getTraded () = nil
28-
29-
30-
31-@Callable(i)
32-func getFee () = nil
62+func addItem (title,price,data) = {
63+ let supplierAddress = toBase58String(i.caller.bytes)
64+ let item = getKeyItem(supplierAddress, title)
65+ if ((0 >= price))
66+ then throw("purchase amount cannot be less than item price")
67+ else if ((getValueItemSupplier(item) != NONE))
68+ then throw("an item is already exist")
69+ else [StringEntry(getKeyItemSupplier(item), supplierAddress), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data)]
70+ }
3371
3472
3573 @Verifier(tx)
Full:
OldNewDifferences
1-{-# STDLIB_VERSION 5 #-}
1+{-# STDLIB_VERSION 6 #-}
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 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 getValueItemSpupplier (item) = getStrByKey(getKeyItemSupplier(item))
53+
54+
55+func getKeyBalanceSupplier (account) = (account + "_balance")
56+
57+
58+func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
459
560
661 @Callable(i)
7-func provideLiquidity () = nil
8-
9-
10-
11-@Callable(i)
12-func removeLiquidity () = nil
13-
14-
15-
16-@Callable(i)
17-func trade () = nil
18-
19-
20-
21-@Callable(i)
22-func getLiquidity () = nil
23-
24-
25-
26-@Callable(i)
27-func getTraded () = nil
28-
29-
30-
31-@Callable(i)
32-func getFee () = nil
62+func addItem (title,price,data) = {
63+ let supplierAddress = toBase58String(i.caller.bytes)
64+ let item = getKeyItem(supplierAddress, title)
65+ if ((0 >= price))
66+ then throw("purchase amount cannot be less than item price")
67+ else if ((getValueItemSupplier(item) != NONE))
68+ then throw("an item is already exist")
69+ else [StringEntry(getKeyItemSupplier(item), supplierAddress), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data)]
70+ }
3371
3472
3573 @Verifier(tx)
3674 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
3775

github/deemru/w8io/169f3d6 
25.34 ms