tx · CKXTy7STEeMVoxfMEuiYmgDHtokpGxXWFtQuzRWWcqNK 3N4ziXSMRverXyxHDUKKMR9MHXnB3TyU3Yh: -0.01000000 Waves 2023.04.18 14:19 [2539915] smart account 3N4ziXSMRverXyxHDUKKMR9MHXnB3TyU3Yh > SELF 0.00000000 Waves
{ "type": 13, "id": "CKXTy7STEeMVoxfMEuiYmgDHtokpGxXWFtQuzRWWcqNK", "fee": 1000000, "feeAssetId": null, "timestamp": 1681816821392, "version": 2, "chainId": 84, "sender": "3N4ziXSMRverXyxHDUKKMR9MHXnB3TyU3Yh", "senderPublicKey": "EU9obW1yVhR8qug3EmXPeew3DMagvJFQzY5Ku8bmcsU7", "proofs": [ "4PD3vwcGAVbfgAFqJmCvY5tDTcMUM9d9kstRndxXvQJsPNpNm4aawfAa1d4xDrQNzAJMdxciMRxJHz85Fd246tKq" ], "script": "base64:BgIHCAISAwoBCBIAA1NFUAICX18AEGNvbnRyYWN0RmlsZW5hbWUCCXRlc3QucmlkZQEIdGhyb3dFcnIBAXMJAAIBCQCsAgIJAKwCAgUQY29udHJhY3RGaWxlbmFtZQICOiAFAXMBGWtleUFjdGl2ZU1hbmFnZXJQdWJsaWNLZXkACQC5CQIJAMwIAgICJXMJAMwIAgIQbWFuYWdlclB1YmxpY0tleQUDbmlsBQNTRVABGmtleUN1cnJlbnRNYW5hZ2VyUHVibGljS2V5AAkAuQkCCQDMCAICAiVzCQDMCAICEWtleUN1cnJlbnRNYW5hZ2VyBQNuaWwFA1NFUAEaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkACQC5CQIJAMwIAgICJXMJAMwIAgIXcGVuZGluZ01hbmFnZXJQdWJsaWNLZXkFA25pbAUDU0VQARprZXlTZXROZXdNYW5hZ2VyVm90ZVByZWZpeAEQbWFuYWdlclB1YmxpY0tleQkAuQkCCQDMCAICBiVzJXMlcwkAzAgCAgpzZXRNYW5hZ2VyCQDMCAIFEG1hbmFnZXJQdWJsaWNLZXkFA25pbAUDU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wJAQh0aHJvd0VycgEJAKwCAgUTY2FsbGVyQWRkcmVzc1N0cmluZwITOiBub3QgaW4gQWRtaW4gbGlzdADpgelF", "height": 2539915, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FnsZGczRfLRYUpQ5Pg9zjdd3JC9GNCVjWVP6Uq8Nk1b Next: 7JSUxBcotPbE6cWuYza6ezr7rnyVT21Y2yqermkkB9R5 Diff:
Old | New | Differences | |
---|---|---|---|
85 | 85 | } | |
86 | 86 | ||
87 | 87 | ||
88 | + | func clearVotesHelper (result,key) = (result :+ DeleteEntry(key)) | |
89 | + | ||
90 | + | ||
91 | + | func getClearVotesEntries (prefix) = { | |
92 | + | let votes = genVotesKeys(prefix)._1 | |
93 | + | let $l = votes | |
94 | + | let $s = size($l) | |
95 | + | let $acc0 = nil | |
96 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
97 | + | then $a | |
98 | + | else clearVotesHelper($a, $l[$i]) | |
99 | + | ||
100 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
101 | + | then $a | |
102 | + | else throw("List size exceeds 10") | |
103 | + | ||
104 | + | $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) | |
105 | + | } | |
106 | + | ||
107 | + | ||
88 | 108 | @Callable(i) | |
89 | 109 | func voteForNewManger (newManagerPublicKey) = { | |
90 | 110 | let callerAddressString = toBase58String(i.caller.bytes) | |
91 | 111 | if (isInAdminList(callerAddressString)) | |
92 | - | then nil | |
112 | + | then { | |
113 | + | let votes = countVotes(keySetNewManagerVotePrefix(newManagerPublicKey)) | |
114 | + | if (((votes + 1) > 1)) | |
115 | + | then { | |
116 | + | let clearVotesEntries = getClearVotesEntries(keySetNewManagerVotePrefix(newManagerPublicKey)) | |
117 | + | (clearVotesEntries ++ [StringEntry(keyPendingManagerPublicKey(), newManagerPublicKey)]) | |
118 | + | } | |
119 | + | else [IntegerEntry(keySetNewManagerVote(newManagerPublicKey, callerAddressString), 1)] | |
120 | + | } | |
93 | 121 | else throwErr((callerAddressString + ": not in Admin list")) | |
94 | 122 | } | |
95 | 123 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | 6 | let contractFilename = "test.ride" | |
7 | 7 | ||
8 | 8 | func throwErr (s) = throw(((contractFilename + ": ") + s)) | |
9 | 9 | ||
10 | 10 | ||
11 | 11 | func keyActiveManagerPublicKey () = makeString(["%s", "managerPublicKey"], SEP) | |
12 | 12 | ||
13 | 13 | ||
14 | 14 | func keyCurrentManagerPublicKey () = makeString(["%s", "keyCurrentManager"], SEP) | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func keyPendingManagerPublicKey () = makeString(["%s", "pendingManagerPublicKey"], SEP) | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func keySetNewManagerVotePrefix (managerPublicKey) = makeString(["%s%s%s", "setManager", managerPublicKey], SEP) | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | func keySetNewManagerVote (managerPublicKey,admin) = makeString([keySetNewManagerVotePrefix(managerPublicKey), admin], SEP) | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | func getSetNewManagerVote (admin,managerPublicKey) = valueOrElse(getInteger(keySetNewManagerVote(admin, managerPublicKey)), 0) | |
27 | 27 | ||
28 | 28 | ||
29 | 29 | func adminAdressList () = makeString(["%s", "adminAddressList"], SEP) | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func getAdminsList () = split(valueOrElse(getString(this, adminAdressList()), ""), SEP) | |
33 | 33 | ||
34 | 34 | ||
35 | 35 | func isInAdminList (address) = match indexOf(getAdminsList(), address) { | |
36 | 36 | case t: Int => | |
37 | 37 | true | |
38 | 38 | case _ => | |
39 | 39 | false | |
40 | 40 | } | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func genVotesKeysHelper (lst,adminAddress) = { | |
44 | 44 | let $t013191345 = lst | |
45 | 45 | let result = $t013191345._1 | |
46 | 46 | let prefix = $t013191345._2 | |
47 | 47 | $Tuple2((result :+ makeString([prefix, adminAddress], SEP)), prefix) | |
48 | 48 | } | |
49 | 49 | ||
50 | 50 | ||
51 | 51 | func genVotesKeys (keyPrefix) = { | |
52 | 52 | let adminList = adminAdressList() | |
53 | 53 | let $l = getAdminsList() | |
54 | 54 | let $s = size($l) | |
55 | 55 | let $acc0 = $Tuple2(nil, keyPrefix) | |
56 | 56 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
57 | 57 | then $a | |
58 | 58 | else genVotesKeysHelper($a, $l[$i]) | |
59 | 59 | ||
60 | 60 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
61 | 61 | then $a | |
62 | 62 | else throw("List size exceeds 10") | |
63 | 63 | ||
64 | 64 | $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) | |
65 | 65 | } | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func countVotesHelper (result,voteKey) = (result + valueOrElse(getInteger(voteKey), 0)) | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | func countVotes (prefix) = { | |
72 | 72 | let votes = genVotesKeys(prefix)._1 | |
73 | 73 | let $l = votes | |
74 | 74 | let $s = size($l) | |
75 | 75 | let $acc0 = 0 | |
76 | 76 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
77 | 77 | then $a | |
78 | 78 | else countVotesHelper($a, $l[$i]) | |
79 | 79 | ||
80 | 80 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
81 | 81 | then $a | |
82 | 82 | else throw("List size exceeds 10") | |
83 | 83 | ||
84 | 84 | $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) | |
85 | 85 | } | |
86 | 86 | ||
87 | 87 | ||
88 | + | func clearVotesHelper (result,key) = (result :+ DeleteEntry(key)) | |
89 | + | ||
90 | + | ||
91 | + | func getClearVotesEntries (prefix) = { | |
92 | + | let votes = genVotesKeys(prefix)._1 | |
93 | + | let $l = votes | |
94 | + | let $s = size($l) | |
95 | + | let $acc0 = nil | |
96 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
97 | + | then $a | |
98 | + | else clearVotesHelper($a, $l[$i]) | |
99 | + | ||
100 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
101 | + | then $a | |
102 | + | else throw("List size exceeds 10") | |
103 | + | ||
104 | + | $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) | |
105 | + | } | |
106 | + | ||
107 | + | ||
88 | 108 | @Callable(i) | |
89 | 109 | func voteForNewManger (newManagerPublicKey) = { | |
90 | 110 | let callerAddressString = toBase58String(i.caller.bytes) | |
91 | 111 | if (isInAdminList(callerAddressString)) | |
92 | - | then nil | |
112 | + | then { | |
113 | + | let votes = countVotes(keySetNewManagerVotePrefix(newManagerPublicKey)) | |
114 | + | if (((votes + 1) > 1)) | |
115 | + | then { | |
116 | + | let clearVotesEntries = getClearVotesEntries(keySetNewManagerVotePrefix(newManagerPublicKey)) | |
117 | + | (clearVotesEntries ++ [StringEntry(keyPendingManagerPublicKey(), newManagerPublicKey)]) | |
118 | + | } | |
119 | + | else [IntegerEntry(keySetNewManagerVote(newManagerPublicKey, callerAddressString), 1)] | |
120 | + | } | |
93 | 121 | else throwErr((callerAddressString + ": not in Admin list")) | |
94 | 122 | } | |
95 | 123 | ||
96 | 124 |
github/deemru/w8io/026f985 23.75 ms ◑