tx · AWSrfeLWHDHNoSWb91dLzUxmHyJfsBJFfbcTkUeHy1Xa 3MrwiwvG6BeUNCyXBfSAHgaXHASsxbjYMVF: -0.10000000 Waves 2023.01.24 11:59 [2418832] smart account 3MrwiwvG6BeUNCyXBfSAHgaXHASsxbjYMVF > SELF 0.00000000 Waves
{ "type": 13, "id": "AWSrfeLWHDHNoSWb91dLzUxmHyJfsBJFfbcTkUeHy1Xa", "fee": 10000000, "feeAssetId": null, "timestamp": 1674550805733, "version": 2, "chainId": 84, "sender": "3MrwiwvG6BeUNCyXBfSAHgaXHASsxbjYMVF", "senderPublicKey": "7m7j9TNbV4vKeeJqy37XpMNH784X3GGN6acbgLwbBiDD", "proofs": [ "4CZAahWXYfJBc5CdGMCc3B3g7woAsW1CQMKnGqS7kAwkjtNGDopDJkYPs7BN3iyK3jHbaCceZGdubmUL4z3WGSSm", "EHmtg2YVRGAPjjWU4KZVpfZeYT5kpUTu6dRbQyBub9jtPwCirg5jLEpLnhQbjBqPmtoaSjQcBCz61pBPmPF4Yew" ], "script": "base64:BgIXCAISBwoFAQgIGBgSBAoCAQESBAoCAREfAA1rQWRtaW5QdWJLZXkxAgthZG1pbl9wdWJfMQANa0FkbWluUHViS2V5MgILYWRtaW5fcHViXzIADWtBZG1pblB1YktleTMCC2FkbWluX3B1Yl8zABJrQWRtaW5JbnZva2VQdWJLZXkCEGFkbWluX2ludm9rZV9wdWIAEGtNb25leUJveEFkZHJlc3MCEW1vbmV5X2JveF9hZGRyZXNzAAtrR292QWRkcmVzcwISZ292ZXJuYW5jZV9hZGRyZXNzAAdrQWN0aXZlAgZhY3RpdmUAC2tBY3RpdmVHbG9iAhRhY3RpdmVfYWxsX2NvbnRyYWN0cwANa0xhc3RTdXJ2ZXlJZAIObGFzdF9zdXJ2ZXlfaWQAF2tTdXJ2ZXlIZWlnaHRDb21wbGV0aW9uAhlfc3VydmV5X2hlaWdodF9jb21wbGV0aW9uAAxrU3VydmV5VGl0bGUCDV9zdXJ2ZXl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zdWx0CQEMSW50ZWdlckVudHJ5AgkArAICCQCsAgIJAKwCAgkApAMBBQhzdXJ2ZXlJZAIBXwkApAMBBQZvcHRpb24FD2tUb3RhbFN3b3BWb3RlZAUFdG90YWwJAJQKAgkAZAIFBm9wdGlvbgABBQNyZXMEDm9wdGlvbnNFbnRyaWVzCgACJGwFBnRvdGFscwoAAiRzCQCQAwEFAiRsCgAFJGFjYzAJAJQKAgAABQNuaWwKAQUkZjBfMQICJGECJGkDCQBnAgUCJGkFAiRzBQIkYQkBDXByZXBhcmVUb3RhbHMCBQIkYQkAkQMCBQIkbAUCJGkKAQUkZjBfMgICJGECJGkDCQBnAgUCJGkFAiRzBQIkYQkAAgECFExpc3Qgc2l6ZSBleGNlZWRzIDEwCQEFJGYwXzICCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECCQEFJGYwXzECBQUkYWNjMAAAAAEAAgADAAQABQAGAAcACAAJAAoIBQ5vcHRpb25zRW50cmllcwJfMgECdHgBBnZlcmlmeQAEEmFkbWluUHViS2V5MVNpZ25lZAMJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAFDGFkbWluUHViS2V5MQABAAAEEmFkbWluUHViS2V5MlNpZ25lZAMJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAEFDGFkbWluUHViS2V5MgABAAAEEmFkbWluUHViS2V5M1NpZ25lZAMJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAIFDGFkbWluUHViS2V5MwABAAAJAGcCCQBkAgkAZAIFEmFkbWluUHViS2V5MVNpZ25lZAUSYWRtaW5QdWJLZXkyU2lnbmVkBRJhZG1pblB1YktleTNTaWduZWQAAgFAsTc=", "height": 2418832, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4dFyybK9k9XcDDixshUgsigT2Lj1fS4GxiKtBhcCqa69 Next: HE1mkWpoDYGq1U5vzCS4ra56MR44Fhhu4Ra6MkgpXs7D Diff:
Old | New | Differences | |
---|---|---|---|
14 | 14 | let kGovAddress = "governance_address" | |
15 | 15 | ||
16 | 16 | let kActive = "active" | |
17 | + | ||
18 | + | let kActiveGlob = "active_all_contracts" | |
17 | 19 | ||
18 | 20 | let kLastSurveyId = "last_survey_id" | |
19 | 21 | ||
32 | 34 | let kTotalSwopVoted = "_survey_option_total_swop_voted" | |
33 | 35 | ||
34 | 36 | let kUserGSwopInGov = "_GSwop_amount" | |
37 | + | ||
38 | + | let kUserSwopInGov = "_SWOP_amount" | |
35 | 39 | ||
36 | 40 | let oracle = Address(base58'3MvVBtsXroQpy1tsPw21TU2ET9A8WfmrNjz') | |
37 | 41 | ||
57 | 61 | ||
58 | 62 | let active = valueOrElse(getBoolean(this, kActive), true) | |
59 | 63 | ||
60 | - | func isActive () = if (active) | |
64 | + | let activeGlob = valueOrElse(getBoolean(oracle, kActiveGlob), true) | |
65 | + | ||
66 | + | func isActive () = if (if (active) | |
67 | + | then activeGlob | |
68 | + | else false) | |
61 | 69 | then unit | |
62 | 70 | else throw("DApp is inactive at this moment") | |
63 | 71 | ||
82 | 90 | else { | |
83 | 91 | let newSurveyId = (valueOrElse(getInteger(this, kLastSurveyId), 0) + 1) | |
84 | 92 | func prepareOptions (acc,name) = { | |
85 | - | let $ | |
86 | - | let types = $ | |
87 | - | let k = $ | |
88 | - | let result = $ | |
93 | + | let $t031733201 = acc | |
94 | + | let types = $t031733201._1 | |
95 | + | let k = $t031733201._2 | |
96 | + | let result = $t031733201._3 | |
89 | 97 | let res = ((result :+ StringEntry((((toString(newSurveyId) + "_") + toString(k)) + kSurveyOptionName), name)) :+ StringEntry((((toString(newSurveyId) + "_") + toString(k)) + kSurveyOptionType), types[k])) | |
90 | 98 | $Tuple3(types, (k + 1), res) | |
91 | 99 | } | |
118 | 126 | then throw("You can't vote twice") | |
119 | 127 | else if ((height > value(getInteger(this, (toString(surveyId) + kSurveyHeightCompletion))))) | |
120 | 128 | then throw("Survey already end") | |
121 | - | else if ((0 >= valueOrElse(getInteger(govAddress, (toString(i.caller) + kUserGSwopInGov)), 0))) | |
129 | + | else if ((0 >= valueOrElse(getInteger(govAddress, (toString(i.caller) + kUserGSwopInGov)), valueOrElse(getInteger(govAddress, (toString(i.caller) + kUserSwopInGov)), 0)))) | |
122 | 130 | then throw("Stake swop in governance to survey") | |
123 | 131 | else [IntegerEntry((((toString(surveyId) + "_") + toString(i.caller)) + kUserVote), option)]) | |
124 | 132 | ||
131 | 139 | then throw("Survey is not ended yet") | |
132 | 140 | else { | |
133 | 141 | func prepareTotals (acc,total) = { | |
134 | - | let $ | |
135 | - | let option = $ | |
136 | - | let result = $ | |
142 | + | let $t059455971 = acc | |
143 | + | let option = $t059455971._1 | |
144 | + | let result = $t059455971._2 | |
137 | 145 | let res = (result :+ IntegerEntry((((toString(surveyId) + "_") + toString(option)) + kTotalSwopVoted), total)) | |
138 | 146 | $Tuple2((option + 1), res) | |
139 | 147 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let kAdminPubKey1 = "admin_pub_1" | |
5 | 5 | ||
6 | 6 | let kAdminPubKey2 = "admin_pub_2" | |
7 | 7 | ||
8 | 8 | let kAdminPubKey3 = "admin_pub_3" | |
9 | 9 | ||
10 | 10 | let kAdminInvokePubKey = "admin_invoke_pub" | |
11 | 11 | ||
12 | 12 | let kMoneyBoxAddress = "money_box_address" | |
13 | 13 | ||
14 | 14 | let kGovAddress = "governance_address" | |
15 | 15 | ||
16 | 16 | let kActive = "active" | |
17 | + | ||
18 | + | let kActiveGlob = "active_all_contracts" | |
17 | 19 | ||
18 | 20 | let kLastSurveyId = "last_survey_id" | |
19 | 21 | ||
20 | 22 | let kSurveyHeightCompletion = "_survey_height_completion" | |
21 | 23 | ||
22 | 24 | let kSurveyTitle = "_survey_title" | |
23 | 25 | ||
24 | 26 | let kSurveyDescription = "_survey_description" | |
25 | 27 | ||
26 | 28 | let kSurveyOptionName = "_survey_option_name" | |
27 | 29 | ||
28 | 30 | let kSurveyOptionType = "_survey_option_type" | |
29 | 31 | ||
30 | 32 | let kUserVote = "_survey_user_vote" | |
31 | 33 | ||
32 | 34 | let kTotalSwopVoted = "_survey_option_total_swop_voted" | |
33 | 35 | ||
34 | 36 | let kUserGSwopInGov = "_GSwop_amount" | |
37 | + | ||
38 | + | let kUserSwopInGov = "_SWOP_amount" | |
35 | 39 | ||
36 | 40 | let oracle = Address(base58'3MvVBtsXroQpy1tsPw21TU2ET9A8WfmrNjz') | |
37 | 41 | ||
38 | 42 | func getBase58FromOracle (key) = match getString(oracle, key) { | |
39 | 43 | case string: String => | |
40 | 44 | fromBase58String(string) | |
41 | 45 | case nothing => | |
42 | 46 | throw((key + "is empty")) | |
43 | 47 | } | |
44 | 48 | ||
45 | 49 | ||
46 | 50 | let adminPubKey1 = getBase58FromOracle(kAdminPubKey1) | |
47 | 51 | ||
48 | 52 | let adminPubKey2 = getBase58FromOracle(kAdminPubKey2) | |
49 | 53 | ||
50 | 54 | let adminPubKey3 = getBase58FromOracle(kAdminPubKey3) | |
51 | 55 | ||
52 | 56 | let adminPubKeyInvoke = getBase58FromOracle(kAdminInvokePubKey) | |
53 | 57 | ||
54 | 58 | let moneyBoxAddress = Address(getBase58FromOracle(kMoneyBoxAddress)) | |
55 | 59 | ||
56 | 60 | let govAddress = Address(getBase58FromOracle(kGovAddress)) | |
57 | 61 | ||
58 | 62 | let active = valueOrElse(getBoolean(this, kActive), true) | |
59 | 63 | ||
60 | - | func isActive () = if (active) | |
64 | + | let activeGlob = valueOrElse(getBoolean(oracle, kActiveGlob), true) | |
65 | + | ||
66 | + | func isActive () = if (if (active) | |
67 | + | then activeGlob | |
68 | + | else false) | |
61 | 69 | then unit | |
62 | 70 | else throw("DApp is inactive at this moment") | |
63 | 71 | ||
64 | 72 | ||
65 | 73 | func isAdminCall (i) = if (containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey)) | |
66 | 74 | then unit | |
67 | 75 | else throw("Only admin can call this function") | |
68 | 76 | ||
69 | 77 | ||
70 | 78 | func isMoneyBoxCall (i) = if ((moneyBoxAddress == i.caller)) | |
71 | 79 | then unit | |
72 | 80 | else throw("Only Money box can call this function") | |
73 | 81 | ||
74 | 82 | ||
75 | 83 | @Callable(i) | |
76 | 84 | func initSurvey (heightCompletion,surveyTitle,surveyDescription,options,optionsType) = valueOrElse(isActive(), valueOrElse(isAdminCall(i), if ((height >= heightCompletion)) | |
77 | 85 | then throw("Height of survey completion must be greater than currnet height") | |
78 | 86 | else if ((size(options) > 10)) | |
79 | 87 | then throw("Max 10 options must be specified") | |
80 | 88 | else if ((size(options) != size(optionsType))) | |
81 | 89 | then throw("Size of optionsTypes must be same as options") | |
82 | 90 | else { | |
83 | 91 | let newSurveyId = (valueOrElse(getInteger(this, kLastSurveyId), 0) + 1) | |
84 | 92 | func prepareOptions (acc,name) = { | |
85 | - | let $ | |
86 | - | let types = $ | |
87 | - | let k = $ | |
88 | - | let result = $ | |
93 | + | let $t031733201 = acc | |
94 | + | let types = $t031733201._1 | |
95 | + | let k = $t031733201._2 | |
96 | + | let result = $t031733201._3 | |
89 | 97 | let res = ((result :+ StringEntry((((toString(newSurveyId) + "_") + toString(k)) + kSurveyOptionName), name)) :+ StringEntry((((toString(newSurveyId) + "_") + toString(k)) + kSurveyOptionType), types[k])) | |
90 | 98 | $Tuple3(types, (k + 1), res) | |
91 | 99 | } | |
92 | 100 | ||
93 | 101 | let optionsEntries = { | |
94 | 102 | let $l = options | |
95 | 103 | let $s = size($l) | |
96 | 104 | let $acc0 = $Tuple3(optionsType, 0, nil) | |
97 | 105 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
98 | 106 | then $a | |
99 | 107 | else prepareOptions($a, $l[$i]) | |
100 | 108 | ||
101 | 109 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
102 | 110 | then $a | |
103 | 111 | else throw("List size exceeds 10") | |
104 | 112 | ||
105 | 113 | $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) | |
106 | 114 | } | |
107 | 115 | ([IntegerEntry(kLastSurveyId, newSurveyId), IntegerEntry((toString(newSurveyId) + kSurveyHeightCompletion), heightCompletion), StringEntry((toString(newSurveyId) + kSurveyTitle), surveyTitle), StringEntry((toString(newSurveyId) + kSurveyDescription), surveyDescription)] ++ optionsEntries._3) | |
108 | 116 | })) | |
109 | 117 | ||
110 | 118 | ||
111 | 119 | ||
112 | 120 | @Callable(i) | |
113 | 121 | func vote (surveyId,option) = valueOrElse(isActive(), if (!(isDefined(getString(this, (toString(surveyId) + kSurveyTitle))))) | |
114 | 122 | then throw(("There is no survey with id " + toString(surveyId))) | |
115 | 123 | else if (!(isDefined(getString(this, (((toString(surveyId) + "_") + toString(option)) + kSurveyOptionName))))) | |
116 | 124 | then throw(((("There is no option " + toString(option)) + " in survey ") + toString(surveyId))) | |
117 | 125 | else if (isDefined(getInteger(this, (((toString(surveyId) + "_") + toString(i.caller)) + kUserVote)))) | |
118 | 126 | then throw("You can't vote twice") | |
119 | 127 | else if ((height > value(getInteger(this, (toString(surveyId) + kSurveyHeightCompletion))))) | |
120 | 128 | then throw("Survey already end") | |
121 | - | else if ((0 >= valueOrElse(getInteger(govAddress, (toString(i.caller) + kUserGSwopInGov)), 0))) | |
129 | + | else if ((0 >= valueOrElse(getInteger(govAddress, (toString(i.caller) + kUserGSwopInGov)), valueOrElse(getInteger(govAddress, (toString(i.caller) + kUserSwopInGov)), 0)))) | |
122 | 130 | then throw("Stake swop in governance to survey") | |
123 | 131 | else [IntegerEntry((((toString(surveyId) + "_") + toString(i.caller)) + kUserVote), option)]) | |
124 | 132 | ||
125 | 133 | ||
126 | 134 | ||
127 | 135 | @Callable(i) | |
128 | 136 | func writeTotals (surveyId,totals) = valueOrElse(isActive(), valueOrElse(isMoneyBoxCall(i), if (!(isDefined(getString(this, (toString(surveyId) + kSurveyTitle))))) | |
129 | 137 | then throw(("There is no survey with id " + toString(surveyId))) | |
130 | 138 | else if ((value(getInteger(this, (toString(surveyId) + kSurveyHeightCompletion))) > height)) | |
131 | 139 | then throw("Survey is not ended yet") | |
132 | 140 | else { | |
133 | 141 | func prepareTotals (acc,total) = { | |
134 | - | let $ | |
135 | - | let option = $ | |
136 | - | let result = $ | |
142 | + | let $t059455971 = acc | |
143 | + | let option = $t059455971._1 | |
144 | + | let result = $t059455971._2 | |
137 | 145 | let res = (result :+ IntegerEntry((((toString(surveyId) + "_") + toString(option)) + kTotalSwopVoted), total)) | |
138 | 146 | $Tuple2((option + 1), res) | |
139 | 147 | } | |
140 | 148 | ||
141 | 149 | let optionsEntries = { | |
142 | 150 | let $l = totals | |
143 | 151 | let $s = size($l) | |
144 | 152 | let $acc0 = $Tuple2(0, nil) | |
145 | 153 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
146 | 154 | then $a | |
147 | 155 | else prepareTotals($a, $l[$i]) | |
148 | 156 | ||
149 | 157 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
150 | 158 | then $a | |
151 | 159 | else throw("List size exceeds 10") | |
152 | 160 | ||
153 | 161 | $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) | |
154 | 162 | } | |
155 | 163 | optionsEntries._2 | |
156 | 164 | })) | |
157 | 165 | ||
158 | 166 | ||
159 | 167 | @Verifier(tx) | |
160 | 168 | func verify () = { | |
161 | 169 | let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], adminPubKey1)) | |
162 | 170 | then 1 | |
163 | 171 | else 0 | |
164 | 172 | let adminPubKey2Signed = if (sigVerify(tx.bodyBytes, tx.proofs[1], adminPubKey2)) | |
165 | 173 | then 1 | |
166 | 174 | else 0 | |
167 | 175 | let adminPubKey3Signed = if (sigVerify(tx.bodyBytes, tx.proofs[2], adminPubKey3)) | |
168 | 176 | then 1 | |
169 | 177 | else 0 | |
170 | 178 | (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2) | |
171 | 179 | } | |
172 | 180 |
github/deemru/w8io/169f3d6 53.91 ms ◑