From 07f6635d57c91ea6688f72ef33592e32e6689322 Mon Sep 17 00:00:00 2001 From: Conway <43109407+conwayconstar@users.noreply.github.com> Date: Thu, 12 Sep 2024 15:32:37 +0100 Subject: [PATCH] feat: add points schema --- 1/points.json | 13 +++++++++++++ README.md | 11 +++++++++++ verify.js | 19 +++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 1/points.json diff --git a/1/points.json b/1/points.json new file mode 100644 index 0000000..817dba1 --- /dev/null +++ b/1/points.json @@ -0,0 +1,13 @@ +[ + { + "token": "0xbC4B4AC47582c3E38Ce5940B80Da65401F4628f1", + "name": "Euler points", + "description": "testing", + "logo": "euler.svg", + "url": "https://euler.finance", + "vaults": [ + "0xbC4B4AC47582c3E38Ce5940B80Da65401F4628f1" + ], + "entity": "euler-dao" + } +] diff --git a/README.md b/README.md index c1f6507..e62f8e7 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,17 @@ Each entry in this object corresponds to a lending product, which is primarily a * `logo`: The filename of a logo stored in the `logo/` directory. * `vaults`: An array of the vault addresses (in checksumed hex format) that comprise the product. Each vault must exist in the `vaults.json` file. +### `points.json` + +Each entry in this array corresponds to points available on deposits in a vault. Each item has the following + +* `token`: The token address (in a checksumed hex format) that the points are denominated in. (Required) +* `name`: The name of the points, for example "Euler Points". (Required) +* `description`: A long-form description of the points, displayed within points tooltips. +* `url`: A URL where users can learn more about the points. +* `logo`: The filename of a logo stored in the `logo/` directory. (Required) +* `vaults`: An array of the vault addresses (in checksumed hex format) that offer these points. Each vault does not need to exist in the `vaults.json` file. (Required) +* `entity`: An entity ID that refers to the organisation responsible for governing and/or creating this vault, or a list of entity IDs if the vault is joint-managed. ## Logos diff --git a/verify.js b/verify.js index ae7eda5..d969aa5 100644 --- a/verify.js +++ b/verify.js @@ -40,6 +40,7 @@ function validateChain(chainId) { let entities = loadJsonFile(`${chainId}/entities.json`); let vaults = loadJsonFile(`${chainId}/vaults.json`); let products = loadJsonFile(`${chainId}/products.json`); + let points = loadJsonFile(`${chainId}/points.json`); for (let entityId of Object.keys(entities)) { let entity = entities[entityId]; @@ -84,9 +85,23 @@ function validateChain(chainId) { if (product.logo && !logos[product.logo]) throw Error(`products: logo not found: ${product.logo}`); } + for(const point of points) { + if (point.token !== ethers.getAddress(point.token)) throw Error(`points: malformed token: ${point.token}`); + if (!point.name) throw Error(`points: missing name: ${point.name}`); + if (point.url && !validUrl(point.url)) throw Error(`points: missing name: ${point.name}`); + if (point.logo && !logos[point.logo]) throw Error(`points: logo not found: ${product.logo}`); + for (let addr of point.vaults) { + if (addr !== ethers.getAddress(addr)) throw Error(`points: malformed vault address: ${addr}`); + } + for (let entity of getArray(point.entity)) { + if (!entities[entity]) throw Error(`points: no such entity ${entity}`); + } + } + checkFormatting(`${chainId}/entities.json`); checkFormatting(`${chainId}/vaults.json`); checkFormatting(`${chainId}/products.json`); + checkFormatting(`${chainId}/points.json`); } function loadJsonFile(file) { @@ -97,6 +112,10 @@ function validSlug(slug) { return /^[a-z0-9-]+$/.test(slug); } +function validUrl(url) { + return /^(https?:\/\/)?([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,63}(\/[^\s]*)?$/.test(url); +} + function getArray(v) { if (Array.isArray(v)) return v; return [v];