Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

verify each labelled vault is in exactly one product, fix dinero, all… #33

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions 1/products.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,10 @@
"0xb2A8bAba27B5D45Db0a4E58275cAf62DEBca7AA2",
"0xfaCaD9D934F17930d28b93F3C84a13BFAc73347C"
]
},
"dinero-protocol": {
"name": "Dinero Protocol",
"entity": ["dinero"],
"vaults": ["0xBe4089616039eC3F7361B7058d92a90246ee86e0"]
}
}
23 changes: 12 additions & 11 deletions verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,8 @@ for (let i = 0; i < fs.readdirSync("logo/").length; i++) {
for (const file of Object.keys(logos)) {
const info = imageSize(`logo/${file}`);

if (info.type !== "svg") {
// legacy PNG files: please use SVG instead
if (
file !== "re7labs.png" &&
file !== "apostro.png" &&
file !== "usual.png" &&
file !== "dinero.png" &&
file !== "alterscope_wb.png" &&
file !== "ethena.png"
)
throw Error(`logo file ${file} is not SVG`);
if (info.type !== "svg" && info.type !== "png") {
throw Error(`logo file ${file} is not SVG/PNG`);
}

if (info.height !== info.width)
Expand Down Expand Up @@ -81,6 +72,8 @@ function validateChain(chainId) {
}
}

const vaultsSeenInProducts = {};

for (const productId of Object.keys(products)) {
const product = products[productId];

Expand All @@ -94,6 +87,9 @@ function validateChain(chainId) {
`products: malformed vault address: ${ethers.getAddress(addr)}`,
);
if (!vaults[addr]) throw Error(`products: unknown vault: ${addr}`);
if (vaultsSeenInProducts[addr])
throw Error(`products: vault in multiple products: ${addr}`);
vaultsSeenInProducts[addr] = true;
}

for (const entity of getArray(product.entity)) {
Expand All @@ -104,6 +100,11 @@ function validateChain(chainId) {
throw Error(`products: logo not found: ${product.logo}`);
}

for (const vaultId of Object.keys(vaults)) {
if (!vaultsSeenInProducts[vaultId])
throw Error(`vault does not exist in product: ${vaultId}`);
}

for (const point of points) {
if (point.token && point.token !== ethers.getAddress(point.token))
throw Error(`points: malformed token: ${point.token}`);
Expand Down
Loading