tx · J7y1yAku4bVWHWGktE21QGsWY8JNsp8PA4Ru6wjkSsTc 3NCzUsFn22SqL6SiuFpRSo8VRj6XpBzNCTK: -0.00900000 Waves 2022.06.27 19:06 [2115059] smart account 3NCzUsFn22SqL6SiuFpRSo8VRj6XpBzNCTK > SELF 0.00000000 Waves
{ "type": 13, "id": "J7y1yAku4bVWHWGktE21QGsWY8JNsp8PA4Ru6wjkSsTc", "fee": 900000, "feeAssetId": null, "timestamp": 1656346012568, "version": 2, "chainId": 84, "sender": "3NCzUsFn22SqL6SiuFpRSo8VRj6XpBzNCTK", "senderPublicKey": "8tc6RQVnwQMdDY1k9GxP7EvBttrJT2a6GeBMQHEsKnW7", "proofs": [ "azvFCLJpPKuPxMdDctBx9Uj2YoZk9mstu6VKxzNdub874XqMGHbMDfX4CB7zmC5xixVCkSKYifWXAfST66JR2hV" ], "script": "base64:AAIFAAAAAAAAAAYIAhIAEgAAAAAIAAAAAAVmYXJtcwkABEwAAAACAgAAAARiZXRhCQAETAAAAAICAAAABG1ldGEJAARMAAAAAgIAAAAEemV0YQUAAAADbmlsAQAAAAZnZXRTdHIAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYgUAAAAHJG1hdGNoMAUAAAABYgIAAAAAAQAAAAZnZXRJbnQAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYgUAAAAHJG1hdGNoMAUAAAABYgAAAAAAAAAAAAEAAAAFc3Rha2UAAAACAAAABGZhcm0AAAAGYW1vdW50BAAAAAdhc3NldElkCQACWQAAAAEJAQAAAAZnZXRTdHIAAAABCQABLAAAAAIFAAAABGZhcm0CAAAAA19pZAQAAAAEZEFwcAkBAAAABmdldFN0cgAAAAEJAAEsAAAAAgUAAAA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GcAAAACBQAAAAIkaQUAAAACJHMFAAAAAiRhCQAAAgAAAAECAAAAE0xpc3Qgc2l6ZSBleGNlZWRzIDMJAQAAAAUkZjBfMgAAAAIJAQAAAAUkZjBfMQAAAAIJAQAAAAUkZjBfMQAAAAIJAQAAAAUkZjBfMQAAAAIFAAAABSRhY2MwAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAACAAAAAAAAAAADCQAAAgAAAAECAAAAIFByaXZhdGUgRmFybS4gQWNjZXNzIHByb2hpYml0ZWQhAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkwq+/V", "height": 2115059, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AXHFfVW6daH2YjMeXM5CNKHUHsv6Kg7fhn9cecgGY7Hi Next: 6n8xxwoN5cu5DJQQ77kUaFKvF7y7nvhv1zkcEHonAHGA Diff:
Old | New | Differences | |
---|---|---|---|
31 | 31 | } | |
32 | 32 | ||
33 | 33 | ||
34 | + | func unstake (farm,amount) = { | |
35 | + | let assetId = fromBase58String(getStr((farm + "_id"))) | |
36 | + | let dApp = getStr((farm + "_st")) | |
37 | + | let balance = assetBalance(this, assetId) | |
38 | + | if ((amount == -1)) | |
39 | + | then invoke(Address(fromBase58String(dApp)), "withdrawFarmTokens", [false], [AttachedPayment(assetId, balance)]) | |
40 | + | else if ((balance >= amount)) | |
41 | + | then invoke(Address(fromBase58String(dApp)), "withdrawFarmTokens", [false], [AttachedPayment(assetId, amount)]) | |
42 | + | else throw(((("Low balance: " + toString(balance)) + " and need: ") + toString(amount))) | |
43 | + | } | |
44 | + | ||
45 | + | ||
34 | 46 | func check (pbk) = { | |
35 | 47 | let pbk_st = toBase58String(pbk) | |
36 | 48 | let points = getStringValue("points") | |
40 | 52 | ||
41 | 53 | func iterStake (acc,farm) = { | |
42 | 54 | let rez = stake(farm, -1) | |
55 | + | match rez { | |
56 | + | case t: ScriptTransfer => | |
57 | + | (acc ++ [rez]) | |
58 | + | case _ => | |
59 | + | acc | |
60 | + | } | |
61 | + | } | |
62 | + | ||
63 | + | ||
64 | + | func iterUnstake (acc,farm) = { | |
65 | + | let rez = unstake(farm, -1) | |
43 | 66 | match rez { | |
44 | 67 | case t: ScriptTransfer => | |
45 | 68 | (acc ++ [rez]) | |
71 | 94 | ||
72 | 95 | @Callable(i) | |
73 | 96 | func UnstakeAll () = if (check(i.callerPublicKey)) | |
74 | - | then throw("Welcome") | |
97 | + | then { | |
98 | + | let $l = farms | |
99 | + | let $s = size($l) | |
100 | + | let $acc0 = nil | |
101 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
102 | + | then $a | |
103 | + | else iterUnstake($a, $l[$i]) | |
104 | + | ||
105 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
106 | + | then $a | |
107 | + | else throw("List size exceeds 3") | |
108 | + | ||
109 | + | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) | |
110 | + | } | |
75 | 111 | else throw("Private Farm. Access prohibited!") | |
76 | 112 | ||
77 | 113 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let farms = ["beta", "meta", "zeta"] | |
5 | 5 | ||
6 | 6 | func getStr (key) = match getString(this, key) { | |
7 | 7 | case b: String => | |
8 | 8 | b | |
9 | 9 | case _ => | |
10 | 10 | "" | |
11 | 11 | } | |
12 | 12 | ||
13 | 13 | ||
14 | 14 | func getInt (key) = match getInteger(this, key) { | |
15 | 15 | case b: Int => | |
16 | 16 | b | |
17 | 17 | case _ => | |
18 | 18 | 0 | |
19 | 19 | } | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | func stake (farm,amount) = { | |
23 | 23 | let assetId = fromBase58String(getStr((farm + "_id"))) | |
24 | 24 | let dApp = getStr((farm + "_st")) | |
25 | 25 | let balance = assetBalance(this, assetId) | |
26 | 26 | if ((amount == -1)) | |
27 | 27 | then invoke(Address(fromBase58String(dApp)), "stakeFarmTokens", [false], [AttachedPayment(assetId, balance)]) | |
28 | 28 | else if ((balance >= amount)) | |
29 | 29 | then invoke(Address(fromBase58String(dApp)), "stakeFarmTokens", [false], [AttachedPayment(assetId, amount)]) | |
30 | 30 | else throw(((("Low balance: " + toString(balance)) + " and need: ") + toString(amount))) | |
31 | 31 | } | |
32 | 32 | ||
33 | 33 | ||
34 | + | func unstake (farm,amount) = { | |
35 | + | let assetId = fromBase58String(getStr((farm + "_id"))) | |
36 | + | let dApp = getStr((farm + "_st")) | |
37 | + | let balance = assetBalance(this, assetId) | |
38 | + | if ((amount == -1)) | |
39 | + | then invoke(Address(fromBase58String(dApp)), "withdrawFarmTokens", [false], [AttachedPayment(assetId, balance)]) | |
40 | + | else if ((balance >= amount)) | |
41 | + | then invoke(Address(fromBase58String(dApp)), "withdrawFarmTokens", [false], [AttachedPayment(assetId, amount)]) | |
42 | + | else throw(((("Low balance: " + toString(balance)) + " and need: ") + toString(amount))) | |
43 | + | } | |
44 | + | ||
45 | + | ||
34 | 46 | func check (pbk) = { | |
35 | 47 | let pbk_st = toBase58String(pbk) | |
36 | 48 | let points = getStringValue("points") | |
37 | 49 | contains(points, pbk_st) | |
38 | 50 | } | |
39 | 51 | ||
40 | 52 | ||
41 | 53 | func iterStake (acc,farm) = { | |
42 | 54 | let rez = stake(farm, -1) | |
55 | + | match rez { | |
56 | + | case t: ScriptTransfer => | |
57 | + | (acc ++ [rez]) | |
58 | + | case _ => | |
59 | + | acc | |
60 | + | } | |
61 | + | } | |
62 | + | ||
63 | + | ||
64 | + | func iterUnstake (acc,farm) = { | |
65 | + | let rez = unstake(farm, -1) | |
43 | 66 | match rez { | |
44 | 67 | case t: ScriptTransfer => | |
45 | 68 | (acc ++ [rez]) | |
46 | 69 | case _ => | |
47 | 70 | acc | |
48 | 71 | } | |
49 | 72 | } | |
50 | 73 | ||
51 | 74 | ||
52 | 75 | @Callable(i) | |
53 | 76 | func StakeAndClaimAll () = if (check(i.callerPublicKey)) | |
54 | 77 | then { | |
55 | 78 | let $l = farms | |
56 | 79 | let $s = size($l) | |
57 | 80 | let $acc0 = nil | |
58 | 81 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
59 | 82 | then $a | |
60 | 83 | else iterStake($a, $l[$i]) | |
61 | 84 | ||
62 | 85 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
63 | 86 | then $a | |
64 | 87 | else throw("List size exceeds 3") | |
65 | 88 | ||
66 | 89 | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) | |
67 | 90 | } | |
68 | 91 | else throw("Private Farm. Access prohibited!") | |
69 | 92 | ||
70 | 93 | ||
71 | 94 | ||
72 | 95 | @Callable(i) | |
73 | 96 | func UnstakeAll () = if (check(i.callerPublicKey)) | |
74 | - | then throw("Welcome") | |
97 | + | then { | |
98 | + | let $l = farms | |
99 | + | let $s = size($l) | |
100 | + | let $acc0 = nil | |
101 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
102 | + | then $a | |
103 | + | else iterUnstake($a, $l[$i]) | |
104 | + | ||
105 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
106 | + | then $a | |
107 | + | else throw("List size exceeds 3") | |
108 | + | ||
109 | + | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) | |
110 | + | } | |
75 | 111 | else throw("Private Farm. Access prohibited!") | |
76 | 112 | ||
77 | 113 | ||
78 | 114 | @Verifier(tx) | |
79 | 115 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
80 | 116 |
github/deemru/w8io/169f3d6 46.42 ms ◑