Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1.0 mock #17

Merged
merged 18 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions common/model/api_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package model

import "errors"

type TryPayUserOpRequest struct {
ForceStrategyId string `json:"force_strategy_id"`
ForceNetWork string `json:"force_network"`
ForceTokens string `json:"force_tokens"`
ForceEntryPointAddress string `json:"force_entrypoint_address"`
UserOperation UserOperationItem `json:"user_operation"`
Extra interface{} `json:"extra"`
}

func (request *TryPayUserOpRequest) Validate() error {
if len(request.ForceStrategyId) == 0 {
if len(request.ForceNetWork) == 0 || len(request.ForceTokens) == 0 || len(request.ForceEntryPointAddress) == 0 {
return errors.New("strategy configuration illegal")
}
}
return nil
}

type GetSupportEntrypointRequest struct {
}

func (request *GetSupportEntrypointRequest) Validate() error {
return nil
}

type GetSupportStrategyRequest struct {
}

func (request *GetSupportStrategyRequest) Validate() error {
return nil
}
18 changes: 18 additions & 0 deletions common/model/api_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package model

type TryPayUserOpResponse struct {
StrategyId string `json:"strategy_id"`
EntryPointAddress string `json:"entrypoint_address"`
PayMasterAddress string `json:"paymaster_address"`
PayMasterSignature string `json:"paymaster_signature"`
PayReceipt interface{} `json:"pay_receipt"`
GasInfo *ComputeGasResponse `json:"gas_info"`
}

type ComputeGasResponse struct {
fanhousanbu marked this conversation as resolved.
Show resolved Hide resolved
StrategyId string `json:"strategy_id"`
TokenCost string `json:"token_cost"`
Network string `json:"network"`
Token string `json:"token"`
UsdCost string `json:"usd_cost"`
}
1 change: 1 addition & 0 deletions common/model/chain.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package model
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package models
package model

type ClientCredential struct {
ApiKey string `json:"apiKey"`
Expand Down
4 changes: 2 additions & 2 deletions rpc_server/models/response.go → common/model/response.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package models
package model

import (
"github.com/gin-gonic/gin"
Expand All @@ -10,7 +10,7 @@ func GetResponse() *Response {
return &Response{
httpCode: http.StatusOK,
Result: &Result{
Code: 0,
Code: 200,
Message: "",
Data: nil,
Cost: "",
Expand Down
7 changes: 7 additions & 0 deletions common/model/strategy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package model

type Strategy struct {
Id string
EntryPointAddress string
PayMasterAddress string
}
14 changes: 14 additions & 0 deletions common/model/user_operation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package model

type UserOperationItem struct {
Sender string `json:"sender" binding:"required"`
Nonce string `json:"nonce" binding:"required"`
InitCode string `json:"init_code"`
CallGasLimit string `json:"call_gas_limit" binding:"required"`
VerificationGasList string `json:"verification_gas_list" binding:"required"`
PerVerificationGas string `json:"per_verification_gas" binding:"required"`
MaxFeePerGas string `json:"max_fee_per_gas" binding:"required"`
MaxPriorityFeePerGas string `json:"max_priority_fee_per_gas" binding:"required"`
Signature string `json:"signature"`
//paymasterAndData string `json:"paymaster_and_data"`
}
4 changes: 0 additions & 4 deletions common/types/strategy.go

This file was deleted.

2 changes: 1 addition & 1 deletion conf/appsettings.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jwt:
security: hello-eth-paymaster
security: hello-ethereum-paymaster
realm: aastar
idkey: id
80 changes: 78 additions & 2 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.ClientCredential"
"$ref": "#/definitions/model.ClientCredential"
}
}
],
Expand All @@ -48,6 +48,9 @@ const docTemplate = `{
"/api/healthz": {
"get": {
"description": "Get Healthz",
"consumes": [
"application/json"
],
"tags": [
"Healthz"
],
Expand Down Expand Up @@ -117,6 +120,17 @@ const docTemplate = `{
"tags": [
"Sponsor"
],
"parameters": [
{
"description": "UserOp Request",
"name": "tryPay",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/model.TryPayUserOpRequest"
}
}
],
"responses": {
"200": {
"description": "OK"
Expand All @@ -126,13 +140,75 @@ const docTemplate = `{
}
},
"definitions": {
"models.ClientCredential": {
"model.ClientCredential": {
"type": "object",
"properties": {
"apiKey": {
"type": "string"
}
}
},
"model.TryPayUserOpRequest": {
"type": "object",
"properties": {
"extra": {},
"force_entrypoint_address": {
"type": "string"
},
"force_network": {
"type": "string"
},
"force_strategy_id": {
"type": "string"
},
"force_tokens": {
"type": "string"
},
"user_operation": {
"$ref": "#/definitions/model.UserOperationItem"
}
}
},
"model.UserOperationItem": {
"type": "object",
"required": [
"call_gas_limit",
"max_fee_per_gas",
"max_priority_fee_per_gas",
"nonce",
"per_verification_gas",
"sender",
"verification_gas_list"
],
"properties": {
"call_gas_limit": {
"type": "string"
},
"init_code": {
"type": "string"
},
"max_fee_per_gas": {
"type": "string"
},
"max_priority_fee_per_gas": {
"type": "string"
},
"nonce": {
"type": "string"
},
"per_verification_gas": {
"type": "string"
},
"sender": {
"type": "string"
},
"signature": {
"type": "string"
},
"verification_gas_list": {
"type": "string"
}
}
}
},
"securityDefinitions": {
Expand Down
80 changes: 78 additions & 2 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/models.ClientCredential"
"$ref": "#/definitions/model.ClientCredential"
}
}
],
Expand All @@ -37,6 +37,9 @@
"/api/healthz": {
"get": {
"description": "Get Healthz",
"consumes": [
"application/json"
],
"tags": [
"Healthz"
],
Expand Down Expand Up @@ -106,6 +109,17 @@
"tags": [
"Sponsor"
],
"parameters": [
{
"description": "UserOp Request",
"name": "tryPay",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/model.TryPayUserOpRequest"
}
}
],
"responses": {
"200": {
"description": "OK"
Expand All @@ -115,13 +129,75 @@
}
},
"definitions": {
"models.ClientCredential": {
"model.ClientCredential": {
"type": "object",
"properties": {
"apiKey": {
"type": "string"
}
}
},
"model.TryPayUserOpRequest": {
"type": "object",
"properties": {
"extra": {},
"force_entrypoint_address": {
"type": "string"
},
"force_network": {
"type": "string"
},
"force_strategy_id": {
"type": "string"
},
"force_tokens": {
"type": "string"
},
"user_operation": {
"$ref": "#/definitions/model.UserOperationItem"
}
}
},
"model.UserOperationItem": {
"type": "object",
"required": [
"call_gas_limit",
"max_fee_per_gas",
"max_priority_fee_per_gas",
"nonce",
"per_verification_gas",
"sender",
"verification_gas_list"
],
"properties": {
"call_gas_limit": {
"type": "string"
},
"init_code": {
"type": "string"
},
"max_fee_per_gas": {
"type": "string"
},
"max_priority_fee_per_gas": {
"type": "string"
},
"nonce": {
"type": "string"
},
"per_verification_gas": {
"type": "string"
},
"sender": {
"type": "string"
},
"signature": {
"type": "string"
},
"verification_gas_list": {
"type": "string"
}
}
}
},
"securityDefinitions": {
Expand Down
Loading
Loading