tx · DyfEUMjxzzXeydsTn1xjZi2aKd7W1j91MeFiouDRgkVt 3N4ziXSMRverXyxHDUKKMR9MHXnB3TyU3Yh: -0.01000000 Waves 2023.04.18 17:14 [2540086] smart account 3N4ziXSMRverXyxHDUKKMR9MHXnB3TyU3Yh > SELF 0.00000000 Waves
{ "type": 13, "id": "DyfEUMjxzzXeydsTn1xjZi2aKd7W1j91MeFiouDRgkVt", "fee": 1000000, "feeAssetId": null, "timestamp": 1681827269097, "version": 2, "chainId": 84, "sender": "3N4ziXSMRverXyxHDUKKMR9MHXnB3TyU3Yh", "senderPublicKey": "EU9obW1yVhR8qug3EmXPeew3DMagvJFQzY5Ku8bmcsU7", "proofs": [ "4MTn8ZtdxaBvyUUWW1YK1TVXj8H5ZD3XmqhhyZ8Cu4KfTbBHDXxjLL5cA9LALq1dPfSQCSB6aQtQ2ZPjGb2LmBgZ" ], "script": "base64:BgILCAISABIDCgEIEgAVAANTRVACAl9fABBjb250cmFjdEZpbGVuYW1lAgl0ZXN0LnJpZGUBCHRocm93RXJyAQFzCQACAQkArAICCQCsAgIFEGNvbnRyYWN0RmlsZW5hbWUCAjogBQFzARlrZXlBY3RpdmVNYW5hZ2VyUHVibGljS2V5AAkAuQkCCQDMCAICAiVzCQDMCAICEG1hbmFnZXJQdWJsaWNLZXkFA25pbAUDU0VQARprZXlQZW5kaW5nTWFuYWdlclB1YmxpY0tleQAJALkJAgkAzAgCAgIlcwkAzAgCAhdwZW5kaW5nTWFuYWdlclB1YmxpY0tleQUDbmlsBQNTRVABHXBlbmRpbmdNYW5hZ2VyUHVibGljS2V5T3JVbml0AAQHJG1hdGNoMAkAoggBCQEaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkAAwkAAQIFByRtYXRjaDACBlN0cmluZwQBcwUHJG1hdGNoMAkA2QQBBQFzAwkAAQIFByRtYXRjaDACBFVuaXQFBHVuaXQJAAIBAgtNYXRjaCBlcnJvcgEaa2V5U2V0TmV3TWFuYWdlclZvdGVQ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kaW5nTWFuYWdlclN0cmluZwUDbmlsCQDMCAIJAQxJbnRlZ2VyRW50cnkCCQEYa2V5RGVhY3RpdmF0ZU1hbmFnZXJWb3RlAQUTY2FsbGVyQWRkcmVzc1N0cmluZwABBQNuaWwJAQh0aHJvd0VycgEJAKwCAgkArAICAglBZGRyZXNzOiAFE2NhbGxlckFkZHJlc3NTdHJpbmcCEiBub3QgaW4gQWRtaW4gbGlzdADdi2Bb", "height": 2540086, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4pNi8fwyVmUGrvB13YQSVJjJWRw1MJ56K5saNAbxj6v5 Next: AR6YkGR42shTBWuk6u8eBmFfXR5oPExJkGxYXmv6iGzo Diff:
Old | New | Differences | |
---|---|---|---|
11 | 11 | func keyActiveManagerPublicKey () = makeString(["%s", "managerPublicKey"], SEP) | |
12 | 12 | ||
13 | 13 | ||
14 | - | func | |
14 | + | func keyPendingManagerPublicKey () = makeString(["%s", "pendingManagerPublicKey"], SEP) | |
15 | 15 | ||
16 | 16 | ||
17 | - | func keyPendingManagerPublicKey () = makeString(["%s", "pendingManagerPublicKey"], SEP) | |
17 | + | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
18 | + | case s: String => | |
19 | + | fromBase58String(s) | |
20 | + | case _: Unit => | |
21 | + | unit | |
22 | + | case _ => | |
23 | + | throw("Match error") | |
24 | + | } | |
18 | 25 | ||
19 | 26 | ||
20 | 27 | func keySetNewManagerVotePrefix (managerPublicKey) = makeString(["%s%s%s", "setManager", managerPublicKey], SEP) | |
24 | 31 | ||
25 | 32 | ||
26 | 33 | func getSetNewManagerVote (managerPublicKey,admin) = valueOrElse(getInteger(keySetNewManagerVote(managerPublicKey, admin)), 0) | |
34 | + | ||
35 | + | ||
36 | + | func keyDeactivateManagerVotePrefix () = makeString(["%s%s", "deactivateManager"], SEP) | |
37 | + | ||
38 | + | ||
39 | + | func keyDeactivateManagerVote (admin) = makeString([keyDeactivateManagerVotePrefix(), admin], SEP) | |
40 | + | ||
41 | + | ||
42 | + | func getDeactivateManagerVote (admin) = valueOrElse(getInteger(keyDeactivateManagerVote(admin)), 0) | |
27 | 43 | ||
28 | 44 | ||
29 | 45 | func adminAdressList () = makeString(["%s", "adminAddressList"], SEP) | |
41 | 57 | ||
42 | 58 | ||
43 | 59 | func genVotesKeysHelper (lst,adminAddress) = { | |
44 | - | let $ | |
45 | - | let result = $ | |
46 | - | let prefix = $ | |
60 | + | let $t018291855 = lst | |
61 | + | let result = $t018291855._1 | |
62 | + | let prefix = $t018291855._2 | |
47 | 63 | $Tuple2((result :+ makeString([prefix, adminAddress], SEP)), prefix) | |
48 | 64 | } | |
49 | 65 | ||
106 | 122 | ||
107 | 123 | ||
108 | 124 | @Callable(i) | |
125 | + | func confirmManager () = { | |
126 | + | let pm = pendingManagerPublicKeyOrUnit() | |
127 | + | let hasPM = if (isDefined(pm)) | |
128 | + | then true | |
129 | + | else throwErr("no pending manager") | |
130 | + | if ((hasPM == hasPM)) | |
131 | + | then { | |
132 | + | let checkPM = if ((i.callerPublicKey == value(pm))) | |
133 | + | then true | |
134 | + | else throwErr("you are not pending manager") | |
135 | + | if ((checkPM == checkPM)) | |
136 | + | then [StringEntry(keyActiveManagerPublicKey(), toBase58String(value(pm)))] | |
137 | + | else throw("Strict value is not equal to itself.") | |
138 | + | } | |
139 | + | else throw("Strict value is not equal to itself.") | |
140 | + | } | |
141 | + | ||
142 | + | ||
143 | + | ||
144 | + | @Callable(i) | |
109 | 145 | func voteForNewManger (newManagerPublicKey) = { | |
110 | 146 | let callerAddressString = toBase58String(i.caller.bytes) | |
111 | 147 | if (isInAdminList(callerAddressString)) | |
112 | 148 | then if ((getSetNewManagerVote(newManagerPublicKey, callerAddressString) == 1)) | |
113 | - | then throwErr((((callerAddressString + ": ") + newManagerPublicKey) + " | |
149 | + | then throwErr((((("Address: " + callerAddressString) + " NewManager: ") + newManagerPublicKey) + " voteForNewManger() you already voted")) | |
114 | 150 | else { | |
115 | 151 | let votes = countVotes(keySetNewManagerVotePrefix(newManagerPublicKey)) | |
116 | 152 | if (((votes + 1) >= 2)) | |
120 | 156 | } | |
121 | 157 | else [IntegerEntry(keySetNewManagerVote(newManagerPublicKey, callerAddressString), 1)] | |
122 | 158 | } | |
123 | - | else throwErr((callerAddressString + ": not in Admin list")) | |
159 | + | else throwErr((("Address: " + callerAddressString) + " not in Admin list")) | |
160 | + | } | |
161 | + | ||
162 | + | ||
163 | + | ||
164 | + | @Callable(i) | |
165 | + | func deactivateManager () = { | |
166 | + | let callerAddressString = toBase58String(i.caller.bytes) | |
167 | + | let pendingManagerString = getStringValue(keyPendingManagerPublicKey()) | |
168 | + | if (isInAdminList(callerAddressString)) | |
169 | + | then if ((getDeactivateManagerVote(callerAddressString) == 1)) | |
170 | + | then throwErr((("Address: " + callerAddressString) + " deactivateManager() you already voted")) | |
171 | + | else { | |
172 | + | let votes = countVotes(keyDeactivateManagerVotePrefix()) | |
173 | + | if (((votes + 1) >= 1)) | |
174 | + | then { | |
175 | + | let clearVotesEntries = getClearVotesEntries(keyDeactivateManagerVotePrefix()) | |
176 | + | (clearVotesEntries ++ [StringEntry(keyActiveManagerPublicKey(), pendingManagerString)]) | |
177 | + | } | |
178 | + | else [IntegerEntry(keyDeactivateManagerVote(callerAddressString), 1)] | |
179 | + | } | |
180 | + | else throwErr((("Address: " + callerAddressString) + " not in Admin list")) | |
124 | 181 | } | |
125 | 182 | ||
126 | 183 |
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 | - | func | |
14 | + | func keyPendingManagerPublicKey () = makeString(["%s", "pendingManagerPublicKey"], SEP) | |
15 | 15 | ||
16 | 16 | ||
17 | - | func keyPendingManagerPublicKey () = makeString(["%s", "pendingManagerPublicKey"], SEP) | |
17 | + | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
18 | + | case s: String => | |
19 | + | fromBase58String(s) | |
20 | + | case _: Unit => | |
21 | + | unit | |
22 | + | case _ => | |
23 | + | throw("Match error") | |
24 | + | } | |
18 | 25 | ||
19 | 26 | ||
20 | 27 | func keySetNewManagerVotePrefix (managerPublicKey) = makeString(["%s%s%s", "setManager", managerPublicKey], SEP) | |
21 | 28 | ||
22 | 29 | ||
23 | 30 | func keySetNewManagerVote (managerPublicKey,admin) = makeString([keySetNewManagerVotePrefix(managerPublicKey), admin], SEP) | |
24 | 31 | ||
25 | 32 | ||
26 | 33 | func getSetNewManagerVote (managerPublicKey,admin) = valueOrElse(getInteger(keySetNewManagerVote(managerPublicKey, admin)), 0) | |
34 | + | ||
35 | + | ||
36 | + | func keyDeactivateManagerVotePrefix () = makeString(["%s%s", "deactivateManager"], SEP) | |
37 | + | ||
38 | + | ||
39 | + | func keyDeactivateManagerVote (admin) = makeString([keyDeactivateManagerVotePrefix(), admin], SEP) | |
40 | + | ||
41 | + | ||
42 | + | func getDeactivateManagerVote (admin) = valueOrElse(getInteger(keyDeactivateManagerVote(admin)), 0) | |
27 | 43 | ||
28 | 44 | ||
29 | 45 | func adminAdressList () = makeString(["%s", "adminAddressList"], SEP) | |
30 | 46 | ||
31 | 47 | ||
32 | 48 | func getAdminsList () = split(valueOrElse(getString(this, adminAdressList()), ""), SEP) | |
33 | 49 | ||
34 | 50 | ||
35 | 51 | func isInAdminList (address) = match indexOf(getAdminsList(), address) { | |
36 | 52 | case t: Int => | |
37 | 53 | true | |
38 | 54 | case _ => | |
39 | 55 | false | |
40 | 56 | } | |
41 | 57 | ||
42 | 58 | ||
43 | 59 | func genVotesKeysHelper (lst,adminAddress) = { | |
44 | - | let $ | |
45 | - | let result = $ | |
46 | - | let prefix = $ | |
60 | + | let $t018291855 = lst | |
61 | + | let result = $t018291855._1 | |
62 | + | let prefix = $t018291855._2 | |
47 | 63 | $Tuple2((result :+ makeString([prefix, adminAddress], SEP)), prefix) | |
48 | 64 | } | |
49 | 65 | ||
50 | 66 | ||
51 | 67 | func genVotesKeys (keyPrefix) = { | |
52 | 68 | let adminList = adminAdressList() | |
53 | 69 | let $l = getAdminsList() | |
54 | 70 | let $s = size($l) | |
55 | 71 | let $acc0 = $Tuple2(nil, keyPrefix) | |
56 | 72 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
57 | 73 | then $a | |
58 | 74 | else genVotesKeysHelper($a, $l[$i]) | |
59 | 75 | ||
60 | 76 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
61 | 77 | then $a | |
62 | 78 | else throw("List size exceeds 10") | |
63 | 79 | ||
64 | 80 | $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 | 81 | } | |
66 | 82 | ||
67 | 83 | ||
68 | 84 | func countVotesHelper (result,voteKey) = (result + valueOrElse(getInteger(voteKey), 0)) | |
69 | 85 | ||
70 | 86 | ||
71 | 87 | func countVotes (prefix) = { | |
72 | 88 | let votes = genVotesKeys(prefix)._1 | |
73 | 89 | let $l = votes | |
74 | 90 | let $s = size($l) | |
75 | 91 | let $acc0 = 0 | |
76 | 92 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
77 | 93 | then $a | |
78 | 94 | else countVotesHelper($a, $l[$i]) | |
79 | 95 | ||
80 | 96 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
81 | 97 | then $a | |
82 | 98 | else throw("List size exceeds 10") | |
83 | 99 | ||
84 | 100 | $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 | 101 | } | |
86 | 102 | ||
87 | 103 | ||
88 | 104 | func clearVotesHelper (result,key) = (result :+ DeleteEntry(key)) | |
89 | 105 | ||
90 | 106 | ||
91 | 107 | func getClearVotesEntries (prefix) = { | |
92 | 108 | let votes = genVotesKeys(prefix)._1 | |
93 | 109 | let $l = votes | |
94 | 110 | let $s = size($l) | |
95 | 111 | let $acc0 = nil | |
96 | 112 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
97 | 113 | then $a | |
98 | 114 | else clearVotesHelper($a, $l[$i]) | |
99 | 115 | ||
100 | 116 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
101 | 117 | then $a | |
102 | 118 | else throw("List size exceeds 10") | |
103 | 119 | ||
104 | 120 | $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 | 121 | } | |
106 | 122 | ||
107 | 123 | ||
108 | 124 | @Callable(i) | |
125 | + | func confirmManager () = { | |
126 | + | let pm = pendingManagerPublicKeyOrUnit() | |
127 | + | let hasPM = if (isDefined(pm)) | |
128 | + | then true | |
129 | + | else throwErr("no pending manager") | |
130 | + | if ((hasPM == hasPM)) | |
131 | + | then { | |
132 | + | let checkPM = if ((i.callerPublicKey == value(pm))) | |
133 | + | then true | |
134 | + | else throwErr("you are not pending manager") | |
135 | + | if ((checkPM == checkPM)) | |
136 | + | then [StringEntry(keyActiveManagerPublicKey(), toBase58String(value(pm)))] | |
137 | + | else throw("Strict value is not equal to itself.") | |
138 | + | } | |
139 | + | else throw("Strict value is not equal to itself.") | |
140 | + | } | |
141 | + | ||
142 | + | ||
143 | + | ||
144 | + | @Callable(i) | |
109 | 145 | func voteForNewManger (newManagerPublicKey) = { | |
110 | 146 | let callerAddressString = toBase58String(i.caller.bytes) | |
111 | 147 | if (isInAdminList(callerAddressString)) | |
112 | 148 | then if ((getSetNewManagerVote(newManagerPublicKey, callerAddressString) == 1)) | |
113 | - | then throwErr((((callerAddressString + ": ") + newManagerPublicKey) + " | |
149 | + | then throwErr((((("Address: " + callerAddressString) + " NewManager: ") + newManagerPublicKey) + " voteForNewManger() you already voted")) | |
114 | 150 | else { | |
115 | 151 | let votes = countVotes(keySetNewManagerVotePrefix(newManagerPublicKey)) | |
116 | 152 | if (((votes + 1) >= 2)) | |
117 | 153 | then { | |
118 | 154 | let clearVotesEntries = getClearVotesEntries(keySetNewManagerVotePrefix(newManagerPublicKey)) | |
119 | 155 | (clearVotesEntries ++ [StringEntry(keyPendingManagerPublicKey(), newManagerPublicKey)]) | |
120 | 156 | } | |
121 | 157 | else [IntegerEntry(keySetNewManagerVote(newManagerPublicKey, callerAddressString), 1)] | |
122 | 158 | } | |
123 | - | else throwErr((callerAddressString + ": not in Admin list")) | |
159 | + | else throwErr((("Address: " + callerAddressString) + " not in Admin list")) | |
160 | + | } | |
161 | + | ||
162 | + | ||
163 | + | ||
164 | + | @Callable(i) | |
165 | + | func deactivateManager () = { | |
166 | + | let callerAddressString = toBase58String(i.caller.bytes) | |
167 | + | let pendingManagerString = getStringValue(keyPendingManagerPublicKey()) | |
168 | + | if (isInAdminList(callerAddressString)) | |
169 | + | then if ((getDeactivateManagerVote(callerAddressString) == 1)) | |
170 | + | then throwErr((("Address: " + callerAddressString) + " deactivateManager() you already voted")) | |
171 | + | else { | |
172 | + | let votes = countVotes(keyDeactivateManagerVotePrefix()) | |
173 | + | if (((votes + 1) >= 1)) | |
174 | + | then { | |
175 | + | let clearVotesEntries = getClearVotesEntries(keyDeactivateManagerVotePrefix()) | |
176 | + | (clearVotesEntries ++ [StringEntry(keyActiveManagerPublicKey(), pendingManagerString)]) | |
177 | + | } | |
178 | + | else [IntegerEntry(keyDeactivateManagerVote(callerAddressString), 1)] | |
179 | + | } | |
180 | + | else throwErr((("Address: " + callerAddressString) + " not in Admin list")) | |
124 | 181 | } | |
125 | 182 | ||
126 | 183 |
github/deemru/w8io/026f985 32.29 ms ◑