Skip to content

Commit e80eb00

Browse files
authored
fix(governance/xc_admin_cli): remove duplicates in pub buffer init (#2026)
The JS Set is not smart to support custom equality operator and for object it only considers the equal objects the same. Activate and approve instructions are also changed because the sqds/mesh sdk uses an old Anchor version that uses a deprecated getRecentBlockHash RPC method. This method is removed in Agave v2 and devnet is fully on Agave v2 now.
1 parent 0b5d72d commit e80eb00

File tree

1 file changed

+27
-6
lines changed
  • governance/xc_admin/packages/xc_admin_cli/src

1 file changed

+27
-6
lines changed

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

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ import {
5555
} from "@pythnetwork/pyth-solana-receiver";
5656

5757
import { LedgerNodeWallet } from "./ledger";
58-
import { DEFAULT_PRIORITY_FEE_CONFIG } from "@pythnetwork/solana-utils";
58+
import {
59+
DEFAULT_PRIORITY_FEE_CONFIG,
60+
TransactionBuilder,
61+
} from "@pythnetwork/solana-utils";
5962

6063
export async function loadHotWalletOrLedger(
6164
wallet: string,
@@ -623,7 +626,10 @@ multisigCommand("init-price-store-buffers", "Init price store buffers").action(
623626
const allPythAccounts = await connection.getProgramAccounts(
624627
oracleProgramId
625628
);
626-
const allPublishers: Set<PublicKey> = new Set();
629+
630+
// Storing them as string to make sure equal comparison works (for the Set)
631+
const allPublishers: Set<string> = new Set();
632+
627633
for (const account of allPythAccounts) {
628634
const data = account.account.data;
629635
const base = parseBaseData(data);
@@ -633,13 +639,14 @@ multisigCommand("init-price-store-buffers", "Init price store buffers").action(
633639
0,
634640
parsed.numComponentPrices
635641
)) {
636-
allPublishers.add(component.publisher);
642+
allPublishers.add(component.publisher.toBase58());
637643
}
638644
}
639645
}
640646

641647
let instructions = [];
642-
for (const publisherKey of allPublishers) {
648+
for (const publisherKeyBase58 of allPublishers) {
649+
const publisherKey = new PublicKey(publisherKeyBase58);
643650
if (await isPriceStorePublisherInitialized(connection, publisherKey)) {
644651
// Already configured.
645652
continue;
@@ -703,7 +710,14 @@ multisigCommand("approve", "Approve a transaction sitting in the multisig")
703710
.action(async (options: any) => {
704711
const vault = await loadVaultFromOptions(options);
705712
const transaction: PublicKey = new PublicKey(options.transaction);
706-
await vault.squad.approveTransaction(transaction);
713+
const instruction = await vault.approveProposalIx(transaction);
714+
715+
const txToSend = TransactionBuilder.batchIntoLegacyTransactions(
716+
[instruction],
717+
DEFAULT_PRIORITY_FEE_CONFIG
718+
);
719+
720+
await vault.sendAllTransactions(txToSend);
707721
});
708722

709723
multisigCommand("propose-token-transfer", "Propose token transfer")
@@ -801,7 +815,14 @@ multisigCommand("activate", "Activate a transaction sitting in the multisig")
801815
.action(async (options: any) => {
802816
const vault = await loadVaultFromOptions(options);
803817
const transaction: PublicKey = new PublicKey(options.transaction);
804-
await vault.squad.activateTransaction(transaction);
818+
const instruction = await vault.activateProposalIx(transaction);
819+
820+
const txToSend = TransactionBuilder.batchIntoLegacyTransactions(
821+
[instruction],
822+
DEFAULT_PRIORITY_FEE_CONFIG
823+
);
824+
825+
await vault.sendAllTransactions(txToSend);
805826
});
806827

807828
multisigCommand("add-and-delete", "Change the roster of the multisig")

0 commit comments

Comments
 (0)