tx · Dszrxn96N3zTGY9qbVdwZ9k6gTwHuhxbvBGwqPK4TZ3t 3PFoA1JFDoLWQJ3DqzAHNrrWR4riVuBfHks: -0.01000000 Waves 2022.04.25 12:07 [3089213] smart account 3PFoA1JFDoLWQJ3DqzAHNrrWR4riVuBfHks > SELF 0.00000000 Waves
{ "type": 13, "id": "Dszrxn96N3zTGY9qbVdwZ9k6gTwHuhxbvBGwqPK4TZ3t", "fee": 1000000, "feeAssetId": null, "timestamp": 1650877591101, "version": 1, "sender": "3PFoA1JFDoLWQJ3DqzAHNrrWR4riVuBfHks", "senderPublicKey": "5wDXuHuaDELQu1VzL96PvhJeSpJGXHu9W9v3booheS1R", "proofs": [ "53WWvw3RSDetA4uVQbfi2S2JyazZpbDgmEX2fFn7iCPYA4DzrQd6v1uE6NoSVQfNkFrNBSRFEZGxu19Db7Ji9MWo" ], "script": "base64:AAIFAAAAAAAAAA4IAhIDCgEIEgUKAwgIAQAAAAoBAAAAEHdyaXRlQ29uc3RTdHJpbmcAAAACAAAAA2tleQAAAAV2YWx1ZQMJAQAAAAEhAAAAAQkBAAAACWlzRGVmaW5lZAAAAAEJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5CQEAAAALU3RyaW5nRW50cnkAAAACBQAAAANrZXkFAAAABXZhbHVlCQAAAgAAAAEJAAEsAAAAAgIAAAAVYWxyZWFkeSBpbml0aWFsaXplZDogBQAAAANrZXkAAAAAC2NvbmZpZ1N0b3JlAgAAAAZjb25maWcAAAAADWNvbmZpZ0FkZHJlc3MJAQAAABFAZXh0ck5hdGl2ZSgxMDYyKQAAAAEJAQAAABFAZXh0ck5hdGl2ZSgxMDUzKQAAAAIFAAAABHRoaXMFAAAAC2NvbmZpZ1N0b3JlAAAAABJtYXliZU9yYWNsZUFkZHJlc3MEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAANY29uZmlnQWRkcmVzcwIAAAAOb3JhY2xlX2FkZHJlc3MDCQAAAQAAAAIFAAAAByRtYXRjaDACAAA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AAACBQAAAB91c2VyV2l0aGRyYXduV2l0aGluQ3VycmVudEVwb2NoBQAAAAZhbW91bnQFAAAAA2xtdAkAAAIAAAABCQABLAAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAEsAAAAAgIAAAAdYnJlYWNoaW5nIHdpdGhkcmF3IGxpbWl0IHBlciAJAAGkAAAAAQUAAAADbG10AgAAAAEgBQAAAAdhc3NldElkAgAAAAYgb3ZlciAJAAGkAAAAAQUAAAAJdGltZWZyYW1lAgAAABQgYmxvY2tzLiBBdmFpbGFibGU6IAkAAaQAAAABCQAAZQAAAAIFAAAAA2xtdAUAAAAfdXNlcldpdGhkcmF3bldpdGhpbkN1cnJlbnRFcG9jaAIAAAAQIGN1cnJlbnQgZXBvY2g6IAkAAaQAAAABBQAAABFjdXJyZW50RXBvY2hTdGFydAIAAAABLQkAAaQAAAABBQAAAA9jdXJyZW50RXBvY2hFbmQJAAUUAAAAAgkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACBQAAAAVzdG9yZQkAASwAAAACCQABLAAAAAIJAAGkAAAAAQUAAAARY3VycmVudEVwb2NoU3RhcnQCAAAAAXwJAAGkAAAAAQkAAGQAAAACBQAAAB91c2VyV2l0aGRyYXduV2l0aGluQ3VycmVudEVwb2NoBQAAAAZhbW91bnQFAAAAA25pbAkAAGUAAAACCQAAZQAAAAIFAAAAA2xtdAUAAAAfdXNlcldpdGhkcmF3bldpdGhpbkN1cnJlbnRFcG9jaAUAAAAGYW1vdW50CQAFFAAAAAIFAAAAA25pbAD//////////wkAAAIAAAABAgAAACRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4AAAAAL6iVAQ==", "chainId": 87, "height": 3089213, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4Xn2yWJ11jtwZGd8bcVyt3yWpasLQ28iRcPNK4MCJsFj Next: 3tyZP396He9WXQoCDehks6KzZfCNiKnD9koKmMBJUdbL Diff:
Old | New | Differences | |
---|---|---|---|
27 | 27 | func userWithdrawnWithinEpochStore (user,assetId) = ((("withdrawn_" + user) + "_") + assetId) | |
28 | 28 | ||
29 | 29 | ||
30 | + | let mainContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(configAddress, "main"), "no main in config")), "invalid main address") | |
31 | + | ||
32 | + | func mainOnly (i) = if ((i.caller != mainContract)) | |
33 | + | then throw("only main can do") | |
34 | + | else true | |
35 | + | ||
36 | + | ||
30 | 37 | @Callable(i) | |
31 | 38 | func initialize (ca) = [writeConstString(configStore, ca)] | |
32 | 39 | ||
33 | 40 | ||
34 | 41 | ||
35 | 42 | @Callable(i) | |
36 | - | func validateWithdrawLimit (assetId,user,amount) = match limit(assetId) { | |
37 | - | case lmt: Int => | |
38 | - | let currentEpochStart = ((HEIGHT / timeframe) * timeframe) | |
39 | - | let currentEpochEnd = ((1 + (HEIGHT / timeframe)) * timeframe) | |
40 | - | let store = userWithdrawnWithinEpochStore(user, assetId) | |
41 | - | let $t012941518 = match getString(store) { | |
42 | - | case s: String => | |
43 | - | let data = split(s, "|") | |
44 | - | $Tuple2(parseIntValue(data[0]), parseIntValue(data[1])) | |
43 | + | func validateWithdrawLimit (assetId,user,amount) = { | |
44 | + | let m = mainOnly(i) | |
45 | + | if ((m == m)) | |
46 | + | then match limit(assetId) { | |
47 | + | case lmt: Int => | |
48 | + | let currentEpochStart = ((HEIGHT / timeframe) * timeframe) | |
49 | + | let currentEpochEnd = ((1 + (HEIGHT / timeframe)) * timeframe) | |
50 | + | let store = userWithdrawnWithinEpochStore(user, assetId) | |
51 | + | let $t015801804 = match getString(store) { | |
52 | + | case s: String => | |
53 | + | let data = split(s, "|") | |
54 | + | $Tuple2(parseIntValue(data[0]), parseIntValue(data[1])) | |
55 | + | case _ => | |
56 | + | $Tuple2(0, 0) | |
57 | + | } | |
58 | + | let epoch = $t015801804._1 | |
59 | + | let withdrawn = $t015801804._2 | |
60 | + | let userWithdrawnWithinCurrentEpoch = if ((epoch == currentEpochStart)) | |
61 | + | then withdrawn | |
62 | + | else 0 | |
63 | + | if (((userWithdrawnWithinCurrentEpoch + amount) > lmt)) | |
64 | + | then throw(((((((((((("breaching withdraw limit per " + toString(lmt)) + " ") + assetId) + " over ") + toString(timeframe)) + " blocks. Available: ") + toString((lmt - userWithdrawnWithinCurrentEpoch))) + " current epoch: ") + toString(currentEpochStart)) + "-") + toString(currentEpochEnd))) | |
65 | + | else $Tuple2([StringEntry(store, ((toString(currentEpochStart) + "|") + toString((userWithdrawnWithinCurrentEpoch + amount))))], ((lmt - userWithdrawnWithinCurrentEpoch) - amount)) | |
45 | 66 | case _ => | |
46 | - | $Tuple2( | |
67 | + | $Tuple2(nil, -1) | |
47 | 68 | } | |
48 | - | let epoch = $t012941518._1 | |
49 | - | let withdrawn = $t012941518._2 | |
50 | - | let userWithdrawnWithinCurrentEpoch = if ((epoch == currentEpochStart)) | |
51 | - | then withdrawn | |
52 | - | else 0 | |
53 | - | if (((userWithdrawnWithinCurrentEpoch + amount) > lmt)) | |
54 | - | then throw(((((((((((("breaching withdraw limit per " + toString(lmt)) + " ") + assetId) + " over ") + toString(timeframe)) + " blocks. Available: ") + toString((lmt - userWithdrawnWithinCurrentEpoch))) + " current epoch: ") + toString(currentEpochStart)) + "-") + toString(currentEpochEnd))) | |
55 | - | else $Tuple2([StringEntry(store, ((toString(currentEpochStart) + "|") + toString((userWithdrawnWithinCurrentEpoch + amount))))], ((lmt - userWithdrawnWithinCurrentEpoch) - amount)) | |
56 | - | case _ => | |
57 | - | $Tuple2(nil, -1) | |
58 | - | } | |
69 | + | else throw("Strict value is not equal to itself.") | |
70 | + | } | |
59 | 71 | ||
60 | 72 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func writeConstString (key,value) = if (!(isDefined(getString(this, key)))) | |
5 | 5 | then StringEntry(key, value) | |
6 | 6 | else throw(("already initialized: " + key)) | |
7 | 7 | ||
8 | 8 | ||
9 | 9 | let configStore = "config" | |
10 | 10 | ||
11 | 11 | let configAddress = addressFromStringValue(getStringValue(this, configStore)) | |
12 | 12 | ||
13 | 13 | let maybeOracleAddress = match getString(configAddress, "oracle_address") { | |
14 | 14 | case s: String => | |
15 | 15 | addressFromString(s) | |
16 | 16 | case _ => | |
17 | 17 | unit | |
18 | 18 | } | |
19 | 19 | ||
20 | 20 | let HEIGHT = height | |
21 | 21 | ||
22 | 22 | let timeframe = valueOrElse(getInteger(configAddress, "WithdrawLimitTimeframe"), 1) | |
23 | 23 | ||
24 | 24 | func limit (assetId) = getInteger(configAddress, (assetId + "_WithdrawLimitAcc")) | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | func userWithdrawnWithinEpochStore (user,assetId) = ((("withdrawn_" + user) + "_") + assetId) | |
28 | 28 | ||
29 | 29 | ||
30 | + | let mainContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(configAddress, "main"), "no main in config")), "invalid main address") | |
31 | + | ||
32 | + | func mainOnly (i) = if ((i.caller != mainContract)) | |
33 | + | then throw("only main can do") | |
34 | + | else true | |
35 | + | ||
36 | + | ||
30 | 37 | @Callable(i) | |
31 | 38 | func initialize (ca) = [writeConstString(configStore, ca)] | |
32 | 39 | ||
33 | 40 | ||
34 | 41 | ||
35 | 42 | @Callable(i) | |
36 | - | func validateWithdrawLimit (assetId,user,amount) = match limit(assetId) { | |
37 | - | case lmt: Int => | |
38 | - | let currentEpochStart = ((HEIGHT / timeframe) * timeframe) | |
39 | - | let currentEpochEnd = ((1 + (HEIGHT / timeframe)) * timeframe) | |
40 | - | let store = userWithdrawnWithinEpochStore(user, assetId) | |
41 | - | let $t012941518 = match getString(store) { | |
42 | - | case s: String => | |
43 | - | let data = split(s, "|") | |
44 | - | $Tuple2(parseIntValue(data[0]), parseIntValue(data[1])) | |
43 | + | func validateWithdrawLimit (assetId,user,amount) = { | |
44 | + | let m = mainOnly(i) | |
45 | + | if ((m == m)) | |
46 | + | then match limit(assetId) { | |
47 | + | case lmt: Int => | |
48 | + | let currentEpochStart = ((HEIGHT / timeframe) * timeframe) | |
49 | + | let currentEpochEnd = ((1 + (HEIGHT / timeframe)) * timeframe) | |
50 | + | let store = userWithdrawnWithinEpochStore(user, assetId) | |
51 | + | let $t015801804 = match getString(store) { | |
52 | + | case s: String => | |
53 | + | let data = split(s, "|") | |
54 | + | $Tuple2(parseIntValue(data[0]), parseIntValue(data[1])) | |
55 | + | case _ => | |
56 | + | $Tuple2(0, 0) | |
57 | + | } | |
58 | + | let epoch = $t015801804._1 | |
59 | + | let withdrawn = $t015801804._2 | |
60 | + | let userWithdrawnWithinCurrentEpoch = if ((epoch == currentEpochStart)) | |
61 | + | then withdrawn | |
62 | + | else 0 | |
63 | + | if (((userWithdrawnWithinCurrentEpoch + amount) > lmt)) | |
64 | + | then throw(((((((((((("breaching withdraw limit per " + toString(lmt)) + " ") + assetId) + " over ") + toString(timeframe)) + " blocks. Available: ") + toString((lmt - userWithdrawnWithinCurrentEpoch))) + " current epoch: ") + toString(currentEpochStart)) + "-") + toString(currentEpochEnd))) | |
65 | + | else $Tuple2([StringEntry(store, ((toString(currentEpochStart) + "|") + toString((userWithdrawnWithinCurrentEpoch + amount))))], ((lmt - userWithdrawnWithinCurrentEpoch) - amount)) | |
45 | 66 | case _ => | |
46 | - | $Tuple2( | |
67 | + | $Tuple2(nil, -1) | |
47 | 68 | } | |
48 | - | let epoch = $t012941518._1 | |
49 | - | let withdrawn = $t012941518._2 | |
50 | - | let userWithdrawnWithinCurrentEpoch = if ((epoch == currentEpochStart)) | |
51 | - | then withdrawn | |
52 | - | else 0 | |
53 | - | if (((userWithdrawnWithinCurrentEpoch + amount) > lmt)) | |
54 | - | then throw(((((((((((("breaching withdraw limit per " + toString(lmt)) + " ") + assetId) + " over ") + toString(timeframe)) + " blocks. Available: ") + toString((lmt - userWithdrawnWithinCurrentEpoch))) + " current epoch: ") + toString(currentEpochStart)) + "-") + toString(currentEpochEnd))) | |
55 | - | else $Tuple2([StringEntry(store, ((toString(currentEpochStart) + "|") + toString((userWithdrawnWithinCurrentEpoch + amount))))], ((lmt - userWithdrawnWithinCurrentEpoch) - amount)) | |
56 | - | case _ => | |
57 | - | $Tuple2(nil, -1) | |
58 | - | } | |
69 | + | else throw("Strict value is not equal to itself.") | |
70 | + | } | |
59 | 71 | ||
60 | 72 |
github/deemru/w8io/3ef1775 30.29 ms ◑