@@ -3,13 +3,16 @@ pub mod cli;
3
3
4
4
use std:: str:: FromStr ;
5
5
6
- use anchor_client:: anchor_lang:: {
7
- AccountDeserialize ,
8
- AnchorDeserialize ,
9
- AnchorSerialize ,
10
- InstructionData ,
11
- Owner ,
12
- ToAccountMetas ,
6
+ use anchor_client:: {
7
+ anchor_lang:: {
8
+ AccountDeserialize ,
9
+ AnchorDeserialize ,
10
+ AnchorSerialize ,
11
+ InstructionData as AnchorInstructionData ,
12
+ Owner ,
13
+ ToAccountMetas ,
14
+ } ,
15
+ solana_sdk:: bpf_loader_upgradeable,
13
16
} ;
14
17
use clap:: Parser ;
15
18
use cli:: {
@@ -20,6 +23,7 @@ use cli::{
20
23
use anyhow:: Result ;
21
24
use remote_executor:: {
22
25
accounts:: ExecutePostedVaa ,
26
+ state:: governance_payload:: InstructionData ,
23
27
EXECUTOR_KEY_SEED ,
24
28
ID ,
25
29
} ;
@@ -207,6 +211,64 @@ fn main() -> Result<()> {
207
211
& vec ! [ & payer, & message_keypair] ,
208
212
)
209
213
}
214
+ Action :: GetTestPayload { } => {
215
+ let payload = ExecutorPayload {
216
+ header : GovernanceHeader :: executor_governance_header ( ) ,
217
+ instructions : vec ! [ ] ,
218
+ }
219
+ . try_to_vec ( ) ?;
220
+ println ! ( "Test payload : {:?}" , hex:: encode( payload) ) ;
221
+ Ok ( ( ) )
222
+ }
223
+ Action :: MapKey { pubkey } => {
224
+ let executor_key = Pubkey :: find_program_address (
225
+ & [ EXECUTOR_KEY_SEED . as_bytes ( ) , & pubkey. to_bytes ( ) ] ,
226
+ & ID ,
227
+ )
228
+ . 0 ;
229
+ println ! ( "{:?} maps to {:?}" , pubkey, executor_key) ;
230
+ Ok ( ( ) )
231
+ }
232
+
233
+ Action :: GetSetUpgradeAuthorityPayload {
234
+ current,
235
+ new,
236
+ program_id,
237
+ } => {
238
+ let mut instruction =
239
+ bpf_loader_upgradeable:: set_upgrade_authority ( & program_id, & current, Some ( & new) ) ;
240
+ instruction. accounts [ 2 ] . is_signer = true ; // Require signature of new authority for safety
241
+ println ! ( "New authority : {:}" , instruction. accounts[ 2 ] . pubkey) ;
242
+ let payload = ExecutorPayload {
243
+ header : GovernanceHeader :: executor_governance_header ( ) ,
244
+ instructions : vec ! [ InstructionData :: from( & instruction) ] ,
245
+ }
246
+ . try_to_vec ( ) ?;
247
+ println ! ( "Set upgrade authority payload : {:?}" , hex:: encode( payload) ) ;
248
+ Ok ( ( ) )
249
+ }
250
+
251
+ Action :: GetUpgradeProgramPayload {
252
+ program_id,
253
+ authority,
254
+ new_buffer,
255
+ spill,
256
+ } => {
257
+ let instruction =
258
+ bpf_loader_upgradeable:: upgrade ( & program_id, & new_buffer, & authority, & spill) ;
259
+ println ! ( "New buffer : {:}" , instruction. accounts[ 2 ] . pubkey) ;
260
+ println ! (
261
+ "Extra PGAS will be sent to : {:}" ,
262
+ instruction. accounts[ 3 ] . pubkey
263
+ ) ;
264
+ let payload = ExecutorPayload {
265
+ header : GovernanceHeader :: executor_governance_header ( ) ,
266
+ instructions : vec ! [ InstructionData :: from( & instruction) ] ,
267
+ }
268
+ . try_to_vec ( ) ?;
269
+ println ! ( "Upgrade program payload : {:?}" , hex:: encode( payload) ) ;
270
+ Ok ( ( ) )
271
+ }
210
272
}
211
273
}
212
274
0 commit comments