From 54552674fe8a6b0b4321afe1ef4d90d00d62f0e8 Mon Sep 17 00:00:00 2001 From: jeff <113397187+cyberhorsey@users.noreply.github.com> Date: Thu, 12 Oct 2023 21:03:59 -0700 Subject: [PATCH] feat(eventindexer): API documentation, swagger, github pages (#14948) --- go.mod | 11 + go.sum | 29 ++ packages/eventindexer/docs/docs.go | 312 ++++++++++++++++++ packages/eventindexer/docs/swagger.json | 264 +++++++++++++++ packages/eventindexer/docs/swagger.yaml | 189 +++++++++++ .../get_assigned_blocks_by_prover_address.go | 13 + .../http/get_by_address_and_event.go | 12 + .../eventindexer/http/get_chart_by_task.go | 11 + .../http/get_count_by_address_and_event.go | 12 + ...et_nft_balances_by_address_and_chain_id.go | 12 + packages/eventindexer/http/get_stats.go | 8 + .../eventindexer/http/get_unique_proposers.go | 10 + .../eventindexer/http/get_unique_provers.go | 10 + packages/eventindexer/http/server.go | 12 + packages/eventindexer/index.html | 29 ++ packages/eventindexer/scripts/swagger.sh | 3 + packages/relayer/docs/docs.go | 173 ++++++++++ packages/relayer/docs/swagger.json | 141 ++++++++ packages/relayer/docs/swagger.yaml | 98 ++++++ packages/relayer/index.html | 29 ++ .../relayer/indexer/http/get_block_info.go | 10 + .../indexer/http/get_events_by_address.go | 15 + packages/relayer/indexer/http/server.go | 12 + packages/relayer/scripts/swagger.sh | 3 + 24 files changed, 1418 insertions(+) create mode 100644 packages/eventindexer/docs/docs.go create mode 100644 packages/eventindexer/docs/swagger.json create mode 100644 packages/eventindexer/docs/swagger.yaml create mode 100644 packages/eventindexer/index.html create mode 100644 packages/eventindexer/scripts/swagger.sh create mode 100644 packages/relayer/docs/docs.go create mode 100644 packages/relayer/docs/swagger.json create mode 100644 packages/relayer/docs/swagger.yaml create mode 100644 packages/relayer/index.html create mode 100644 packages/relayer/scripts/swagger.sh diff --git a/go.mod b/go.mod index 5f2f3d976b3..f38d47597bb 100644 --- a/go.mod +++ b/go.mod @@ -40,8 +40,11 @@ require ( require ( github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect github.com/DataDog/zstd v1.5.2 // indirect + github.com/KyleBanks/depth v1.2.1 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/ProtonMail/go-crypto v0.0.0-20230518184743-7afd39499903 // indirect + github.com/PuerkitoBio/purell v1.1.1 // indirect + github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/StackExchange/wmi v1.2.1 // indirect github.com/VictoriaMetrics/fastcache v1.6.0 // indirect github.com/acomagu/bufpipe v1.0.4 // indirect @@ -70,6 +73,10 @@ require ( github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.4.1 // indirect github.com/go-ole/go-ole v1.2.5 // indirect + github.com/go-openapi/jsonpointer v0.19.5 // indirect + github.com/go-openapi/jsonreference v0.19.6 // indirect + github.com/go-openapi/spec v0.20.4 // indirect + github.com/go-openapi/swag v0.19.15 // indirect github.com/go-playground/locales v0.14.0 // indirect github.com/go-playground/universal-translator v0.18.0 // indirect github.com/go-playground/validator/v10 v10.11.1 // indirect @@ -92,12 +99,14 @@ require ( github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect + github.com/josharian/intern v1.0.0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/klauspost/compress v1.16.3 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/leodido/go-urn v1.2.1 // indirect github.com/magiconair/properties v1.8.7 // indirect + github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.16 // indirect github.com/mattn/go-runewidth v0.0.9 // indirect @@ -124,6 +133,7 @@ require ( github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/sirupsen/logrus v1.9.0 // indirect github.com/skeema/knownhosts v1.1.1 // indirect + github.com/swaggo/swag v1.16.2 // indirect github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect @@ -144,6 +154,7 @@ require ( google.golang.org/protobuf v1.28.1 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/warnings.v0 v0.1.2 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect ) replace github.com/ethereum/go-ethereum v1.13.1 => github.com/taikoxyz/taiko-geth v0.0.0-20230920223320-89ffc4c82519 diff --git a/go.sum b/go.sum index 4f44b93c66e..db3490e72e3 100644 --- a/go.sum +++ b/go.sum @@ -13,6 +13,8 @@ github.com/CloudyKit/jet/v3 v3.0.0/go.mod h1:HKQPgSJmdK8hdoAbKUUWajkHyHo4RaU5rMd github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY= +github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= +github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= @@ -21,6 +23,10 @@ github.com/Microsoft/hcsshim v0.9.7 h1:mKNHW/Xvv1aFH87Jb6ERDzXTJTLPlmzfZ28VBFD/b github.com/Microsoft/hcsshim v0.9.7/go.mod h1:7pLA8lDk46WKDWlVsENo92gC0XFa8rbKfyFRBqxEbCc= github.com/ProtonMail/go-crypto v0.0.0-20230518184743-7afd39499903 h1:ZK3C5DtzV2nVAQTx5S5jQvMeDqWtD1By5mOoyY/xJek= github.com/ProtonMail/go-crypto v0.0.0-20230518184743-7afd39499903/go.mod h1:8TI4H3IbrackdNgv+92dI+rhpCaLqM0IfpgCgenFvRE= +github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= +github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= @@ -194,6 +200,16 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= github.com/go-ole/go-ole v1.2.5 h1:t4MGB5xEDZvXI+0rMjjsfBsD7yAgp/s9ZDkL1JndXwY= github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= +github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonreference v0.19.6 h1:UBIxjkht+AWIgYzCDSv2GN+E/togfwXUJFRTWhl2Jjs= +github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns= +github.com/go-openapi/spec v0.20.4 h1:O8hJrt0UMnhHcluhIdUgCLRWyM2x7QkBXRvOs7m+O1M= +github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I= +github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= +github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= @@ -372,6 +388,8 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg= github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= @@ -430,6 +448,11 @@ github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= @@ -611,6 +634,8 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4= github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= +github.com/swaggo/swag v1.16.2 h1:28Pp+8DkQoV+HLzLx8RGJZXNGKbFqnuvSbAAtoxiY04= +github.com/swaggo/swag v1.16.2/go.mod h1:6YzXnDcpr0767iOejs318CwYkCQqyGer6BizOg03f+E= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= @@ -740,6 +765,7 @@ golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226101413-39120d07d75e/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211008194852-3b03d305991f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -793,6 +819,7 @@ golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -905,6 +932,7 @@ google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= @@ -931,6 +959,7 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/packages/eventindexer/docs/docs.go b/packages/eventindexer/docs/docs.go new file mode 100644 index 00000000000..37e5dad7b77 --- /dev/null +++ b/packages/eventindexer/docs/docs.go @@ -0,0 +1,312 @@ +// 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": "info@taiko.xyz" + }, + "license": { + "name": "MIT" + }, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/assignedBlocks": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "summary": "Get assigned blocks by prover address", + "operationId": "get-assigned-blocks-by-prover-address", + "parameters": [ + { + "type": "string", + "description": "address to query", + "name": "address", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/paginate.Page" + } + } + } + } + }, + "/events": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "summary": "Get events by address and event name", + "operationId": "get-events-by-address-and-event-name", + "parameters": [ + { + "type": "string", + "description": "address to query", + "name": "address", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "event name to query", + "name": "event", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/paginate.Page" + } + } + } + } + }, + "/nftsByAddress": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "summary": "Get nft balances by address and chain ID", + "operationId": "get-nft-balances-by-address-and-chain-id", + "parameters": [ + { + "type": "string", + "description": "address to query", + "name": "address", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "chainID to query", + "name": "chainID", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/paginate.Page" + } + } + } + } + }, + "/stats": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "summary": "Get stats", + "operationId": "get-stats", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/eventindexer.Stat" + } + } + } + } + }, + "/uniqueProposers": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "summary": "Get unique proposers", + "operationId": "get-unique-proposers", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/http.uniqueProposersResp" + } + } + } + } + }, + "/uniqueProvers": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "summary": "Get unique provers", + "operationId": "get-unique-provers", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/http.uniqueProversResp" + } + } + } + } + } + }, + "definitions": { + "eventindexer.Stat": { + "type": "object", + "properties": { + "averageProofReward": { + "type": "string" + }, + "averageProofTime": { + "type": "string" + }, + "averageProposerReward": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "numProofs": { + "type": "integer" + }, + "numProposerRewards": { + "type": "integer" + }, + "numVerifiedBlocks": { + "type": "integer" + } + } + }, + "eventindexer.UniqueProposersResponse": { + "type": "object", + "properties": { + "address": { + "type": "string" + }, + "count": { + "type": "integer" + } + } + }, + "eventindexer.UniqueProversResponse": { + "type": "object", + "properties": { + "address": { + "type": "string" + }, + "count": { + "type": "integer" + } + } + }, + "http.uniqueProposersResp": { + "type": "object", + "properties": { + "proposers": { + "type": "array", + "items": { + "$ref": "#/definitions/eventindexer.UniqueProposersResponse" + } + }, + "uniqueProposers": { + "type": "integer" + } + } + }, + "http.uniqueProversResp": { + "type": "object", + "properties": { + "provers": { + "type": "array", + "items": { + "$ref": "#/definitions/eventindexer.UniqueProversResponse" + } + }, + "uniqueProvers": { + "type": "integer" + } + } + }, + "paginate.Page": { + "type": "object", + "properties": { + "first": { + "type": "boolean" + }, + "items": {}, + "last": { + "type": "boolean" + }, + "max_page": { + "type": "integer" + }, + "page": { + "type": "integer" + }, + "size": { + "type": "integer" + }, + "total": { + "type": "integer" + }, + "total_pages": { + "type": "integer" + }, + "visible": { + "type": "integer" + } + } + } + } +}` + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = &swag.Spec{ + Version: "1.0", + Host: "eventindexer.jolnir.taiko.xyz", + BasePath: "", + Schemes: []string{}, + Title: "Taiko Eventindexer API", + Description: "", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate, +} + +func init() { + swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) +} diff --git a/packages/eventindexer/docs/swagger.json b/packages/eventindexer/docs/swagger.json new file mode 100644 index 00000000000..b653010deae --- /dev/null +++ b/packages/eventindexer/docs/swagger.json @@ -0,0 +1,264 @@ +{ + "swagger": "2.0", + "info": { + "title": "Taiko Eventindexer API", + "termsOfService": "http://swagger.io/terms/", + "contact": { + "name": "API Support", + "url": "https://community.taiko.xyz/", + "email": "info@taiko.xyz" + }, + "license": { + "name": "MIT" + }, + "version": "1.0" + }, + "host": "eventindexer.jolnir.taiko.xyz", + "paths": { + "/assignedBlocks": { + "get": { + "consumes": ["application/json"], + "produces": ["application/json"], + "summary": "Get assigned blocks by prover address", + "operationId": "get-assigned-blocks-by-prover-address", + "parameters": [ + { + "type": "string", + "description": "address to query", + "name": "address", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/paginate.Page" + } + } + } + } + }, + "/events": { + "get": { + "consumes": ["application/json"], + "produces": ["application/json"], + "summary": "Get events by address and event name", + "operationId": "get-events-by-address-and-event-name", + "parameters": [ + { + "type": "string", + "description": "address to query", + "name": "address", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "event name to query", + "name": "event", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/paginate.Page" + } + } + } + } + }, + "/nftsByAddress": { + "get": { + "consumes": ["application/json"], + "produces": ["application/json"], + "summary": "Get nft balances by address and chain ID", + "operationId": "get-nft-balances-by-address-and-chain-id", + "parameters": [ + { + "type": "string", + "description": "address to query", + "name": "address", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "chainID to query", + "name": "chainID", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/paginate.Page" + } + } + } + } + }, + "/stats": { + "get": { + "consumes": ["application/json"], + "produces": ["application/json"], + "summary": "Get stats", + "operationId": "get-stats", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/eventindexer.Stat" + } + } + } + } + }, + "/uniqueProposers": { + "get": { + "consumes": ["application/json"], + "produces": ["application/json"], + "summary": "Get unique proposers", + "operationId": "get-unique-proposers", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/http.uniqueProposersResp" + } + } + } + } + }, + "/uniqueProvers": { + "get": { + "consumes": ["application/json"], + "produces": ["application/json"], + "summary": "Get unique provers", + "operationId": "get-unique-provers", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/http.uniqueProversResp" + } + } + } + } + } + }, + "definitions": { + "eventindexer.Stat": { + "type": "object", + "properties": { + "averageProofReward": { + "type": "string" + }, + "averageProofTime": { + "type": "string" + }, + "averageProposerReward": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "numProofs": { + "type": "integer" + }, + "numProposerRewards": { + "type": "integer" + }, + "numVerifiedBlocks": { + "type": "integer" + } + } + }, + "eventindexer.UniqueProposersResponse": { + "type": "object", + "properties": { + "address": { + "type": "string" + }, + "count": { + "type": "integer" + } + } + }, + "eventindexer.UniqueProversResponse": { + "type": "object", + "properties": { + "address": { + "type": "string" + }, + "count": { + "type": "integer" + } + } + }, + "http.uniqueProposersResp": { + "type": "object", + "properties": { + "proposers": { + "type": "array", + "items": { + "$ref": "#/definitions/eventindexer.UniqueProposersResponse" + } + }, + "uniqueProposers": { + "type": "integer" + } + } + }, + "http.uniqueProversResp": { + "type": "object", + "properties": { + "provers": { + "type": "array", + "items": { + "$ref": "#/definitions/eventindexer.UniqueProversResponse" + } + }, + "uniqueProvers": { + "type": "integer" + } + } + }, + "paginate.Page": { + "type": "object", + "properties": { + "first": { + "type": "boolean" + }, + "items": {}, + "last": { + "type": "boolean" + }, + "max_page": { + "type": "integer" + }, + "page": { + "type": "integer" + }, + "size": { + "type": "integer" + }, + "total": { + "type": "integer" + }, + "total_pages": { + "type": "integer" + }, + "visible": { + "type": "integer" + } + } + } + } +} diff --git a/packages/eventindexer/docs/swagger.yaml b/packages/eventindexer/docs/swagger.yaml new file mode 100644 index 00000000000..5b10a218cc4 --- /dev/null +++ b/packages/eventindexer/docs/swagger.yaml @@ -0,0 +1,189 @@ +definitions: + eventindexer.Stat: + properties: + averageProofReward: + type: string + averageProofTime: + type: string + averageProposerReward: + type: string + id: + type: integer + numProofs: + type: integer + numProposerRewards: + type: integer + numVerifiedBlocks: + type: integer + type: object + eventindexer.UniqueProposersResponse: + properties: + address: + type: string + count: + type: integer + type: object + eventindexer.UniqueProversResponse: + properties: + address: + type: string + count: + type: integer + type: object + http.uniqueProposersResp: + properties: + proposers: + items: + $ref: "#/definitions/eventindexer.UniqueProposersResponse" + type: array + uniqueProposers: + type: integer + type: object + http.uniqueProversResp: + properties: + provers: + items: + $ref: "#/definitions/eventindexer.UniqueProversResponse" + type: array + uniqueProvers: + type: integer + type: object + paginate.Page: + properties: + first: + type: boolean + items: {} + last: + type: boolean + max_page: + type: integer + page: + type: integer + size: + type: integer + total: + type: integer + total_pages: + type: integer + visible: + type: integer + type: object +host: eventindexer.jolnir.taiko.xyz +info: + contact: + email: info@taiko.xyz + name: API Support + url: https://community.taiko.xyz/ + license: + name: MIT + termsOfService: http://swagger.io/terms/ + title: Taiko Eventindexer API + version: "1.0" +paths: + /assignedBlocks: + get: + consumes: + - application/json + operationId: get-assigned-blocks-by-prover-address + parameters: + - description: address to query + in: query + name: address + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: "#/definitions/paginate.Page" + summary: Get assigned blocks by prover address + /events: + get: + consumes: + - application/json + operationId: get-events-by-address-and-event-name + parameters: + - description: address to query + in: query + name: address + required: true + type: string + - description: event name to query + in: query + name: event + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: "#/definitions/paginate.Page" + summary: Get events by address and event name + /nftsByAddress: + get: + consumes: + - application/json + operationId: get-nft-balances-by-address-and-chain-id + parameters: + - description: address to query + in: query + name: address + required: true + type: string + - description: chainID to query + in: query + name: chainID + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: "#/definitions/paginate.Page" + summary: Get nft balances by address and chain ID + /stats: + get: + consumes: + - application/json + operationId: get-stats + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: "#/definitions/eventindexer.Stat" + summary: Get stats + /uniqueProposers: + get: + consumes: + - application/json + operationId: get-unique-proposers + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: "#/definitions/http.uniqueProposersResp" + summary: Get unique proposers + /uniqueProvers: + get: + consumes: + - application/json + operationId: get-unique-provers + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: "#/definitions/http.uniqueProversResp" + summary: Get unique provers +swagger: "2.0" diff --git a/packages/eventindexer/http/get_assigned_blocks_by_prover_address.go b/packages/eventindexer/http/get_assigned_blocks_by_prover_address.go index d16d73192fd..d2f31727cbc 100644 --- a/packages/eventindexer/http/get_assigned_blocks_by_prover_address.go +++ b/packages/eventindexer/http/get_assigned_blocks_by_prover_address.go @@ -5,8 +5,21 @@ import ( "github.com/cyberhorsey/webutils" "github.com/labstack/echo/v4" + + _ "github.com/morkid/paginate" ) +// GetAssignedBlocksByProverAddress +// +// returns the assigned blocks for a given prover address. +// +// @Summary Get assigned blocks by prover address +// @ID get-assigned-blocks-by-prover-address +// @Param address query string true "address to query" +// @Accept json +// @Produce json +// @Success 200 {object} paginate.Page +// @Router /assignedBlocks [get] func (srv *Server) GetAssignedBlocksByProverAddress(c echo.Context) error { page, err := srv.eventRepo.GetAssignedBlocksByProverAddress( c.Request().Context(), diff --git a/packages/eventindexer/http/get_by_address_and_event.go b/packages/eventindexer/http/get_by_address_and_event.go index 38d1410f8b9..dfd95048e3a 100644 --- a/packages/eventindexer/http/get_by_address_and_event.go +++ b/packages/eventindexer/http/get_by_address_and_event.go @@ -7,6 +7,18 @@ import ( "github.com/labstack/echo/v4" ) +// GetByAddressAndEventName +// +// returns events by address and name of the event +// +// @Summary Get events by address and event name +// @ID get-events-by-address-and-event-name +// @Param address query string true "address to query" +// @Param event query string true "event name to query" +// @Accept json +// @Produce json +// @Success 200 {object} paginate.Page +// @Router /events [get] func (srv *Server) GetByAddressAndEventName(c echo.Context) error { page, err := srv.eventRepo.GetByAddressAndEventName( c.Request().Context(), diff --git a/packages/eventindexer/http/get_chart_by_task.go b/packages/eventindexer/http/get_chart_by_task.go index 94dc06ef900..3c97450df90 100644 --- a/packages/eventindexer/http/get_chart_by_task.go +++ b/packages/eventindexer/http/get_chart_by_task.go @@ -9,6 +9,17 @@ import ( "github.com/taikoxyz/taiko-mono/packages/eventindexer" ) +// GetChartByTask +// +// returns time series data for displaying charts +// +// @Summary Get time series data for displaying charts +// @ID get-charts-by-task +// @Param task query string true "task to query" +// @Accept json +// @Produce json +// @Success 200 {object} eventindexer.ChartResponse +// @Router /chartByTask [get] func (srv *Server) GetChartByTask(c echo.Context) error { cached, found := srv.cache.Get(c.QueryParam("task")) diff --git a/packages/eventindexer/http/get_count_by_address_and_event.go b/packages/eventindexer/http/get_count_by_address_and_event.go index 800c2d725e3..a482cf492e5 100644 --- a/packages/eventindexer/http/get_count_by_address_and_event.go +++ b/packages/eventindexer/http/get_count_by_address_and_event.go @@ -7,6 +7,18 @@ import ( "github.com/labstack/echo/v4" ) +// GetCountByAddressAndEventName +// +// returns count of events by user address and event name +// +// @Summary Get count of events by user address and event name +// @ID get-charts-by-task +// @Param address query string true "address to query" +// @Param event query string true "event name to query" +// @Accept json +// @Produce json +// @Success 200 {object} GetCountByAddressAndEventNameResp +// @Router /eventByAddress [get] type GetCountByAddressAndEventNameResp struct { Count int `json:"count"` } diff --git a/packages/eventindexer/http/get_nft_balances_by_address_and_chain_id.go b/packages/eventindexer/http/get_nft_balances_by_address_and_chain_id.go index cb757173956..1befd1d1649 100644 --- a/packages/eventindexer/http/get_nft_balances_by_address_and_chain_id.go +++ b/packages/eventindexer/http/get_nft_balances_by_address_and_chain_id.go @@ -7,6 +7,18 @@ import ( "github.com/labstack/echo/v4" ) +// GetNFTBalancesByAddessAndChainID +// +// returns nft balances by address and chain ID +// +// @Summary Get nft balances by address and chain ID +// @ID get-nft-balances-by-address-and-chain-id +// @Param address query string true "address to query" +// @Param chainID query string true "chainID to query" +// @Accept json +// @Produce json +// @Success 200 {object} paginate.Page +// @Router /nftsByAddress [get] func (srv *Server) GetNFTBalancesByAddessAndChainID(c echo.Context) error { page, err := srv.nftBalanceRepo.FindByAddress( c.Request().Context(), diff --git a/packages/eventindexer/http/get_stats.go b/packages/eventindexer/http/get_stats.go index c66e26a4109..8746b07724a 100644 --- a/packages/eventindexer/http/get_stats.go +++ b/packages/eventindexer/http/get_stats.go @@ -9,6 +9,14 @@ import ( "github.com/taikoxyz/taiko-mono/packages/eventindexer" ) +// GetStats returns the current computed stats for the deployed network. +// +// @Summary Get stats +// @ID get-stats +// @Accept json +// @Produce json +// @Success 200 {object} eventindexer.Stat +// @Router /stats [get] func (srv *Server) GetStats(c echo.Context) error { cached, found := srv.cache.Get(CacheKeyStats) diff --git a/packages/eventindexer/http/get_unique_proposers.go b/packages/eventindexer/http/get_unique_proposers.go index cac8bd10ed9..824658b6b5c 100644 --- a/packages/eventindexer/http/get_unique_proposers.go +++ b/packages/eventindexer/http/get_unique_proposers.go @@ -14,6 +14,16 @@ type uniqueProposersResp struct { UniqueProposers int `json:"uniqueProposers"` } +// GetUniqueProposers +// +// returns all unique proposers +// +// @Summary Get unique proposers +// @ID get-unique-proposers +// @Accept json +// @Produce json +// @Success 200 {object} uniqueProposersResp +// @Router /uniqueProposers [get] func (srv *Server) GetUniqueProposers(c echo.Context) error { cached, found := srv.cache.Get(CacheKeyUniqueProposers) diff --git a/packages/eventindexer/http/get_unique_provers.go b/packages/eventindexer/http/get_unique_provers.go index 02ec73bb40f..1565e7d55e4 100644 --- a/packages/eventindexer/http/get_unique_provers.go +++ b/packages/eventindexer/http/get_unique_provers.go @@ -14,6 +14,16 @@ type uniqueProversResp struct { UniqueProvers int `json:"uniqueProvers"` } +// GetUniqueProvers +// +// returns all unique provers +// +// @Summary Get unique provers +// @ID get-unique-provers +// @Accept json +// @Produce json +// @Success 200 {object} uniqueProversResp +// @Router /uniqueProvers [get] func (srv *Server) GetUniqueProvers(c echo.Context) error { cached, found := srv.cache.Get(CacheKeyUniqueProvers) diff --git a/packages/eventindexer/http/server.go b/packages/eventindexer/http/server.go index 501d67b1538..c55422147a8 100644 --- a/packages/eventindexer/http/server.go +++ b/packages/eventindexer/http/server.go @@ -14,6 +14,18 @@ import ( echo "github.com/labstack/echo/v4" ) +// @title Taiko Eventindexer API +// @version 1.0 +// @termsOfService http://swagger.io/terms/ + +// @contact.name API Support +// @contact.url https://community.taiko.xyz/ +// @contact.email info@taiko.xyz + +// @license.name MIT + +// @host eventindexer.jolnir.taiko.xyz +// Server represents an eventindexer http server instance. type Server struct { echo *echo.Echo eventRepo eventindexer.EventRepository diff --git a/packages/eventindexer/index.html b/packages/eventindexer/index.html new file mode 100644 index 00000000000..f249d5da51b --- /dev/null +++ b/packages/eventindexer/index.html @@ -0,0 +1,29 @@ + +
+ + + +