Skip to content

Commit

Permalink
Merge pull request #597 from bitcoin-sv/SPV-807/adjustSharedConfig
Browse files Browse the repository at this point in the history
SPV-807: adjust shared config
  • Loading branch information
Nazarii-4chain authored May 28, 2024
2 parents 47efa37 + 8106355 commit cf3d33a
Show file tree
Hide file tree
Showing 7 changed files with 631 additions and 603 deletions.
1 change: 0 additions & 1 deletion actions/admin/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func NewHandler(appConfig *config.AppConfig, services *config.AppServices) route
adminGroup.POST("/xpub", action.xpubsCreate)
adminGroup.POST("/xpubs/search", action.xpubsSearch)
adminGroup.POST("/xpubs/count", action.xpubsCount)
adminGroup.GET("/shared-config", action.sharedConfig)
})

return adminEndpoints
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package admin
package sharedconfig

import (
"net/http"
Expand All @@ -12,12 +12,12 @@ import (
// Get shared config godoc
// @Summary Get shared config
// @Description Get shared config
// @Tags Admin
// @Tags Shared-config
// @Produce json
// @Success 200 {object} models.SharedConfig "Shared configuration"
// @Router /v1/admin/shared-config [get]
// @Router /v1/shared-config [get]
// @Security x-auth-xpub
func (a *Action) sharedConfig(c *gin.Context) {
func (a *Action) get(c *gin.Context) {
makeConfig := sync.OnceValue(func() models.SharedConfig {
return models.SharedConfig{
PaymailDomains: a.AppConfig.Paymail.Domains,
Expand Down
25 changes: 25 additions & 0 deletions actions/sharedconfig/routes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package sharedconfig

import (
"github.com/bitcoin-sv/spv-wallet/actions"
"github.com/bitcoin-sv/spv-wallet/config"
"github.com/bitcoin-sv/spv-wallet/server/routes"
"github.com/gin-gonic/gin"
)

// Action is an extension of actions.Action for this package
type Action struct {
actions.Action
}

// NewHandler creates the specific package routes
func NewHandler(appConfig *config.AppConfig, services *config.AppServices) routes.APIEndpointsFunc {
action := &Action{actions.Action{AppConfig: appConfig, Services: services}}

sharedConfigEndpoints := routes.APIEndpointsFunc(func(router *gin.RouterGroup) {
group := router.Group("/shared-config")
group.GET("", action.get)
})

return sharedConfigEndpoints
}
60 changes: 30 additions & 30 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -814,31 +814,6 @@ const docTemplate = `{
}
}
},
"/v1/admin/shared-config": {
"get": {
"security": [
{
"x-auth-xpub": []
}
],
"description": "Get shared config",
"produces": [
"application/json"
],
"tags": [
"Admin"
],
"summary": "Get shared config",
"responses": {
"200": {
"description": "Shared configuration",
"schema": {
"$ref": "#/definitions/models.SharedConfig"
}
}
}
}
},
"/v1/admin/stats": {
"get": {
"security": [
Expand Down Expand Up @@ -1686,6 +1661,31 @@ const docTemplate = `{
}
}
},
"/v1/shared-config": {
"get": {
"security": [
{
"x-auth-xpub": []
}
],
"description": "Get shared config",
"produces": [
"application/json"
],
"tags": [
"Shared-config"
],
"summary": "Get shared config",
"responses": {
"200": {
"description": "Shared configuration",
"schema": {
"$ref": "#/definitions/models.SharedConfig"
}
}
}
}
},
"/v1/transaction": {
"get": {
"security": [
Expand Down Expand Up @@ -3785,7 +3785,7 @@ const docTemplate = `{
}
}
},
"models.FeeUnit": {
"models.FeeUnit": {
"type": "object",
"properties": {
"bytes": {
Expand Down Expand Up @@ -3939,7 +3939,7 @@ const docTemplate = `{
}
}
},
"models.PaymailP4": {
"models.PaymailP4": {
"type": "object",
"properties": {
"alias": {
Expand Down Expand Up @@ -4042,7 +4042,7 @@ const docTemplate = `{
}
}
},
"models.SyncConfig": {
"models.SyncConfig": {
"type": "object",
"properties": {
"broadcast": {
Expand Down Expand Up @@ -4516,7 +4516,7 @@ const docTemplate = `{
}
}
},
"models.UtxoPointer": {
"models.UtxoPointer": {
"type": "object",
"properties": {
"output_index": {
Expand Down Expand Up @@ -4582,7 +4582,7 @@ const docTemplate = `{
}
}
},
"time.Duration": {
"time.Duration": {
"type": "integer",
"enum": [
-9223372036854775808,
Expand Down
Loading

0 comments on commit cf3d33a

Please sign in to comment.