@@ -458,6 +458,15 @@ multisigCommand(
458
458
) ;
459
459
} ) ;
460
460
461
+ async function accountExists (
462
+ cluster : PythCluster ,
463
+ accountPubkey : PublicKey
464
+ ) : Promise < boolean > {
465
+ const connection = new Connection ( getPythClusterApiUrl ( cluster ) ) ;
466
+ const account = await connection . getAccountInfo ( accountPubkey ) ;
467
+ return account !== null ;
468
+ }
469
+
461
470
multisigCommand (
462
471
"initialize-stake-accounts" ,
463
472
"Initialize stake accounts and assign them to the given vote accounts"
@@ -484,6 +493,15 @@ multisigCommand(
484
493
authorizedPubkey ,
485
494
votePubkey
486
495
) ;
496
+
497
+ if ( await accountExists ( cluster , stakePubkey ) ) {
498
+ throw new Error (
499
+ "Stake account for validator " +
500
+ votePubkey . toBase58 ( ) +
501
+ " already exists, it may be already permissioned"
502
+ ) ;
503
+ }
504
+
487
505
instructions . push (
488
506
SystemProgram . createAccountWithSeed ( {
489
507
basePubkey : authorizedPubkey ,
@@ -513,11 +531,17 @@ multisigCommand(
513
531
) ;
514
532
}
515
533
516
- await vault . proposeInstructions (
534
+ const proposalAddresses = await vault . proposeInstructions (
517
535
instructions ,
518
536
cluster ,
519
537
DEFAULT_PRIORITY_FEE_CONFIG
520
538
) ;
539
+
540
+ // This should be a single proposal normally
541
+ console . log (
542
+ "Successfully proposed at: https://proposals.pyth.network/?tab=proposals&proposal=" +
543
+ proposalAddresses [ 0 ] . toBase58 ( )
544
+ ) ;
521
545
} ) ;
522
546
523
547
multisigCommand (
0 commit comments