This repository was archived by the owner on Nov 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Private Key Encryption (#20)
- Loading branch information
1 parent
dca1b2a
commit 996a23d
Showing
42 changed files
with
1,075 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
package config | ||
|
||
import ( | ||
"os-gateway/internal/config" | ||
"os-gateway/pkg/pokt/pokt_v0/models" | ||
"time" | ||
"pokt_gateway_server/internal/config" | ||
) | ||
|
||
type GatewayServerProvider interface { | ||
GetPoktRPCFullHost() string | ||
GetHTTPServerPort() uint | ||
GetPoktRPCTimeout() time.Duration | ||
GetAppStakes() []*models.Ed25519Account | ||
config.DBCredentialsProvider | ||
config.PoktNodeConfigProvider | ||
config.SecretProvider | ||
config.EnvironmentProvider | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/pquerna/ffjson/ffjson" | ||
"github.com/valyala/fasthttp" | ||
"go.uber.org/zap" | ||
"pokt_gateway_server/cmd/gateway_server/internal/models" | ||
"pokt_gateway_server/cmd/gateway_server/internal/transform" | ||
"pokt_gateway_server/internal/pokt_applications_registry" | ||
"pokt_gateway_server/pkg/pokt/pokt_v0" | ||
) | ||
|
||
// RelayController handles relay requests for a specific chain. | ||
type PoktAppsController struct { | ||
logger *zap.Logger | ||
poktClient pokt_v0.PocketService | ||
appRegistry pokt_applications_registry.Service | ||
} | ||
|
||
// NewRelayController creates a new instance of RelayController. | ||
func NewPoktAppsController(appRegistry pokt_applications_registry.Service, logger *zap.Logger) *PoktAppsController { | ||
return &PoktAppsController{appRegistry: appRegistry, logger: logger} | ||
} | ||
|
||
// GetAllPoktApps is the path for relay requests. | ||
const GetAllPoktApps = "/poktapps" | ||
|
||
// HandleRelay handles incoming relay requests. | ||
func (c *PoktAppsController) GetAll(ctx *fasthttp.RequestCtx) { | ||
applications := c.appRegistry.GetApplications() | ||
appsPublic := []*models.PoktApplication{} | ||
for _, app := range applications { | ||
appsPublic = append(appsPublic, transform.ToPoktApplication(app)) | ||
} | ||
result, err := ffjson.Marshal(appsPublic) | ||
if err != nil { | ||
ctx.Response.SetStatusCode(fasthttp.StatusInternalServerError) | ||
return | ||
} | ||
// Send a successful response back to the client. | ||
ctx.Response.SetStatusCode(fasthttp.StatusOK) | ||
ctx.Response.Header.Set("Content-Type", "application/json") | ||
ctx.Response.SetBody(result) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package models | ||
|
||
type PoktApplication struct { | ||
ID string `json:"id"` | ||
MaxRelays int `json:"max_relays"` | ||
Chains []string `json:"chain"` | ||
Address string `json:"address"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package transform | ||
|
||
import ( | ||
"pokt_gateway_server/cmd/gateway_server/internal/models" | ||
internal_model "pokt_gateway_server/internal/pokt_applications_registry/models" | ||
) | ||
|
||
func ToPoktApplication(signer *internal_model.PoktApplicationSigner) *models.PoktApplication { | ||
return &models.PoktApplication{ | ||
ID: signer.ID, | ||
MaxRelays: int(signer.MaxRelays), | ||
Chains: signer.Chains, | ||
Address: signer.PoktApplication.Address, | ||
} | ||
} |
Oops, something went wrong.