Skip to content

Commit 97270f2

Browse files
authored
chore: xc-admin-cli improvements (#2196)
* do it * go * go * go
1 parent a26f335 commit 97270f2

File tree

1 file changed

+25
-1
lines changed
  • governance/xc_admin/packages/xc_admin_cli/src

1 file changed

+25
-1
lines changed

governance/xc_admin/packages/xc_admin_cli/src/index.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,15 @@ multisigCommand(
458458
);
459459
});
460460

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+
461470
multisigCommand(
462471
"initialize-stake-accounts",
463472
"Initialize stake accounts and assign them to the given vote accounts"
@@ -484,6 +493,15 @@ multisigCommand(
484493
authorizedPubkey,
485494
votePubkey
486495
);
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+
487505
instructions.push(
488506
SystemProgram.createAccountWithSeed({
489507
basePubkey: authorizedPubkey,
@@ -513,11 +531,17 @@ multisigCommand(
513531
);
514532
}
515533

516-
await vault.proposeInstructions(
534+
const proposalAddresses = await vault.proposeInstructions(
517535
instructions,
518536
cluster,
519537
DEFAULT_PRIORITY_FEE_CONFIG
520538
);
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+
);
521545
});
522546

523547
multisigCommand(

0 commit comments

Comments
 (0)