tx · 8KTND8WuqdztFVAXHdoZwJQKbmnxMgLRWme7YtVapGmF 3NA37aEhY3CSPtrXjKUsNibx5i45P7FxuA4: -0.01000010 Waves 2021.07.07 14:17 [1603118] smart account 3NA37aEhY3CSPtrXjKUsNibx5i45P7FxuA4 > SELF 0.00000000 Waves
{ "type": 13, "id": "8KTND8WuqdztFVAXHdoZwJQKbmnxMgLRWme7YtVapGmF", "fee": 1000010, "feeAssetId": null, "timestamp": 1625656678447, "version": 2, "chainId": 84, "sender": "3NA37aEhY3CSPtrXjKUsNibx5i45P7FxuA4", "senderPublicKey": "B3Kkg7AgjdZYrAW5kNXeBi1KfWcjdiHpEnu3tsfirQPy", "proofs": [ "5zZZ4UmTgwgVAq2Ru6oN7nnTtRd4jQhudidpcZJnbeZJKdL82qdQmJd7YcN2hkW2wfVvgnsFext4o6MwK73Fz9Fx" ], "script": "base64:AAIFAAAAAAAAAkQIAhIFCgMIAQgSAwoBCBIAGgoKAmExEgROT05FGhQKAmEyEg5nZXROdW1iZXJCeUtleRoJCgJhMxIDa2V5GgkKAmE0EgNudW0aDQoCYTUSByRtYXRjaDAaBwoCYTYSAWEaEQoCYTcSC2dldFN0ckJ5S2V5GgkKAmE4EgNzdHIaFQoCYTkSD2dldEtleUl0ZW1QcmljZRoKCgJiMRIEaXRlbRoXCgJiMhIRZ2V0VmFsdWVJdGVtUHJpY2UaGwoCYjMSFWdldEtleVVzZXJJdGVtQ291bnRlchoKCgJiNBIEdXNlchodCgJiNRIXZ2V0VmFsdWVVc2VySXRlbUNvdW50ZXIaEAoCYjYSCmdldEtleUl0ZW0aDgoCYjcSCHN1cHBsaWVyGgsKAmI4EgV0aXRsZRoUCgJiORIOZ2V0S2V5SXRlbURhdGEaGAoCYzESEmdldEtleUl0ZW1TdXBwbGllchoaCgJjMhIUZ2V0VmFsdWVJdGVtU3VwcGxpZXIaGwoCYzMSFWdldEtleUJhbGFuY2VTdXBwbGllchoNCgJjNBIHYWNjb3VudBodCgJjNRIXZ2V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atus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4uam79MWtrNAT7o4wEJad34bo8sGcJYZVNecvadDABWZ Next: none Diff:
Old | New | Differences | |
---|---|---|---|
94 | 94 | let supplierAddress = toBase58String(i.caller.bytes) | |
95 | 95 | let balance = getValueBalanceSupplier(supplierAddress) | |
96 | 96 | if ((0 >= balance)) | |
97 | - | then throw(" | |
97 | + | then throw("za mało środków") | |
98 | 98 | else [IntegerEntry(getKeyBalanceSupplier(supplierAddress), 0), ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)] | |
99 | 99 | } | |
100 | 100 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let NONE = "none" | |
5 | 5 | ||
6 | 6 | func getNumberByKey (key) = { | |
7 | 7 | let num = match getInteger(this, key) { | |
8 | 8 | case a: Int => | |
9 | 9 | a | |
10 | 10 | case _ => | |
11 | 11 | 0 | |
12 | 12 | } | |
13 | 13 | num | |
14 | 14 | } | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func getStrByKey (key) = { | |
18 | 18 | let str = match getString(this, key) { | |
19 | 19 | case a: String => | |
20 | 20 | a | |
21 | 21 | case _ => | |
22 | 22 | NONE | |
23 | 23 | } | |
24 | 24 | str | |
25 | 25 | } | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func getKeyItemPrice (item) = (item + "_price") | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func getKeyItemData (item) = (item + "_data") | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func getKeyItemSupplier (item) = (item + "_data") | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func getKeyBalanceSupplier (account) = (account + "_balance") | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | @Callable(i) | |
59 | 59 | func addItem (title,price,data) = { | |
60 | 60 | let supplierAddress = toBase58String(i.caller.bytes) | |
61 | 61 | let item = getKeyItem(supplierAddress, title) | |
62 | 62 | if ((0 >= price)) | |
63 | 63 | then throw("purchase amount cannot be less than item price") | |
64 | 64 | else if ((getValueItemSupplier(item) != NONE)) | |
65 | 65 | then throw("an item is already exist") | |
66 | 66 | else [StringEntry(getKeyItemSupplier(item), supplierAddress), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data)] | |
67 | 67 | } | |
68 | 68 | ||
69 | 69 | ||
70 | 70 | ||
71 | 71 | @Callable(i) | |
72 | 72 | func purchase (item) = { | |
73 | 73 | let pmt = i.payments[0] | |
74 | 74 | if (isDefined(pmt.assetId)) | |
75 | 75 | then throw("WAVES token only at the moment") | |
76 | 76 | else { | |
77 | 77 | let userAddress = toBase58String(i.caller.bytes) | |
78 | 78 | let price = getValueItemPrice(item) | |
79 | 79 | let supplierAddres = getValueItemSupplier(item) | |
80 | 80 | if ((price > pmt.amount)) | |
81 | 81 | then throw("purchase amunt cannot be less than item price") | |
82 | 82 | else if ((pmt.amount > price)) | |
83 | 83 | then throw("purchase amount cannot be higher than item price") | |
84 | 84 | else if ((supplierAddres == NONE)) | |
85 | 85 | then throw("Supplier address doesn't exist") | |
86 | 86 | else [IntegerEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), IntegerEntry(getKeyBalanceSupplier(supplierAddres), (getValueBalanceSupplier(supplierAddres) + pmt.amount))] | |
87 | 87 | } | |
88 | 88 | } | |
89 | 89 | ||
90 | 90 | ||
91 | 91 | ||
92 | 92 | @Callable(i) | |
93 | 93 | func withdraw () = { | |
94 | 94 | let supplierAddress = toBase58String(i.caller.bytes) | |
95 | 95 | let balance = getValueBalanceSupplier(supplierAddress) | |
96 | 96 | if ((0 >= balance)) | |
97 | - | then throw(" | |
97 | + | then throw("za mało środków") | |
98 | 98 | else [IntegerEntry(getKeyBalanceSupplier(supplierAddress), 0), ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)] | |
99 | 99 | } | |
100 | 100 | ||
101 | 101 |
github/deemru/w8io/026f985 318.25 ms ◑