Skip to content

Commit 811960e

Browse files
committed
refactor: fix product filtering and improve account processing logging in usePyth
1 parent 7e8c3f8 commit 811960e

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

governance/xc_admin/packages/xc_admin_common/src/programs/core/core_functions.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,12 @@ export function getConfig(params: CoreConfigParams): RawConfig {
224224
products: parsed.productAccountKeys
225225
.filter((key) => {
226226
const keyStr = key.toBase58();
227-
// Only include products that exist and haven't been processed yet
228-
return productRawConfigs[keyStr] && !processedProducts.has(keyStr);
227+
// Only include products that exist, have price accounts, and haven't been processed yet
228+
return (
229+
productRawConfigs[keyStr] &&
230+
productRawConfigs[keyStr].priceAccounts.length > 0 &&
231+
!processedProducts.has(keyStr)
232+
);
229233
})
230234
.map((key) => {
231235
const keyStr = key.toBase58();

governance/xc_admin/packages/xc_admin_frontend/hooks/usePyth.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,36 @@ export const usePyth = (): PythHookData => {
6262
cluster: cluster as PythCluster,
6363
})
6464

65-
// Verify all accounts were processed
66-
const remainingAccounts = allPythAccounts.filter((account) => {
65+
// Get all account pubkeys from the parsed config
66+
const processedPubkeys = new Set<string>([
67+
...parsedConfig.mappingAccounts.map((acc) => acc.address.toBase58()),
68+
...parsedConfig.mappingAccounts.flatMap((mapping) =>
69+
mapping.products.map((prod) => prod.address.toBase58())
70+
),
71+
...parsedConfig.mappingAccounts.flatMap((mapping) =>
72+
mapping.products.flatMap((prod) =>
73+
prod.priceAccounts.map((price) => price.address.toBase58())
74+
)
75+
),
76+
])
77+
78+
// Find accounts that weren't included in the parsed config
79+
const unprocessedAccounts = allPythAccounts.filter((account) => {
6780
const base = parseBaseData(account.account.data)
68-
return base && base.type !== AccountType.Test
81+
// Skip permission accounts entirely
82+
if (!base || base.type === AccountType.Permission) {
83+
return false
84+
}
85+
return !processedPubkeys.has(account.pubkey.toBase58())
6986
})
7087

71-
if (remainingAccounts.length > 0) {
88+
if (unprocessedAccounts.length > 0) {
7289
console.warn(
73-
`${remainingAccounts.length} accounts were not processed`
90+
`${unprocessedAccounts.length} accounts were not processed:`,
91+
unprocessedAccounts.map((acc) => ({
92+
pubkey: acc.pubkey.toBase58(),
93+
type: parseBaseData(acc.account.data)?.type,
94+
}))
7495
)
7596
}
7697

0 commit comments

Comments
 (0)