tx · Ga5wcD8sxwhMegh1rA5yGDpoz3bEWX633Hgg2fDPDhSe 3Muxd5JEAQz655DDi2yiZxSQ63jVJJHrQyV: -0.01400000 Waves 2022.02.04 04:31 [1908209] smart account 3Muxd5JEAQz655DDi2yiZxSQ63jVJJHrQyV > SELF 0.00000000 Waves
{ "type": 13, "id": "Ga5wcD8sxwhMegh1rA5yGDpoz3bEWX633Hgg2fDPDhSe", "fee": 1400000, "feeAssetId": null, "timestamp": 1643938266110, "version": 2, "chainId": 84, "sender": "3Muxd5JEAQz655DDi2yiZxSQ63jVJJHrQyV", "senderPublicKey": "7ycxALbgfzht9z36iWCgRauBfWzQGSgkc3HMwu7wDwNX", "proofs": [ "4QYvf6oLk7sznbfS9KrjHUpSxJxyvxEa9urYquFC39f3FwkbJHmAPyHNHTqaJSMPNH2qehwNWxSZHUtaMV3x6Gkp" ], "script": "base64:AAIFAAAAAAAAAhEIAhIDCgEIEgUKAwgBCBIFCgMICAgSAwoBCBIDCgEIEgMKAQgaDAoBQRIHcGF5bWVudBoRCgFCEgxjdXN0b21lckFkZHIaBgoBQxIBcBoMCgFEEgdzb2xkb3V0GgcKAUUSAnR4GgsKAUYSBnZlcmlmeRoJCgFhEgROT05FGg0KAWISCGN1c3RvbWVyGg0KAWMSCHN1cHBsaWVyGg8KAWQSCmVyaWNQdWJLZXkaEwoBZRIOZ2V0U3RyaW5nQnlLZXkaCAoBZhIDa2V5GgwKAWcSByRtYXRjaDAaBgoBaBIBYRoQCgFpEgtnZXRJdGVtSGFzaBoKCgFqEgV0aXRsZRoPCgFrEgpjb21ib1RpdGxlGg8KAWwSCmdldE5hbWVLZXkaCQoBbRIEdHlwZRoJCgFuEgRhZGRyGhcKAW8SEmdldEl0ZW1TdXBwbGllcktleRoJCgFwEgRpdGVtGhQKAXESD2dldEl0ZW1QcmljZUtleRoWCgFyEhFnZXRJdGVtU29sZE91dEtleRoTCgFzEg5nZXRJdGVtRGF0YUtleRoZCgF0EhRnZXRWYWx1ZUl0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AAAAEJAQAAAAFzAAAAAQUAAAABcAkABEwAAAACCQEAAAALRGVsZXRlRW50cnkAAAABCQEAAAABcgAAAAEFAAAAAXAFAAAAA25pbAkAAAIAAAABAgAAABRObyBzdWNoIGl0ZW0gcHJlc2VudAAAAAF3AQAAAAtkZWxldGVFbnRyeQAAAAEAAAABZgMJAAAAAAAAAggFAAAAAXcAAAAPY2FsbGVyUHVibGljS2V5BQAAAAFkCQAETAAAAAIJAQAAAAtEZWxldGVFbnRyeQAAAAEFAAAAAWYFAAAAA25pbAkAAAIAAAABAgAAABxPbmx5IEVyaWMgY2FuIGRlbGV0ZSBlbnRyaWVzAAAAAXcBAAAACnVucmVnaXN0ZXIAAAABAAAAAW0DAwkAAAAAAAACBQAAAAFtBQAAAAFjBgkAAAAAAAACBQAAAAFtBQAAAAFiBAAAAAFuCQACWAAAAAEICAUAAAABdwAAAAZjYWxsZXIAAAAFYnl0ZXMJAARMAAAAAgkBAAAAC0RlbGV0ZUVudHJ5AAAAAQkBAAAAAWwAAAACBQAAAAFtBQAAAAFuBQAAAANuaWwJAAACAAAAAQIAAAAQSWxsZWdhbCBhcmd1bWVudAAAAAEAAAABRQEAAAABRgAAAAAJAAH0AAAAAwgFAAAAAUUAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAFFAAAABnByb29mcwAAAAAAAAAAAAgFAAAAAUUAAAAPc2VuZGVyUHVibGljS2V50idhPw==", "height": 1908209, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: HRXA72GWLbTeHMQBpZme4fnekwwPi2p71Wnk5ZQ9aiTC Next: none Diff:
Old | New | Differences | |
---|---|---|---|
46 | 46 | ||
47 | 47 | func getSoldOutValue (item) = { | |
48 | 48 | let key = getItemSoldOutKey(item) | |
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 | - | } | |
49 | + | match getInteger(this, key) { | |
50 | + | case a: Int => | |
51 | + | a | |
52 | + | case _ => | |
53 | + | 2 | |
54 | + | } | |
57 | 55 | } | |
58 | 56 | ||
59 | 57 |
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 | - | if (true) | |
50 | - | then throw(("SoldKey: " + key)) | |
51 | - | else match getInteger(this, key) { | |
52 | - | case a: Int => | |
53 | - | a | |
54 | - | case _ => | |
55 | - | 2 | |
56 | - | } | |
49 | + | match getInteger(this, key) { | |
50 | + | case a: Int => | |
51 | + | a | |
52 | + | case _ => | |
53 | + | 2 | |
54 | + | } | |
57 | 55 | } | |
58 | 56 | ||
59 | 57 | ||
60 | 58 | @Callable(i) | |
61 | 59 | func register (type) = { | |
62 | 60 | let addr = toBase58String(i.caller.bytes) | |
63 | 61 | if (if (isDefined(type)) | |
64 | 62 | then if ((type == customer)) | |
65 | 63 | then true | |
66 | 64 | else (type == supplier) | |
67 | 65 | else false) | |
68 | 66 | then [StringEntry(getNameKey(type, addr), addr)] | |
69 | 67 | else throw("Invalid func parameters") | |
70 | 68 | } | |
71 | 69 | ||
72 | 70 | ||
73 | 71 | ||
74 | 72 | @Callable(i) | |
75 | 73 | func createItem (title,price,data) = { | |
76 | 74 | let supplierAddress = toBase58String(i.caller.bytes) | |
77 | 75 | let item = getItemHash(supplierAddress, title) | |
78 | 76 | if ((0 >= price)) | |
79 | 77 | then throw("Price can not be negative value or zero") | |
80 | 78 | else if ((getValueItemSupplier(item) != NONE)) | |
81 | 79 | then throw("Item already exists") | |
82 | 80 | else [StringEntry(getItemSupplierKey(item), supplierAddress), IntegerEntry(getItemPriceKey(item), price), IntegerEntry(getItemSoldOutKey(item), 0), StringEntry(getItemDataKey(item), data)] | |
83 | 81 | } | |
84 | 82 | ||
85 | 83 | ||
86 | 84 | ||
87 | 85 | @Callable(i) | |
88 | 86 | func purchase (title,supplier,data) = if ((size(i.payments) > 0)) | |
89 | 87 | then { | |
90 | 88 | let payment = i.payments[0] | |
91 | 89 | if (if (isDefined(title)) | |
92 | 90 | then isDefined(supplier) | |
93 | 91 | else false) | |
94 | 92 | then if (isDefined(payment.assetId)) | |
95 | 93 | then throw("Only should pay in waves") | |
96 | 94 | else { | |
97 | 95 | let customerAddr = toBase58String(i.caller.bytes) | |
98 | 96 | let item = getItemHash(supplier, title) | |
99 | 97 | let price = match getInteger(this, getItemPriceKey(item)) { | |
100 | 98 | case p: Int => | |
101 | 99 | p | |
102 | 100 | case _ => | |
103 | 101 | 0 | |
104 | 102 | } | |
105 | 103 | let soldout = getSoldOutValue(item) | |
106 | 104 | if ((soldout != 0)) | |
107 | 105 | then throw(("Item is already sold, res: " + toString(soldout))) | |
108 | 106 | else if ((payment.amount > price)) | |
109 | 107 | then throw("payment cant be higher than price") | |
110 | 108 | else if ((price > payment.amount)) | |
111 | 109 | then throw("payment cant be lower than price") | |
112 | 110 | 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)] | |
113 | 111 | } | |
114 | 112 | else throw("Coupon title and supplier address should be present") | |
115 | 113 | } | |
116 | 114 | else throw("Please attach payment") | |
117 | 115 | ||
118 | 116 | ||
119 | 117 | ||
120 | 118 | @Callable(i) | |
121 | 119 | func deleteItem (title) = { | |
122 | 120 | let supplierAddress = toBase58String(i.caller.bytes) | |
123 | 121 | let item = getItemHash(supplierAddress, title) | |
124 | 122 | if ((getValueItemSupplier(item) != NONE)) | |
125 | 123 | then [DeleteEntry(getItemSupplierKey(item)), DeleteEntry(getItemPriceKey(item)), DeleteEntry(getItemDataKey(item)), DeleteEntry(getItemSoldOutKey(item))] | |
126 | 124 | else throw("No such item present") | |
127 | 125 | } | |
128 | 126 | ||
129 | 127 | ||
130 | 128 | ||
131 | 129 | @Callable(i) | |
132 | 130 | func deleteEntry (key) = if ((i.callerPublicKey == ericPubKey)) | |
133 | 131 | then [DeleteEntry(key)] | |
134 | 132 | else throw("Only Eric can delete entries") | |
135 | 133 | ||
136 | 134 | ||
137 | 135 | ||
138 | 136 | @Callable(i) | |
139 | 137 | func unregister (type) = if (if ((type == supplier)) | |
140 | 138 | then true | |
141 | 139 | else (type == customer)) | |
142 | 140 | then { | |
143 | 141 | let addr = toBase58String(i.caller.bytes) | |
144 | 142 | [DeleteEntry(getNameKey(type, addr))] | |
145 | 143 | } | |
146 | 144 | else throw("Illegal argument") | |
147 | 145 | ||
148 | 146 | ||
149 | 147 | @Verifier(tx) | |
150 | 148 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
151 | 149 |
github/deemru/w8io/026f985 29.16 ms ◑