|
| 1 | +scilla_version 0 |
| 2 | + |
| 3 | +library SSNListProxy_V2 |
| 4 | + |
| 5 | +let zero = Uint128 0 |
| 6 | + |
| 7 | +let one_msg = |
| 8 | + fun (m: Message) => |
| 9 | + let e = Nil {Message} in |
| 10 | + Cons {Message} m e |
| 11 | + |
| 12 | +(***************************************************) |
| 13 | +(* The contract definition *) |
| 14 | +(***************************************************) |
| 15 | +contract SSNListProxy_V2( |
| 16 | + init_implementation: ByStr20, |
| 17 | + init_admin: ByStr20 |
| 18 | +) |
| 19 | + |
| 20 | +(* Mutable fields *) |
| 21 | +field implementation: ByStr20 = init_implementation |
| 22 | +field admin: ByStr20 = init_admin |
| 23 | +field stagingadmin: Option ByStr20 = None {ByStr20} |
| 24 | + |
| 25 | +(***************************************************) |
| 26 | +(* Transition *) |
| 27 | +(***************************************************) |
| 28 | + |
| 29 | +(***************************************************) |
| 30 | +(* Proxy Transition *) |
| 31 | +(***************************************************) |
| 32 | +transition UpgradeTo(newImplementation: ByStr20) |
| 33 | + currentAdmin <- admin; |
| 34 | + isAdmin = builtin eq currentAdmin _sender; |
| 35 | + match isAdmin with |
| 36 | + | True => |
| 37 | + implementation := newImplementation; |
| 38 | + e = {_eventname: "Upgraded"; implementation_address: newImplementation}; |
| 39 | + event e |
| 40 | + | False => |
| 41 | + e = {_eventname: "upgradeTo FailedNotAdmin"; newImplementation: newImplementation}; |
| 42 | + event e |
| 43 | + end |
| 44 | +end |
| 45 | + |
| 46 | +transition ChangeProxyAdmin(newAdmin: ByStr20) |
| 47 | + currentAdmin <- admin; |
| 48 | + isAdmin = builtin eq currentAdmin _sender; |
| 49 | + match isAdmin with |
| 50 | + | True => |
| 51 | + new_staging_admin = Some {ByStr20} newAdmin; |
| 52 | + stagingadmin := new_staging_admin; |
| 53 | + e = {_eventname: "ChangeProxyAdmin"; oldAdmin: currentAdmin; newAdmin: newAdmin}; |
| 54 | + event e |
| 55 | + | False => |
| 56 | + e = {_eventname: "ChangeProxyAdmin FailedNotAdmin"; newAdmin: newAdmin}; |
| 57 | + event e |
| 58 | + end |
| 59 | +end |
| 60 | + |
| 61 | +transition ClaimProxyAdmin() |
| 62 | + staging_admin_o <- stagingadmin; |
| 63 | + match staging_admin_o with |
| 64 | + | Some staging_admin => |
| 65 | + is_stagingadmin = builtin eq staging_admin _sender; |
| 66 | + match is_stagingadmin with |
| 67 | + | True => |
| 68 | + admin := _sender; |
| 69 | + tmp_staging_admin = None {ByStr20}; |
| 70 | + stagingadmin := tmp_staging_admin; |
| 71 | + e = {_eventname: "ClaimProxyAdmin"; newAdmin: _sender}; |
| 72 | + event e |
| 73 | + | False => |
| 74 | + e = {_eventname: "ClaimProxyAdmin FailedNotStagingadmin"; newAdmin: _sender}; |
| 75 | + event e |
| 76 | + end |
| 77 | + | None => |
| 78 | + e = {_eventname: "ClaimProxyAdmin FailedNoStagingadmin"}; |
| 79 | + event e |
| 80 | + end |
| 81 | +end |
| 82 | + |
| 83 | +(***************************************************) |
| 84 | +(* House keeping transition *) |
| 85 | +(***************************************************) |
| 86 | +transition OptInSSNToConsensusPoolAdminOverride(ssnaddr: ByStr20) |
| 87 | + current_impl <- implementation; |
| 88 | + msg = {_tag: "OptInSSNToConsensusPoolAdminOverride"; _recipient: current_impl; _amount: zero; ssnaddr: ssnaddr; initiator: _sender}; |
| 89 | + msgs = one_msg msg; |
| 90 | + send msgs |
| 91 | +end |
| 92 | + |
| 93 | +transition OptOutSSNFromConsensusPoolAdminOverride(ssnaddr: ByStr20) |
| 94 | + current_impl <- implementation; |
| 95 | + msg = {_tag: "OptOutSSNFromConsensusPoolAdminOverride"; _recipient: current_impl; _amount: zero; ssnaddr: ssnaddr; initiator: _sender}; |
| 96 | + msgs = one_msg msg; |
| 97 | + send msgs |
| 98 | +end |
| 99 | + |
| 100 | +transition RemoveFromConsensusPoolAdminOverride(ssnaddr: ByStr20) |
| 101 | + current_impl <- implementation; |
| 102 | + msg = {_tag: "RemoveFromConsensusPoolAdminOverride"; _recipient: current_impl; _amount: zero; ssnaddr: ssnaddr; initiator: _sender}; |
| 103 | + msgs = one_msg msg; |
| 104 | + send msgs |
| 105 | +end |
| 106 | + |
| 107 | +transition ChangeMinCommissionRate(mincommrate_value: Uint128) |
| 108 | + current_impl <- implementation; |
| 109 | + msg = {_tag: "ChangeMinCommissionRate"; _recipient: current_impl; _amount: zero; mincommrate_value: mincommrate_value; initiator: _sender}; |
| 110 | + msgs = one_msg msg; |
| 111 | + send msgs |
| 112 | +end |
| 113 | + |
| 114 | +transition AddSSNNonStaking(ssnaddr: ByStr20, name: String, urlraw: String, urlapi: String, comm: Uint128) |
| 115 | + current_impl <- implementation; |
| 116 | + msg = {_tag: "AddSSNNonStaking"; _recipient: current_impl; _amount: zero; ssnaddr: ssnaddr; name: name; urlraw: urlraw; urlapi: urlapi; comm: comm; initiator: _sender}; |
| 117 | + msgs = one_msg msg; |
| 118 | + send msgs |
| 119 | +end |
| 120 | + |
| 121 | +(***************************************************) |
| 122 | +(* SSN operator transition *) |
| 123 | +(***************************************************) |
| 124 | + |
| 125 | +transition AddSSNToConsensusPool() |
| 126 | + current_impl <- implementation; |
| 127 | + msg = {_tag: "AddSSNToConsensusPool"; _recipient: current_impl; _amount: zero; initiator: _sender}; |
| 128 | + msgs = one_msg msg; |
| 129 | + send msgs |
| 130 | +end |
| 131 | + |
| 132 | +transition RemoveSSNFromConsensusPool() |
| 133 | + current_impl <- implementation; |
| 134 | + msg = {_tag: "RemoveSSNFromConsensusPool"; _recipient: current_impl; _amount: zero; initiator: _sender}; |
| 135 | + msgs = one_msg msg; |
| 136 | + send msgs |
| 137 | +end |
| 138 | + |
| 139 | +(***************************************************) |
| 140 | +(* Delegator transition *) |
| 141 | +(***************************************************) |
| 142 | + |
| 143 | +(* @dev: Withdraw stake reward . Can be called by a deleg. *) |
| 144 | +transition WithdrawStakeRewardsForCycles(ssnaddr: ByStr20, cycles: Uint32) |
| 145 | + current_impl <- implementation; |
| 146 | + msg = {_tag: "WithdrawStakeRewardsForCycles"; _recipient: current_impl; _amount: zero; ssnaddr: ssnaddr; cycles: cycles; initiator: _sender}; |
| 147 | + msgs = one_msg msg; |
| 148 | + send msgs |
| 149 | +end |
| 150 | + |
| 151 | + |
| 152 | +(***************************************************) |
| 153 | +(* Contract state migration *) |
| 154 | +(***************************************************) |
| 155 | + |
| 156 | +transition CopySSNDelegAmt(ssn: ByStr20, |
| 157 | + keys: List (Pair ByStr20 Uint128)) |
| 158 | + current_impl <- implementation; |
| 159 | + msg = {_tag: "CopySSNDelegAmt"; _recipient: current_impl; _amount: zero; ssn: ssn; keys: keys; initiator: _sender}; |
| 160 | + msgs = one_msg msg; |
| 161 | + send msgs |
| 162 | +end |
| 163 | + |
| 164 | +transition MigrateStakeSSNPerCycle(ssn: ByStr20, |
| 165 | + keys: List (Pair Uint32 (Pair Uint128 Uint128))) |
| 166 | + current_impl <- implementation; |
| 167 | + msg = {_tag: "MigrateStakeSSNPerCycle"; _recipient: current_impl; _amount: zero; ssn: ssn; keys: keys; initiator: _sender}; |
| 168 | + msgs = one_msg msg; |
| 169 | + send msgs |
| 170 | +end |
| 171 | + |
| 172 | +transition CopyBuffDepositDeleg(deleg: ByStr20, |
| 173 | + keys: List (Pair ByStr20 (List (Pair Uint32 Uint128)))) |
| 174 | + current_impl <- implementation; |
| 175 | + msg = {_tag: "CopyBuffDepositDeleg"; _recipient: current_impl; _amount: zero; deleg: deleg; keys: keys; initiator: _sender}; |
| 176 | + msgs = one_msg msg; |
| 177 | + send msgs |
| 178 | +end |
| 179 | + |
| 180 | +transition CopyLastBufDepositCycleDelegList(last_buf_deposit_cycle_deleg_list: (List (Pair ByStr20 (List (Pair ByStr20 Uint32))))) |
| 181 | + current_impl <- implementation; |
| 182 | + msg = {_tag: "CopyLastBufDepositCycleDelegList"; _recipient: current_impl; _amount: zero; last_buf_deposit_cycle_deleg_list: last_buf_deposit_cycle_deleg_list; initiator: _sender}; |
| 183 | + msgs = one_msg msg; |
| 184 | + send msgs |
| 185 | +end |
| 186 | + |
| 187 | +transition CopyLastWithdrawCycleDelegList(last_withdraw_cycle_deleg_list: (List (Pair ByStr20 (List (Pair ByStr20 Uint32))))) |
| 188 | + current_impl <- implementation; |
| 189 | + msg = {_tag: "CopyLastWithdrawCycleDelegList"; _recipient: current_impl; _amount: zero; last_withdraw_cycle_deleg_list: last_withdraw_cycle_deleg_list; initiator: _sender}; |
| 190 | + msgs = one_msg msg; |
| 191 | + send msgs |
| 192 | +end |
| 193 | + |
| 194 | +transition CopyDelegStakePerCycleList(deleg_stake_per_cycle_list: (List (Pair ByStr20 (List (Pair ByStr20 (List (Pair Uint32 Uint128))))))) |
| 195 | + current_impl <- implementation; |
| 196 | + msg = {_tag: "CopyDelegStakePerCycleList"; _recipient: current_impl; _amount: zero; deleg_stake_per_cycle_list: deleg_stake_per_cycle_list; initiator: _sender}; |
| 197 | + msgs = one_msg msg; |
| 198 | + send msgs |
| 199 | +end |
| 200 | + |
| 201 | +transition CopyDirectDepositDelegList(direct_deposit_deleg_list: (List (Pair ByStr20 (List (Pair ByStr20 (List (Pair Uint32 Uint128))))))) |
| 202 | + current_impl <- implementation; |
| 203 | + msg = {_tag: "CopyDirectDepositDelegList"; _recipient: current_impl; _amount: zero; direct_deposit_deleg_list: direct_deposit_deleg_list; initiator: _sender}; |
| 204 | + msgs = one_msg msg; |
| 205 | + send msgs |
| 206 | +end |
| 207 | + |
| 208 | +transition CopyBuffDepositDelegList(buff_deposit_deleg_list: (List (Pair ByStr20 (List (Pair ByStr20 (List (Pair Uint32 Uint128))))))) |
| 209 | + current_impl <- implementation; |
| 210 | + msg = {_tag: "CopyBuffDepositDelegList"; _recipient: current_impl; _amount: zero; buff_deposit_deleg_list: buff_deposit_deleg_list; initiator: _sender}; |
| 211 | + msgs = one_msg msg; |
| 212 | + send msgs |
| 213 | +end |
| 214 | + |
| 215 | +transition CopyDepositAmtDelegList(deposit_amt_deleg_list: (List (Pair ByStr20 (List (Pair ByStr20 Uint128))))) |
| 216 | + current_impl <- implementation; |
| 217 | + msg = {_tag: "CopyDepositAmtDelegList"; _recipient: current_impl; _amount: zero; deposit_amt_deleg_list: deposit_amt_deleg_list; initiator: _sender}; |
| 218 | + msgs = one_msg msg; |
| 219 | + send msgs |
| 220 | +end |
| 221 | + |
| 222 | +transition CopyWithDrawalPendingList(withdrawal_pending_list: (List (Pair ByStr20 (List (Pair BNum Uint128))))) |
| 223 | + current_impl <- implementation; |
| 224 | + msg = {_tag: "CopyWithDrawalPendingList"; _recipient: current_impl; _amount: zero; withdrawal_pending_list: withdrawal_pending_list; initiator: _sender}; |
| 225 | + msgs = one_msg msg; |
| 226 | + send msgs |
| 227 | +end |
| 228 | + |
| 229 | +transition CopyCommForSSNList(comm_for_ssn_list: (List (Pair ByStr20 (List (Pair Uint32 Uint128))))) |
| 230 | + current_impl <- implementation; |
| 231 | + msg = {_tag: "CopyCommForSSNList"; _recipient: current_impl; _amount: zero; comm_for_ssn_list: comm_for_ssn_list; initiator: _sender}; |
| 232 | + msgs = one_msg msg; |
| 233 | + send msgs |
| 234 | +end |
| 235 | + |
| 236 | +transition CopyDelegSwapRequest(deleg_swap_request_list: (List (Pair ByStr20 ByStr20))) |
| 237 | + current_impl <- implementation; |
| 238 | + msg = {_tag: "CopyDelegSwapRequest"; _recipient: current_impl; _amount: zero; deleg_swap_request_list: deleg_swap_request_list; initiator: _sender}; |
| 239 | + msgs = one_msg msg; |
| 240 | + send msgs |
| 241 | +end |
| 242 | + |
| 243 | +transition ChangeCycleRewardsDeleg(input_cycle_rewards_deleg: Uint128) |
| 244 | + current_impl <- implementation; |
| 245 | + msg = {_tag: "ChangeCycleRewardsDeleg"; _recipient: current_impl; _amount: zero; input_cycle_rewards_deleg: input_cycle_rewards_deleg; initiator: _sender}; |
| 246 | + msgs = one_msg msg; |
| 247 | + send msgs |
| 248 | +end |
| 249 | + |
| 250 | +transition ChangeVerifierReward(input_verifier_reward: Uint128) |
| 251 | + current_impl <- implementation; |
| 252 | + msg = {_tag: "ChangeVerifierReward"; _recipient: current_impl; _amount: zero; input_verifier_reward: input_verifier_reward; initiator: _sender}; |
| 253 | + msgs = one_msg msg; |
| 254 | + send msgs |
| 255 | +end |
| 256 | + |
| 257 | +transition ChangeAvailableWithdrawal(input_available_withdrawal: Uint128) |
| 258 | + current_impl <- implementation; |
| 259 | + msg = {_tag: "ChangeAvailableWithdrawal"; _recipient: current_impl; _amount: zero; input_available_withdrawal: input_available_withdrawal; initiator: _sender}; |
| 260 | + msgs = one_msg msg; |
| 261 | + send msgs |
| 262 | +end |
| 263 | + |
| 264 | +transition ChangeCurrentDeleg(input_current_deleg: ByStr20) |
| 265 | + current_impl <- implementation; |
| 266 | + msg = {_tag: "ChangeCurrentDeleg"; _recipient: current_impl; _amount: zero; input_current_deleg: input_current_deleg; initiator: _sender}; |
| 267 | + msgs = one_msg msg; |
| 268 | + send msgs |
| 269 | +end |
| 270 | + |
| 271 | +transition ChangeCurrentSSN(input_current_ssn: ByStr20) |
| 272 | + current_impl <- implementation; |
| 273 | + msg = {_tag: "ChangeCurrentSSN"; _recipient: current_impl; _amount: zero; input_current_ssn: input_current_ssn; initiator: _sender}; |
| 274 | + msgs = one_msg msg; |
| 275 | + send msgs |
| 276 | +end |
| 277 | + |
| 278 | +transition ChangeNewDeleg(input_new_deleg: ByStr20) |
| 279 | + current_impl <- implementation; |
| 280 | + msg = {_tag: "ChangeNewDeleg"; _recipient: current_impl; _amount: zero; input_new_deleg: input_new_deleg; initiator: _sender}; |
| 281 | + msgs = one_msg msg; |
| 282 | + send msgs |
| 283 | +end |
| 284 | + |
| 285 | +transition ChangeVerifier(input_verifier: ByStr20) |
| 286 | + current_impl <- implementation; |
| 287 | + msg = {_tag: "ChangeVerifier"; _recipient: current_impl; _amount: zero; input_verifier: input_verifier; initiator: _sender}; |
| 288 | + msgs = one_msg msg; |
| 289 | + send msgs |
| 290 | +end |
| 291 | + |
| 292 | +transition ChangeVerifierReceivingAddr(input_verifier_receiving_addr: ByStr20) |
| 293 | + current_impl <- implementation; |
| 294 | + msg = {_tag: "ChangeVerifierReceivingAddr"; _recipient: current_impl; _amount: zero; input_verifier_receiving_addr: input_verifier_receiving_addr; initiator: _sender}; |
| 295 | + msgs = one_msg msg; |
| 296 | + send msgs |
| 297 | +end |
| 298 | + |
| 299 | +transition ChangeMinStake(input_minstake: Uint128) |
| 300 | + current_impl <- implementation; |
| 301 | + msg = {_tag: "ChangeMinStake"; _recipient: current_impl; _amount: zero; input_minstake: input_minstake; initiator: _sender}; |
| 302 | + msgs = one_msg msg; |
| 303 | + send msgs |
| 304 | +end |
| 305 | + |
| 306 | +transition ChangeMinDelegStake(input_mindelegstake: Uint128) |
| 307 | + current_impl <- implementation; |
| 308 | + msg = {_tag: "ChangeMinDelegStake"; _recipient: current_impl; _amount: zero; input_mindelegstake: input_mindelegstake; initiator: _sender}; |
| 309 | + msgs = one_msg msg; |
| 310 | + send msgs |
| 311 | +end |
| 312 | + |
| 313 | +transition ChangeLastRewardCycle(input_lastrewardcycle: Uint32) |
| 314 | + current_impl <- implementation; |
| 315 | + msg = {_tag: "ChangeLastRewardCycle"; _recipient: current_impl; _amount: zero; input_lastrewardcycle: input_lastrewardcycle; initiator: _sender}; |
| 316 | + msgs = one_msg msg; |
| 317 | + send msgs |
| 318 | +end |
| 319 | + |
| 320 | +transition ChangeMaxCommChangeRate(input_maxcommchangerate: Uint128) |
| 321 | + current_impl <- implementation; |
| 322 | + msg = {_tag: "ChangeMaxCommChangeRate"; _recipient: current_impl; _amount: zero; input_maxcommchangerate: input_maxcommchangerate; initiator: _sender}; |
| 323 | + msgs = one_msg msg; |
| 324 | + send msgs |
| 325 | +end |
| 326 | + |
| 327 | +transition ChangeMaxCommRate(input_maxcommrate: Uint128) |
| 328 | + current_impl <- implementation; |
| 329 | + msg = {_tag: "ChangeMaxCommRate"; _recipient: current_impl; _amount: zero; input_maxcommrate: input_maxcommrate; initiator: _sender}; |
| 330 | + msgs = one_msg msg; |
| 331 | + send msgs |
| 332 | +end |
| 333 | + |
| 334 | +transition ChangeTotalStakeAmount(input_totalstakeamount: Uint128) |
| 335 | + current_impl <- implementation; |
| 336 | + msg = {_tag: "ChangeTotalStakeAmount"; _recipient: current_impl; _amount: zero; input_totalstakeamount: input_totalstakeamount; initiator: _sender}; |
| 337 | + msgs = one_msg msg; |
| 338 | + send msgs |
| 339 | +end |
0 commit comments