From d8b0d237c2060ed22b1f422c7c8225f2b6a75470 Mon Sep 17 00:00:00 2001 From: "lightclient@protonmail.com" Date: Wed, 28 Jul 2021 19:17:31 +0200 Subject: [PATCH 1/2] split spec into multiple files --- .github/workflows/build.yaml | 27 + .gitignore | 1 + openrpc.json | 1304 ---------------------------------- package.json | 1 + scripts/build.js | 52 ++ src/methods/block.json | 128 ++++ src/methods/chain.json | 14 + src/methods/client.json | 62 ++ src/methods/execute.json | 40 ++ src/methods/filter.json | 114 +++ src/methods/mining.json | 110 +++ src/methods/sign.json | 47 ++ src/methods/state.json | 117 +++ src/methods/submit.json | 40 ++ src/methods/transaction.json | 91 +++ src/schemas/base-types.json | 52 ++ src/schemas/block.json | 129 ++++ src/schemas/client.json | 30 + src/schemas/filter.json | 70 ++ src/schemas/receipt.json | 99 +++ src/schemas/transaction.json | 175 +++++ 21 files changed, 1399 insertions(+), 1304 deletions(-) create mode 100644 .github/workflows/build.yaml delete mode 100644 openrpc.json create mode 100644 scripts/build.js create mode 100644 src/methods/block.json create mode 100644 src/methods/chain.json create mode 100644 src/methods/client.json create mode 100644 src/methods/execute.json create mode 100644 src/methods/filter.json create mode 100644 src/methods/mining.json create mode 100644 src/methods/sign.json create mode 100644 src/methods/state.json create mode 100644 src/methods/submit.json create mode 100644 src/methods/transaction.json create mode 100644 src/schemas/base-types.json create mode 100644 src/schemas/block.json create mode 100644 src/schemas/client.json create mode 100644 src/schemas/filter.json create mode 100644 src/schemas/receipt.json create mode 100644 src/schemas/transaction.json diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 000000000..f2a6ee78b --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,27 @@ +name: Build specification + +on: + push: + branches: + - master + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [15.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm run build + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Assemble openrpc.json + branch: assembled-spec diff --git a/.gitignore b/.gitignore index c2658d7d1..5668b82a0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules/ +openrpc.json diff --git a/openrpc.json b/openrpc.json deleted file mode 100644 index 520f32c00..000000000 --- a/openrpc.json +++ /dev/null @@ -1,1304 +0,0 @@ -{ - "openrpc": "1.2.4", - "info": { - "title": "Ethereum JSON-RPC Specification", - "description": "A specification of the standard interface for Ethereum clients.", - "license": { - "name": "CC0-1.0", - "url": "https://creativecommons.org/publicdomain/zero/1.0/legalcode" - }, - "version": "0.0.0" - }, - "methods": [ - { - "name": "eth_protocolVersion", - "summary": "Returns the current ethereum protocol version.", - "params": [], - "result": { - "name": "Protocol version", - "schema": { - "title": "version", - "type": "string" - } - } - }, - { - "name": "eth_syncing", - "summary": "Returns an object with data about the sync status or false.", - "params": [], - "result": { - "name": "Syncing status", - "schema": { - "$ref": "#/components/schemas/SyncingStatus" - } - } - }, - { - "name": "eth_coinbase", - "summary": "Returns the client coinbase address.", - "params": [], - "result": { - "name": "Coinbase address", - "schema": { - "$ref": "#/components/schemas/address" - } - } - }, - { - "name": "eth_mining", - "summary": "Returns whether the client is actively mining new blocks.", - "params": [], - "result": { - "name": "Mining status", - "schema": { - "title": "miningStatus", - "type": "boolean" - } - } - }, - { - "name": "eth_hashrate", - "summary": "Returns the number of hashes per second that the node is mining with.", - "params": [], - "result": { - "name": "Mining status", - "schema": { - "title": "Hashrate", - "$ref": "#/components/schemas/uint" - } - } - }, - { - "name": "eth_gasPrice", - "summary": "Returns the current price per gas in wei.", - "params": [], - "result": { - "name": "Gas price", - "schema": { - "title": "Gas price", - "$ref": "#/components/schemas/uint" - } - } - }, - { - "name": "eth_accounts", - "summary": "Returns a list of addresses owned by client.", - "params": [], - "result": { - "name": "Accounts", - "schema": { - "title": "Accounts", - "type": "array", - "items": { - "$ref": "#/components/schemas/address" - } - } - } - }, - { - "name": "eth_blockNumber", - "summary": "Returns the number of most recent block.", - "params": [], - "result": { - "name": "Block number", - "schema": { - "$ref": "#/components/schemas/uint" - } - } - }, - { - "name": "eth_getBalance", - "summary": "Returns the balance of the account of given address.", - "params": [ - { - "name": "Address", - "required": true, - "schema": { - "$ref": "#/components/schemas/address" - } - }, - { - "name": "Block", - "required": true, - "schema": { - "$ref": "#/components/schemas/BlockNumberOrTag" - } - } - ], - "result": { - "name": "Balance", - "schema": { - "$ref": "#/components/schemas/uint" - } - } - }, - { - "name": "eth_getStorage", - "summary": "Returns the value from a storage position at a given address.", - "params": [ - { - "name": "Address", - "required": true, - "schema": { - "$ref": "#/components/schemas/address" - } - }, - { - "name": "Storage slot", - "required": true, - "schema": { - "$ref": "#/components/schemas/uint256" - } - }, - { - "name": "Block", - "required": true, - "schema": { - "$ref": "#/components/schemas/BlockNumberOrTag" - } - } - ], - "result": { - "name": "Value", - "schema": { - "$ref": "#/components/schemas/bytes" - } - } - }, - { - "name": "eth_getTransactionCount", - "summary": "Returns the number of transactions sent from an address.", - "params": [ - { - "name": "Address", - "required": true, - "schema": { - "$ref": "#/components/schemas/address" - } - }, - { - "name": "Block", - "required": true, - "schema": { - "$ref": "#/components/schemas/BlockNumberOrTag" - } - } - ], - "result": { - "name": "Transaction count", - "schema": { - "title": "Transaction count", - "type": "array", - "items": { - "$ref": "#/components/schemas/uint" - } - } - } - }, - { - "name": "eth_getBlockTransactionCountByHash", - "summary": "Returns the number of transactions in a block from a block matching the given block hash.", - "params": [ - { - "name": "Block hash", - "schema": { - "$ref": "#/components/schemas/hash32" - } - } - ], - "result": { - "name": "Transaction count", - "schema": { - "title": "Transaction count", - "type": "array", - "items": { - "$ref": "#/components/schemas/uint" - } - } - } - }, - { - "name": "eth_getBlockTransactionCountByNumber", - "summary": "Returns the number of transactions in a block matching the given block number.", - "params": [ - { - "name": "Block number", - "schema": { - "$ref": "#/components/schemas/uint" - } - } - ], - "result": { - "name": "Transaction count", - "schema": { - "title": "Transaction count", - "type": "array", - "items": { - "$ref": "#/components/schemas/uint" - } - } - } - }, - { - "name": "eth_getUncleCountByBlockHash", - "summary": "Returns the number of uncles in a block from a block matching the given block hash.", - "params": [ - { - "name": "Block hash", - "schema": { - "$ref": "#/components/schemas/hash32" - } - } - ], - "result": { - "name": "Uncle count", - "schema": { - "title": "Uncle count", - "type": "array", - "items": { - "$ref": "#/components/schemas/uint" - } - } - } - }, - { - "name": "eth_getUncleCountByBlockNumber", - "summary": "Returns the number of transactions in a block matching the given block number.", - "params": [ - { - "name": "Block number", - "schema": { - "$ref": "#/components/schemas/uint" - } - } - ], - "result": { - "name": "Uncle count", - "schema": { - "title": "Uncle count", - "type": "array", - "items": { - "$ref": "#/components/schemas/uint" - } - } - } - }, - { - "name": "eth_getCode", - "summary": "Returns code at a given address.", - "params": [ - { - "name": "Address", - "required": true, - "schema": { - "$ref": "#/components/schemas/address" - } - }, - { - "name": "Block", - "required": true, - "schema": { - "$ref": "#/components/schemas/BlockNumberOrTag" - } - } - ], - "result": { - "name": "Bytecode", - "schema": { - "$ref": "#/components/schemas/bytes" - } - } - }, - { - "name": "eth_sign", - "summary": "Returns an EIP-191 signature over the provided data.", - "params": [ - { - "name": "Address", - "required": true, - "schema": { - "$ref": "#/components/schemas/address" - } - }, - { - "name": "Message", - "required": true, - "schema": { - "$ref": "#/components/schemas/bytes" - } - } - ], - "result": { - "name": "Signature", - "schema": { - "$ref": "#/components/schemas/bytes65" - } - } - }, - { - "name": "eth_signTransaction", - "summary": "Returns an RLP encoded transaction signed by the specified account.", - "params": [ - { - "name": "Transaction", - "required": true, - "schema": { - "$ref": "#/components/schemas/TransactionWithSender" - } - } - ], - "result": { - "name": "Encoded transaction", - "schema": { - "$ref": "#/components/schemas/bytes" - } - } - }, - { - "name": "eth_sendTransaction", - "summary": "Signs and submits a transaction.", - "params": [ - { - "name": "Transaction", - "required": true, - "schema": { - "$ref": "#/components/schemas/TransactionWithSender" - } - } - ], - "result": { - "name": "Transaction hash", - "schema": { - "$ref": "#/components/schemas/hash32" - } - } - }, - { - "name": "eth_sendRawTransaction", - "summary": "Submits a raw transaction.", - "params": [ - { - "name": "Transaction", - "required": true, - "schema": { - "$ref": "#/components/schemas/bytes" - } - } - ], - "result": { - "name": "Transaction hash", - "schema": { - "$ref": "#/components/schemas/hash32" - } - } - }, - { - "name": "eth_call", - "summary": "Executes a new message call immediately without creating a transaction on the block chain.", - "params": [ - { - "name": "Transaction", - "required": true, - "schema": { - "$ref": "#/components/schemas/TransactionWithSender" - } - } - ], - "result": { - "name": "Return data", - "schema": { - "$ref": "#/components/schemas/bytes" - } - } - }, - { - "name": "eth_estimateGas", - "summary": "Generates and returns an estimate of how much gas is necessary to allow the transaction to complete.", - "params": [ - { - "name": "Transaction", - "required": true, - "schema": { - "$ref": "#/components/schemas/TransactionWithSender" - } - } - ], - "result": { - "name": "Gas used", - "schema": { - "$ref": "#/components/schemas/uint" - } - } - }, - { - "name": "eth_getBlockByHash", - "summary": "Returns information about a block by hash.", - "params": [ - { - "name": "Block hash", - "required": true, - "schema": { - "$ref": "#/components/schemas/hash32" - } - } - ], - "result": { - "name": "Block information", - "schema": { - "$ref": "#/components/schemas/Block" - } - } - }, - { - "name": "eth_getBlockByNumber", - "summary": "Returns information about a block by number.", - "params": [ - { - "name": "Block number", - "required": true, - "schema": { - "$ref": "#/components/schemas/uint" - } - } - ], - "result": { - "name": "Block information", - "schema": { - "$ref": "#/components/schemas/Block" - } - } - }, - { - "name": "eth_getTransactionByHash", - "summary": "Returns the information about a transaction requested by transaction hash.", - "params": [ - { - "name": "Transaction hash", - "required": true, - "schema": { - "$ref": "#/components/schemas/hash32" - } - } - ], - "result": { - "name": "Transaction information", - "schema": { - "$ref": "#/components/schemas/TransactionInfo" - } - } - }, - { - "name": "eth_getTransactionByBlockHashAndIndex", - "summary": "Returns information about a transaction by block hash and transaction index position.", - "params": [ - { - "name": "Block hash", - "required": true, - "schema": { - "$ref": "#/components/schemas/hash32" - } - }, - { - "name": "Transaction index", - "required": true, - "schema": { - "$ref": "#/components/schemas/uint" - } - } - ], - "result": { - "name": "Transaction information", - "schema": { - "$ref": "#/components/schemas/TransactionInfo" - } - } - }, - { - "name": "eth_getTransactionByBlockNumberAndIndex", - "summary": "Returns information about a transaction by block number and transaction index position.", - "params": [ - { - "name": "Block number", - "required": true, - "schema": { - "$ref": "#/components/schemas/uint" - } - }, - { - "name": "Transaction index", - "required": true, - "schema": { - "$ref": "#/components/schemas/uint" - } - } - ], - "result": { - "name": "Transaction information", - "schema": { - "$ref": "#/components/schemas/TransactionInfo" - } - } - }, - { - "name": "eth_getTransactionReceipt", - "summary": "Returns the receipt of a transaction by transaction hash.", - "params": [ - { - "name": "Transaction hash", - "schema": { - "$ref": "#/components/schemas/hash32" - } - } - ], - "result": { - "name": "Receipt Information", - "schema": { - "$ref": "#/components/schemas/ReceiptInfo" - } - } - }, - { - "name": "eth_newFilter", - "summary": "Creates a filter object, based on filter options, to notify when the state changes (logs).", - "params": [ - { - "name": "Filter", - "schema": { - "$ref": "#/components/schemas/Filter" - } - } - ], - "result": { - "name": "Filter Identifier", - "schema": { - "$ref": "#/components/schemas/uint" - } - } - }, - { - "name": "eth_newBlockFilter", - "summary": "Creates a filter in the node, to notify when a new block arrives.", - "params": [], - "result": { - "name": "Filter Identifier", - "schema": { - "$ref": "#/components/schemas/uint" - } - } - }, - { - "name": "eth_newPendingTransactionFilter", - "summary": "Creates a filter in the node, to notify when new pending transactions arrive.", - "params": [], - "result": { - "name": "Filter Identifier", - "schema": { - "$ref": "#/components/schemas/uint" - } - } - }, - { - "name": "eth_uninstallFilter", - "summary": "Uninstalls a filter with given id.", - "params": [ - { - "name": "Filter Identifier", - "schema": { - "$ref": "#/components/schemas/uint" - } - } - ], - "result": { - "name": "Success", - "schema": { - "type": "boolean" - } - } - }, - { - "name": "eth_getFilterChanges", - "summary": "Polling method for a filter, which returns an array of logs which occurred since last poll.", - "params": [ - { - "name": "Filter Identifier", - "schema": { - "$ref": "#/components/schemas/uint" - } - } - ], - "result": { - "name": "Log objects", - "schema": { - "$ref": "#/components/schemas/FilterResults" - } - } - }, - { - "name": "eth_getFilterLogs", - "summary": "Returns an array of all logs matching filter with given id.", - "params": [ - { - "name": "Filter Identifier", - "schema": { - "$ref": "#/components/schemas/uint" - } - } - ], - "result": { - "name": "Log objects", - "schema": { - "$ref": "#/components/schemas/FilterResults" - } - } - }, - { - "name": "eth_getLogs", - "summary": "Returns an array of all logs matching filter with given id.", - "params": [ - { - "name": "Filter", - "schema": { - "$ref": "#/components/schemas/Filter" - } - } - ], - "result": { - "name": "Log objects", - "schema": { - "$ref": "#/components/schemas/FilterResults" - } - } - }, - { - "name": "eth_getWork", - "summary": "Returns the hash of the current block, the seedHash, and the boundary condition to be met (“target”).", - "params": [], - "result": { - "name": "Current work", - "schema": { - "type": "array", - "items": [ - { - "title": "PoW hash", - "$ref": "#/components/schemas/bytes32" - }, - { - "title": "seed hash", - "$ref": "#/components/schemas/bytes32" - }, - { - "title": "difficulty", - "$ref": "#/components/schemas/bytes32" - } - ] - } - } - }, - { - "name": "eth_submitWork", - "summary": "Used for submitting a proof-of-work solution.", - "params": [ - { - "name": "PoW hash", - "required": true, - "schema": { - "$ref": "#/components/schemas/bytes32" - } - }, - { - "name": "seed hash", - "required": true, - "schema": { - "$ref": "#/components/schemas/bytes32" - } - }, - { - "name": "difficulty", - "required": true, - "schema": { - "$ref": "#/components/schemas/bytes32" - } - } - ], - "result": { - "name": "Success", - "schema": { - "type": "boolean" - } - } - }, - { - "name": "eth_submitHashrate", - "summary": "Used for submitting mining hashrate.", - "params": [ - { - "name": "Hashrate", - "required": true, - "schema": { - "$ref": "#/components/schemas/bytes32" - } - }, - { - "name": "ID", - "required": true, - "schema": { - "$ref": "#/components/schemas/bytes32" - } - } - ], - "result": { - "name": "Success", - "schema": { - "type": "boolean" - } - } - } - ], - "components": { - "schemas": { - "address": { - "title": "hex encoded address", - "type": "string", - "pattern": "^0x[0-9a-f]{40}$" - }, - "addresses": { - "title": "hex encoded address", - "type": "array", - "items": { "$ref": "#/components/schemas/address" } - }, - "byte": { - "title": "hex encoded byte", - "type": "string", - "pattern": "^0x([a-fA-F0-9]?){1,2}$" - }, - "bytes": { - "title": "hex encoded bytes", - "type": "string", - "pattern": "^0x[0-9a-f]+$" - }, - "bytes32": { - "title": "32 hex encoded bytes", - "type": "string", - "pattern": "^0x[0-9a-f]{64}$" - }, - "bytes256": { - "title": "256 hex encoded bytes", - "type": "string", - "pattern": "^0x[0-9a-f]{512}$" - }, - "bytes65": { - "title": "65 hex encoded bytes", - "type": "string", - "pattern": "^0x[0-9a-f]{512}$" - }, - "uint": { - "title": "hex encoded unsigned integer", - "type": "string", - "pattern": "^0x[0-9a-f]+$" - }, - "uint256": { - "title": "hex encoded unsigned integer", - "type": "string", - "pattern": "^0x[0-9a-f]{64}$" - }, - "hash32": { - "title": "32 byte hex value", - "type": "string", - "pattern": "^0x[0-9a-f]{64}$" - }, - "BlockTag": { - "title": "Block tag", - "type": "string", - "enum": ["earliest", "latest", "pending"] - }, - "BlockNumberOrTag": { - "title": "Block number or tag", - "oneOf": [ - { - "title": "Block number", - "$ref": "#/components/schemas/uint" - }, - { - "title": "Block tag", - "$ref": "#/components/schemas/BlockTag" - } - ] - }, - "SyncingStatus": { - "title": "Syncing status", - "oneOf": [ - { - "title": "Syncing progress", - "type": "object", - "properties": { - "startingBlock": { - "title": "Starting block", - "$ref": "#/components/schemas/uint" - }, - "currentBlock": { - "title": "Current block", - "$ref": "#/components/schemas/uint" - }, - "highestBlock": { - "title": "Highest block", - "$ref": "#/components/schemas/uint" - } - } - }, - { - "title": "Not syncing", - "description": "Should always return false if not syncing.", - "type": "boolean" - } - ] - }, - "FilterResults": { - "title": "Filter results", - "oneOf": [ - { - "title": "new block hashes", - "type": "array", - "items": { - "$ref": "#/components/schemas/hash32" - } - }, - { - "title": "new transaction hashes", - "type": "array", - "items": { - "$ref": "#/components/schemas/hash32" - } - }, - { - "title": "new logs", - "type": "array", - "items": { - "$ref": "#/components/schemas/Log" - } - } - ] - }, - "Header": { - "title": "Header object", - "type": "object", - "required": [ - "parentHash", - "sha3Uncles", - "miner", - "stateRoot", - "transactionsRoot", - "receiptRoot", - "bloom", - "totalDifficulty", - "number", - "gasLimit", - "gasUsed", - "timestamp", - "extraData", - "mixHash", - "nonce" - ], - "properties": { - "parentHash": { - "title": "Parent block hash", - "$ref": "#/components/schemas/hash32" - }, - "sha3Uncles": { - "title": "Ommers hash", - "$ref": "#/components/schemas/hash32" - }, - "miner": { - "title": "Coinbase", - "$ref": "#/components/schemas/address" - }, - "stateRoot": { - "title": "State root", - "$ref": "#/components/schemas/hash32" - }, - "transactionsRoot": { - "title": "Transactions root", - "$ref": "#/components/schemas/hash32" - }, - "receiptRoot": { - "title": "Receipts root", - "$ref": "#/components/schemas/hash32" - }, - "bloom": { - "title": "Bloom filter", - "$ref": "#/components/schemas/bytes256" - }, - "totalDifficulty": { - "title": "Difficulty", - "$ref": "#/components/schemas/bytes" - }, - "number": { - "title": "Number", - "$ref": "#/components/schemas/uint" - }, - "gasLimit": { - "title": "Gas limit", - "$ref": "#/components/schemas/uint" - }, - "gasUsed": { - "title": "Gas used", - "$ref": "#/components/schemas/uint" - }, - "timestamp": { - "title": "Timestamp", - "$ref": "#/components/schemas/uint" - }, - "extraData": { - "title": "Extra data", - "$ref": "#/components/schemas/bytes" - }, - "mixHash": { - "title": "Mix hash", - "$ref": "#/components/schemas/hash32" - }, - "nonce": { - "title": "nonce", - "$ref": "#/components/schemas/bytes" - }, - "baseFeePerGas": { - "title": "Base fee per gas", - "$ref": "#/components/schemas/uint" - } - } - }, - "Block": { - "title": "Block object", - "type": "object", - "required": ["transactions", "uncles"], - "allOf": [ - { "$ref": "#/components/schemas/Header" }, - { - "title": "transactions", - "type": "array", - "items": { - "$ref": "#/components/schemas/hash32" - } - }, - { - "title": "uncles", - "type": "array", - "items": { - "$ref": "#/components/schemas/hash32" - } - } - ] - }, - "AccessListEntry": { - "title": "Access list entry", - "type": "object", - "properties": { - "address": { - "$ref": "#/components/schemas/address" - }, - "storageKeys": { - "type": "array", - "items": { - "$ref": "#/components/schemas/hash32" - } - } - } - }, - "AccessList": { - "title": "Access list", - "type": "object", - "items": { - "$ref": "#/components/schemas/AccessListEntry" - } - }, - "SignedTransaction": { - "title": "Signed transaction object", - "type": "object", - "allOf": [ - { "$ref": "#/components/schemas/Transaction" }, - { - "required": ["v", "r", "s"], - "properties": { - "v": { - "title": "v", - "$ref": "#/components/schemas/uint" - }, - "r": { - "title": "r", - "$ref": "#/components/schemas/uint" - }, - "s": { - "title": "s", - "$ref": "#/components/schemas/uint" - } - } - } - ] - }, - "TransactionWithSender": { - "title": "Transaction object with sender", - "type": "object", - "allOf": [ - { - "required": ["from"], - "properties": { - "from": { - "title": "from", - "$ref": "#/components/schemas/address" - } - } - }, - { "$ref": "#/components/schemas/Transaction" } - ] - }, - "Transaction": { - "type": "object", - "title": "Transaction object", - "allOf": [ - { - "required": ["nonce", "gas", "value", "input"], - "properties": { - "type": { - "title": "type", - "$ref": "#/components/schemas/byte" - }, - "nonce": { - "title": "nonce", - "$ref": "#/components/schemas/uint" - }, - "to": { - "title": "to address", - "$ref": "#/components/schemas/address" - }, - "gas": { - "title": "gas limit", - "$ref": "#/components/schemas/uint" - }, - "value": { - "title": "value", - "$ref": "#/components/schemas/uint" - }, - "input": { - "title": "input data", - "$ref": "#/components/schemas/bytes" - }, - "accessList": { - "title": "accessList", - "description": "EIP-2930 access list", - "$ref": "#/components/schemas/AccessList" - } - } - }, - { - "oneOf": [ - { - "title": "EIP-1559 fee market parameters", - "type": "object", - "description": "EIP-1559 dynamic fee transactions have two fee parameters.", - "required": [ - "maxFeePerGas", - "maxPriorityFeePerGas" - ], - "properties": { - "maxPriorityFeePerGas": { - "title": "max priority fee per gas", - "description": "Maximum fee per gas the sender is willing to pay to miners in wei", - "$ref": "#/components/schemas/uint" - }, - "maxFeePerGas": { - "title": "max fee per gas", - "description": "The maximum total fee per gas the sender is willing to pay (includes the network / base fee and miner / priority fee) in wei", - "$ref": "#/components/schemas/uint" - } - } - }, - { - "title": "Legacy fee market parameters", - "type": "object", - "description": "Legacy transactions and EIP-2930 access list transaction include this parameter.", - "required": ["gasPrice"], - "properties": { - "gasPrice": { - "title": "gas price", - "description": "The gas price willing to be paid by the sender in wei", - "$ref": "#/components/schemas/uint" - } - } - } - ] - } - ] - }, - "TransactionInfo": { - "type": "object", - "title": "Transaction information", - "allOf": [ - { - "title": "Contextual information", - "required": ["blockHash", "blockNumber", "from", "hash", "transactionIndex"], - "properties": { - "blockHash": { - "title": "block hash", - "$ref": "#/components/schemas/hash32" - }, - "blockNumber": { - "title": "block number", - "$ref": "#/components/schemas/uint" - }, - "from": { - "title": "from address", - "$ref": "#/components/schemas/address" - }, - "hash": { - "title": "transaction hash", - "$ref": "#/components/schemas/hash32" - }, - "transactionIndex": { - "title": "transaction index", - "$ref": "#/components/schemas/uint" - } - } - }, - { "$ref": "#/components/schemas/SignedTransaction"} - ] - }, - "Filter": { - "title": "filter", - "type": "object", - "properties": { - "fromBlock": { - "title": "from block", - "$ref": "#/components/schemas/uint" - }, - "toBlock": { - "title": "to block", - "$ref": "#/components/schemas/uint" - }, - "address": { - "title": "Address(es)", - "oneOf": [ - { - "title": "Address", - "$ref": "#/components/schemas/address" - }, - { - "title": "Addresses", - "$ref": "#/components/schemas/addresses" - } - ] - }, - "topics": { - "title": "Topics", - "$ref": "#/components/schemas/Topics" - } - } - }, - "Topic": { - "title": "Topic", - "$ref": "#/components/schemas/uint256" - }, - "Topics": { - "title": "Topics", - "type": "array", - "items": { - "$ref": "#/components/schemas/Topic" - } - }, - "Log": { - "title": "log", - "type": "object", - "properties": { - "removed": { - "title": "removed", - "type": "boolean" - }, - "logIndex": { - "title": "log index", - "$ref": "#/components/schemas/uint" - }, - "transactionIndex": { - "title": "transaction index", - "$ref": "#/components/schemas/uint" - }, - "transactionHash": { - "title": "transaction hash", - "$ref": "#/components/schemas/hash32" - }, - "blockHash": { - "title": "block hash", - "$ref": "#/components/schemas/hash32" - }, - "blockNumber": { - "title": "block number", - "$ref": "#/components/schemas/uint" - }, - "address": { - "title": "address", - "$ref": "#/components/schemas/address" - }, - "data": { - "title": "data", - "$ref": "#/components/schemas/bytes" - }, - "topics": { - "title": "topics", - "$ref": "#/components/schemas/Topics" - } - } - }, - "ReceiptInfo": { - "type": "object", - "title": "Receipt info", - "required": [ - "transactionHash", "transactionIndex", "value", "input"], - "properties": { - "transactionHash": { - "title": "transaction hash", - "$ref": "#/components/schemas/hash32" - }, - "transactionIndex": { - "title": "transaction index", - "$ref": "#/components/schemas/uint" - }, - "blockHash": { - "title": "block hash", - "$ref": "#/components/schemas/hash32" - }, - "blockNumber": { - "title": "block number", - "$ref": "#/components/schemas/uint" - }, - "from": { - "title": "from", - "$ref": "#/components/schemas/address" - }, - "to": { - "title": "to", - "$ref": "#/components/schemas/address" - }, - "cumulativeGasUsed": { - "title": "accessList", - "$ref": "#/components/schemas/uint" - }, - "gasUsed": { - "title": "gasUsed", - "$ref": "#/components/schemas/uint" - }, - "contractAddress": { - "title": "contract address", - "$ref": "#/components/schemas/address" - }, - "logs": { - "title": "logs", - "type": "array", - "items": { - "$ref": "#/components/schemas/Log" - } - }, - "logsBloom": { - "title": "logs bloom", - "$ref": "#/components/schemas/bytes256" - } - } - } - } - } -} diff --git a/package.json b/package.json index 7d3f67574..6e11683e4 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "main": "index.js", "type": "module", "scripts": { + "build": "node scripts/build.js", "lint": "node scripts/validate.js" }, "repository": { diff --git a/scripts/build.js b/scripts/build.js new file mode 100644 index 000000000..da7cceb4a --- /dev/null +++ b/scripts/build.js @@ -0,0 +1,52 @@ +import fs from "fs"; + +console.log("Loading files..."); + +let methods = []; +let methodsBase = "src/methods/"; +let methodFiles = fs.readdirSync(methodsBase); +methodFiles.forEach(file => { + console.log(file); + let raw = fs.readFileSync(methodsBase + file); + let parsed = JSON.parse(raw); + methods = [ + ...methods, + ...parsed, + ]; +}); + +let schemas = {}; +let schemasBase = "src/schemas/" +let schemaFiles = fs.readdirSync(schemasBase); +schemaFiles.forEach(file => { + console.log(file); + let raw = fs.readFileSync(schemasBase + file); + let parsed = JSON.parse(raw); + schemas = { + ...schemas, + ...parsed, + }; +}); + +const spec = { + openrpc: "1.2.4", + info: { + title: "Ethereum JSON-RPC Specification", + description: "A specification of the standard interface for Ethereum clients.", + license: { + name: "CC0-1.0", + url: "https://creativecommons.org/publicdomain/zero/1.0/legalcode" + }, + version: "0.0.0" + }, + methods: methods, + components: { + schemas: schemas + } +} + +let data = JSON.stringify(spec, null, '\t'); +fs.writeFileSync('openrpc.json', data); + +console.log(); +console.log("Build successful."); diff --git a/src/methods/block.json b/src/methods/block.json new file mode 100644 index 000000000..2ca1443b6 --- /dev/null +++ b/src/methods/block.json @@ -0,0 +1,128 @@ +[ + { + "name": "eth_getBlockByHash", + "summary": "Returns information about a block by hash.", + "params": [ + { + "name": "Block hash", + "required": true, + "schema": { + "$ref": "#/components/schemas/hash32" + } + } + ], + "result": { + "name": "Block information", + "schema": { + "$ref": "#/components/schemas/Block" + } + } + }, + { + "name": "eth_getBlockByNumber", + "summary": "Returns information about a block by number.", + "params": [ + { + "name": "Block number", + "required": true, + "schema": { + "$ref": "#/components/schemas/uint" + } + } + ], + "result": { + "name": "Block information", + "schema": { + "$ref": "#/components/schemas/Block" + } + } + }, + { + "name": "eth_getBlockTransactionCountByHash", + "summary": "Returns the number of transactions in a block from a block matching the given block hash.", + "params": [ + { + "name": "Block hash", + "schema": { + "$ref": "#/components/schemas/hash32" + } + } + ], + "result": { + "name": "Transaction count", + "schema": { + "title": "Transaction count", + "type": "array", + "items": { + "$ref": "#/components/schemas/uint" + } + } + } + }, + { + "name": "eth_getBlockTransactionCountByNumber", + "summary": "Returns the number of transactions in a block matching the given block number.", + "params": [ + { + "name": "Block number", + "schema": { + "$ref": "#/components/schemas/uint" + } + } + ], + "result": { + "name": "Transaction count", + "schema": { + "title": "Transaction count", + "type": "array", + "items": { + "$ref": "#/components/schemas/uint" + } + } + } + }, + { + "name": "eth_getUncleCountByBlockHash", + "summary": "Returns the number of uncles in a block from a block matching the given block hash.", + "params": [ + { + "name": "Block hash", + "schema": { + "$ref": "#/components/schemas/hash32" + } + } + ], + "result": { + "name": "Uncle count", + "schema": { + "title": "Uncle count", + "type": "array", + "items": { + "$ref": "#/components/schemas/uint" + } + } + } + }, + { + "name": "eth_getUncleCountByBlockNumber", + "summary": "Returns the number of transactions in a block matching the given block number.", + "params": [ + { + "name": "Block number", + "schema": { + "$ref": "#/components/schemas/uint" + } + } + ], + "result": { + "name": "Uncle count", + "schema": { + "title": "Uncle count", + "type": "array", + "items": { + "$ref": "#/components/schemas/uint" + } + } + } + } +] diff --git a/src/methods/chain.json b/src/methods/chain.json new file mode 100644 index 000000000..c876006f6 --- /dev/null +++ b/src/methods/chain.json @@ -0,0 +1,14 @@ +[ + { + "name": "eth_gasPrice", + "summary": "Returns the current price per gas in wei.", + "params": [], + "result": { + "name": "Gas price", + "schema": { + "title": "Gas price", + "$ref": "#/components/schemas/uint" + } + } + } +] diff --git a/src/methods/client.json b/src/methods/client.json new file mode 100644 index 000000000..2a0c2e250 --- /dev/null +++ b/src/methods/client.json @@ -0,0 +1,62 @@ +[ + { + "name": "eth_protocolVersion", + "summary": "Returns the current ethereum protocol version.", + "params": [], + "result": { + "name": "Protocol version", + "schema": { + "title": "version", + "type": "string" + } + } + }, + { + "name": "eth_syncing", + "summary": "Returns an object with data about the sync status or false.", + "params": [], + "result": { + "name": "Syncing status", + "schema": { + "$ref": "#/components/schemas/SyncingStatus" + } + } + }, + { + "name": "eth_coinbase", + "summary": "Returns the client coinbase address.", + "params": [], + "result": { + "name": "Coinbase address", + "schema": { + "$ref": "#/components/schemas/address" + } + } + }, + { + "name": "eth_accounts", + "summary": "Returns a list of addresses owned by client.", + "params": [], + "result": { + "name": "Accounts", + "schema": { + "title": "Accounts", + "type": "array", + "items": { + "$ref": "#/components/schemas/address" + } + } + } + }, + { + "name": "eth_blockNumber", + "summary": "Returns the number of most recent block.", + "params": [], + "result": { + "name": "Block number", + "schema": { + "$ref": "#/components/schemas/uint" + } + } + } +] diff --git a/src/methods/execute.json b/src/methods/execute.json new file mode 100644 index 000000000..c0cea3a64 --- /dev/null +++ b/src/methods/execute.json @@ -0,0 +1,40 @@ +[ + { + "name": "eth_call", + "summary": "Executes a new message call immediately without creating a transaction on the block chain.", + "params": [ + { + "name": "Transaction", + "required": true, + "schema": { + "$ref": "#/components/schemas/TransactionWithSender" + } + } + ], + "result": { + "name": "Return data", + "schema": { + "$ref": "#/components/schemas/bytes" + } + } + }, + { + "name": "eth_estimateGas", + "summary": "Generates and returns an estimate of how much gas is necessary to allow the transaction to complete.", + "params": [ + { + "name": "Transaction", + "required": true, + "schema": { + "$ref": "#/components/schemas/TransactionWithSender" + } + } + ], + "result": { + "name": "Gas used", + "schema": { + "$ref": "#/components/schemas/uint" + } + } + } +] diff --git a/src/methods/filter.json b/src/methods/filter.json new file mode 100644 index 000000000..2d7b609bb --- /dev/null +++ b/src/methods/filter.json @@ -0,0 +1,114 @@ +[ + { + "name": "eth_newFilter", + "summary": "Creates a filter object, based on filter options, to notify when the state changes (logs).", + "params": [ + { + "name": "Filter", + "schema": { + "$ref": "#/components/schemas/Filter" + } + } + ], + "result": { + "name": "Filter Identifier", + "schema": { + "$ref": "#/components/schemas/uint" + } + } + }, + { + "name": "eth_newBlockFilter", + "summary": "Creates a filter in the node, to notify when a new block arrives.", + "params": [], + "result": { + "name": "Filter Identifier", + "schema": { + "$ref": "#/components/schemas/uint" + } + } + }, + { + "name": "eth_newPendingTransactionFilter", + "summary": "Creates a filter in the node, to notify when new pending transactions arrive.", + "params": [], + "result": { + "name": "Filter Identifier", + "schema": { + "$ref": "#/components/schemas/uint" + } + } + }, + { + "name": "eth_uninstallFilter", + "summary": "Uninstalls a filter with given id.", + "params": [ + { + "name": "Filter Identifier", + "schema": { + "$ref": "#/components/schemas/uint" + } + } + ], + "result": { + "name": "Success", + "schema": { + "type": "boolean" + } + } + }, + { + "name": "eth_getFilterChanges", + "summary": "Polling method for a filter, which returns an array of logs which occurred since last poll.", + "params": [ + { + "name": "Filter Identifier", + "schema": { + "$ref": "#/components/schemas/uint" + } + } + ], + "result": { + "name": "Log objects", + "schema": { + "$ref": "#/components/schemas/FilterResults" + } + } + }, + { + "name": "eth_getFilterLogs", + "summary": "Returns an array of all logs matching filter with given id.", + "params": [ + { + "name": "Filter Identifier", + "schema": { + "$ref": "#/components/schemas/uint" + } + } + ], + "result": { + "name": "Log objects", + "schema": { + "$ref": "#/components/schemas/FilterResults" + } + } + }, + { + "name": "eth_getLogs", + "summary": "Returns an array of all logs matching filter with given id.", + "params": [ + { + "name": "Filter", + "schema": { + "$ref": "#/components/schemas/Filter" + } + } + ], + "result": { + "name": "Log objects", + "schema": { + "$ref": "#/components/schemas/FilterResults" + } + } + } +] diff --git a/src/methods/mining.json b/src/methods/mining.json new file mode 100644 index 000000000..33314a8d4 --- /dev/null +++ b/src/methods/mining.json @@ -0,0 +1,110 @@ +[ + { + "name": "eth_mining", + "summary": "Returns whether the client is actively mining new blocks.", + "params": [], + "result": { + "name": "Mining status", + "schema": { + "title": "miningStatus", + "type": "boolean" + } + } + }, + { + "name": "eth_hashrate", + "summary": "Returns the number of hashes per second that the node is mining with.", + "params": [], + "result": { + "name": "Mining status", + "schema": { + "title": "Hashrate", + "$ref": "#/components/schemas/uint" + } + } + }, + { + "name": "eth_getWork", + "summary": "Returns the hash of the current block, the seedHash, and the boundary condition to be met (“target”).", + "params": [], + "result": { + "name": "Current work", + "schema": { + "type": "array", + "items": [ + { + "title": "PoW hash", + "$ref": "#/components/schemas/bytes32" + }, + { + "title": "seed hash", + "$ref": "#/components/schemas/bytes32" + }, + { + "title": "difficulty", + "$ref": "#/components/schemas/bytes32" + } + ] + } + } + }, + { + "name": "eth_submitWork", + "summary": "Used for submitting a proof-of-work solution.", + "params": [ + { + "name": "PoW hash", + "required": true, + "schema": { + "$ref": "#/components/schemas/bytes32" + } + }, + { + "name": "seed hash", + "required": true, + "schema": { + "$ref": "#/components/schemas/bytes32" + } + }, + { + "name": "difficulty", + "required": true, + "schema": { + "$ref": "#/components/schemas/bytes32" + } + } + ], + "result": { + "name": "Success", + "schema": { + "type": "boolean" + } + } + }, + { + "name": "eth_submitHashrate", + "summary": "Used for submitting mining hashrate.", + "params": [ + { + "name": "Hashrate", + "required": true, + "schema": { + "$ref": "#/components/schemas/bytes32" + } + }, + { + "name": "ID", + "required": true, + "schema": { + "$ref": "#/components/schemas/bytes32" + } + } + ], + "result": { + "name": "Success", + "schema": { + "type": "boolean" + } + } + } +] diff --git a/src/methods/sign.json b/src/methods/sign.json new file mode 100644 index 000000000..74d4109e9 --- /dev/null +++ b/src/methods/sign.json @@ -0,0 +1,47 @@ +[ + { + "name": "eth_sign", + "summary": "Returns an EIP-191 signature over the provided data.", + "params": [ + { + "name": "Address", + "required": true, + "schema": { + "$ref": "#/components/schemas/address" + } + }, + { + "name": "Message", + "required": true, + "schema": { + "$ref": "#/components/schemas/bytes" + } + } + ], + "result": { + "name": "Signature", + "schema": { + "$ref": "#/components/schemas/bytes65" + } + } + }, + { + "name": "eth_signTransaction", + "summary": "Returns an RLP encoded transaction signed by the specified account.", + "params": [ + { + "name": "Transaction", + "required": true, + "schema": { + "$ref": "#/components/schemas/TransactionWithSender" + } + } + ], + "result": { + "name": "Encoded transaction", + "schema": { + "$ref": "#/components/schemas/bytes" + } + } + } +] diff --git a/src/methods/state.json b/src/methods/state.json new file mode 100644 index 000000000..4d5164602 --- /dev/null +++ b/src/methods/state.json @@ -0,0 +1,117 @@ +[ + { + "name": "eth_getBalance", + "summary": "Returns the balance of the account of given address.", + "params": [ + { + "name": "Address", + "required": true, + "schema": { + "$ref": "#/components/schemas/address" + } + }, + { + "name": "Block", + "required": true, + "schema": { + "$ref": "#/components/schemas/BlockNumberOrTag" + } + } + ], + "result": { + "name": "Balance", + "schema": { + "$ref": "#/components/schemas/uint" + } + } + }, + { + "name": "eth_getStorage", + "summary": "Returns the value from a storage position at a given address.", + "params": [ + { + "name": "Address", + "required": true, + "schema": { + "$ref": "#/components/schemas/address" + } + }, + { + "name": "Storage slot", + "required": true, + "schema": { + "$ref": "#/components/schemas/uint256" + } + }, + { + "name": "Block", + "required": true, + "schema": { + "$ref": "#/components/schemas/BlockNumberOrTag" + } + } + ], + "result": { + "name": "Value", + "schema": { + "$ref": "#/components/schemas/bytes" + } + } + }, + { + "name": "eth_getTransactionCount", + "summary": "Returns the number of transactions sent from an address.", + "params": [ + { + "name": "Address", + "required": true, + "schema": { + "$ref": "#/components/schemas/address" + } + }, + { + "name": "Block", + "required": true, + "schema": { + "$ref": "#/components/schemas/BlockNumberOrTag" + } + } + ], + "result": { + "name": "Transaction count", + "schema": { + "title": "Transaction count", + "type": "array", + "items": { + "$ref": "#/components/schemas/uint" + } + } + } + }, + { + "name": "eth_getCode", + "summary": "Returns code at a given address.", + "params": [ + { + "name": "Address", + "required": true, + "schema": { + "$ref": "#/components/schemas/address" + } + }, + { + "name": "Block", + "required": true, + "schema": { + "$ref": "#/components/schemas/BlockNumberOrTag" + } + } + ], + "result": { + "name": "Bytecode", + "schema": { + "$ref": "#/components/schemas/bytes" + } + } + } +] diff --git a/src/methods/submit.json b/src/methods/submit.json new file mode 100644 index 000000000..279e10483 --- /dev/null +++ b/src/methods/submit.json @@ -0,0 +1,40 @@ +[ + { + "name": "eth_sendTransaction", + "summary": "Signs and submits a transaction.", + "params": [ + { + "name": "Transaction", + "required": true, + "schema": { + "$ref": "#/components/schemas/TransactionWithSender" + } + } + ], + "result": { + "name": "Transaction hash", + "schema": { + "$ref": "#/components/schemas/hash32" + } + } + }, + { + "name": "eth_sendRawTransaction", + "summary": "Submits a raw transaction.", + "params": [ + { + "name": "Transaction", + "required": true, + "schema": { + "$ref": "#/components/schemas/bytes" + } + } + ], + "result": { + "name": "Transaction hash", + "schema": { + "$ref": "#/components/schemas/hash32" + } + } + } +] diff --git a/src/methods/transaction.json b/src/methods/transaction.json new file mode 100644 index 000000000..21e254828 --- /dev/null +++ b/src/methods/transaction.json @@ -0,0 +1,91 @@ +[ + { + "name": "eth_getTransactionByHash", + "summary": "Returns the information about a transaction requested by transaction hash.", + "params": [ + { + "name": "Transaction hash", + "required": true, + "schema": { + "$ref": "#/components/schemas/hash32" + } + } + ], + "result": { + "name": "Transaction information", + "schema": { + "$ref": "#/components/schemas/TransactionInfo" + } + } + }, + { + "name": "eth_getTransactionByBlockHashAndIndex", + "summary": "Returns information about a transaction by block hash and transaction index position.", + "params": [ + { + "name": "Block hash", + "required": true, + "schema": { + "$ref": "#/components/schemas/hash32" + } + }, + { + "name": "Transaction index", + "required": true, + "schema": { + "$ref": "#/components/schemas/uint" + } + } + ], + "result": { + "name": "Transaction information", + "schema": { + "$ref": "#/components/schemas/TransactionInfo" + } + } + }, + { + "name": "eth_getTransactionByBlockNumberAndIndex", + "summary": "Returns information about a transaction by block number and transaction index position.", + "params": [ + { + "name": "Block number", + "required": true, + "schema": { + "$ref": "#/components/schemas/uint" + } + }, + { + "name": "Transaction index", + "required": true, + "schema": { + "$ref": "#/components/schemas/uint" + } + } + ], + "result": { + "name": "Transaction information", + "schema": { + "$ref": "#/components/schemas/TransactionInfo" + } + } + }, + { + "name": "eth_getTransactionReceipt", + "summary": "Returns the receipt of a transaction by transaction hash.", + "params": [ + { + "name": "Transaction hash", + "schema": { + "$ref": "#/components/schemas/hash32" + } + } + ], + "result": { + "name": "Receipt Information", + "schema": { + "$ref": "#/components/schemas/ReceiptInfo" + } + } + } +] diff --git a/src/schemas/base-types.json b/src/schemas/base-types.json new file mode 100644 index 000000000..89275b847 --- /dev/null +++ b/src/schemas/base-types.json @@ -0,0 +1,52 @@ +{ + "address": { + "title": "hex encoded address", + "type": "string", + "pattern": "^0x[0-9a-f]{40}$" + }, + "addresses": { + "title": "hex encoded address", + "type": "array", + "items": { "$ref": "#/components/schemas/address" } + }, + "byte": { + "title": "hex encoded byte", + "type": "string", + "pattern": "^0x([a-fA-F0-9]?){1,2}$" + }, + "bytes": { + "title": "hex encoded bytes", + "type": "string", + "pattern": "^0x[0-9a-f]+$" + }, + "bytes32": { + "title": "32 hex encoded bytes", + "type": "string", + "pattern": "^0x[0-9a-f]{64}$" + }, + "bytes256": { + "title": "256 hex encoded bytes", + "type": "string", + "pattern": "^0x[0-9a-f]{512}$" + }, + "bytes65": { + "title": "65 hex encoded bytes", + "type": "string", + "pattern": "^0x[0-9a-f]{512}$" + }, + "uint": { + "title": "hex encoded unsigned integer", + "type": "string", + "pattern": "^0x[0-9a-f]+$" + }, + "uint256": { + "title": "hex encoded unsigned integer", + "type": "string", + "pattern": "^0x[0-9a-f]{64}$" + }, + "hash32": { + "title": "32 byte hex value", + "type": "string", + "pattern": "^0x[0-9a-f]{64}$" + } +} diff --git a/src/schemas/block.json b/src/schemas/block.json new file mode 100644 index 000000000..a4de59d46 --- /dev/null +++ b/src/schemas/block.json @@ -0,0 +1,129 @@ +{ + "Header": { + "title": "Header object", + "type": "object", + "required": [ + "parentHash", + "sha3Uncles", + "miner", + "stateRoot", + "transactionsRoot", + "receiptRoot", + "bloom", + "totalDifficulty", + "number", + "gasLimit", + "gasUsed", + "timestamp", + "extraData", + "mixHash", + "nonce" + ], + "properties": { + "parentHash": { + "title": "Parent block hash", + "$ref": "#/components/schemas/hash32" + }, + "sha3Uncles": { + "title": "Ommers hash", + "$ref": "#/components/schemas/hash32" + }, + "miner": { + "title": "Coinbase", + "$ref": "#/components/schemas/address" + }, + "stateRoot": { + "title": "State root", + "$ref": "#/components/schemas/hash32" + }, + "transactionsRoot": { + "title": "Transactions root", + "$ref": "#/components/schemas/hash32" + }, + "receiptRoot": { + "title": "Receipts root", + "$ref": "#/components/schemas/hash32" + }, + "bloom": { + "title": "Bloom filter", + "$ref": "#/components/schemas/bytes256" + }, + "totalDifficulty": { + "title": "Difficulty", + "$ref": "#/components/schemas/bytes" + }, + "number": { + "title": "Number", + "$ref": "#/components/schemas/uint" + }, + "gasLimit": { + "title": "Gas limit", + "$ref": "#/components/schemas/uint" + }, + "gasUsed": { + "title": "Gas used", + "$ref": "#/components/schemas/uint" + }, + "timestamp": { + "title": "Timestamp", + "$ref": "#/components/schemas/uint" + }, + "extraData": { + "title": "Extra data", + "$ref": "#/components/schemas/bytes" + }, + "mixHash": { + "title": "Mix hash", + "$ref": "#/components/schemas/hash32" + }, + "nonce": { + "title": "nonce", + "$ref": "#/components/schemas/bytes" + }, + "baseFeePerGas": { + "title": "Base fee per gas", + "$ref": "#/components/schemas/uint" + } + } + }, + "Block": { + "title": "Block object", + "type": "object", + "required": ["transactions", "uncles"], + "allOf": [ + { "$ref": "#/components/schemas/Header" }, + { + "title": "transactions", + "type": "array", + "items": { + "$ref": "#/components/schemas/hash32" + } + }, + { + "title": "uncles", + "type": "array", + "items": { + "$ref": "#/components/schemas/hash32" + } + } + ] + }, + "BlockTag": { + "title": "Block tag", + "type": "string", + "enum": ["earliest", "latest", "pending"] + }, + "BlockNumberOrTag": { + "title": "Block number or tag", + "oneOf": [ + { + "title": "Block number", + "$ref": "#/components/schemas/uint" + }, + { + "title": "Block tag", + "$ref": "#/components/schemas/BlockTag" + } + ] + } +} diff --git a/src/schemas/client.json b/src/schemas/client.json new file mode 100644 index 000000000..1124807e3 --- /dev/null +++ b/src/schemas/client.json @@ -0,0 +1,30 @@ +{ + "SyncingStatus": { + "title": "Syncing status", + "oneOf": [ + { + "title": "Syncing progress", + "type": "object", + "properties": { + "startingBlock": { + "title": "Starting block", + "$ref": "#/components/schemas/uint" + }, + "currentBlock": { + "title": "Current block", + "$ref": "#/components/schemas/uint" + }, + "highestBlock": { + "title": "Highest block", + "$ref": "#/components/schemas/uint" + } + } + }, + { + "title": "Not syncing", + "description": "Should always return false if not syncing.", + "type": "boolean" + } + ] + } +} diff --git a/src/schemas/filter.json b/src/schemas/filter.json new file mode 100644 index 000000000..91cb40be6 --- /dev/null +++ b/src/schemas/filter.json @@ -0,0 +1,70 @@ +{ + "FilterResults": { + "title": "Filter results", + "oneOf": [ + { + "title": "new block hashes", + "type": "array", + "items": { + "$ref": "#/components/schemas/hash32" + } + }, + { + "title": "new transaction hashes", + "type": "array", + "items": { + "$ref": "#/components/schemas/hash32" + } + }, + { + "title": "new logs", + "type": "array", + "items": { + "$ref": "#/components/schemas/Log" + } + } + ] + }, + "Filter": { + "title": "filter", + "type": "object", + "properties": { + "fromBlock": { + "title": "from block", + "$ref": "#/components/schemas/uint" + }, + "toBlock": { + "title": "to block", + "$ref": "#/components/schemas/uint" + }, + "address": { + "title": "Address(es)", + "oneOf": [ + { + "title": "Address", + "$ref": "#/components/schemas/address" + }, + { + "title": "Addresses", + "$ref": "#/components/schemas/addresses" + } + ] + }, + "topics": { + "title": "Topics", + "$ref": "#/components/schemas/Topics" + } + } + }, + "Topic": { + "title": "Topic", + "$ref": "#/components/schemas/uint256" + }, + "Topics": { + "title": "Topics", + "type": "array", + "items": { + "$ref": "#/components/schemas/Topic" + } + } +} diff --git a/src/schemas/receipt.json b/src/schemas/receipt.json new file mode 100644 index 000000000..fef5d7a88 --- /dev/null +++ b/src/schemas/receipt.json @@ -0,0 +1,99 @@ +{ + "Log": { + "title": "log", + "type": "object", + "properties": { + "removed": { + "title": "removed", + "type": "boolean" + }, + "logIndex": { + "title": "log index", + "$ref": "#/components/schemas/uint" + }, + "transactionIndex": { + "title": "transaction index", + "$ref": "#/components/schemas/uint" + }, + "transactionHash": { + "title": "transaction hash", + "$ref": "#/components/schemas/hash32" + }, + "blockHash": { + "title": "block hash", + "$ref": "#/components/schemas/hash32" + }, + "blockNumber": { + "title": "block number", + "$ref": "#/components/schemas/uint" + }, + "address": { + "title": "address", + "$ref": "#/components/schemas/address" + }, + "data": { + "title": "data", + "$ref": "#/components/schemas/bytes" + }, + "topics": { + "title": "topics", + "$ref": "#/components/schemas/Topics" + } + } + }, + "ReceiptInfo": { + "type": "object", + "title": "Receipt info", + "required": [ + "transactionHash", "transactionIndex", "value", "input"], + "properties": { + "transactionHash": { + "title": "transaction hash", + "$ref": "#/components/schemas/hash32" + }, + "transactionIndex": { + "title": "transaction index", + "$ref": "#/components/schemas/uint" + }, + "blockHash": { + "title": "block hash", + "$ref": "#/components/schemas/hash32" + }, + "blockNumber": { + "title": "block number", + "$ref": "#/components/schemas/uint" + }, + "from": { + "title": "from", + "$ref": "#/components/schemas/address" + }, + "to": { + "title": "to", + "$ref": "#/components/schemas/address" + }, + "cumulativeGasUsed": { + "title": "accessList", + "$ref": "#/components/schemas/uint" + }, + "gasUsed": { + "title": "gasUsed", + "$ref": "#/components/schemas/uint" + }, + "contractAddress": { + "title": "contract address", + "$ref": "#/components/schemas/address" + }, + "logs": { + "title": "logs", + "type": "array", + "items": { + "$ref": "#/components/schemas/Log" + } + }, + "logsBloom": { + "title": "logs bloom", + "$ref": "#/components/schemas/bytes256" + } + } + } +} diff --git a/src/schemas/transaction.json b/src/schemas/transaction.json new file mode 100644 index 000000000..60cc501ad --- /dev/null +++ b/src/schemas/transaction.json @@ -0,0 +1,175 @@ +{ + "AccessListEntry": { + "title": "Access list entry", + "type": "object", + "properties": { + "address": { + "$ref": "#/components/schemas/address" + }, + "storageKeys": { + "type": "array", + "items": { + "$ref": "#/components/schemas/hash32" + } + } + } + }, + "AccessList": { + "title": "Access list", + "type": "object", + "items": { + "$ref": "#/components/schemas/AccessListEntry" + } + }, + "SignedTransaction": { + "title": "Signed transaction object", + "type": "object", + "allOf": [ + { "$ref": "#/components/schemas/Transaction" }, + { + "required": ["v", "r", "s"], + "properties": { + "v": { + "title": "v", + "$ref": "#/components/schemas/uint" + }, + "r": { + "title": "r", + "$ref": "#/components/schemas/uint" + }, + "s": { + "title": "s", + "$ref": "#/components/schemas/uint" + } + } + } + ] + }, + "TransactionWithSender": { + "title": "Transaction object with sender", + "type": "object", + "allOf": [ + { + "required": ["from"], + "properties": { + "from": { + "title": "from", + "$ref": "#/components/schemas/address" + } + } + }, + { "$ref": "#/components/schemas/Transaction" } + ] + }, + "Transaction": { + "type": "object", + "title": "Transaction object", + "allOf": [ + { + "required": ["nonce", "gas", "value", "input"], + "properties": { + "type": { + "title": "type", + "$ref": "#/components/schemas/byte" + }, + "nonce": { + "title": "nonce", + "$ref": "#/components/schemas/uint" + }, + "to": { + "title": "to address", + "$ref": "#/components/schemas/address" + }, + "gas": { + "title": "gas limit", + "$ref": "#/components/schemas/uint" + }, + "value": { + "title": "value", + "$ref": "#/components/schemas/uint" + }, + "input": { + "title": "input data", + "$ref": "#/components/schemas/bytes" + }, + "accessList": { + "title": "accessList", + "description": "EIP-2930 access list", + "$ref": "#/components/schemas/AccessList" + } + } + }, + { + "oneOf": [ + { + "title": "EIP-1559 fee market parameters", + "type": "object", + "description": "EIP-1559 dynamic fee transactions have two fee parameters.", + "required": [ + "maxFeePerGas", + "maxPriorityFeePerGas" + ], + "properties": { + "maxPriorityFeePerGas": { + "title": "max priority fee per gas", + "description": "Maximum fee per gas the sender is willing to pay to miners in wei", + "$ref": "#/components/schemas/uint" + }, + "maxFeePerGas": { + "title": "max fee per gas", + "description": "The maximum total fee per gas the sender is willing to pay (includes the network / base fee and miner / priority fee) in wei", + "$ref": "#/components/schemas/uint" + } + } + }, + { + "title": "Legacy fee market parameters", + "type": "object", + "description": "Legacy transactions and EIP-2930 access list transaction include this parameter.", + "required": ["gasPrice"], + "properties": { + "gasPrice": { + "title": "gas price", + "description": "The gas price willing to be paid by the sender in wei", + "$ref": "#/components/schemas/uint" + } + } + } + ] + } + ] + }, + "TransactionInfo": { + "type": "object", + "title": "Transaction information", + "allOf": [ + { + "title": "Contextual information", + "required": ["blockHash", "blockNumber", "from", "hash", "transactionIndex"], + "properties": { + "blockHash": { + "title": "block hash", + "$ref": "#/components/schemas/hash32" + }, + "blockNumber": { + "title": "block number", + "$ref": "#/components/schemas/uint" + }, + "from": { + "title": "from address", + "$ref": "#/components/schemas/address" + }, + "hash": { + "title": "transaction hash", + "$ref": "#/components/schemas/hash32" + }, + "transactionIndex": { + "title": "transaction index", + "$ref": "#/components/schemas/uint" + } + } + }, + { "$ref": "#/components/schemas/SignedTransaction"} + ] + } +} From 8e0c313df9cdfacf54409466e64bad56d5d59106 Mon Sep 17 00:00:00 2001 From: "lightclient@protonmail.com" Date: Wed, 28 Jul 2021 19:20:38 +0200 Subject: [PATCH 2/2] update readme to new assembled spec --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e5c20cc32..59609a1fa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Ethereum JSON-RPC Specification -[View the spec](https://playground.open-rpc.org/?uiSchema%5BappBar%5D%5Bui:splitView%5D=false&schemaUrl=https://raw.githubusercontent.com/lightclient/eth1.0-apis/main/openrpc.json&uiSchema%5BappBar%5D%5Bui:input%5D=false) +[View the spec](https://playground.open-rpc.org/?uiSchema%5BappBar%5D%5Bui:splitView%5D=false&schemaUrl=https://raw.githubusercontent.com/lightclient/eth1.0-apis/assembled-spec/openrpc.json&uiSchema%5BappBar%5D%5Bui:input%5D=false) The Ethereum JSON-RPC is a collection of methods that all clients implement. This interface allows downstream tooling and infrastructure to treat different