mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-10 21:09:11 +00:00
* feat(did): remove account types * feat: Refactor Property to Proof in zkprop.go * feat: add ZKP proof mechanism for verifications * fix: return bool and error from pinInitialVault * feat: implement KeyshareSet for managing user and validator keyshares * feat: Update Credential type in protobuf * feat: update credential schema with sign count * feat: migrate and modules to middleware * refactor: rename vault module to ORM * chore(dwn): add service worker registration to index template * feat: integrate service worker for offline functionality * refactor(did): use DIDNamespace enum for verification method in proto reflection * refactor: update protobuf definitions to support Keyshare * feat: expose did keeper in app keepers * Add Motr Web App * refactor: rename motr/handlers/discovery.go to motr/handlers/openid.go * refactor: move session related code to middleware * feat: add database operations for managing assets, chains, and credentials * feat: add htmx support for UI updates * refactor: extract common helper scripts * chore: remove unused storage GUI components * refactor: Move frontend rendering to dedicated handlers * refactor: rename to * refactor: move alert implementation to templ * feat: add alert component with icon, title, and message * feat: add new RequestHeaders struct to store request headers * Feature/create home view (#9) * refactor: move view logic to new htmx handler * refactor: remove unnecessary dependencies * refactor: remove unused dependencies * feat(devbox): integrate air for local development * feat: implement openid connect discovery document * refactor: rename to * refactor(did): update service handling to support DNS discovery * feat: add support for user and validator keyshares * refactor: move keyshare signing logic to signer
61 lines
1.4 KiB
Go
61 lines
1.4 KiB
Go
package keeper
|
|
|
|
import (
|
|
"context"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/onsonr/sonr/x/did/builder"
|
|
"github.com/onsonr/sonr/x/did/types"
|
|
"google.golang.org/grpc/peer"
|
|
)
|
|
|
|
type Context struct {
|
|
SDKCtx sdk.Context
|
|
Keeper Keeper
|
|
Peer *peer.Peer
|
|
}
|
|
|
|
func (k Keeper) CurrentCtx(goCtx context.Context) Context {
|
|
ctx := sdk.UnwrapSDKContext(goCtx)
|
|
peer, _ := peer.FromContext(goCtx)
|
|
return Context{SDKCtx: ctx, Peer: peer, Keeper: k}
|
|
}
|
|
|
|
func (c Context) Params() *types.Params {
|
|
return c.Keeper.GetParams(c.SDK())
|
|
}
|
|
|
|
func (c Context) SDK() sdk.Context {
|
|
return c.SDKCtx
|
|
}
|
|
|
|
func (c Context) IsAnonymous() bool {
|
|
if c.Peer == nil {
|
|
return true
|
|
}
|
|
return c.Peer.Addr == nil
|
|
}
|
|
|
|
func (c Context) PeerID() string {
|
|
if c.Peer == nil {
|
|
return ""
|
|
}
|
|
return c.Peer.Addr.String()
|
|
}
|
|
|
|
func (c Context) GetService(origin string) (*types.Service, error) {
|
|
rec, err := c.Keeper.OrmDB.ServiceRecordTable().GetByOrigin(c.SDK(), origin)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return builder.ModuleFormatAPIServiceRecord(rec), nil
|
|
}
|
|
|
|
func (c Context) GetServiceInfo(origin string) *types.ServiceInfo {
|
|
rec, _ := c.GetService(origin)
|
|
if rec == nil {
|
|
return &types.ServiceInfo{Exists: false, Origin: origin, Fingerprint: types.ComputeOriginTXTRecord(origin)}
|
|
}
|
|
return &types.ServiceInfo{Exists: true, Origin: origin, Fingerprint: types.ComputeOriginTXTRecord(origin), Service: rec}
|
|
}
|