@@ -61,6 +61,7 @@ impl Command {
61
61
pub async fn execute ( self , config : & Config ) -> CommandResult {
62
62
match self {
63
63
Command :: Initialize ( command_config) => command_initialize ( config, command_config) . await ,
64
+ Command :: Reactivate ( command_config) => command_reactivate ( config, command_config) . await ,
64
65
Command :: Deposit ( command_config) => command_deposit ( config, command_config) . await ,
65
66
Command :: Withdraw ( command_config) => command_withdraw ( config, command_config) . await ,
66
67
Command :: CreateTokenMetadata ( command_config) => {
@@ -157,6 +158,61 @@ async fn command_initialize(config: &Config, command_config: InitializeCli) -> C
157
158
) )
158
159
}
159
160
161
+ // reactivate stake account
162
+ async fn command_reactivate ( config : & Config , command_config : ReactivateCli ) -> CommandResult {
163
+ let payer = config. fee_payer ( ) ?;
164
+ let pool_address = pool_address_from_args (
165
+ command_config. pool_address ,
166
+ command_config. vote_account_address ,
167
+ ) ;
168
+
169
+ println_display (
170
+ config,
171
+ format ! ( "Reactivating stake account for pool {}\n " , pool_address) ,
172
+ ) ;
173
+
174
+ let vote_account_address =
175
+ if let Some ( pool_data) = config. program_client . get_account ( pool_address) . await ? {
176
+ try_from_slice_unchecked :: < SinglePool > ( & pool_data. data ) ?. vote_account_address
177
+ } else {
178
+ return Err ( format ! ( "Pool {} has not been initialized" , pool_address) . into ( ) ) ;
179
+ } ;
180
+
181
+ // the only reason this check is skippable is for testing, otherwise theres no reason
182
+ if !command_config. yolo {
183
+ let current_epoch = config. rpc_client . get_epoch_info ( ) . await ?. epoch ;
184
+ let pool_stake_address = find_pool_stake_address ( & single_pool:: id ( ) , & pool_address) ;
185
+ let pool_stake_deactivated = quarantine:: get_stake_info ( config, & pool_stake_address)
186
+ . await ?
187
+ . unwrap ( )
188
+ . 1
189
+ . delegation
190
+ . deactivation_epoch
191
+ < current_epoch;
192
+
193
+ if !pool_stake_deactivated {
194
+ return Err ( "Pool stake account is not deactivated" . into ( ) ) ;
195
+ }
196
+ }
197
+
198
+ let instruction =
199
+ single_pool:: instruction:: reactivate_pool ( & single_pool:: id ( ) , & vote_account_address) ;
200
+ let transaction = Transaction :: new_signed_with_payer (
201
+ & [ instruction] ,
202
+ Some ( & payer. pubkey ( ) ) ,
203
+ & vec ! [ payer] ,
204
+ config. program_client . get_latest_blockhash ( ) . await ?,
205
+ ) ;
206
+
207
+ let signature = process_transaction ( config, transaction) . await ?;
208
+
209
+ Ok ( format_output (
210
+ config,
211
+ "Reactivate" . to_string ( ) ,
212
+ SignatureOutput { signature } ,
213
+ ) )
214
+ }
215
+
160
216
// deposit stake
161
217
async fn command_deposit ( config : & Config , command_config : DepositCli ) -> CommandResult {
162
218
let payer = config. fee_payer ( ) ?;
@@ -572,7 +628,7 @@ async fn command_update_metadata(
572
628
. into ( ) ) ;
573
629
}
574
630
} else {
575
- // we know the pool exists so the vote accound must exist
631
+ // we know the pool exists so the vote account must exist
576
632
unreachable ! ( ) ;
577
633
}
578
634
0 commit comments