diff --git a/scripts/build.js b/scripts/build.js index 639081f7e..c1eaa4014 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -54,6 +54,18 @@ methodFiles.forEach(file => { ]; }); +methodsBase = "src/txpool/"; +methodFiles = fs.readdirSync(methodsBase); +methodFiles.forEach(file => { + console.log(file); + let raw = fs.readFileSync(methodsBase + file); + let parsed = yaml.load(raw); + methods = [ + ...methods, + ...parsed, + ]; +}); + let schemas = {}; let schemasBase = "src/schemas/" let schemaFiles = fs.readdirSync(schemasBase); diff --git a/src/schemas/filter.yaml b/src/schemas/filter.yaml index 2d4542046..13c938e17 100644 --- a/src/schemas/filter.yaml +++ b/src/schemas/filter.yaml @@ -50,3 +50,13 @@ FilterTopic: type: array items: $ref: '#/components/schemas/bytes32' +FilterOperators: + title: operator + type: object + properties: + eq: + $ref: '#/components/schemas/uint' + gt: + $ref: '#/components/schemas/uint' + lt: + $ref: '#/components/schemas/uint' \ No newline at end of file diff --git a/src/txpool/getters.yaml b/src/txpool/getters.yaml new file mode 100644 index 000000000..f4932be96 --- /dev/null +++ b/src/txpool/getters.yaml @@ -0,0 +1,66 @@ +- name: txpool_transactions + summary: Returns a list of all transactions that match the supplied filter conditions that are either pending for inclusion in the next block(s) or scheduled for future execution. + params: + - name: Filter + schema: + title: txpool filter + type: object + properties: + from: + title: from address + $ref: '#/components/schemas/address' + to: + title: to address + $ref: '#/components/schemas/address' + gas: + title: gas limit + $ref: '#/components/schemas/FilterOperators' + gasPrice: + title: gas price + $ref: '#/components/schemas/FilterOperators' + maxFeePerGas: + title: max fee + $ref: '#/components/schemas/FilterOperators' + maxPriorityFeePerGas: + title: max priority fee + $ref: '#/components/schemas/FilterOperators' + value: + title: value + $ref: '#/components/schemas/FilterOperators' + nonce: + title: nonce + $ref: '#/components/schemas/FilterOperators' + result: + name: Result + schema: + title: Result + schema: + $ref: '#/components/schemas/TxPoolTransactions' + title: transactions + type: object + properties: + pending: + title: pending + type: array + items: + $ref: '#/components/schemas/GenericTransaction' + queued: + title: queued + type: array + items: + $ref: '#/components/schemas/GenericTransaction' +- name: txpool_statistics + summary: Returns statistics about the node's transaction pool. + params: [] + result: + name: Statistics + schema: + title: statistics + type: object + properties: + pending: + title: pending + $ref: '#/components/schemas/uint' + queued: + title: queued + $ref: '#/components/schemas/uint' diff --git a/tests/txpool_statistics/get-statistics.io b/tests/txpool_statistics/get-statistics.io new file mode 100644 index 000000000..87bb7a7f6 --- /dev/null +++ b/tests/txpool_statistics/get-statistics.io @@ -0,0 +1,2 @@ +>> {"jsonrpc":"2.0","id":31,"method":"txpool_statistics"} +<< {"jsonrpc":"2.0","id":31,"result":{"maxSize":"0x1","pending":"0x1","queued":"0x1"}} diff --git a/tests/txpool_transactions/get-default-transactions.io b/tests/txpool_transactions/get-default-transactions.io new file mode 100644 index 000000000..a665f3e9b --- /dev/null +++ b/tests/txpool_transactions/get-default-transactions.io @@ -0,0 +1,2 @@ +>> {"jsonrpc":"2.0","id":31,"method":"txpool_transactions"} +<< {"jsonrpc":"2.0","id":31,"result":{"pending":[{"blockHash":null,"blockNumber":null,"from":"0x658bdf435d810c91414ec09147daa6db62406379","gas":"0x5208","gasPrice":"0x342770c1","hash":"0x74e41d593675913d6d5521f46523f1bd396dff1891bdb35f59be47c7e5e0b34b","input":"0x","nonce":"0x0","to":"0x658bdf435d810c91414ec09147daa6db62406379","transactionIndex":"0x0","value":"0x3e8","type":"0x0","chainId":"0x539","v":"0xa95","r":"0xaf5fc351b9e457a31f37c84e5cd99dd3c5de60af3de33c6f4160177a2c786a60","s":"0x201da7a21046af55837330a2c52fc1543cd4d9ead00ddf178dd96935b607ff9b"}],"queued":[{"blockHash":null,"blockNumber":null,"from":"0x658bdf435d810c91414ec09147daa6db62406379","gas":"0x5208","gasPrice":"0x342770c1","hash":"0x74e41d593675913d6d5521f46523f1bd396dff1891bdb35f59be47c7e5e0b34b","input":"0x","nonce":"0x0","to":"0x658bdf435d810c91414ec09147daa6db62406379","transactionIndex":"0x0","value":"0x3e8","type":"0x0","chainId":"0x539","v":"0xa95","r":"0xaf5fc351b9e457a31f37c84e5cd99dd3c5de60af3de33c6f4160177a2c786a60","s":"0x201da7a21046af55837330a2c52fc1543cd4d9ead00ddf178dd96935b607ff9b"}]}} diff --git a/tests/txpool_transactions/get-empty-transactions-list.io b/tests/txpool_transactions/get-empty-transactions-list.io new file mode 100644 index 000000000..487e13e13 --- /dev/null +++ b/tests/txpool_transactions/get-empty-transactions-list.io @@ -0,0 +1,2 @@ +>> {"jsonrpc":"2.0","id":31,"method":"txpool_transactions"} +<< {"jsonrpc":"2.0","id":31,"result":{"pending":[],"queued":[]}} diff --git a/tests/txpool_transactions/get-filtered-transactions-by-address.io b/tests/txpool_transactions/get-filtered-transactions-by-address.io new file mode 100644 index 000000000..4479fc288 --- /dev/null +++ b/tests/txpool_transactions/get-filtered-transactions-by-address.io @@ -0,0 +1,2 @@ +>> {"jsonrpc":"2.0","id":31,"method":"txpool_transactions","params":[{"from":"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"}]} +<< {"jsonrpc":"2.0","id":31,"result":{"pending":[{"blockHash":null,"blockNumber":null,"from":"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73","gas":"0x5208","gasPrice":"0x342770c1","hash":"0x74e41d593675913d6d5521f46523f1bd396dff1891bdb35f59be47c7e5e0b34b","input":"0x","nonce":"0x0","to":"0x658bdf435d810c91414ec09147daa6db62406379","transactionIndex":"0x0","value":"0x3e8","type":"0x0","chainId":"0x539","v":"0xa95","r":"0xaf5fc351b9e457a31f37c84e5cd99dd3c5de60af3de33c6f4160177a2c786a60","s":"0x201da7a21046af55837330a2c52fc1543cd4d9ead00ddf178dd96935b607ff9b"}],"queued":[{"blockHash":null,"blockNumber":null,"from":"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73","gas":"0x5208","gasPrice":"0x342770c1","hash":"0x74e41d593675913d6d5521f46523f1bd396dff1891bdb35f59be47c7e5e0b34b","input":"0x","nonce":"0x0","to":"0x658bdf435d810c91414ec09147daa6db62406379","transactionIndex":"0x0","value":"0x3e8","type":"0x0","chainId":"0x539","v":"0xa95","r":"0xaf5fc351b9e457a31f37c84e5cd99dd3c5de60af3de33c6f4160177a2c786a60","s":"0x201da7a21046af55837330a2c52fc1543cd4d9ead00ddf178dd96935b607ff9b"}]}} diff --git a/tests/txpool_transactions/get-filtered-transactions-gt-gas.io b/tests/txpool_transactions/get-filtered-transactions-gt-gas.io new file mode 100644 index 000000000..0fc5c43c2 --- /dev/null +++ b/tests/txpool_transactions/get-filtered-transactions-gt-gas.io @@ -0,0 +1,2 @@ +>> {"jsonrpc":"2.0","id":31,"method":"txpool_transactions","params":[{"gas":{"lt":"0x0"}}]} +<< {"jsonrpc":"2.0","id":31,"result":{"pending":[{"blockHash":null,"blockNumber":null,"from":"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73","gas":"0x5208","gasPrice":"0x342770c1","hash":"0x74e41d593675913d6d5521f46523f1bd396dff1891bdb35f59be47c7e5e0b34b","input":"0x","nonce":"0x0","to":"0x658bdf435d810c91414ec09147daa6db62406379","transactionIndex":"0x0","value":"0x3e8","type":"0x0","chainId":"0x539","v":"0xa95","r":"0xaf5fc351b9e457a31f37c84e5cd99dd3c5de60af3de33c6f4160177a2c786a60","s":"0x201da7a21046af55837330a2c52fc1543cd4d9ead00ddf178dd96935b607ff9b"}],"queued":[{"blockHash":null,"blockNumber":null,"from":"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73","gas":"0x5208","gasPrice":"0x342770c1","hash":"0x74e41d593675913d6d5521f46523f1bd396dff1891bdb35f59be47c7e5e0b34b","input":"0x","nonce":"0x0","to":"0x658bdf435d810c91414ec09147daa6db62406379","transactionIndex":"0x0","value":"0x3e8","type":"0x0","chainId":"0x539","v":"0xa95","r":"0xaf5fc351b9e457a31f37c84e5cd99dd3c5de60af3de33c6f4160177a2c786a60","s":"0x201da7a21046af55837330a2c52fc1543cd4d9ead00ddf178dd96935b607ff9b"}]}} diff --git a/wordlist.txt b/wordlist.txt index fef7a4af8..8a5759016 100644 --- a/wordlist.txt +++ b/wordlist.txt @@ -57,3 +57,8 @@ randao src https forkchoiceupdatedresponsev +txpool +TxPool +eq +lt +gt