Skip to content

Commit

Permalink
fix: update Schema service to use new API endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
prnk28 committed Oct 8, 2024
1 parent af6e073 commit fbc640b
Show file tree
Hide file tree
Showing 11 changed files with 1,481 additions and 122 deletions.
1,043 changes: 970 additions & 73 deletions api/vault/v1/query.pulsar.go

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions api/vault/v1/query_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
1 change: 1 addition & 0 deletions devbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"make build-hway"
],
"gen:proto": [
"rm -rf ./pkg/nebula/node_modules",
"make proto-gen"
],
"gen:pkl": [
Expand Down
15 changes: 0 additions & 15 deletions pkg/nebula/nebula.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
package nebula

import (
"context"
"embed"
"io/fs"
"net/http"

"github.com/labstack/echo/v4"

"github.com/onsonr/sonr/pkg/nebula/models"
)

//go:embed assets
var embeddedFiles embed.FS

//go:embed nebula.pkl
var config []byte

func getHTTPFS() (http.FileSystem, error) {
fsys, err := fs.Sub(embeddedFiles, "assets")
if err != nil {
Expand All @@ -27,21 +21,12 @@ func getHTTPFS() (http.FileSystem, error) {

// UseAssets is a middleware that serves static files from the embedded assets
func UseAssets(e *echo.Echo) error {
err := models.LoadFromString(context.Background(), string(config))
if err != nil {
return err
}
fsys, err := getHTTPFS()
if err != nil {
return err
}
assets := http.FileServer(fsys)
e.GET("/", echo.WrapHandler(assets))
e.GET("/assets/*", echo.WrapHandler(http.StripPrefix("/assets/", assets)))
e.GET("/_nebula/config", handleGetConfig)
return nil
}

func handleGetConfig(c echo.Context) error {
return c.Blob(http.StatusOK, "application/octet-stream", config)
}
15 changes: 15 additions & 0 deletions proto/vault/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ service Query {
option (google.api.http).post = "/vault/v1/buildtx";
}

// Schema queries the DID document by its id. And returns the required PKL
// information
rpc Schema(QuerySchemaRequest) returns (QuerySchemaResponse) {
option (google.api.http).get = "/vault/v1/schema";
}

// Sync queries the DID document by its id. And returns the required PKL
// information
rpc Sync(SyncRequest) returns (SyncResponse) {
Expand All @@ -43,6 +49,15 @@ message QueryIPFSResponse {
bool ipfs = 1;
}

// QuerySchemaRequest is the request type for the Query/Schema RPC method.
message QuerySchemaRequest {}

// QuerySchemaResponse is the response type for the Query/Schema RPC method.
message QuerySchemaResponse {
// Schema is the DID document.
Schema schema = 1;
}

// SyncRequest is the request type for the Sync RPC method.
message SyncRequest {
string did = 1;
Expand Down
1 change: 0 additions & 1 deletion web/provider/sync.go

This file was deleted.

1 change: 0 additions & 1 deletion web/provider/wss.go

This file was deleted.

13 changes: 13 additions & 0 deletions x/vault/keeper/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,16 @@ func (k Querier) BuildTx(goCtx context.Context, req *types.BuildTxRequest) (*typ
// ctx := sdk.UnwrapSDKContext(goCtx)
return &types.BuildTxResponse{}, nil
}

// Schema implements types.QueryServer.
func (k Querier) Schema(goCtx context.Context, req *types.QuerySchemaRequest) (*types.QuerySchemaResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

p, err := k.Keeper.Params.Get(ctx)
if err != nil {
return nil, err
}
return &types.QuerySchemaResponse{
Schema: p.Schema,
}, nil
}
Loading

0 comments on commit fbc640b

Please sign in to comment.