mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +00:00
feature/ipfs vault allocation (#8)
* 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
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
templ VaultIndex() {
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>Sonr Vault</title>
|
||||
<script>
|
||||
navigator.serviceWorker.register({ swPath });
|
||||
|
||||
// Skip installed stage and jump to activating stage
|
||||
addEventListener("install", (event) => {
|
||||
event.waitUntil(skipWaiting());
|
||||
});
|
||||
|
||||
// Start controlling clients as soon as the SW is activated
|
||||
addEventListener("activate", (event) => {
|
||||
event.waitUntil(clients.claim());
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Sonr Vault</h1>
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
package main
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
func VaultIndex() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var1 == nil {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<!doctype html><html lang=\"en\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>Sonr Vault</title><script>\n navigator.serviceWorker.register({ swPath });\n\n // Skip installed stage and jump to activating stage\n addEventListener(\"install\", (event) => {\n event.waitUntil(skipWaiting());\n });\n\n // Start controlling clients as soon as the SW is activated\n addEventListener(\"activate\", (event) => {\n event.waitUntil(clients.claim());\n });\n </script></head><body><h1>Sonr Vault</h1></body></html>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
@@ -0,0 +1,43 @@
|
||||
//go:build js && wasm
|
||||
// +build js,wasm
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
wasmhttp "github.com/nlepage/go-wasm-http-server"
|
||||
|
||||
"github.com/onsonr/sonr/internal/db"
|
||||
)
|
||||
|
||||
var edb *db.DB
|
||||
|
||||
func main() {
|
||||
// Initialize the database
|
||||
initDB()
|
||||
|
||||
e := echo.New()
|
||||
e.POST("/api/insert/:account/:address", itemsHandler)
|
||||
wasmhttp.Serve(e)
|
||||
}
|
||||
|
||||
func initDB() {
|
||||
var err error
|
||||
edb, err = db.Open(db.New())
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func itemsHandler(e echo.Context) error {
|
||||
switch e.Request().Method {
|
||||
case "GET":
|
||||
case "POST":
|
||||
edb.AddAccount(e.Param("account"), e.Param("address"))
|
||||
default:
|
||||
e.Error(errors.New("Method not allowed"))
|
||||
}
|
||||
return e.JSON(200, "OK")
|
||||
}
|
||||
+1
-1
@@ -13,7 +13,7 @@ import (
|
||||
|
||||
func main() {
|
||||
rootCmd := NewRootCmd()
|
||||
rootCmd.AddCommand(tui.NewBuildProtoMsgCmd())
|
||||
rootCmd.AddCommand(tui.NewTUIDashboardCmd())
|
||||
// rootCmd.AddCommand(tui.NewExplorerCmd())
|
||||
|
||||
if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil {
|
||||
|
||||
+9
-13
@@ -3,11 +3,8 @@ package main
|
||||
import (
|
||||
"os"
|
||||
|
||||
dbm "github.com/cosmos/cosmos-db"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"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"
|
||||
@@ -19,11 +16,10 @@ import (
|
||||
"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"
|
||||
// NewRootCmd creates a new root command for chain app. It is called once in the
|
||||
// main function.
|
||||
)
|
||||
|
||||
func NewRootCmd() *cobra.Command {
|
||||
@@ -34,14 +30,14 @@ func NewRootCmd() *cobra.Command {
|
||||
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)
|
||||
tempApp := app.NewChainApp(
|
||||
preApp := app.NewChainApp(
|
||||
log.NewNopLogger(), dbm.NewMemDB(), nil, false, simtestutil.NewAppOptionsWithFlagHome(tempDir()),
|
||||
)
|
||||
encodingConfig := params.EncodingConfig{
|
||||
InterfaceRegistry: tempApp.InterfaceRegistry(),
|
||||
Codec: tempApp.AppCodec(),
|
||||
TxConfig: tempApp.TxConfig(),
|
||||
Amino: tempApp.LegacyAmino(),
|
||||
InterfaceRegistry: preApp.InterfaceRegistry(),
|
||||
Codec: preApp.AppCodec(),
|
||||
TxConfig: preApp.TxConfig(),
|
||||
Amino: preApp.LegacyAmino(),
|
||||
}
|
||||
|
||||
initClientCtx := client.Context{}.
|
||||
@@ -109,10 +105,10 @@ func NewRootCmd() *cobra.Command {
|
||||
},
|
||||
}
|
||||
|
||||
initRootCmd(rootCmd, encodingConfig.TxConfig, encodingConfig.InterfaceRegistry, tempApp.BasicModuleManager)
|
||||
initRootCmd(rootCmd, encodingConfig.TxConfig, encodingConfig.InterfaceRegistry, preApp.BasicModuleManager)
|
||||
|
||||
// add keyring to autocli opts
|
||||
autoCliOpts := tempApp.AutoCliOpts()
|
||||
autoCliOpts := preApp.AutoCliOpts()
|
||||
initClientCtx, _ = config.ReadFromClientConfig(initClientCtx)
|
||||
autoCliOpts.Keyring, _ = keyring.NewAutoCLIKeyring(initClientCtx.Keyring)
|
||||
autoCliOpts.ClientCtx = initClientCtx
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
//go:build js && wasm
|
||||
// +build js,wasm
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
wasmhttp "github.com/nlepage/go-wasm-http-server"
|
||||
)
|
||||
|
||||
var db *sql.DB
|
||||
|
||||
func main() {
|
||||
// Initialize the database
|
||||
initDB()
|
||||
|
||||
// Define your handlers
|
||||
http.HandleFunc("/", homeHandler)
|
||||
http.HandleFunc("/api/items", itemsHandler)
|
||||
|
||||
// Use wasmhttp.Serve to start the server
|
||||
wasmhttp.Serve(nil)
|
||||
}
|
||||
|
||||
func initDB() {
|
||||
_, err := db.Exec(`
|
||||
CREATE TABLE IF NOT EXISTS items (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL
|
||||
)
|
||||
`)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func homeHandler(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, "Welcome to the WASM SQLite Server!")
|
||||
}
|
||||
|
||||
func itemsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
getItems(w, r)
|
||||
case "POST":
|
||||
addItem(w, r)
|
||||
default:
|
||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||
}
|
||||
}
|
||||
|
||||
func getItems(w http.ResponseWriter, _ *http.Request) {
|
||||
rows, err := db.Query("SELECT id, name FROM items")
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var items []map[string]interface{}
|
||||
for rows.Next() {
|
||||
var id int
|
||||
var name string
|
||||
if err := rows.Scan(&id, &name); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
items = append(items, map[string]interface{}{"id": id, "name": name})
|
||||
}
|
||||
|
||||
json.NewEncoder(w).Encode(items)
|
||||
}
|
||||
|
||||
func addItem(w http.ResponseWriter, r *http.Request) {
|
||||
var item struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&item); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := db.Exec("INSERT INTO items (name) VALUES (?)", item.Name)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
id, _ := result.LastInsertId()
|
||||
json.NewEncoder(w).Encode(map[string]interface{}{"id": id, "name": item.Name})
|
||||
}
|
||||
Reference in New Issue
Block a user