mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-10 13:07:09 +00:00
feature/dwn database state (#18)
* refactor: move database, navigator scripts to state package * feat: add Schema config for dwn * test: add unit tests for InitializeDatabase * feat: use templated index.html for the DWN frontend * feat: introduce templ generation for templ * chore(deps): update devbox.json to use latest packages * chore: update devbox to use bun * feat: introduce dwn config generation * feat: add motr.mjs for vault management * refactor: move front end from to (alert) * feat: implement devbox integration and devbox-based process management * feat: embed motr.mjs script for offline demo * refactor: embed motr.mjs data in embed.go * chore: update workflows to use actions/checkout@v4 * refactor: move process-compose.yaml to deploy directory * refactor: remove unnecessary JSON conversion
This commit is contained in:
parent
a115b79db7
commit
a4dbb41202
7
.envrc
Normal file
7
.envrc
Normal file
@ -0,0 +1,7 @@
|
||||
# Automatically sets up your devbox environment whenever you cd into this
|
||||
# directory via our direnv integration:
|
||||
|
||||
eval "$(devbox generate direnv --print-envrc)"
|
||||
|
||||
# check out https://www.jetpack.io/devbox/docs/ide_configuration/direnv/
|
||||
# for more details
|
29
.github/workflows/pr-merged.yml
vendored
Normal file
29
.github/workflows/pr-merged.yml
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
name: PR Merged - Bump Version and Tag
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- closed
|
||||
branches:
|
||||
- develop
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
bump-version-and-tag:
|
||||
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'feature/')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Bump version and update changelog
|
||||
uses: commitizen-tools/commitizen-action@master
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Push changes and tag
|
||||
run: git push && git push --tags
|
82
.github/workflows/sync-branches.yml
vendored
82
.github/workflows/sync-branches.yml
vendored
@ -1,61 +1,45 @@
|
||||
name: Scheduled Production Release
|
||||
name: Sync Branches
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 * * MON" # Runs every Monday at 00:00 UTC
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags:
|
||||
- "*"
|
||||
|
||||
permissions:
|
||||
contents: write # Grants the workflow permission to push changes
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
production-release:
|
||||
sync-branches:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # Fetch all history for accurate merging
|
||||
ref: develop # Start from the develop branch
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Git user
|
||||
- name: Check if tag is on develop or master
|
||||
id: check-branch
|
||||
run: |
|
||||
git config user.name "GitHub Action"
|
||||
git config user.email "action@github.com"
|
||||
if git branch -r --contains ${{ github.ref }} | grep -q 'origin/develop\|origin/master'; then
|
||||
echo "SYNC_NEEDED=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "SYNC_NEEDED=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Install Devbox
|
||||
uses: jetpack-io/devbox-install-action@v0.7.0
|
||||
- name: Sync develop to master
|
||||
if: steps.check-branch.outputs.SYNC_NEEDED == 'true'
|
||||
uses: devmasx/merge-branch@master
|
||||
with:
|
||||
type: now
|
||||
from_branch: develop
|
||||
target_branch: master
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: devbox install
|
||||
|
||||
- name: Bump Version with Commitizen
|
||||
run: |
|
||||
# Use Commitizen to bump version
|
||||
devbox shell -- cz bump --yes --changelog
|
||||
|
||||
# Get the new version
|
||||
NEW_VERSION=$(devbox shell -- cz version --project)
|
||||
echo "New version: $NEW_VERSION"
|
||||
|
||||
# Tag the new version
|
||||
git tag -a "v$NEW_VERSION" -m "Release $NEW_VERSION"
|
||||
|
||||
- name: Merge develop into master
|
||||
run: |
|
||||
# Switch to master branch
|
||||
git checkout master
|
||||
|
||||
# Merge develop into master with a merge commit
|
||||
git merge develop --no-ff -m "Merge develop into master for release v$NEW_VERSION"
|
||||
|
||||
- name: Push Changes and Tags
|
||||
run: |
|
||||
git push origin master
|
||||
git push origin --tags
|
||||
|
||||
- name: Merge back into develop
|
||||
run: |
|
||||
git checkout develop
|
||||
git merge master --no-ff -m "Merge master back into develop after release v$NEW_VERSION"
|
||||
git push origin develop
|
||||
- name: Sync master back to develop
|
||||
if: steps.check-branch.outputs.SYNC_NEEDED == 'true'
|
||||
uses: devmasx/merge-branch@master
|
||||
with:
|
||||
type: now
|
||||
from_branch: master
|
||||
target_branch: develop
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
@ -9,7 +9,7 @@ RUN mkdir -p /code && chown ${DEVBOX_USER}:${DEVBOX_USER} /code
|
||||
USER ${DEVBOX_USER}:${DEVBOX_USER}
|
||||
|
||||
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.json devbox.json
|
||||
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} process-compose.yaml process-compose.yaml
|
||||
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} deploy/process-compose.yaml process-compose.yaml
|
||||
|
||||
RUN devbox run -- echo "Installed Packages."
|
||||
|
||||
@ -26,7 +26,7 @@ RUN mkdir -p /code && chown ${DEVBOX_USER}:${DEVBOX_USER} /code
|
||||
USER ${DEVBOX_USER}:${DEVBOX_USER}
|
||||
|
||||
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.json devbox.json
|
||||
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} process-compose.yaml process-compose.yaml
|
||||
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} deploy/process-compose.yaml process-compose.yaml
|
||||
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} . .
|
||||
|
||||
RUN devbox run -- echo "Installed Packages."
|
||||
|
31
Makefile
31
Makefile
@ -95,6 +95,13 @@ endif
|
||||
install: go.sum
|
||||
go install -mod=readonly $(BUILD_FLAGS) ./cmd/sonrd
|
||||
|
||||
deps:
|
||||
@echo "(go) Installing go dependencies"
|
||||
@which air > /dev/null || go install github.com/air-verse/air@latest
|
||||
@which templ > /dev/null || go install github.com/a-h/templ/cmd/templ@latest
|
||||
@which xcaddy > /dev/null || go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
|
||||
@mkdir -p ./bin
|
||||
@[ ! -f ./bin/caddy ] && xcaddy build --with github.com/caddy-dns/cloudflare && mv ./caddy ./bin/caddy || echo "Caddy already exists"
|
||||
########################################
|
||||
### Tools & dependencies
|
||||
|
||||
@ -293,8 +300,6 @@ sh-testnet: mod-tidy
|
||||
|
||||
.PHONY: setup-testnet set-testnet-configs testnet testnet-basic sh-testnet
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
### templ & vault ###
|
||||
###############################################################################
|
||||
@ -303,27 +308,31 @@ sh-testnet: mod-tidy
|
||||
|
||||
dwn:
|
||||
@echo "(dwn) Building dwn.wasm -> IPFS Vault"
|
||||
GOOS=js GOARCH=wasm go build -o ./internal/vfs/app.wasm ./internal/dwn/main.go
|
||||
GOOS=js GOARCH=wasm go build -o ./pkg/vault/app.wasm ./internal/dwn/main.go
|
||||
|
||||
motr:
|
||||
@echo "(web) Building app.wasm -> Deploy to Cloudflare Workers"
|
||||
GOOS=js GOARCH=wasm go build -o ./web/build/app.wasm ./web/src/main.go
|
||||
|
||||
xcaddy:
|
||||
@echo "(proxy) Building Cloudflare/Caddy proxy"
|
||||
go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
|
||||
mkdir -p ./bin
|
||||
xcaddy build --with github.com/caddy-dns/cloudflare
|
||||
mv ./caddy ./bin/caddy
|
||||
./bin/caddy adapt > ./config/caddy/caddy.json
|
||||
templ:
|
||||
@echo "(templ) Generating templ files"
|
||||
templ generate
|
||||
|
||||
pkl:
|
||||
@echo "(pkl) Building PKL"
|
||||
go run github.com/apple/pkl-go/cmd/pkl-gen-go ./config/pkl/dwn.pkl
|
||||
go run github.com/apple/pkl-go/cmd/pkl-gen-go ./config/pkl/orm.pkl
|
||||
go run github.com/apple/pkl-go/cmd/pkl-gen-go ./config/pkl/web.pkl
|
||||
go run github.com/apple/pkl-go/cmd/pkl-gen-go ./config/pkl/txns.pkl
|
||||
|
||||
ipfs-cluster-start:
|
||||
@echo "(ipfs) Starting ipfs-cluster"
|
||||
ipfs-cluster-service init --consensus crdt
|
||||
ipfs-cluster-service daemon
|
||||
|
||||
caddy-start:
|
||||
xcaddy:
|
||||
@echo "(proxy) Starting caddy"
|
||||
# ./bin/caddy adapt ./config/caddy/Caddyfile > ./config/caddy/caddy.json
|
||||
./bin/caddy run --config ./config/caddy/caddy.json
|
||||
|
||||
###############################################################################
|
||||
|
@ -8,12 +8,12 @@ import (
|
||||
_ "github.com/joho/godotenv/autoload"
|
||||
|
||||
"github.com/onsonr/sonr/app"
|
||||
"github.com/onsonr/sonr/internal/tui"
|
||||
"github.com/onsonr/sonr/internal/cli"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rootCmd := NewRootCmd()
|
||||
tui.AddTUICmds(rootCmd)
|
||||
cli.AddTUICmds(rootCmd)
|
||||
|
||||
if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil {
|
||||
log.NewLogger(rootCmd.OutOrStderr()).Error("failure when running app", "err", err)
|
||||
|
@ -1 +0,0 @@
|
||||
{"apps":{"http":{"servers":{"srv0":{"listen":[":443"],"routes":[{"match":[{"host":["vault.sonr.id"]}],"handle":[{"handler":"subroute","routes":[{"handle":[{"handler":"headers","response":{"replace":{"Content-Type":[{"replace":"application/wasm","search_regexp":".wasm"}]},"set":{"Service-Worker-Allowed":["/"]}}},{"encodings":{"gzip":{},"zstd":{}},"handler":"encode","prefer":["zstd","gzip"]}]},{"handle":[{"handler":"subroute","routes":[{"handle":[{"handler":"rewrite","uri_substring":[{"find":"/{http.regexp.vaultPath.0}","replace":"/ipns/{http.regexp.vaultPath.1}{http.regexp.vaultPath.2}"}]},{"handler":"reverse_proxy","upstreams":[{"dial":"localhost:8080"}]}]}]}],"match":[{"path_regexp":{"name":"vaultPath","pattern":"^/([a-z0-9]{42})(/.*|)$"}}]},{"handle":[{"handler":"file_server","hide":["./Caddyfile"]}]}]}],"terminal":true}]}}},"tls":{"automation":{"policies":[{"subjects":["vault.sonr.id"],"issuers":[{"challenges":{"dns":{"provider":{"api_token":"{env.CLOUDFLARE_API_TOKEN}","name":"cloudflare"},"resolvers":["1.1.1.1"]}},"email":"team@sonr.id","module":"acme"}]}]}}}}
|
@ -7,4 +7,6 @@ type Config struct {
|
||||
Sonr *Sonr `pkl:"sonr" json:"sonr,omitempty"`
|
||||
|
||||
Motr *Motr `pkl:"motr" json:"motr,omitempty"`
|
||||
|
||||
Schema *Schema `pkl:"schema" json:"schema,omitempty"`
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
)
|
||||
|
||||
type Dwn struct {
|
||||
Config any `pkl:"config"`
|
||||
}
|
||||
|
||||
// LoadFromPath loads the pkl module at the given path and evaluates it into a Dwn
|
||||
|
24
config/dwn/Schema.pkl.go
Normal file
24
config/dwn/Schema.pkl.go
Normal file
@ -0,0 +1,24 @@
|
||||
// Code generated from Pkl module `dwn`. DO NOT EDIT.
|
||||
package dwn
|
||||
|
||||
type Schema struct {
|
||||
Version int `pkl:"version"`
|
||||
|
||||
Account string `pkl:"account" json:"account,omitempty"`
|
||||
|
||||
Asset string `pkl:"asset" json:"asset,omitempty"`
|
||||
|
||||
Chain string `pkl:"chain" json:"chain,omitempty"`
|
||||
|
||||
Credential string `pkl:"credential" json:"credential,omitempty"`
|
||||
|
||||
Jwk string `pkl:"jwk" json:"jwk,omitempty"`
|
||||
|
||||
Grant string `pkl:"grant" json:"grant,omitempty"`
|
||||
|
||||
Keyshare string `pkl:"keyshare" json:"keyshare,omitempty"`
|
||||
|
||||
PublicKey string `pkl:"publicKey" json:"publicKey,omitempty"`
|
||||
|
||||
Profile string `pkl:"profile" json:"profile,omitempty"`
|
||||
}
|
@ -9,4 +9,5 @@ func init() {
|
||||
pkl.RegisterMapping("dwn#IPFS", IPFS{})
|
||||
pkl.RegisterMapping("dwn#Sonr", Sonr{})
|
||||
pkl.RegisterMapping("dwn#Motr", Motr{})
|
||||
pkl.RegisterMapping("dwn#Schema", Schema{})
|
||||
}
|
||||
|
@ -21,6 +21,9 @@ class Config {
|
||||
|
||||
@JsonField
|
||||
motr: Motr
|
||||
|
||||
@JsonField
|
||||
schema: Schema
|
||||
}
|
||||
|
||||
class IPFS {
|
||||
@ -42,6 +45,37 @@ class Motr {
|
||||
origin: String
|
||||
}
|
||||
|
||||
class Schema {
|
||||
version: Int
|
||||
|
||||
@JsonField
|
||||
account: String
|
||||
|
||||
@JsonField
|
||||
asset: String
|
||||
|
||||
@JsonField
|
||||
chain: String
|
||||
|
||||
@JsonField
|
||||
credential: String
|
||||
|
||||
@JsonField
|
||||
jwk: String
|
||||
|
||||
@JsonField
|
||||
grant: String
|
||||
|
||||
@JsonField
|
||||
keyshare: String
|
||||
|
||||
@JsonField
|
||||
publicKey: String
|
||||
|
||||
@JsonField
|
||||
profile: String
|
||||
}
|
||||
|
||||
class Sonr {
|
||||
@JsonField
|
||||
apiUrl: String
|
||||
@ -60,16 +94,4 @@ class Sonr {
|
||||
}
|
||||
|
||||
|
||||
config = new Config {
|
||||
ipfs = new IPFS {
|
||||
apiUrl = "https://api.sonr-ipfs.land"
|
||||
gatewayUrl = "https://ipfs.sonr.land"
|
||||
}
|
||||
|
||||
sonr = new Sonr {
|
||||
apiUrl = "https://api.sonr.land"
|
||||
grpcUrl = "https://grpc.sonr.land"
|
||||
rpcUrl = "https://rpc.sonr.land"
|
||||
webSocketUrl = "wss://rpc.sonr.land/ws"
|
||||
}
|
||||
}
|
||||
|
25
deploy/process-compose.dev.yaml
Normal file
25
deploy/process-compose.dev.yaml
Normal file
@ -0,0 +1,25 @@
|
||||
version: "0.6"
|
||||
|
||||
processes:
|
||||
sonr:
|
||||
namespace: testnet
|
||||
command: "devbox run sonr"
|
||||
restart: on_failure
|
||||
max_restarts: 3
|
||||
depends:
|
||||
|
||||
caddy:
|
||||
namespace: testnet
|
||||
command: "devbox run xcaddy"
|
||||
restart: on_failure
|
||||
max_restarts: 3
|
||||
depends:
|
||||
- sonr
|
||||
|
||||
air:
|
||||
namespace: testnet
|
||||
command: "devbox run air"
|
||||
restart: on_failure
|
||||
max_restarts: 3
|
||||
depends:
|
||||
- sonr
|
@ -10,7 +10,7 @@ processes:
|
||||
|
||||
caddy:
|
||||
namespace: testnet
|
||||
command: "make caddy-start"
|
||||
command: "make xcaddy"
|
||||
restart: on_failure
|
||||
max_restarts: 3
|
||||
depends:
|
45
devbox.json
45
devbox.json
@ -2,11 +2,9 @@
|
||||
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.12.0/.schema/devbox.schema.json",
|
||||
"packages": [
|
||||
"go@1.22",
|
||||
"templ@latest",
|
||||
"bun@latest",
|
||||
"ipfs-cluster@latest",
|
||||
"air@latest",
|
||||
"commitizen@latest"
|
||||
"process-compose@latest"
|
||||
],
|
||||
"env": {
|
||||
"CLOUDFLARE_API_TOKEN": "$CLOUDFLARE_API_TOKEN",
|
||||
@ -14,49 +12,56 @@
|
||||
"PROJECT_BIN": "$PROJECT_DIR/bin",
|
||||
"GOPATH": "$HOME/go",
|
||||
"PATH": "$HOME/go/bin:$PROJECT_BIN:$PATH",
|
||||
"TEMPL_EXPERIMENT": "rawgo",
|
||||
"CHAIN_ID": "sonr-testnet-1",
|
||||
"DENOM": "usnr",
|
||||
"KEYRING": "test",
|
||||
"MONIKER": "florence"
|
||||
"MONIKER": "florence",
|
||||
"ENV": "$ENVIRONMENT"
|
||||
},
|
||||
"shell": {
|
||||
"scripts": {
|
||||
"install": [
|
||||
"make install"
|
||||
],
|
||||
"install:deps": [
|
||||
"make deps"
|
||||
],
|
||||
"build": [
|
||||
"make build",
|
||||
"make local-image"
|
||||
"make build"
|
||||
],
|
||||
"build:dwn": [
|
||||
"templ generate",
|
||||
"make dwn"
|
||||
],
|
||||
"build:image": [
|
||||
"make local-image"
|
||||
],
|
||||
"build:motr": [
|
||||
"templ generate",
|
||||
"make motr"
|
||||
],
|
||||
"gen:proto": [
|
||||
"make proto-gen"
|
||||
],
|
||||
"gen:pkl": [
|
||||
"go run github.com/apple/pkl-go/cmd/pkl-gen-go ./config/pkl/dwn.pkl",
|
||||
"go run github.com/apple/pkl-go/cmd/pkl-gen-go ./config/pkl/orm.pkl",
|
||||
"go run github.com/apple/pkl-go/cmd/pkl-gen-go ./config/pkl/web.pkl",
|
||||
"go run github.com/apple/pkl-go/cmd/pkl-gen-go ./config/pkl/txns.pkl"
|
||||
"make pkl"
|
||||
],
|
||||
"gen:templ": [
|
||||
"templ generate"
|
||||
"make templ"
|
||||
],
|
||||
"dev": [
|
||||
"air"
|
||||
"serve:local": [
|
||||
"process-compose -f ./deploy/process-compose.dev.yaml"
|
||||
],
|
||||
"start-proxy": [
|
||||
"./bin/caddy run --config ./config/caddy/caddy.conf"
|
||||
"serve:testnet": [
|
||||
"process-compose -f ./deploy/process-compose.yaml"
|
||||
],
|
||||
"testnet": [
|
||||
"make xcaddy",
|
||||
"devbox services up"
|
||||
"air": [
|
||||
"air -c ./deploy/air.toml"
|
||||
],
|
||||
"xcaddy": [
|
||||
"make xcaddy"
|
||||
],
|
||||
"sonr": [
|
||||
"make sh-testnet"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
2
go.mod
2
go.mod
@ -46,7 +46,7 @@ require (
|
||||
cosmossdk.io/x/nft v0.1.0
|
||||
cosmossdk.io/x/tx v0.13.3
|
||||
cosmossdk.io/x/upgrade v0.1.1
|
||||
github.com/a-h/templ v0.2.771
|
||||
github.com/a-h/templ v0.2.778
|
||||
github.com/apple/pkl-go v0.8.0
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.3
|
||||
github.com/charmbracelet/bubbles v0.19.0
|
||||
|
4
go.sum
4
go.sum
@ -832,8 +832,8 @@ github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE
|
||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||
github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE=
|
||||
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
|
||||
github.com/a-h/templ v0.2.771 h1:4KH5ykNigYGGpCe0fRJ7/hzwz72k3qFqIiiLLJskbSo=
|
||||
github.com/a-h/templ v0.2.771/go.mod h1:lq48JXoUvuQrU0VThrK31yFwdRjTCnIE5bcPCM9IP1w=
|
||||
github.com/a-h/templ v0.2.778 h1:VzhOuvWECrwOec4790lcLlZpP4Iptt5Q4K9aFxQmtaM=
|
||||
github.com/a-h/templ v0.2.778/go.mod h1:lq48JXoUvuQrU0VThrK31yFwdRjTCnIE5bcPCM9IP1w=
|
||||
github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I=
|
||||
github.com/adlio/schema v1.3.3/go.mod h1:1EsRssiv9/Ce2CMzq5DoL7RiMshhuigQxrR4DMV9fHg=
|
||||
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
|
||||
|
@ -1,12 +1,12 @@
|
||||
package tui
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/onsonr/sonr/internal/tui/dexmodel"
|
||||
"github.com/onsonr/sonr/internal/tui/txmodel"
|
||||
"github.com/onsonr/sonr/internal/cli/dexmodel"
|
||||
"github.com/onsonr/sonr/internal/cli/txmodel"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
@ -1,6 +0,0 @@
|
||||
package scripts
|
||||
|
||||
type (
|
||||
DatabaseAPI interface{}
|
||||
NavigatorAPI interface{}
|
||||
)
|
@ -1,21 +0,0 @@
|
||||
package scripts
|
||||
|
||||
templ InitializeDatabase() {
|
||||
<script type="module">
|
||||
// Import Dexie
|
||||
import { Dexie } from 'https://unpkg.com/dexie/dist/modern/dexie.mjs';
|
||||
|
||||
// Create a new Dexie database
|
||||
const db = new Dexie('myDatabase');
|
||||
|
||||
// Define the schema for the database
|
||||
db.version(1).stores({
|
||||
users: '++id, name, age',
|
||||
posts: '++id, title, content, authorId',
|
||||
comments: '++id, content, postId, authorId',
|
||||
});
|
||||
|
||||
// Export the database instance
|
||||
export default db;
|
||||
</script>
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
package scripts
|
||||
|
||||
//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 InitializeDatabase() 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("<script type=\"module\">\n // Import Dexie\n import { Dexie } from 'https://unpkg.com/dexie/dist/modern/dexie.mjs';\n \n // Create a new Dexie database\n const db = new Dexie('myDatabase');\n \n // Define the schema for the database\n db.version(1).stores({\n users: '++id, name, age',\n posts: '++id, title, content, authorId',\n comments: '++id, content, postId, authorId',\n });\n \n // Export the database instance\n export default db;\n </script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
@ -1,41 +0,0 @@
|
||||
package scripts
|
||||
|
||||
templ CreateCredential() {
|
||||
<script type="module">
|
||||
// Import Dexie
|
||||
import { Dexie } from 'https://unpkg.com/dexie/dist/modern/dexie.mjs';
|
||||
|
||||
// Create a new Dexie database
|
||||
const db = new Dexie('myDatabase');
|
||||
|
||||
// Define the schema for the database
|
||||
db.version(1).stores({
|
||||
users: '++id, name, age',
|
||||
posts: '++id, title, content, authorId',
|
||||
comments: '++id, content, postId, authorId',
|
||||
});
|
||||
|
||||
// Export the database instance
|
||||
window.vault = db;
|
||||
</script>
|
||||
}
|
||||
|
||||
templ GetCredential() {
|
||||
<script type="module">
|
||||
// Import Dexie
|
||||
import { Dexie } from 'https://unpkg.com/dexie/dist/modern/dexie.mjs';
|
||||
|
||||
// Create a new Dexie database
|
||||
const db = new Dexie('myDatabase');
|
||||
|
||||
// Define the schema for the database
|
||||
db.version(1).stores({
|
||||
users: '++id, name, age',
|
||||
posts: '++id, title, content, authorId',
|
||||
comments: '++id, content, postId, authorId',
|
||||
});
|
||||
|
||||
// Export the database instance
|
||||
export default db;
|
||||
</script>
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
package scripts
|
||||
|
||||
//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 CreateCredential() 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("<script type=\"module\">\n // Import Dexie\n import { Dexie } from 'https://unpkg.com/dexie/dist/modern/dexie.mjs';\n \n // Create a new Dexie database\n const db = new Dexie('myDatabase');\n \n // Define the schema for the database\n db.version(1).stores({\n users: '++id, name, age',\n posts: '++id, title, content, authorId',\n comments: '++id, content, postId, authorId',\n });\n \n // Export the database instance\n window.vault = db;\n </script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func GetCredential() 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_Var2 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var2 == nil {
|
||||
templ_7745c5c3_Var2 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script type=\"module\">\n // Import Dexie\n import { Dexie } from 'https://unpkg.com/dexie/dist/modern/dexie.mjs';\n \n // Create a new Dexie database\n const db = new Dexie('myDatabase');\n \n // Define the schema for the database\n db.version(1).stores({\n users: '++id, name, age',\n posts: '++id, title, content, authorId',\n comments: '++id, content, postId, authorId',\n });\n \n // Export the database instance\n export default db;\n </script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
@ -4,17 +4,138 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"syscall/js"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/dwn/front"
|
||||
promise "github.com/nlepage/go-js-promise"
|
||||
"github.com/onsonr/sonr/internal/dwn/handlers"
|
||||
"github.com/onsonr/sonr/internal/dwn/middleware"
|
||||
"github.com/onsonr/sonr/internal/vfs"
|
||||
"github.com/onsonr/sonr/pkg/nebula"
|
||||
)
|
||||
|
||||
func main() {
|
||||
e := echo.New()
|
||||
e.Use(middleware.UseSession)
|
||||
front.RegisterViews(e)
|
||||
nebula.RouteViews(e)
|
||||
handlers.RegisterState(e)
|
||||
vfs.Serve(e)
|
||||
Serve(e)
|
||||
}
|
||||
|
||||
// Serve serves HTTP requests using handler or http.DefaultServeMux if handler is nil.
|
||||
func Serve(handler http.Handler) func() {
|
||||
h := handler
|
||||
if h == nil {
|
||||
h = http.DefaultServeMux
|
||||
}
|
||||
|
||||
prefix := js.Global().Get("wasmhttp").Get("path").String()
|
||||
for strings.HasSuffix(prefix, "/") {
|
||||
prefix = strings.TrimSuffix(prefix, "/")
|
||||
}
|
||||
|
||||
if prefix != "" {
|
||||
mux := http.NewServeMux()
|
||||
mux.Handle(prefix+"/", http.StripPrefix(prefix, h))
|
||||
h = mux
|
||||
}
|
||||
|
||||
cb := js.FuncOf(func(_ js.Value, args []js.Value) interface{} {
|
||||
resPromise, resolve, reject := promise.New()
|
||||
|
||||
go func() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
if err, ok := r.(error); ok {
|
||||
reject(fmt.Sprintf("wasmhttp: panic: %+v\n", err))
|
||||
} else {
|
||||
reject(fmt.Sprintf("wasmhttp: panic: %v\n", r))
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
res := NewResponseRecorder()
|
||||
|
||||
h.ServeHTTP(res, Request(args[0]))
|
||||
|
||||
resolve(res.JSResponse())
|
||||
}()
|
||||
|
||||
return resPromise
|
||||
})
|
||||
|
||||
js.Global().Get("wasmhttp").Call("setHandler", cb)
|
||||
|
||||
return cb.Release
|
||||
}
|
||||
|
||||
// Request builds and returns the equivalent http.Request
|
||||
func Request(r js.Value) *http.Request {
|
||||
jsBody := js.Global().Get("Uint8Array").New(promise.Await(r.Call("arrayBuffer")))
|
||||
body := make([]byte, jsBody.Get("length").Int())
|
||||
js.CopyBytesToGo(body, jsBody)
|
||||
|
||||
req := httptest.NewRequest(
|
||||
r.Get("method").String(),
|
||||
r.Get("url").String(),
|
||||
bytes.NewBuffer(body),
|
||||
)
|
||||
|
||||
headersIt := r.Get("headers").Call("entries")
|
||||
for {
|
||||
e := headersIt.Call("next")
|
||||
if e.Get("done").Bool() {
|
||||
break
|
||||
}
|
||||
v := e.Get("value")
|
||||
req.Header.Set(v.Index(0).String(), v.Index(1).String())
|
||||
}
|
||||
|
||||
return req
|
||||
}
|
||||
|
||||
// ResponseRecorder uses httptest.ResponseRecorder to build a JS Response
|
||||
type ResponseRecorder struct {
|
||||
*httptest.ResponseRecorder
|
||||
}
|
||||
|
||||
// NewResponseRecorder returns a new ResponseRecorder
|
||||
func NewResponseRecorder() ResponseRecorder {
|
||||
return ResponseRecorder{httptest.NewRecorder()}
|
||||
}
|
||||
|
||||
// JSResponse builds and returns the equivalent JS Response
|
||||
func (rr ResponseRecorder) JSResponse() js.Value {
|
||||
res := rr.Result()
|
||||
|
||||
body := js.Undefined()
|
||||
if res.ContentLength != 0 {
|
||||
b, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
body = js.Global().Get("Uint8Array").New(len(b))
|
||||
js.CopyBytesToJS(body, b)
|
||||
}
|
||||
|
||||
init := make(map[string]interface{}, 2)
|
||||
|
||||
if res.StatusCode != 0 {
|
||||
init["status"] = res.StatusCode
|
||||
}
|
||||
|
||||
if len(res.Header) != 0 {
|
||||
headers := make(map[string]interface{}, len(res.Header))
|
||||
for k := range res.Header {
|
||||
headers[k] = res.Header.Get(k)
|
||||
}
|
||||
init["headers"] = headers
|
||||
}
|
||||
|
||||
return js.Global().Get("Response").New(body, init)
|
||||
}
|
||||
|
@ -1,322 +0,0 @@
|
||||
package txmodel
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/huh"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
"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/tx"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
)
|
||||
|
||||
const maxWidth = 100
|
||||
|
||||
var (
|
||||
red = lipgloss.AdaptiveColor{Light: "#FE5F86", Dark: "#FE5F86"}
|
||||
indigo = lipgloss.AdaptiveColor{Light: "#5A56E0", Dark: "#7571F9"}
|
||||
green = lipgloss.AdaptiveColor{Light: "#02BA84", Dark: "#02BF87"}
|
||||
)
|
||||
|
||||
type Styles struct {
|
||||
Base,
|
||||
HeaderText,
|
||||
Status,
|
||||
StatusHeader,
|
||||
Highlight,
|
||||
ErrorHeaderText,
|
||||
Help lipgloss.Style
|
||||
}
|
||||
|
||||
func NewStyles(lg *lipgloss.Renderer) *Styles {
|
||||
s := Styles{}
|
||||
s.Base = lg.NewStyle().
|
||||
Padding(1, 2, 0, 1)
|
||||
s.HeaderText = lg.NewStyle().
|
||||
Foreground(indigo).
|
||||
Bold(true).
|
||||
Padding(0, 1, 0, 1)
|
||||
s.Status = lg.NewStyle().
|
||||
Border(lipgloss.RoundedBorder()).
|
||||
BorderForeground(indigo).
|
||||
PaddingLeft(1).
|
||||
MarginTop(1)
|
||||
s.StatusHeader = lg.NewStyle().
|
||||
Foreground(green).
|
||||
Bold(true)
|
||||
s.Highlight = lg.NewStyle().
|
||||
Foreground(lipgloss.Color("212"))
|
||||
s.ErrorHeaderText = s.HeaderText.
|
||||
Foreground(red)
|
||||
s.Help = lg.NewStyle().
|
||||
Foreground(lipgloss.Color("240"))
|
||||
return &s
|
||||
}
|
||||
|
||||
type state int
|
||||
|
||||
const (
|
||||
statusNormal state = iota
|
||||
stateDone
|
||||
)
|
||||
|
||||
type Model struct {
|
||||
state state
|
||||
lg *lipgloss.Renderer
|
||||
styles *Styles
|
||||
form *huh.Form
|
||||
width int
|
||||
message *tx.TxBody
|
||||
}
|
||||
|
||||
func NewModel() Model {
|
||||
m := Model{width: maxWidth}
|
||||
m.lg = lipgloss.DefaultRenderer()
|
||||
m.styles = NewStyles(m.lg)
|
||||
|
||||
m.form = huh.NewForm(
|
||||
huh.NewGroup(
|
||||
huh.NewInput().
|
||||
Key("from").
|
||||
Title("From Address").
|
||||
Placeholder("cosmos1...").
|
||||
Validate(func(s string) error {
|
||||
if !strings.HasPrefix(s, "cosmos1") {
|
||||
return fmt.Errorf("invalid address format")
|
||||
}
|
||||
return nil
|
||||
}),
|
||||
|
||||
huh.NewInput().
|
||||
Key("to").
|
||||
Title("To Address").
|
||||
Placeholder("cosmos1...").
|
||||
Validate(func(s string) error {
|
||||
if !strings.HasPrefix(s, "cosmos1") {
|
||||
return fmt.Errorf("invalid address format")
|
||||
}
|
||||
return nil
|
||||
}),
|
||||
|
||||
huh.NewInput().
|
||||
Key("amount").
|
||||
Title("Amount").
|
||||
Placeholder("100").
|
||||
Validate(func(s string) error {
|
||||
if _, err := sdk.ParseCoinNormalized(s + "atom"); err != nil {
|
||||
return fmt.Errorf("invalid coin amount")
|
||||
}
|
||||
return nil
|
||||
}),
|
||||
|
||||
huh.NewSelect[string]().
|
||||
Key("denom").
|
||||
Title("Denom").
|
||||
Options(huh.NewOptions("atom", "osmo", "usnr", "snr")...),
|
||||
|
||||
huh.NewInput().
|
||||
Key("memo").
|
||||
Title("Memo").
|
||||
Placeholder("Optional"),
|
||||
|
||||
huh.NewConfirm().
|
||||
Key("done").
|
||||
Title("Ready to convert?").
|
||||
Validate(func(v bool) error {
|
||||
if !v {
|
||||
return fmt.Errorf("Please confirm when you're ready to convert")
|
||||
}
|
||||
return nil
|
||||
}).
|
||||
Affirmative("Yes, convert!").
|
||||
Negative("Not yet"),
|
||||
),
|
||||
).
|
||||
WithWidth(60).
|
||||
WithShowHelp(false).
|
||||
WithShowErrors(false)
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (m Model) Init() tea.Cmd {
|
||||
return m.form.Init()
|
||||
}
|
||||
|
||||
func min(x, y int) int {
|
||||
if x > y {
|
||||
return y
|
||||
}
|
||||
return x
|
||||
}
|
||||
|
||||
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
switch msg := msg.(type) {
|
||||
case tea.WindowSizeMsg:
|
||||
m.width = min(msg.Width, maxWidth) - m.styles.Base.GetHorizontalFrameSize()
|
||||
case tea.KeyMsg:
|
||||
switch msg.String() {
|
||||
case "esc", "ctrl+c", "q":
|
||||
return m, tea.Quit
|
||||
}
|
||||
}
|
||||
|
||||
var cmds []tea.Cmd
|
||||
|
||||
form, cmd := m.form.Update(msg)
|
||||
if f, ok := form.(*huh.Form); ok {
|
||||
m.form = f
|
||||
cmds = append(cmds, cmd)
|
||||
}
|
||||
|
||||
if m.form.State == huh.StateCompleted {
|
||||
m.buildMessage()
|
||||
cmds = append(cmds, tea.Quit)
|
||||
}
|
||||
|
||||
return m, tea.Batch(cmds...)
|
||||
}
|
||||
|
||||
func (m Model) View() string {
|
||||
s := m.styles
|
||||
|
||||
switch m.form.State {
|
||||
case huh.StateCompleted:
|
||||
pklCode := m.generatePkl()
|
||||
messageView := m.getMessageView()
|
||||
var b strings.Builder
|
||||
fmt.Fprintf(&b, "Final Tx:\n\n%s\n\n%s", pklCode, messageView)
|
||||
return s.Status.Margin(0, 1).Padding(1, 2).Width(80).Render(b.String()) + "\n\n"
|
||||
default:
|
||||
var schemaType string
|
||||
if m.form.GetString("schemaType") != "" {
|
||||
schemaType = "Schema Type: " + m.form.GetString("schemaType")
|
||||
}
|
||||
|
||||
v := strings.TrimSuffix(m.form.View(), "\n\n")
|
||||
form := m.lg.NewStyle().Margin(1, 0).Render(v)
|
||||
|
||||
var status string
|
||||
{
|
||||
preview := "(Preview will appear here)"
|
||||
if m.form.GetString("schema") != "" {
|
||||
preview = m.generatePkl()
|
||||
}
|
||||
|
||||
const statusWidth = 40
|
||||
statusMarginLeft := m.width - statusWidth - lipgloss.Width(form) - s.Status.GetMarginRight()
|
||||
status = s.Status.
|
||||
Height(lipgloss.Height(form)).
|
||||
Width(statusWidth).
|
||||
MarginLeft(statusMarginLeft).
|
||||
Render(s.StatusHeader.Render("Pkl Preview") + "\n" +
|
||||
schemaType + "\n\n" +
|
||||
preview)
|
||||
}
|
||||
|
||||
errors := m.form.Errors()
|
||||
header := m.appBoundaryView("Sonr TX Builder")
|
||||
if len(errors) > 0 {
|
||||
header = m.appErrorBoundaryView(m.errorView())
|
||||
}
|
||||
body := lipgloss.JoinHorizontal(lipgloss.Top, form, status)
|
||||
|
||||
footer := m.appBoundaryView(m.form.Help().ShortHelpView(m.form.KeyBinds()))
|
||||
if len(errors) > 0 {
|
||||
footer = m.appErrorBoundaryView("")
|
||||
}
|
||||
|
||||
return s.Base.Render(header + "\n" + body + "\n\n" + footer)
|
||||
}
|
||||
}
|
||||
|
||||
func (m Model) errorView() string {
|
||||
var s string
|
||||
for _, err := range m.form.Errors() {
|
||||
s += err.Error()
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func (m Model) appBoundaryView(text string) string {
|
||||
return lipgloss.PlaceHorizontal(
|
||||
m.width,
|
||||
lipgloss.Left,
|
||||
m.styles.HeaderText.Render(text),
|
||||
lipgloss.WithWhitespaceChars("="),
|
||||
lipgloss.WithWhitespaceForeground(indigo),
|
||||
)
|
||||
}
|
||||
|
||||
func (m Model) appErrorBoundaryView(text string) string {
|
||||
return lipgloss.PlaceHorizontal(
|
||||
m.width,
|
||||
lipgloss.Left,
|
||||
m.styles.ErrorHeaderText.Render(text),
|
||||
lipgloss.WithWhitespaceChars("="),
|
||||
lipgloss.WithWhitespaceForeground(red),
|
||||
)
|
||||
}
|
||||
|
||||
func (m Model) generatePkl() string {
|
||||
schemaType := m.form.GetString("schemaType")
|
||||
schema := m.form.GetString("schema")
|
||||
|
||||
// This is a placeholder for the actual conversion logic
|
||||
// In a real implementation, you would parse the schema and generate Pkl code
|
||||
return fmt.Sprintf("// Converted from %s\n\nclass ConvertedSchema {\n // TODO: Implement conversion from %s\n // Original schema:\n /*\n%s\n */\n}", schemaType, schemaType, schema)
|
||||
}
|
||||
|
||||
func (m *Model) buildMessage() {
|
||||
from := m.form.GetString("from")
|
||||
to := m.form.GetString("to")
|
||||
amount := m.form.GetString("amount")
|
||||
denom := m.form.GetString("denom")
|
||||
memo := m.form.GetString("memo")
|
||||
|
||||
coin, _ := sdk.ParseCoinNormalized(fmt.Sprintf("%s%s", amount, denom))
|
||||
sendMsg := &banktypes.MsgSend{
|
||||
FromAddress: from,
|
||||
ToAddress: to,
|
||||
Amount: sdk.NewCoins(coin),
|
||||
}
|
||||
|
||||
anyMsg, _ := codectypes.NewAnyWithValue(sendMsg)
|
||||
m.message = &tx.TxBody{
|
||||
Messages: []*codectypes.Any{anyMsg},
|
||||
Memo: memo,
|
||||
}
|
||||
}
|
||||
|
||||
func (m Model) getMessageView() string {
|
||||
if m.message == nil {
|
||||
return "Current Message: None"
|
||||
}
|
||||
|
||||
interfaceRegistry := codectypes.NewInterfaceRegistry()
|
||||
marshaler := codec.NewProtoCodec(interfaceRegistry)
|
||||
jsonBytes, _ := marshaler.MarshalJSON(m.message)
|
||||
|
||||
return fmt.Sprintf("Current Message:\n%s", string(jsonBytes))
|
||||
}
|
||||
|
||||
func RunTUIForm() (*tx.TxBody, error) {
|
||||
m := NewModel()
|
||||
p := tea.NewProgram(m)
|
||||
|
||||
finalModel, err := p.Run()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to run program: %w", err)
|
||||
}
|
||||
|
||||
finalM, ok := finalModel.(Model)
|
||||
if !ok || finalM.message == nil {
|
||||
return nil, fmt.Errorf("form not completed")
|
||||
}
|
||||
|
||||
return finalM.message, nil
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<script src="https://cdn.sonr.io/js/htmx.min.js"></script>
|
||||
<link href="https://cdn.sonr.io/stylesheet.css" rel="stylesheet" />
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<script src="https://unpkg.com/alpinejs" defer></script>
|
||||
<style>
|
||||
[x-cloak] {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<title>Sonr DWN</title>
|
||||
</head>
|
||||
<body
|
||||
class="flex items-center justify-center h-full bg-neutral-50 lg:p-24 md:16 p-4"
|
||||
>
|
||||
<script>
|
||||
if ("serviceWorker" in navigator) {
|
||||
navigator.serviceWorker
|
||||
.register("sw.js")
|
||||
.then(function (registration) {
|
||||
console.log(
|
||||
"Service Worker registered with scope:",
|
||||
registration.scope,
|
||||
);
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log("Service Worker registration failed:", error);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<main
|
||||
class="flex-row items-center justify-center mx-auto w-fit max-w-screen-sm gap-y-3"
|
||||
>
|
||||
<div hx-get="/" hx-trigger="load">Loading...</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
@ -1,128 +0,0 @@
|
||||
//go:build js && wasm
|
||||
|
||||
package vfs
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"syscall/js"
|
||||
|
||||
promise "github.com/nlepage/go-js-promise"
|
||||
)
|
||||
|
||||
// Serve serves HTTP requests using handler or http.DefaultServeMux if handler is nil.
|
||||
func Serve(handler http.Handler) func() {
|
||||
h := handler
|
||||
if h == nil {
|
||||
h = http.DefaultServeMux
|
||||
}
|
||||
|
||||
prefix := js.Global().Get("wasmhttp").Get("path").String()
|
||||
for strings.HasSuffix(prefix, "/") {
|
||||
prefix = strings.TrimSuffix(prefix, "/")
|
||||
}
|
||||
|
||||
if prefix != "" {
|
||||
mux := http.NewServeMux()
|
||||
mux.Handle(prefix+"/", http.StripPrefix(prefix, h))
|
||||
h = mux
|
||||
}
|
||||
|
||||
cb := js.FuncOf(func(_ js.Value, args []js.Value) interface{} {
|
||||
resPromise, resolve, reject := promise.New()
|
||||
|
||||
go func() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
if err, ok := r.(error); ok {
|
||||
reject(fmt.Sprintf("wasmhttp: panic: %+v\n", err))
|
||||
} else {
|
||||
reject(fmt.Sprintf("wasmhttp: panic: %v\n", r))
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
res := NewResponseRecorder()
|
||||
|
||||
h.ServeHTTP(res, Request(args[0]))
|
||||
|
||||
resolve(res.JSResponse())
|
||||
}()
|
||||
|
||||
return resPromise
|
||||
})
|
||||
|
||||
js.Global().Get("wasmhttp").Call("setHandler", cb)
|
||||
|
||||
return cb.Release
|
||||
}
|
||||
|
||||
// Request builds and returns the equivalent http.Request
|
||||
func Request(r js.Value) *http.Request {
|
||||
jsBody := js.Global().Get("Uint8Array").New(promise.Await(r.Call("arrayBuffer")))
|
||||
body := make([]byte, jsBody.Get("length").Int())
|
||||
js.CopyBytesToGo(body, jsBody)
|
||||
|
||||
req := httptest.NewRequest(
|
||||
r.Get("method").String(),
|
||||
r.Get("url").String(),
|
||||
bytes.NewBuffer(body),
|
||||
)
|
||||
|
||||
headersIt := r.Get("headers").Call("entries")
|
||||
for {
|
||||
e := headersIt.Call("next")
|
||||
if e.Get("done").Bool() {
|
||||
break
|
||||
}
|
||||
v := e.Get("value")
|
||||
req.Header.Set(v.Index(0).String(), v.Index(1).String())
|
||||
}
|
||||
|
||||
return req
|
||||
}
|
||||
|
||||
// ResponseRecorder uses httptest.ResponseRecorder to build a JS Response
|
||||
type ResponseRecorder struct {
|
||||
*httptest.ResponseRecorder
|
||||
}
|
||||
|
||||
// NewResponseRecorder returns a new ResponseRecorder
|
||||
func NewResponseRecorder() ResponseRecorder {
|
||||
return ResponseRecorder{httptest.NewRecorder()}
|
||||
}
|
||||
|
||||
// JSResponse builds and returns the equivalent JS Response
|
||||
func (rr ResponseRecorder) JSResponse() js.Value {
|
||||
res := rr.Result()
|
||||
|
||||
body := js.Undefined()
|
||||
if res.ContentLength != 0 {
|
||||
b, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
body = js.Global().Get("Uint8Array").New(len(b))
|
||||
js.CopyBytesToJS(body, b)
|
||||
}
|
||||
|
||||
init := make(map[string]interface{}, 2)
|
||||
|
||||
if res.StatusCode != 0 {
|
||||
init["status"] = res.StatusCode
|
||||
}
|
||||
|
||||
if len(res.Header) != 0 {
|
||||
headers := make(map[string]interface{}, len(res.Header))
|
||||
for k := range res.Header {
|
||||
headers[k] = res.Header.Get(k)
|
||||
}
|
||||
init["headers"] = headers
|
||||
}
|
||||
|
||||
return js.Global().Get("Response").New(body, init)
|
||||
}
|
22
pkg/builder/schema.go
Normal file
22
pkg/builder/schema.go
Normal file
@ -0,0 +1,22 @@
|
||||
package builder
|
||||
|
||||
import "github.com/onsonr/sonr/config/dwn"
|
||||
|
||||
type SchemaVersion = int
|
||||
|
||||
var CurrentSchemaVersion SchemaVersion = 1
|
||||
|
||||
func DefaultSchema() *dwn.Schema {
|
||||
return &dwn.Schema{
|
||||
Version: CurrentSchemaVersion,
|
||||
Account: "++, id, name, address, publicKey, chainCode, index, controller, createdAt",
|
||||
Asset: "++, id, name, symbol, decimals, chainCode, createdAt",
|
||||
Chain: "++, id, name, networkId, chainCode, createdAt",
|
||||
Credential: "++, id, subject, controller, attestationType, origin, label, deviceId, credentialId, publicKey, transport, signCount, userPresent, userVerified, backupEligible, backupState, cloneWarning, createdAt, updatedAt",
|
||||
Jwk: "++, kty, crv, x, y, n, e",
|
||||
Grant: "++, subject, controller, origin, token, scopes, createdAt, updatedAt",
|
||||
Keyshare: "++, id, data, role, createdAt, lastRefreshed",
|
||||
PublicKey: "++, role, algorithm, encoding, curve, key_type, raw, jwk",
|
||||
Profile: "++, id, subject, controller, originUri, publicMetadata, privateMetadata, createdAt, updatedAt",
|
||||
}
|
||||
}
|
53
pkg/builder/vault.go
Normal file
53
pkg/builder/vault.go
Normal file
@ -0,0 +1,53 @@
|
||||
package builder
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/types/bech32"
|
||||
"github.com/ipfs/boxo/files"
|
||||
"github.com/onsonr/crypto/mpc"
|
||||
"github.com/onsonr/sonr/pkg/vault"
|
||||
)
|
||||
|
||||
type Vault struct {
|
||||
FS files.Node
|
||||
ValKs mpc.Share
|
||||
}
|
||||
|
||||
func NewVault(subject string, origin string, chainID string) (*Vault, error) {
|
||||
shares, err := mpc.GenerateKeyshares()
|
||||
var (
|
||||
valKs = shares[0]
|
||||
usrKs = shares[1]
|
||||
)
|
||||
usrKsJSON, err := usrKs.Marshal()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sonrAddr, err := bech32.ConvertAndEncode("idx", valKs.GetPublicKey())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cnfg := vault.NewConfig(usrKsJSON, sonrAddr, chainID, DefaultSchema())
|
||||
cnfgFile, err := vault.MarshalConfigFile(cnfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
idxFile, err := vault.IndexHTMLFile(cnfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fileMap := map[string]files.Node{
|
||||
"config.json": cnfgFile,
|
||||
"motr.mjs": vault.MotrMJSFile(),
|
||||
"sw.js": vault.SWJSFile(),
|
||||
"app.wasm": vault.DWNWasmFile(),
|
||||
"index.html": idxFile,
|
||||
}
|
||||
|
||||
return &Vault{
|
||||
FS: files.NewMapDirectory(fileMap),
|
||||
ValKs: valKs,
|
||||
}, nil
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
// templ: version: v0.2.778
|
||||
package blocks
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@ -15,6 +15,9 @@ func Alert(variant Variant, icon Icon, title, message string) templ.Component {
|
||||
func alertElement(attrs templ.Attributes, title, message string, icon templ.Component) 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() {
|
||||
@ -53,7 +56,7 @@ func alertElement(attrs templ.Attributes, title, message string, icon templ.Comp
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/alert.templ`, Line: 10, Col: 66}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/alert.templ`, Line: 10, Col: 66}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -66,7 +69,7 @@ func alertElement(attrs templ.Attributes, title, message string, icon templ.Comp
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(message)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/alert.templ`, Line: 11, Col: 43}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/alert.templ`, Line: 11, Col: 43}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
// templ: version: v0.2.778
|
||||
package blocks
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@ -11,6 +11,9 @@ import templruntime "github.com/a-h/templ/runtime"
|
||||
func PoweredBySonr() 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() {
|
@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
// templ: version: v0.2.778
|
||||
package blocks
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@ -87,6 +87,9 @@ func Button(opts ...ButtonOpt) templ.Component {
|
||||
func renderButton(attrs templ.Attributes) 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() {
|
||||
@ -129,6 +132,9 @@ func renderButton(attrs templ.Attributes) templ.Component {
|
||||
func renderHxGetButton(c *button, attrs templ.Attributes) 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() {
|
||||
@ -151,7 +157,7 @@ func renderHxGetButton(c *button, attrs templ.Attributes) templ.Component {
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxGet)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/button.templ`, Line: 86, Col: 25}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/button.templ`, Line: 86, Col: 25}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -164,7 +170,7 @@ func renderHxGetButton(c *button, attrs templ.Attributes) templ.Component {
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxTarget)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/button.templ`, Line: 86, Col: 69}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/button.templ`, Line: 86, Col: 69}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -177,7 +183,7 @@ func renderHxGetButton(c *button, attrs templ.Attributes) templ.Component {
|
||||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxTrigger)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/button.templ`, Line: 86, Col: 96}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/button.templ`, Line: 86, Col: 96}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -190,7 +196,7 @@ func renderHxGetButton(c *button, attrs templ.Attributes) templ.Component {
|
||||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxSwap)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/button.templ`, Line: 86, Col: 117}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/button.templ`, Line: 86, Col: 117}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -223,6 +229,9 @@ func renderHxGetButton(c *button, attrs templ.Attributes) templ.Component {
|
||||
func renderHxPostButton(c *button, attrs templ.Attributes) 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() {
|
||||
@ -245,7 +254,7 @@ func renderHxPostButton(c *button, attrs templ.Attributes) templ.Component {
|
||||
var templ_7745c5c3_Var8 string
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxPost)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/button.templ`, Line: 92, Col: 27}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/button.templ`, Line: 92, Col: 27}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -258,7 +267,7 @@ func renderHxPostButton(c *button, attrs templ.Attributes) templ.Component {
|
||||
var templ_7745c5c3_Var9 string
|
||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxTarget)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/button.templ`, Line: 92, Col: 52}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/button.templ`, Line: 92, Col: 52}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -271,7 +280,7 @@ func renderHxPostButton(c *button, attrs templ.Attributes) templ.Component {
|
||||
var templ_7745c5c3_Var10 string
|
||||
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxTrigger)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/button.templ`, Line: 92, Col: 79}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/button.templ`, Line: 92, Col: 79}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -284,7 +293,7 @@ func renderHxPostButton(c *button, attrs templ.Attributes) templ.Component {
|
||||
var templ_7745c5c3_Var11 string
|
||||
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(c.hxSwap)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/button.templ`, Line: 92, Col: 100}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/button.templ`, Line: 92, Col: 100}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
|
||||
if templ_7745c5c3_Err != nil {
|
@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
// templ: version: v0.2.778
|
||||
package blocks
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@ -15,6 +15,9 @@ func Card(id string, size Size) templ.Component {
|
||||
func renderCard(id string, attrs templ.Attributes) 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() {
|
||||
@ -37,7 +40,7 @@ func renderCard(id string, attrs templ.Attributes) templ.Component {
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(id)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/card.templ`, Line: 8, Col: 13}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/card.templ`, Line: 8, Col: 13}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -70,6 +73,9 @@ func renderCard(id string, attrs templ.Attributes) templ.Component {
|
||||
func ProfileCard() 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() {
|
@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
// templ: version: v0.2.778
|
||||
package blocks
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@ -27,6 +27,9 @@ func Text(content string) templ.Component {
|
||||
func renderText(level int, 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() {
|
||||
@ -51,7 +54,7 @@ func renderText(level int, text string) templ.Component {
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(text)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/fonts.templ`, Line: 23, Col: 10}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/fonts.templ`, Line: 23, Col: 10}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -69,7 +72,7 @@ func renderText(level int, text string) templ.Component {
|
||||
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: `internal/dwn/front/blocks/fonts.templ`, Line: 27, Col: 10}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/fonts.templ`, Line: 27, Col: 10}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -87,7 +90,7 @@ func renderText(level int, text string) templ.Component {
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(text)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/fonts.templ`, Line: 31, Col: 10}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/fonts.templ`, Line: 31, Col: 10}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -105,7 +108,7 @@ func renderText(level int, text string) templ.Component {
|
||||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(text)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/fonts.templ`, Line: 35, Col: 10}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/fonts.templ`, Line: 35, Col: 10}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -123,6 +126,9 @@ func renderText(level int, text string) templ.Component {
|
||||
func renderLink(attrs templ.Attributes, 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() {
|
||||
@ -153,7 +159,7 @@ func renderLink(attrs templ.Attributes, text string) templ.Component {
|
||||
var templ_7745c5c3_Var7 string
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(text)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/fonts.templ`, Line: 42, Col: 8}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/fonts.templ`, Line: 42, Col: 8}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -170,6 +176,9 @@ func renderLink(attrs templ.Attributes, text string) templ.Component {
|
||||
func renderStrong(attrs templ.Attributes, 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() {
|
||||
@ -200,7 +209,7 @@ func renderStrong(attrs templ.Attributes, text string) templ.Component {
|
||||
var templ_7745c5c3_Var9 string
|
||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(text)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/fonts.templ`, Line: 48, Col: 8}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/fonts.templ`, Line: 48, Col: 8}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -217,6 +226,9 @@ func renderStrong(attrs templ.Attributes, text string) templ.Component {
|
||||
func renderEmphasis(attrs templ.Attributes, 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() {
|
||||
@ -247,7 +259,7 @@ func renderEmphasis(attrs templ.Attributes, text string) templ.Component {
|
||||
var templ_7745c5c3_Var11 string
|
||||
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(text)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/fonts.templ`, Line: 54, Col: 8}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/fonts.templ`, Line: 54, Col: 8}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -264,6 +276,9 @@ func renderEmphasis(attrs templ.Attributes, text string) templ.Component {
|
||||
func renderCode(attrs templ.Attributes, 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() {
|
||||
@ -294,7 +309,7 @@ func renderCode(attrs templ.Attributes, text string) templ.Component {
|
||||
var templ_7745c5c3_Var13 string
|
||||
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(text)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/fonts.templ`, Line: 60, Col: 8}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/fonts.templ`, Line: 60, Col: 8}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
|
||||
if templ_7745c5c3_Err != nil {
|
@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
// templ: version: v0.2.778
|
||||
package blocks
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@ -11,6 +11,9 @@ import templruntime "github.com/a-h/templ/runtime"
|
||||
func Spacer() 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() {
|
||||
@ -37,6 +40,9 @@ func Spacer() templ.Component {
|
||||
func ServiceWorker(path 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() {
|
||||
@ -63,6 +69,9 @@ func ServiceWorker(path string) templ.Component {
|
||||
func defaultStyles() 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() {
|
||||
@ -89,6 +98,9 @@ func defaultStyles() templ.Component {
|
||||
func Rows() 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() {
|
||||
@ -123,6 +135,9 @@ func Rows() templ.Component {
|
||||
func Columns() 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() {
|
@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
// templ: version: v0.2.778
|
||||
package blocks
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@ -24,6 +24,9 @@ func (v Icons) Render() templ.Component {
|
||||
func renderIconVariant(v Icons) 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() {
|
||||
@ -72,6 +75,9 @@ func renderIconVariant(v Icons) templ.Component {
|
||||
func SonrIcon() 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() {
|
@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
// templ: version: v0.2.778
|
||||
package blocks
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@ -19,6 +19,9 @@ const (
|
||||
func TextInput(state InputState, label string, placeholder 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() {
|
||||
@ -43,7 +46,7 @@ func TextInput(state InputState, label string, placeholder string) templ.Compone
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(label)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/inputs.templ`, Line: 15, Col: 128}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/inputs.templ`, Line: 15, Col: 128}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -61,7 +64,7 @@ func TextInput(state InputState, label string, placeholder string) templ.Compone
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(label)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/inputs.templ`, Line: 20, Col: 128}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/inputs.templ`, Line: 20, Col: 128}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -79,7 +82,7 @@ func TextInput(state InputState, label string, placeholder string) templ.Compone
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(label)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/inputs.templ`, Line: 25, Col: 128}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/inputs.templ`, Line: 25, Col: 128}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||
if templ_7745c5c3_Err != nil {
|
@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
// templ: version: v0.2.778
|
||||
package blocks
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@ -13,6 +13,9 @@ import "github.com/labstack/echo/v4"
|
||||
func Breadcrumbs() 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() {
|
||||
@ -71,6 +74,9 @@ func Breadcrumbs() templ.Component {
|
||||
func breadcrumbItem(title string, active bool) 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() {
|
||||
@ -94,7 +100,7 @@ func breadcrumbItem(title string, active bool) templ.Component {
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(title)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/panel.templ`, Line: 25, Col: 126}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/panel.templ`, Line: 25, Col: 126}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -112,7 +118,7 @@ func breadcrumbItem(title string, active bool) templ.Component {
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(title)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/dwn/front/blocks/panel.templ`, Line: 27, Col: 118}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/nebula/blocks/panel.templ`, Line: 27, Col: 118}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@ -130,6 +136,9 @@ func breadcrumbItem(title string, active bool) templ.Component {
|
||||
func breadcrumbIcon() 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() {
|
||||
@ -156,6 +165,9 @@ func breadcrumbIcon() templ.Component {
|
||||
func Panel(c echo.Context, id 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() {
|
@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
// templ: version: v0.2.778
|
||||
package blocks
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@ -11,6 +11,9 @@ import templruntime "github.com/a-h/templ/runtime"
|
||||
func RadioGroup() 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() {
|
@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
// templ: version: v0.2.778
|
||||
package blocks
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
// templ: version: v0.2.778
|
||||
package blocks
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@ -11,6 +11,9 @@ import templruntime "github.com/a-h/templ/runtime"
|
||||
func Tabs() 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() {
|
||||
@ -45,6 +48,9 @@ func Tabs() templ.Component {
|
||||
func Table() 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() {
|
@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
// templ: version: v0.2.778
|
||||
package islands
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@ -13,6 +13,9 @@ import "github.com/labstack/echo/v4"
|
||||
func BasicInfo(c echo.Context, state 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() {
|
||||
@ -42,6 +45,9 @@ func BasicInfo(c echo.Context, state FormState) templ.Component {
|
||||
func CreateCredentials(c echo.Context, state 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() {
|
||||
@ -64,6 +70,9 @@ func CreateCredentials(c echo.Context, state FormState) templ.Component {
|
||||
func PrivacyTerms(c echo.Context, state 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() {
|
@ -1,12 +1,12 @@
|
||||
package front
|
||||
package nebula
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/dwn/front/views"
|
||||
"github.com/onsonr/sonr/pkg/nebula/views"
|
||||
)
|
||||
|
||||
func RegisterViews(e *echo.Echo) {
|
||||
e.GET("/", views.HomeView)
|
||||
func RouteViews(e *echo.Echo) {
|
||||
e.GET("/home", views.HomeView)
|
||||
e.GET("/login", views.LoginView)
|
||||
e.GET("/register", views.RegisterView)
|
||||
e.GET("/profile", views.ProfileView)
|
@ -2,7 +2,7 @@ package views
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/dwn/front/blocks"
|
||||
"github.com/onsonr/sonr/pkg/nebula/blocks"
|
||||
)
|
||||
|
||||
func HomeView(c echo.Context) error {
|
@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
// templ: version: v0.2.778
|
||||
package views
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@ -10,7 +10,7 @@ import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/dwn/front/blocks"
|
||||
"github.com/onsonr/sonr/pkg/nebula/blocks"
|
||||
)
|
||||
|
||||
func HomeView(c echo.Context) error {
|
||||
@ -20,6 +20,9 @@ func HomeView(c echo.Context) error {
|
||||
func renderHomeView() 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() {
|
@ -2,7 +2,8 @@ package views
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/dwn/front/blocks"
|
||||
"github.com/onsonr/sonr/pkg/nebula/blocks"
|
||||
|
||||
)
|
||||
|
||||
func LoginView(c echo.Context) error {
|
@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
// templ: version: v0.2.778
|
||||
package views
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@ -10,7 +10,7 @@ import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/dwn/front/blocks"
|
||||
"github.com/onsonr/sonr/pkg/nebula/blocks"
|
||||
)
|
||||
|
||||
func LoginView(c echo.Context) error {
|
||||
@ -20,6 +20,9 @@ func LoginView(c echo.Context) error {
|
||||
func renderLoginView() 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() {
|
@ -2,7 +2,8 @@ package views
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/dwn/front/blocks"
|
||||
"github.com/onsonr/sonr/pkg/nebula/blocks"
|
||||
|
||||
)
|
||||
|
||||
func AuthorizeView(c echo.Context) error {
|
@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
// templ: version: v0.2.778
|
||||
package views
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@ -10,7 +10,7 @@ import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/dwn/front/blocks"
|
||||
"github.com/onsonr/sonr/pkg/nebula/blocks"
|
||||
)
|
||||
|
||||
func AuthorizeView(c echo.Context) error {
|
||||
@ -20,6 +20,9 @@ func AuthorizeView(c echo.Context) error {
|
||||
func renderAuthorizeView() 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() {
|
@ -2,7 +2,8 @@ package views
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/dwn/front/blocks"
|
||||
"github.com/onsonr/sonr/pkg/nebula/blocks"
|
||||
|
||||
)
|
||||
|
||||
func ProfileView(c echo.Context) error {
|
@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
// templ: version: v0.2.778
|
||||
package views
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@ -10,7 +10,7 @@ import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/dwn/front/blocks"
|
||||
"github.com/onsonr/sonr/pkg/nebula/blocks"
|
||||
)
|
||||
|
||||
func ProfileView(c echo.Context) error {
|
||||
@ -20,6 +20,9 @@ func ProfileView(c echo.Context) error {
|
||||
func renderProfileView() 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() {
|
@ -2,8 +2,8 @@ package views
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/dwn/front/blocks"
|
||||
"github.com/onsonr/sonr/internal/dwn/front/islands"
|
||||
"github.com/onsonr/sonr/pkg/nebula/blocks"
|
||||
"github.com/onsonr/sonr/pkg/nebula/islands"
|
||||
)
|
||||
|
||||
func RegisterView(c echo.Context) error {
|
@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
// templ: version: v0.2.778
|
||||
package views
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@ -10,8 +10,8 @@ import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/dwn/front/blocks"
|
||||
"github.com/onsonr/sonr/internal/dwn/front/islands"
|
||||
"github.com/onsonr/sonr/pkg/nebula/blocks"
|
||||
"github.com/onsonr/sonr/pkg/nebula/islands"
|
||||
)
|
||||
|
||||
func RegisterView(c echo.Context) error {
|
||||
@ -21,6 +21,9 @@ func RegisterView(c echo.Context) error {
|
||||
func renderRegisterView(c echo.Context) 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() {
|
Binary file not shown.
@ -1,9 +1,12 @@
|
||||
package vfs
|
||||
package vault
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
_ "embed"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/a-h/templ"
|
||||
"github.com/ipfs/boxo/files"
|
||||
"github.com/onsonr/sonr/config/dwn"
|
||||
)
|
||||
@ -11,20 +14,41 @@ import (
|
||||
//go:embed app.wasm
|
||||
var dwnWasmData []byte
|
||||
|
||||
//go:embed index.html
|
||||
var indexData []byte
|
||||
//go:embed motr.mjs
|
||||
var motrMJSData []byte
|
||||
|
||||
//go:embed sw.js
|
||||
var swJSData []byte
|
||||
|
||||
// NewDWNConfigFile uses the config template to generate the dwn config file
|
||||
func NewDWNConfigFile(keyshareJSON string, adddress string, chainID string) (files.Node, error) {
|
||||
// NewConfig uses the config template to generate the dwn config file
|
||||
func NewConfig(keyshareJSON string, adddress string, chainID string, schema *dwn.Schema) *dwn.Config {
|
||||
dwnCfg := &dwn.Config{
|
||||
Motr: createMotrConfig(keyshareJSON, adddress, "sonr.id"),
|
||||
Ipfs: defaultIPFSConfig(),
|
||||
Sonr: defaultSonrConfig(chainID),
|
||||
Motr: createMotrConfig(keyshareJSON, adddress, "sonr.id"),
|
||||
Ipfs: defaultIPFSConfig(),
|
||||
Sonr: defaultSonrConfig(chainID),
|
||||
Schema: schema,
|
||||
}
|
||||
dwnConfigData, err := json.Marshal(dwnCfg)
|
||||
return dwnCfg
|
||||
}
|
||||
|
||||
// Use IndexHTML template to generate the index file
|
||||
func IndexHTMLFile(c *dwn.Config) (files.Node, error) {
|
||||
str, err := templ.JSONString(c)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
w := bytes.NewBuffer(nil)
|
||||
err = indexFile(str).Render(context.Background(), w)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
indexData := w.Bytes()
|
||||
return files.NewBytesFile(indexData), nil
|
||||
}
|
||||
|
||||
// MarshalConfigFile uses the config template to generate the dwn config file
|
||||
func MarshalConfigFile(c *dwn.Config) (files.Node, error) {
|
||||
dwnConfigData, err := json.Marshal(c)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -36,9 +60,9 @@ func DWNWasmFile() files.Node {
|
||||
return files.NewBytesFile(dwnWasmData)
|
||||
}
|
||||
|
||||
// Use IndexHTML template to generate the index file
|
||||
func IndexFile() files.Node {
|
||||
return files.NewBytesFile(indexData)
|
||||
// Use MotrMJS template to generate the dwn wasm file
|
||||
func MotrMJSFile() files.Node {
|
||||
return files.NewBytesFile(motrMJSData)
|
||||
}
|
||||
|
||||
// Use ServiceWorkerJS template to generate the service worker file
|
107
pkg/vault/index.templ
Normal file
107
pkg/vault/index.templ
Normal file
@ -0,0 +1,107 @@
|
||||
package vault
|
||||
|
||||
|
||||
var motrHandle = templ.NewOnceHandle()
|
||||
|
||||
templ importScripts() {
|
||||
<script src="https://cdn.sonr.io/js/htmx.min.js"></script>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<script src="https://unpkg.com/alpinejs" defer></script>
|
||||
}
|
||||
|
||||
templ indexFile(cfg string) {
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link href="https://cdn.sonr.io/stylesheet.css" rel="stylesheet" />
|
||||
@importScripts()
|
||||
<style>
|
||||
[x-cloak] {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<title>Sonr DWN</title>
|
||||
<script>
|
||||
if ("serviceWorker" in navigator) {
|
||||
window.addEventListener("load", function() {
|
||||
navigator.serviceWorker
|
||||
.register("/sw.js")
|
||||
.then(function (registration) {
|
||||
console.log("Service Worker registered with scope:", registration.scope);
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log("Service Worker registration failed:", error);
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body class="flex items-center justify-center h-full bg-neutral-50 lg:p-24 md:16 p-4">
|
||||
<main class="flex-row items-center justify-center mx-auto w-fit max-w-screen-sm gap-y-3">
|
||||
<div id="output">Loading...</div>
|
||||
</main>
|
||||
@motrHandle.Once() {
|
||||
<script src="./motr.mjs" type="module"></script>
|
||||
@initializeMotr(cfg)
|
||||
}
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
|
||||
script initializeMotr(config string) {
|
||||
const motr = new Motr(JSON.parse(config));
|
||||
|
||||
async function demo() {
|
||||
try {
|
||||
// Insert a new account
|
||||
const accountId = await motr.insertAccount({
|
||||
name: 'John Doe',
|
||||
address: '0x1234567890123456789012345678901234567890',
|
||||
publicKey: 'sample_public_key',
|
||||
chainCode: 'SONR',
|
||||
index: 0,
|
||||
controller: 'sample_controller',
|
||||
createdAt: new Date()
|
||||
});
|
||||
|
||||
console.log('Inserted account with ID:', accountId);
|
||||
|
||||
// Retrieve the account
|
||||
const account = await motr.getAccount(accountId);
|
||||
console.log('Retrieved account:', account);
|
||||
|
||||
// Insert a new credential
|
||||
const credentialId = await motr.insertCredential({
|
||||
subject: 'john@example.com',
|
||||
label: 'John\'s Device',
|
||||
controller: 'sample_controller',
|
||||
attestationType: 'platform',
|
||||
origin: 'https://app.sonr.io'
|
||||
});
|
||||
|
||||
console.log('Inserted credential with ID:', credentialId);
|
||||
|
||||
// Retrieve the credential
|
||||
const credential = await motr.getCredential(credentialId);
|
||||
console.log('Retrieved credential:', credential);
|
||||
|
||||
document.getElementById('output').innerHTML = `
|
||||
<h2>Demo Results:</h2>
|
||||
<p>Inserted account ID: ${accountId}</p>
|
||||
<p>Retrieved account name: ${account.name}</p>
|
||||
<p>Inserted credential ID: ${credentialId}</p>
|
||||
<p>Retrieved credential subject: ${credential.subject}</p>
|
||||
`;
|
||||
} catch (error) {
|
||||
console.error('Error in demo:', error);
|
||||
document.getElementById('output').innerHTML = `<p>Error: ${error.message}</p>`;
|
||||
}
|
||||
}
|
||||
|
||||
// Run the demo when the page loads
|
||||
window.onload = demo;
|
||||
}
|
||||
|
169
pkg/vault/index_templ.go
Normal file
169
pkg/vault/index_templ.go
Normal file
@ -0,0 +1,169 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.778
|
||||
package vault
|
||||
|
||||
//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"
|
||||
|
||||
var motrHandle = templ.NewOnceHandle()
|
||||
|
||||
func importScripts() 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("<script src=\"https://cdn.sonr.io/js/htmx.min.js\"></script><script src=\"https://cdn.tailwindcss.com\"></script><script src=\"https://unpkg.com/alpinejs\" defer></script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func indexFile(cfg 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_Var2 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var2 == nil {
|
||||
templ_7745c5c3_Var2 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<!doctype html><html lang=\"en\"><head><meta charset=\"UTF-8\"><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><link href=\"https://cdn.sonr.io/stylesheet.css\" rel=\"stylesheet\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = importScripts().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<style>\n [x-cloak] {\n display: none;\n }\n </style><title>Sonr DWN</title><script>\n if (\"serviceWorker\" in navigator) {\n window.addEventListener(\"load\", function() {\n navigator.serviceWorker\n .register(\"/sw.js\")\n .then(function (registration) {\n console.log(\"Service Worker registered with scope:\", registration.scope);\n })\n .catch(function (error) {\n console.log(\"Service Worker registration failed:\", error);\n });\n });\n }\n </script></head><body class=\"flex items-center justify-center h-full bg-neutral-50 lg:p-24 md:16 p-4\"><main class=\"flex-row items-center justify-center mx-auto w-fit max-w-screen-sm gap-y-3\"><div id=\"output\">Loading...</div></main>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
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 = templ_7745c5c3_Buffer.WriteString("<script src=\"./motr.mjs\" type=\"module\"></script> ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = initializeMotr(cfg).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
templ_7745c5c3_Err = motrHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</body></html>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return templ_7745c5c3_Err
|
||||
})
|
||||
}
|
||||
|
||||
func initializeMotr(config string) templ.ComponentScript {
|
||||
return templ.ComponentScript{
|
||||
Name: `__templ_initializeMotr_4943`,
|
||||
Function: `function __templ_initializeMotr_4943(config){const motr = new Motr(JSON.parse(config));
|
||||
|
||||
async function demo() {
|
||||
try {
|
||||
// Insert a new account
|
||||
const accountId = await motr.insertAccount({
|
||||
name: 'John Doe',
|
||||
address: '0x1234567890123456789012345678901234567890',
|
||||
publicKey: 'sample_public_key',
|
||||
chainCode: 'SONR',
|
||||
index: 0,
|
||||
controller: 'sample_controller',
|
||||
createdAt: new Date()
|
||||
});
|
||||
|
||||
console.log('Inserted account with ID:', accountId);
|
||||
|
||||
// Retrieve the account
|
||||
const account = await motr.getAccount(accountId);
|
||||
console.log('Retrieved account:', account);
|
||||
|
||||
// Insert a new credential
|
||||
const credentialId = await motr.insertCredential({
|
||||
subject: 'john@example.com',
|
||||
label: 'John\'s Device',
|
||||
controller: 'sample_controller',
|
||||
attestationType: 'platform',
|
||||
origin: 'https://app.sonr.io'
|
||||
});
|
||||
|
||||
console.log('Inserted credential with ID:', credentialId);
|
||||
|
||||
// Retrieve the credential
|
||||
const credential = await motr.getCredential(credentialId);
|
||||
console.log('Retrieved credential:', credential);
|
||||
|
||||
document.getElementById('output').innerHTML = ` + "`" + `
|
||||
<h2>Demo Results:</h2>
|
||||
<p>Inserted account ID: ${accountId}</p>
|
||||
<p>Retrieved account name: ${account.name}</p>
|
||||
<p>Inserted credential ID: ${credentialId}</p>
|
||||
<p>Retrieved credential subject: ${credential.subject}</p>
|
||||
` + "`" + `;
|
||||
} catch (error) {
|
||||
console.error('Error in demo:', error);
|
||||
document.getElementById('output').innerHTML = ` + "`" + `<p>Error: ${error.message}</p>` + "`" + `;
|
||||
}
|
||||
}
|
||||
|
||||
// Run the demo when the page loads
|
||||
window.onload = demo;
|
||||
}`,
|
||||
Call: templ.SafeScript(`__templ_initializeMotr_4943`, config),
|
||||
CallInline: templ.SafeScriptInline(`__templ_initializeMotr_4943`, config),
|
||||
}
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
253
pkg/vault/motr.mjs
Normal file
253
pkg/vault/motr.mjs
Normal file
@ -0,0 +1,253 @@
|
||||
// motr.mjs
|
||||
|
||||
import Dexie from "dexie";
|
||||
|
||||
export class Motr {
|
||||
constructor(config) {
|
||||
this.config = config;
|
||||
this.vault = null;
|
||||
this.initializeVault();
|
||||
}
|
||||
|
||||
initializeVault() {
|
||||
const { schema } = this.config;
|
||||
this.vault = new Dexie("Vault");
|
||||
this.vault.version(schema.version).stores(schema);
|
||||
}
|
||||
|
||||
// Account methods
|
||||
async insertAccount(accountData) {
|
||||
return this.vault.account.add(accountData);
|
||||
}
|
||||
|
||||
async getAccount(id) {
|
||||
return this.vault.account.get(id);
|
||||
}
|
||||
|
||||
async updateAccount(id, accountData) {
|
||||
return this.vault.account.update(id, accountData);
|
||||
}
|
||||
|
||||
async deleteAccount(id) {
|
||||
return this.vault.account.delete(id);
|
||||
}
|
||||
|
||||
// Asset methods
|
||||
async insertAsset(assetData) {
|
||||
return this.vault.asset.add(assetData);
|
||||
}
|
||||
|
||||
async getAsset(id) {
|
||||
return this.vault.asset.get(id);
|
||||
}
|
||||
|
||||
async updateAsset(id, assetData) {
|
||||
return this.vault.asset.update(id, assetData);
|
||||
}
|
||||
|
||||
async deleteAsset(id) {
|
||||
return this.vault.asset.delete(id);
|
||||
}
|
||||
|
||||
// Chain methods
|
||||
async insertChain(chainData) {
|
||||
return this.vault.chain.add(chainData);
|
||||
}
|
||||
|
||||
async getChain(id) {
|
||||
return this.vault.chain.get(id);
|
||||
}
|
||||
|
||||
async updateChain(id, chainData) {
|
||||
return this.vault.chain.update(id, chainData);
|
||||
}
|
||||
|
||||
async deleteChain(id) {
|
||||
return this.vault.chain.delete(id);
|
||||
}
|
||||
|
||||
// Credential methods
|
||||
async insertCredential(credentialData) {
|
||||
const publicKey = await this.createPublicKeyCredential(credentialData);
|
||||
credentialData.credentialId = publicKey.id;
|
||||
credentialData.publicKey = publicKey.publicKey;
|
||||
return this.vault.credential.add(credentialData);
|
||||
}
|
||||
|
||||
async getCredential(id) {
|
||||
return this.vault.credential.get(id);
|
||||
}
|
||||
|
||||
async updateCredential(id, credentialData) {
|
||||
return this.vault.credential.update(id, credentialData);
|
||||
}
|
||||
|
||||
async deleteCredential(id) {
|
||||
return this.vault.credential.delete(id);
|
||||
}
|
||||
|
||||
// JWK methods
|
||||
async insertJwk(jwkData) {
|
||||
return this.vault.jwk.add(jwkData);
|
||||
}
|
||||
|
||||
async getJwk(id) {
|
||||
return this.vault.jwk.get(id);
|
||||
}
|
||||
|
||||
async updateJwk(id, jwkData) {
|
||||
return this.vault.jwk.update(id, jwkData);
|
||||
}
|
||||
|
||||
async deleteJwk(id) {
|
||||
return this.vault.jwk.delete(id);
|
||||
}
|
||||
|
||||
// Grant methods
|
||||
async insertGrant(grantData) {
|
||||
return this.vault.grant.add(grantData);
|
||||
}
|
||||
|
||||
async getGrant(id) {
|
||||
return this.vault.grant.get(id);
|
||||
}
|
||||
|
||||
async updateGrant(id, grantData) {
|
||||
return this.vault.grant.update(id, grantData);
|
||||
}
|
||||
|
||||
async deleteGrant(id) {
|
||||
return this.vault.grant.delete(id);
|
||||
}
|
||||
|
||||
// Keyshare methods
|
||||
async insertKeyshare(keyshareData) {
|
||||
return this.vault.keyshare.add(keyshareData);
|
||||
}
|
||||
|
||||
async getKeyshare(id) {
|
||||
return this.vault.keyshare.get(id);
|
||||
}
|
||||
|
||||
async updateKeyshare(id, keyshareData) {
|
||||
return this.vault.keyshare.update(id, keyshareData);
|
||||
}
|
||||
|
||||
async deleteKeyshare(id) {
|
||||
return this.vault.keyshare.delete(id);
|
||||
}
|
||||
|
||||
// PublicKey methods
|
||||
async insertPublicKey(publicKeyData) {
|
||||
return this.vault.publicKey.add(publicKeyData);
|
||||
}
|
||||
|
||||
async getPublicKey(id) {
|
||||
return this.vault.publicKey.get(id);
|
||||
}
|
||||
|
||||
async updatePublicKey(id, publicKeyData) {
|
||||
return this.vault.publicKey.update(id, publicKeyData);
|
||||
}
|
||||
|
||||
async deletePublicKey(id) {
|
||||
return this.vault.publicKey.delete(id);
|
||||
}
|
||||
|
||||
// Profile methods
|
||||
async insertProfile(profileData) {
|
||||
return this.vault.profile.add(profileData);
|
||||
}
|
||||
|
||||
async getProfile(id) {
|
||||
return this.vault.profile.get(id);
|
||||
}
|
||||
|
||||
async updateProfile(id, profileData) {
|
||||
return this.vault.profile.update(id, profileData);
|
||||
}
|
||||
|
||||
async deleteProfile(id) {
|
||||
return this.vault.profile.delete(id);
|
||||
}
|
||||
|
||||
// WebAuthn methods
|
||||
async createPublicKeyCredential(options) {
|
||||
const publicKeyCredentialCreationOptions = {
|
||||
challenge: new Uint8Array(32),
|
||||
rp: {
|
||||
name: this.config.motr.origin,
|
||||
id: new URL(this.config.motr.origin).hostname,
|
||||
},
|
||||
user: {
|
||||
id: new TextEncoder().encode(options.subject),
|
||||
name: options.subject,
|
||||
displayName: options.label,
|
||||
},
|
||||
pubKeyCredParams: [
|
||||
{ alg: -7, type: "public-key" },
|
||||
{ alg: -257, type: "public-key" },
|
||||
],
|
||||
authenticatorSelection: {
|
||||
authenticatorAttachment: "platform",
|
||||
userVerification: "required",
|
||||
},
|
||||
timeout: 60000,
|
||||
attestation: "direct",
|
||||
};
|
||||
|
||||
try {
|
||||
const credential = await navigator.credentials.create({
|
||||
publicKey: publicKeyCredentialCreationOptions,
|
||||
});
|
||||
|
||||
const publicKeyJwk = await crypto.subtle.exportKey(
|
||||
"jwk",
|
||||
credential.response.getPublicKey(),
|
||||
);
|
||||
|
||||
return {
|
||||
id: credential.id,
|
||||
publicKey: publicKeyJwk,
|
||||
type: credential.type,
|
||||
transports: credential.response.getTransports(),
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error creating credential:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async getPublicKeyCredential(options) {
|
||||
const publicKeyCredentialRequestOptions = {
|
||||
challenge: new Uint8Array(32),
|
||||
rpId: new URL(this.config.motr.origin).hostname,
|
||||
allowCredentials: options.allowCredentials || [],
|
||||
userVerification: "required",
|
||||
timeout: 60000,
|
||||
};
|
||||
|
||||
try {
|
||||
const assertion = await navigator.credentials.get({
|
||||
publicKey: publicKeyCredentialRequestOptions,
|
||||
});
|
||||
|
||||
return {
|
||||
id: assertion.id,
|
||||
type: assertion.type,
|
||||
rawId: new Uint8Array(assertion.rawId),
|
||||
response: {
|
||||
authenticatorData: new Uint8Array(
|
||||
assertion.response.authenticatorData,
|
||||
),
|
||||
clientDataJSON: new Uint8Array(assertion.response.clientDataJSON),
|
||||
signature: new Uint8Array(assertion.response.signature),
|
||||
userHandle: new Uint8Array(assertion.response.userHandle),
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error getting credential:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +1,16 @@
|
||||
importScripts(
|
||||
"https://cdn.jsdelivr.net/gh/golang/go@go1.22.5/misc/wasm/wasm_exec.js",
|
||||
"https://cdn.jsdelivr.net/gh/nlepage/go-wasm-http-server@v1.1.0/sw.js",
|
||||
"https://storage.googleapis.com/workbox-cdn/releases/3.6.3/workbox-sw.js",
|
||||
);
|
||||
|
||||
registerWasmHTTPListener("app.wasm");
|
||||
|
||||
// Skip installed stage and jump to activating stage
|
||||
addEventListener("install", (event) => {
|
||||
self.addEventListener("install", (event) => {
|
||||
event.waitUntil(skipWaiting());
|
||||
});
|
||||
|
||||
// Start controlling clients as soon as the SW is activated
|
||||
addEventListener("activate", (event) => {
|
||||
self.addEventListener("activate", (event) => {
|
||||
event.waitUntil(clients.claim());
|
||||
});
|
@ -31,28 +31,6 @@ service Msg {
|
||||
rpc RegisterService(MsgRegisterService) returns (MsgRegisterServiceResponse);
|
||||
}
|
||||
|
||||
// MsgUpdateParams is the Msg/UpdateParams request type.
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
message MsgUpdateParams {
|
||||
option (cosmos.msg.v1.signer) = "authority";
|
||||
|
||||
// authority is the address of the governance account.
|
||||
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
|
||||
// params defines the parameters to update.
|
||||
Params params = 2 [(gogoproto.nullable) = false];
|
||||
|
||||
// token is the macron token to authenticate the operation.
|
||||
string token = 3;
|
||||
}
|
||||
|
||||
// MsgUpdateParamsResponse defines the response structure for executing a
|
||||
// MsgUpdateParams message.
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
message MsgUpdateParamsResponse {}
|
||||
|
||||
// MsgAllocateVault is the message type for the AllocateVault RPC.
|
||||
message MsgAllocateVault {
|
||||
option (cosmos.msg.v1.signer) = "authority";
|
||||
@ -150,3 +128,25 @@ message MsgRegisterServiceResponse {
|
||||
bool success = 1;
|
||||
string did = 2;
|
||||
}
|
||||
|
||||
// MsgUpdateParams is the Msg/UpdateParams request type.
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
message MsgUpdateParams {
|
||||
option (cosmos.msg.v1.signer) = "authority";
|
||||
|
||||
// authority is the address of the governance account.
|
||||
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
|
||||
// params defines the parameters to update.
|
||||
Params params = 2 [(gogoproto.nullable) = false];
|
||||
|
||||
// token is the macron token to authenticate the operation.
|
||||
string token = 3;
|
||||
}
|
||||
|
||||
// MsgUpdateParamsResponse defines the response structure for executing a
|
||||
// MsgUpdateParams message.
|
||||
//
|
||||
// Since: cosmos-sdk 0.47
|
||||
message MsgUpdateParamsResponse {}
|
||||
|
@ -2,7 +2,7 @@ package pages
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/dwn/front/blocks"
|
||||
"github.com/onsonr/sonr/pkg/nebula/blocks"
|
||||
)
|
||||
|
||||
func AllocateView(c echo.Context) error {
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
// templ: version: v0.2.778
|
||||
package pages
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@ -10,7 +10,7 @@ import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/dwn/front/blocks"
|
||||
"github.com/onsonr/sonr/pkg/nebula/blocks"
|
||||
)
|
||||
|
||||
func AllocateView(c echo.Context) error {
|
||||
@ -20,6 +20,9 @@ func AllocateView(c echo.Context) error {
|
||||
func renderAuthorizeView() 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() {
|
||||
|
@ -2,7 +2,7 @@ package pages
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/dwn/front/blocks"
|
||||
"github.com/onsonr/sonr/pkg/nebula/blocks"
|
||||
)
|
||||
|
||||
func HomeView(c echo.Context) error {
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.2.771
|
||||
// templ: version: v0.2.778
|
||||
package pages
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
@ -10,7 +10,7 @@ import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/internal/dwn/front/blocks"
|
||||
"github.com/onsonr/sonr/pkg/nebula/blocks"
|
||||
)
|
||||
|
||||
func HomeView(c echo.Context) error {
|
||||
@ -20,6 +20,9 @@ func HomeView(c echo.Context) error {
|
||||
func renderHomeView() 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() {
|
||||
|
@ -1,19 +1,46 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/ipfs/kubo/client/rpc"
|
||||
|
||||
nftkeeper "cosmossdk.io/x/nft/keeper"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/ipfs/boxo/path"
|
||||
"github.com/ipfs/kubo/client/rpc"
|
||||
"github.com/ipfs/kubo/core/coreiface/options"
|
||||
"github.com/onsonr/sonr/pkg/builder"
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
"google.golang.org/grpc/peer"
|
||||
"gopkg.in/macaroon.v2"
|
||||
)
|
||||
|
||||
func (k Keeper) UnwrapCtx(goCtx context.Context) Context {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
peer, _ := peer.FromContext(goCtx)
|
||||
return Context{SDKCtx: ctx, Peer: peer, Keeper: k}
|
||||
}
|
||||
|
||||
type Context struct {
|
||||
SDKCtx sdk.Context
|
||||
Keeper Keeper
|
||||
Peer *peer.Peer
|
||||
SDKCtx sdk.Context
|
||||
Keeper Keeper
|
||||
Peer *peer.Peer
|
||||
NFTKeeper nftkeeper.Keeper
|
||||
}
|
||||
|
||||
// AssembleVault assembles the initial vault
|
||||
func (k Keeper) AssembleVault(ctx Context, subject string, origin string) (string, int64, error) {
|
||||
v, err := builder.NewVault(subject, origin, "sonr-testnet")
|
||||
if err != nil {
|
||||
return "", 0, err
|
||||
}
|
||||
cid, err := k.ipfsClient.Unixfs().Add(context.Background(), v.FS)
|
||||
if err != nil {
|
||||
return "", 0, err
|
||||
}
|
||||
return cid.String(), ctx.CalculateExpiration(time.Second * 15), nil
|
||||
}
|
||||
|
||||
// AverageBlockTime returns the average block time in seconds
|
||||
@ -45,6 +72,26 @@ func (c Context) IsAnonymous() bool {
|
||||
return c.Peer.Addr == nil
|
||||
}
|
||||
|
||||
// IssueMacaroon creates a macaroon with the specified parameters.
|
||||
func (c Context) IssueMacaroon(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
|
||||
}
|
||||
|
||||
func (c Context) Params() *types.Params {
|
||||
p, err := c.Keeper.Params.Get(c.SDK())
|
||||
if err != nil {
|
||||
@ -61,6 +108,30 @@ func (c Context) PeerID() string {
|
||||
return c.Peer.Addr.String()
|
||||
}
|
||||
|
||||
// PinVaultController pins the initial vault to the local IPFS node
|
||||
func (k Keeper) PinVaultController(_ sdk.Context, cid string, address string) (bool, error) {
|
||||
// Resolve the path
|
||||
path, err := path.NewPath(cid)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// 1. Initialize vault.db sqlite database in local IPFS with Mount
|
||||
|
||||
// 2. Insert the InitialWalletAccounts
|
||||
|
||||
// 3. Publish the path to the IPNS
|
||||
_, err = k.ipfsClient.Name().Publish(context.Background(), path, options.Name.Key(address))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// 4. Insert the accounts into x/auth
|
||||
|
||||
// 5. Insert the controller into state
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (c Context) SDK() sdk.Context {
|
||||
return c.SDKCtx
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"cosmossdk.io/log"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/ipfs/boxo/path"
|
||||
"google.golang.org/grpc/peer"
|
||||
|
||||
"github.com/onsonr/sonr/x/did/types"
|
||||
)
|
||||
@ -71,9 +70,3 @@ func (k Keeper) HasPathInIPFS(ctx sdk.Context, cid string) (bool, error) {
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (k Keeper) UnwrapCtx(goCtx context.Context) Context {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
peer, _ := peer.FromContext(goCtx)
|
||||
return Context{SDKCtx: ctx, Peer: peer, Keeper: k}
|
||||
}
|
||||
|
@ -1,86 +0,0 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/bech32"
|
||||
"github.com/ipfs/boxo/files"
|
||||
"github.com/ipfs/boxo/path"
|
||||
"github.com/ipfs/kubo/core/coreiface/options"
|
||||
"github.com/onsonr/crypto/mpc"
|
||||
"github.com/onsonr/sonr/internal/vfs"
|
||||
)
|
||||
|
||||
type Vault struct {
|
||||
FS files.Node
|
||||
ValKs mpc.Share
|
||||
}
|
||||
|
||||
func NewVault(subject string, origin string, chainID string) (*Vault, error) {
|
||||
shares, err := mpc.GenerateKeyshares()
|
||||
var (
|
||||
valKs = shares[0]
|
||||
usrKs = shares[1]
|
||||
)
|
||||
usrKsJSON, err := usrKs.Marshal()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sonrAddr, err := bech32.ConvertAndEncode("idx", valKs.GetPublicKey())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cnfg, err := vfs.NewDWNConfigFile(usrKsJSON, sonrAddr, chainID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fileMap := map[string]files.Node{
|
||||
"config.json": cnfg,
|
||||
"sw.js": vfs.SWJSFile(),
|
||||
"app.wasm": vfs.DWNWasmFile(),
|
||||
"index.html": vfs.IndexFile(),
|
||||
}
|
||||
return &Vault{
|
||||
FS: files.NewMapDirectory(fileMap),
|
||||
ValKs: valKs,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// AssembleVault assembles the initial vault
|
||||
func (k Keeper) AssembleVault(ctx Context, subject string, origin string) (string, int64, error) {
|
||||
v, err := NewVault(subject, origin, "sonr-testnet")
|
||||
if err != nil {
|
||||
return "", 0, err
|
||||
}
|
||||
cid, err := k.ipfsClient.Unixfs().Add(context.Background(), v.FS)
|
||||
if err != nil {
|
||||
return "", 0, err
|
||||
}
|
||||
return cid.String(), ctx.CalculateExpiration(time.Second * 15), nil
|
||||
}
|
||||
|
||||
// PinVaultController pins the initial vault to the local IPFS node
|
||||
func (k Keeper) PinVaultController(_ sdk.Context, cid string, address string) (bool, error) {
|
||||
// Resolve the path
|
||||
path, err := path.NewPath(cid)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// 1. Initialize vault.db sqlite database in local IPFS with Mount
|
||||
|
||||
// 2. Insert the InitialWalletAccounts
|
||||
|
||||
// 3. Publish the path to the IPNS
|
||||
_, err = k.ipfsClient.Name().Publish(context.Background(), path, options.Name.Key(address))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// 4. Insert the accounts into x/auth
|
||||
|
||||
// 5. Insert the controller into state
|
||||
return true, nil
|
||||
}
|
@ -30,6 +30,9 @@ func init() {
|
||||
// RegisterLegacyAminoCodec registers concrete types on the LegacyAmino codec
|
||||
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
||||
cdc.RegisterConcrete(&MsgUpdateParams{}, ModuleName+"/MsgUpdateParams", nil)
|
||||
cdc.RegisterConcrete(&MsgRegisterController{}, ModuleName+"/MsgRegisterController", nil)
|
||||
cdc.RegisterConcrete(&MsgRegisterService{}, ModuleName+"/MsgRegisterService", nil)
|
||||
cdc.RegisterConcrete(&MsgAllocateVault{}, ModuleName+"/MsgAllocateVault", nil)
|
||||
}
|
||||
|
||||
func RegisterInterfaces(registry types.InterfaceRegistry) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user