Skip to content

Commit

Permalink
Check contract config duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
prevostc committed Dec 18, 2024
1 parent 3c82361 commit 80d4faa
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 5 deletions.
57 changes: 57 additions & 0 deletions bin/check-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,63 @@ async function main() {
}
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// check contracts in data files are not discovered from factory as well
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
for (const chain of uniqChains) {
const fs = require("fs")
if (!fs.existsSync(`./data/${chain}_data.json`)) {
continue
}
const data = JSON.parse(fs.readFileSync(`./data/${chain}_data.json`, "utf8"))

const gql = `
query Misconfig {
duplicate_config: contracts(where: {
factory: true,
config: true,
}) {
id
}
none_config: contracts(where: {
factory: false,
config: false,
}) {
id
}
}
`

// only use the next version of the subgraph
const subgraphUrl = `https://api.goldsky.com/api/public/project_clu2walwem1qm01w40v3yhw1f/subgraphs/beefy-balances-${chain}/next/gn`
const result = await fetch(subgraphUrl, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ query: gql }),
})

if (!result.ok) {
console.error(`Failed to fetch data from subgraph: ${result.statusText}`)
continue
}

const resultData = (await result.json()) as {
data: {
duplicate_config: { id: string }[]
none_config: { id: string }[]
}
}

for (const contract of resultData.data.duplicate_config) {
console.error(`${chain}: Contract ${contract.id} is discovered from factory as well`)
}

for (const contract of resultData.data.none_config) {
console.error(`${chain}: Contract ${contract.id} is not discovered from factory`)
}
}
}

main()
5 changes: 0 additions & 5 deletions data/gnosis_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@
"no_factory_vaults": [
"0x1de0375e770efb9c92d7958cbb5b53c9fb8eb1cb",
"0x21c4d71882364b395209c07a7710a9251c285d73",
"0x3e442af13db47e27b48de6caf2708b2d180b10f9",
"0x4b6edd5e8f68a7b6502af7872cedc5c31c343b00",
"0x50583f8dce18d4180f074be7332b4734968246ec",
"0x5f603c60adb40691939b9a740beecef4b0f5c146",
"0x78c90c28edc5f4b266bfd40b01e7de8ebb3682f7",
"0x89e1dfc9088c3d9d9050eae7aae2fb79369f2092",
"0xa12fb8417cff62f717235009c58140c8f91c660e",
"0xd40da4e7ec845ea7940b09122ff34306d78c4c03",
"0xe21396a3f0e752ac03b195cf140de84e58e58771",
"0xf49de23df72c886946eef19d1b751b3d997ef668",
"0xf9ac09ec1ab2e4cd5ca2cf9451d3a49fd6b25cc5"
Expand Down

0 comments on commit 80d4faa

Please sign in to comment.