mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-10 13:07:09 +00:00
- **feat(did): add assertion type to DID spec** - **refactor: update build process to include assets generation** - **refactor: update import paths for to** - **feat: introduce new authentication state management** - **feat: add current account route** - **feat: implement global toasts with custom HTML** - **refactor: remove unused session code** - **feat: add config.json to embedded assets** - **refactor: remove unused dependency on gorilla/sessions** - **refactor: simplify session management and remove unnecessary fields** - **fix: remove unnecessary import for unused protobuf types** - **feat: introduce separate HTTP contexts for Highway and DWN** - **fix(keeper): Handle missing controller during initial sync** - **refactor: extract DWN configuration from DWNContext** - **feat: add view route** - **fix: update configuration file name in embed.go** - **feat: improve vaultindex page loading experience** - **feat(hway): add highway context to echo context** - **chore(deps): bump onsonr/crypto from 1.32.0 to 1.33.0** - **refactor: rename DWNSessionMiddleware to WebNodeSessionMiddleware** - **feat: rename client API to web node API** - **refactor: separate API and view routes** - **refactor: remove unused build targets in Makefile** - **feat: add Devbox integration to container** - **feat: add wasm support for dwn** - **refactor: update module proto import** - **feat: add default first and third party caveats** - **feat: Add target vault allocation mechanism** - **refactor: introduce standardized session cookie handling** - **fix: update service worker installation and ready states** - **feat: add worker handlers** - **feat: Enable SSH access to devcontainer** - **refactor: rename HighwayContext to HwayContext** - **feat: add block expiration calculation to sonr context** - **feat: remove config from cookie and header** - **feat(gen): Remove generated code for IPFS, Motr and Sonr** - **refactor: remove unused createMotrConfig function** - **feat: add project analytics with Repobeats** - **docs: Remove component details from README** - **refactor: rename SetConfig to injectConfig**
139 lines
3.7 KiB
Go
139 lines
3.7 KiB
Go
package module
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"cosmossdk.io/client/v2/autocli"
|
|
errorsmod "cosmossdk.io/errors"
|
|
abci "github.com/cometbft/cometbft/abci/types"
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/cosmos-sdk/types/module"
|
|
"github.com/gorilla/mux"
|
|
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
|
|
|
didkeeper "github.com/onsonr/sonr/x/did/keeper"
|
|
"github.com/onsonr/sonr/x/vault/keeper"
|
|
"github.com/onsonr/sonr/x/vault/types"
|
|
)
|
|
|
|
const (
|
|
// ConsensusVersion defines the current x/vault module consensus version.
|
|
ConsensusVersion = 1
|
|
|
|
// this line is used by starport scaffolding # simapp/module/const
|
|
)
|
|
|
|
var (
|
|
_ module.AppModuleBasic = AppModuleBasic{}
|
|
_ module.AppModuleGenesis = AppModule{}
|
|
_ module.AppModule = AppModule{}
|
|
|
|
_ autocli.HasAutoCLIConfig = AppModule{}
|
|
)
|
|
|
|
// AppModuleBasic defines the basic application module used by the wasm module.
|
|
type AppModuleBasic struct {
|
|
cdc codec.Codec
|
|
}
|
|
|
|
type AppModule struct {
|
|
AppModuleBasic
|
|
|
|
keeper keeper.Keeper
|
|
didk didkeeper.Keeper
|
|
}
|
|
|
|
// NewAppModule constructor
|
|
func NewAppModule(
|
|
cdc codec.Codec,
|
|
keeper keeper.Keeper,
|
|
didkeeper didkeeper.Keeper,
|
|
) *AppModule {
|
|
return &AppModule{
|
|
AppModuleBasic: AppModuleBasic{cdc: cdc},
|
|
keeper: keeper,
|
|
didk: didkeeper,
|
|
}
|
|
}
|
|
|
|
func (a AppModuleBasic) Name() string {
|
|
return types.ModuleName
|
|
}
|
|
|
|
func (a AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
|
|
return cdc.MustMarshalJSON(&types.GenesisState{
|
|
Params: types.DefaultParams(),
|
|
})
|
|
}
|
|
|
|
func (a AppModuleBasic) ValidateGenesis(marshaler codec.JSONCodec, _ client.TxEncodingConfig, message json.RawMessage) error {
|
|
var data types.GenesisState
|
|
err := marshaler.UnmarshalJSON(message, &data)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if err := data.Params.Validate(); err != nil {
|
|
return errorsmod.Wrap(err, "params")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (a AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {
|
|
}
|
|
|
|
func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
|
|
err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))
|
|
if err != nil {
|
|
// same behavior as in cosmos-sdk
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
|
types.RegisterLegacyAminoCodec(cdc)
|
|
}
|
|
|
|
func (a AppModuleBasic) RegisterInterfaces(r codectypes.InterfaceRegistry) {
|
|
types.RegisterInterfaces(r)
|
|
}
|
|
|
|
func (a AppModule) InitGenesis(ctx sdk.Context, marshaler codec.JSONCodec, message json.RawMessage) []abci.ValidatorUpdate {
|
|
var genesisState types.GenesisState
|
|
marshaler.MustUnmarshalJSON(message, &genesisState)
|
|
|
|
if err := a.keeper.Params.Set(ctx, genesisState.Params); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (a AppModule) ExportGenesis(ctx sdk.Context, marshaler codec.JSONCodec) json.RawMessage {
|
|
genState := a.keeper.ExportGenesis(ctx)
|
|
return marshaler.MustMarshalJSON(genState)
|
|
}
|
|
|
|
func (a AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {
|
|
}
|
|
|
|
func (a AppModule) QuerierRoute() string {
|
|
return types.QuerierRoute
|
|
}
|
|
|
|
func (a AppModule) RegisterServices(cfg module.Configurator) {
|
|
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(a.keeper))
|
|
types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQuerier(a.keeper))
|
|
}
|
|
|
|
// ConsensusVersion is a sequence number for state-breaking change of the
|
|
// module. It should be incremented on each consensus-breaking change
|
|
// introduced by the module. To avoid wrong/empty versions, the initial version
|
|
// should be set to 1.
|
|
func (a AppModule) ConsensusVersion() uint64 {
|
|
return ConsensusVersion
|
|
}
|