Skip to content

Commit

Permalink
update Deposit
Browse files Browse the repository at this point in the history
  • Loading branch information
cherry-yl-sh committed Jun 14, 2024
1 parent b9830dc commit 2fcf3ca
Show file tree
Hide file tree
Showing 14 changed files with 400 additions and 315 deletions.
1 change: 0 additions & 1 deletion cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ func main() {
}

func initEngine(strategyPath string, basicConfigPath string, secretPath string) {

logrus.Infof("secretPath: %s", secretPath)
config.InitConfig(strategyPath, basicConfigPath, secretPath)
if envirment.Environment.IsDevelopment() {
Expand Down
4 changes: 1 addition & 3 deletions common/model/sponsor.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package model

import "math/big"

type DepositSponsorRequest struct {
TimeStamp int64 `json:"time_stamp"`
DepositAddress string `json:"deposit_address"`
Expand All @@ -11,7 +9,7 @@ type DepositSponsorRequest struct {
DepositSource string `json:"deposit_source"`
}
type WithdrawSponsorRequest struct {
Amount *big.Float
Amount float64

PayUserId string
IsTestNet bool
Expand Down
12 changes: 7 additions & 5 deletions common/utils/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

var HexPattern = regexp.MustCompile(`^0x[a-fA-F\d]*$`)

const defaultStackSize = 4096
const defaultStackSize = 10000

type EthCallReq struct {
From common.Address `json:"from"`
Expand Down Expand Up @@ -202,18 +202,20 @@ func GetCurrentGoroutineStack() string {
n := runtime.Stack(buf[:], false)
return string(buf[:n])
}
func DBTransactional(db *gorm.DB, handle func() error) (err error) {
func DBTransactional(db *gorm.DB, handle func(tx *gorm.DB) error) (err error) {
tx := db.Begin()
defer func() {
if p := recover(); p != nil {
tx.Rollback()
panic(p)
logrus.Errorf("TX ERROR [%s] ", GetCurrentGoroutineStack())
err = xerrors.Errorf("TX ERROR [%v]", p)
//panic(p)
} else if err != nil {
tx.Rollback()
} else {
err = tx.Commit().Error
}
}()
err = handle()
return
err = handle(tx)
return err
}
139 changes: 109 additions & 30 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,46 @@ const docTemplate = `{
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/api/auth": {
"/api/healthz": {
"get": {
"description": "Get Healthz",
"consumes": [
"application/json"
],
"tags": [
"Healthz"
],
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/api/v1/paymaster/{network}": {
"post": {
"description": "Get AccessToken By ApiKey",
"description": "Paymaster JSON-RPC API",
"consumes": [
"application/json"
],
"tags": [
"Auth"
"Paymaster"
],
"parameters": [
{
"description": "AccessToken Model",
"name": "credential",
"type": "string",
"description": "Network",
"name": "network",
"in": "path",
"required": true
},
{
"description": "JsonRpcRequest Model",
"name": "rpcRequest",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/model.ClientCredential"
"$ref": "#/definitions/model.JsonRpcRequest"
}
}
],
Expand All @@ -45,14 +68,37 @@ const docTemplate = `{
}
}
},
"/api/healthz": {
"get": {
"description": "Get Healthz",
"/api/v1/paymaster_sponsor/deposit": {
"post": {
"description": "Deposit Sponsor",
"consumes": [
"application/json"
],
"tags": [
"Healthz"
"DepositSponsor"
],
"parameters": [
{
"description": "DepositSponsorRequest Model",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/model.DepositSponsorRequest"
}
},
{
"type": "string",
"description": "relay Request Body Hash",
"name": "relay_hash",
"in": "header"
},
{
"type": "string",
"description": "relay Request Body Hash",
"name": "relay_signature",
"in": "header"
}
],
"responses": {
"200": {
Expand All @@ -61,36 +107,31 @@ const docTemplate = `{
}
}
},
"/api/v1/paymaster/{network}": {
"/api/v1/paymaster_sponsor/withdraw": {
"post": {
"security": [
{
"JWT": []
}
],
"description": "Paymaster JSON-RPC API",
"description": "Withdraw Sponsor",
"consumes": [
"application/json"
],
"tags": [
"Paymaster"
"Sponsor"
],
"parameters": [
{
"type": "string",
"description": "Network",
"name": "network",
"in": "path",
"required": true
},
{
"description": "JsonRpcRequest Model",
"name": "rpcRequest",
"description": "WithdrawSponsorRequest Model",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/model.JsonRpcRequest"
"$ref": "#/definitions/model.WithdrawSponsorRequest"
}
},
{
"type": "boolean",
"description": "Is Test Net",
"name": "is_test_net",
"in": "path",
"required": true
}
],
"responses": {
Expand All @@ -102,10 +143,25 @@ const docTemplate = `{
}
},
"definitions": {
"model.ClientCredential": {
"model.DepositSponsorRequest": {
"type": "object",
"properties": {
"apiKey": {
"deposit_address": {
"type": "string"
},
"deposit_source": {
"type": "string"
},
"is_test_net": {
"type": "boolean"
},
"pay_user_id": {
"type": "string"
},
"time_stamp": {
"type": "integer"
},
"tx_hash": {
"type": "string"
}
}
Expand All @@ -127,6 +183,29 @@ const docTemplate = `{
"items": {}
}
}
},
"model.WithdrawSponsorRequest": {
"type": "object",
"properties": {
"amount": {
"type": "number"
},
"isTestNet": {
"type": "boolean"
},
"payUserId": {
"type": "string"
},
"txHash": {
"type": "string"
},
"txInfo": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
},
"securityDefinitions": {
Expand Down
Loading

0 comments on commit 2fcf3ca

Please sign in to comment.