Skip to content

Commit 9e742f5

Browse files
committed
refactor: dont delete in map
1 parent 84110f7 commit 9e742f5

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ export function getConfig(params: GetConfigParams): RawConfig {
221221
const rawConfig: RawConfig = { mappingAccounts: [] };
222222

223223
// Process mapping accounts
224+
const processedProducts = new Map<string, boolean>();
224225
const mappingAccounts = accounts
225226
.filter(
226227
(account) =>
@@ -232,10 +233,16 @@ export function getConfig(params: GetConfigParams): RawConfig {
232233
next: parsed.nextMappingAccount,
233234
address: account.pubkey,
234235
products: parsed.productAccountKeys
235-
.filter((key) => productRawConfigs[key.toBase58()])
236+
.filter((key) => {
237+
const keyStr = key.toBase58();
238+
// Only include products that exist and haven't been processed yet
239+
return productRawConfigs[keyStr] && !processedProducts.has(keyStr);
240+
})
236241
.map((key) => {
237-
const product = productRawConfigs[key.toBase58()];
238-
delete productRawConfigs[key.toBase58()];
242+
const keyStr = key.toBase58();
243+
const product = productRawConfigs[keyStr];
244+
// Mark this product as processed
245+
processedProducts.set(keyStr, true);
239246
return product;
240247
}),
241248
};

0 commit comments

Comments
 (0)