tx · 5Y39PyhQ8PRGmTHduAmx5QmYLyX8yZZJVzgSzEJChgzu 3N9nVNxRXkYG1LxBamitnLpZzXcjGDZ2Q6z: -0.01400000 Waves 2019.10.18 18:33 [725626] smart account 3N9nVNxRXkYG1LxBamitnLpZzXcjGDZ2Q6z > SELF 0.00000000 Waves
{ "type": 13, "id": "5Y39PyhQ8PRGmTHduAmx5QmYLyX8yZZJVzgSzEJChgzu", "fee": 1400000, "feeAssetId": null, "timestamp": 1571412900231, "version": 1, "sender": "3N9nVNxRXkYG1LxBamitnLpZzXcjGDZ2Q6z", "senderPublicKey": "EEGsMXJbL3i6pER7gfBpcw87Km3h2gz6qiqhqPXbdob1", "proofs": [ "3eHWViP5C8ZacESHb14ndDVY22XnddM3YYfLGnAVnuqWRsA7v7hJVpqAc2KGRXJoWB13hZ5hjSuUYTD6Xfut1yeW" ], "script": "base64:AAIDAAAAAAAAABIIARIAEgUKAwgBCBIAEgMKAQEAAAANAAAAAAVvd25lcgEAAAAgxI5sOc85F96AyMEOQS+ZrrcXbjWOtavgO5Vy9VGjFCwBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAABm51bWJlcgQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAAGbnVtYmVyAQAAAA5nZXRTdHJpbmdCeUtleQAAAAEAAAADa2V5BAAAAAZzdHJpbmcEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWECAAAABG5vbmUFAAAABnN0cmluZwEAAAAPZ2V0SXRlbUtleVByaWNlAAAAAQAAAARpdGVtCQABLAAAAAIFAAAABGl0ZW0CAAAABl9wcmljZQEAAAARZ2V0Vm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VzdWx0AAAAAgkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAAKY3VycmVudEtleQUAAAAJbmV3QW1vdW50BQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAAZhbW91bnQFAAAABHVuaXQFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAEAAAAByRtYXRjaDAFAAAAAnR4AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABRTZXRTY3JpcHRUcmFuc2FjdGlvbgQAAAABYQUAAAAHJG1hdGNoMAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAABW93bmVyAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAA9EYXRhVHJhbnNhY3Rpb24EAAAAAWIFAAAAByRtYXRjaDAGBzcVMZY=", "chainId": 84, "height": 725626, "spentComplexity": 0 } View: original | compacted Prev: BEBVB9dADX4fvRRDye9yrfxdVNzT9FWzNwqPpWaYJd3q Next: none Diff:
Old | New | Differences | |
---|---|---|---|
95 | 95 | ||
96 | 96 | ||
97 | 97 | @Callable(i) | |
98 | - | func | |
98 | + | func purchase () = { | |
99 | 99 | let pmt = extract(i.payment) | |
100 | 100 | if (isDefined(pmt.assetId)) | |
101 | 101 | then throw("you can use WAVES only at the moment") | |
108 | 108 | 0 | |
109 | 109 | } | |
110 | 110 | if ((price > pmt.amount)) | |
111 | - | then throw(" | |
111 | + | then throw("purchase amount cannot be less that item price") | |
112 | 112 | else if ((pmt.amount > price)) | |
113 | - | then throw(" | |
114 | - | else WriteSet([DataEntry(("status: | |
113 | + | then throw("purchase amount cannot be higher that item price") | |
114 | + | else WriteSet([DataEntry(("status:purchase_item_A_customer_" + customerAddres), "confirmed"), DataEntry(("price:purchase_item_A_customer" + customerAddres), price)]) | |
115 | 115 | } | |
116 | 116 | } | |
117 | 117 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let owner = base58'EEGsMXJbL3i6pER7gfBpcw87Km3h2gz6qiqhqPXbdob1' | |
5 | 5 | ||
6 | 6 | func getNumberByKey (key) = { | |
7 | 7 | let number = match getInteger(this, key) { | |
8 | 8 | case a: Int => | |
9 | 9 | a | |
10 | 10 | case _ => | |
11 | 11 | 0 | |
12 | 12 | } | |
13 | 13 | number | |
14 | 14 | } | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func getStringByKey (key) = { | |
18 | 18 | let string = match getString(this, key) { | |
19 | 19 | case a: String => | |
20 | 20 | a | |
21 | 21 | case _ => | |
22 | 22 | "none" | |
23 | 23 | } | |
24 | 24 | string | |
25 | 25 | } | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func getItemKeyPrice (item) = (item + "_price") | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | func getValueItemPrice (item) = getNumberByKey(getItemKeyPrice(item)) | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "count") | |
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(toBytes((supplier + title)))) | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func getKeyItemData (item) = (item + "_data") | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func getKeyItemSupplier (item) = (item + "_owner") | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func getValueItemSupplier (item) = getStringByKey(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 deposit () = { | |
60 | 60 | let pmt = extract(i.payment) | |
61 | 61 | if (isDefined(pmt.assetId)) | |
62 | 62 | then throw("you can use WAVES only at the moment") | |
63 | 63 | else { | |
64 | 64 | let currentKey = toBase58String(i.caller.bytes) | |
65 | 65 | let currentAmount = match getInteger(this, ("wl_sts" + currentKey)) { | |
66 | 66 | case a: Int => | |
67 | 67 | a | |
68 | 68 | case _ => | |
69 | 69 | 0 | |
70 | 70 | } | |
71 | 71 | let wlStsCurr = match getString(this, ("wls_sts" + currentKey)) { | |
72 | 72 | case a: String => | |
73 | 73 | a | |
74 | 74 | case _ => | |
75 | 75 | throw("user has not waitlisted") | |
76 | 76 | } | |
77 | 77 | let newAmount = (currentAmount + pmt.amount) | |
78 | 78 | WriteSet([DataEntry(currentKey, newAmount)]) | |
79 | 79 | } | |
80 | 80 | } | |
81 | 81 | ||
82 | 82 | ||
83 | 83 | ||
84 | 84 | @Callable(i) | |
85 | 85 | func addItem (title,price,data) = { | |
86 | 86 | let supplierAddres = toBase58String(i.caller.bytes) | |
87 | 87 | let item = getKeyItem(supplierAddres, title) | |
88 | 88 | if ((0 >= price)) | |
89 | 89 | then throw("purchase amount cannot be less that item price") | |
90 | 90 | else if (("none" != getValueItemSupplier(item))) | |
91 | 91 | then throw("an item is alreadt exist") | |
92 | 92 | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddres), DataEntry(getItemKeyPrice(item), price), DataEntry(getKeyItemData(item), data)]) | |
93 | 93 | } | |
94 | 94 | ||
95 | 95 | ||
96 | 96 | ||
97 | 97 | @Callable(i) | |
98 | - | func | |
98 | + | func purchase () = { | |
99 | 99 | let pmt = extract(i.payment) | |
100 | 100 | if (isDefined(pmt.assetId)) | |
101 | 101 | then throw("you can use WAVES only at the moment") | |
102 | 102 | else { | |
103 | 103 | let customerAddres = toBase58String(i.caller.bytes) | |
104 | 104 | let price = match getInteger(this, "item_A_coupon_price") { | |
105 | 105 | case a: Int => | |
106 | 106 | a | |
107 | 107 | case _ => | |
108 | 108 | 0 | |
109 | 109 | } | |
110 | 110 | if ((price > pmt.amount)) | |
111 | - | then throw(" | |
111 | + | then throw("purchase amount cannot be less that item price") | |
112 | 112 | else if ((pmt.amount > price)) | |
113 | - | then throw(" | |
114 | - | else WriteSet([DataEntry(("status: | |
113 | + | then throw("purchase amount cannot be higher that item price") | |
114 | + | else WriteSet([DataEntry(("status:purchase_item_A_customer_" + customerAddres), "confirmed"), DataEntry(("price:purchase_item_A_customer" + customerAddres), price)]) | |
115 | 115 | } | |
116 | 116 | } | |
117 | 117 | ||
118 | 118 | ||
119 | 119 | ||
120 | 120 | @Callable(i) | |
121 | 121 | func withdraw (amount) = { | |
122 | 122 | let currentKey = toBase58String(i.caller.bytes) | |
123 | 123 | let currentAmount = match getInteger(this, currentKey) { | |
124 | 124 | case a: Int => | |
125 | 125 | a | |
126 | 126 | case _ => | |
127 | 127 | 0 | |
128 | 128 | } | |
129 | 129 | let newAmount = (currentAmount - amount) | |
130 | 130 | if ((0 > amount)) | |
131 | 131 | then throw("can't withdraw negative amount") | |
132 | 132 | else if ((0 > newAmount)) | |
133 | 133 | then throw("not enough balance") | |
134 | 134 | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
135 | 135 | } | |
136 | 136 | ||
137 | 137 | ||
138 | 138 | @Verifier(tx) | |
139 | 139 | func verify () = match tx { | |
140 | 140 | case a: SetScriptTransaction => | |
141 | 141 | sigVerify(tx.bodyBytes, tx.proofs[0], owner) | |
142 | 142 | case b: DataTransaction => | |
143 | 143 | true | |
144 | 144 | case _ => | |
145 | 145 | false | |
146 | 146 | } | |
147 | 147 |
github/deemru/w8io/169f3d6 42.93 ms ◑