Skip to content

Commit

Permalink
feat(shemas): Permit hex/dec input via uintParam
Browse files Browse the repository at this point in the history
  • Loading branch information
perama-v committed Aug 4, 2023
1 parent 9c873c2 commit 90a3aca
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/eth/filter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
params:
- name: Filter Identifier
schema:
$ref: '#/components/schemas/uint'
$ref: '#/components/schemas/uintParam'
result:
name: Success
schema:
Expand All @@ -37,7 +37,7 @@
params:
- name: Filter Identifier
schema:
$ref: '#/components/schemas/uint'
$ref: '#/components/schemas/uintParam'
result:
name: Log objects
schema:
Expand All @@ -47,7 +47,7 @@
params:
- name: Filter Identifier
schema:
$ref: '#/components/schemas/uint'
$ref: '#/components/schemas/uintParam'
result:
name: Log objects
schema:
Expand Down
4 changes: 2 additions & 2 deletions src/eth/transaction.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
- name: Transaction index
required: true
schema:
$ref: '#/components/schemas/uint'
$ref: '#/components/schemas/uintParam'
result:
name: Transaction information
schema:
Expand All @@ -38,7 +38,7 @@
- name: Transaction index
required: true
schema:
$ref: '#/components/schemas/uint'
$ref: '#/components/schemas/uintParam'
result:
name: Transaction information
schema:
Expand Down
8 changes: 8 additions & 0 deletions src/schemas/base-types.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ uint:
title: hex encoded unsigned integer
type: string
pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
uintParam:
title: unsigned integer number or hex string
description: clients accept both integer kinds in request parameters
oneOf:
- title: hex encoded unsigned integer
$ref: '#/components/schemas/uint'
- title: decimal unsigned integer
type: number
uint64:
title: hex encoded 64 bit unsigned integer
type: string
Expand Down
4 changes: 2 additions & 2 deletions src/schemas/block.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ BlockNumberOrTag:
title: Block number or tag
oneOf:
- title: Block number
$ref: '#/components/schemas/uint'
$ref: '#/components/schemas/uintParam'
- title: Block tag
$ref: '#/components/schemas/BlockTag'
BlockNumberOrTagOrHash:
title: Block number, tag, or block hash
anyOf:
- title: Block number
$ref: '#/components/schemas/uint'
$ref: '#/components/schemas/uintParam'
- title: Block tag
$ref: '#/components/schemas/BlockTag'
- title: Block hash
Expand Down
4 changes: 2 additions & 2 deletions src/schemas/filter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ Filter:
properties:
fromBlock:
title: from block
$ref: '#/components/schemas/uint'
$ref: '#/components/schemas/uintParam'
toBlock:
title: to block
$ref: '#/components/schemas/uint'
$ref: '#/components/schemas/uintParam'
address:
title: Address(es)
oneOf:
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions tests/eth_getBlockByNumber/get-block-n-number.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>> {"jsonrpc":"2.0","id":1,"method":"eth_getBlockByNumber","params":[2,true]}
<< {"jsonrpc":"2.0","id":1,"result":{"baseFeePerGas":"0x2db08786","difficulty":"0x0","extraData":"0x","gasLimit":"0x4c4b40","gasUsed":"0x5208","hash":"0xb019ea73504c933a601125fc37ebfd9629a2119a91792a5653365ed73ec56acb","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","number":"0x2","parentHash":"0x7cb4dd3daba1f739d0c1ec7d998b4a2f6fd83019116455afa54ca4f49dfa0ad4","receiptsRoot":"0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x2bf","stateRoot":"0xf87c613573a54e020b1bf5d540b6ed339fe982a90dc01da3f45f9714367ea9a3","timestamp":"0x14","totalDifficulty":"0x1","transactions":[{"blockHash":"0xb019ea73504c933a601125fc37ebfd9629a2119a91792a5653365ed73ec56acb","blockNumber":"0x2","from":"0x658bdf435d810c91414ec09147daa6db62406379","gas":"0x5208","gasPrice":"0x2db08787","hash":"0x0d9ba049a158972e7fc1066122ceb31e431483ebf84f90f845f02e326942d467","input":"0x","nonce":"0x1","to":"0x658bdf435d810c91414ec09147daa6db62406379","transactionIndex":"0x0","value":"0x3e8","type":"0x0","chainId":"0x539","v":"0xa95","r":"0x52a6f622013359249316f4c017a67bc2c659f513dac5efea43a84b6ce4e462b1","s":"0x55ba2a779eaf62efa7d641a32ea329faabf9f097d376e2e400115a5151b9470"}],"transactionsRoot":"0x14488a14ae59174bedee90344854fb9b6a308143ce4bf688c00f2e81a9aae2a3","uncles":[],"withdrawals":[{"index":"0x0","validatorIndex":"0x2a","address":"0xee00000000000000000000000000000000000000","amount":"0x539"},{"index":"0x1","validatorIndex":"0xd","address":"0xee00000000000000000000000000000000000000","amount":"0x1"}],"withdrawalsRoot":"0x625ee608ff633ca6371503f9a8159a9e158f3fa9585650418562ef7bd1d1dfc9"}}

0 comments on commit 90a3aca

Please sign in to comment.