Skip to content

Commit

Permalink
fix(governance/xc_admin_cli): remove duplicates in pub buffer init (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
ali-bahjati authored Oct 10, 2024
1 parent 0b5d72d commit e80eb00
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions governance/xc_admin/packages/xc_admin_cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ import {
} from "@pythnetwork/pyth-solana-receiver";

import { LedgerNodeWallet } from "./ledger";
import { DEFAULT_PRIORITY_FEE_CONFIG } from "@pythnetwork/solana-utils";
import {
DEFAULT_PRIORITY_FEE_CONFIG,
TransactionBuilder,
} from "@pythnetwork/solana-utils";

export async function loadHotWalletOrLedger(
wallet: string,
Expand Down Expand Up @@ -623,7 +626,10 @@ multisigCommand("init-price-store-buffers", "Init price store buffers").action(
const allPythAccounts = await connection.getProgramAccounts(
oracleProgramId
);
const allPublishers: Set<PublicKey> = new Set();

// Storing them as string to make sure equal comparison works (for the Set)
const allPublishers: Set<string> = new Set();

for (const account of allPythAccounts) {
const data = account.account.data;
const base = parseBaseData(data);
Expand All @@ -633,13 +639,14 @@ multisigCommand("init-price-store-buffers", "Init price store buffers").action(
0,
parsed.numComponentPrices
)) {
allPublishers.add(component.publisher);
allPublishers.add(component.publisher.toBase58());
}
}
}

let instructions = [];
for (const publisherKey of allPublishers) {
for (const publisherKeyBase58 of allPublishers) {
const publisherKey = new PublicKey(publisherKeyBase58);
if (await isPriceStorePublisherInitialized(connection, publisherKey)) {
// Already configured.
continue;
Expand Down Expand Up @@ -703,7 +710,14 @@ multisigCommand("approve", "Approve a transaction sitting in the multisig")
.action(async (options: any) => {
const vault = await loadVaultFromOptions(options);
const transaction: PublicKey = new PublicKey(options.transaction);
await vault.squad.approveTransaction(transaction);
const instruction = await vault.approveProposalIx(transaction);

const txToSend = TransactionBuilder.batchIntoLegacyTransactions(
[instruction],
DEFAULT_PRIORITY_FEE_CONFIG
);

await vault.sendAllTransactions(txToSend);
});

multisigCommand("propose-token-transfer", "Propose token transfer")
Expand Down Expand Up @@ -801,7 +815,14 @@ multisigCommand("activate", "Activate a transaction sitting in the multisig")
.action(async (options: any) => {
const vault = await loadVaultFromOptions(options);
const transaction: PublicKey = new PublicKey(options.transaction);
await vault.squad.activateTransaction(transaction);
const instruction = await vault.activateProposalIx(transaction);

const txToSend = TransactionBuilder.batchIntoLegacyTransactions(
[instruction],
DEFAULT_PRIORITY_FEE_CONFIG
);

await vault.sendAllTransactions(txToSend);
});

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

0 comments on commit e80eb00

Please sign in to comment.