Skip to content

Commit 80d4faa

Browse files
committed
Check contract config duplicates
1 parent 3c82361 commit 80d4faa

File tree

2 files changed

+57
-5
lines changed

2 files changed

+57
-5
lines changed

bin/check-config.ts

+57
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,63 @@ async function main() {
425425
}
426426
}
427427
}
428+
429+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
430+
// check contracts in data files are not discovered from factory as well
431+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
432+
for (const chain of uniqChains) {
433+
const fs = require("fs")
434+
if (!fs.existsSync(`./data/${chain}_data.json`)) {
435+
continue
436+
}
437+
const data = JSON.parse(fs.readFileSync(`./data/${chain}_data.json`, "utf8"))
438+
439+
const gql = `
440+
query Misconfig {
441+
duplicate_config: contracts(where: {
442+
factory: true,
443+
config: true,
444+
}) {
445+
id
446+
}
447+
448+
none_config: contracts(where: {
449+
factory: false,
450+
config: false,
451+
}) {
452+
id
453+
}
454+
}
455+
`
456+
457+
// only use the next version of the subgraph
458+
const subgraphUrl = `https://api.goldsky.com/api/public/project_clu2walwem1qm01w40v3yhw1f/subgraphs/beefy-balances-${chain}/next/gn`
459+
const result = await fetch(subgraphUrl, {
460+
method: "POST",
461+
headers: { "Content-Type": "application/json" },
462+
body: JSON.stringify({ query: gql }),
463+
})
464+
465+
if (!result.ok) {
466+
console.error(`Failed to fetch data from subgraph: ${result.statusText}`)
467+
continue
468+
}
469+
470+
const resultData = (await result.json()) as {
471+
data: {
472+
duplicate_config: { id: string }[]
473+
none_config: { id: string }[]
474+
}
475+
}
476+
477+
for (const contract of resultData.data.duplicate_config) {
478+
console.error(`${chain}: Contract ${contract.id} is discovered from factory as well`)
479+
}
480+
481+
for (const contract of resultData.data.none_config) {
482+
console.error(`${chain}: Contract ${contract.id} is not discovered from factory`)
483+
}
484+
}
428485
}
429486

430487
main()

data/gnosis_data.json

-5
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@
22
"no_factory_vaults": [
33
"0x1de0375e770efb9c92d7958cbb5b53c9fb8eb1cb",
44
"0x21c4d71882364b395209c07a7710a9251c285d73",
5-
"0x3e442af13db47e27b48de6caf2708b2d180b10f9",
65
"0x4b6edd5e8f68a7b6502af7872cedc5c31c343b00",
76
"0x50583f8dce18d4180f074be7332b4734968246ec",
8-
"0x5f603c60adb40691939b9a740beecef4b0f5c146",
97
"0x78c90c28edc5f4b266bfd40b01e7de8ebb3682f7",
10-
"0x89e1dfc9088c3d9d9050eae7aae2fb79369f2092",
11-
"0xa12fb8417cff62f717235009c58140c8f91c660e",
12-
"0xd40da4e7ec845ea7940b09122ff34306d78c4c03",
138
"0xe21396a3f0e752ac03b195cf140de84e58e58771",
149
"0xf49de23df72c886946eef19d1b751b3d997ef668",
1510
"0xf9ac09ec1ab2e4cd5ca2cf9451d3a49fd6b25cc5"

0 commit comments

Comments
 (0)