tx · 7e2fyHr9YGe9mn5g4xa83T7C5Mc4aE6iVNAifoS4VRrc
3NCzUsFn22SqL6SiuFpRSo8VRj6XpBzNCTK: -0.00700000 Waves
2022.06.27 17:38 [2114972] smart account 3NCzUsFn22SqL6SiuFpRSo8VRj6XpBzNCTK > SELF 0.00000000 Waves
{
"type": 13,
"id": "7e2fyHr9YGe9mn5g4xa83T7C5Mc4aE6iVNAifoS4VRrc",
"fee": 700000,
"feeAssetId": null,
"timestamp": 1656340734620,
"version": 2,
"chainId": 84,
"sender": "3NCzUsFn22SqL6SiuFpRSo8VRj6XpBzNCTK",
"senderPublicKey": "8tc6RQVnwQMdDY1k9GxP7EvBttrJT2a6GeBMQHEsKnW7",
"proofs": [
"39DMxYS4yPEY81G4cAVYXmkWbVcmsk4Z2YsNJ487xhfNy3wj7UbrAd14Uovq2fqpUV6wvVnDPG4gvqXq4HvoEjYN"
],
"script": "base64:AAIFAAAAAAAAAAgIAhIAEgASAAAAAAcAAAAABWZhcm1zCQAETAAAAAICAAAABGJldGEJAARMAAAAAgIAAAAEbWV0YQkABEwAAAACAgAAAAR6ZXRhBQAAAANuaWwBAAAABmdldFN0cgAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFiBQAAAAckbWF0Y2gwBQAAAAFiAgAAAAABAAAABmdldEludAAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFiBQAAAAckbWF0Y2gwBQAAAAFiAAAAAAAAAAAAAQAAAA1nZXRBc3NldEJ5dGVzAAAAAQAAAARhc2lkAwkAAAAAAAACBQAAAARhc2lkAgAAAAVXQVZFUwUAAAAEdW5pdAkAAlkAAAABBQAAAARhc2lkAQAAAAVzdGFrZQAAAAIAAAAEZmFyb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IBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXlVEZQi",
"height": 2114972,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: ALRoUu2Rjw7UGiSNch45uv6aTcfarucUWgtuhg2VquEs
Next: BGe87eAkHcUFE99gP7ghCLu9FG8XFVFkNtjAF9CWTzB1
Diff:
Old | New | | Differences |
---|
19 | 19 | | } |
---|
20 | 20 | | |
---|
21 | 21 | | |
---|
| 22 | + | func getAssetBytes (asid) = if ((asid == "WAVES")) |
---|
| 23 | + | then unit |
---|
| 24 | + | else fromBase58String(asid) |
---|
| 25 | + | |
---|
| 26 | + | |
---|
22 | 27 | | func stake (farm,amount) = { |
---|
23 | 28 | | let assetId = fromBase58String(getStr((farm + "_id"))) |
---|
24 | 29 | | let dApp = getStr((farm + "_st")) |
---|
|
27 | 32 | | then invoke(Address(fromBase58String(dApp)), "stakeFarmTokens", [false], [AttachedPayment(assetId, balance)]) |
---|
28 | 33 | | else if ((balance >= amount)) |
---|
29 | 34 | | then invoke(Address(fromBase58String(dApp)), "stakeFarmTokens", [false], [AttachedPayment(assetId, amount)]) |
---|
30 | | - | else throw(((("Low balance: " + toString(balance)) + " and need: ") + toString(amount))) |
---|
| 35 | + | else false |
---|
31 | 36 | | } |
---|
32 | 37 | | |
---|
33 | 38 | | |
---|
|
38 | 43 | | } |
---|
39 | 44 | | |
---|
40 | 45 | | |
---|
41 | | - | func iter (acc,farm) = if ((acc == 0)) |
---|
42 | | - | then stake(farm, -1) |
---|
43 | | - | else 0 |
---|
| 46 | + | func iter (acc,farm) = { |
---|
| 47 | + | let rez = stake(farm, -1) |
---|
| 48 | + | match rez { |
---|
| 49 | + | case t: ScriptTransfer => |
---|
| 50 | + | (acc ++ [rez]) |
---|
| 51 | + | case _ => |
---|
| 52 | + | acc |
---|
| 53 | + | } |
---|
| 54 | + | } |
---|
44 | 55 | | |
---|
45 | 56 | | |
---|
46 | 57 | | @Callable(i) |
---|
47 | 58 | | func StakeAll () = if (check(i.callerPublicKey)) |
---|
48 | | - | then [IntegerEntry("stake", { |
---|
| 59 | + | then { |
---|
49 | 60 | | let $l = farms |
---|
50 | 61 | | let $s = size($l) |
---|
51 | | - | let $acc0 = 0 |
---|
| 62 | + | let $acc0 = nil |
---|
52 | 63 | | func $f0_1 ($a,$i) = if (($i >= $s)) |
---|
53 | 64 | | then $a |
---|
54 | 65 | | else iter($a, $l[$i]) |
---|
|
58 | 69 | | else throw("List size exceeds 3") |
---|
59 | 70 | | |
---|
60 | 71 | | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) |
---|
61 | | - | })] |
---|
| 72 | + | } |
---|
62 | 73 | | else throw("Private Farm. Access prohibited!") |
---|
63 | 74 | | |
---|
64 | 75 | | |
---|
Full:
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 | + | func getAssetBytes (asid) = if ((asid == "WAVES")) |
---|
| 23 | + | then unit |
---|
| 24 | + | else fromBase58String(asid) |
---|
| 25 | + | |
---|
| 26 | + | |
---|
22 | 27 | | func stake (farm,amount) = { |
---|
23 | 28 | | let assetId = fromBase58String(getStr((farm + "_id"))) |
---|
24 | 29 | | let dApp = getStr((farm + "_st")) |
---|
25 | 30 | | let balance = assetBalance(this, assetId) |
---|
26 | 31 | | if ((amount == -1)) |
---|
27 | 32 | | then invoke(Address(fromBase58String(dApp)), "stakeFarmTokens", [false], [AttachedPayment(assetId, balance)]) |
---|
28 | 33 | | else if ((balance >= amount)) |
---|
29 | 34 | | then invoke(Address(fromBase58String(dApp)), "stakeFarmTokens", [false], [AttachedPayment(assetId, amount)]) |
---|
30 | | - | else throw(((("Low balance: " + toString(balance)) + " and need: ") + toString(amount))) |
---|
| 35 | + | else false |
---|
31 | 36 | | } |
---|
32 | 37 | | |
---|
33 | 38 | | |
---|
34 | 39 | | func check (pbk) = { |
---|
35 | 40 | | let pbk_st = toBase58String(pbk) |
---|
36 | 41 | | let points = getStringValue("points") |
---|
37 | 42 | | contains(points, pbk_st) |
---|
38 | 43 | | } |
---|
39 | 44 | | |
---|
40 | 45 | | |
---|
41 | | - | func iter (acc,farm) = if ((acc == 0)) |
---|
42 | | - | then stake(farm, -1) |
---|
43 | | - | else 0 |
---|
| 46 | + | func iter (acc,farm) = { |
---|
| 47 | + | let rez = stake(farm, -1) |
---|
| 48 | + | match rez { |
---|
| 49 | + | case t: ScriptTransfer => |
---|
| 50 | + | (acc ++ [rez]) |
---|
| 51 | + | case _ => |
---|
| 52 | + | acc |
---|
| 53 | + | } |
---|
| 54 | + | } |
---|
44 | 55 | | |
---|
45 | 56 | | |
---|
46 | 57 | | @Callable(i) |
---|
47 | 58 | | func StakeAll () = if (check(i.callerPublicKey)) |
---|
48 | | - | then [IntegerEntry("stake", { |
---|
| 59 | + | then { |
---|
49 | 60 | | let $l = farms |
---|
50 | 61 | | let $s = size($l) |
---|
51 | | - | let $acc0 = 0 |
---|
| 62 | + | let $acc0 = nil |
---|
52 | 63 | | func $f0_1 ($a,$i) = if (($i >= $s)) |
---|
53 | 64 | | then $a |
---|
54 | 65 | | else iter($a, $l[$i]) |
---|
55 | 66 | | |
---|
56 | 67 | | func $f0_2 ($a,$i) = if (($i >= $s)) |
---|
57 | 68 | | then $a |
---|
58 | 69 | | else throw("List size exceeds 3") |
---|
59 | 70 | | |
---|
60 | 71 | | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) |
---|
61 | | - | })] |
---|
| 72 | + | } |
---|
62 | 73 | | else throw("Private Farm. Access prohibited!") |
---|
63 | 74 | | |
---|
64 | 75 | | |
---|
65 | 76 | | |
---|
66 | 77 | | @Callable(i) |
---|
67 | 78 | | func UnstakeAll () = if (check(i.callerPublicKey)) |
---|
68 | 79 | | then throw("Welcome") |
---|
69 | 80 | | else throw("Private Farm. Access prohibited!") |
---|
70 | 81 | | |
---|
71 | 82 | | |
---|
72 | 83 | | |
---|
73 | 84 | | @Callable(i) |
---|
74 | 85 | | func ClaimAll () = if (check(i.callerPublicKey)) |
---|
75 | 86 | | then throw("Welcome") |
---|
76 | 87 | | else throw("Private Farm. Access prohibited!") |
---|
77 | 88 | | |
---|
78 | 89 | | |
---|
79 | 90 | | @Verifier(tx) |
---|
80 | 91 | | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) |
---|
81 | 92 | | |
---|