Skip to content

Commit

Permalink
change routers.go
Browse files Browse the repository at this point in the history
  • Loading branch information
cherry-yl-sh committed Mar 1, 2024
1 parent e2b1b09 commit 4ab6975
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 3 deletions.
28 changes: 28 additions & 0 deletions rpc_server/api/v1/get_support_entrypoint.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package v1

import (
"AAStarCommunity/EthPaymaster_BackService/rpc_server/models"
"AAStarCommunity/EthPaymaster_BackService/service"
"fmt"
"github.com/gin-gonic/gin"
"net/http"
)

// GetSupportEntrypoint
// @Tags Sponsor
// @Description get the support entrypoint
// @Accept json
// @Product json
// @Router /api/v1/get_support_entrypoint [get]
// @Success 200 {object} gin.H
func GetSupportEntrypoint(c *gin.Context) {
//1.TODO API validate
//2. recall service
result, err := service.GetSupportEntrypointExecute()
response := models.GetResponse()
if err != nil {
errStr := fmt.Sprintf("%v", err)
response.SetHttpCode(http.StatusInternalServerError).FailCode(c, http.StatusInternalServerError, errStr)
}
response.WithData(result).Success(c)
}
28 changes: 28 additions & 0 deletions rpc_server/api/v1/get_supprot_strategy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package v1

import (
"AAStarCommunity/EthPaymaster_BackService/rpc_server/models"
"AAStarCommunity/EthPaymaster_BackService/service"
"fmt"
"github.com/gin-gonic/gin"
"net/http"
)

// GetSupportStrategy
// @Tags Sponsor
// @Description get the support strategy
// @Accept json
// @Produce json
// @Success 200 {object} gin.H
// @Router /api/v1/get_support_strategy [get]
func GetSupportStrategy(c *gin.Context) {
//1.TODO API validate
//2. recall service
result, err := service.GetSupportStrategyExecute()
response := models.GetResponse()
if err != nil {
errStr := fmt.Sprintf("%v", err)
response.SetHttpCode(http.StatusInternalServerError).FailCode(c, http.StatusInternalServerError, errStr)
}
response.WithData(result).Success(c)
}
16 changes: 13 additions & 3 deletions rpc_server/api/v1/pay_user_operation.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package v1

import (
"AAStarCommunity/EthPaymaster_BackService/rpc_server/models"
"AAStarCommunity/EthPaymaster_BackService/service"
"fmt"
"github.com/gin-gonic/gin"
"net/http"
)

// TryPayUserOperation
Expand All @@ -12,7 +16,13 @@ import (
// @Router /api/v1/try-pay-user-operation [post]
// @Success 200
func TryPayUserOperation(c *gin.Context) {
c.JSON(200, gin.H{
"status": "ok",
})
//1.TODO API validate
//2. recall service
result, err := service.TryPayUserOpExecute()
response := models.GetResponse()
if err != nil {
errStr := fmt.Sprintf("%v", err)
response.SetHttpCode(http.StatusInternalServerError).FailCode(c, http.StatusInternalServerError, errStr)
}
response.WithData(result).Success(c)
}
1 change: 1 addition & 0 deletions rpc_server/models/userOperation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package models
3 changes: 3 additions & 0 deletions rpc_server/routers/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ func init() {
RouterMaps = make([]RouterMap, 0)

RouterMaps = append(RouterMaps, RouterMap{"api/v1/try-pay-user-operation", []RestfulMethod{POST}, v1.TryPayUserOperation})
RouterMaps = append(RouterMaps, RouterMap{"api/v1/get_support_strategy", []RestfulMethod{POST}, v1.GetSupportStrategy})
RouterMaps = append(RouterMaps, RouterMap{"api/v1/get_support_entrypoint", []RestfulMethod{POST}, v1.GetSupportEntrypoint})

}
1 change: 1 addition & 0 deletions service/service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package service
13 changes: 13 additions & 0 deletions service/tryPayUserOperationExecutor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package service

import "AAStarCommunity/EthPaymaster_BackService/rpc_server/models"

func TryPayUserOpExecute() (models.Result, error) {
return models.Result{}, nil
}
func GetSupportEntrypointExecute() (models.Result, error) {
return models.Result{}, nil
}
func GetSupportStrategyExecute() (models.Result, error) {
return models.Result{}, nil
}

0 comments on commit 4ab6975

Please sign in to comment.