diff --git a/Makefile b/Makefile index 0acac00..ef0d254 100644 --- a/Makefile +++ b/Makefile @@ -1,60 +1,55 @@ export ROOT_DIR := $(shell git rev-parse --show-toplevel) + +export ENCLAVE_ROOT := $(ROOT_DIR)/cmd/enclave export RADAR_ROOT := $(ROOT_DIR)/cmd/radar +export SIGNER_ROOT := $(ROOT_DIR)/cmd/signer export WORKER_ROOT := $(ROOT_DIR)/cmd/worker +export VERIFIER_ROOT := $(ROOT_DIR)/cmd/verifier + export SQLC_ROOT := $(ROOT_DIR)/internal/db export MIGRATE_ROOT := $(ROOT_DIR)/internal/migrations export RADAR_OUT := $(RADAR_ROOT)/build/app.wasm export WORKER_OUT := $(WORKER_ROOT)/build/app.wasm -.PHONY: install clean help - -install: - @go mod download - @go install github.com/syumai/workers/cmd/workers-assets-gen@latest - -clean: - @rm -rf ./build - @rm -rf ./bin - @rm -rf ./dist - @rm -rf ./cmd/worker/node_modules - @rm -rf ./cmd/radar/node_modules - -help: - @echo "Usage: make " - @echo "" - @echo "Commands:" - @echo " help Show this help message" - @echo " tidy Tidy up the project" - @echo " templ Generate templates" - @echo " sqlc Generate SQL schema" - @echo " worker Build and deploy worker" - @echo " radar Build and deploy radar" - -.PHONY: templ sqlc - -templ: - @templ generate - -sqlc: - @devbox run gen:sqlc - migrate: @cd $(MIGRATE_ROOT) && task -worker: - @devbox run serve:worker +.PHONY: worker worker-build worker-deploy worker-start +worker: worker-deploy +worker-build: + @make -C $(WORKER_ROOT) build +worker-deploy: + @make -C $(WORKER_ROOT) deploy +worker-start: + @make -C $(WORKER_ROOT) start -radar: - @devbox run serve:radar +.PHONY: radar radar-build radar-deploy radar-start +radar: radar-deploy +radar-build: + @make -C $(RADAR_ROOT) build +radar-deploy: + @make -C $(RADAR_ROOT) deploy +radar-start: + @make -C $(RADAR_ROOT) start + +.PHONY: enclave enclave-build enclave-publish +enclave: enclave-publish +enclave-build: + @make -C $(ENCLAVE_ROOT) build +enclave-publish: + @make -C $(ENCLAVE_ROOT) publish -deploy: - @devbox run deploy +.PHONY: signer signer-build signer-publish +signer: signer-publish +signer-build: + @make -C $(SIGNER_ROOT) build +signer-publish: + @make -C $(SIGNER_ROOT) publish -release: - @devbox run release -templ-watch: - @devbox run watch:templ - -migrate: - @devbox run db:migrate +.PHONY: verifier verifier-build verifier-publish +verifier: verifier-publish +verifier-build: + @make -C $(VERIFIER_ROOT) build +verifier-publish: + @make -C $(VERIFIER_ROOT) publish diff --git a/cmd/enclave/.gitignore b/cmd/enclave/.gitignore new file mode 100644 index 0000000..19e1bce --- /dev/null +++ b/cmd/enclave/.gitignore @@ -0,0 +1 @@ +*.wasm diff --git a/cmd/enclave/Makefile b/cmd/enclave/Makefile index d37e2a0..e7188e1 100644 --- a/cmd/enclave/Makefile +++ b/cmd/enclave/Makefile @@ -2,7 +2,7 @@ all: build publish -build: tidy +build: @gum spin --show-error --title "[ENCLAVE] Running go build..." -- sh -c "GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared -o enclave.wasm" @gum log --level info --time kitchen "[ENCLAVE] Completed go build successfully." diff --git a/cmd/enclave/README.md b/cmd/enclave/README.md new file mode 100644 index 0000000..36676ac --- /dev/null +++ b/cmd/enclave/README.md @@ -0,0 +1,37 @@ +# `enclave` + +## Features + +The Motr Enclave is used for DKG-MPC Generation of Decentralized Web Nodes. + +## Usage + +### Call Plugin from JavaScript + +```bash +git clone https://github.com/sonr-io/motr.git +cd motr +go mod tidy +``` + +### Call Plugin from Extism CLI + +```bash +git clone https://github.com/sonr-io/motr.git +cd motr +go mod tidy +``` + +## Configuration + +## API Reference + +### `generate()` + +The Generate function initializes an MPC Vault + +## License + +[MIT](LICENSE) + +Copyright (c) 2025, Sonr Inc. diff --git a/cmd/signer/Makefile b/cmd/signer/Makefile index 49afef7..0185808 100644 --- a/cmd/signer/Makefile +++ b/cmd/signer/Makefile @@ -2,11 +2,7 @@ all: build publish -tidy: - @gum spin --show-error --title "[SIGNER] Running go mod tidy..." -- sh -c "go mod tidy" - @gum log --level info --time kitchen "[SIGNER] Completed go mod tidy successfully." - -build: tidy +build: @gum spin --show-error --title "[SIGNER] Running tinygo build..." -- sh -c "tinygo build -o signer.wasm -target wasip1 -buildmode=c-shared main.go" @gum log --level info --time kitchen "[SIGNER] Completed tinygo build successfully." diff --git a/cmd/verifier/.gitignore b/cmd/verifier/.gitignore new file mode 100644 index 0000000..19e1bce --- /dev/null +++ b/cmd/verifier/.gitignore @@ -0,0 +1 @@ +*.wasm diff --git a/cmd/verifier/Makefile b/cmd/verifier/Makefile index 41cd9f3..3dfdfe8 100644 --- a/cmd/verifier/Makefile +++ b/cmd/verifier/Makefile @@ -2,11 +2,7 @@ all: build publish -tidy: - @gum spin --show-error --title "[VERIFIER] Running go mod tidy..." -- sh -c "go mod tidy" - @gum log --level info --time kitchen "[VERIFIER] Completed go mod tidy successfully." - -build: tidy +build: @gum spin --show-error --title "[VERIFIER] Running tinygo build..." -- sh -c "tinygo build -o verifier.wasm -target wasip1 -buildmode=c-shared main.go" @gum log --level info --time kitchen "[VERIFIER] Completed tinygo build successfully." diff --git a/cmd/worker/Makefile b/cmd/worker/Makefile index 2f3ab37..6bbe17b 100644 --- a/cmd/worker/Makefile +++ b/cmd/worker/Makefile @@ -1,8 +1,6 @@ -templ: - go run github.com/a-h/templ/cmd/templ generate - -assets: - go run github.com/syumai/workers/cmd/workers-assets-gen -mode=go +generate: + @go run github.com/a-h/templ/cmd/templ generate + @go run github.com/syumai/workers/cmd/workers-assets-gen -mode=go build: generate GOOS=js GOARCH=wasm go build -ldflags="-s -w" -o ./build/app.wasm . diff --git a/devbox.json b/devbox.json index 6128174..8e8dc98 100644 --- a/devbox.json +++ b/devbox.json @@ -5,8 +5,8 @@ "sqlc@latest", "nodejs@latest", "goreleaser@latest", - "go-task@latest", - "doppler@latest" + "rclone@latest", + "go-task@latest" ], "env": { "SONR_API_URL": "https://api.sonr.ws", diff --git a/pkg/render/ui/layout.templ b/pkg/render/ui/layout.templ new file mode 100644 index 0000000..b069a88 --- /dev/null +++ b/pkg/render/ui/layout.templ @@ -0,0 +1,113 @@ +package ui + +// Body is a component that renders the body tag +templ Body() { + + { children... } + +} + +// Head is a component that renders the head of the document +templ Head() { + + + + @ApexCharts() + @Helia() + @Dexie() + @Htmx() + @Tailwind() + @Shoelace() + @DefaultStyles() + { children... } + +} + +// HTML is a component that renders the html tag +templ HTML() { + + + { children... } + +} + +// Columns is a component that renders a responsive flex container that stacks on mobile +templ Columns() { +
+ { children... } +
+} + +// Container is a component that renders a full screen container +templ Container() { +
+
+
+
+ { children... } +
+
+
+
+} + +// Tailwind css dependencies +templ Tailwind() { + @tailwindHandle.Once() { + + } +} + +// Nav is a component that renders the navigation bar +templ Nav() { + +} + +// NavCTA is a component that renders a call to action button +templ NavCTA(href string, text string) { + { text } +} + +// NavItem is a component that renders a navigation item +templ NavItem(href string, text string) { + { text } +} + +// NavLogo is a component that renders a logo +templ NavLogo(title string) { + + { children... } + { title } + +} + +// NavLeft is a component that renders the left side of the navigation bar +templ NavLeft() { +
+ { children... } +
+} + +templ NavRight() { +
+ { children... } +
+} + +// Rows is a component that renders a responsive flex container that wraps on mobile +templ Rows() { +
+ { children... } +
+} + +templ Separator(text string) { +
+
+
+ { text } +
+
+} diff --git a/pkg/render/ui/providers.templ b/pkg/render/ui/providers.templ new file mode 100644 index 0000000..76dd400 --- /dev/null +++ b/pkg/render/ui/providers.templ @@ -0,0 +1,139 @@ +package ui + +import "fmt" + +var ( + apexChartsHandle = templ.NewOnceHandle() + d3Handle = templ.NewOnceHandle() + dexieHandle = templ.NewOnceHandle() + heliaHandle = templ.NewOnceHandle() + htmxHandle = templ.NewOnceHandle() + tailwindHandle = templ.NewOnceHandle() +) + +// ApexCharts is a component that renders the ApexCharts.js library +templ ApexCharts() { + @apexChartsHandle.Once() { + + } +} + +// d3 is a component that renders the D3.js library +templ D3() { + @d3Handle.Once() { + + } +} + +// dexie is a component that renders the Dexie.js library +templ Dexie() { + @dexieHandle.Once() { + + + } +} + +// In package deps +templ Helia() { + @heliaHandle.Once() { + + + + + + } +} + +// Htmx is a component that renders the Htmx.js library +templ Htmx() { + @htmxHandle.Once() { + + + + + + + } +} + +// jsDelivrURL returns the URL of a package on jsDelivr +func jsDelivrURL(pkg string, version string, path string) string { + return fmt.Sprintf("https://cdn.jsdelivr.net/npm/%s/%s/%s", pkg, version, path) +} diff --git a/pkg/render/ui/styles.templ b/pkg/render/ui/styles.templ new file mode 100644 index 0000000..4a27eb0 --- /dev/null +++ b/pkg/render/ui/styles.templ @@ -0,0 +1,54 @@ +package ui + +templ DefaultStyles() { + +} + +// Shoelace dependencies +templ Shoelace() { + + + +}