tx · BieAafGQFz8YETNncydwoyz3jA2P4fepp5WCYzqnQaos 3N7Gg64FJ3ESaqn41qu1ete7zmzbmoP1AAV: -0.01000000 Waves 2021.12.12 09:00 [1830640] smart account 3N7Gg64FJ3ESaqn41qu1ete7zmzbmoP1AAV > SELF 0.00000000 Waves
{ "type": 13, "id": "BieAafGQFz8YETNncydwoyz3jA2P4fepp5WCYzqnQaos", "fee": 1000000, "feeAssetId": null, "timestamp": 1639288833102, "version": 2, "chainId": 84, "sender": "3N7Gg64FJ3ESaqn41qu1ete7zmzbmoP1AAV", "senderPublicKey": "5amLtMwixiEesBDKPy9dkFWntG2fNxhTs5n69JbQE9F7", "proofs": [ "2h9xTMmPfnQiZxAX6AChvR6bh3AKfttHfZpUviyjqw5mRye3L1ofqCKcZmjdo1sP1arP6UZfmrtXBX4pdpkRXPMT" ], "script": "base64:AAIFAAAAAAAAAAsIAhIAEgMKAQgSAAAAAAMAAAAABXRva2VuAQAAACDnOZgLkNAqR859hHqstm3f+W8Ysf2b79oIcjd5zepeZgAAAAAHYWlyZHJvcAkBAAAAB0FkZHJlc3MAAAABAQAAABoBVL5fGbDUbkI0fER3ZA37DWC9GkZHGFznigAAAAAKdGVhbUFkcmVzcwkBAAAAB0FkZHJlc3MAAAABAQAAABoBVAAmCU/IrzTjRqRT1pNRXalTwMQKQXJi2gAAAAMAAAABaQEAAAAFcmVzZXQAAAAACQAETAAAAAIJAQAAAAtEZWxldGVFbnRyeQAAAAEJAAJYAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgIAAAAFYnVybnQAAAAAAAAAAAAJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAICAAAAB2Ryb3BwZWQAAAAAAAAAAAAJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAICAAAACHRlYW1naWZ0AAAAAAAAAAAACQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAA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5pdAkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADBQAAAAxjYWxsZXJBZHJlc3MFAAAACnNlbGxhbW91bnQFAAAABXRva2VuBQAAAANuaWwJAARMAAAAAgkBAAAAC1N0cmluZ0VudHJ5AAAAAgkAASwAAAACCQACWAAAAAEICAUAAAABaQAAAAZjYWxsZXIAAAAFYnl0ZXMCAAAABF9idXkFAAAABG1lc3MFAAAAA25pbAAAAAB876a+", "height": 1830640, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 52qJsLn7sJW8jo366ZaXQqvRfAuXdYHd29P3DcD871St Next: FahA1ajcuPw4vJUJyqEyHzpCgC1tQUzF7v53FJHnBoKw Diff:
Old | New | Differences | |
---|---|---|---|
120 | 120 | else false) | |
121 | 121 | then 1 | |
122 | 122 | else 2 | |
123 | + | let callerCanBuy = if (if (callerReceived) | |
124 | + | then if ((callerBuylevel == 0)) | |
125 | + | then true | |
126 | + | else (callerBuylevel == 1) | |
127 | + | else false) | |
128 | + | then true | |
129 | + | else false | |
123 | 130 | let callerPrice = if ((callerBuylevel == 0)) | |
124 | 131 | then price1 | |
125 | 132 | else if ((callerBuylevel == 1)) | |
132 | 139 | then true | |
133 | 140 | else false | |
134 | 141 | else false | |
135 | - | let mess = if (!( | |
142 | + | let mess = if (!(callerCanBuy)) | |
136 | 143 | then "not prooved for buy" | |
137 | 144 | else ("" + (if (!(pmtok)) | |
138 | 145 | then "not enough payment" | |
141 | 148 | else "")))) | |
142 | 149 | let datarecs = split(callerData, "|") | |
143 | 150 | let newdata = if (callerReceived) | |
144 | - | then | |
151 | + | then datarecs[0] | |
145 | 152 | else ("" + (if ((callerBuylevel == 0)) | |
146 | 153 | then "|bought1" | |
147 | 154 | else ("" + (if ((callerBuylevel == 1)) | |
148 | 155 | then "|bought1|bought2" | |
149 | 156 | else "")))) | |
150 | 157 | let deal = if (if (if (balanceok) | |
151 | - | then | |
158 | + | then callerCanBuy | |
152 | 159 | else false) | |
153 | 160 | then pmtok | |
154 | 161 | else false) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let token = base58'GZc7eKnq2KJwqetRmUzSqr2ZaCGseDZufSocz83sUNoo' | |
5 | 5 | ||
6 | 6 | let airdrop = Address(base58'3N7Gg64FJ3ESaqn41qu1ete7zmzbmoP1AAV') | |
7 | 7 | ||
8 | 8 | let teamAdress = Address(base58'3MovsLjXpJr9HD2vBqmAf7Gze6jwuRxX1fX') | |
9 | 9 | ||
10 | 10 | @Callable(i) | |
11 | 11 | func reset () = [DeleteEntry(toBase58String(i.caller.bytes)), IntegerEntry("burnt", 0), IntegerEntry("dropped", 0), IntegerEntry("teamgift", 0), IntegerEntry("burningstage", 0)] | |
12 | 12 | ||
13 | 13 | ||
14 | 14 | ||
15 | 15 | @Callable(i) | |
16 | 16 | func call (id58) = { | |
17 | 17 | let currenttime = match blockInfoByHeight(height) { | |
18 | 18 | case block: BlockInfo => | |
19 | 19 | block.timestamp | |
20 | 20 | case _ => | |
21 | 21 | throw("Can't find block") | |
22 | 22 | } | |
23 | 23 | let balance = assetBalance(airdrop, token) | |
24 | 24 | let burnamount = match getInteger("burningstage") { | |
25 | 25 | case a: Int => | |
26 | 26 | if (if ((getIntegerValue("burningstage") == 0)) | |
27 | 27 | then (currenttime > 1639131654752) | |
28 | 28 | else false) | |
29 | 29 | then fraction(balance, 10, 100) | |
30 | 30 | else 0 | |
31 | 31 | case _ => | |
32 | 32 | throw("no burningstage") | |
33 | 33 | } | |
34 | 34 | let dropamount = 1000 | |
35 | 35 | let teamgift = 10 | |
36 | 36 | let trid = fromBase58String(id58) | |
37 | 37 | let callerAdress = Address(i.caller.bytes) | |
38 | 38 | let deadline = 1639230864311 | |
39 | 39 | let isenough = if ((balance > dropamount)) | |
40 | 40 | then true | |
41 | 41 | else throw("not enough") | |
42 | 42 | if ((isenough == isenough)) | |
43 | 43 | then { | |
44 | 44 | let trexists = match transferTransactionById(trid) { | |
45 | 45 | case ttx: TransferTransaction => | |
46 | 46 | true | |
47 | 47 | case _ => | |
48 | 48 | false | |
49 | 49 | } | |
50 | 50 | let trtime = match transferTransactionById(trid) { | |
51 | 51 | case ttx: TransferTransaction => | |
52 | 52 | ttx.timestamp | |
53 | 53 | case _ => | |
54 | 54 | 9999999999999 | |
55 | 55 | } | |
56 | 56 | let trsender = match transferTransactionById(trid) { | |
57 | 57 | case ttx: TransferTransaction => | |
58 | 58 | ttx.sender | |
59 | 59 | case _ => | |
60 | 60 | airdrop | |
61 | 61 | } | |
62 | 62 | let received = if ((take(valueOrElse(getString(toBase58String(i.caller.bytes)), ""), 8) == "received")) | |
63 | 63 | then true | |
64 | 64 | else false | |
65 | 65 | let isprooved = if (if (if ((trtime > deadline)) | |
66 | 66 | then true | |
67 | 67 | else (callerAdress != trsender)) | |
68 | 68 | then true | |
69 | 69 | else received) | |
70 | 70 | then false | |
71 | 71 | else true | |
72 | 72 | let result = if (trexists) | |
73 | 73 | then if ((trtime > deadline)) | |
74 | 74 | then ("transaction is out of time range: " + toString(trtime)) | |
75 | 75 | else ("" + (if ((callerAdress != trsender)) | |
76 | 76 | then ((("it is incorrect sender: " + toString(callerAdress)) + " / ") + toString(trsender)) | |
77 | 77 | else ("" + (if (received) | |
78 | 78 | then getStringValue(toBase58String(i.caller.bytes)) | |
79 | 79 | else ("" + (if (isprooved) | |
80 | 80 | then ("received in " + toString(currenttime)) | |
81 | 81 | else "")))))) | |
82 | 82 | else "cant find transaction" | |
83 | 83 | if (isprooved) | |
84 | 84 | then if ((burnamount > 0)) | |
85 | 85 | then [ScriptTransfer(callerAdress, dropamount, token), ScriptTransfer(teamAdress, teamgift, token), StringEntry(toBase58String(i.caller.bytes), result), IntegerEntry("dropped", (getIntegerValue("dropped") + dropamount)), IntegerEntry("teamgift", (getIntegerValue("teamgift") + teamgift))] | |
86 | 86 | else [ScriptTransfer(callerAdress, dropamount, token), ScriptTransfer(teamAdress, teamgift, token), StringEntry(toBase58String(i.caller.bytes), result), IntegerEntry("dropped", (getIntegerValue("dropped") + dropamount)), IntegerEntry("teamgift", (getIntegerValue("teamgift") + teamgift))] | |
87 | 87 | else [StringEntry(toBase58String(i.caller.bytes), result)] | |
88 | 88 | } | |
89 | 89 | else throw("Strict value is not equal to itself.") | |
90 | 90 | } | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | ||
94 | 94 | @Callable(i) | |
95 | 95 | func buy () = { | |
96 | 96 | let currenttime = match blockInfoByHeight(height) { | |
97 | 97 | case block: BlockInfo => | |
98 | 98 | block.timestamp | |
99 | 99 | case _ => | |
100 | 100 | throw("Can't find block") | |
101 | 101 | } | |
102 | 102 | let balance = assetBalance(airdrop, token) | |
103 | 103 | let sellamount = 1000 | |
104 | 104 | let price1 = (1 * 100000000) | |
105 | 105 | let price2 = (2 * 100000000) | |
106 | 106 | let callerAdress = Address(i.caller.bytes) | |
107 | 107 | let balanceok = if ((balance >= sellamount)) | |
108 | 108 | then true | |
109 | 109 | else false | |
110 | 110 | let callerData = valueOrElse(getString(toBase58String(i.caller.bytes)), "") | |
111 | 111 | let callerReceived = if ((take(callerData, 8) == "received")) | |
112 | 112 | then true | |
113 | 113 | else false | |
114 | 114 | let callerBuylevel = if (if (callerReceived) | |
115 | 115 | then (size(split(callerData, "|")) == 1) | |
116 | 116 | else false) | |
117 | 117 | then 0 | |
118 | 118 | else if (if (callerReceived) | |
119 | 119 | then (size(split(callerData, "|")) == 2) | |
120 | 120 | else false) | |
121 | 121 | then 1 | |
122 | 122 | else 2 | |
123 | + | let callerCanBuy = if (if (callerReceived) | |
124 | + | then if ((callerBuylevel == 0)) | |
125 | + | then true | |
126 | + | else (callerBuylevel == 1) | |
127 | + | else false) | |
128 | + | then true | |
129 | + | else false | |
123 | 130 | let callerPrice = if ((callerBuylevel == 0)) | |
124 | 131 | then price1 | |
125 | 132 | else if ((callerBuylevel == 1)) | |
126 | 133 | then price2 | |
127 | 134 | else 0 | |
128 | 135 | let pmtok = if ((size(i.payments) == 1)) | |
129 | 136 | then if (if (!(isDefined(i.payments[0].assetId))) | |
130 | 137 | then (i.payments[0].amount >= callerPrice) | |
131 | 138 | else false) | |
132 | 139 | then true | |
133 | 140 | else false | |
134 | 141 | else false | |
135 | - | let mess = if (!( | |
142 | + | let mess = if (!(callerCanBuy)) | |
136 | 143 | then "not prooved for buy" | |
137 | 144 | else ("" + (if (!(pmtok)) | |
138 | 145 | then "not enough payment" | |
139 | 146 | else ("" + (if (!(balanceok)) | |
140 | 147 | then "ballance empty " | |
141 | 148 | else "")))) | |
142 | 149 | let datarecs = split(callerData, "|") | |
143 | 150 | let newdata = if (callerReceived) | |
144 | - | then | |
151 | + | then datarecs[0] | |
145 | 152 | else ("" + (if ((callerBuylevel == 0)) | |
146 | 153 | then "|bought1" | |
147 | 154 | else ("" + (if ((callerBuylevel == 1)) | |
148 | 155 | then "|bought1|bought2" | |
149 | 156 | else "")))) | |
150 | 157 | let deal = if (if (if (balanceok) | |
151 | - | then | |
158 | + | then callerCanBuy | |
152 | 159 | else false) | |
153 | 160 | then pmtok | |
154 | 161 | else false) | |
155 | 162 | then true | |
156 | 163 | else false | |
157 | 164 | if (deal) | |
158 | 165 | then [StringEntry(toBase58String(i.caller.bytes), newdata), ScriptTransfer(teamAdress, callerPrice, unit), ScriptTransfer(callerAdress, sellamount, token)] | |
159 | 166 | else [StringEntry((toBase58String(i.caller.bytes) + "_buy"), mess)] | |
160 | 167 | } | |
161 | 168 | ||
162 | 169 |
github/deemru/w8io/026f985 40.25 ms ◑