2022.09.23 16:36 [3307274] smart account 3PDs3ewniAQCp4LfXPMEqb2xRECgtZu2AR5 > SELF 0.00000000 Waves
{ "type": 13, "id": "Au5LMRENii93xiKxWYNfdbUL7hKUQSRuftj4HJfavW2z", "fee": 700000, "feeAssetId": null, "timestamp": 1663940199121, "version": 2, "chainId": 87, "sender": "3PDs3ewniAQCp4LfXPMEqb2xRECgtZu2AR5", "senderPublicKey": "D2oFRSwLr9uimTCnnv7K7DUe1Ahtu17JDmRVCXR9kKV6", "proofs": [ "35HfUzTLS4BdFyKAceTaf4XGFTXSwR8YKitVucthKEkWbx2TgzYAfH2qLi31VVetk6XmGDq19xG4AcPVan5TPrXB" ], "script": "base64:BgIICAISBAoCCAgdAAtrZXlNQWNjUEtleQIJbWFzdGVyX3BrAA1rZXlCYWNrdXBQS2V5AgdiYWNrX3BrAAh3YXJzUEtleQIHd2Fyc19wawEGZ2V0U3RyAQNrZXkEByRtYXRjaDAJAJ0IAgUEdGhpcwUDa2V5AwkAAQIFByRtYXRjaDACBlN0cmluZwQBYgUHJG1hdGNoMAUBYgIAAA5tQWNjUEtleVN0cmluZwkBBmdldFN0cgEFC2tleU1BY2NQS2V5ABBiYWNrdXBQS2V5U3RyaW5nCQEGZ2V0U3RyAQUNa2V5QmFja3VwUEtleQEMZ2V0QmFja3VwS2V5AAMJAAACBRBiYWNrdXBQS2V5U3RyaW5nAgAIBQR0aGlzBWJ5dGVzCQDZBAEFEGJhY2t1cFBLZXlTdHJpbmcACG1BY2NQS2V5CQDZBAEFDm1BY2NQS2V5U3RyaW5nAAhtQWNjQWRkcgkApwgBBQhtQWNjUEtleQAKZmVlUGVyY2VudAkBEUBleHRyTmF0aXZlKDEwNTApAgUIbUFjY0FkZHIJAKwCAgkArAICAgJmXwkApQgBBQR0aGlzAgRfZmVlAA5zdGFraW5nQWRkcmVzcwkBEUBleHRyTmF0aXZlKDEwNjIpAQkBE3ZhbHVlT3JFcnJvck1lc3NhZ2UCCQCdCAIFCG1BY2NBZGRyCQCsAgIJAKwCAgICZl8JAKUIAQUEdGhpcwIOX3N0YWtlX2FkZHJlc3MJAKwCAgkArAICAgJmXwkApQgBBQR0aGlzAhpfc3Rha2VfYWRkcmVzcyBub3QgZGVmaW5lZAAId0FjY1BLZXkJANkEAQkBE3ZhbHVlT3JFcnJvck1lc3NhZ2UCCQCdCAIFCG1BY2NBZGRyBQh3YXJzUEtleQkArAICBQh3YXJzUEtleQIMIG5vdCBkZWZpbmVkAA9rVG90YWxMaXF1aWRpdHkCD3RvdGFsX2xpcXVpZGl0eQAMa0luaXRpYWxpemVkAgtJTklUSUFMSVpFRAATa0xpcXVpZGl0eVRocmVzaG9sZAITTElRVUlESVRZX1RIUkVTSE9MRAATa1RvdGFsRmFybWluZ1Jld2FyZAIUdG90YWxfZmFybWluZ19yZXdhcmQADWtTaGFyZUFzc2V0SWQCDlNIQVJFX0FTU0VUX0lEAA5rSW5jdWJhdG9yRGFwcAIOSU5DVUJBVE9SX0RBUFAADGtCcmVlZGVyRGFwcAIMQlJFRURFUl9EQVBQAAxrRmFybWluZ0RhcHACDEZBUk1JTkdfREFQUAAQa01hcmtldFByb3h5RGFwcAIWTUFSS0VUUExBQ0VfUFJPWFlfREFQUAAMa0F1Y3Rpb25EYXBwAgxBVUNUSU9OX0RBUFAAB2tMb2NrZWQCBkxPQ0tFRAAQa0Nlb0NvbGxlY3RlZEZlZQIRY2VvX2NvbGxlY3RlZF9mZWUAF2tDZW9Db2xsZWN0ZWRGZWVPdmVyYWxsAg9jZW9fZmVlX292ZXJhbGwAEmtMb2NrZWRJbnZlc3RtZW50cwISbG9ja2VkX2ludmVzdG1lbnRzABBrZXlUb3RhbENvbXBvdW5kAg50b3RhbF9jb21wb3VuZAAPa2V5R2xvYmFsU3Rha2VkAg1nbG9iYWxfc3Rha2VkAQdnZXRTdHJBAgFhAWsEByRtYXRjaDAJAJ0IAgUBYQUBawMJAAECBQckbWF0Y2gwAgZTdHJpbmcEAWIFByRtYXRjaDAFAWICAAEBaQEQY2FsbFVuc3Rha2VQcm94eQIIZnVuY3Rpb24DaWRzAwMJAQIhPQIFCGZ1bmN0aW9uAgp1bnN0YWtlTkZUCQECIT0CBQhmdW5jdGlvbgIOdW5zdGFrZUphY2twb3QHCQACAQIRQmFkIGZ1bmN0aW9uIG5hbWUDCQECIT0CCAUBaQZjYWxsZXIFBHRoaXMJAAIBAiFDYW4gYmUgY2FsbGVkIG9ubHkgYnkgdGhlIGFjY291bnQEEmZhcm1pbmdEYXBwQWRkcmVzcwkBEUBleHRyTmF0aXZlKDEwNjIpAQkBB2dldFN0ckECBQhtQWNjQWRkcgIMRkFSTUlOR19EQVBQCgELdW5zdGFrZUR1Y2sCBWFjY3VtBW5mdElkBAZpbnZSZXMJAPwHBAUSZmFybWluZ0RhcHBBZGRyZXNzBQhmdW5jdGlvbgkAzAgCBQVuZnRJZAUDbmlsBQNuaWwDCQAAAgUGaW52UmVzBQZpbnZSZXMFA25pbAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgQGbmZ0SWRzCQC1CQIFA2lkcwIBOwQKZm9sZFJlc3VsdAoAAiRsBQZuZnRJZHMKAAIkcwkAkAMBBQIkbAoABSRhY2MwAAAKAQUkZjBfMQICJGECJGkDCQBnAgUCJGkFAiRzBQIkYQkBC3Vuc3Rha2VEdWNrAgUCJGEJAJEDAgUCJGwFAiRpCgEFJGYwXzICAiRhAiRpAwkAZwIFAiRpBQIkcwUCJGEJAAIBAhRMaXN0IHNpemUgZXhjZWVkcyAxMAkBBSRmMF8yAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgkBBSRmMF8xAgUFJGFjYzAAAAABAAIAAwAEAAUABgAHAAgACQAKBQNuaWwBAnR4AQZ2ZXJpZnkACQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAABQhtQWNjUEtlecx4Qx4=", "height": 3307274, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7i4ZtaznLPTaEhq6xF1jPQTfHi1gSVVGb7Bm6TugXocG Next: DZ12KbuPvjd9dmXQJ9iNZu24sepNTtceNV3hSi7wzVvF Diff:
Old | New | Differences | |
---|---|---|---|
66 | 66 | ||
67 | 67 | let keyGlobalStaked = "global_staked" | |
68 | 68 | ||
69 | - | func getInt (key) = match getInteger(this, key) { | |
70 | - | case b: Int => | |
71 | - | b | |
72 | - | case _ => | |
73 | - | 0 | |
74 | - | } | |
75 | - | ||
76 | - | ||
77 | - | func getBool (key) = match getBoolean(this, key) { | |
78 | - | case b: Boolean => | |
79 | - | b | |
80 | - | case _ => | |
81 | - | unit | |
82 | - | } | |
83 | - | ||
84 | - | ||
85 | 69 | func getStrA (a,k) = match getString(a, k) { | |
86 | 70 | case b: String => | |
87 | 71 | b | |
90 | 74 | } | |
91 | 75 | ||
92 | 76 | ||
93 | - | func tryGetBoolean (a,key) = match getBoolean(a, key) { | |
94 | - | case b: Boolean => | |
95 | - | b | |
96 | - | case _ => | |
97 | - | false | |
98 | - | } | |
99 | - | ||
100 | - | ||
101 | - | func getIntA (address,key) = match getInteger(address, key) { | |
102 | - | case b: Int => | |
103 | - | b | |
104 | - | case _ => | |
105 | - | 0 | |
106 | - | } | |
107 | - | ||
108 | - | ||
109 | - | func getVoteHeightKey () = "VOTE_HEIGHT_START" | |
110 | - | ||
111 | - | ||
112 | - | func resultVoteKey (height) = ("LIQUIDATED_" + height) | |
113 | - | ||
114 | - | ||
115 | - | func isLiquidated () = { | |
116 | - | let voteHeight = getIntA(stakingAddress, getVoteHeightKey()) | |
117 | - | if ((voteHeight == 0)) | |
118 | - | then false | |
119 | - | else tryGetBoolean(stakingAddress, resultVoteKey(toString(voteHeight))) | |
120 | - | } | |
121 | - | ||
122 | - | ||
123 | - | func getMarketProxyAddr () = getStrA(mAccAddr, kMarketProxyDapp) | |
124 | - | ||
125 | - | ||
126 | - | func getEggId () = fromBase58String(getStringValue(mAccAddr, "EGG_ASSET_ID")) | |
127 | - | ||
128 | - | ||
129 | - | func getShareAssetId () = fromBase58String(getStr(kShareAssetId)) | |
130 | - | ||
131 | - | ||
132 | - | func asInt (value) = match value { | |
133 | - | case int: Int => | |
134 | - | int | |
135 | - | case _ => | |
136 | - | throw("wrong type, expected: Int") | |
137 | - | } | |
138 | - | ||
139 | - | ||
140 | 77 | @Callable(i) | |
141 | - | func initMasterKey (publicKey) = if ((i.caller != this)) | |
142 | - | then throw("You cannot do this action") | |
143 | - | else if ((mAccPKeyString != "")) | |
144 | - | then throw("Master public key already set, you can't override!") | |
145 | - | else [StringEntry(keyMAccPKey, publicKey)] | |
146 | - | ||
147 | - | ||
148 | - | ||
149 | - | @Callable(i) | |
150 | - | func initBackupKey (publicKey) = if ((i.caller != addressFromPublicKey(mAccPKey))) | |
151 | - | then throw("You cannot do this action") | |
152 | - | else [StringEntry(keyBackupPKey, publicKey)] | |
153 | - | ||
154 | - | ||
155 | - | ||
156 | - | @Callable(i) | |
157 | - | func initCollectiveFarm (name,minimumThreshold,migration,totalFarmingReward,totalLiquidity,totalFarmToken) = if ((mAccPKeyString == "")) | |
158 | - | then throw("First initiatie a master public key!") | |
159 | - | else if ((i.callerPublicKey != mAccPKey)) | |
160 | - | then throw("_1") | |
161 | - | else if ((getBool(kInitialized) != unit)) | |
162 | - | then throw("_2") | |
163 | - | else if (if ((migration == false)) | |
164 | - | then if ((i.payments[0].amount != 10000000)) | |
165 | - | then true | |
166 | - | else (i.payments[0].assetId != getEggId()) | |
167 | - | else false) | |
168 | - | then throw("_20") | |
169 | - | else { | |
170 | - | let shareTokens = if (migration) | |
171 | - | then totalFarmToken | |
172 | - | else 10000000 | |
173 | - | let shareToken = Issue(name, (("Team token for the \"" + name) + "\" collective farm"), shareTokens, 8, true) | |
174 | - | let totLiquidity = if (migration) | |
175 | - | then totalLiquidity | |
176 | - | else 10000000 | |
177 | - | let totFarmingReward = if (migration) | |
178 | - | then [IntegerEntry(kTotalFarmingReward, totalFarmingReward)] | |
179 | - | else nil | |
180 | - | ([StringEntry(kShareAssetId, toBase58String(calculateAssetId(shareToken))), BooleanEntry(kInitialized, true), IntegerEntry(kTotalLiquidity, totLiquidity), shareToken, ScriptTransfer(i.caller, shareTokens, calculateAssetId(shareToken)), BooleanEntry(kLocked, false), IntegerEntry(kLiquidityThreshold, minimumThreshold)] ++ totFarmingReward) | |
181 | - | } | |
182 | - | ||
183 | - | ||
184 | - | ||
185 | - | @Callable(i) | |
186 | - | func setLock (s) = if ((i.callerPublicKey != mAccPKey)) | |
187 | - | then throw("_21") | |
188 | - | else [BooleanEntry(kLocked, s)] | |
189 | - | ||
190 | - | ||
191 | - | ||
192 | - | @Callable(i) | |
193 | - | func lockInvestments () = if ((i.caller != this)) | |
194 | - | then throw("You cannot lock this contract") | |
195 | - | else [BooleanEntry(kLockedInvestments, true)] | |
196 | - | ||
197 | - | ||
198 | - | ||
199 | - | @Callable(i) | |
200 | - | func unlockInvestments () = if ((i.caller != this)) | |
201 | - | then throw("You cannot lock this contract") | |
202 | - | else [BooleanEntry(kLockedInvestments, false)] | |
203 | - | ||
204 | - | ||
205 | - | ||
206 | - | @Callable(i) | |
207 | - | func provideLiquidity () = if (isLiquidated()) | |
208 | - | then throw("CPL: CF is liquidated!") | |
209 | - | else { | |
210 | - | let eggAssetId = getEggId() | |
211 | - | if (if (if ((i.callerPublicKey != wAccPKey)) | |
212 | - | then (i.callerPublicKey != mAccPKey) | |
213 | - | else false) | |
214 | - | then (getBool(kLockedInvestments) == true) | |
215 | - | else false) | |
216 | - | then throw("Contract is locked for investments by it's CEO. Please invest in another collective farm.") | |
217 | - | else if ((getBool(kLocked) == true)) | |
218 | - | then throw("_22") | |
219 | - | else if ((i.payments[0].assetId != eggAssetId)) | |
220 | - | then throw("_4") | |
221 | - | else if ((1000000 > i.payments[0].amount)) | |
222 | - | then throw("Min amount to invest is 0.01 EGG") | |
223 | - | else { | |
224 | - | let totalLiquidity = getInt(kTotalLiquidity) | |
225 | - | let shareTokensToGive = i.payments[0].amount | |
226 | - | let shareTokensId = fromBase58String(getStr(kShareAssetId)) | |
227 | - | let reissue = Reissue(getShareAssetId(), shareTokensToGive, true) | |
228 | - | let kParticipated = (("account_" + toString(i.caller)) + "_participated") | |
229 | - | let alreadyParticipated = getBool(kParticipated) | |
230 | - | $Tuple2([reissue, ScriptTransfer(i.caller, shareTokensToGive, shareTokensId), IntegerEntry(kTotalLiquidity, (totalLiquidity + value(i.payments[0].amount))), BooleanEntry(kParticipated, true)], shareTokensToGive) | |
231 | - | } | |
232 | - | } | |
233 | - | ||
234 | - | ||
235 | - | ||
236 | - | @Callable(i) | |
237 | - | func claimFarmingRewardProxy (ids) = if (isLiquidated()) | |
238 | - | then throw("CCFRP: CF is liquidated!") | |
239 | - | else if ((i.callerPublicKey != mAccPKey)) | |
240 | - | then throw("_23") | |
78 | + | func callUnstakeProxy (function,ids) = if (if ((function != "unstakeNFT")) | |
79 | + | then (function != "unstakeJackpot") | |
80 | + | else false) | |
81 | + | then throw("Bad function name") | |
82 | + | else if ((i.caller != this)) | |
83 | + | then throw("Can be called only by the account") | |
241 | 84 | else { | |
242 | - | let eggAssetId = getEggId() | |
243 | - | let shareAssetId = getShareAssetId() | |
244 | - | let farmingDapp = addressFromStringValue(getStrA(mAccAddr, kFarmingDapp)) | |
245 | - | func claimReward (accum,nftId) = { | |
246 | - | let invRes = invoke(farmingDapp, "claimReward", [nftId], nil) | |
85 | + | let farmingDappAddress = addressFromStringValue(getStrA(mAccAddr, "FARMING_DAPP")) | |
86 | + | func unstakeDuck (accum,nftId) = { | |
87 | + | let invRes = invoke(farmingDappAddress, function, [nftId], nil) | |
247 | 88 | if ((invRes == invRes)) | |
248 | - | then match invRes { | |
249 | - | case int: Int => | |
250 | - | (accum + int) | |
251 | - | case _ => | |
252 | - | throw("_5") | |
253 | - | } | |
89 | + | then nil | |
254 | 90 | else throw("Strict value is not equal to itself.") | |
255 | 91 | } | |
256 | 92 | ||
261 | 97 | let $acc0 = 0 | |
262 | 98 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
263 | 99 | then $a | |
264 | - | else | |
100 | + | else unstakeDuck($a, $l[$i]) | |
265 | 101 | ||
266 | 102 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
267 | 103 | then $a | |
269 | 105 | ||
270 | 106 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
271 | 107 | } | |
272 | - | let claimedReward = match foldResult { | |
273 | - | case int: Int => | |
274 | - | int | |
275 | - | case _ => | |
276 | - | throw("_6") | |
277 | - | } | |
278 | - | let totalFarmingReward = getInt(kTotalFarmingReward) | |
279 | - | let farmCeoFeeSize = fraction(claimedReward, feePercent, 100) | |
280 | - | let currentCeoFee = getInt(kCeoCollectedFee) | |
281 | - | let ceoFeeOverall = getInt(kCeoCollectedFeeOverall) | |
282 | - | let amountToPay = (claimedReward - farmCeoFeeSize) | |
283 | - | let topUp = invoke(stakingAddress, "topUpReward", nil, [AttachedPayment(eggAssetId, amountToPay)]) | |
284 | - | if ((topUp == topUp)) | |
285 | - | then [IntegerEntry(kTotalFarmingReward, (totalFarmingReward + amountToPay)), IntegerEntry(kCeoCollectedFee, (currentCeoFee + farmCeoFeeSize)), IntegerEntry(kCeoCollectedFeeOverall, (ceoFeeOverall + farmCeoFeeSize))] | |
286 | - | else throw("Strict value is not equal to itself.") | |
108 | + | nil | |
287 | 109 | } | |
288 | 110 | ||
289 | 111 | ||
290 | - | ||
291 | - | @Callable(i) | |
292 | - | func claimCeoFee (address1,address2,address1Share,address2Share) = if (isLiquidated()) | |
293 | - | then throw("CCCF: CF is liquidated!") | |
294 | - | else if ((0 > address1Share)) | |
295 | - | then throw("Share 1 can't be negative") | |
296 | - | else if ((0 > address2Share)) | |
297 | - | then throw("Share 2 can't be negative") | |
298 | - | else if (((address1Share + address2Share) != 100)) | |
299 | - | then throw("Sum of shares should be 100") | |
300 | - | else if ((getBool(kLocked) == true)) | |
301 | - | then throw("_22") | |
302 | - | else if ((i.caller == this)) | |
303 | - | then { | |
304 | - | let currentCeoCollectedFee = getInt(kCeoCollectedFee) | |
305 | - | let address1Reward = if ((address2 == "")) | |
306 | - | then currentCeoCollectedFee | |
307 | - | else fraction(currentCeoCollectedFee, address1Share, 100) | |
308 | - | let address2Reward = if ((address2 == "")) | |
309 | - | then 0 | |
310 | - | else fraction(currentCeoCollectedFee, address2Share, 100) | |
311 | - | let scriptTransferAddress2 = if ((address2 == "")) | |
312 | - | then nil | |
313 | - | else [ScriptTransfer(addressFromStringValue(address2), address2Reward, getEggId())] | |
314 | - | (scriptTransferAddress2 ++ [ScriptTransfer(addressFromStringValue(address1), address1Reward, getEggId()), IntegerEntry(kCeoCollectedFee, 0)]) | |
315 | - | } | |
316 | - | else throw("Only manager can call the contract") | |
317 | - | ||
318 | - | ||
319 | - | ||
320 | - | @Callable(i) | |
321 | - | func callUnstakeProxy (function,assetId) = if (isLiquidated()) | |
322 | - | then throw("CCUP: CF is liquidated!") | |
323 | - | else if ((getBool(kLocked) == true)) | |
324 | - | then throw("Contract is locked now") | |
325 | - | else if (if ((function != "unstakeNFT")) | |
326 | - | then (function != "unstakeJackpot") | |
327 | - | else false) | |
328 | - | then throw("Bad function name") | |
329 | - | else if ((i.caller != this)) | |
330 | - | then throw("Can be called only by the account") | |
331 | - | else { | |
332 | - | let eggAssetId = getEggId() | |
333 | - | let shareAssetId = getShareAssetId() | |
334 | - | let farmingDappAddress = addressFromStringValue(getStrA(mAccAddr, "FARMING_DAPP")) | |
335 | - | let unstakedReward = invoke(farmingDappAddress, function, [assetId], nil) | |
336 | - | if ((unstakedReward == unstakedReward)) | |
337 | - | then { | |
338 | - | let reward = match unstakedReward { | |
339 | - | case int: Int => | |
340 | - | int | |
341 | - | case _ => | |
342 | - | throw("Error during unstaking") | |
343 | - | } | |
344 | - | let currentCeoFee = getInt(kCeoCollectedFee) | |
345 | - | let ceoFeeOverall = getInt(kCeoCollectedFeeOverall) | |
346 | - | let farmCeoFeeSize = fraction(reward, feePercent, 100) | |
347 | - | let amountToPay = (reward - farmCeoFeeSize) | |
348 | - | let topUp = invoke(stakingAddress, "topUpReward", nil, [AttachedPayment(eggAssetId, amountToPay)]) | |
349 | - | if ((topUp == topUp)) | |
350 | - | then [IntegerEntry(kCeoCollectedFee, (currentCeoFee + farmCeoFeeSize)), IntegerEntry(kCeoCollectedFeeOverall, (ceoFeeOverall + farmCeoFeeSize))] | |
351 | - | else throw("Strict value is not equal to itself.") | |
352 | - | } | |
353 | - | else throw("Strict value is not equal to itself.") | |
354 | - | } | |
355 | - | ||
356 | - | ||
357 | 112 | @Verifier(tx) | |
358 | - | func verify () = { | |
359 | - | let checkStarted = (getInt(kTotalLiquidity) >= getInt(kLiquidityThreshold)) | |
360 | - | match tx { | |
361 | - | case inv: InvokeScriptTransaction => | |
362 | - | let acceptedCallsStaking = ["stakeFarmTokens", "claimReward", "withdrawFarmTokens"] | |
363 | - | let acceptedCallsThis = ["callUnstakeProxy", "claimCeoFee", "lockInvestments", "unlockInvestments"] | |
364 | - | if (if ((inv.function == "unstakeNFT")) | |
365 | - | then true | |
366 | - | else (inv.function == "unstakeJackpot")) | |
367 | - | then throw("You cannot call these functions directly") | |
368 | - | else if (if (if ((addressFromRecipient(inv.dApp) == this)) | |
369 | - | then (inv.function == "initMasterKey") | |
370 | - | else false) | |
371 | - | then (mAccPKeyString == "") | |
372 | - | else false) | |
373 | - | then if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
374 | - | then true | |
375 | - | else sigVerify(tx.bodyBytes, tx.proofs[0], getBackupKey()) | |
376 | - | else if (if ((sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) == false)) | |
377 | - | then (sigVerify(tx.bodyBytes, tx.proofs[0], getBackupKey()) == false) | |
378 | - | else false) | |
379 | - | then throw("_100") | |
380 | - | else if ((checkStarted == false)) | |
381 | - | then throw("_14") | |
382 | - | else if ((getBool(kLocked) == true)) | |
383 | - | then throw("_22") | |
384 | - | else if (if ((inv.fee > 900000)) | |
385 | - | then true | |
386 | - | else (inv.feeAssetId != unit)) | |
387 | - | then throw("_15") | |
388 | - | else if ((size(inv.payments) > 3)) | |
389 | - | then throw("_17") | |
390 | - | else if (if ((addressFromRecipient(inv.dApp) == this)) | |
391 | - | then containsElement(acceptedCallsThis, inv.function) | |
392 | - | else false) | |
393 | - | then if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
394 | - | then true | |
395 | - | else sigVerify(tx.bodyBytes, tx.proofs[0], getBackupKey()) | |
396 | - | else if (if ((addressFromRecipient(inv.dApp) == addressFromStringValue(getMarketProxyAddr()))) | |
397 | - | then (inv.function == "callMarketplaceProxy") | |
398 | - | else false) | |
399 | - | then if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
400 | - | then true | |
401 | - | else sigVerify(tx.bodyBytes, tx.proofs[0], getBackupKey()) | |
402 | - | else if (if ((addressFromRecipient(inv.dApp) == stakingAddress)) | |
403 | - | then containsElement(acceptedCallsStaking, inv.function) | |
404 | - | else false) | |
405 | - | then if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
406 | - | then true | |
407 | - | else sigVerify(tx.bodyBytes, tx.proofs[0], getBackupKey()) | |
408 | - | else { | |
409 | - | let allowedContracts = getStrA(mAccAddr, "allowed_contracts") | |
410 | - | let allowedContractsList = split(allowedContracts, ";") | |
411 | - | let dappToCall = toString(addressFromRecipient(inv.dApp)) | |
412 | - | (indexOf(allowedContractsList, dappToCall) != unit) | |
413 | - | } | |
414 | - | case ss: SetScriptTransaction => | |
415 | - | sigVerify(tx.bodyBytes, tx.proofs[0], mAccPKey) | |
416 | - | case mt: MassTransferTransaction => | |
417 | - | sigVerify(tx.bodyBytes, tx.proofs[0], mAccPKey) | |
418 | - | case _ => | |
419 | - | false | |
420 | - | } | |
421 | - | } | |
113 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], mAccPKey) | |
422 | 114 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let keyMAccPKey = "master_pk" | |
5 | 5 | ||
6 | 6 | let keyBackupPKey = "back_pk" | |
7 | 7 | ||
8 | 8 | let warsPKey = "wars_pk" | |
9 | 9 | ||
10 | 10 | func getStr (key) = match getString(this, key) { | |
11 | 11 | case b: String => | |
12 | 12 | b | |
13 | 13 | case _ => | |
14 | 14 | "" | |
15 | 15 | } | |
16 | 16 | ||
17 | 17 | ||
18 | 18 | let mAccPKeyString = getStr(keyMAccPKey) | |
19 | 19 | ||
20 | 20 | let backupPKeyString = getStr(keyBackupPKey) | |
21 | 21 | ||
22 | 22 | func getBackupKey () = if ((backupPKeyString == "")) | |
23 | 23 | then this.bytes | |
24 | 24 | else fromBase58String(backupPKeyString) | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | let mAccPKey = fromBase58String(mAccPKeyString) | |
28 | 28 | ||
29 | 29 | let mAccAddr = addressFromPublicKey(mAccPKey) | |
30 | 30 | ||
31 | 31 | let feePercent = getIntegerValue(mAccAddr, (("f_" + toString(this)) + "_fee")) | |
32 | 32 | ||
33 | 33 | let stakingAddress = addressFromStringValue(valueOrErrorMessage(getString(mAccAddr, (("f_" + toString(this)) + "_stake_address")), (("f_" + toString(this)) + "_stake_address not defined"))) | |
34 | 34 | ||
35 | 35 | let wAccPKey = fromBase58String(valueOrErrorMessage(getString(mAccAddr, warsPKey), (warsPKey + " not defined"))) | |
36 | 36 | ||
37 | 37 | let kTotalLiquidity = "total_liquidity" | |
38 | 38 | ||
39 | 39 | let kInitialized = "INITIALIZED" | |
40 | 40 | ||
41 | 41 | let kLiquidityThreshold = "LIQUIDITY_THRESHOLD" | |
42 | 42 | ||
43 | 43 | let kTotalFarmingReward = "total_farming_reward" | |
44 | 44 | ||
45 | 45 | let kShareAssetId = "SHARE_ASSET_ID" | |
46 | 46 | ||
47 | 47 | let kIncubatorDapp = "INCUBATOR_DAPP" | |
48 | 48 | ||
49 | 49 | let kBreederDapp = "BREEDER_DAPP" | |
50 | 50 | ||
51 | 51 | let kFarmingDapp = "FARMING_DAPP" | |
52 | 52 | ||
53 | 53 | let kMarketProxyDapp = "MARKETPLACE_PROXY_DAPP" | |
54 | 54 | ||
55 | 55 | let kAuctionDapp = "AUCTION_DAPP" | |
56 | 56 | ||
57 | 57 | let kLocked = "LOCKED" | |
58 | 58 | ||
59 | 59 | let kCeoCollectedFee = "ceo_collected_fee" | |
60 | 60 | ||
61 | 61 | let kCeoCollectedFeeOverall = "ceo_fee_overall" | |
62 | 62 | ||
63 | 63 | let kLockedInvestments = "locked_investments" | |
64 | 64 | ||
65 | 65 | let keyTotalCompound = "total_compound" | |
66 | 66 | ||
67 | 67 | let keyGlobalStaked = "global_staked" | |
68 | 68 | ||
69 | - | func getInt (key) = match getInteger(this, key) { | |
70 | - | case b: Int => | |
71 | - | b | |
72 | - | case _ => | |
73 | - | 0 | |
74 | - | } | |
75 | - | ||
76 | - | ||
77 | - | func getBool (key) = match getBoolean(this, key) { | |
78 | - | case b: Boolean => | |
79 | - | b | |
80 | - | case _ => | |
81 | - | unit | |
82 | - | } | |
83 | - | ||
84 | - | ||
85 | 69 | func getStrA (a,k) = match getString(a, k) { | |
86 | 70 | case b: String => | |
87 | 71 | b | |
88 | 72 | case _ => | |
89 | 73 | "" | |
90 | 74 | } | |
91 | 75 | ||
92 | 76 | ||
93 | - | func tryGetBoolean (a,key) = match getBoolean(a, key) { | |
94 | - | case b: Boolean => | |
95 | - | b | |
96 | - | case _ => | |
97 | - | false | |
98 | - | } | |
99 | - | ||
100 | - | ||
101 | - | func getIntA (address,key) = match getInteger(address, key) { | |
102 | - | case b: Int => | |
103 | - | b | |
104 | - | case _ => | |
105 | - | 0 | |
106 | - | } | |
107 | - | ||
108 | - | ||
109 | - | func getVoteHeightKey () = "VOTE_HEIGHT_START" | |
110 | - | ||
111 | - | ||
112 | - | func resultVoteKey (height) = ("LIQUIDATED_" + height) | |
113 | - | ||
114 | - | ||
115 | - | func isLiquidated () = { | |
116 | - | let voteHeight = getIntA(stakingAddress, getVoteHeightKey()) | |
117 | - | if ((voteHeight == 0)) | |
118 | - | then false | |
119 | - | else tryGetBoolean(stakingAddress, resultVoteKey(toString(voteHeight))) | |
120 | - | } | |
121 | - | ||
122 | - | ||
123 | - | func getMarketProxyAddr () = getStrA(mAccAddr, kMarketProxyDapp) | |
124 | - | ||
125 | - | ||
126 | - | func getEggId () = fromBase58String(getStringValue(mAccAddr, "EGG_ASSET_ID")) | |
127 | - | ||
128 | - | ||
129 | - | func getShareAssetId () = fromBase58String(getStr(kShareAssetId)) | |
130 | - | ||
131 | - | ||
132 | - | func asInt (value) = match value { | |
133 | - | case int: Int => | |
134 | - | int | |
135 | - | case _ => | |
136 | - | throw("wrong type, expected: Int") | |
137 | - | } | |
138 | - | ||
139 | - | ||
140 | 77 | @Callable(i) | |
141 | - | func initMasterKey (publicKey) = if ((i.caller != this)) | |
142 | - | then throw("You cannot do this action") | |
143 | - | else if ((mAccPKeyString != "")) | |
144 | - | then throw("Master public key already set, you can't override!") | |
145 | - | else [StringEntry(keyMAccPKey, publicKey)] | |
146 | - | ||
147 | - | ||
148 | - | ||
149 | - | @Callable(i) | |
150 | - | func initBackupKey (publicKey) = if ((i.caller != addressFromPublicKey(mAccPKey))) | |
151 | - | then throw("You cannot do this action") | |
152 | - | else [StringEntry(keyBackupPKey, publicKey)] | |
153 | - | ||
154 | - | ||
155 | - | ||
156 | - | @Callable(i) | |
157 | - | func initCollectiveFarm (name,minimumThreshold,migration,totalFarmingReward,totalLiquidity,totalFarmToken) = if ((mAccPKeyString == "")) | |
158 | - | then throw("First initiatie a master public key!") | |
159 | - | else if ((i.callerPublicKey != mAccPKey)) | |
160 | - | then throw("_1") | |
161 | - | else if ((getBool(kInitialized) != unit)) | |
162 | - | then throw("_2") | |
163 | - | else if (if ((migration == false)) | |
164 | - | then if ((i.payments[0].amount != 10000000)) | |
165 | - | then true | |
166 | - | else (i.payments[0].assetId != getEggId()) | |
167 | - | else false) | |
168 | - | then throw("_20") | |
169 | - | else { | |
170 | - | let shareTokens = if (migration) | |
171 | - | then totalFarmToken | |
172 | - | else 10000000 | |
173 | - | let shareToken = Issue(name, (("Team token for the \"" + name) + "\" collective farm"), shareTokens, 8, true) | |
174 | - | let totLiquidity = if (migration) | |
175 | - | then totalLiquidity | |
176 | - | else 10000000 | |
177 | - | let totFarmingReward = if (migration) | |
178 | - | then [IntegerEntry(kTotalFarmingReward, totalFarmingReward)] | |
179 | - | else nil | |
180 | - | ([StringEntry(kShareAssetId, toBase58String(calculateAssetId(shareToken))), BooleanEntry(kInitialized, true), IntegerEntry(kTotalLiquidity, totLiquidity), shareToken, ScriptTransfer(i.caller, shareTokens, calculateAssetId(shareToken)), BooleanEntry(kLocked, false), IntegerEntry(kLiquidityThreshold, minimumThreshold)] ++ totFarmingReward) | |
181 | - | } | |
182 | - | ||
183 | - | ||
184 | - | ||
185 | - | @Callable(i) | |
186 | - | func setLock (s) = if ((i.callerPublicKey != mAccPKey)) | |
187 | - | then throw("_21") | |
188 | - | else [BooleanEntry(kLocked, s)] | |
189 | - | ||
190 | - | ||
191 | - | ||
192 | - | @Callable(i) | |
193 | - | func lockInvestments () = if ((i.caller != this)) | |
194 | - | then throw("You cannot lock this contract") | |
195 | - | else [BooleanEntry(kLockedInvestments, true)] | |
196 | - | ||
197 | - | ||
198 | - | ||
199 | - | @Callable(i) | |
200 | - | func unlockInvestments () = if ((i.caller != this)) | |
201 | - | then throw("You cannot lock this contract") | |
202 | - | else [BooleanEntry(kLockedInvestments, false)] | |
203 | - | ||
204 | - | ||
205 | - | ||
206 | - | @Callable(i) | |
207 | - | func provideLiquidity () = if (isLiquidated()) | |
208 | - | then throw("CPL: CF is liquidated!") | |
209 | - | else { | |
210 | - | let eggAssetId = getEggId() | |
211 | - | if (if (if ((i.callerPublicKey != wAccPKey)) | |
212 | - | then (i.callerPublicKey != mAccPKey) | |
213 | - | else false) | |
214 | - | then (getBool(kLockedInvestments) == true) | |
215 | - | else false) | |
216 | - | then throw("Contract is locked for investments by it's CEO. Please invest in another collective farm.") | |
217 | - | else if ((getBool(kLocked) == true)) | |
218 | - | then throw("_22") | |
219 | - | else if ((i.payments[0].assetId != eggAssetId)) | |
220 | - | then throw("_4") | |
221 | - | else if ((1000000 > i.payments[0].amount)) | |
222 | - | then throw("Min amount to invest is 0.01 EGG") | |
223 | - | else { | |
224 | - | let totalLiquidity = getInt(kTotalLiquidity) | |
225 | - | let shareTokensToGive = i.payments[0].amount | |
226 | - | let shareTokensId = fromBase58String(getStr(kShareAssetId)) | |
227 | - | let reissue = Reissue(getShareAssetId(), shareTokensToGive, true) | |
228 | - | let kParticipated = (("account_" + toString(i.caller)) + "_participated") | |
229 | - | let alreadyParticipated = getBool(kParticipated) | |
230 | - | $Tuple2([reissue, ScriptTransfer(i.caller, shareTokensToGive, shareTokensId), IntegerEntry(kTotalLiquidity, (totalLiquidity + value(i.payments[0].amount))), BooleanEntry(kParticipated, true)], shareTokensToGive) | |
231 | - | } | |
232 | - | } | |
233 | - | ||
234 | - | ||
235 | - | ||
236 | - | @Callable(i) | |
237 | - | func claimFarmingRewardProxy (ids) = if (isLiquidated()) | |
238 | - | then throw("CCFRP: CF is liquidated!") | |
239 | - | else if ((i.callerPublicKey != mAccPKey)) | |
240 | - | then throw("_23") | |
78 | + | func callUnstakeProxy (function,ids) = if (if ((function != "unstakeNFT")) | |
79 | + | then (function != "unstakeJackpot") | |
80 | + | else false) | |
81 | + | then throw("Bad function name") | |
82 | + | else if ((i.caller != this)) | |
83 | + | then throw("Can be called only by the account") | |
241 | 84 | else { | |
242 | - | let eggAssetId = getEggId() | |
243 | - | let shareAssetId = getShareAssetId() | |
244 | - | let farmingDapp = addressFromStringValue(getStrA(mAccAddr, kFarmingDapp)) | |
245 | - | func claimReward (accum,nftId) = { | |
246 | - | let invRes = invoke(farmingDapp, "claimReward", [nftId], nil) | |
85 | + | let farmingDappAddress = addressFromStringValue(getStrA(mAccAddr, "FARMING_DAPP")) | |
86 | + | func unstakeDuck (accum,nftId) = { | |
87 | + | let invRes = invoke(farmingDappAddress, function, [nftId], nil) | |
247 | 88 | if ((invRes == invRes)) | |
248 | - | then match invRes { | |
249 | - | case int: Int => | |
250 | - | (accum + int) | |
251 | - | case _ => | |
252 | - | throw("_5") | |
253 | - | } | |
89 | + | then nil | |
254 | 90 | else throw("Strict value is not equal to itself.") | |
255 | 91 | } | |
256 | 92 | ||
257 | 93 | let nftIds = split(ids, ";") | |
258 | 94 | let foldResult = { | |
259 | 95 | let $l = nftIds | |
260 | 96 | let $s = size($l) | |
261 | 97 | let $acc0 = 0 | |
262 | 98 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
263 | 99 | then $a | |
264 | - | else | |
100 | + | else unstakeDuck($a, $l[$i]) | |
265 | 101 | ||
266 | 102 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
267 | 103 | then $a | |
268 | 104 | else throw("List size exceeds 10") | |
269 | 105 | ||
270 | 106 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
271 | 107 | } | |
272 | - | let claimedReward = match foldResult { | |
273 | - | case int: Int => | |
274 | - | int | |
275 | - | case _ => | |
276 | - | throw("_6") | |
277 | - | } | |
278 | - | let totalFarmingReward = getInt(kTotalFarmingReward) | |
279 | - | let farmCeoFeeSize = fraction(claimedReward, feePercent, 100) | |
280 | - | let currentCeoFee = getInt(kCeoCollectedFee) | |
281 | - | let ceoFeeOverall = getInt(kCeoCollectedFeeOverall) | |
282 | - | let amountToPay = (claimedReward - farmCeoFeeSize) | |
283 | - | let topUp = invoke(stakingAddress, "topUpReward", nil, [AttachedPayment(eggAssetId, amountToPay)]) | |
284 | - | if ((topUp == topUp)) | |
285 | - | then [IntegerEntry(kTotalFarmingReward, (totalFarmingReward + amountToPay)), IntegerEntry(kCeoCollectedFee, (currentCeoFee + farmCeoFeeSize)), IntegerEntry(kCeoCollectedFeeOverall, (ceoFeeOverall + farmCeoFeeSize))] | |
286 | - | else throw("Strict value is not equal to itself.") | |
108 | + | nil | |
287 | 109 | } | |
288 | 110 | ||
289 | 111 | ||
290 | - | ||
291 | - | @Callable(i) | |
292 | - | func claimCeoFee (address1,address2,address1Share,address2Share) = if (isLiquidated()) | |
293 | - | then throw("CCCF: CF is liquidated!") | |
294 | - | else if ((0 > address1Share)) | |
295 | - | then throw("Share 1 can't be negative") | |
296 | - | else if ((0 > address2Share)) | |
297 | - | then throw("Share 2 can't be negative") | |
298 | - | else if (((address1Share + address2Share) != 100)) | |
299 | - | then throw("Sum of shares should be 100") | |
300 | - | else if ((getBool(kLocked) == true)) | |
301 | - | then throw("_22") | |
302 | - | else if ((i.caller == this)) | |
303 | - | then { | |
304 | - | let currentCeoCollectedFee = getInt(kCeoCollectedFee) | |
305 | - | let address1Reward = if ((address2 == "")) | |
306 | - | then currentCeoCollectedFee | |
307 | - | else fraction(currentCeoCollectedFee, address1Share, 100) | |
308 | - | let address2Reward = if ((address2 == "")) | |
309 | - | then 0 | |
310 | - | else fraction(currentCeoCollectedFee, address2Share, 100) | |
311 | - | let scriptTransferAddress2 = if ((address2 == "")) | |
312 | - | then nil | |
313 | - | else [ScriptTransfer(addressFromStringValue(address2), address2Reward, getEggId())] | |
314 | - | (scriptTransferAddress2 ++ [ScriptTransfer(addressFromStringValue(address1), address1Reward, getEggId()), IntegerEntry(kCeoCollectedFee, 0)]) | |
315 | - | } | |
316 | - | else throw("Only manager can call the contract") | |
317 | - | ||
318 | - | ||
319 | - | ||
320 | - | @Callable(i) | |
321 | - | func callUnstakeProxy (function,assetId) = if (isLiquidated()) | |
322 | - | then throw("CCUP: CF is liquidated!") | |
323 | - | else if ((getBool(kLocked) == true)) | |
324 | - | then throw("Contract is locked now") | |
325 | - | else if (if ((function != "unstakeNFT")) | |
326 | - | then (function != "unstakeJackpot") | |
327 | - | else false) | |
328 | - | then throw("Bad function name") | |
329 | - | else if ((i.caller != this)) | |
330 | - | then throw("Can be called only by the account") | |
331 | - | else { | |
332 | - | let eggAssetId = getEggId() | |
333 | - | let shareAssetId = getShareAssetId() | |
334 | - | let farmingDappAddress = addressFromStringValue(getStrA(mAccAddr, "FARMING_DAPP")) | |
335 | - | let unstakedReward = invoke(farmingDappAddress, function, [assetId], nil) | |
336 | - | if ((unstakedReward == unstakedReward)) | |
337 | - | then { | |
338 | - | let reward = match unstakedReward { | |
339 | - | case int: Int => | |
340 | - | int | |
341 | - | case _ => | |
342 | - | throw("Error during unstaking") | |
343 | - | } | |
344 | - | let currentCeoFee = getInt(kCeoCollectedFee) | |
345 | - | let ceoFeeOverall = getInt(kCeoCollectedFeeOverall) | |
346 | - | let farmCeoFeeSize = fraction(reward, feePercent, 100) | |
347 | - | let amountToPay = (reward - farmCeoFeeSize) | |
348 | - | let topUp = invoke(stakingAddress, "topUpReward", nil, [AttachedPayment(eggAssetId, amountToPay)]) | |
349 | - | if ((topUp == topUp)) | |
350 | - | then [IntegerEntry(kCeoCollectedFee, (currentCeoFee + farmCeoFeeSize)), IntegerEntry(kCeoCollectedFeeOverall, (ceoFeeOverall + farmCeoFeeSize))] | |
351 | - | else throw("Strict value is not equal to itself.") | |
352 | - | } | |
353 | - | else throw("Strict value is not equal to itself.") | |
354 | - | } | |
355 | - | ||
356 | - | ||
357 | 112 | @Verifier(tx) | |
358 | - | func verify () = { | |
359 | - | let checkStarted = (getInt(kTotalLiquidity) >= getInt(kLiquidityThreshold)) | |
360 | - | match tx { | |
361 | - | case inv: InvokeScriptTransaction => | |
362 | - | let acceptedCallsStaking = ["stakeFarmTokens", "claimReward", "withdrawFarmTokens"] | |
363 | - | let acceptedCallsThis = ["callUnstakeProxy", "claimCeoFee", "lockInvestments", "unlockInvestments"] | |
364 | - | if (if ((inv.function == "unstakeNFT")) | |
365 | - | then true | |
366 | - | else (inv.function == "unstakeJackpot")) | |
367 | - | then throw("You cannot call these functions directly") | |
368 | - | else if (if (if ((addressFromRecipient(inv.dApp) == this)) | |
369 | - | then (inv.function == "initMasterKey") | |
370 | - | else false) | |
371 | - | then (mAccPKeyString == "") | |
372 | - | else false) | |
373 | - | then if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
374 | - | then true | |
375 | - | else sigVerify(tx.bodyBytes, tx.proofs[0], getBackupKey()) | |
376 | - | else if (if ((sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) == false)) | |
377 | - | then (sigVerify(tx.bodyBytes, tx.proofs[0], getBackupKey()) == false) | |
378 | - | else false) | |
379 | - | then throw("_100") | |
380 | - | else if ((checkStarted == false)) | |
381 | - | then throw("_14") | |
382 | - | else if ((getBool(kLocked) == true)) | |
383 | - | then throw("_22") | |
384 | - | else if (if ((inv.fee > 900000)) | |
385 | - | then true | |
386 | - | else (inv.feeAssetId != unit)) | |
387 | - | then throw("_15") | |
388 | - | else if ((size(inv.payments) > 3)) | |
389 | - | then throw("_17") | |
390 | - | else if (if ((addressFromRecipient(inv.dApp) == this)) | |
391 | - | then containsElement(acceptedCallsThis, inv.function) | |
392 | - | else false) | |
393 | - | then if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
394 | - | then true | |
395 | - | else sigVerify(tx.bodyBytes, tx.proofs[0], getBackupKey()) | |
396 | - | else if (if ((addressFromRecipient(inv.dApp) == addressFromStringValue(getMarketProxyAddr()))) | |
397 | - | then (inv.function == "callMarketplaceProxy") | |
398 | - | else false) | |
399 | - | then if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
400 | - | then true | |
401 | - | else sigVerify(tx.bodyBytes, tx.proofs[0], getBackupKey()) | |
402 | - | else if (if ((addressFromRecipient(inv.dApp) == stakingAddress)) | |
403 | - | then containsElement(acceptedCallsStaking, inv.function) | |
404 | - | else false) | |
405 | - | then if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
406 | - | then true | |
407 | - | else sigVerify(tx.bodyBytes, tx.proofs[0], getBackupKey()) | |
408 | - | else { | |
409 | - | let allowedContracts = getStrA(mAccAddr, "allowed_contracts") | |
410 | - | let allowedContractsList = split(allowedContracts, ";") | |
411 | - | let dappToCall = toString(addressFromRecipient(inv.dApp)) | |
412 | - | (indexOf(allowedContractsList, dappToCall) != unit) | |
413 | - | } | |
414 | - | case ss: SetScriptTransaction => | |
415 | - | sigVerify(tx.bodyBytes, tx.proofs[0], mAccPKey) | |
416 | - | case mt: MassTransferTransaction => | |
417 | - | sigVerify(tx.bodyBytes, tx.proofs[0], mAccPKey) | |
418 | - | case _ => | |
419 | - | false | |
420 | - | } | |
421 | - | } | |
113 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], mAccPKey) | |
422 | 114 |
github/deemru/w8io/786bc32 39.42 ms ◑