mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-10 13:07:09 +00:00
* refactor: move constants to genesis.proto * feat: add ipfs_active flag to genesis state * feat: add IPFS connection initialization to keeper * feat: add testnet process-compose * refactor: rename sonr-testnet docker image to sonr-runner * refactor: update docker-vm-release workflow to use 'latest' tag * feat: add permission to workflows * feat: add new service chain execution * feat: add abstract vault class to pkl * feat: use jetpackio/devbox image for runner * feat: introduce dwn for local service worker * refactor: remove unnecessary dockerfile layers * refactor(deploy): Update Dockerfile to copy go.mod and go.sum from the parent directory * build: move Dockerfile to root directory * build: Add Dockerfile for deployment * feat: Update Dockerfile to work with Go project in parent directory * build: Update docker-compose.yaml to use relative paths * feat: Update docker-compose to work with new image and parent git directory * refactor: remove unnecessary test script * <no value> * feat: add test_node script for running node tests * feat: add IPFS cluster to testnet * feat: add docker image for sonr-runner * fix: typo in export path * feat(did): Add Localhost Registration Enabled Genesis Option * feat: add support for Sqlite DB in vault * feat: improve vault model JSON serialization * feat: support querying HTMX endpoint for DID * feat: Add primary key, unique, default, not null, auto increment, and foreign key field types * feat: Add PublicKey model in pkl/vault.pkl * feat: add frontend server * refactor: move dwn.wasm to vfs directory * feat(frontend): remove frontend server implementation * feat: Add a frontend server and web auth protocol * feat: implement new key types for MPC and ZK proofs * fix: Update enum types and DefaultKeyInfos * fix: correct typo in KeyAlgorithm enum * feat(did): add attestation format validation * feat: Add x/did/builder/extractor.go * feat: Update JWK parsing in x/did/builder/extractor.go * feat: Use github.com/onsonr/sonr/x/did/types package * feat: Extract and format public keys from WebAuthn credentials * feat: Introduce a new `mapToJWK` function to convert a map to a `types.JWK` struct * feat: add support for extracting JWK public keys * feat: remove VerificationMethod struct * refactor: extract public key extraction logic * feat: add helper functions to map COSECurveID to JWK curve names * feat: pin initial vault
122 lines
4.1 KiB
Go
122 lines
4.1 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
|
|
"cosmossdk.io/log"
|
|
dbm "github.com/cosmos/cosmos-db"
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/client/config"
|
|
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
|
"github.com/cosmos/cosmos-sdk/server"
|
|
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
|
"github.com/cosmos/cosmos-sdk/version"
|
|
"github.com/cosmos/cosmos-sdk/x/auth/tx"
|
|
txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
|
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/onsonr/sonr/app"
|
|
"github.com/onsonr/sonr/app/params"
|
|
)
|
|
|
|
func NewRootCmd() *cobra.Command {
|
|
cfg := sdk.GetConfig()
|
|
cfg.SetBech32PrefixForAccount(app.Bech32PrefixAccAddr, app.Bech32PrefixAccPub)
|
|
cfg.SetBech32PrefixForValidator(app.Bech32PrefixValAddr, app.Bech32PrefixValPub)
|
|
cfg.SetBech32PrefixForConsensusNode(app.Bech32PrefixConsAddr, app.Bech32PrefixConsPub)
|
|
cfg.Seal()
|
|
// we "pre"-instantiate the application for getting the injected/configured encoding configuration
|
|
// note, this is not necessary when using app wiring, as depinject can be directly used (see root_v2.go)
|
|
preApp := app.NewChainApp(
|
|
log.NewNopLogger(), dbm.NewMemDB(), nil, false, simtestutil.NewAppOptionsWithFlagHome(tempDir()),
|
|
)
|
|
encodingConfig := params.EncodingConfig{
|
|
InterfaceRegistry: preApp.InterfaceRegistry(),
|
|
Codec: preApp.AppCodec(),
|
|
TxConfig: preApp.TxConfig(),
|
|
Amino: preApp.LegacyAmino(),
|
|
}
|
|
|
|
initClientCtx := client.Context{}.
|
|
WithCodec(encodingConfig.Codec).
|
|
WithInterfaceRegistry(encodingConfig.InterfaceRegistry).
|
|
WithTxConfig(encodingConfig.TxConfig).
|
|
WithLegacyAmino(encodingConfig.Amino).
|
|
WithInput(os.Stdin).
|
|
WithAccountRetriever(authtypes.AccountRetriever{}).
|
|
WithHomeDir(app.DefaultNodeHome).
|
|
WithViper("")
|
|
|
|
rootCmd := &cobra.Command{
|
|
Use: version.AppName,
|
|
Short: version.AppName + " Daemon (server)",
|
|
SilenceErrors: true,
|
|
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
|
|
// set the default command outputs
|
|
cmd.SetOut(cmd.OutOrStdout())
|
|
cmd.SetErr(cmd.ErrOrStderr())
|
|
|
|
initClientCtx = initClientCtx.WithCmdContext(cmd.Context())
|
|
initClientCtx, err := client.ReadPersistentCommandFlags(initClientCtx, cmd.Flags())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
initClientCtx, err = config.ReadFromClientConfig(initClientCtx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// This needs to go after ReadFromClientConfig, as that function
|
|
// sets the RPC client needed for SIGN_MODE_TEXTUAL. This sign mode
|
|
// is only available if the client is online.
|
|
if !initClientCtx.Offline {
|
|
enabledSignModes := append(tx.DefaultSignModes, signing.SignMode_SIGN_MODE_TEXTUAL)
|
|
txConfigOpts := tx.ConfigOptions{
|
|
EnabledSignModes: enabledSignModes,
|
|
TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(initClientCtx),
|
|
}
|
|
txConfig, err := tx.NewTxConfigWithOptions(
|
|
initClientCtx.Codec,
|
|
txConfigOpts,
|
|
)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
initClientCtx = initClientCtx.WithTxConfig(txConfig)
|
|
}
|
|
|
|
if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Set the context chain ID and validator address
|
|
app.SetLocalChainID(initClientCtx.ChainID)
|
|
app.SetLocalValidatorAddress(initClientCtx.FromAddress.String())
|
|
|
|
customAppTemplate, customAppConfig := initAppConfig()
|
|
customCMTConfig := initCometBFTConfig()
|
|
|
|
return server.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, customCMTConfig)
|
|
},
|
|
}
|
|
|
|
initRootCmd(rootCmd, encodingConfig.TxConfig, encodingConfig.InterfaceRegistry, preApp.BasicModuleManager)
|
|
|
|
// add keyring to autocli opts
|
|
autoCliOpts := preApp.AutoCliOpts()
|
|
initClientCtx, _ = config.ReadFromClientConfig(initClientCtx)
|
|
autoCliOpts.Keyring, _ = keyring.NewAutoCLIKeyring(initClientCtx.Keyring)
|
|
autoCliOpts.ClientCtx = initClientCtx
|
|
|
|
if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
return rootCmd
|
|
}
|