Skip to content

Commit

Permalink
feat(taiko-client): add swagger for preconf api
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerLamTd committed Oct 21, 2024
1 parent 267ec3b commit 22346fb
Show file tree
Hide file tree
Showing 8 changed files with 928 additions and 10 deletions.
2 changes: 0 additions & 2 deletions packages/taiko-client/.swaggo
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
replace common.Address string
replace encoding.TierFee uint64
355 changes: 355 additions & 0 deletions packages/taiko-client/docs/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,355 @@
// Package docs Code generated by swaggo/swag. DO NOT EDIT
package docs

import "github.com/swaggo/swag"

const docTemplate = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"name": "API Support",
"url": "https://community.taiko.xyz/",
"email": "[email protected]"
},
"license": {
"name": "MIT",
"url": "https://github.com/taikoxyz/taiko-mono/blob/main/LICENSE.md"
},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/healthz": {
"get": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "Get current server health status",
"operationId": "health-check",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
}
}
}
},
"/preconfBlocks": {
"post": {
"description": "Insert preconfirmation blocks by the given groups to the backend L2 execution engine, please note that\nthe AVS service should sort the groups and make sure all the groups are valid at first.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"description": "preconf blocks creation request body",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/preconf_server.CreateOrUpdateBlocksFromBatchResponseBodyRequestBody"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/preconf_server.CreateOrUpdateBlocksFromBatchResponseBody"
}
}
}
}
},
"/preconfHead": {
"put": {
"description": "Resets the backend L2 execution engine preconfirmation head, please note that\nthe AVS service should make sure the new head height is from a valid preconfirmation head.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"description": "preconf blocks creation request body",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/preconf_server.ResetPreconfHeadRequestBody"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/preconf_server.ResetPreconfHeadResponseBody"
}
}
}
}
}
},
"definitions": {
"big.Int": {
"type": "object"
},
"preconf_server.CreateOrUpdateBlocksFromBatchResponseBody": {
"type": "object",
"properties": {
"preconfHeaders": {
"type": "array",
"items": {
"$ref": "#/definitions/types.Header"
}
}
}
},
"preconf_server.CreateOrUpdateBlocksFromBatchResponseBodyRequestBody": {
"type": "object",
"properties": {
"transactionsGroups": {
"type": "array",
"items": {
"$ref": "#/definitions/preconf_server.PreconfTransactionsGroup"
}
}
}
},
"preconf_server.PreconfTransactionsGroup": {
"type": "object",
"properties": {
"anchorBlockId": {
"description": "AnchorV2 parameters",
"type": "integer"
},
"anchorStateRoot": {
"type": "array",
"items": {
"type": "integer"
}
},
"baseFeePerGas": {
"type": "integer"
},
"blockId": {
"type": "integer"
},
"groupId": {
"type": "integer"
},
"groupStatus": {
"$ref": "#/definitions/preconf_server.PreconfTxsGroupStatus"
},
"parentGasUsed": {
"type": "integer"
},
"prevRandao": {
"type": "array",
"items": {
"type": "integer"
}
},
"signature": {
"type": "string"
},
"suggestedFeeRecipient": {
"type": "array",
"items": {
"type": "integer"
}
},
"timestamp": {
"description": "Block parameters",
"type": "integer"
},
"transactions": {
"type": "array",
"items": {
"$ref": "#/definitions/types.Transaction"
}
}
}
},
"preconf_server.PreconfTxsGroupStatus": {
"type": "string",
"enum": [
"finalBlockGroup",
"finalPreconfGroup"
],
"x-enum-varnames": [
"StatusFinalBlockGroup",
"StatusFinalPreconfGroup"
]
},
"preconf_server.ResetPreconfHeadRequestBody": {
"type": "object",
"properties": {
"newHead": {
"type": "integer"
}
}
},
"preconf_server.ResetPreconfHeadResponseBody": {
"type": "object",
"properties": {
"currentHead": {
"$ref": "#/definitions/types.Header"
}
}
},
"types.Header": {
"type": "object",
"properties": {
"baseFeePerGas": {
"description": "BaseFee was added by EIP-1559 and is ignored in legacy headers.",
"allOf": [
{
"$ref": "#/definitions/big.Int"
}
]
},
"blobGasUsed": {
"description": "BlobGasUsed was added by EIP-4844 and is ignored in legacy headers.",
"type": "integer"
},
"difficulty": {
"$ref": "#/definitions/big.Int"
},
"excessBlobGas": {
"description": "ExcessBlobGas was added by EIP-4844 and is ignored in legacy headers.",
"type": "integer"
},
"extraData": {
"type": "array",
"items": {
"type": "integer"
}
},
"gasLimit": {
"type": "integer"
},
"gasUsed": {
"type": "integer"
},
"logsBloom": {
"type": "array",
"items": {
"type": "integer"
}
},
"miner": {
"type": "array",
"items": {
"type": "integer"
}
},
"mixHash": {
"type": "array",
"items": {
"type": "integer"
}
},
"nonce": {
"type": "array",
"items": {
"type": "integer"
}
},
"number": {
"$ref": "#/definitions/big.Int"
},
"parentBeaconBlockRoot": {
"description": "ParentBeaconRoot was added by EIP-4788 and is ignored in legacy headers.",
"type": "array",
"items": {
"type": "integer"
}
},
"parentHash": {
"type": "array",
"items": {
"type": "integer"
}
},
"receiptsRoot": {
"type": "array",
"items": {
"type": "integer"
}
},
"requestsRoot": {
"description": "RequestsHash was added by EIP-7685 and is ignored in legacy headers.",
"type": "array",
"items": {
"type": "integer"
}
},
"sha3Uncles": {
"type": "array",
"items": {
"type": "integer"
}
},
"stateRoot": {
"type": "array",
"items": {
"type": "integer"
}
},
"timestamp": {
"type": "integer"
},
"transactionsRoot": {
"type": "array",
"items": {
"type": "integer"
}
},
"withdrawalsRoot": {
"description": "WithdrawalsHash was added by EIP-4895 and is ignored in legacy headers.",
"type": "array",
"items": {
"type": "integer"
}
}
}
},
"types.Transaction": {
"type": "object"
}
}
}`

// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "1.0",
Host: "",
BasePath: "",
Schemes: []string{},
Title: "Taiko Preconfirmation Server API",
Description: "",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}

func init() {
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}
29 changes: 29 additions & 0 deletions packages/taiko-client/docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<html>
<head>
<!-- Load the latest Swagger UI code and style from npm using unpkg.com -->
<script src="https://unpkg.com/swagger-ui-dist@3/swagger-ui-bundle.js"></script>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/swagger-ui-dist@3/swagger-ui.css"/>
<title>Preconf Serer API</title>
</head>
<body>
<div id="swagger-ui"></div> <!-- Div to hold the UI component -->
<script>
window.onload = function () {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: "/swagger.json", //Location of Open API spec in the repo
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIBundle.SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
})
window.ui = ui
}
</script>
</body>
</html>
Loading

0 comments on commit 22346fb

Please sign in to comment.