tx · HRXA72GWLbTeHMQBpZme4fnekwwPi2p71Wnk5ZQ9aiTC 3Muxd5JEAQz655DDi2yiZxSQ63jVJJHrQyV: -0.01400000 Waves 2022.02.04 04:26 [1908204] smart account 3Muxd5JEAQz655DDi2yiZxSQ63jVJJHrQyV > SELF 0.00000000 Waves
{ "type": 13, "id": "HRXA72GWLbTeHMQBpZme4fnekwwPi2p71Wnk5ZQ9aiTC", "fee": 1400000, "feeAssetId": null, "timestamp": 1643937964336, "version": 2, "chainId": 84, "sender": "3Muxd5JEAQz655DDi2yiZxSQ63jVJJHrQyV", "senderPublicKey": "7ycxALbgfzht9z36iWCgRauBfWzQGSgkc3HMwu7wDwNX", "proofs": [ "5LPMpRxK7SoUKqwKcLNWpJWCKuAaruiwptD63CfzE4KFK2rMB8EFTd5vEQpfpDxhym4uWYZ8h12rrzEPiAbnXoxR" ], "script": "base64:AAIFAAAAAAAAAhEIAhIDCgEIEgUKAwgBCBIFCgMICAgSAwoBCBIDCgEIEgMKAQgaDAoBQRIHcGF5bWVudBoRCgFCEgxjdXN0b21lckFkZHIaBgoBQxIBcBoMCgFEEgdzb2xkb3V0GgcKAUUSAnR4GgsKAUYSBnZlcmlmeRoJCgFhEgROT05FGg0KAWISCGN1c3RvbWVyGg0KAWMSCHN1cHBsaWVyGg8KAWQSCmVyaWNQdWJLZXkaEwoBZRIOZ2V0U3RyaW5nQnlLZXkaCAoBZhIDa2V5GgwKAWcSByRtYXRjaDAaBgoBaBIBYRoQCgFpEgtnZXRJdGVtSGFzaBoKCgFqEgV0aXRsZRoPCgFrEgpjb21ib1RpdGxlGg8KAWwSCmdldE5hbWVLZXkaCQoBbRIEdHlwZRoJCgFuEgRhZGRyGhcKAW8SEmdldEl0ZW1TdXBwbGllcktleRoJCgFwEgRpdGVtGhQKAXESD2dldEl0ZW1QcmljZUtleRoWCgFyEhFnZXRJdGVtU29sZE91dEtleRoTCgFzEg5nZXRJdGVtRGF0YUtleRoZCgF0EhRnZXRWYWx1ZUl0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FAAAAAXAJAARMAAAAAgkBAAAAC0RlbGV0ZUVudHJ5AAAAAQkBAAAAAXMAAAABBQAAAAFwCQAETAAAAAIJAQAAAAtEZWxldGVFbnRyeQAAAAEJAQAAAAFyAAAAAQUAAAABcAUAAAADbmlsCQAAAgAAAAECAAAAFE5vIHN1Y2ggaXRlbSBwcmVzZW50AAAAAXcBAAAAC2RlbGV0ZUVudHJ5AAAAAQAAAAFmAwkAAAAAAAACCAUAAAABdwAAAA9jYWxsZXJQdWJsaWNLZXkFAAAAAWQJAARMAAAAAgkBAAAAC0RlbGV0ZUVudHJ5AAAAAQUAAAABZgUAAAADbmlsCQAAAgAAAAECAAAAHE9ubHkgRXJpYyBjYW4gZGVsZXRlIGVudHJpZXMAAAABdwEAAAAKdW5yZWdpc3RlcgAAAAEAAAABbQMDCQAAAAAAAAIFAAAAAW0FAAAAAWMGCQAAAAAAAAIFAAAAAW0FAAAAAWIEAAAAAW4JAAJYAAAAAQgIBQAAAAF3AAAABmNhbGxlcgAAAAVieXRlcwkABEwAAAACCQEAAAALRGVsZXRlRW50cnkAAAABCQEAAAABbAAAAAIFAAAAAW0FAAAAAW4FAAAAA25pbAkAAAIAAAABAgAAABBJbGxlZ2FsIGFyZ3VtZW50AAAAAQAAAAFFAQAAAAFGAAAAAAkAAfQAAAADCAUAAAABRQAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAUUAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAABRQAAAA9zZW5kZXJQdWJsaWNLZXloog8C", "height": 1908204, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DxYuqpFDfYAfxL294ghooZUTaoghTfWcppPfku8gLBy9 Next: Ga5wcD8sxwhMegh1rA5yGDpoz3bEWX633Hgg2fDPDhSe Diff:
Old | New | Differences | |
---|---|---|---|
46 | 46 | ||
47 | 47 | func getSoldOutValue (item) = { | |
48 | 48 | let key = getItemSoldOutKey(item) | |
49 | - | match getInteger(this, key) { | |
50 | - | case a: Int => | |
51 | - | a | |
52 | - | case _ => | |
53 | - | 2 | |
54 | - | } | |
49 | + | if (true) | |
50 | + | then throw(("SoldKey: " + key)) | |
51 | + | else match getInteger(this, key) { | |
52 | + | case a: Int => | |
53 | + | a | |
54 | + | case _ => | |
55 | + | 2 | |
56 | + | } | |
55 | 57 | } | |
56 | 58 | ||
57 | 59 |
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 | let customer = "CUSTOMER" | |
7 | 7 | ||
8 | 8 | let supplier = "SUPPLIER" | |
9 | 9 | ||
10 | 10 | let ericPubKey = base58'8haEN2a7ZmkzawLmnr5rFX14X1oHi5kjt8NQUDNjSDLG' | |
11 | 11 | ||
12 | 12 | func getStringByKey (key) = match getString(key) { | |
13 | 13 | case a: String => | |
14 | 14 | a | |
15 | 15 | case _ => | |
16 | 16 | NONE | |
17 | 17 | } | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func getItemHash (supplier,title) = { | |
21 | 21 | let comboTitle = (supplier + title) | |
22 | 22 | ("item_" + toBase58String(sha256(toBytes(comboTitle)))) | |
23 | 23 | } | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | func getNameKey (type,addr) = (((type + "_") + addr) + "_name") | |
27 | 27 | ||
28 | 28 | ||
29 | 29 | func getItemSupplierKey (item) = (item + "_owner") | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func getItemPriceKey (item) = (item + "_price") | |
33 | 33 | ||
34 | 34 | ||
35 | 35 | func getItemSoldOutKey (item) = (item + "_soldout") | |
36 | 36 | ||
37 | 37 | ||
38 | 38 | func getItemDataKey (item) = (item + "_data") | |
39 | 39 | ||
40 | 40 | ||
41 | 41 | func getValueItemSupplier (item) = { | |
42 | 42 | let itemKey = getItemSupplierKey(item) | |
43 | 43 | getStringByKey(itemKey) | |
44 | 44 | } | |
45 | 45 | ||
46 | 46 | ||
47 | 47 | func getSoldOutValue (item) = { | |
48 | 48 | let key = getItemSoldOutKey(item) | |
49 | - | match getInteger(this, key) { | |
50 | - | case a: Int => | |
51 | - | a | |
52 | - | case _ => | |
53 | - | 2 | |
54 | - | } | |
49 | + | if (true) | |
50 | + | then throw(("SoldKey: " + key)) | |
51 | + | else match getInteger(this, key) { | |
52 | + | case a: Int => | |
53 | + | a | |
54 | + | case _ => | |
55 | + | 2 | |
56 | + | } | |
55 | 57 | } | |
56 | 58 | ||
57 | 59 | ||
58 | 60 | @Callable(i) | |
59 | 61 | func register (type) = { | |
60 | 62 | let addr = toBase58String(i.caller.bytes) | |
61 | 63 | if (if (isDefined(type)) | |
62 | 64 | then if ((type == customer)) | |
63 | 65 | then true | |
64 | 66 | else (type == supplier) | |
65 | 67 | else false) | |
66 | 68 | then [StringEntry(getNameKey(type, addr), addr)] | |
67 | 69 | else throw("Invalid func parameters") | |
68 | 70 | } | |
69 | 71 | ||
70 | 72 | ||
71 | 73 | ||
72 | 74 | @Callable(i) | |
73 | 75 | func createItem (title,price,data) = { | |
74 | 76 | let supplierAddress = toBase58String(i.caller.bytes) | |
75 | 77 | let item = getItemHash(supplierAddress, title) | |
76 | 78 | if ((0 >= price)) | |
77 | 79 | then throw("Price can not be negative value or zero") | |
78 | 80 | else if ((getValueItemSupplier(item) != NONE)) | |
79 | 81 | then throw("Item already exists") | |
80 | 82 | else [StringEntry(getItemSupplierKey(item), supplierAddress), IntegerEntry(getItemPriceKey(item), price), IntegerEntry(getItemSoldOutKey(item), 0), StringEntry(getItemDataKey(item), data)] | |
81 | 83 | } | |
82 | 84 | ||
83 | 85 | ||
84 | 86 | ||
85 | 87 | @Callable(i) | |
86 | 88 | func purchase (title,supplier,data) = if ((size(i.payments) > 0)) | |
87 | 89 | then { | |
88 | 90 | let payment = i.payments[0] | |
89 | 91 | if (if (isDefined(title)) | |
90 | 92 | then isDefined(supplier) | |
91 | 93 | else false) | |
92 | 94 | then if (isDefined(payment.assetId)) | |
93 | 95 | then throw("Only should pay in waves") | |
94 | 96 | else { | |
95 | 97 | let customerAddr = toBase58String(i.caller.bytes) | |
96 | 98 | let item = getItemHash(supplier, title) | |
97 | 99 | let price = match getInteger(this, getItemPriceKey(item)) { | |
98 | 100 | case p: Int => | |
99 | 101 | p | |
100 | 102 | case _ => | |
101 | 103 | 0 | |
102 | 104 | } | |
103 | 105 | let soldout = getSoldOutValue(item) | |
104 | 106 | if ((soldout != 0)) | |
105 | 107 | then throw(("Item is already sold, res: " + toString(soldout))) | |
106 | 108 | else if ((payment.amount > price)) | |
107 | 109 | then throw("payment cant be higher than price") | |
108 | 110 | else if ((price > payment.amount)) | |
109 | 111 | then throw("payment cant be lower than price") | |
110 | 112 | else [DeleteEntry(getItemSupplierKey(item)), DeleteEntry(getItemPriceKey(item)), DeleteEntry(getItemDataKey(item)), DeleteEntry(getItemSoldOutKey(item)), StringEntry(getItemSupplierKey(item), customerAddr), IntegerEntry(getItemPriceKey(item), price), IntegerEntry(getItemSoldOutKey(item), 1), StringEntry(getItemDataKey(item), data), StringEntry(((((("status:purchase_" + item) + "_supplier_") + supplier) + "_customer_") + customerAddr), "confirmed"), IntegerEntry(((((("price:purchase_" + item) + "_supplier_") + supplier) + "_customer_") + customerAddr), price)] | |
111 | 113 | } | |
112 | 114 | else throw("Coupon title and supplier address should be present") | |
113 | 115 | } | |
114 | 116 | else throw("Please attach payment") | |
115 | 117 | ||
116 | 118 | ||
117 | 119 | ||
118 | 120 | @Callable(i) | |
119 | 121 | func deleteItem (title) = { | |
120 | 122 | let supplierAddress = toBase58String(i.caller.bytes) | |
121 | 123 | let item = getItemHash(supplierAddress, title) | |
122 | 124 | if ((getValueItemSupplier(item) != NONE)) | |
123 | 125 | then [DeleteEntry(getItemSupplierKey(item)), DeleteEntry(getItemPriceKey(item)), DeleteEntry(getItemDataKey(item)), DeleteEntry(getItemSoldOutKey(item))] | |
124 | 126 | else throw("No such item present") | |
125 | 127 | } | |
126 | 128 | ||
127 | 129 | ||
128 | 130 | ||
129 | 131 | @Callable(i) | |
130 | 132 | func deleteEntry (key) = if ((i.callerPublicKey == ericPubKey)) | |
131 | 133 | then [DeleteEntry(key)] | |
132 | 134 | else throw("Only Eric can delete entries") | |
133 | 135 | ||
134 | 136 | ||
135 | 137 | ||
136 | 138 | @Callable(i) | |
137 | 139 | func unregister (type) = if (if ((type == supplier)) | |
138 | 140 | then true | |
139 | 141 | else (type == customer)) | |
140 | 142 | then { | |
141 | 143 | let addr = toBase58String(i.caller.bytes) | |
142 | 144 | [DeleteEntry(getNameKey(type, addr))] | |
143 | 145 | } | |
144 | 146 | else throw("Illegal argument") | |
145 | 147 | ||
146 | 148 | ||
147 | 149 | @Verifier(tx) | |
148 | 150 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
149 | 151 |
github/deemru/w8io/026f985 45.94 ms ◑