From 400eeb820ecb8b9ac86af9c2fdfbcc8bedeefe45 Mon Sep 17 00:00:00 2001 From: dylanyang Date: Thu, 14 Mar 2024 14:40:03 +0800 Subject: [PATCH] update API --- go.sum | 2 ++ service/dashboard_service/dashboard_service.go | 8 ++++---- .../operator/get_support_entry_point_execute.go | 14 ++++++++++++-- .../get_support_entry_point_execute_test.go | 11 +++++++++++ service/operator/get_support_strategy_execute.go | 5 +++-- .../operator/get_support_strategy_execute_test.go | 13 +++++++++++++ 6 files changed, 45 insertions(+), 8 deletions(-) diff --git a/go.sum b/go.sum index 944906a8..2be1a2b5 100644 --- a/go.sum +++ b/go.sum @@ -120,6 +120,8 @@ github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= diff --git a/service/dashboard_service/dashboard_service.go b/service/dashboard_service/dashboard_service.go index f9016f00..708e8ddc 100644 --- a/service/dashboard_service/dashboard_service.go +++ b/service/dashboard_service/dashboard_service.go @@ -7,12 +7,12 @@ import ( ) // TODO just Temp Mock -var mockStrategyMap = map[string]*model.Strategy{} +var MockStrategyMap = map[string]*model.Strategy{} var payMasterSupport = map[string]bool{} var entryPointSupport = map[string]bool{} func init() { - mockStrategyMap["1"] = &model.Strategy{ + MockStrategyMap["1"] = &model.Strategy{ Id: "1", EntryPointAddress: "0x0576a174D229E3cFA37253523E645A78A0C91B57", PayMasterAddress: "0x0000000000325602a77416A16136FDafd04b299f", @@ -21,7 +21,7 @@ func init() { EntryPointTag: types.EntrypointV06, Token: types.USDT, } - mockStrategyMap["2"] = &model.Strategy{ + MockStrategyMap["2"] = &model.Strategy{ Id: "2", EntryPointAddress: "0x0576a174D229E3cFA37253523E645A78A0C91B57", PayMasterAddress: "0x0000000000325602a77416A16136FDafd04b299f", @@ -35,7 +35,7 @@ func init() { payMasterSupport["0x0000000000325602a77416A16136FDafd04b299f"] = true } func GetStrategyById(strategyId string) *model.Strategy { - return mockStrategyMap[strategyId] + return MockStrategyMap[strategyId] } func GetSupportEntryPoint() { diff --git a/service/operator/get_support_entry_point_execute.go b/service/operator/get_support_entry_point_execute.go index 68cc59e2..69d4af70 100644 --- a/service/operator/get_support_entry_point_execute.go +++ b/service/operator/get_support_entry_point_execute.go @@ -1,9 +1,19 @@ package operator -import "AAStarCommunity/EthPaymaster_BackService/common/model" +import ( + "AAStarCommunity/EthPaymaster_BackService/common/model" + "AAStarCommunity/EthPaymaster_BackService/common/types" +) func GetSupportEntrypointExecute(network string) (*model.GetSupportEntryPointResponse, error) { return &model.GetSupportEntryPointResponse{ - EntrypointDomains: &[]model.EntrypointDomain{}, + EntrypointDomains: &[]model.EntrypointDomain{ + { + Address: "0x0576a174D229E3cFA37253523E645A78A0C91B57", + Desc: "desc", + NetWork: types.Sepolia, + StrategyId: "1", + }, + }, }, nil } diff --git a/service/operator/get_support_entry_point_execute_test.go b/service/operator/get_support_entry_point_execute_test.go index 18b97f2b..e7a7bc07 100644 --- a/service/operator/get_support_entry_point_execute_test.go +++ b/service/operator/get_support_entry_point_execute_test.go @@ -1 +1,12 @@ package operator + +import ( + "github.com/stretchr/testify/assert" + "testing" +) + +func TestGetSupportEntrypointExecute(t *testing.T) { + res, err := GetSupportEntrypointExecute("network") + assert.NoError(t, err) + t.Log(res.EntrypointDomains) +} diff --git a/service/operator/get_support_strategy_execute.go b/service/operator/get_support_strategy_execute.go index 8fe58223..411b8109 100644 --- a/service/operator/get_support_strategy_execute.go +++ b/service/operator/get_support_strategy_execute.go @@ -2,8 +2,9 @@ package operator import ( "AAStarCommunity/EthPaymaster_BackService/common/model" + "AAStarCommunity/EthPaymaster_BackService/service/dashboard_service" ) -func GetSupportStrategyExecute(network string) (*model.Result, error) { - return &model.Result{}, nil +func GetSupportStrategyExecute(network string) (map[string]*model.Strategy, error) { + return dashboard_service.MockStrategyMap, nil } diff --git a/service/operator/get_support_strategy_execute_test.go b/service/operator/get_support_strategy_execute_test.go index 18b97f2b..65e2089e 100644 --- a/service/operator/get_support_strategy_execute_test.go +++ b/service/operator/get_support_strategy_execute_test.go @@ -1 +1,14 @@ package operator + +import ( + "fmt" + "github.com/stretchr/testify/assert" + "testing" +) + +func TestGetSupportStrategyExecute(t *testing.T) { + res, err := GetSupportStrategyExecute("network") + assert.NoError(t, err) + assert.NotNil(t, res) + fmt.Println(res["1"]) +}