-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
53 lines (47 loc) · 2.2 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"context"
"github.com/gin-gonic/gin"
"github.com/optimism-java/dispute-explorer/docs"
"github.com/optimism-java/dispute-explorer/internal/api"
"github.com/optimism-java/dispute-explorer/internal/handler"
"github.com/optimism-java/dispute-explorer/internal/svc"
"github.com/optimism-java/dispute-explorer/internal/types"
"github.com/optimism-java/dispute-explorer/migration/migrate"
"github.com/optimism-java/dispute-explorer/pkg/log"
swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
)
func main() {
ctx := context.Background()
cfg := types.GetConfig()
log.Init(cfg.LogLevel, cfg.LogFormat)
log.Infof("config: %v\n", cfg)
sCtx := svc.NewServiceContext(ctx, cfg)
migrate.Migrate(sCtx.DB)
handler.Run(sCtx)
log.Info("listener running...\n")
router := gin.Default()
disputeGameHandler := api.NewDisputeGameHandler(sCtx.DB, sCtx.L1RPC, sCtx.L2RPC, cfg)
docs.SwaggerInfo.Title = "Dispute Game Swagger API"
docs.SwaggerInfo.Description = "This is a dispute-explorer server."
docs.SwaggerInfo.BasePath = "/"
router.GET("/disputegames", disputeGameHandler.ListDisputeGames)
router.GET("/disputegames/:address/claimdatas", disputeGameHandler.GetClaimData)
router.GET("/disputegames/credit/rank", disputeGameHandler.GetCreditRank)
router.GET("/disputegames/:address/credit", disputeGameHandler.GetCreditDetails)
router.GET("/disputegames/overview", disputeGameHandler.GetOverview)
router.GET("/disputegames/overview/amountperday", disputeGameHandler.GetAmountPerDays)
router.GET("/disputegames/statistics/bond/inprogress", disputeGameHandler.GetBondInProgressPerDays)
router.GET("/disputegames/daylycount", disputeGameHandler.GetCountDisputeGameGroupByStatus)
router.GET("/disputegames/events", disputeGameHandler.ListGameEvents)
router.GET("/disputegames/claimroot/:blockNumber", disputeGameHandler.GetClaimRoot)
router.POST("/disputegames/calculate/claim", disputeGameHandler.GetGamesClaimByPosition)
router.GET("/disputegames/chainname", disputeGameHandler.GetCurrentBlockChain)
router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
err := router.Run(":" + cfg.APIPort)
if err != nil {
log.Errorf("start error %s", err)
return
}
}