remove duplicate publishers from json (#646)

This commit is contained in:
Daniel Chew 2023-03-02 00:35:53 +09:00 committed by GitHub
parent b3c697e5f5
commit c3ca23f3b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 11 deletions

View File

@ -172,6 +172,10 @@ const General = () => {
const fileDataParsed = sortData(JSON.parse(fileData as string))
const changes: Record<string, any> = {}
Object.keys(fileDataParsed).forEach((symbol) => {
// remove duplicate publishers
fileDataParsed[symbol].priceAccounts[0].publishers = [
...new Set(fileDataParsed[symbol].priceAccounts[0].publishers),
]
if (!existingSymbols.has(symbol)) {
// if symbol is not in existing symbols, create new entry
changes[symbol] = { new: {} }
@ -245,17 +249,6 @@ const General = () => {
}
})
// check that there are no duplicate publishers
Object.keys(jsonParsed).forEach((symbol) => {
if (
new Set(jsonParsed[symbol].priceAccounts[0].publishers).size !=
jsonParsed[symbol].priceAccounts[0].publishers.length
) {
toast.error(`${symbol} has a duplicate publisher.`)
isValid = false
}
})
// check that no price account has more than 32 publishers
Object.keys(jsonParsed).forEach((symbol) => {
if (jsonParsed[symbol].priceAccounts[0].publishers.length > 32) {