tx · HykdfxjytxdV628ndwpVA5RgTrcpsQkjLkjeDXbBkQhA 3MyV9Fm9cwW9W68VCGfPvejLujx7xVpJiKW: -0.01400000 Waves 2020.01.03 17:48 [837819] smart account 3MyV9Fm9cwW9W68VCGfPvejLujx7xVpJiKW > SELF 0.00000000 Waves
{ "type": 13, "id": "HykdfxjytxdV628ndwpVA5RgTrcpsQkjLkjeDXbBkQhA", "fee": 1400000, "feeAssetId": null, "timestamp": 1578062876136, "version": 1, "sender": "3MyV9Fm9cwW9W68VCGfPvejLujx7xVpJiKW", "senderPublicKey": "8zVjiVAuhkkAyQsSHHvjkNNoN8WDKJAEBV5nSpiyyYWr", "proofs": [ "2zQazTHUUACd6ysQzGZopH74PUMkjo8xBbPtpVMiuUQ3AjrjR3ZuemtWLjBKbdvXi934AkKJD9UYPY2vTsuJ2EGU" ], "script": "base64:AAIDAAAAAAAAABAIARIFCgMBCAgSBQoDAQgIAAAABQAAAAAQZGFwcEFjb3VudFB1YktleQEAAAAgXEhEUm3PDwRAY2AliL4WiobL9+1WmvxN966h/S9Tg1gAAAAABnBhcjdJZAEAAAAgzlhA/ZjitMWTd+McxVJoK0GcLLGrEdV8aco355LpR4wAAAAABnVzZG5JZAEAAAAgImQ/Hr5gRukRahMT3KYz/hZ+B/l36bPyFfyZSSowCjcAAAAABWJ0Y0lkAQAAACC55z+qjxAm26PduiiTGHV+rQKiANia4ToJ1sVRNwsbjQAAAAAGZXVyb0lkAQAAACCSw5qKFqMqhCqerwy3G5JWNH0QK6GLgoZ1q6bNcyUwmwAAAAIAAAABaQEAAAAHZGVwb3NpdAAAAAMAAAAKY29tcGVTdGFydAAAAAJpZAAAAANudW0EAAAAA3BtdAkBAAAAB2V4dHJhY3QAAAABCAUAAAABaQAAAAdwYXltZW50BAAAAAlwYXltZW50SWQIBQAAAANwbXQAAAAHYXNzZXRJZAQAAAAKY3VycmVudEtleQkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzBAAAAA1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ZAUAAAAKY3VycmVudEtleQUAAAAJbmV3QW1vdW50BQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAAZhbW91bnQFAAAABHVuaXQFAAAAA25pbAkAAAIAAAABAgAAAA5DYW4ndCB3aXRoZHJhdwAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAEAAAAByRtYXRjaDAFAAAAAnR4AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABNUcmFuc2ZlclRyYW5zYWN0aW9uBAAAAAN0dHgFAAAAByRtYXRjaDAJAAH0AAAAAwgFAAAAA3R0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAA3R0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAN0dHgAAAAPc2VuZGVyUHVibGljS2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABRTZXRTY3JpcHRUcmFuc2FjdGlvbgQAAAADc3R4BQAAAAckbWF0Y2gwCQAB9AAAAAMIBQAAAANzdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAANzdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAADc3R4AAAAD3NlbmRlclB1YmxpY0tleQaxZ51P", "chainId": 84, "height": 837819, "spentComplexity": 0 } View: original | compacted Prev: EprzdgqwojEiyWHBfK7PRkZz8pzkeurExq8jAmuN8NLm Next: GjNKi1PG2RNBCNwvQnYG8hY5R65nXmd6im3r3Yda6LNx Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let dappAcountPubKey = base58'7DERSZYEoBTSwaTrN1ktwnx1Y5D46mSpMSayUNs8CmcK' | |
5 | + | ||
4 | 6 | let par7Id = base58'EtV3CXQ4wqm28WPB1KaBv5B9ke2bpXRZMutYNEJUQcXm' | |
5 | 7 | ||
8 | + | let usdnId = base58'3KFXBGGLCjA5Z2DuW4Dq9fDDrHjJJP1ZEkaoajSzuKsC' | |
9 | + | ||
6 | 10 | let btcId = base58'DWgwcZTMhSvnyYCoWLRUXXSH1RSkzThXLJhww9gwkqdn' | |
7 | - | ||
8 | - | let usdId = base58'D6N2rAqWN6ZCWnCeNFWLGqqjS6nJLeK4m19XiuhdDenr' | |
9 | 11 | ||
10 | 12 | let euroId = base58'AsuWyM9MUUsMmWkK7jS48L3ky6gA1pxx7QtEYPbfLjAJ' | |
11 | 13 | ||
12 | 14 | @Callable(i) | |
13 | - | func | |
15 | + | func deposit (compeStart,id,num) = { | |
14 | 16 | let pmt = extract(i.payment) | |
15 | - | if ((pmt.assetId != par7Id)) | |
16 | - | then throw("PAR7 only at the moment") | |
17 | - | else { | |
18 | - | let currentKey = toBase58String(i.caller.bytes) | |
19 | - | let currentAmount = match getInteger(this, currentKey) { | |
20 | - | case a: Int => | |
21 | - | a | |
22 | - | case _ => | |
23 | - | 0 | |
24 | - | } | |
25 | - | let newAmount = (currentAmount + pmt.amount) | |
26 | - | WriteSet([DataEntry(currentKey, newAmount)]) | |
27 | - | } | |
28 | - | } | |
29 | - | ||
30 | - | ||
31 | - | ||
32 | - | @Callable(i) | |
33 | - | func par7withdraw (amount) = { | |
17 | + | let paymentId = pmt.assetId | |
34 | 18 | let currentKey = toBase58String(i.caller.bytes) | |
35 | 19 | let currentAmount = match getInteger(this, currentKey) { | |
36 | 20 | case a: Int => | |
38 | 22 | case _ => | |
39 | 23 | 0 | |
40 | 24 | } | |
41 | - | let newAmount = (currentAmount - amount) | |
42 | - | if ((0 > amount)) | |
43 | - | then throw("Can't withdraw negative amount") | |
44 | - | else if ((0 > newAmount)) | |
45 | - | then throw("Not enough balance") | |
46 | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, par7Id)])) | |
25 | + | let newAmount = (currentAmount + pmt.amount) | |
26 | + | WriteSet([DataEntry(((((id + "_") + num) + "_") + currentKey), newAmount), DataEntry(((((id + "_") + num) + "_compeStart_") + currentKey), compeStart)]) | |
47 | 27 | } | |
48 | 28 | ||
49 | 29 | ||
50 | 30 | ||
51 | 31 | @Callable(i) | |
52 | - | func wavesdeposit () = { | |
53 | - | let pmt = extract(i.payment) | |
54 | - | if (isDefined(pmt.assetId)) | |
55 | - | then throw("WAVES only at the moment") | |
56 | - | else { | |
57 | - | let currentKey = toBase58String(i.caller.bytes) | |
58 | - | let currentAmount = match getInteger(this, currentKey) { | |
59 | - | case a: Int => | |
60 | - | a | |
61 | - | case _ => | |
62 | - | 0 | |
63 | - | } | |
64 | - | let newAmount = (currentAmount + pmt.amount) | |
65 | - | WriteSet([DataEntry(currentKey, newAmount)]) | |
66 | - | } | |
32 | + | func withdraw (amount,id,num) = { | |
33 | + | let currentKey = toBase58String(i.caller.bytes) | |
34 | + | let compeStart = match getInteger(this, ((((id + "_") + num) + "_compeStart_") + currentKey)) { | |
35 | + | case a: Int => | |
36 | + | a | |
37 | + | case _ => | |
38 | + | 0 | |
67 | 39 | } | |
68 | - | ||
69 | - | ||
70 | - | ||
71 | - | @Callable(i) | |
72 | - | func waveswithdraw (amount) = { | |
73 | - | let currentKey = toBase58String(i.caller.bytes) | |
74 | - | let currentAmount = match getInteger(this, currentKey) { | |
40 | + | let currentAmount = match getInteger(this, ((((id + "_") + num) + "_") + currentKey)) { | |
75 | 41 | case a: Int => | |
76 | 42 | a | |
77 | 43 | case _ => | |
78 | 44 | 0 | |
79 | 45 | } | |
80 | 46 | let newAmount = (currentAmount - amount) | |
81 | - | if ((0 > amount)) | |
82 | - | then throw("Can't withdraw negative amount") | |
83 | - | else if ((0 > newAmount)) | |
84 | - | then throw("Not enough balance") | |
85 | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
86 | - | } | |
87 | - | ||
88 | - | ||
89 | - | ||
90 | - | @Callable(i) | |
91 | - | func btcdeposit () = { | |
92 | - | let pmt = extract(i.payment) | |
93 | - | if ((pmt.assetId != btcId)) | |
94 | - | then throw("btc only at the moment") | |
95 | - | else { | |
96 | - | let currentKey = toBase58String(i.caller.bytes) | |
97 | - | let currentAmount = match getInteger(this, currentKey) { | |
98 | - | case a: Int => | |
99 | - | a | |
100 | - | case _ => | |
101 | - | 0 | |
102 | - | } | |
103 | - | let newAmount = (currentAmount + pmt.amount) | |
104 | - | WriteSet([DataEntry(currentKey, newAmount)]) | |
105 | - | } | |
106 | - | } | |
107 | - | ||
108 | - | ||
109 | - | ||
110 | - | @Callable(i) | |
111 | - | func btcwithdraw (amount) = { | |
112 | - | let currentKey = toBase58String(i.caller.bytes) | |
113 | - | let currentAmount = match getInteger(this, currentKey) { | |
114 | - | case a: Int => | |
115 | - | a | |
116 | - | case _ => | |
117 | - | 0 | |
118 | - | } | |
119 | - | let newAmount = (currentAmount - amount) | |
120 | - | if ((0 > amount)) | |
121 | - | then throw("Can't withdraw negative amount") | |
122 | - | else if ((0 > newAmount)) | |
123 | - | then throw("Not enough balance") | |
124 | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, btcId)])) | |
125 | - | } | |
126 | - | ||
127 | - | ||
128 | - | ||
129 | - | @Callable(i) | |
130 | - | func usddeposit () = { | |
131 | - | let pmt = extract(i.payment) | |
132 | - | if ((pmt.assetId != usdId)) | |
133 | - | then throw("US Doller only at the moment") | |
134 | - | else { | |
135 | - | let currentKey = toBase58String(i.caller.bytes) | |
136 | - | let currentAmount = match getInteger(this, currentKey) { | |
137 | - | case a: Int => | |
138 | - | a | |
139 | - | case _ => | |
140 | - | 0 | |
141 | - | } | |
142 | - | let newAmount = (currentAmount + pmt.amount) | |
143 | - | WriteSet([DataEntry(currentKey, newAmount)]) | |
144 | - | } | |
145 | - | } | |
146 | - | ||
147 | - | ||
148 | - | ||
149 | - | @Callable(i) | |
150 | - | func usdwithdraw (amount) = { | |
151 | - | let currentKey = toBase58String(i.caller.bytes) | |
152 | - | let currentAmount = match getInteger(this, currentKey) { | |
153 | - | case a: Int => | |
154 | - | a | |
155 | - | case _ => | |
156 | - | 0 | |
157 | - | } | |
158 | - | let newAmount = (currentAmount - amount) | |
159 | - | if ((0 > amount)) | |
160 | - | then throw("Can't withdraw negative amount") | |
161 | - | else if ((0 > newAmount)) | |
162 | - | then throw("Not enough balance") | |
163 | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, usdId)])) | |
164 | - | } | |
165 | - | ||
166 | - | ||
167 | - | ||
168 | - | @Callable(i) | |
169 | - | func eurodeposit () = { | |
170 | - | let pmt = extract(i.payment) | |
171 | - | if ((pmt.assetId != euroId)) | |
172 | - | then throw("US Doller only at the moment") | |
173 | - | else { | |
174 | - | let currentKey = toBase58String(i.caller.bytes) | |
175 | - | let currentAmount = match getInteger(this, currentKey) { | |
176 | - | case a: Int => | |
177 | - | a | |
178 | - | case _ => | |
179 | - | 0 | |
180 | - | } | |
181 | - | let newAmount = (currentAmount + pmt.amount) | |
182 | - | WriteSet([DataEntry(currentKey, newAmount)]) | |
183 | - | } | |
184 | - | } | |
185 | - | ||
186 | - | ||
187 | - | ||
188 | - | @Callable(i) | |
189 | - | func eurowithdraw (amount) = { | |
190 | - | let currentKey = toBase58String(i.caller.bytes) | |
191 | - | let currentAmount = match getInteger(this, currentKey) { | |
192 | - | case a: Int => | |
193 | - | a | |
194 | - | case _ => | |
195 | - | 0 | |
196 | - | } | |
197 | - | let newAmount = (currentAmount - amount) | |
198 | - | if ((0 > amount)) | |
199 | - | then throw("Can't withdraw negative amount") | |
200 | - | else if ((0 > newAmount)) | |
201 | - | then throw("Not enough balance") | |
202 | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, euroId)])) | |
47 | + | if ((lastBlock.timestamp > compeStart)) | |
48 | + | then throw("Can't withdraw compe start") | |
49 | + | else if ((0 > amount)) | |
50 | + | then throw("Can't withdraw negative amount") | |
51 | + | else if ((0 > newAmount)) | |
52 | + | then throw("Not enough balance") | |
53 | + | else if ((id == "EtV3CXQ4wqm28WPB1KaBv5B9ke2bpXRZMutYNEJUQcXm")) | |
54 | + | then ScriptResult(WriteSet([DataEntry((id + currentKey), newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, par7Id)])) | |
55 | + | else if ((id == "3KFXBGGLCjA5Z2DuW4Dq9fDDrHjJJP1ZEkaoajSzuKsC")) | |
56 | + | then ScriptResult(WriteSet([DataEntry((id + currentKey), newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, usdnId)])) | |
57 | + | else if ((id == "DWgwcZTMhSvnyYCoWLRUXXSH1RSkzThXLJhww9gwkqdn")) | |
58 | + | then ScriptResult(WriteSet([DataEntry((id + currentKey), newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, btcId)])) | |
59 | + | else if ((id == "AsuWyM9MUUsMmWkK7jS48L3ky6gA1pxx7QtEYPbfLjAJ")) | |
60 | + | then ScriptResult(WriteSet([DataEntry((id + currentKey), newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, euroId)])) | |
61 | + | else if ((id == "WAVES")) | |
62 | + | then ScriptResult(WriteSet([DataEntry((id + currentKey), newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
63 | + | else throw("Can't withdraw") | |
203 | 64 | } | |
204 | 65 | ||
205 | 66 | ||
206 | 67 | @Verifier(tx) | |
207 | 68 | func verify () = match tx { | |
208 | - | case d: InvokeScriptTransaction => | |
69 | + | case ttx: TransferTransaction => | |
70 | + | sigVerify(ttx.bodyBytes, ttx.proofs[0], ttx.senderPublicKey) | |
71 | + | case stx: SetScriptTransaction => | |
72 | + | sigVerify(stx.bodyBytes, stx.proofs[0], stx.senderPublicKey) | |
73 | + | case _ => | |
209 | 74 | true | |
210 | - | case _ => | |
211 | - | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
212 | 75 | } | |
213 | 76 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let dappAcountPubKey = base58'7DERSZYEoBTSwaTrN1ktwnx1Y5D46mSpMSayUNs8CmcK' | |
5 | + | ||
4 | 6 | let par7Id = base58'EtV3CXQ4wqm28WPB1KaBv5B9ke2bpXRZMutYNEJUQcXm' | |
5 | 7 | ||
8 | + | let usdnId = base58'3KFXBGGLCjA5Z2DuW4Dq9fDDrHjJJP1ZEkaoajSzuKsC' | |
9 | + | ||
6 | 10 | let btcId = base58'DWgwcZTMhSvnyYCoWLRUXXSH1RSkzThXLJhww9gwkqdn' | |
7 | - | ||
8 | - | let usdId = base58'D6N2rAqWN6ZCWnCeNFWLGqqjS6nJLeK4m19XiuhdDenr' | |
9 | 11 | ||
10 | 12 | let euroId = base58'AsuWyM9MUUsMmWkK7jS48L3ky6gA1pxx7QtEYPbfLjAJ' | |
11 | 13 | ||
12 | 14 | @Callable(i) | |
13 | - | func | |
15 | + | func deposit (compeStart,id,num) = { | |
14 | 16 | let pmt = extract(i.payment) | |
15 | - | if ((pmt.assetId != par7Id)) | |
16 | - | then throw("PAR7 only at the moment") | |
17 | - | else { | |
18 | - | let currentKey = toBase58String(i.caller.bytes) | |
19 | - | let currentAmount = match getInteger(this, currentKey) { | |
20 | - | case a: Int => | |
21 | - | a | |
22 | - | case _ => | |
23 | - | 0 | |
24 | - | } | |
25 | - | let newAmount = (currentAmount + pmt.amount) | |
26 | - | WriteSet([DataEntry(currentKey, newAmount)]) | |
27 | - | } | |
28 | - | } | |
29 | - | ||
30 | - | ||
31 | - | ||
32 | - | @Callable(i) | |
33 | - | func par7withdraw (amount) = { | |
17 | + | let paymentId = pmt.assetId | |
34 | 18 | let currentKey = toBase58String(i.caller.bytes) | |
35 | 19 | let currentAmount = match getInteger(this, currentKey) { | |
36 | 20 | case a: Int => | |
37 | 21 | a | |
38 | 22 | case _ => | |
39 | 23 | 0 | |
40 | 24 | } | |
41 | - | let newAmount = (currentAmount - amount) | |
42 | - | if ((0 > amount)) | |
43 | - | then throw("Can't withdraw negative amount") | |
44 | - | else if ((0 > newAmount)) | |
45 | - | then throw("Not enough balance") | |
46 | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, par7Id)])) | |
25 | + | let newAmount = (currentAmount + pmt.amount) | |
26 | + | WriteSet([DataEntry(((((id + "_") + num) + "_") + currentKey), newAmount), DataEntry(((((id + "_") + num) + "_compeStart_") + currentKey), compeStart)]) | |
47 | 27 | } | |
48 | 28 | ||
49 | 29 | ||
50 | 30 | ||
51 | 31 | @Callable(i) | |
52 | - | func wavesdeposit () = { | |
53 | - | let pmt = extract(i.payment) | |
54 | - | if (isDefined(pmt.assetId)) | |
55 | - | then throw("WAVES only at the moment") | |
56 | - | else { | |
57 | - | let currentKey = toBase58String(i.caller.bytes) | |
58 | - | let currentAmount = match getInteger(this, currentKey) { | |
59 | - | case a: Int => | |
60 | - | a | |
61 | - | case _ => | |
62 | - | 0 | |
63 | - | } | |
64 | - | let newAmount = (currentAmount + pmt.amount) | |
65 | - | WriteSet([DataEntry(currentKey, newAmount)]) | |
66 | - | } | |
32 | + | func withdraw (amount,id,num) = { | |
33 | + | let currentKey = toBase58String(i.caller.bytes) | |
34 | + | let compeStart = match getInteger(this, ((((id + "_") + num) + "_compeStart_") + currentKey)) { | |
35 | + | case a: Int => | |
36 | + | a | |
37 | + | case _ => | |
38 | + | 0 | |
67 | 39 | } | |
68 | - | ||
69 | - | ||
70 | - | ||
71 | - | @Callable(i) | |
72 | - | func waveswithdraw (amount) = { | |
73 | - | let currentKey = toBase58String(i.caller.bytes) | |
74 | - | let currentAmount = match getInteger(this, currentKey) { | |
40 | + | let currentAmount = match getInteger(this, ((((id + "_") + num) + "_") + currentKey)) { | |
75 | 41 | case a: Int => | |
76 | 42 | a | |
77 | 43 | case _ => | |
78 | 44 | 0 | |
79 | 45 | } | |
80 | 46 | let newAmount = (currentAmount - amount) | |
81 | - | if ((0 > amount)) | |
82 | - | then throw("Can't withdraw negative amount") | |
83 | - | else if ((0 > newAmount)) | |
84 | - | then throw("Not enough balance") | |
85 | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
86 | - | } | |
87 | - | ||
88 | - | ||
89 | - | ||
90 | - | @Callable(i) | |
91 | - | func btcdeposit () = { | |
92 | - | let pmt = extract(i.payment) | |
93 | - | if ((pmt.assetId != btcId)) | |
94 | - | then throw("btc only at the moment") | |
95 | - | else { | |
96 | - | let currentKey = toBase58String(i.caller.bytes) | |
97 | - | let currentAmount = match getInteger(this, currentKey) { | |
98 | - | case a: Int => | |
99 | - | a | |
100 | - | case _ => | |
101 | - | 0 | |
102 | - | } | |
103 | - | let newAmount = (currentAmount + pmt.amount) | |
104 | - | WriteSet([DataEntry(currentKey, newAmount)]) | |
105 | - | } | |
106 | - | } | |
107 | - | ||
108 | - | ||
109 | - | ||
110 | - | @Callable(i) | |
111 | - | func btcwithdraw (amount) = { | |
112 | - | let currentKey = toBase58String(i.caller.bytes) | |
113 | - | let currentAmount = match getInteger(this, currentKey) { | |
114 | - | case a: Int => | |
115 | - | a | |
116 | - | case _ => | |
117 | - | 0 | |
118 | - | } | |
119 | - | let newAmount = (currentAmount - amount) | |
120 | - | if ((0 > amount)) | |
121 | - | then throw("Can't withdraw negative amount") | |
122 | - | else if ((0 > newAmount)) | |
123 | - | then throw("Not enough balance") | |
124 | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, btcId)])) | |
125 | - | } | |
126 | - | ||
127 | - | ||
128 | - | ||
129 | - | @Callable(i) | |
130 | - | func usddeposit () = { | |
131 | - | let pmt = extract(i.payment) | |
132 | - | if ((pmt.assetId != usdId)) | |
133 | - | then throw("US Doller only at the moment") | |
134 | - | else { | |
135 | - | let currentKey = toBase58String(i.caller.bytes) | |
136 | - | let currentAmount = match getInteger(this, currentKey) { | |
137 | - | case a: Int => | |
138 | - | a | |
139 | - | case _ => | |
140 | - | 0 | |
141 | - | } | |
142 | - | let newAmount = (currentAmount + pmt.amount) | |
143 | - | WriteSet([DataEntry(currentKey, newAmount)]) | |
144 | - | } | |
145 | - | } | |
146 | - | ||
147 | - | ||
148 | - | ||
149 | - | @Callable(i) | |
150 | - | func usdwithdraw (amount) = { | |
151 | - | let currentKey = toBase58String(i.caller.bytes) | |
152 | - | let currentAmount = match getInteger(this, currentKey) { | |
153 | - | case a: Int => | |
154 | - | a | |
155 | - | case _ => | |
156 | - | 0 | |
157 | - | } | |
158 | - | let newAmount = (currentAmount - amount) | |
159 | - | if ((0 > amount)) | |
160 | - | then throw("Can't withdraw negative amount") | |
161 | - | else if ((0 > newAmount)) | |
162 | - | then throw("Not enough balance") | |
163 | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, usdId)])) | |
164 | - | } | |
165 | - | ||
166 | - | ||
167 | - | ||
168 | - | @Callable(i) | |
169 | - | func eurodeposit () = { | |
170 | - | let pmt = extract(i.payment) | |
171 | - | if ((pmt.assetId != euroId)) | |
172 | - | then throw("US Doller only at the moment") | |
173 | - | else { | |
174 | - | let currentKey = toBase58String(i.caller.bytes) | |
175 | - | let currentAmount = match getInteger(this, currentKey) { | |
176 | - | case a: Int => | |
177 | - | a | |
178 | - | case _ => | |
179 | - | 0 | |
180 | - | } | |
181 | - | let newAmount = (currentAmount + pmt.amount) | |
182 | - | WriteSet([DataEntry(currentKey, newAmount)]) | |
183 | - | } | |
184 | - | } | |
185 | - | ||
186 | - | ||
187 | - | ||
188 | - | @Callable(i) | |
189 | - | func eurowithdraw (amount) = { | |
190 | - | let currentKey = toBase58String(i.caller.bytes) | |
191 | - | let currentAmount = match getInteger(this, currentKey) { | |
192 | - | case a: Int => | |
193 | - | a | |
194 | - | case _ => | |
195 | - | 0 | |
196 | - | } | |
197 | - | let newAmount = (currentAmount - amount) | |
198 | - | if ((0 > amount)) | |
199 | - | then throw("Can't withdraw negative amount") | |
200 | - | else if ((0 > newAmount)) | |
201 | - | then throw("Not enough balance") | |
202 | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, euroId)])) | |
47 | + | if ((lastBlock.timestamp > compeStart)) | |
48 | + | then throw("Can't withdraw compe start") | |
49 | + | else if ((0 > amount)) | |
50 | + | then throw("Can't withdraw negative amount") | |
51 | + | else if ((0 > newAmount)) | |
52 | + | then throw("Not enough balance") | |
53 | + | else if ((id == "EtV3CXQ4wqm28WPB1KaBv5B9ke2bpXRZMutYNEJUQcXm")) | |
54 | + | then ScriptResult(WriteSet([DataEntry((id + currentKey), newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, par7Id)])) | |
55 | + | else if ((id == "3KFXBGGLCjA5Z2DuW4Dq9fDDrHjJJP1ZEkaoajSzuKsC")) | |
56 | + | then ScriptResult(WriteSet([DataEntry((id + currentKey), newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, usdnId)])) | |
57 | + | else if ((id == "DWgwcZTMhSvnyYCoWLRUXXSH1RSkzThXLJhww9gwkqdn")) | |
58 | + | then ScriptResult(WriteSet([DataEntry((id + currentKey), newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, btcId)])) | |
59 | + | else if ((id == "AsuWyM9MUUsMmWkK7jS48L3ky6gA1pxx7QtEYPbfLjAJ")) | |
60 | + | then ScriptResult(WriteSet([DataEntry((id + currentKey), newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, euroId)])) | |
61 | + | else if ((id == "WAVES")) | |
62 | + | then ScriptResult(WriteSet([DataEntry((id + currentKey), newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
63 | + | else throw("Can't withdraw") | |
203 | 64 | } | |
204 | 65 | ||
205 | 66 | ||
206 | 67 | @Verifier(tx) | |
207 | 68 | func verify () = match tx { | |
208 | - | case d: InvokeScriptTransaction => | |
69 | + | case ttx: TransferTransaction => | |
70 | + | sigVerify(ttx.bodyBytes, ttx.proofs[0], ttx.senderPublicKey) | |
71 | + | case stx: SetScriptTransaction => | |
72 | + | sigVerify(stx.bodyBytes, stx.proofs[0], stx.senderPublicKey) | |
73 | + | case _ => | |
209 | 74 | true | |
210 | - | case _ => | |
211 | - | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
212 | 75 | } | |
213 | 76 |
github/deemru/w8io/169f3d6 50.67 ms ◑