@blocks.Breadcrumbs()
- @basicInfoForm(formstate.Initial)
+ @basicInfoForm()
@blocks.Spacer()
Cancel
diff --git a/pkg/nebula/components/register/modal_templ.go b/pkg/nebula/components/register/modal_templ.go
index 75c368787..38f0c23c5 100644
--- a/pkg/nebula/components/register/modal_templ.go
+++ b/pkg/nebula/components/register/modal_templ.go
@@ -11,7 +11,6 @@ import templruntime "github.com/a-h/templ/runtime"
import (
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/pkg/nebula/components/blocks"
- "github.com/onsonr/sonr/pkg/nebula/models/formstate"
)
func Modal(c echo.Context) templ.Component {
@@ -43,7 +42,7 @@ func Modal(c echo.Context) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- templ_7745c5c3_Err = basicInfoForm(formstate.Initial).Render(ctx, templ_7745c5c3_Buffer)
+ templ_7745c5c3_Err = basicInfoForm().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
diff --git a/pkg/nebula/components/register/view.templ b/pkg/nebula/components/register/view.templ
index cb19f58b3..64bdcbe22 100644
--- a/pkg/nebula/components/register/view.templ
+++ b/pkg/nebula/components/register/view.templ
@@ -1,19 +1,11 @@
package register
-import (
- "github.com/onsonr/sonr/pkg/nebula/components/blocks"
- "github.com/onsonr/sonr/pkg/nebula/models/formstate"
-)
-
-templ basicInfoForm(state formstate.FormState) {
- switch (state) {
- default:
-
- }
+templ basicInfoForm() {
+
}
diff --git a/pkg/nebula/components/register/view_templ.go b/pkg/nebula/components/register/view_templ.go
index b4fa6d8c4..e29262c8e 100644
--- a/pkg/nebula/components/register/view_templ.go
+++ b/pkg/nebula/components/register/view_templ.go
@@ -8,13 +8,7 @@ package register
import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime"
-import (
- "github.com/labstack/echo/v4"
- "github.com/onsonr/sonr/pkg/nebula/components/blocks"
- "github.com/onsonr/sonr/pkg/nebula/models/formstate"
-)
-
-func View(c echo.Context) templ.Component {
+func basicInfoForm() 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
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
@@ -35,67 +29,7 @@ func View(c echo.Context) templ.Component {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
- templ_7745c5c3_Var2 := 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_Var3 := 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_Err = blocks.Spacer().Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = blocks.Breadcrumbs().Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = basicInfoForm(formstate.Initial).Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = blocks.Spacer().Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return templ_7745c5c3_Err
- })
- templ_7745c5c3_Err = blocks.Card("register-view", blocks.SizeMedium).Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- return templ_7745c5c3_Err
- })
- templ_7745c5c3_Err = blocks.Layout("Sonr.ID", true).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -103,36 +37,4 @@ func View(c echo.Context) templ.Component {
})
}
-func basicInfoForm(state formstate.FormState) 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
- if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
- return templ_7745c5c3_CtxErr
- }
- 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_Var4 := templ.GetChildren(ctx)
- if templ_7745c5c3_Var4 == nil {
- templ_7745c5c3_Var4 = templ.NopComponent
- }
- ctx = templ.ClearChildren(ctx)
- switch state {
- default:
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- }
- return templ_7745c5c3_Err
- })
-}
-
var _ = templruntime.GeneratedTemplate
diff --git a/pkg/nebula/components/ui/button_templ.go b/pkg/nebula/components/ui/button_templ.go
new file mode 100644
index 000000000..86b8787f9
--- /dev/null
+++ b/pkg/nebula/components/ui/button_templ.go
@@ -0,0 +1,121 @@
+// Code generated by templ - DO NOT EDIT.
+
+// templ: version: v0.2.778
+package ui
+
+//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 PrimaryButton(href string, text string) 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
+ if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
+ return templ_7745c5c3_CtxErr
+ }
+ 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("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var3 string
+ templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(text)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/components/ui/button.templ`, Line: 5, Col: 133}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+func SecondaryButton(href string, text string) 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
+ if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
+ return templ_7745c5c3_CtxErr
+ }
+ 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_Var4 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var4 == nil {
+ templ_7745c5c3_Var4 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var6 string
+ templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(text)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/components/ui/button.templ`, Line: 11, Col: 132}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ return templ_7745c5c3_Err
+ })
+}
+
+var _ = templruntime.GeneratedTemplate
diff --git a/pkg/nebula/models/RegistrationForm.pkl.go b/pkg/nebula/models/RegistrationForm.pkl.go
deleted file mode 100644
index 28fc721cc..000000000
--- a/pkg/nebula/models/RegistrationForm.pkl.go
+++ /dev/null
@@ -1,14 +0,0 @@
-// Code generated from Pkl module `models`. DO NOT EDIT.
-package models
-
-import "github.com/onsonr/sonr/pkg/nebula/models/formstate"
-
-type RegistrationForm struct {
- Title string `pkl:"title"`
-
- Description string `pkl:"description"`
-
- State formstate.FormState `pkl:"state"`
-
- Inputs []*Input `pkl:"inputs"`
-}
diff --git a/pkg/nebula/pages/pages.go b/pkg/nebula/pages/pages.go
index a5826b630..9f90b41a1 100644
--- a/pkg/nebula/pages/pages.go
+++ b/pkg/nebula/pages/pages.go
@@ -1,6 +1,9 @@
package pages
import (
+ "bytes"
+
+ "github.com/a-h/templ"
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/pkg/nebula/components/grant"
@@ -34,3 +37,24 @@ func Profile(c echo.Context) error {
func Register(c echo.Context) error {
return echoResponse(c, register.Modal(c))
}
+
+// ╭───────────────────────────────────────────────────────────╮
+// │ Helper Methods │
+// ╰───────────────────────────────────────────────────────────╯
+
+func echoResponse(c echo.Context, cmp templ.Component) error {
+ // Create a buffer to store the rendered HTML
+ buf := &bytes.Buffer{}
+ // Render the component to the buffer
+ err := cmp.Render(c.Request().Context(), buf)
+ if err != nil {
+ return err
+ }
+
+ // Set the content type
+ c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML)
+
+ // Write the buffered content to the response
+ _, err = c.Response().Write(buf.Bytes())
+ return err
+}
diff --git a/pkg/nebula/pages/utils.go b/pkg/nebula/pages/utils.go
deleted file mode 100644
index de34ff40c..000000000
--- a/pkg/nebula/pages/utils.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package pages
-
-import (
- "bytes"
-
- "github.com/a-h/templ"
- "github.com/labstack/echo/v4"
-)
-
-func echoResponse(c echo.Context, cmp templ.Component) error {
- // Create a buffer to store the rendered HTML
- buf := &bytes.Buffer{}
- // Render the component to the buffer
- err := cmp.Render(c.Request().Context(), buf)
- if err != nil {
- return err
- }
-
- // Set the content type
- c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML)
-
- // Write the buffered content to the response
- _, err = c.Response().Write(buf.Bytes())
- return err
-}
diff --git a/x/did/keeper/controller.go b/x/did/keeper/controller.go
new file mode 100644
index 000000000..20f1a3763
--- /dev/null
+++ b/x/did/keeper/controller.go
@@ -0,0 +1,27 @@
+package keeper
+
+import (
+ sdk "github.com/cosmos/cosmos-sdk/types"
+ "github.com/onsonr/crypto/mpc"
+ "github.com/onsonr/sonr/x/did/types"
+)
+
+func (k Keeper) NewController(ctx sdk.Context) (uint64, types.ControllerI, error) {
+ shares, err := mpc.GenerateKeyshares()
+ if err != nil {
+ return 0, nil, err
+ }
+ controller, err := types.NewController(shares)
+ if err != nil {
+ return 0, nil, err
+ }
+ entry, err := controller.GetTableEntry()
+ if err != nil {
+ return 0, nil, err
+ }
+ num, err := k.OrmDB.ControllerTable().InsertReturningNumber(ctx, entry)
+ if err != nil {
+ return 0, nil, err
+ }
+ return num, controller, nil
+}
diff --git a/x/did/keeper/keeper.go b/x/did/keeper/keeper.go
index d8ad08f63..6ea70aea1 100644
--- a/x/did/keeper/keeper.go
+++ b/x/did/keeper/keeper.go
@@ -1,22 +1,16 @@
package keeper
import (
- "crypto/sha256"
- "fmt"
-
"cosmossdk.io/collections"
storetypes "cosmossdk.io/core/store"
"cosmossdk.io/log"
"cosmossdk.io/orm/model/ormdb"
nftkeeper "cosmossdk.io/x/nft/keeper"
"github.com/cosmos/cosmos-sdk/codec"
- sdk "github.com/cosmos/cosmos-sdk/types"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
stakkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
- "github.com/onsonr/crypto/mpc"
- "gopkg.in/macaroon.v2"
apiv1 "github.com/onsonr/sonr/api/did/v1"
"github.com/onsonr/sonr/x/did/types"
@@ -91,43 +85,3 @@ func NewKeeper(
k.Schema = schema
return k
}
-
-func (k Keeper) NewController(ctx sdk.Context) (uint64, types.ControllerI, error) {
- shares, err := mpc.GenerateKeyshares()
- if err != nil {
- return 0, nil, err
- }
- controller, err := types.NewController(shares)
- if err != nil {
- return 0, nil, err
- }
- entry, err := controller.GetTableEntry()
- if err != nil {
- return 0, nil, err
- }
- num, err := k.OrmDB.ControllerTable().InsertReturningNumber(ctx, entry)
- if err != nil {
- return 0, nil, err
- }
- return num, controller, nil
-}
-
-// IssueMacaroon creates a macaroon with the specified parameters.
-func (k Keeper) IssueMacaroon(ctx sdk.Context, sharedMPCPubKey, location, id string, blockExpiry uint64) (*macaroon.Macaroon, error) {
- // Derive the root key by hashing the shared MPC public key
- rootKey := sha256.Sum256([]byte(sharedMPCPubKey))
- // Create the macaroon
- m, err := macaroon.New(rootKey[:], []byte(id), location, macaroon.LatestVersion)
- if err != nil {
- return nil, err
- }
-
- // Add the block expiry caveat
- caveat := fmt.Sprintf("block-expiry=%d", blockExpiry)
- err = m.AddFirstPartyCaveat([]byte(caveat))
- if err != nil {
- return nil, err
- }
-
- return m, nil
-}
diff --git a/x/macaroon/keeper/issuer.go b/x/macaroon/keeper/issuer.go
new file mode 100644
index 000000000..b2bb9dd75
--- /dev/null
+++ b/x/macaroon/keeper/issuer.go
@@ -0,0 +1,29 @@
+package keeper
+
+import (
+ "crypto/sha256"
+ "fmt"
+
+ sdk "github.com/cosmos/cosmos-sdk/types"
+ "gopkg.in/macaroon.v2"
+)
+
+// IssueMacaroon creates a macaroon with the specified parameters.
+func (k Keeper) IssueMacaroon(ctx sdk.Context, sharedMPCPubKey, location, id string, blockExpiry uint64) (*macaroon.Macaroon, error) {
+ // Derive the root key by hashing the shared MPC public key
+ rootKey := sha256.Sum256([]byte(sharedMPCPubKey))
+ // Create the macaroon
+ m, err := macaroon.New(rootKey[:], []byte(id), location, macaroon.LatestVersion)
+ if err != nil {
+ return nil, err
+ }
+
+ // Add the block expiry caveat
+ caveat := fmt.Sprintf("block-expiry=%d", blockExpiry)
+ err = m.AddFirstPartyCaveat([]byte(caveat))
+ if err != nil {
+ return nil, err
+ }
+
+ return m, nil
+}