From 80d4faa42caa9587df0719cf7048643a17c10912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Pr=C3=A9vost?= <998369+prevostc@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:34:17 +0100 Subject: [PATCH] Check contract config duplicates --- bin/check-config.ts | 57 +++++++++++++++++++++++++++++++++++++++++++ data/gnosis_data.json | 5 ---- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/bin/check-config.ts b/bin/check-config.ts index 866e332..a12287c 100644 --- a/bin/check-config.ts +++ b/bin/check-config.ts @@ -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() diff --git a/data/gnosis_data.json b/data/gnosis_data.json index b7a53bd..41a7dd2 100644 --- a/data/gnosis_data.json +++ b/data/gnosis_data.json @@ -2,14 +2,9 @@ "no_factory_vaults": [ "0x1de0375e770efb9c92d7958cbb5b53c9fb8eb1cb", "0x21c4d71882364b395209c07a7710a9251c285d73", - "0x3e442af13db47e27b48de6caf2708b2d180b10f9", "0x4b6edd5e8f68a7b6502af7872cedc5c31c343b00", "0x50583f8dce18d4180f074be7332b4734968246ec", - "0x5f603c60adb40691939b9a740beecef4b0f5c146", "0x78c90c28edc5f4b266bfd40b01e7de8ebb3682f7", - "0x89e1dfc9088c3d9d9050eae7aae2fb79369f2092", - "0xa12fb8417cff62f717235009c58140c8f91c660e", - "0xd40da4e7ec845ea7940b09122ff34306d78c4c03", "0xe21396a3f0e752ac03b195cf140de84e58e58771", "0xf49de23df72c886946eef19d1b751b3d997ef668", "0xf9ac09ec1ab2e4cd5ca2cf9451d3a49fd6b25cc5"