diff --git a/.env b/.env new file mode 100644 index 0000000..d52a9a8 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +VALIDATE_JSON= \ No newline at end of file diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index aa99d22..a98aec7 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -15,38 +15,44 @@ name: Lint Code Base # Start the job on all push # ############################# on: - push: - branches-ignore: ["*"] - # Remove the line above to run when pushing to master - pull_request: - branches: ["*"] + push: + branches-ignore: ["*"] + # Remove the line above to run when pushing to master + pull_request: + branches: ["*"] ############### # Set the Job # ############### jobs: - build: - # Name the Job - name: Lint Code Base - # Set the agent to run on - runs-on: ubuntu-latest + build: + # Name the Job + name: Lint Code Base + # Set the agent to run on + runs-on: ubuntu-latest - ################## - # Load all steps # - ################## - steps: - ########################## - # Checkout the code base # - ########################## - - name: Checkout Code - uses: actions/checkout@v2 + ################## + # Load all steps # + ################## + steps: + ########################## + # Checkout the code base # + ########################## + - name: Checkout Code + uses: actions/checkout@v2 - ################################ - # Run Linter against code base # - ################################ - - name: Lint Code Base - uses: github/super-linter@v3 - env: - VALIDATE_ALL_CODEBASE: false - DEFAULT_BRANCH: master - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ################################ + # Run Linter against code base # + ################################ + - name: Lint Code Base + uses: github/super-linter@v3 + env: + VALIDATE_ALL_CODEBASE: false + DEFAULT_BRANCH: master + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ################################ + # Run Series CI KPI Script # + ################################ + - name: Exec Series-CI + run: | + sh ./.series-ci.sh \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3c3629e..0c8d041 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,10 @@ +.tar.gz +*.tar.gz +*.zip +*.tgz +*.tar.lz +*.tar +.DS_Store +build/ +dist/ node_modules diff --git a/.series-ci.sh b/.series-ci.sh new file mode 100644 index 0000000..3d25588 --- /dev/null +++ b/.series-ci.sh @@ -0,0 +1,22 @@ +#!/bin/usr/env bash +curl \ + --header "Authorization: Token c8ba7ebc-950c-49a5-ad5f-d69aa31a2c60" \ + --header "Content-Type: application/json" \ + --data "{ + \"values\":[ + { + \"line\":\"a\", + \"value\":\"1 %\" + }, + { + \"line\":\"b\", + \"value\":\"2 %\" + }, + { + \"line\":\"c\", + \"value\":\"3 %\" + } + ], + \"sha\":\"${GITHUB_SHA}\" + }" \ + https://seriesci.com/api/sambacha/yearn-vault-schema/:series/many diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..34e9211 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +### Changelog + +All notable changes to this project will be documented in this file. Dates are displayed in UTC. + +Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). + +#### v0.1.0 + +> 4 September 2020 + +- feat(v0.1.0): v0.1.0 release [`9e0e8b1`](https://github.com/sambacha/yearn-vault-schema/commit/9e0e8b15ef07acce1d9103aa3fd1e8debd3657bf) +- feat(github): github release [`bc4adcf`](https://github.com/sambacha/yearn-vault-schema/commit/bc4adcf2c4baef96195ae0464ed212fba7bceb90) diff --git a/README.md b/README.md index 808b5e5..769c283 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ The JSON schema represents the technical specification for yfi vaults - which ca use `camelCase` -## JSON Schema $id +## JSON Schema \$id The JSON schema ID is [schema.yfi.json](schema.yfi.json)) @@ -28,15 +28,13 @@ The Vault Lists include a `version` field, which follows [semantic versioning](h List versions must follow the rules: -- Increment major version when vaults are removed/migrated -- Increment minor version when vaults are added -- Increment patch version when vaults already on the list have minor details changed (name, symbol, logo URL, decimals) +- Increment major version when vaults are removed/migrated +- Increment minor version when vaults are added +- Increment patch version when vaults already on the list have minor details changed (name, symbol, logo URL, decimals) Changing a token address or chain ID is considered both a remove and an add, and should be a major version update. -Note that list versioning is used to improve the user experience, but not for security, i.e. list versions are not meant -to provide protection against malicious updates to a token list; i.e. the list semver is used as a lossy compression -of the diff of list updates. List updates may still be diffed in the client dApp. +Note that list versioning is used to improve the user experience, but not for security, i.e. list versions are not meant to provide protection against malicious updates to a token list; i.e. the list semver is used as a lossy compression of the diff of list updates. List updates may still be diffed in the client dApp. ## Contributors diff --git a/SPEC.md b/SPEC.md new file mode 100644 index 0000000..e78ed07 --- /dev/null +++ b/SPEC.md @@ -0,0 +1,61 @@ +# Development Specification + +This document is intended to detail the `+dev` version of the schema. It is used to document changes between versions along with record design decisions, etc. + +## TODO + +* create: array of function hashes associated with vault +where hex string e.g: `0xa68027f2` + +## +dev Changes + +> `+dev` refers to the `semver` option after the patch identifier so that there is not changes in the `0.0.x` portion of versioning + +### \$id + +ADD: Versioning in `$id` reference at top, i.e.: `"$id": "https://yearn.finance/v0.1.0+dev/vault.schema.json",` + +### Properties + +ADD: `properties` field + +## Vault Strategy + +```json + "vaultStrategy": { + "type": "object", + "description": "a strategy associated with this specific vault", + "items": { + "$ref": "#/definitions/yEarnVault" + }, + "maxLength": 18, + "examples": ["vault", "aave"] + } +``` + +### Keywords + +TODO: create a list of `keywords` for vaults && strategies + +### Tags + +TODO: create a list of `tags` for vaults && strategies + +### yipId + +```json + "yipId": { + "type": "string", + "description": "The associated YIP for this vault and/or strategy", + "minLength": 5, + "maxLength": 8, + "pattern": "/^[a-zA-Z-][a-zA-Z0-9-]*$", + "examples": ["YIP-40"] + } +``` + +## Notes + +- il8n - translations +- additional parameters useful for UIs +- additional parameters or structuring to make usability easier diff --git a/VERSIONING.md b/VERSIONING.md new file mode 100644 index 0000000..8829f99 --- /dev/null +++ b/VERSIONING.md @@ -0,0 +1,25 @@ +# Versioning + +> Matches SemVer (Semantic Versioning) strings. + +The string MAY start with a "v" but it is not matched. + +## Versioning Regex + +```pearl +/(?<=^[Vv]|^)(?:(?(?:0|[1-9](?:(?:0|[1-9])+)*))[.](?(?:0|[1-9](?:(?:0|[1-9])+)*))[.](?(?:0|[1-9](?:(?:0|[1-9])+)*))(?:-(?(?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:0|[1-9](?:(?:0|[1-9])+)*))(?:[.](?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:0|[1-9](?:(?:0|[1-9])+)*)))*))?(?:[+](?(?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:(?:0|[1-9])+))(?:[.](?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:(?:0|[1-9])+)))*))?)$/ +``` + +## Validation + +[rgxdb/semver](https://rgxdb.com/r/40OZ1HN5) + +`1.2.3-pre+build` + +```js +major = 1 +minor = 2 +patch = 3 +prerelease = pre +build = dev +``` diff --git a/dev.schema.yif.json b/dev.schema.yif.json new file mode 100644 index 0000000..9ba0ad6 --- /dev/null +++ b/dev.schema.yif.json @@ -0,0 +1,239 @@ +{ + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "https://yearn.finance/v0.1.0+dev/vault.schema.json", + "title": "YFI Vault List Schema", + "description": "Schema for YFI Vaults", + "definitions": { + "Version": { + "type": "object", + "description": "The version of the vault list, used in change detection", + "examples": [{ + "major": 1, + "minor": 0, + "patch": 0 + }], + "additionalProperties": false, + "properties": { + "major": { + "type": "integer", + "description": "The major version of the list. Must be incremented when vaults are removed from the list or token addresses are changed.", + "minimum": 0, + "examples": [1, 2] + }, + "minor": { + "type": "integer", + "description": "The minor version of the list. Must be incremented when vaults are added to the list.", + "minimum": 0, + "examples": [0, 1] + }, + "patch": { + "type": "integer", + "description": "The patch version of the list. Must be incremented for any changes to the list.", + "minimum": 0, + "examples": [0, 1] + } + }, + "required": ["major", "minor", "patch"] + } + }, + "ChainInfo": { + "type": "object", + "description": "Metadata for Chain Information", + "additionalProperties": false, + "properties": { + "chainId": { + "type": "integer", + "description": "The chain ID of the EVM-based Network where this token is deployed", + "minimum": 1, + "examples": [1, 42] + } + }, + "yfiVault": { + "type": "object", + "description": "Metadata for yfi vault", + "additionalProperties": false, + "properties": { + "yfiVaultStrategy": { + "id": { + "type": "string" + }, + "erc20Name": { + "type": "string", + "description": "The name of the token", + "minLength": 1, + "maxLength": 40, + "pattern": "^[ \\w.'+\\-%/À-ÖØ-öø-ÿ]+$" + }, + "erc20Symbol": { + "type": "string", + "description": "The symbol for the token; must be alphanumeric", + "pattern": "^[a-zA-Z0-9+\\-%/]+$" + }, + "vaultDescription": { + "type": "string" + }, + "vaultSymbol": { + "type": "string", + "description": "The symbol for the vault; must be alphanumeric", + "pattern": "^[a-zA-Z0-9+\\-%/]+$" + }, + "erc20Address": { + "type": "string", + "description": "The checksummed address of the contract address for the erc20asset on the specified chain ID", + "pattern": "^0x[a-fA-F0-9]{40}$" + }, + "vaultContractAddress": { + "type": "string", + "description": "The checksummed address of the contract address for the specified vault on the specified chain ID", + "pattern": "^0x[a-fA-F0-9]{40}$" + }, + "vaultContractABI": { + "type": "string" + }, + "vaultFunctionHashes": { + "type": "string", + "description": "the 4byte function hashes associated with this vault" + }, + "balance": { + "type": "integer" + }, + "vaultBalance": { + "type": "integer" + }, + "decimals": { + "type": "integer" + }, + "deposit": { + "type": "boolean" + }, + "depositAll": { + "type": "boolean" + }, + "withdraw": { + "type": "boolean" + }, + "withdrawAll": { + "type": "boolean" + }, + "lastMeasurement": { + "type": "integer" + }, + "measurement": { + "type": "integer" + }, + "propertyNames": { + "$ref": "#/definitions/yEarnVault" + } + }, + "tags": { + "type": "array", + "description": "An array of tag identifiers associated with the vault; tags are defined at the list level", + "items": { + "$ref": "#/definitions/TagIdentifier" + }, + "maxLength": 18, + "examples": ["vault", "aave"] + }, + "vaultStrategy": { + "type": "object", + "description": "a strategy associated with this specific vault", + "items": { + "$ref": "#/definitions/yEarnVault" + }, + "maxLength": 18, + "examples": ["vault", "aave"] + } + } + }, + "VaultList": { + "type": "object", + "additionalProperties": false, + "properties": { + "name": { + "type": "string", + "description": "The name of the vault and/or list", + "minLength": 1, + "maxLength": 20, + "pattern": "^[\\w ]+$", + "examples": ["yETH"] + }, + "yipId": { + "type": "string", + "description": "The associated YIP for this vault and/or strategy", + "minLength": 5, + "maxLength": 8, + "pattern": "/^[a-zA-Z-][a-zA-Z0-9-]*$", + "examples": ["YIP-40"] + }, + "timestamp": { + "type": "string", + "format": "date-time", + "description": "The timestamp of this list version; i.e. when this immutable version of the list was created as defined by standard UNIX Epoch time" + }, + "version": { + "$ref": "#/definitions/Version" + }, + "tokens": { + "type": "array", + "description": "The list of tokens included in the list of vaults", + "items": { + "$ref": "#/definitions/TokenInfo" + }, + "minItems": 1, + "maxItems": 1000 + }, + "keywords": { + "type": "array", + "description": "Keywords associated with the contents of the vault; may be used in list discoverability", + "items": { + "type": "string", + "description": "A keyword to describe the contents of the vault", + "minLength": 1, + "maxLength": 20, + "pattern": "^[\\w ]+$", + "examples": ["aave", "lending", "personal tokens"] + }, + "maxItems": 20, + "uniqueItems": true + }, + "tags": { + "type": "object", + "description": "A mapping of tag identifiers to their name and description", + "pattern": "^[ \\w]+$", + "propertyNames": { + "$ref": "#/definitions/TagIdentifier" + }, + "additionalProperties": { + "$ref": "#/definitions/TagDefinition" + }, + "maxProperties": 20, + "examples": [{ + "stablecoin": { + "name": "Stablecoin", + "description": "A token with value pegged to another asset" + } + }] + } + }, + "required": [ + "id", + "name", + "symbol", + "description", + "vaultSymbol", + "erc20address", + "vaultContractAddress", + "vaultContractABI", + "balance", + "vaultBalance", + "decimals", + "deposit", + "depositAll", + "withdraw", + "withdrawAll", + "lastMeasurement", + "measurement" + ] + } + } +} \ No newline at end of file diff --git a/dev/README.md b/dev/README.md new file mode 100644 index 0000000..2c30c34 --- /dev/null +++ b/dev/README.md @@ -0,0 +1,40 @@ +# Development Documents + +> Reference Regex for usage in the schema file + +```pearl +/ +# protocol user host-ip port path path path querystring fragment +^ +#protocol +(?:(?[a-zA-Z][a-zA-Z\d+-.]*):)? +(?: + (?: + (?: + \/\/ + (?: + #userinfo + (?:((?:[a-zA-Z\d\-._~\!$&'()*+,;=%]*)(?::(?:[a-zA-Z\d\-._~\!$&'()*+,;=:%]*))?)@)? + #host-ip + ((?:[a-zA-Z\d-.%]+)|(?:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|(?:\[(?:[a-fA-F\d.:]+)\]))? + #port + (?::(\d*))? + ) + ) + #slash-path + ( + (?:\/[a-zA-Z\d\-._~\!$&'()*+,;=:@%]*)* + ) + ) + #slash-path + |(\/(?:(?:[a-zA-Z\d\-._~\!$&'()*+,;=:@%]+(?:\/[a-zA-Z\d\-._~\!$&'()*+,;=:@%]*)*))?) + #path + |([a-zA-Z\d\-._~\!$&'()*+,;=:@%]+(?:\/[a-zA-Z\d\-._~\!$&'()*+,;=:@%]*)*) +)? +#querystring +(?:\?([a-zA-Z\d\-._~\!$&'()*+,;=:@%\/?]*))? +#fragment +(?:\#([a-zA-Z\d\-._~\!$&'()*+,;=:@%\/?]*))? +$ +/x +``` diff --git a/package-lock.json b/package-lock.json index a551ffb..6142ce7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "yearn-json-schema", - "version": "1.0.0", + "version": "0.2.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 0f7d4b4..27ac4b2 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,13 @@ { "name": "yearn-json-schema", - "version": "0.1.0", + "version": "0.2.1", "description": "Schema for YFI Vaults from iearn.finance", - "main": "index.json", + "main": "src/index.json", "scripts": { - "test": "ajv compile -s schema.yif.json", + "test": "ajv compile -s src/schema.yif.json", "release": "npx release-it", - "changelog": "npx auto-changelog" + "changelog": "npx auto-changelog", + "schema-version": "cat schema.version" }, "keywords": [ "yearn", diff --git a/schema.version b/schema.version new file mode 100644 index 0000000..6e8bf73 --- /dev/null +++ b/schema.version @@ -0,0 +1 @@ +0.1.0 diff --git a/index.json b/src/index.json similarity index 69% rename from index.json rename to src/index.json index 9d3eccd..416543f 100644 --- a/index.json +++ b/src/index.json @@ -2,5 +2,5 @@ "name": "yearn.vault.schema.json", "description": "yearn vault schema list", "fileMatch": ["schema.json", ".yfi.json"], - "url": "https://yearn.finance/vault.schema.json" + "url": "https://yearn.finance/v0.1.0/vault.schema.json" } diff --git a/schema.yif.json b/src/schema.yif.json similarity index 100% rename from schema.yif.json rename to src/schema.yif.json diff --git a/vault.json b/src/vault.json similarity index 100% rename from vault.json rename to src/vault.json diff --git a/test.vault.json b/test.vault.json new file mode 100644 index 0000000..671a288 --- /dev/null +++ b/test.vault.json @@ -0,0 +1,27 @@ +{ + "yfiVault": { + "id": "ETH", + "name": "ETH", + "symbol": "ETH", + "description": "Ether", + "vaultSymbol": "yETH", + "erc20address": "Ethereum", + "vaultContractAddress": "0xe1237aA7f535b0CC33Fd973D66cBf830354D16c7", + "vaultContractABI": "config.vaultContractV4ABI", + "balance": 0, + "vaultBalance": 0, + "decimals": 18, + "deposit": true, + "depositAll": false, + "withdraw": true, + "withdrawAll": true, + "lastMeasurement": 10774489, + "measurement": 1000000000000000000, + "chainId": 1, + "vaultList": "yEth", + "tags": "ethereum, yeth", + "tokens": "eth", + "vaultFunctionHashes": "0x00000", + "yipId": "YIP-YIP" + } +}