Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,11 @@ export async function isPriceStorePublisherInitialized(
const response = await connection.getAccountInfo(publisherConfigKey);
return response !== null;
}

export async function isPriceStoreInitialized(
connection: Connection
): Promise<boolean> {
const configKey = findPriceStoreConfigAddress()[0];
const response = await connection.getAccountInfo(configKey);
return response !== null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
PRICE_FEED_OPS_KEY,
getMessageBufferAddressForPrice,
getMaximumNumberOfPublishers,
isPriceStoreInitialized,
isPriceStorePublisherInitialized,
createDetermisticPriceStoreInitializePublisherInstruction,
} from '@pythnetwork/xc-admin-common'
Expand Down Expand Up @@ -290,7 +291,7 @@ const General = ({ proposerServerUrl }: { proposerServerUrl: string }) => {
const handleSendProposalButtonClick = async () => {
if (pythProgramClient && dataChanges && !isMultisigLoading && squads) {
const instructions: TransactionInstruction[] = []
const publisherInitializationsVerified: PublicKey[] = []
const publisherInPriceStoreInitializationsVerified: PublicKey[] = []

for (const symbol of Object.keys(dataChanges)) {
const multisigAuthority = squads.getAuthorityPDA(
Expand All @@ -301,9 +302,14 @@ const General = ({ proposerServerUrl }: { proposerServerUrl: string }) => {
? mapKey(multisigAuthority)
: multisigAuthority

const initPublisher = async (publisherKey: PublicKey) => {
const initPublisherInPriceStore = async (publisherKey: PublicKey) => {
// Ignore this step if Price Store is not initialized (or not deployed)
if (!connection || !(await isPriceStoreInitialized(connection))) {
return
}

if (
publisherInitializationsVerified.every(
publisherInPriceStoreInitializationsVerified.every(
(el) => !el.equals(publisherKey)
)
) {
Expand All @@ -321,7 +327,7 @@ const General = ({ proposerServerUrl }: { proposerServerUrl: string }) => {
)
)
}
publisherInitializationsVerified.push(publisherKey)
publisherInPriceStoreInitializationsVerified.push(publisherKey)
}
}
const { prev, new: newChanges } = dataChanges[symbol]
Expand Down Expand Up @@ -406,7 +412,7 @@ const General = ({ proposerServerUrl }: { proposerServerUrl: string }) => {
})
.instruction()
)
await initPublisher(publisherPubKey)
await initPublisherInPriceStore(publisherPubKey)
}

// create set min publisher instruction if there are any publishers
Expand Down Expand Up @@ -576,7 +582,7 @@ const General = ({ proposerServerUrl }: { proposerServerUrl: string }) => {
})
.instruction()
)
await initPublisher(publisherPubKey)
await initPublisherInPriceStore(publisherPubKey)
}
}
}
Expand Down
Loading