From 7fb635f10032efdc20aa5302567d85dbf82fb219 Mon Sep 17 00:00:00 2001 From: Troy Kessler Date: Wed, 5 Jun 2024 10:24:20 +0200 Subject: [PATCH] chore: remove schemas --- integrations/tendermint/package.json | 1 - integrations/tendermint/src/runtime.ts | 27 -- .../tendermint/src/schemas/block.json | 345 ------------------ .../tendermint/src/schemas/block_result.json | 277 -------------- yarn.lock | 2 +- 5 files changed, 1 insertion(+), 651 deletions(-) delete mode 100644 integrations/tendermint/src/schemas/block.json delete mode 100644 integrations/tendermint/src/schemas/block_result.json diff --git a/integrations/tendermint/package.json b/integrations/tendermint/package.json index 9bde4a1e..f7e66bce 100644 --- a/integrations/tendermint/package.json +++ b/integrations/tendermint/package.json @@ -23,7 +23,6 @@ }, "dependencies": { "@kyvejs/protocol": "1.1.7", - "ajv": "^8.12.0", "axios": "^0.27.2", "dotenv": "^16.3.1" }, diff --git a/integrations/tendermint/src/runtime.ts b/integrations/tendermint/src/runtime.ts index 65bbfe5e..57080d21 100644 --- a/integrations/tendermint/src/runtime.ts +++ b/integrations/tendermint/src/runtime.ts @@ -1,11 +1,6 @@ import { DataItem, IRuntime, Validator, VOTE } from '@kyvejs/protocol'; import { name, version } from '../package.json'; import axios from 'axios'; -import Ajv from 'ajv'; -import block_schema from './schemas/block.json'; -import block_results_schema from './schemas/block_result.json'; - -const ajv = new Ajv(); // Tendermint config interface IConfig { @@ -100,28 +95,6 @@ export default class Tendermint implements IRuntime { ); } - // validate block schema - const block_validate = ajv.compile(block_schema); - - if (!block_validate(item.value.block)) { - throw new Error( - `Block schema validation failed: ${JSON.stringify( - block_validate.errors - )}` - ); - } - - // validate block_results schema - const block_results_validate = ajv.compile(block_results_schema); - - if (!block_results_validate(item.value.block_results)) { - throw new Error( - `Block results schema validation failed: ${JSON.stringify( - block_results_validate.errors - )}` - ); - } - return true; } diff --git a/integrations/tendermint/src/schemas/block.json b/integrations/tendermint/src/schemas/block.json deleted file mode 100644 index b86cdb70..00000000 --- a/integrations/tendermint/src/schemas/block.json +++ /dev/null @@ -1,345 +0,0 @@ -{ - "type": "object", - "properties": { - "block_id": { - "type": "object", - "properties": { - "hash": { - "type": "string" - }, - "parts": { - "type": "object", - "properties": { - "total": { - "type": "integer" - }, - "hash": { - "type": "string" - } - }, - "required": ["total", "hash"] - } - }, - "required": ["hash", "parts"] - }, - "block": { - "type": "object", - "properties": { - "header": { - "type": "object", - "properties": { - "version": { - "type": "object", - "properties": { - "block": { - "type": "string" - } - }, - "required": ["block"] - }, - "chain_id": { - "type": "string" - }, - "height": { - "type": "string" - }, - "time": { - "type": "string" - }, - "last_block_id": { - "type": "object", - "properties": { - "hash": { - "type": "string" - }, - "parts": { - "type": "object", - "properties": { - "total": { - "type": "integer" - }, - "hash": { - "type": "string" - } - }, - "required": ["total", "hash"] - } - }, - "required": ["hash", "parts"] - }, - "last_commit_hash": { - "type": "string" - }, - "data_hash": { - "type": "string" - }, - "validators_hash": { - "type": "string" - }, - "next_validators_hash": { - "type": "string" - }, - "consensus_hash": { - "type": "string" - }, - "app_hash": { - "type": "string" - }, - "last_results_hash": { - "type": "string" - }, - "evidence_hash": { - "type": "string" - }, - "proposer_address": { - "type": "string" - } - }, - "required": [ - "version", - "chain_id", - "height", - "time", - "last_block_id", - "last_commit_hash", - "data_hash", - "validators_hash", - "next_validators_hash", - "consensus_hash", - "app_hash", - "last_results_hash", - "evidence_hash", - "proposer_address" - ] - }, - "data": { - "type": "object", - "properties": { - "txs": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "required": ["txs"] - }, - "evidence": { - "type": "object", - "properties": { - "evidence": { - "type": "array", - "items": { - "type": "object", - "properties": { - "type": { - "type": "string" - }, - "value": { - "type": "object", - "properties": { - "vote_a": { - "type": "object", - "properties": { - "type": { - "type": "integer" - }, - "height": { - "type": "string" - }, - "round": { - "type": "integer" - }, - "block_id": { - "type": "object", - "properties": { - "hash": { - "type": "string" - }, - "parts": { - "type": "object", - "properties": { - "total": { - "type": "integer" - }, - "hash": { - "type": "string" - } - }, - "required": ["total", "hash"] - } - }, - "required": ["hash", "parts"] - }, - "timestamp": { - "type": "string" - }, - "validator_address": { - "type": "string" - }, - "validator_index": { - "type": "integer" - }, - "signature": { - "type": "string" - } - }, - "required": [ - "type", - "height", - "round", - "block_id", - "timestamp", - "validator_address", - "validator_index", - "signature" - ] - }, - "vote_b": { - "type": "object", - "properties": { - "type": { - "type": "integer" - }, - "height": { - "type": "string" - }, - "round": { - "type": "integer" - }, - "block_id": { - "type": "object", - "properties": { - "hash": { - "type": "string" - }, - "parts": { - "type": "object", - "properties": { - "total": { - "type": "integer" - }, - "hash": { - "type": "string" - } - }, - "required": ["total", "hash"] - } - }, - "required": ["hash", "parts"] - }, - "timestamp": { - "type": "string" - }, - "validator_address": { - "type": "string" - }, - "validator_index": { - "type": "integer" - }, - "signature": { - "type": "string" - } - }, - "required": [ - "type", - "height", - "round", - "block_id", - "timestamp", - "validator_address", - "validator_index", - "signature" - ] - }, - "TotalVotingPower": { - "type": "string" - }, - "ValidatorPower": { - "type": "string" - }, - "Timestamp": { - "type": "string" - } - }, - "required": [ - "vote_a", - "vote_b", - "TotalVotingPower", - "ValidatorPower", - "Timestamp" - ] - } - }, - "required": ["type", "value"] - } - } - }, - "required": ["evidence"] - }, - "last_commit": { - "type": "object", - "properties": { - "height": { - "type": "string" - }, - "round": { - "type": "integer" - }, - "block_id": { - "type": "object", - "properties": { - "hash": { - "type": "string" - }, - "parts": { - "type": "object", - "properties": { - "total": { - "type": "integer" - }, - "hash": { - "type": "string" - } - }, - "required": ["total", "hash"] - } - }, - "required": ["hash", "parts"] - }, - "signatures": { - "type": "array", - "items": { - "type": "object", - "properties": { - "block_id_flag": { - "type": "integer" - }, - "validator_address": { - "type": "string" - }, - "timestamp": { - "type": "string" - }, - "signature": { - "type": ["string", "null"] - } - }, - "required": [ - "block_id_flag", - "validator_address", - "timestamp", - "signature" - ] - } - } - }, - "required": ["height", "round", "block_id", "signatures"] - } - }, - "required": ["header", "data", "evidence", "last_commit"] - } - }, - "required": ["block_id", "block"], - "additionalProperties": false -} diff --git a/integrations/tendermint/src/schemas/block_result.json b/integrations/tendermint/src/schemas/block_result.json deleted file mode 100644 index 471f7d43..00000000 --- a/integrations/tendermint/src/schemas/block_result.json +++ /dev/null @@ -1,277 +0,0 @@ -{ - "type": "object", - "properties": { - "height": { - "type": "string" - }, - "txs_results": { - "type": ["array", "null"], - "items": [ - { - "type": "object", - "properties": { - "code": { - "type": "integer" - }, - "data": { - "type": ["string", "null"] - }, - "log": { - "type": "string" - }, - "info": { - "type": "string" - }, - "gas_wanted": { - "type": "string" - }, - "gas_used": { - "type": "string" - }, - "events": { - "type": "array", - "items": [ - { - "type": "object", - "properties": { - "type": { - "type": "string" - }, - "attributes": { - "type": "array", - "items": [ - { - "type": "object", - "properties": { - "key": { - "type": "string" - }, - "value": { - "type": ["string", "null"] - }, - "index": { - "type": "boolean" - } - }, - "required": ["key", "value", "index"] - } - ] - } - }, - "required": ["type", "attributes"] - } - ] - }, - "codespace": { - "type": "string" - } - }, - "required": [ - "code", - "data", - "log", - "info", - "gas_wanted", - "gas_used", - "events", - "codespace" - ] - } - ] - }, - "begin_block_events": { - "type": ["array", "null"], - "items": [ - { - "type": "object", - "properties": { - "type": { - "type": "string" - }, - "attributes": { - "type": "array", - "items": [ - { - "type": "object", - "properties": { - "key": { - "type": "string" - }, - "value": { - "type": ["string", "null"] - }, - "index": { - "type": "boolean" - } - }, - "required": ["key", "value", "index"] - } - ] - } - }, - "required": ["type", "attributes"] - } - ] - }, - "end_block_events": { - "type": ["array", "null"], - "items": [ - { - "type": "object", - "properties": { - "type": { - "type": "string" - }, - "attributes": { - "type": "array", - "items": [ - { - "type": "object", - "properties": { - "key": { - "type": "string" - }, - "value": { - "type": ["string", "null"] - }, - "index": { - "type": "boolean" - } - }, - "required": ["key", "value", "index"] - } - ] - } - }, - "required": ["type", "attributes"] - } - ] - }, - "finalize_block_events": { - "type": ["array", "null"], - "items": [ - { - "type": "object", - "properties": { - "type": { - "type": "string" - }, - "attributes": { - "type": "array", - "items": [ - { - "type": "object", - "properties": { - "key": { - "type": "string" - }, - "value": { - "type": ["string", "null"] - }, - "index": { - "type": "boolean" - } - }, - "required": ["key", "value", "index"] - } - ] - } - }, - "required": ["type", "attributes"] - } - ] - }, - "validator_updates": { - "type": ["array", "null"], - "items": [ - { - "type": "object", - "properties": { - "pub_key": { - "type": "object", - "properties": { - "Sum": { - "type": "object", - "properties": { - "type": { - "type": "string" - }, - "value": { - "type": "object", - "properties": { - "ed25519": { - "type": "string" - } - }, - "required": ["ed25519"] - } - }, - "required": ["type", "value"] - } - }, - "required": ["Sum"] - }, - "power": { - "type": "string" - } - } - } - ], - "required": ["pub_key"] - }, - "consensus_param_updates": { - "type": "object", - "properties": { - "block": { - "type": "object", - "properties": { - "max_bytes": { - "type": "string" - }, - "max_gas": { - "type": "string" - } - }, - "required": ["max_bytes", "max_gas"] - }, - "evidence": { - "type": "object", - "properties": { - "max_age_num_blocks": { - "type": "string" - }, - "max_age_duration": { - "type": "string" - }, - "max_bytes": { - "type": "string" - } - }, - "required": ["max_age_num_blocks", "max_age_duration", "max_bytes"] - }, - "validator": { - "type": "object", - "properties": { - "pub_key_types": { - "type": "array", - "items": [ - { - "type": "string" - } - ] - } - }, - "required": ["pub_key_types"] - } - }, - "required": ["block", "evidence", "validator"] - } - }, - "required": [ - "height", - "txs_results", - "validator_updates", - "consensus_param_updates" - ], - "additionalProperties": true -} diff --git a/yarn.lock b/yarn.lock index 76993553..b5edb344 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3482,7 +3482,7 @@ ajv@^6.12.4: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ajv@^8.11.0, ajv@^8.12.0: +ajv@^8.11.0: version "8.12.0" resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.12.0.tgz#d1a0527323e22f53562c567c00991577dfbe19d1" integrity sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==