|
@@ -458,6 +458,15 @@ multisigCommand(
|
|
|
);
|
|
);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+async function accountExists(
|
|
|
|
|
+ cluster: PythCluster,
|
|
|
|
|
+ accountPubkey: PublicKey
|
|
|
|
|
+): Promise<boolean> {
|
|
|
|
|
+ const connection = new Connection(getPythClusterApiUrl(cluster));
|
|
|
|
|
+ const account = await connection.getAccountInfo(accountPubkey);
|
|
|
|
|
+ return account !== null;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
multisigCommand(
|
|
multisigCommand(
|
|
|
"initialize-stake-accounts",
|
|
"initialize-stake-accounts",
|
|
|
"Initialize stake accounts and assign them to the given vote accounts"
|
|
"Initialize stake accounts and assign them to the given vote accounts"
|
|
@@ -484,6 +493,15 @@ multisigCommand(
|
|
|
authorizedPubkey,
|
|
authorizedPubkey,
|
|
|
votePubkey
|
|
votePubkey
|
|
|
);
|
|
);
|
|
|
|
|
+
|
|
|
|
|
+ if (await accountExists(cluster, stakePubkey)) {
|
|
|
|
|
+ throw new Error(
|
|
|
|
|
+ "Stake account for validator " +
|
|
|
|
|
+ votePubkey.toBase58() +
|
|
|
|
|
+ " already exists, it may be already permissioned"
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
instructions.push(
|
|
instructions.push(
|
|
|
SystemProgram.createAccountWithSeed({
|
|
SystemProgram.createAccountWithSeed({
|
|
|
basePubkey: authorizedPubkey,
|
|
basePubkey: authorizedPubkey,
|
|
@@ -513,11 +531,17 @@ multisigCommand(
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- await vault.proposeInstructions(
|
|
|
|
|
|
|
+ const proposalAddresses = await vault.proposeInstructions(
|
|
|
instructions,
|
|
instructions,
|
|
|
cluster,
|
|
cluster,
|
|
|
DEFAULT_PRIORITY_FEE_CONFIG
|
|
DEFAULT_PRIORITY_FEE_CONFIG
|
|
|
);
|
|
);
|
|
|
|
|
+
|
|
|
|
|
+ // This should be a single proposal normally
|
|
|
|
|
+ console.log(
|
|
|
|
|
+ "Successfully proposed at: https://proposals.pyth.network/?tab=proposals&proposal=" +
|
|
|
|
|
+ proposalAddresses[0].toBase58()
|
|
|
|
|
+ );
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
multisigCommand(
|
|
multisigCommand(
|