tx · 2YfvDASrDncA3vvQYGybYuFy6KQx1LxoiZryUDKi3B1r 3N6oQmUanp4TWuHnv5rma4WveVub63JRFB2: -0.01000000 Waves 2023.07.11 12:26 [2661065] smart account 3N6oQmUanp4TWuHnv5rma4WveVub63JRFB2 > SELF 0.00000000 Waves
{ "type": 13, "id": "2YfvDASrDncA3vvQYGybYuFy6KQx1LxoiZryUDKi3B1r", "fee": 1000000, "feeAssetId": null, "timestamp": 1689067602905, "version": 2, "chainId": 84, "sender": "3N6oQmUanp4TWuHnv5rma4WveVub63JRFB2", "senderPublicKey": "EM2pooK6eEzhzFXZFGd2phMRus6f1M5GxBsawNk9oi37", "proofs": [ "5ZCkXDPknqA4HsegJBNGz9Xe6DMdtZEUz75rg7v6vcZS47cpQdHTZFBNu2uz4EMgeQT9dhCmX7nLWVJgu4PvuYYp" ], "script": "base64:BgIbCAISBAoCCAESBAoCAQESBgoECAEBGBIDCgEBLgEVa2V5VXNlckd3bFJlbGVhc2VUaW1lAQh1c2VyQWRkcgkArAICAholcyVzX191c2VyR3dsUmVsZWFzZVRpbWVfXwUIdXNlckFkZHIABWNoYWluCQDJAQIJAMoBAggFBHRoaXMFYnl0ZXMAAQABABVkZWZhdWx0UmVzdEFkZHJlc3NTdHIEByRtYXRjaDAFBWNoYWluAwkAAAIBAVcFByRtYXRjaDACIzNQUUN1dkZidmg0TGtQVW5yblUxejNqbmJBMXA5bTNXTmh2AwkAAAIBAVQFByRtYXRjaDACIzNNdW1rR0d6dENLQVhwV0RxeGtkZG9mcVhTVWJxUWt2U0p5CQACAQINVW5rbm93biBjaGFpbgADU0VQAgJfXwAFTVVMVDYAwIQ9AQ9nZXRTdHJpbmdPckZhaWwCB2FkZHJlc3MDa2V5CQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJ0IAgUHYWRkcmVzcwUDa2V5CQC5CQIJAMwIAgIKbWFuZGF0b3J5IAkAzAgCCQClCAEFB2FkZHJlc3MJAMwIAgIBLgkAzAgCBQNrZXkJAMw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"spentComplexity": 0 } View: original | compacted Prev: 53M6FQUSbp5Y1Zxr2eRXfquntmLipG9eGNbnmF4fxjug Next: 894rLDLpprUyKeihGhviW3gcHKKmcgxuAXhLvTGBcHWS Diff:
Old | New | Differences | |
---|---|---|---|
18 | 18 | let SEP = "__" | |
19 | 19 | ||
20 | 20 | let MULT6 = 1000000 | |
21 | - | ||
22 | - | let SSIZE = 25 | |
23 | - | ||
24 | - | let MSIZE = 100 | |
25 | - | ||
26 | - | let LSIZE = 225 | |
27 | - | ||
28 | - | let XLSIZE = 400 | |
29 | - | ||
30 | - | let XXLSIZE = 625 | |
31 | 21 | ||
32 | 22 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
33 | 23 | ||
55 | 45 | ||
56 | 46 | let stakingContract = getContractAddressOrFail(restCfg, IdxCfgStakingDapp) | |
57 | 47 | ||
58 | - | let recLandSize = 1 | |
59 | - | ||
60 | 48 | let IdxEffTotal = 0 | |
61 | 49 | ||
62 | 50 | let IdxEffUser = 1 | |
64 | 52 | func keyResProportions () = "resTypesProportions" | |
65 | 53 | ||
66 | 54 | ||
67 | - | func keyStakedLandsByOwner (ownerAddr) = ("stakedLandsByOwner_" + ownerAddr) | |
68 | - | ||
69 | - | ||
70 | - | func numPiecesBySize (landSize) = match landSize { | |
71 | - | case _ => | |
72 | - | if (("S" == $match0)) | |
73 | - | then SSIZE | |
74 | - | else if (("M" == $match0)) | |
75 | - | then MSIZE | |
76 | - | else if (("L" == $match0)) | |
77 | - | then LSIZE | |
78 | - | else if (("XL" == $match0)) | |
79 | - | then XLSIZE | |
80 | - | else if (("XXL" == $match0)) | |
81 | - | then XXLSIZE | |
82 | - | else throw("Unknown land size") | |
83 | - | } | |
55 | + | func keyStakedPiecesByOwner (ownerAddr) = ("stakedPiecesByOwner_" + ownerAddr) | |
84 | 56 | ||
85 | 57 | ||
86 | 58 | func getVotingPower (userAddrStrOrEmpty) = { | |
101 | 73 | ||
102 | 74 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6) | |
103 | 75 | } | |
104 | - | let usersPower = if ((userAddrStrOrEmpty == "")) | |
105 | - | then 0 | |
106 | - | else { | |
107 | - | let landsStr = getString(stakingContract, keyStakedLandsByOwner(userAddrStrOrEmpty)) | |
108 | - | let lands = if (isDefined(landsStr)) | |
109 | - | then split_51C(value(landsStr), "_") | |
110 | - | else nil | |
111 | - | func oneLand (acc,landAssetId) = { | |
112 | - | let asset = value(assetInfo(fromBase58String(landAssetId))) | |
113 | - | let landSize = split(asset.description, "_")[recLandSize] | |
114 | - | (acc + numPiecesBySize(landSize)) | |
115 | - | } | |
116 | - | ||
117 | - | let $l = lands | |
118 | - | let $s = size($l) | |
119 | - | let $acc0 = 0 | |
120 | - | func $f1_1 ($a,$i) = if (($i >= $s)) | |
121 | - | then $a | |
122 | - | else oneLand($a, $l[$i]) | |
123 | - | ||
124 | - | func $f1_2 ($a,$i) = if (($i >= $s)) | |
125 | - | then $a | |
126 | - | else throw("List size exceeds 100") | |
127 | - | ||
128 | - | $f1_2($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40), 41), 42), 43), 44), 45), 46), 47), 48), 49), 50), 51), 52), 53), 54), 55), 56), 57), 58), 59), 60), 61), 62), 63), 64), 65), 66), 67), 68), 69), 70), 71), 72), 73), 74), 75), 76), 77), 78), 79), 80), 81), 82), 83), 84), 85), 86), 87), 88), 89), 90), 91), 92), 93), 94), 95), 96), 97), 98), 99), 100) | |
129 | - | } | |
76 | + | let usersPower = valueOrElse(getInteger(stakingContract, keyStakedPiecesByOwner(userAddrStrOrEmpty)), 0) | |
130 | 77 | [totalPower, usersPower] | |
131 | 78 | } | |
132 | 79 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func keyUserGwlReleaseTime (userAddr) = ("%s%s__userGwlReleaseTime__" + userAddr) | |
5 | 5 | ||
6 | 6 | ||
7 | 7 | let chain = take(drop(this.bytes, 1), 1) | |
8 | 8 | ||
9 | 9 | let defaultRestAddressStr = match chain { | |
10 | 10 | case _ => | |
11 | 11 | if ((base58'2W' == $match0)) | |
12 | 12 | then "3PQCuvFbvh4LkPUnrnU1z3jnbA1p9m3WNhv" | |
13 | 13 | else if ((base58'2T' == $match0)) | |
14 | 14 | then "3MumkGGztCKAXpWDqxkddofqXSUbqQkvSJy" | |
15 | 15 | else throw("Unknown chain") | |
16 | 16 | } | |
17 | 17 | ||
18 | 18 | let SEP = "__" | |
19 | 19 | ||
20 | 20 | let MULT6 = 1000000 | |
21 | - | ||
22 | - | let SSIZE = 25 | |
23 | - | ||
24 | - | let MSIZE = 100 | |
25 | - | ||
26 | - | let LSIZE = 225 | |
27 | - | ||
28 | - | let XLSIZE = 400 | |
29 | - | ||
30 | - | let XXLSIZE = 625 | |
31 | 21 | ||
32 | 22 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
33 | 23 | ||
34 | 24 | ||
35 | 25 | func getIntOrElse (key,defaultVal) = valueOrElse(getInteger(this, key), defaultVal) | |
36 | 26 | ||
37 | 27 | ||
38 | 28 | let IdxCfgStakingDapp = 1 | |
39 | 29 | ||
40 | 30 | func keyRestCfg () = "%s__restConfig" | |
41 | 31 | ||
42 | 32 | ||
43 | 33 | func keyRestAddress () = "%s__restAddr" | |
44 | 34 | ||
45 | 35 | ||
46 | 36 | func readRestCfgOrFail (rest) = split_4C(getStringOrFail(rest, keyRestCfg()), SEP) | |
47 | 37 | ||
48 | 38 | ||
49 | 39 | func getContractAddressOrFail (restCfg,idx) = valueOrErrorMessage(addressFromString(restCfg[idx]), ("Rest cfg doesn't contain address at index " + toString(idx))) | |
50 | 40 | ||
51 | 41 | ||
52 | 42 | let restContract = addressFromStringValue(valueOrElse(getString(this, keyRestAddress()), defaultRestAddressStr)) | |
53 | 43 | ||
54 | 44 | let restCfg = readRestCfgOrFail(restContract) | |
55 | 45 | ||
56 | 46 | let stakingContract = getContractAddressOrFail(restCfg, IdxCfgStakingDapp) | |
57 | 47 | ||
58 | - | let recLandSize = 1 | |
59 | - | ||
60 | 48 | let IdxEffTotal = 0 | |
61 | 49 | ||
62 | 50 | let IdxEffUser = 1 | |
63 | 51 | ||
64 | 52 | func keyResProportions () = "resTypesProportions" | |
65 | 53 | ||
66 | 54 | ||
67 | - | func keyStakedLandsByOwner (ownerAddr) = ("stakedLandsByOwner_" + ownerAddr) | |
68 | - | ||
69 | - | ||
70 | - | func numPiecesBySize (landSize) = match landSize { | |
71 | - | case _ => | |
72 | - | if (("S" == $match0)) | |
73 | - | then SSIZE | |
74 | - | else if (("M" == $match0)) | |
75 | - | then MSIZE | |
76 | - | else if (("L" == $match0)) | |
77 | - | then LSIZE | |
78 | - | else if (("XL" == $match0)) | |
79 | - | then XLSIZE | |
80 | - | else if (("XXL" == $match0)) | |
81 | - | then XXLSIZE | |
82 | - | else throw("Unknown land size") | |
83 | - | } | |
55 | + | func keyStakedPiecesByOwner (ownerAddr) = ("stakedPiecesByOwner_" + ownerAddr) | |
84 | 56 | ||
85 | 57 | ||
86 | 58 | func getVotingPower (userAddrStrOrEmpty) = { | |
87 | 59 | let props = split(valueOrElse(getString(stakingContract, keyResProportions()), "0_0_0_0_0_0"), "_") | |
88 | 60 | func adder (acc,item) = (acc + parseIntValue(item)) | |
89 | 61 | ||
90 | 62 | let totalPower = { | |
91 | 63 | let $l = props | |
92 | 64 | let $s = size($l) | |
93 | 65 | let $acc0 = 0 | |
94 | 66 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
95 | 67 | then $a | |
96 | 68 | else adder($a, $l[$i]) | |
97 | 69 | ||
98 | 70 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
99 | 71 | then $a | |
100 | 72 | else throw("List size exceeds 6") | |
101 | 73 | ||
102 | 74 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6) | |
103 | 75 | } | |
104 | - | let usersPower = if ((userAddrStrOrEmpty == "")) | |
105 | - | then 0 | |
106 | - | else { | |
107 | - | let landsStr = getString(stakingContract, keyStakedLandsByOwner(userAddrStrOrEmpty)) | |
108 | - | let lands = if (isDefined(landsStr)) | |
109 | - | then split_51C(value(landsStr), "_") | |
110 | - | else nil | |
111 | - | func oneLand (acc,landAssetId) = { | |
112 | - | let asset = value(assetInfo(fromBase58String(landAssetId))) | |
113 | - | let landSize = split(asset.description, "_")[recLandSize] | |
114 | - | (acc + numPiecesBySize(landSize)) | |
115 | - | } | |
116 | - | ||
117 | - | let $l = lands | |
118 | - | let $s = size($l) | |
119 | - | let $acc0 = 0 | |
120 | - | func $f1_1 ($a,$i) = if (($i >= $s)) | |
121 | - | then $a | |
122 | - | else oneLand($a, $l[$i]) | |
123 | - | ||
124 | - | func $f1_2 ($a,$i) = if (($i >= $s)) | |
125 | - | then $a | |
126 | - | else throw("List size exceeds 100") | |
127 | - | ||
128 | - | $f1_2($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40), 41), 42), 43), 44), 45), 46), 47), 48), 49), 50), 51), 52), 53), 54), 55), 56), 57), 58), 59), 60), 61), 62), 63), 64), 65), 66), 67), 68), 69), 70), 71), 72), 73), 74), 75), 76), 77), 78), 79), 80), 81), 82), 83), 84), 85), 86), 87), 88), 89), 90), 91), 92), 93), 94), 95), 96), 97), 98), 99), 100) | |
129 | - | } | |
76 | + | let usersPower = valueOrElse(getInteger(stakingContract, keyStakedPiecesByOwner(userAddrStrOrEmpty)), 0) | |
130 | 77 | [totalPower, usersPower] | |
131 | 78 | } | |
132 | 79 | ||
133 | 80 | ||
134 | 81 | let LISTSEP = ":" | |
135 | 82 | ||
136 | 83 | let DEFAULTQUORUM = 500000 | |
137 | 84 | ||
138 | 85 | let MAXTITLE = 250 | |
139 | 86 | ||
140 | 87 | let MAXVOTINGTIME = 1209600000 | |
141 | 88 | ||
142 | 89 | let DEFAULTFIRSTPROPOSAL = 1 | |
143 | 90 | ||
144 | 91 | let govIdxStart = 4 | |
145 | 92 | ||
146 | 93 | let govIdxEnd = 5 | |
147 | 94 | ||
148 | 95 | let govIdxQuorum = 6 | |
149 | 96 | ||
150 | 97 | let govIdxOptions = 7 | |
151 | 98 | ||
152 | 99 | let govStatusIdxTotalVotes = 4 | |
153 | 100 | ||
154 | 101 | let govStatusIdxIsCanceled = 5 | |
155 | 102 | ||
156 | 103 | func keyQuorumRequiredPercent () = "%s__quorumRequired" | |
157 | 104 | ||
158 | 105 | ||
159 | 106 | func keyLastProposalId () = "%s__proposalId" | |
160 | 107 | ||
161 | 108 | ||
162 | 109 | func keyFirstProposalId () = "%s__firstProposalId" | |
163 | 110 | ||
164 | 111 | ||
165 | 112 | func keyProposalStatusDataById (proposalId) = ("%s%d__proposalStatusData__" + toString(proposalId)) | |
166 | 113 | ||
167 | 114 | ||
168 | 115 | func keyProposalDataById (proposalId) = ("%s%d__proposalData__" + toString(proposalId)) | |
169 | 116 | ||
170 | 117 | ||
171 | 118 | func keyProposalVotesByIdAndOption (proposalId,opt) = makeString(["%s%d%d", "votesByOpt", toString(proposalId), toString(opt)], SEP) | |
172 | 119 | ||
173 | 120 | ||
174 | 121 | func keyProposalVotesByIdAndUser (proposalId,userAddr) = makeString(["%s%d%s", "votesByUser", toString(proposalId), userAddr], SEP) | |
175 | 122 | ||
176 | 123 | ||
177 | 124 | func keyProposalChoiceByIdAndUser (proposalId,userAddr) = makeString(["%s%d%s", "optionByUser", toString(proposalId), userAddr], SEP) | |
178 | 125 | ||
179 | 126 | ||
180 | 127 | func keyNumUniqueVotersByProposalId (proposalId) = ("%s%d__numVoters__" + toString(proposalId)) | |
181 | 128 | ||
182 | 129 | ||
183 | 130 | func keyStatsAverUniqueVoters () = "%s%s%s__stats__avg__uniqueVoters" | |
184 | 131 | ||
185 | 132 | ||
186 | 133 | func keyStatsAverGwlVoted () = "%s%s%s__stats__avg__gwlVoted" | |
187 | 134 | ||
188 | 135 | ||
189 | 136 | func statusData (isVotingValid,winOption,winOptionVotes,totalVotes,canceledByTeam) = makeString(["%b%d%d%d%b", toString(isVotingValid), toString(winOption), toString(winOptionVotes), toString(totalVotes), toString(canceledByTeam)], SEP) | |
190 | 137 | ||
191 | 138 | ||
192 | 139 | func proposalData (proposalTxId,title,proposalTime,votingStartTime,votingEndTime,quorumInGwl,options) = makeString_2C(["%s%s%d%d%d%d%s", proposalTxId, title, toString(proposalTime), toString(votingStartTime), toString(votingEndTime), toString(quorumInGwl), options], SEP) | |
193 | 140 | ||
194 | 141 | ||
195 | 142 | func calcWinOption (proposalId,optionsList,isPrevOptional,oldChoice,optionalTotalOld,newChoice,newTotalByNewChoice) = { | |
196 | 143 | func findBest (acc,elem) = { | |
197 | 144 | let idx = value(indexOf(optionsList, elem)) | |
198 | 145 | let val = if (isPrevOptional) | |
199 | 146 | then if ((idx == newChoice)) | |
200 | 147 | then newTotalByNewChoice | |
201 | 148 | else getIntOrElse(keyProposalVotesByIdAndOption(proposalId, idx), 0) | |
202 | 149 | else if ((idx == value(oldChoice))) | |
203 | 150 | then optionalTotalOld | |
204 | 151 | else if ((idx == newChoice)) | |
205 | 152 | then newTotalByNewChoice | |
206 | 153 | else getIntOrElse(keyProposalVotesByIdAndOption(proposalId, idx), 0) | |
207 | 154 | if ((acc._2 > val)) | |
208 | 155 | then acc | |
209 | 156 | else $Tuple2(idx, val) | |
210 | 157 | } | |
211 | 158 | ||
212 | 159 | let $l = optionsList | |
213 | 160 | let $s = size($l) | |
214 | 161 | let $acc0 = $Tuple2(0, 0) | |
215 | 162 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
216 | 163 | then $a | |
217 | 164 | else findBest($a, $l[$i]) | |
218 | 165 | ||
219 | 166 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
220 | 167 | then $a | |
221 | 168 | else throw("List size exceeds 10") | |
222 | 169 | ||
223 | 170 | $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) | |
224 | 171 | } | |
225 | 172 | ||
226 | 173 | ||
227 | 174 | func updateStatusData (isCanceledStr,isValid,newWinOpt,newTotalVotes) = makeString(["%b%d%d%d%b", toString(isValid), toString(newWinOpt._1), toString(newWinOpt._2), toString(newTotalVotes), isCanceledStr], SEP) | |
228 | 175 | ||
229 | 176 | ||
230 | 177 | @Callable(i) | |
231 | 178 | func constructorV1 (restAddr,quorumReqPerc) = if ((i.caller != this)) | |
232 | 179 | then throw("Permission denied") | |
233 | 180 | else [StringEntry(keyRestAddress(), restAddr), IntegerEntry(keyQuorumRequiredPercent(), quorumReqPerc)] | |
234 | 181 | ||
235 | 182 | ||
236 | 183 | ||
237 | 184 | @Callable(i) | |
238 | 185 | func castVote (proposalId,choice) = { | |
239 | 186 | let userAddressStr = toString(i.caller) | |
240 | 187 | let dynamicData = split(getStringOrFail(this, keyProposalStatusDataById(proposalId)), SEP) | |
241 | 188 | if ((dynamicData[govStatusIdxIsCanceled] == "true")) | |
242 | 189 | then throw("Voting is canceled by team") | |
243 | 190 | else { | |
244 | 191 | let propData = split_4C(getStringOrFail(this, keyProposalDataById(proposalId)), SEP) | |
245 | 192 | let start = parseIntValue(propData[govIdxStart]) | |
246 | 193 | let end = parseIntValue(propData[govIdxEnd]) | |
247 | 194 | let now = lastBlock.timestamp | |
248 | 195 | if ((start > now)) | |
249 | 196 | then throw("Voting not started yet") | |
250 | 197 | else if ((now >= end)) | |
251 | 198 | then throw("Voting already finished") | |
252 | 199 | else { | |
253 | 200 | let availableOptions = split(propData[govIdxOptions], LISTSEP) | |
254 | 201 | let numOptions = size(availableOptions) | |
255 | 202 | if ((1 >= numOptions)) | |
256 | 203 | then throw("Too few choices to vote") | |
257 | 204 | else if ((choice >= numOptions)) | |
258 | 205 | then throw(("Unknown choice! Must be 0.." + toString((numOptions - 1)))) | |
259 | 206 | else { | |
260 | 207 | let eff = getVotingPower(userAddressStr) | |
261 | 208 | let gwlAmt = eff[IdxEffUser] | |
262 | 209 | if ((0 >= gwlAmt)) | |
263 | 210 | then throw("You need staked lands to vote") | |
264 | 211 | else { | |
265 | 212 | let gwlTotal = eff[IdxEffTotal] | |
266 | 213 | let oldChoice = getInteger(keyProposalChoiceByIdAndUser(proposalId, userAddressStr)) | |
267 | 214 | let oldUserVotes = if (!(isDefined(oldChoice))) | |
268 | 215 | then 0 | |
269 | 216 | else getIntOrElse(keyProposalVotesByIdAndUser(proposalId, userAddressStr), 0) | |
270 | 217 | let oldTotalByOldChoice = if (isDefined(oldChoice)) | |
271 | 218 | then getIntOrElse(keyProposalVotesByIdAndOption(proposalId, value(oldChoice)), 0) | |
272 | 219 | else 0 | |
273 | 220 | let oldTotalByNewChoice = getIntOrElse(keyProposalVotesByIdAndOption(proposalId, choice), 0) | |
274 | 221 | let oldTotal = parseIntValue(dynamicData[govStatusIdxTotalVotes]) | |
275 | 222 | let newTotalByOldChoice = if (!(isDefined(oldChoice))) | |
276 | 223 | then 0 | |
277 | 224 | else ((oldTotalByOldChoice - oldUserVotes) + (if ((value(oldChoice) == choice)) | |
278 | 225 | then gwlAmt | |
279 | 226 | else 0)) | |
280 | 227 | let newTotalByNewChoice = if (if (isDefined(oldChoice)) | |
281 | 228 | then (value(oldChoice) == choice) | |
282 | 229 | else false) | |
283 | 230 | then newTotalByOldChoice | |
284 | 231 | else (oldTotalByNewChoice + gwlAmt) | |
285 | 232 | let newTotal = ((oldTotal - oldUserVotes) + gwlAmt) | |
286 | 233 | let isQuorumReached = (newTotal >= parseIntValue(propData[govIdxQuorum])) | |
287 | 234 | let numVotersByProposalId = getIntOrElse(keyNumUniqueVotersByProposalId(proposalId), 0) | |
288 | 235 | let oldAverUniqueVoters6 = getIntOrElse(keyStatsAverUniqueVoters(), 0) | |
289 | 236 | let numProposals = ((getIntegerValue(keyLastProposalId()) - valueOrElse(getInteger(keyFirstProposalId()), DEFAULTFIRSTPROPOSAL)) + 1) | |
290 | 237 | let uniqueDiff = if ((oldUserVotes == 0)) | |
291 | 238 | then 1 | |
292 | 239 | else 0 | |
293 | 240 | let newAverUniqueVoters6 = (oldAverUniqueVoters6 + fraction(uniqueDiff, MULT6, numProposals)) | |
294 | 241 | let oldAverGwl = getIntOrElse(keyStatsAverGwlVoted(), 0) | |
295 | 242 | let newAverGwl = (oldAverGwl + ((gwlAmt - oldUserVotes) / numProposals)) | |
296 | 243 | let isPrevOptional = if (!(isDefined(oldChoice))) | |
297 | 244 | then true | |
298 | 245 | else (value(oldChoice) == choice) | |
299 | 246 | let optionalTotalOld = if (isPrevOptional) | |
300 | 247 | then nil | |
301 | 248 | else [IntegerEntry(keyProposalVotesByIdAndOption(proposalId, value(oldChoice)), newTotalByOldChoice)] | |
302 | 249 | let winOpt = calcWinOption(proposalId, availableOptions, isPrevOptional, oldChoice, newTotalByOldChoice, choice, newTotalByNewChoice) | |
303 | 250 | let releaseTime = max([end, getIntOrElse(keyUserGwlReleaseTime(userAddressStr), 0)]) | |
304 | 251 | $Tuple2(([IntegerEntry(keyProposalChoiceByIdAndUser(proposalId, userAddressStr), choice), IntegerEntry(keyProposalVotesByIdAndUser(proposalId, userAddressStr), gwlAmt), IntegerEntry(keyProposalVotesByIdAndOption(proposalId, choice), newTotalByNewChoice), IntegerEntry(keyNumUniqueVotersByProposalId(proposalId), (numVotersByProposalId + uniqueDiff)), IntegerEntry(keyUserGwlReleaseTime(userAddressStr), releaseTime), IntegerEntry(keyStatsAverUniqueVoters(), newAverUniqueVoters6), IntegerEntry(keyStatsAverGwlVoted(), newAverGwl), StringEntry(keyProposalStatusDataById(proposalId), updateStatusData(dynamicData[govStatusIdxIsCanceled], isQuorumReached, winOpt, newTotal))] ++ optionalTotalOld), unit) | |
305 | 252 | } | |
306 | 253 | } | |
307 | 254 | } | |
308 | 255 | } | |
309 | 256 | } | |
310 | 257 | ||
311 | 258 | ||
312 | 259 | ||
313 | 260 | @Callable(i) | |
314 | 261 | func initiateVoting (title,votingStartTime,votingEndTime,optionsList) = if ((i.caller != this)) | |
315 | 262 | then throw("Permission denied") | |
316 | 263 | else if ((size(i.payments) != 0)) | |
317 | 264 | then throw("governance doesn't require any payments") | |
318 | 265 | else { | |
319 | 266 | let proposalTxId = toBase58String(i.transactionId) | |
320 | 267 | if ((title == "")) | |
321 | 268 | then throw("Title is empty") | |
322 | 269 | else if ((size(title) > MAXTITLE)) | |
323 | 270 | then throw("Too long title") | |
324 | 271 | else { | |
325 | 272 | let proposalTime = lastBlock.timestamp | |
326 | 273 | if ((proposalTime > votingStartTime)) | |
327 | 274 | then throw(((("votingStartTime=" + toString(votingStartTime)) + " < proposalTime=") + toString(proposalTime))) | |
328 | 275 | else if ((votingStartTime > votingEndTime)) | |
329 | 276 | then throw(((("votingEndTime=" + toString(votingEndTime)) + " < votingStartTime=") + toString(votingStartTime))) | |
330 | 277 | else if (((votingEndTime - votingStartTime) > MAXVOTINGTIME)) | |
331 | 278 | then throw(((("Voting period exceeds max: " + toString((votingEndTime - votingStartTime))) + " > ") + toString(MAXVOTINGTIME))) | |
332 | 279 | else if ((1 >= size(optionsList))) | |
333 | 280 | then throw("Too few choices to vote") | |
334 | 281 | else { | |
335 | 282 | let eff = getVotingPower("") | |
336 | 283 | let gPiecesTotal = eff[IdxEffTotal] | |
337 | 284 | let quorum = getIntOrElse(keyQuorumRequiredPercent(), DEFAULTQUORUM) | |
338 | 285 | let quorumInGpieces = fraction(quorum, gPiecesTotal, MULT6) | |
339 | 286 | let proposalId = (getIntOrElse(keyLastProposalId(), 0) + 1) | |
340 | 287 | let optionsStr = makeString(optionsList, LISTSEP) | |
341 | 288 | $Tuple2([IntegerEntry(keyLastProposalId(), proposalId), StringEntry(keyProposalStatusDataById(proposalId), statusData(false, 0, 0, 0, false)), StringEntry(keyProposalDataById(proposalId), proposalData(proposalTxId, toBase16String(toBytes(title)), proposalTime, votingStartTime, votingEndTime, quorumInGpieces, optionsStr))], proposalTxId) | |
342 | 289 | } | |
343 | 290 | } | |
344 | 291 | } | |
345 | 292 | ||
346 | 293 | ||
347 | 294 | ||
348 | 295 | @Callable(i) | |
349 | 296 | func cancelVoting (proposalId) = if ((i.caller != this)) | |
350 | 297 | then throw("not authorized") | |
351 | 298 | else { | |
352 | 299 | let currentData = getStringOrFail(this, keyProposalStatusDataById(proposalId)) | |
353 | 300 | let updatedData = ((take(currentData, value(lastIndexOf(currentData, SEP))) + SEP) + "true") | |
354 | 301 | $Tuple2([StringEntry(keyProposalStatusDataById(proposalId), updatedData)], unit) | |
355 | 302 | } | |
356 | 303 | ||
357 | 304 |
github/deemru/w8io/169f3d6 49.53 ms ◑