foundry-rs / block-explorers

Bindings for the etherscan API and other block explorers.
Apache License 2.0
54 stars 31 forks source link

Add blobscan client #31

Closed mattsse closed 6 months ago

mattsse commented 9 months ago

TODO

add simple client for https://sepolia.blobscan.com/

swagger:

https://api.blobscan.com/

kamuik16 commented 9 months ago

TODO

add simple client for https://sepolia.blobscan.com/

swagger:

https://api.blobscan.com/

Hey @mattsse! Could you give more context about the issue and point out where to add this? Thanks!

mattsse commented 9 months ago

hey @kamuik16

so this should ideally be another client implementation.

like struct BlobClient or something then we need functions for all the endpoints defined in the swagger, similar to the existing etherscan client we have, but this should be a new client type.

there are perhaps some tools that generate rust code for swagger for example https://github.com/OpenAPITools/openapi-generator

In my experience, their usefulness is very limited though, but definitely helpful to get all the stubs and json types then do a cleanup pass.

mattsse commented 9 months ago

I think this is the spec

'{"openapi":"3.0.3","info":{"title":"Blobscan API","description":"OpenAPI compliant REST API built using tRPC with Express","version":"1.0.0"},"servers":[{"url":"https://api.blobscan.com/api"}],"paths":{"/blocks/{number}":{"get":{"operationId":"block-getByBlockNumber","summary":"Get blocks time series stats","tags":["blocks"],"parameters":[{"name":"number","in":"path","required":true,"schema":{"type":"number"}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object","properties":{"blobAsCalldataGasUsed":{"type":"string"},"blobGasUsed":{"type":"string"},"excessBlobGas":{"type":"string"},"blobGasPrice":{"type":"string"},"number":{"type":"number"},"hash":{"type":"string"},"slot":{"type":"number"},"timestamp":{"type":"string","format":"date-time"},"transactions":{"type":"array","items":{"type":"object","properties":{"hash":{"type":"string"},"fromId":{"type":"string"},"toId":{"type":"string"},"blobs":{"type":"array","items":{"type":"object","properties":{"blobHash":{"type":"string"},"index":{"type":"number"},"blob":{"type":"object","properties":{"size":{"type":"number"}},"required":["size"],"additionalProperties":false}},"required":["blobHash","index","blob"],"additionalProperties":false}}},"required":["hash","fromId","toId","blobs"],"additionalProperties":false}}},"required":["blobAsCalldataGasUsed","blobGasUsed","excessBlobGas","blobGasPrice","number","hash","slot","timestamp","transactions"],"additionalProperties":false}}}},"default":{"$ref":"#/components/responses/error"}}}},"/indexer/slot":{"get":{"operationId":"indexer-getSlot","summary":"Get the latest processed slot from the database","tags":["indexer"],"parameters":[],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object","properties":{"slot":{"type":"number"}},"required":["slot"],"additionalProperties":false}}}},"default":{"$ref":"#/components/responses/error"}}},"put":{"operationId":"indexer-updateSlot","summary":"Update the latest processed slot in the database","tags":["indexer"],"security":[{"Authorization":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"slot":{"type":"number"}},"required":["slot"],"additionalProperties":false}}}},"parameters":[],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{}}}},"default":{"$ref":"#/components/responses/error"}}}},"/indexer/block-txs-blobs":{"put":{"operationId":"indexer-indexData","summary":"Index data in the database","tags":["indexer"],"security":[{"Authorization":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"block":{"type":"object","properties":{"number":{"type":"number"},"hash":{"type":"string"},"timestamp":{"type":"number"},"slot":{"type":"number"},"blobGasUsed":{"type":"string"},"excessBlobGas":{"type":"string"}},"required":["number","hash","timestamp","slot","blobGasUsed","excessBlobGas"],"additionalProperties":false},"transactions":{"type":"array","items":{"type":"object","properties":{"hash":{"type":"string"},"from":{"type":"string"},"to":{"type":"string"},"blockNumber":{"type":"number"},"gasPrice":{"type":"string"},"maxFeePerBlobGas":{"type":"string"}},"required":["hash","from","to","blockNumber","gasPrice","maxFeePerBlobGas"],"additionalProperties":false}},"blobs":{"type":"array","items":{"type":"object","properties":{"versionedHash":{"type":"string"},"commitment":{"type":"string"},"data":{"type":"string"},"txHash":{"type":"string"},"index":{"type":"number"}},"required":["versionedHash","commitment","data","txHash","index"],"additionalProperties":false}}},"required":["block","transactions","blobs"],"additionalProperties":false}}}},"parameters":[],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{}}}},"default":{"$ref":"#/components/responses/error"}}}},"/stats/overall":{"get":{"operationId":"stats-getAllOverallStats","summary":"Get all overall stats","tags":["overall"],"parameters":[],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object","properties":{"blob":{"type":"object","properties":{"totalBlobs":{"type":"number"},"totalUniqueBlobs":{"type":"number"},"totalBlobSize":{"type":"integer","format":"int64"},"avgBlobSize":{"type":"number"},"updatedAt":{"type":"string","format":"date-time"}},"required":["totalBlobs","totalUniqueBlobs","totalBlobSize","avgBlobSize","updatedAt"],"additionalProperties":false},"block":{"type":"object","properties":{"totalBlocks":{"type":"number"},"totalBlobGasUsed":{"type":"string"},"totalBlobAsCalldataGasUsed":{"type":"string"},"totalBlobFee":{"type":"string"},"totalBlobAsCalldataFee":{"type":"string"},"avgBlobFee":{"type":"number"},"avgBlobAsCalldataFee":{"type":"number"},"avgBlobGasPrice":{"type":"number"},"updatedAt":{"type":"string","format":"date-time"}},"required":["totalBlocks","totalBlobGasUsed","totalBlobAsCalldataGasUsed","totalBlobFee","totalBlobAsCalldataFee","avgBlobFee","avgBlobAsCalldataFee","avgBlobGasPrice","updatedAt"],"additionalProperties":false},"transaction":{"type":"object","properties":{"totalTransactions":{"type":"number"},"totalUniqueReceivers":{"type":"number"},"totalUniqueSenders":{"type":"number"},"avgMaxBlobGasFee":{"type":"number"},"updatedAt":{"type":"string","format":"date-time"}},"required":["totalTransactions","totalUniqueReceivers","totalUniqueSenders","avgMaxBlobGasFee","updatedAt"],"additionalProperties":false}},"required":["blob","block","transaction"],"additionalProperties":false}}}},"default":{"$ref":"#/components/responses/error"}}}},"/stats/blobs":{"get":{"operationId":"stats-getBlobDailyStats","summary":"Get blobs time series stats","tags":["blobs"],"parameters":[{"name":"timeFrame","in":"query","required":true,"schema":{"type":"string","enum":["1d","7d","15d","30d","180d","360d","All"]}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object","properties":{"days":{"type":"array","items":{"type":"string"}},"totalBlobs":{"type":"array","items":{"type":"number"}},"totalUniqueBlobs":{"type":"array","items":{"type":"number"}},"totalBlobSizes":{"type":"array","items":{"type":"number"}},"avgBlobSizes":{"type":"array","items":{"type":"number"}}},"required":["days","totalBlobs","totalUniqueBlobs","totalBlobSizes","avgBlobSizes"],"additionalProperties":false}}}},"default":{"$ref":"#/components/responses/error"}}}},"/stats/blobs/overall":{"get":{"operationId":"stats-getBlobOverallStats","summary":"Get blobs overall stats","tags":["blobs"],"parameters":[],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object","properties":{"totalBlobs":{"type":"number"},"totalUniqueBlobs":{"type":"number"},"totalBlobSize":{"type":"integer","format":"int64"},"avgBlobSize":{"type":"number"},"updatedAt":{"type":"string","format":"date-time"}},"required":["totalBlobs","totalUniqueBlobs","totalBlobSize","avgBlobSize","updatedAt"],"additionalProperties":false}}}},"default":{"$ref":"#/components/responses/error"}}}},"/stats/blocks":{"get":{"operationId":"stats-getBlockDailyStats","summary":"Get blocks time series stats","tags":["blocks"],"parameters":[{"name":"timeFrame","in":"query","required":true,"schema":{"type":"string","enum":["1d","7d","15d","30d","180d","360d","All"]}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object","properties":{"days":{"type":"array","items":{"type":"string"}},"totalBlocks":{"type":"array","items":{"type":"number"}},"totalBlobGasUsed":{"type":"array","items":{"type":"string"}},"totalBlobAsCalldataGasUsed":{"type":"array","items":{"type":"string"}},"totalBlobFees":{"type":"array","items":{"type":"string"}},"totalBlobAsCalldataFees":{"type":"array","items":{"type":"string"}},"avgBlobFees":{"type":"array","items":{"type":"number"}},"avgBlobAsCalldataFees":{"type":"array","items":{"type":"number"}},"avgBlobGasPrices":{"type":"array","items":{"type":"number"}}},"required":["days","totalBlocks","totalBlobGasUsed","totalBlobAsCalldataGasUsed","totalBlobFees","totalBlobAsCalldataFees","avgBlobFees","avgBlobAsCalldataFees","avgBlobGasPrices"],"additionalProperties":false}}}},"default":{"$ref":"#/components/responses/error"}}}},"/stats/blocks/overall":{"get":{"operationId":"stats-getBlockOverallStats","summary":"Get blocks overall stats","tags":["blocks"],"parameters":[],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object","properties":{"totalBlocks":{"type":"number"},"totalBlobGasUsed":{"type":"string"},"totalBlobAsCalldataGasUsed":{"type":"string"},"totalBlobFee":{"type":"string"},"totalBlobAsCalldataFee":{"type":"string"},"avgBlobFee":{"type":"number"},"avgBlobAsCalldataFee":{"type":"number"},"avgBlobGasPrice":{"type":"number"},"updatedAt":{"type":"string","format":"date-time"}},"required":["totalBlocks","totalBlobGasUsed","totalBlobAsCalldataGasUsed","totalBlobFee","totalBlobAsCalldataFee","avgBlobFee","avgBlobAsCalldataFee","avgBlobGasPrice","updatedAt"],"additionalProperties":false}}}},"default":{"$ref":"#/components/responses/error"}}}},"/stats/transactions":{"get":{"operationId":"stats-getTransactionDailyStats","summary":"Get transactions time series stats","tags":["transactions"],"parameters":[{"name":"timeFrame","in":"query","required":true,"schema":{"type":"string","enum":["1d","7d","15d","30d","180d","360d","All"]}}],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object","properties":{"days":{"type":"array","items":{"type":"string"}},"totalTransactions":{"type":"array","items":{"type":"number"}},"totalUniqueSenders":{"type":"array","items":{"type":"number"}},"totalUniqueReceivers":{"type":"array","items":{"type":"number"}},"avgMaxBlobGasFees":{"type":"array","items":{"type":"number"}}},"required":["days","totalTransactions","totalUniqueSenders","totalUniqueReceivers","avgMaxBlobGasFees"],"additionalProperties":false}}}},"default":{"$ref":"#/components/responses/error"}}}},"/stats/transactions/overall":{"get":{"operationId":"stats-getTransactionOverallStats","summary":"Get transactions overall stats","tags":["transactions"],"parameters":[],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object","properties":{"totalTransactions":{"type":"number"},"totalUniqueReceivers":{"type":"number"},"totalUniqueSenders":{"type":"number"},"avgMaxBlobGasFee":{"type":"number"},"updatedAt":{"type":"string","format":"date-time"}},"required":["totalTransactions","totalUniqueReceivers","totalUniqueSenders","avgMaxBlobGasFee","updatedAt"],"additionalProperties":false}}}},"default":{"$ref":"#/components/responses/error"}}}},"/healthcheck":{"get":{"operationId":"healthcheck","summary":"Connection healthcheck","tags":["system"],"parameters":[],"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"string"}}}},"default":{"$ref":"#/components/responses/error"}}}}},"components":{"securitySchemes":{"Authorization":{"type":"http","scheme":"bearer"}},"responses":{"error":{"description":"Error response","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"code":{"type":"string"},"issues":{"type":"array","items":{"type":"object","properties":{"message":{"type":"string"}},"required":["message"],"additionalProperties":false}}},"required":["message","code"],"additionalProperties":false}}}}}},"tags":[{"name":"blobs"},{"name":"blocks"},{"name":"transactions"},{"name":"overall"},{"name":"system"}],"externalDocs":{"url":"https://docs.blobscan.com/"}}'
DaniPopes commented 9 months ago

I would like us to split this report into multiple crates as this is not related to etherscan.

mattsse commented 9 months ago

agree, we can do it either before this pr or after

before sounds easier

@kamuik16 lmk if you want to take this

kamuik16 commented 9 months ago

agree, we can do it either before this pr or after

before sounds easier

@kamuik16 lmk if you want to take this

Prob not, I haven't even understood the issue.

DoTheBestToGetTheBest commented 7 months ago

TODO

add simple client for https://sepolia.blobscan.com/

swagger:

https://api.blobscan.com/

hello, i'd be happy to take this (: