feature/migrate models (#16)

* feat: add new supported attestation formats to genesis

* feat: refactor keyType to keytype enum

* refactor: remove unused imports and code

* refactor: update main.go to use src package

* refactor: move web-related structs from  to

* refactor: move client middleware package to root

* refactor: remove unused IndexedDB dependency

* feat: update worker implementation to use

* feat: add Caddyfile and Caddy configuration for vault service

* refactor(config): move keyshare and address to Motr config

* fix: validate service origin in AllocateVault

* chore: remove IndexedDB configuration

* feat: add support for IPNS-based vault access
This commit is contained in:
Prad Nukala
2024-09-19 02:04:22 -04:00
committed by GitHub
parent 6d8bd8fc85
commit 96e6486c43
151 changed files with 10997 additions and 21705 deletions
+24 -36
View File
@@ -2,13 +2,11 @@ package keeper
import (
"context"
"encoding/json"
"cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/onsonr/sonr/x/did/builder"
"github.com/onsonr/sonr/x/did/types"
)
@@ -23,21 +21,6 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer {
return &msgServer{k: keeper}
}
// # AuthorizeService
//
// AuthorizeService implements types.MsgServer.
func (ms msgServer) AuthorizeService(goCtx context.Context, msg *types.MsgAuthorizeService) (*types.MsgAuthorizeServiceResponse, error) {
if ms.k.authority != msg.Controller {
return nil, errors.Wrapf(
govtypes.ErrInvalidSigner,
"invalid authority; expected %s, got %s",
ms.k.authority,
msg.Controller,
)
}
return &types.MsgAuthorizeServiceResponse{}, nil
}
// # AllocateVault
//
// AllocateVault implements types.MsgServer.
@@ -45,32 +28,22 @@ func (ms msgServer) AllocateVault(
goCtx context.Context,
msg *types.MsgAllocateVault,
) (*types.MsgAllocateVaultResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
// 1.Check if the service origin is valid
// if ms.k.IsValidServiceOrigin(ctx, msg.Origin) {
// return nil, types.ErrInvalidServiceOrigin
// }
ctx := ms.k.UnwrapCtx(goCtx)
if err := ctx.ValidateOrigin(msg.Origin); err != nil {
return nil, err
}
cid, expiryBlock, err := ms.k.assembleInitialVault(ctx)
if err != nil {
return nil, err
}
regOpts, err := builder.GetPublicKeyCredentialCreationOptions(msg.Origin, msg.Subject, cid, ms.k.GetParams(ctx))
if err != nil {
return nil, err
}
// Convert to string
regOptsJSON, err := json.Marshal(regOpts)
// 2.Allocate the vault
cid, expiryBlock, err := ms.k.AssembleVault(ctx, msg.GetSubject(), msg.GetOrigin())
if err != nil {
return nil, err
}
// 3.Return the response
return &types.MsgAllocateVaultResponse{
ExpiryBlock: expiryBlock,
Cid: cid,
RegistrationOptions: string(regOptsJSON),
ExpiryBlock: expiryBlock,
Cid: cid,
}, nil
}
@@ -101,6 +74,21 @@ func (ms msgServer) RegisterService(
return nil, errors.Wrapf(types.ErrInvalidServiceOrigin, "invalid service origin")
}
// # AuthorizeService
//
// AuthorizeService implements types.MsgServer.
func (ms msgServer) AuthorizeService(goCtx context.Context, msg *types.MsgAuthorizeService) (*types.MsgAuthorizeServiceResponse, error) {
if ms.k.authority != msg.Controller {
return nil, errors.Wrapf(
govtypes.ErrInvalidSigner,
"invalid authority; expected %s, got %s",
ms.k.authority,
msg.Controller,
)
}
return &types.MsgAuthorizeServiceResponse{}, nil
}
// # UpdateParams
//
// UpdateParams updates the x/did module parameters.