tx · AcQwYeqECaLRMMRkLKh2aJwGwodkbBYE1BryfkEgPcjm 3MrdV3AP4zfU77ifesNStoDZmL1Cfx13eDc: -0.05000000 Waves 2020.01.08 20:53 [845252] smart account 3MrdV3AP4zfU77ifesNStoDZmL1Cfx13eDc > SELF 0.00000000 Waves
{ "type": 13, "id": "AcQwYeqECaLRMMRkLKh2aJwGwodkbBYE1BryfkEgPcjm", "fee": 5000000, "feeAssetId": null, "timestamp": 1578505964180, "version": 1, "sender": "3MrdV3AP4zfU77ifesNStoDZmL1Cfx13eDc", "senderPublicKey": "5M79Anear5ntQk2bbDdFA2goiPXkv7Xy2UpV4n5RKRv", "proofs": [ "5CUgJCpDqx35osMnvfb7dZxYEKXteYSFZeNNnssAAShwQ2C4i8fSmxEuWzvFpdYJvzKWsme1CK7Fn7gdkDxZsC2Q" ], "script": "base64:AAIDAAAAAAAAAAQIARIAAAAAFAAAAAANTE9DS0VEV0JFVEtFWQIAAAATJFdCRVRfTE9DS0VEX0FNT1VOVAAAAAAOTE9DS0VEUk9ZQUxLRVkCAAAAFCRST1lBTF9MT0NLRVJfQU1PVU5UAAAAABBXQUxMRVRDT1VOVEVSS0VZAgAAAAskV0FMTEVUX05VTQAAAAAPQ09NTVVOSVRZRkVFS0VZAgAAABQkQ09NTVVOSVRZRkVFX0FNT1VOVAAAAAAEV0JFVAEAAAAghrQ2qHjTDszY8BetSy4sBB8Hn7rKuRapStdvJa2b0HYAAAAABVJPWUFMAQAAACCbNjGl6sjFQai4ApeuQqCIF0KYeYQ2YB37uvrJElJLuwAAAAAPQ09NTVVOSVRZV0FMTEVUCQEAAAAHQWRkcmVzcwAAAAEBAAAAGgFULxHweE6v1pOfqW4iK2a1H7JT13jPO2j7AAAAAApXQkVUTE9DS0VEAAAAAAAAAAAAAAAAAAtST1lBTExPQ0tFRAAAAAAAAAAAAQAAAAAMV0JFVFdJVEhEUkFXAAAAAAAAAAACAAAAAA1ST1lBTFdJVEhEUkFXAAAAAAAAAAADAAAAAA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AAAA1wYXJzZUludFZhbHVlAAAAAQkAAZEAAAACBQAAAAdhbW91bnRzBQAAAA1XQVZFU1dJVEhEUkFXCQAETAAAAAIFAAAACndiZXRBbW91bnQJAARMAAAAAgUAAAALcm95YWxBbW91bnQJAARMAAAAAgUAAAAMd2JldFdpdGhkcmF3CQAETAAAAAIFAAAADXJveWFsV2l0aGRyYXcJAARMAAAAAgUAAAANd2F2ZXNXaXRoZHJhdwUAAAADbmlsAAAAAQAAAAFpAQAAAANmaXgAAAAACQEAAAAMU2NyaXB0UmVzdWx0AAAAAgkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgIAAAAjM041SFBaQ2JSZnZoMU5jRUxOck0xM0JYbzVrVDhUTHl1eUwCAAAALzg2Mzg1MjUwMDAwMDAwMDAwXzEzMDc5MDAwMDAwXzBfNDM2NjQ0MDEwMuKArF8wCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACAgAAACMzTjUzU0NRM1dSeHk4N0RHQlE1Q3l6bVlDb0M2YzFOVTNmbQIAAAA1MTE4MDUwMTE0MDAwMDAwMDBfMTc4NjAwMDAwMF83NTQ4NDg0ODIxMDFfNTk2NzM1NjM3XzAFAAAAA25pbAkBAAAAC1RyYW5zZmVyU2V0AAAAAQUAAAADbmlsAAAAAB5LWd0=", "chainId": 84, "height": 845252, "spentComplexity": 0 } View: original | compacted Prev: J6b6hntFFT6GYqdB6mfyLhYmopVcL9sbeSozUvS9YQzf Next: 3LCGotmvgzGVG8re391LBj54768XjY5GB1seE7a2on2H Diff:
Old | New | Differences | |
---|---|---|---|
11 | 11 | ||
12 | 12 | let WBET = base58'A4q1mYKo11yuH9gmvDodeJoksagcyQzeFE9JtphMWddw' | |
13 | 13 | ||
14 | - | let ROYAL = base58' | |
14 | + | let ROYAL = base58'BSt87FHK4td7NvDuzKYeb2ETVersiZDr4QW6WMX1BaFU' | |
15 | 15 | ||
16 | 16 | let COMMUNITYWALLET = Address(base58'3MtCy2PCFPyu8A9SRNL4qUo1V17SGLHftD8') | |
17 | 17 | ||
91 | 91 | ||
92 | 92 | ||
93 | 93 | @Callable(i) | |
94 | - | func lock () = { | |
95 | - | let payment = extract(i.payment) | |
96 | - | if (if ((payment.assetId != WBET)) | |
97 | - | then (payment.assetId != ROYAL) | |
98 | - | else false) | |
99 | - | then throw("The token should be in WBET or ROYAL.") | |
100 | - | else { | |
101 | - | let wallet = toString(i.caller) | |
102 | - | let balance = ParsePlayerBalance(wallet) | |
103 | - | if ((payment.assetId == WBET)) | |
104 | - | then { | |
105 | - | let newWBETReservedAmount = (ExtractWBETReservedAmt() + payment.amount) | |
106 | - | let newPlayerWBETAmount = (balance[WBETLOCKED] + payment.amount) | |
107 | - | if (WalletExist(wallet)) | |
108 | - | then ScriptResult(WriteSet([DataEntry(LOCKEDWBETKEY, newWBETReservedAmount), DataEntry(wallet, FormatPlayerBalance(newPlayerWBETAmount, balance[ROYALLOCKED], balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet(nil)) | |
109 | - | else { | |
110 | - | let newWalletNum = IncrementWalletNum() | |
111 | - | ScriptResult(WriteSet([DataEntry(WALLETCOUNTERKEY, newWalletNum), DataEntry(LOCKEDWBETKEY, newWBETReservedAmount), DataEntry(wallet, FormatPlayerBalance(newPlayerWBETAmount, balance[ROYALLOCKED], balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet(nil)) | |
112 | - | } | |
113 | - | } | |
114 | - | else if ((payment.assetId == ROYAL)) | |
115 | - | then { | |
116 | - | let newROYALReservedAmount = (ExtractROYALReservedAmt() + payment.amount) | |
117 | - | let newPlayerRoyalAmount = (balance[ROYALLOCKED] + payment.amount) | |
118 | - | if (WalletExist(wallet)) | |
119 | - | then ScriptResult(WriteSet([DataEntry(LOCKEDROYALKEY, newROYALReservedAmount), DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], newPlayerRoyalAmount, balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet(nil)) | |
120 | - | else { | |
121 | - | let newWalletNum = IncrementWalletNum() | |
122 | - | ScriptResult(WriteSet([DataEntry(WALLETCOUNTERKEY, newWalletNum), DataEntry(LOCKEDROYALKEY, newROYALReservedAmount), DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], newPlayerRoyalAmount, balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet(nil)) | |
123 | - | } | |
124 | - | } | |
125 | - | else throw("error") | |
126 | - | } | |
127 | - | } | |
128 | - | ||
129 | - | ||
130 | - | ||
131 | - | @Callable(i) | |
132 | - | func unlock (asset) = { | |
133 | - | let wallet = toString(i.caller) | |
134 | - | let balance = ParsePlayerBalance(wallet) | |
135 | - | if ((asset == "WBET")) | |
136 | - | then if ((0 >= balance[WBETLOCKED])) | |
137 | - | then throw("You dont have enough balance to withdraw the amount requested.") | |
138 | - | else { | |
139 | - | let newWBETReservedAmount = (ExtractWBETReservedAmt() - balance[WBETLOCKED]) | |
140 | - | ScriptResult(WriteSet([DataEntry(LOCKEDWBETKEY, newWBETReservedAmount), DataEntry(wallet, FormatPlayerBalance(0, balance[ROYALLOCKED], balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet([ScriptTransfer(i.caller, balance[WBETLOCKED], WBET)])) | |
141 | - | } | |
142 | - | else if ((asset == "ROYAL")) | |
143 | - | then if ((0 >= balance[ROYALLOCKED])) | |
144 | - | then throw("You dont have enough balance to withdraw the amount requested.") | |
145 | - | else { | |
146 | - | let newROYALReservedAmount = (ExtractROYALReservedAmt() - balance[ROYALLOCKED]) | |
147 | - | ScriptResult(WriteSet([DataEntry(LOCKEDROYALKEY, newROYALReservedAmount), DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], 0, balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet([ScriptTransfer(i.caller, balance[ROYALLOCKED], ROYAL)])) | |
148 | - | } | |
149 | - | else throw("Invalid asset") | |
150 | - | } | |
151 | - | ||
152 | - | ||
153 | - | ||
154 | - | @Callable(i) | |
155 | - | func withdraw (asset) = { | |
156 | - | let wallet = toString(i.caller) | |
157 | - | let balance = ParsePlayerBalance(wallet) | |
158 | - | if ((asset == "WBET")) | |
159 | - | then if ((0 >= balance[WBETWITHDRAW])) | |
160 | - | then throw("You dont have enough balance to withdraw the amount requested.") | |
161 | - | else ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], 0, balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet([ScriptTransfer(i.caller, balance[WBETWITHDRAW], WBET)])) | |
162 | - | else if ((asset == "ROYAL")) | |
163 | - | then if ((0 >= balance[ROYALWITHDRAW])) | |
164 | - | then throw("You dont have enough balance to withdraw the amount requested.") | |
165 | - | else ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], balance[WBETWITHDRAW], 0, balance[WAVESWITHDRAW]))]), TransferSet([ScriptTransfer(i.caller, balance[ROYALWITHDRAW], ROYAL)])) | |
166 | - | else if ((asset == "WAVES")) | |
167 | - | then if ((0 >= balance[WAVESWITHDRAW])) | |
168 | - | then throw("You dont have enough balance to withdraw the amount requested.") | |
169 | - | else ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], balance[WBETWITHDRAW], balance[WBETWITHDRAW], 0))]), TransferSet([ScriptTransfer(i.caller, balance[WAVESWITHDRAW], unit)])) | |
170 | - | else throw("Invalid asset") | |
171 | - | } | |
172 | - | ||
173 | - | ||
174 | - | ||
175 | - | @Callable(i) | |
176 | - | func addWithdraw (wallet) = if ((i.caller == COMMUNITYWALLET)) | |
177 | - | then { | |
178 | - | let payment = extract(i.payment) | |
179 | - | let balance = ParsePlayerBalance(wallet) | |
180 | - | if ((payment.assetId == WBET)) | |
181 | - | then { | |
182 | - | let newWbetAmount = (balance[WBETWITHDRAW] + payment.amount) | |
183 | - | ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], newWbetAmount, balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet(nil)) | |
184 | - | } | |
185 | - | else if ((payment.assetId == ROYAL)) | |
186 | - | then { | |
187 | - | let newRoyalAmount = (balance[ROYALWITHDRAW] + payment.amount) | |
188 | - | ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], balance[WBETWITHDRAW], newRoyalAmount, balance[WAVESWITHDRAW]))]), TransferSet(nil)) | |
189 | - | } | |
190 | - | else if ((payment.assetId == unit)) | |
191 | - | then { | |
192 | - | let newWavesAmount = (balance[WAVESWITHDRAW] + payment.amount) | |
193 | - | ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], balance[WBETWITHDRAW], balance[ROYALWITHDRAW], newWavesAmount))]), TransferSet(nil)) | |
194 | - | } | |
195 | - | else throw("Invalid asset") | |
196 | - | } | |
197 | - | else throw("You do not have permission to perform this function.") | |
198 | - | ||
199 | - | ||
200 | - | ||
201 | - | @Callable(i) | |
202 | - | func addCommunityFee () = { | |
203 | - | let payment = extract(i.payment) | |
204 | - | if ((payment.assetId != assetInfo(base58'WAVES'))) | |
205 | - | then throw("Payment should be in WAVES.") | |
206 | - | else { | |
207 | - | let newFEEReservedAmount = (ExtractFEEReservedAmt() + payment.amount) | |
208 | - | ScriptResult(WriteSet([DataEntry(COMMUNITYFEEKEY, newFEEReservedAmount)]), TransferSet(nil)) | |
209 | - | } | |
210 | - | } | |
211 | - | ||
212 | - | ||
213 | - | ||
214 | - | @Callable(i) | |
215 | - | func getCommunityFee (amount) = if ((i.caller == COMMUNITYWALLET)) | |
216 | - | then { | |
217 | - | let payment = extract(i.payment) | |
218 | - | let FEEReservedAmount = ExtractFEEReservedAmt() | |
219 | - | if ((amount > FEEReservedAmount)) | |
220 | - | then throw("You dont have enough balance to transfer the amount requested.") | |
221 | - | else { | |
222 | - | let newFEEReservedAmount = (FEEReservedAmount - amount) | |
223 | - | ScriptResult(WriteSet([DataEntry(COMMUNITYFEEKEY, newFEEReservedAmount)]), TransferSet([ScriptTransfer(COMMUNITYWALLET, amount, unit)])) | |
224 | - | } | |
225 | - | } | |
226 | - | else throw("You do not have permission to perform this function.") | |
94 | + | func fix () = ScriptResult(WriteSet([DataEntry("3N5HPZCbRfvh1NcELNrM13BXo5kT8TLyuyL", "86385250000000000_13079000000_0_4366440102_0"), DataEntry("3N53SCQ3WRxy87DGBQ5CyzmYCoC6c1NU3fm", "11805011400000000_1786000000_754848482101_596735637_0")]), TransferSet(nil)) | |
227 | 95 | ||
228 | 96 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let LOCKEDWBETKEY = "$WBET_LOCKED_AMOUNT" | |
5 | 5 | ||
6 | 6 | let LOCKEDROYALKEY = "$ROYAL_LOCKER_AMOUNT" | |
7 | 7 | ||
8 | 8 | let WALLETCOUNTERKEY = "$WALLET_NUM" | |
9 | 9 | ||
10 | 10 | let COMMUNITYFEEKEY = "$COMMUNITYFEE_AMOUNT" | |
11 | 11 | ||
12 | 12 | let WBET = base58'A4q1mYKo11yuH9gmvDodeJoksagcyQzeFE9JtphMWddw' | |
13 | 13 | ||
14 | - | let ROYAL = base58' | |
14 | + | let ROYAL = base58'BSt87FHK4td7NvDuzKYeb2ETVersiZDr4QW6WMX1BaFU' | |
15 | 15 | ||
16 | 16 | let COMMUNITYWALLET = Address(base58'3MtCy2PCFPyu8A9SRNL4qUo1V17SGLHftD8') | |
17 | 17 | ||
18 | 18 | let WBETLOCKED = 0 | |
19 | 19 | ||
20 | 20 | let ROYALLOCKED = 1 | |
21 | 21 | ||
22 | 22 | let WBETWITHDRAW = 2 | |
23 | 23 | ||
24 | 24 | let ROYALWITHDRAW = 3 | |
25 | 25 | ||
26 | 26 | let WAVESWITHDRAW = 4 | |
27 | 27 | ||
28 | 28 | func IncrementWalletNum () = { | |
29 | 29 | let walletNum = match getInteger(this, WALLETCOUNTERKEY) { | |
30 | 30 | case num: Int => | |
31 | 31 | num | |
32 | 32 | case _ => | |
33 | 33 | 0 | |
34 | 34 | } | |
35 | 35 | (walletNum + 1) | |
36 | 36 | } | |
37 | 37 | ||
38 | 38 | ||
39 | 39 | func ExtractWBETReservedAmt () = match getInteger(this, LOCKEDWBETKEY) { | |
40 | 40 | case a: Int => | |
41 | 41 | a | |
42 | 42 | case _ => | |
43 | 43 | 0 | |
44 | 44 | } | |
45 | 45 | ||
46 | 46 | ||
47 | 47 | func ExtractROYALReservedAmt () = match getInteger(this, LOCKEDROYALKEY) { | |
48 | 48 | case a: Int => | |
49 | 49 | a | |
50 | 50 | case _ => | |
51 | 51 | 0 | |
52 | 52 | } | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | func ExtractFEEReservedAmt () = match getInteger(this, COMMUNITYFEEKEY) { | |
56 | 56 | case a: Int => | |
57 | 57 | a | |
58 | 58 | case _ => | |
59 | 59 | 0 | |
60 | 60 | } | |
61 | 61 | ||
62 | 62 | ||
63 | 63 | func ExtractPlayerAmt (wallet) = match getString(this, wallet) { | |
64 | 64 | case str: String => | |
65 | 65 | str | |
66 | 66 | case _ => | |
67 | 67 | "0_0_0_0_0" | |
68 | 68 | } | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | func WalletExist (wallet) = match getString(this, wallet) { | |
72 | 72 | case str: String => | |
73 | 73 | true | |
74 | 74 | case _ => | |
75 | 75 | false | |
76 | 76 | } | |
77 | 77 | ||
78 | 78 | ||
79 | 79 | func FormatPlayerBalance (wbet,royal,wbetWithdraw,royalWithdraw,wavesWithdraw) = ((((((((toString(wbet) + "_") + toString(royal)) + "_") + toString(wbetWithdraw)) + "_") + toString(royalWithdraw)) + "_") + toString(wavesWithdraw)) | |
80 | 80 | ||
81 | 81 | ||
82 | 82 | func ParsePlayerBalance (wallet) = { | |
83 | 83 | let amounts = split(ExtractPlayerAmt(wallet), "_") | |
84 | 84 | let wbetAmount = parseIntValue(amounts[WBETLOCKED]) | |
85 | 85 | let royalAmount = parseIntValue(amounts[ROYALLOCKED]) | |
86 | 86 | let wbetWithdraw = parseIntValue(amounts[WBETWITHDRAW]) | |
87 | 87 | let royalWithdraw = parseIntValue(amounts[ROYALWITHDRAW]) | |
88 | 88 | let wavesWithdraw = parseIntValue(amounts[WAVESWITHDRAW]) | |
89 | 89 | [wbetAmount, royalAmount, wbetWithdraw, royalWithdraw, wavesWithdraw] | |
90 | 90 | } | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | @Callable(i) | |
94 | - | func lock () = { | |
95 | - | let payment = extract(i.payment) | |
96 | - | if (if ((payment.assetId != WBET)) | |
97 | - | then (payment.assetId != ROYAL) | |
98 | - | else false) | |
99 | - | then throw("The token should be in WBET or ROYAL.") | |
100 | - | else { | |
101 | - | let wallet = toString(i.caller) | |
102 | - | let balance = ParsePlayerBalance(wallet) | |
103 | - | if ((payment.assetId == WBET)) | |
104 | - | then { | |
105 | - | let newWBETReservedAmount = (ExtractWBETReservedAmt() + payment.amount) | |
106 | - | let newPlayerWBETAmount = (balance[WBETLOCKED] + payment.amount) | |
107 | - | if (WalletExist(wallet)) | |
108 | - | then ScriptResult(WriteSet([DataEntry(LOCKEDWBETKEY, newWBETReservedAmount), DataEntry(wallet, FormatPlayerBalance(newPlayerWBETAmount, balance[ROYALLOCKED], balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet(nil)) | |
109 | - | else { | |
110 | - | let newWalletNum = IncrementWalletNum() | |
111 | - | ScriptResult(WriteSet([DataEntry(WALLETCOUNTERKEY, newWalletNum), DataEntry(LOCKEDWBETKEY, newWBETReservedAmount), DataEntry(wallet, FormatPlayerBalance(newPlayerWBETAmount, balance[ROYALLOCKED], balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet(nil)) | |
112 | - | } | |
113 | - | } | |
114 | - | else if ((payment.assetId == ROYAL)) | |
115 | - | then { | |
116 | - | let newROYALReservedAmount = (ExtractROYALReservedAmt() + payment.amount) | |
117 | - | let newPlayerRoyalAmount = (balance[ROYALLOCKED] + payment.amount) | |
118 | - | if (WalletExist(wallet)) | |
119 | - | then ScriptResult(WriteSet([DataEntry(LOCKEDROYALKEY, newROYALReservedAmount), DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], newPlayerRoyalAmount, balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet(nil)) | |
120 | - | else { | |
121 | - | let newWalletNum = IncrementWalletNum() | |
122 | - | ScriptResult(WriteSet([DataEntry(WALLETCOUNTERKEY, newWalletNum), DataEntry(LOCKEDROYALKEY, newROYALReservedAmount), DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], newPlayerRoyalAmount, balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet(nil)) | |
123 | - | } | |
124 | - | } | |
125 | - | else throw("error") | |
126 | - | } | |
127 | - | } | |
128 | - | ||
129 | - | ||
130 | - | ||
131 | - | @Callable(i) | |
132 | - | func unlock (asset) = { | |
133 | - | let wallet = toString(i.caller) | |
134 | - | let balance = ParsePlayerBalance(wallet) | |
135 | - | if ((asset == "WBET")) | |
136 | - | then if ((0 >= balance[WBETLOCKED])) | |
137 | - | then throw("You dont have enough balance to withdraw the amount requested.") | |
138 | - | else { | |
139 | - | let newWBETReservedAmount = (ExtractWBETReservedAmt() - balance[WBETLOCKED]) | |
140 | - | ScriptResult(WriteSet([DataEntry(LOCKEDWBETKEY, newWBETReservedAmount), DataEntry(wallet, FormatPlayerBalance(0, balance[ROYALLOCKED], balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet([ScriptTransfer(i.caller, balance[WBETLOCKED], WBET)])) | |
141 | - | } | |
142 | - | else if ((asset == "ROYAL")) | |
143 | - | then if ((0 >= balance[ROYALLOCKED])) | |
144 | - | then throw("You dont have enough balance to withdraw the amount requested.") | |
145 | - | else { | |
146 | - | let newROYALReservedAmount = (ExtractROYALReservedAmt() - balance[ROYALLOCKED]) | |
147 | - | ScriptResult(WriteSet([DataEntry(LOCKEDROYALKEY, newROYALReservedAmount), DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], 0, balance[WBETWITHDRAW], balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet([ScriptTransfer(i.caller, balance[ROYALLOCKED], ROYAL)])) | |
148 | - | } | |
149 | - | else throw("Invalid asset") | |
150 | - | } | |
151 | - | ||
152 | - | ||
153 | - | ||
154 | - | @Callable(i) | |
155 | - | func withdraw (asset) = { | |
156 | - | let wallet = toString(i.caller) | |
157 | - | let balance = ParsePlayerBalance(wallet) | |
158 | - | if ((asset == "WBET")) | |
159 | - | then if ((0 >= balance[WBETWITHDRAW])) | |
160 | - | then throw("You dont have enough balance to withdraw the amount requested.") | |
161 | - | else ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], 0, balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet([ScriptTransfer(i.caller, balance[WBETWITHDRAW], WBET)])) | |
162 | - | else if ((asset == "ROYAL")) | |
163 | - | then if ((0 >= balance[ROYALWITHDRAW])) | |
164 | - | then throw("You dont have enough balance to withdraw the amount requested.") | |
165 | - | else ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], balance[WBETWITHDRAW], 0, balance[WAVESWITHDRAW]))]), TransferSet([ScriptTransfer(i.caller, balance[ROYALWITHDRAW], ROYAL)])) | |
166 | - | else if ((asset == "WAVES")) | |
167 | - | then if ((0 >= balance[WAVESWITHDRAW])) | |
168 | - | then throw("You dont have enough balance to withdraw the amount requested.") | |
169 | - | else ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], balance[WBETWITHDRAW], balance[WBETWITHDRAW], 0))]), TransferSet([ScriptTransfer(i.caller, balance[WAVESWITHDRAW], unit)])) | |
170 | - | else throw("Invalid asset") | |
171 | - | } | |
172 | - | ||
173 | - | ||
174 | - | ||
175 | - | @Callable(i) | |
176 | - | func addWithdraw (wallet) = if ((i.caller == COMMUNITYWALLET)) | |
177 | - | then { | |
178 | - | let payment = extract(i.payment) | |
179 | - | let balance = ParsePlayerBalance(wallet) | |
180 | - | if ((payment.assetId == WBET)) | |
181 | - | then { | |
182 | - | let newWbetAmount = (balance[WBETWITHDRAW] + payment.amount) | |
183 | - | ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], newWbetAmount, balance[ROYALWITHDRAW], balance[WAVESWITHDRAW]))]), TransferSet(nil)) | |
184 | - | } | |
185 | - | else if ((payment.assetId == ROYAL)) | |
186 | - | then { | |
187 | - | let newRoyalAmount = (balance[ROYALWITHDRAW] + payment.amount) | |
188 | - | ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], balance[WBETWITHDRAW], newRoyalAmount, balance[WAVESWITHDRAW]))]), TransferSet(nil)) | |
189 | - | } | |
190 | - | else if ((payment.assetId == unit)) | |
191 | - | then { | |
192 | - | let newWavesAmount = (balance[WAVESWITHDRAW] + payment.amount) | |
193 | - | ScriptResult(WriteSet([DataEntry(wallet, FormatPlayerBalance(balance[WBETLOCKED], balance[ROYALLOCKED], balance[WBETWITHDRAW], balance[ROYALWITHDRAW], newWavesAmount))]), TransferSet(nil)) | |
194 | - | } | |
195 | - | else throw("Invalid asset") | |
196 | - | } | |
197 | - | else throw("You do not have permission to perform this function.") | |
198 | - | ||
199 | - | ||
200 | - | ||
201 | - | @Callable(i) | |
202 | - | func addCommunityFee () = { | |
203 | - | let payment = extract(i.payment) | |
204 | - | if ((payment.assetId != assetInfo(base58'WAVES'))) | |
205 | - | then throw("Payment should be in WAVES.") | |
206 | - | else { | |
207 | - | let newFEEReservedAmount = (ExtractFEEReservedAmt() + payment.amount) | |
208 | - | ScriptResult(WriteSet([DataEntry(COMMUNITYFEEKEY, newFEEReservedAmount)]), TransferSet(nil)) | |
209 | - | } | |
210 | - | } | |
211 | - | ||
212 | - | ||
213 | - | ||
214 | - | @Callable(i) | |
215 | - | func getCommunityFee (amount) = if ((i.caller == COMMUNITYWALLET)) | |
216 | - | then { | |
217 | - | let payment = extract(i.payment) | |
218 | - | let FEEReservedAmount = ExtractFEEReservedAmt() | |
219 | - | if ((amount > FEEReservedAmount)) | |
220 | - | then throw("You dont have enough balance to transfer the amount requested.") | |
221 | - | else { | |
222 | - | let newFEEReservedAmount = (FEEReservedAmount - amount) | |
223 | - | ScriptResult(WriteSet([DataEntry(COMMUNITYFEEKEY, newFEEReservedAmount)]), TransferSet([ScriptTransfer(COMMUNITYWALLET, amount, unit)])) | |
224 | - | } | |
225 | - | } | |
226 | - | else throw("You do not have permission to perform this function.") | |
94 | + | func fix () = ScriptResult(WriteSet([DataEntry("3N5HPZCbRfvh1NcELNrM13BXo5kT8TLyuyL", "86385250000000000_13079000000_0_4366440102_0"), DataEntry("3N53SCQ3WRxy87DGBQ5CyzmYCoC6c1NU3fm", "11805011400000000_1786000000_754848482101_596735637_0")]), TransferSet(nil)) | |
227 | 95 | ||
228 | 96 |
github/deemru/w8io/026f985 44.45 ms ◑