diff --git a/Makefile b/Makefile index 87cf4f835..fda10386a 100644 --- a/Makefile +++ b/Makefile @@ -286,7 +286,10 @@ testnet-basic: setup-testnet sh-testnet: mod-tidy CHAIN_ID="sonr-testnet-1" BLOCK_TIME="1000ms" CLEAN=true sh scripts/test_node.sh -.PHONY: setup-testnet set-testnet-configs testnet testnet-basic sh-testnet +buf-publish: + cd ./proto && bunx buf dep update && bunx buf build && bunx buf push + +.PHONY: setup-testnet set-testnet-configs testnet testnet-basic sh-testnet buf-publish ############################################################################### ### help ### diff --git a/deploy/local/devbox.json b/deploy/local/devbox.json new file mode 100644 index 000000000..7161a4296 --- /dev/null +++ b/deploy/local/devbox.json @@ -0,0 +1,34 @@ +{ + "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.12.0/.schema/devbox.schema.json", + "packages": [ + "go@1.22", + "bun@latest", + "ipfs@latest", + "skate@latest", + "air@latest", + "templ@latest" + ], + "env": { + "GOPATH": "$HOME/go", + "CHAIN_ID": "sonr-testnet-1", + "DENOM": "usnr", + "KEYRING": "test", + "MONIKER": "florence", + "BINARY": "sonrd", + "ACC0_NAME": "acc0", + "ACC1_NAME": "acc1", + "ACC0_ADDRESS": "idx1efd63aw40lxf3n4mhf7dzhjkr453axur9vjt6y", + "ACC1_ADDRESS": "idx1hj5fveer5cjtn4wd6wstzugjfdxzl0xpecp0nd", + "ACC0_MNEMONIC": "$(skate get ACC0_MNEMONIC)", + "ACC1_MNEMONIC": "$(skate get ACC1_MNEMONIC)" + }, + "shell": { + "init_hook": ["export ROOT=$(git rev-parse --show-toplevel)"], + "scripts": { + "devnet": ["cd $ROOT", "make sh-testnet"], + "ipfs": ["ipfs daemon"], + "air": ["cd $ROOT", "air"], + "gex": ["gex"] + } + } +} diff --git a/deploy/local/devbox.lock b/deploy/local/devbox.lock new file mode 100644 index 000000000..e2633ad0f --- /dev/null +++ b/deploy/local/devbox.lock @@ -0,0 +1,251 @@ +{ + "lockfile_version": "1", + "packages": { + "air@latest": { + "last_modified": "2024-11-16T04:25:12Z", + "resolved": "github:NixOS/nixpkgs/34a626458d686f1b58139620a8b2793e9e123bba#air", + "source": "devbox-search", + "version": "1.61.1", + "systems": { + "aarch64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/0s90vbnmsyyixs0991md21pbrw8babfb-air-1.61.1", + "default": true + } + ], + "store_path": "/nix/store/0s90vbnmsyyixs0991md21pbrw8babfb-air-1.61.1" + }, + "aarch64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/8mpw2asxs297v26fxqy2y1bq438f344l-air-1.61.1", + "default": true + } + ], + "store_path": "/nix/store/8mpw2asxs297v26fxqy2y1bq438f344l-air-1.61.1" + }, + "x86_64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/abminkf7ldqf9vm14xx5wvsrdx3wrvy6-air-1.61.1", + "default": true + } + ], + "store_path": "/nix/store/abminkf7ldqf9vm14xx5wvsrdx3wrvy6-air-1.61.1" + }, + "x86_64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/ajx8v5rbbvglncb97yybg3x9kn95gfrm-air-1.61.1", + "default": true + } + ], + "store_path": "/nix/store/ajx8v5rbbvglncb97yybg3x9kn95gfrm-air-1.61.1" + } + } + }, + "bun@latest": { + "last_modified": "2024-11-18T00:41:09Z", + "resolved": "github:NixOS/nixpkgs/5083ec887760adfe12af64830a66807423a859a7#bun", + "source": "devbox-search", + "version": "1.1.34", + "systems": { + "aarch64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/xnj00gq1mfffvgyisghk4m9f38gc5c5c-bun-1.1.34", + "default": true + } + ], + "store_path": "/nix/store/xnj00gq1mfffvgyisghk4m9f38gc5c5c-bun-1.1.34" + }, + "aarch64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/kccpzv8fb7swmmxbhv805qzq242rhy33-bun-1.1.34", + "default": true + } + ], + "store_path": "/nix/store/kccpzv8fb7swmmxbhv805qzq242rhy33-bun-1.1.34" + }, + "x86_64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/8h5k3l4fpgs3al2wvna7x9ybyyc8k36d-bun-1.1.34", + "default": true + } + ], + "store_path": "/nix/store/8h5k3l4fpgs3al2wvna7x9ybyyc8k36d-bun-1.1.34" + }, + "x86_64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/x089g4srqw71w5jnc87vxbh7m12498i0-bun-1.1.34", + "default": true + } + ], + "store_path": "/nix/store/x089g4srqw71w5jnc87vxbh7m12498i0-bun-1.1.34" + } + } + }, + "go@1.22": { + "last_modified": "2024-11-16T04:25:12Z", + "resolved": "github:NixOS/nixpkgs/34a626458d686f1b58139620a8b2793e9e123bba#go_1_22", + "source": "devbox-search", + "version": "1.22.9", + "systems": { + "aarch64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/4nf51i4ah186y2jy3fad2fyvpa49qx6q-go-1.22.9", + "default": true + } + ], + "store_path": "/nix/store/4nf51i4ah186y2jy3fad2fyvpa49qx6q-go-1.22.9" + }, + "aarch64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/8w8vzwgp55yl8j1ljgm4wzdgjkvkv5v3-go-1.22.9", + "default": true + } + ], + "store_path": "/nix/store/8w8vzwgp55yl8j1ljgm4wzdgjkvkv5v3-go-1.22.9" + }, + "x86_64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/vlih7j78ki05i8nvzdsxvws7a7ksq04m-go-1.22.9", + "default": true + } + ], + "store_path": "/nix/store/vlih7j78ki05i8nvzdsxvws7a7ksq04m-go-1.22.9" + }, + "x86_64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/frc5188kgv3ws0n999c7cy5vi2f8k4jp-go-1.22.9", + "default": true + } + ], + "store_path": "/nix/store/frc5188kgv3ws0n999c7cy5vi2f8k4jp-go-1.22.9" + } + } + }, + "ipfs@latest": { + "last_modified": "2023-02-24T09:01:09Z", + "resolved": "github:NixOS/nixpkgs/7d0ed7f2e5aea07ab22ccb338d27fbe347ed2f11#ipfs", + "source": "devbox-search", + "version": "0.17.0" + }, + "skate@latest": { + "last_modified": "2024-11-16T04:25:12Z", + "resolved": "github:NixOS/nixpkgs/34a626458d686f1b58139620a8b2793e9e123bba#skate", + "source": "devbox-search", + "version": "1.0.0", + "systems": { + "aarch64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/q6yhpyfbqiabyic6ymx5rp2db62bnbvr-skate-1.0.0", + "default": true + } + ], + "store_path": "/nix/store/q6yhpyfbqiabyic6ymx5rp2db62bnbvr-skate-1.0.0" + }, + "aarch64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/q55dbgvc4xwvr2g02dks6j2j699qni2k-skate-1.0.0", + "default": true + } + ], + "store_path": "/nix/store/q55dbgvc4xwvr2g02dks6j2j699qni2k-skate-1.0.0" + }, + "x86_64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/s1hy525y8ciya3nrns9kryy3jlcw8igv-skate-1.0.0", + "default": true + } + ], + "store_path": "/nix/store/s1hy525y8ciya3nrns9kryy3jlcw8igv-skate-1.0.0" + }, + "x86_64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/8s03iazymz77nv6pjxpz7wair0m646wv-skate-1.0.0", + "default": true + } + ], + "store_path": "/nix/store/8s03iazymz77nv6pjxpz7wair0m646wv-skate-1.0.0" + } + } + }, + "templ@latest": { + "last_modified": "2024-11-16T04:25:12Z", + "resolved": "github:NixOS/nixpkgs/34a626458d686f1b58139620a8b2793e9e123bba#templ", + "source": "devbox-search", + "version": "0.2.793", + "systems": { + "aarch64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/ivargvf76g71k5gk3iz4al52rsy28w38-templ-0.2.793", + "default": true + } + ], + "store_path": "/nix/store/ivargvf76g71k5gk3iz4al52rsy28w38-templ-0.2.793" + }, + "aarch64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/03654iddn006yx5j1lqq496hax60v8p5-templ-0.2.793", + "default": true + } + ], + "store_path": "/nix/store/03654iddn006yx5j1lqq496hax60v8p5-templ-0.2.793" + }, + "x86_64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/blvd5wbd1ix6m745s4zx3b84kwzprshq-templ-0.2.793", + "default": true + } + ], + "store_path": "/nix/store/blvd5wbd1ix6m745s4zx3b84kwzprshq-templ-0.2.793" + }, + "x86_64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/sn5h79d36r86i6a8rm1k52c2ij1s32kx-templ-0.2.793", + "default": true + } + ], + "store_path": "/nix/store/sn5h79d36r86i6a8rm1k52c2ij1s32kx-templ-0.2.793" + } + } + } + } +} diff --git a/deploy/local/process-compose.yaml b/deploy/local/process-compose.yaml new file mode 100644 index 000000000..67e41333f --- /dev/null +++ b/deploy/local/process-compose.yaml @@ -0,0 +1,28 @@ +version: "0.6" + +processes: + ipfs: + namespace: testnet + command: "devbox run ipfs" + background: true + availability: + restart: never + max_restarts: 0 + + sonr: + namespace: testnet + background: true + command: "devbox run devnet" + restart: never + max_restarts: 1 + depends: + - ipfs + + hway-air: + namespace: testnet + background: true + command: "devbox run air" + restart: never + max_restarts: 1 + depends: + - sonr diff --git a/deploy/testnet/devbox.json b/deploy/testnet/devbox.json new file mode 100644 index 000000000..637c1b677 --- /dev/null +++ b/deploy/testnet/devbox.json @@ -0,0 +1,43 @@ +{ + "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.12.0/.schema/devbox.schema.json", + "packages": [ + "go@1.22", + "bun@latest", + "ipfs@latest", + "air@latest", + "templ@latest" + ], + "env": { + "GOPATH": "$HOME/go", + "PATH": "./build:$HOME/go/bin:$PATH", + "CHAIN_ID": "sonr-testnet-1", + "DENOM": "usnr", + "KEYRING": "test", + "MONIKER": "florence", + "BINARY": "sonrd", + "ACC0_NAME": "acc0", + "ACC1_NAME": "acc1", + "ACC0_ADDRESS": "idx1efd63aw40lxf3n4mhf7dzhjkr453axur9vjt6y", + "ACC1_ADDRESS": "idx1hj5fveer5cjtn4wd6wstzugjfdxzl0xpecp0nd", + "ACC0_MNEMONIC": "$(skate get ACC0_MNEMONIC)", + "ACC1_MNEMONIC": "$(skate get ACC1_MNEMONIC)", + "TUNNEL_TOKEN": "$(skate get CLOUDFLARE_TUNNEL_TOKEN)", + "TEMPL_EXPERIMENT": "rawgo", + "R2_CDN_BUCKET": "cdn", + "R2_PKL_BUCKET": "pkljar" + }, + "shell": { + "init_hook": ["export ROOT=$(git rev-parse --show-toplevel)"], + "scripts": { + "start:testnet": ["make sh-testnet"], + "start:ipfs": ["sh scripts/setup_ipfs.sh"], + "start:air": ["air"], + "start:gex": ["go install github.com/cosmos/gex@latest", "gex"], + "gen:pkl": ["make gen-pkl"], + "gen:templ": ["make gen-templ"], + "buf-push": [ + "cd ./proto && bunx buf dep update && bunx buf build && bunx buf push" + ] + } + } +} diff --git a/process-compose.yaml b/deploy/testnet/process-compose.yaml similarity index 77% rename from process-compose.yaml rename to deploy/testnet/process-compose.yaml index 40f822b48..bb0f06d2e 100644 --- a/process-compose.yaml +++ b/deploy/testnet/process-compose.yaml @@ -3,7 +3,7 @@ version: "0.6" processes: ipfs: namespace: testnet - command: "sh scripts/setup_ipfs.sh" + command: "devbox run start:ipfs" background: true availability: restart: never @@ -12,7 +12,7 @@ processes: sonr: namespace: testnet background: true - command: "make sh-testnet" + command: "devbox run start:testnet" restart: never max_restarts: 1 depends: diff --git a/devbox.json b/devbox.json index e767e1d03..bc31be2f9 100644 --- a/devbox.json +++ b/devbox.json @@ -1,42 +1,17 @@ { "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.12.0/.schema/devbox.schema.json", - "packages": [ - "go@1.22", - "bun@latest", - "ipfs@latest", - "air@latest", - "templ@latest" - ], + "packages": ["go@1.22", "bun@latest", "ipfs@latest", "templ@latest"], "env": { "GOPATH": "$HOME/go", "PATH": "./build:$HOME/go/bin:$PATH", - "CHAIN_ID": "sonr-testnet-1", - "DENOM": "usnr", - "KEYRING": "test", - "MONIKER": "florence", - "BINARY": "sonrd", - "ACC0_NAME": "acc0", - "ACC1_NAME": "acc1", - "ACC0_ADDRESS": "idx1efd63aw40lxf3n4mhf7dzhjkr453axur9vjt6y", - "ACC1_ADDRESS": "idx1hj5fveer5cjtn4wd6wstzugjfdxzl0xpecp0nd", - "ACC0_MNEMONIC": "$(skate get ACC0_MNEMONIC)", - "ACC1_MNEMONIC": "$(skate get ACC1_MNEMONIC)", - "TUNNEL_TOKEN": "$(skate get CLOUDFLARE_TUNNEL_TOKEN)", - "TEMPL_EXPERIMENT": "rawgo", - "R2_CDN_BUCKET": "cdn", - "R2_PKL_BUCKET": "pkljar" + "TEMPL_EXPERIMENT": "rawgo" }, "shell": { + "init_hook": ["./scripts/init_env.sh"], "scripts": { - "gen:pkl": [ - "make gen-pkl" - ], - "gen:templ": [ - "make gen-templ" - ], - "buf-push": [ - "cd ./proto && bunx buf dep update && bunx buf build && bunx buf push" - ] + "start-local": ["cd deploy/local && devbox services up"], + "start-testnet": ["cd deploy/testnet && devbox services up"], + "start-gex": ["go install github.com/cosmos/gex@latest", "gex"] } } } diff --git a/devbox.lock b/devbox.lock index c2759642a..d498be17a 100644 --- a/devbox.lock +++ b/devbox.lock @@ -1,54 +1,6 @@ { "lockfile_version": "1", "packages": { - "air@latest": { - "last_modified": "2024-11-16T04:25:12Z", - "resolved": "github:NixOS/nixpkgs/34a626458d686f1b58139620a8b2793e9e123bba#air", - "source": "devbox-search", - "version": "1.61.1", - "systems": { - "aarch64-darwin": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/0s90vbnmsyyixs0991md21pbrw8babfb-air-1.61.1", - "default": true - } - ], - "store_path": "/nix/store/0s90vbnmsyyixs0991md21pbrw8babfb-air-1.61.1" - }, - "aarch64-linux": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/8mpw2asxs297v26fxqy2y1bq438f344l-air-1.61.1", - "default": true - } - ], - "store_path": "/nix/store/8mpw2asxs297v26fxqy2y1bq438f344l-air-1.61.1" - }, - "x86_64-darwin": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/abminkf7ldqf9vm14xx5wvsrdx3wrvy6-air-1.61.1", - "default": true - } - ], - "store_path": "/nix/store/abminkf7ldqf9vm14xx5wvsrdx3wrvy6-air-1.61.1" - }, - "x86_64-linux": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/ajx8v5rbbvglncb97yybg3x9kn95gfrm-air-1.61.1", - "default": true - } - ], - "store_path": "/nix/store/ajx8v5rbbvglncb97yybg3x9kn95gfrm-air-1.61.1" - } - } - }, "bun@latest": { "last_modified": "2024-10-23T04:36:58Z", "resolved": "github:NixOS/nixpkgs/dfffb2e7a52d29a0ef8e21ec8a0f30487b227f1a#bun", @@ -149,17 +101,7 @@ "last_modified": "2023-02-24T09:01:09Z", "resolved": "github:NixOS/nixpkgs/7d0ed7f2e5aea07ab22ccb338d27fbe347ed2f11#ipfs", "source": "devbox-search", - "version": "0.17.0", - "systems": { - "aarch64-darwin": { - "outputs": [ - { - "path": "/nix/store/1azparhiwjzxgpkswpqnapzw0bfb7vl7-kubo-0.17.0", - "default": true - } - ] - } - } + "version": "0.17.0" }, "templ@latest": { "last_modified": "2024-10-13T23:44:06Z", diff --git a/pkg/services/credentials/scripts_templ.go b/pkg/services/credentials/scripts_templ.go index a12f1871e..a6646451f 100644 --- a/pkg/services/credentials/scripts_templ.go +++ b/pkg/services/credentials/scripts_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package credentials //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/services/payments/scripts_templ.go b/pkg/services/payments/scripts_templ.go index 63f0fa290..d75fc7134 100644 --- a/pkg/services/payments/scripts_templ.go +++ b/pkg/services/payments/scripts_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package payments diff --git a/pkg/services/storage/scripts_templ.go b/pkg/services/storage/scripts_templ.go index aeed45ca9..b413849b6 100644 --- a/pkg/services/storage/scripts_templ.go +++ b/pkg/services/storage/scripts_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package storage //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/components/auth/authorize_templ.go b/pkg/webapp/components/auth/authorize_templ.go index 961b0b757..ad2c23bf7 100644 --- a/pkg/webapp/components/auth/authorize_templ.go +++ b/pkg/webapp/components/auth/authorize_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package auth //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/components/auth/create_credential_templ.go b/pkg/webapp/components/auth/create_credential_templ.go index eea1973f6..11f0103ea 100644 --- a/pkg/webapp/components/auth/create_credential_templ.go +++ b/pkg/webapp/components/auth/create_credential_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package auth //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/components/auth/get_credential_templ.go b/pkg/webapp/components/auth/get_credential_templ.go index 75368de9a..bfb597672 100644 --- a/pkg/webapp/components/auth/get_credential_templ.go +++ b/pkg/webapp/components/auth/get_credential_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package auth //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/components/auth/login_templ.go b/pkg/webapp/components/auth/login_templ.go index 6951af203..f7251cb92 100644 --- a/pkg/webapp/components/auth/login_templ.go +++ b/pkg/webapp/components/auth/login_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package auth //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/components/auth/register_start_templ.go b/pkg/webapp/components/auth/register_start_templ.go index 717370e4d..35ee1d9f5 100644 --- a/pkg/webapp/components/auth/register_start_templ.go +++ b/pkg/webapp/components/auth/register_start_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package auth //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/components/auth/register_templ.go b/pkg/webapp/components/auth/register_templ.go index 17449b7c6..231cc7bcf 100644 --- a/pkg/webapp/components/auth/register_templ.go +++ b/pkg/webapp/components/auth/register_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package auth //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/components/landing/arch_templ.go b/pkg/webapp/components/landing/arch_templ.go index e5e8a1b2e..81225c9f9 100644 --- a/pkg/webapp/components/landing/arch_templ.go +++ b/pkg/webapp/components/landing/arch_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package landing //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/components/landing/cta_templ.go b/pkg/webapp/components/landing/cta_templ.go index a3a12ab86..8414bbef0 100644 --- a/pkg/webapp/components/landing/cta_templ.go +++ b/pkg/webapp/components/landing/cta_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package landing //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/components/landing/footer_templ.go b/pkg/webapp/components/landing/footer_templ.go index c3000b9d2..2621849e4 100644 --- a/pkg/webapp/components/landing/footer_templ.go +++ b/pkg/webapp/components/landing/footer_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package landing diff --git a/pkg/webapp/components/landing/header_templ.go b/pkg/webapp/components/landing/header_templ.go index bd4e740f3..2a948dbb9 100644 --- a/pkg/webapp/components/landing/header_templ.go +++ b/pkg/webapp/components/landing/header_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package landing //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/components/landing/hero_templ.go b/pkg/webapp/components/landing/hero_templ.go index fb3bd7f42..d3cd16ae9 100644 --- a/pkg/webapp/components/landing/hero_templ.go +++ b/pkg/webapp/components/landing/hero_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package landing //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/components/landing/highlights_templ.go b/pkg/webapp/components/landing/highlights_templ.go index 2d3b62e7d..753f3be5f 100644 --- a/pkg/webapp/components/landing/highlights_templ.go +++ b/pkg/webapp/components/landing/highlights_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package landing //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/components/landing/lowlights_templ.go b/pkg/webapp/components/landing/lowlights_templ.go index ad8b1b5a7..1bd2e3dfb 100644 --- a/pkg/webapp/components/landing/lowlights_templ.go +++ b/pkg/webapp/components/landing/lowlights_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package landing //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/components/landing/mission_templ.go b/pkg/webapp/components/landing/mission_templ.go index 33347e3c0..2fccf7548 100644 --- a/pkg/webapp/components/landing/mission_templ.go +++ b/pkg/webapp/components/landing/mission_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package landing //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/components/ui/badges_templ.go b/pkg/webapp/components/ui/badges_templ.go index 606c77c21..ffc481bfa 100644 --- a/pkg/webapp/components/ui/badges_templ.go +++ b/pkg/webapp/components/ui/badges_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package ui //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/components/ui/buttons_templ.go b/pkg/webapp/components/ui/buttons_templ.go index 899f2633b..e53fd6e65 100644 --- a/pkg/webapp/components/ui/buttons_templ.go +++ b/pkg/webapp/components/ui/buttons_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package ui //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/components/ui/cards_templ.go b/pkg/webapp/components/ui/cards_templ.go index fdae71090..ca641cded 100644 --- a/pkg/webapp/components/ui/cards_templ.go +++ b/pkg/webapp/components/ui/cards_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package ui //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/components/ui/icon_templ.go b/pkg/webapp/components/ui/icon_templ.go index c19814e20..616b2de8c 100644 --- a/pkg/webapp/components/ui/icon_templ.go +++ b/pkg/webapp/components/ui/icon_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package ui //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/components/ui/layout_templ.go b/pkg/webapp/components/ui/layout_templ.go index 093fe9b8b..8aa496d19 100644 --- a/pkg/webapp/components/ui/layout_templ.go +++ b/pkg/webapp/components/ui/layout_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package ui //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/components/ui/panels_templ.go b/pkg/webapp/components/ui/panels_templ.go index 439d6a52e..a7df7e25c 100644 --- a/pkg/webapp/components/ui/panels_templ.go +++ b/pkg/webapp/components/ui/panels_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package ui //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/components/ui/scripts_templ.go b/pkg/webapp/components/ui/scripts_templ.go index 71d6f3d5e..86e24b9d6 100644 --- a/pkg/webapp/components/ui/scripts_templ.go +++ b/pkg/webapp/components/ui/scripts_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package ui //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/components/ui/sizes_templ.go b/pkg/webapp/components/ui/sizes_templ.go index 09a5f47c3..52047ba52 100644 --- a/pkg/webapp/components/ui/sizes_templ.go +++ b/pkg/webapp/components/ui/sizes_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package ui //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/components/ui/typography_templ.go b/pkg/webapp/components/ui/typography_templ.go index fc49235a8..c0ac9d207 100644 --- a/pkg/webapp/components/ui/typography_templ.go +++ b/pkg/webapp/components/ui/typography_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package ui //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/pages/auth_templ.go b/pkg/webapp/pages/auth_templ.go index 1e9cc4ff4..79fcf26db 100644 --- a/pkg/webapp/pages/auth_templ.go +++ b/pkg/webapp/pages/auth_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package pages //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/pages/dashboard_templ.go b/pkg/webapp/pages/dashboard_templ.go index 4708ea891..ed2ca5ca4 100644 --- a/pkg/webapp/pages/dashboard_templ.go +++ b/pkg/webapp/pages/dashboard_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package pages //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/pkg/webapp/pages/landing_templ.go b/pkg/webapp/pages/landing_templ.go index 912b46b8f..4efb12569 100644 --- a/pkg/webapp/pages/landing_templ.go +++ b/pkg/webapp/pages/landing_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.2.778 +// templ: version: v0.2.793 package pages diff --git a/pkl/README.md b/pkl/README.md deleted file mode 100644 index e32b62034..000000000 --- a/pkl/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# pkl - -This is a project to generate a language-agnostic, type-safe, and idiomatic -Go code from a [Pkl](https://pkl-lang.org) file. diff --git a/scripts/init_env.sh b/scripts/init_env.sh old mode 100644 new mode 100755 index f1f641af1..236e666d2 --- a/scripts/init_env.sh +++ b/scripts/init_env.sh @@ -1 +1,27 @@ -#!/usr/bin/env bash +#!/bin/bash + +go install github.com/cosmos/gex@latest + +rm -rf ~/.ipfs + +# Initialize IPFS +ipfs init + +# Set up the Cloudflare IPFS gateway peers +ipfs config --json Peering.Peers '[ +{"ID": "QmcFf2FH3CEgTNHeMRGhN7HNHU1EXAxoEk6EFuSyXCsvRE", "Addrs": ["/dnsaddr/node-1.ingress.cloudflare-ipfs.com"]}, +{"ID": "QmcFmLd5ySfk2WZuJ1mfSWLDjdmHZq7rSAua4GoeSQfs1z", "Addrs": ["/dnsaddr/node-2.ingress.cloudflare-ipfs.com"]}, +{"ID": "QmcfFmzSDVbwexQ9Au2pt5YEXHK5xajwgaU6PpkbLWerMa", "Addrs": ["/dnsaddr/node-3.ingress.cloudflare-ipfs.com"]}, +{"ID": "QmcfJeB3Js1FG7T8YaZATEiaHqNKVdQfybYYkbT1knUswx", "Addrs": ["/dnsaddr/node-4.ingress.cloudflare-ipfs.com"]}, +{"ID": "QmcfVvzK4tMdFmpJjEKDUoqRgP4W9FnmJoziYX5GXJJ8eZ", "Addrs": ["/dnsaddr/node-5.ingress.cloudflare-ipfs.com"]}, +{"ID": "QmcfZD3VKrUxyP9BbyUnZDpbqDnT7cQ4WjPP8TRLXaoE7G", "Addrs": ["/dnsaddr/node-6.ingress.cloudflare-ipfs.com"]}, +{"ID": "QmcfZP2LuW4jxviTeG8fi28qjnZScACb8PEgHAc17ZEri3", "Addrs": ["/dnsaddr/node-7.ingress.cloudflare-ipfs.com"]}, +{"ID": "QmcfgsJsMtx6qJb74akCw1M24X1zFwgGo11h1cuhwQjtJP", "Addrs": ["/dnsaddr/node-8.ingress.cloudflare-ipfs.com"]}, +{"ID": "Qmcfr2FC7pFzJbTSDfYaSy1J8Uuy8ccGLeLyqJCKJvTHMi", "Addrs": ["/dnsaddr/node-9.ingress.cloudflare-ipfs.com"]}, +{"ID": "QmcfR3V5YAtHBzxVACWCzXTt26SyEkxdwhGJ6875A8BuWx", "Addrs": ["/dnsaddr/node-10.ingress.cloudflare-ipfs.com"]}, +{"ID": "Qmcfuo1TM9uUiJp6dTbm915Rf1aTqm3a3dnmCdDQLHgvL5", "Addrs": ["/dnsaddr/node-11.ingress.cloudflare-ipfs.com"]}, +{"ID": "QmcfV2sg9zaq7UUHVCGuSvT2M2rnLBAPsiE79vVyK3Cuev", "Addrs": ["/dnsaddr/node-12.ingress.cloudflare-ipfs.com"]} +]' + +# Make sure ipfs is publicly accessible +ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]' diff --git a/scripts/setup_ipfs.sh b/scripts/setup_ipfs.sh deleted file mode 100755 index b98c18d5a..000000000 --- a/scripts/setup_ipfs.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -rm -rf ~/.ipfs - -# Initialize IPFS -ipfs init - -# Set up the Cloudflare IPFS gateway peers -ipfs config --json Peering.Peers '[ -{"ID": "QmcFf2FH3CEgTNHeMRGhN7HNHU1EXAxoEk6EFuSyXCsvRE", "Addrs": ["/dnsaddr/node-1.ingress.cloudflare-ipfs.com"]}, -{"ID": "QmcFmLd5ySfk2WZuJ1mfSWLDjdmHZq7rSAua4GoeSQfs1z", "Addrs": ["/dnsaddr/node-2.ingress.cloudflare-ipfs.com"]}, -{"ID": "QmcfFmzSDVbwexQ9Au2pt5YEXHK5xajwgaU6PpkbLWerMa", "Addrs": ["/dnsaddr/node-3.ingress.cloudflare-ipfs.com"]}, -{"ID": "QmcfJeB3Js1FG7T8YaZATEiaHqNKVdQfybYYkbT1knUswx", "Addrs": ["/dnsaddr/node-4.ingress.cloudflare-ipfs.com"]}, -{"ID": "QmcfVvzK4tMdFmpJjEKDUoqRgP4W9FnmJoziYX5GXJJ8eZ", "Addrs": ["/dnsaddr/node-5.ingress.cloudflare-ipfs.com"]}, -{"ID": "QmcfZD3VKrUxyP9BbyUnZDpbqDnT7cQ4WjPP8TRLXaoE7G", "Addrs": ["/dnsaddr/node-6.ingress.cloudflare-ipfs.com"]}, -{"ID": "QmcfZP2LuW4jxviTeG8fi28qjnZScACb8PEgHAc17ZEri3", "Addrs": ["/dnsaddr/node-7.ingress.cloudflare-ipfs.com"]}, -{"ID": "QmcfgsJsMtx6qJb74akCw1M24X1zFwgGo11h1cuhwQjtJP", "Addrs": ["/dnsaddr/node-8.ingress.cloudflare-ipfs.com"]}, -{"ID": "Qmcfr2FC7pFzJbTSDfYaSy1J8Uuy8ccGLeLyqJCKJvTHMi", "Addrs": ["/dnsaddr/node-9.ingress.cloudflare-ipfs.com"]}, -{"ID": "QmcfR3V5YAtHBzxVACWCzXTt26SyEkxdwhGJ6875A8BuWx", "Addrs": ["/dnsaddr/node-10.ingress.cloudflare-ipfs.com"]}, -{"ID": "Qmcfuo1TM9uUiJp6dTbm915Rf1aTqm3a3dnmCdDQLHgvL5", "Addrs": ["/dnsaddr/node-11.ingress.cloudflare-ipfs.com"]}, -{"ID": "QmcfV2sg9zaq7UUHVCGuSvT2M2rnLBAPsiE79vVyK3Cuev", "Addrs": ["/dnsaddr/node-12.ingress.cloudflare-ipfs.com"]} -]' - -# Make sure ipfs is publicly accessible -ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]' - -ipfs daemon diff --git a/slumber.yml b/slumber.yml deleted file mode 100644 index 158c1a8b5..000000000 --- a/slumber.yml +++ /dev/null @@ -1,45 +0,0 @@ -# For basic usage info, see: -# https://slumber.lucaspickering.me/book/getting_started.html -# For all collection options, see: -# https://slumber.lucaspickering.me/book/api/request_collection/index.html - -# Profiles are groups of data you can easily switch between. A common usage is -# to define profiles for various environments of a REST service -# slumber.yml -profiles: - local: - data: - host: http://localhost:1317 - production: - data: - host: https://api.sonr.id - -requests: - did: !folder - name: Params - requests: - did_params: !request - method: GET - url: "{{host}}/did/v1/params" - macaroon_params: !request - method: GET - url: "{{host}}/macaroon/v1/params" - service_params: !request - method: GET - url: "{{host}}/service/v1/params" - vault_params: !request - method: GET - url: "{{host}}/vault/v1/params" - - vault: !folder - name: Vault - requests: - vault_allocate: !request - method: GET - url: "{{host}}/vault/v1/allocate" - vault_schema: !request - method: GET - url: "{{host}}/vault/v1/schema" - vault_sync: !request - method: GET - url: "{{host}}/vault/v1/sync" diff --git a/web/libs/noble-client b/web/libs/noble-client deleted file mode 160000 index 712a041f4..000000000 --- a/web/libs/noble-client +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 712a041f4fa040be8c53ca0c701f961c59a22233 diff --git a/web/libs/osmosis-client b/web/libs/osmosis-client deleted file mode 160000 index e9529062b..000000000 --- a/web/libs/osmosis-client +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e9529062bc943894e14b67a48a665b0f7e4aabb4 diff --git a/web/libs/sonr-client b/web/libs/sonr-client deleted file mode 160000 index d002aa61f..000000000 --- a/web/libs/sonr-client +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d002aa61f0fed83c3227c146d329b58927975b5d diff --git a/web/workers/noble-client/.gitignore b/web/workers/noble-client/.gitignore new file mode 100644 index 000000000..90cfa7c2d --- /dev/null +++ b/web/workers/noble-client/.gitignore @@ -0,0 +1,5 @@ +node_modules +.DS_Store +.env +dist +out diff --git a/web/workers/noble-client/README.md b/web/workers/noble-client/README.md new file mode 100644 index 000000000..e83bd8757 --- /dev/null +++ b/web/workers/noble-client/README.md @@ -0,0 +1,9 @@ +# `noble-client` + +This is a Cloudflare Workers Durable Object that can be deployed to Cloudflare's edge network. + +It uses `noble-es` to provide a simple interface to interact with the Sonr network. + +## Usage + +### Deploying to Cloudflare diff --git a/web/workers/noble-client/package.json b/web/workers/noble-client/package.json new file mode 100644 index 000000000..b8b7b285d --- /dev/null +++ b/web/workers/noble-client/package.json @@ -0,0 +1,16 @@ +{ + "name": "noble-client", + "version": "0.0.0", + "private": true, + "scripts": { + "deploy": "wrangler deploy", + "dev": "wrangler dev", + "start": "wrangler dev" + }, + "devDependencies": { + "wrangler": "^3.60.3" + }, + "dependencies": { + "sonr-es": "^0.5.3" + } +} diff --git a/web/workers/noble-client/src/index.js b/web/workers/noble-client/src/index.js new file mode 100644 index 000000000..2ae2b739e --- /dev/null +++ b/web/workers/noble-client/src/index.js @@ -0,0 +1,45 @@ +export * from "./stub.js"; + +/** + * Welcome to Cloudflare Workers! This is your first Durable Objects application. + * + * - Run `npm run dev` in your terminal to start a development server + * - Open a browser tab at http://localhost:8787/ to see your Durable Object in action + * - Run `npm run deploy` to publish your application + * + * Learn more at https://developers.cloudflare.com/durable-objects + */ + +/** + * Env provides a mechanism to reference bindings declared in wrangler.toml within JavaScript + * + * @typedef {Object} Env + * @property {DurableObjectNamespace} NOBLE_DURABLE_CLIENT - The Durable Object namespace binding + */ + + +export default { + /** + * This is the standard fetch handler for a Cloudflare Worker + * + * @param {Request} request - The request submitted to the Worker from the client + * @param {Env} env - The interface to reference bindings declared in wrangler.toml + * @param {ExecutionContext} ctx - The execution context of the Worker + * @returns {Promise} The response to be sent back to the client + */ + async fetch(request, env, ctx) { + // We will create a `DurableObjectId` using the pathname from the Worker request + // This id refers to a unique instance of our 'MyDurableObject' class above + let id = env.NOBLE_DURABLE_CLIENT.idFromName(new URL(request.url).pathname); + + // This stub creates a communication channel with the Durable Object instance + // The Durable Object constructor will be invoked upon the first call for a given id + let stub = env.NOBLE_DURABLE_CLIENT.get(id); + + // We call the `sayHello()` RPC method on the stub to invoke the method on the remote + // Durable Object instance + let greeting = await stub.sayHello("world"); + + return new Response(greeting); + }, +}; diff --git a/web/workers/noble-client/src/stub.js b/web/workers/noble-client/src/stub.js new file mode 100644 index 000000000..10d27bb12 --- /dev/null +++ b/web/workers/noble-client/src/stub.js @@ -0,0 +1,26 @@ +import { DurableObject } from "cloudflare:workers"; + +/** A Durable Object's behavior is defined in an exported Javascript class */ +export class NobleDurableClient extends DurableObject { + /** + * The constructor is invoked once upon creation of the Durable Object, i.e. the first call to + * `DurableObjectStub::get` for a given identifier (no-op constructors can be omitted) + * + * @param {DurableObjectState} ctx - The interface for interacting with Durable Object state + * @param {Env} env - The interface to reference bindings declared in wrangler.toml + */ + constructor(ctx, env) { + super(ctx, env); + } + + /** + * The Durable Object exposes an RPC method sayHello which will be invoked when when a Durable + * Object instance receives a request from a Worker via the same method invocation on the stub + * + * @param {string} name - The name provided to a Durable Object instance from a Worker + * @returns {Promise} The greeting to be sent back to the Worker + */ + async sayHello(name) { + return `Hello, ${name}!`; + } +} diff --git a/web/workers/noble-client/wrangler.toml b/web/workers/noble-client/wrangler.toml new file mode 100644 index 000000000..8f4a4020a --- /dev/null +++ b/web/workers/noble-client/wrangler.toml @@ -0,0 +1,113 @@ +#:schema node_modules/wrangler/config-schema.json +name = "noble-client" +main = "src/index.js" +compatibility_date = "2024-11-12" + +# Workers Logs +# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/ +# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs +[observability] +enabled = true + +# Automatically place your workloads in an optimal location to minimize latency. +# If you are running back-end logic in a Worker, running it closer to your back-end infrastructure +# rather than the end user may result in better performance. +# Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement +# [placement] +# mode = "smart" + +# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables) +# Docs: +# - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables +# Note: Use secrets to store sensitive data. +# - https://developers.cloudflare.com/workers/configuration/secrets/ +# [vars] +# MY_VARIABLE = "production_value" + +# Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai +# [ai] +# binding = "AI" + +# Bind an Analytics Engine dataset. Use Analytics Engine to write analytics within your Pages Function. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets +# [[analytics_engine_datasets]] +# binding = "MY_DATASET" + +# Bind a headless browser instance running on Cloudflare's global network. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering +# [browser] +# binding = "MY_BROWSER" + +# Bind a D1 database. D1 is Cloudflare’s native serverless SQL database. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases +# [[d1_databases]] +# binding = "MY_DB" +# database_name = "my-database" +# database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + +# Bind a dispatch namespace. Use Workers for Platforms to deploy serverless functions programmatically on behalf of your customers. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms +# [[dispatch_namespaces]] +# binding = "MY_DISPATCHER" +# namespace = "my-namespace" + +# Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model. +# Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects +[[durable_objects.bindings]] +name = "NOBLE_DURABLE_CLIENT" +class_name = "NobleDurableClient" + +# Durable Object migrations. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#migrations +[[migrations]] +tag = "v1" +new_classes = ["NobleDurableClient"] + +# Bind a Hyperdrive configuration. Use to accelerate access to your existing databases from Cloudflare Workers. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive +# [[hyperdrive]] +# binding = "MY_HYPERDRIVE" +# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + +# Bind a KV Namespace. Use KV as persistent storage for small key-value pairs. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces +# [[kv_namespaces]] +# binding = "MY_KV_NAMESPACE" +# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + +# Bind an mTLS certificate. Use to present a client certificate when communicating with another service. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates +# [[mtls_certificates]] +# binding = "MY_CERTIFICATE" +# certificate_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + +# Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues +# [[queues.producers]] +# binding = "MY_QUEUE" +# queue = "my-queue" + +# Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues +# [[queues.consumers]] +# queue = "my-queue" + +# Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets +# [[r2_buckets]] +# binding = "MY_BUCKET" +# bucket_name = "my-bucket" + +# Bind another Worker service. Use this binding to call another Worker without network overhead. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings +# [[services]] +# binding = "MY_SERVICE" +# service = "my-service" + +# Bind a Vectorize index. Use to store and query vector embeddings for semantic search, classification and other vector search use-cases. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes +# [[vectorize]] +# binding = "MY_INDEX" +# index_name = "my-index" diff --git a/web/workers/osmosis-client/.gitignore b/web/workers/osmosis-client/.gitignore new file mode 100644 index 000000000..90cfa7c2d --- /dev/null +++ b/web/workers/osmosis-client/.gitignore @@ -0,0 +1,5 @@ +node_modules +.DS_Store +.env +dist +out diff --git a/web/workers/osmosis-client/README.md b/web/workers/osmosis-client/README.md new file mode 100644 index 000000000..c54afa25e --- /dev/null +++ b/web/workers/osmosis-client/README.md @@ -0,0 +1,10 @@ +# `osmosis-client` + +This is a Cloudflare Workers Durable Object that can be deployed to Cloudflare's edge network. + +It uses `osmosis-es` to provide a simple interface to interact with the Sonr network. + +## Usage + +### Deploying to Cloudflare + diff --git a/web/workers/osmosis-client/package.json b/web/workers/osmosis-client/package.json new file mode 100644 index 000000000..4dabb65ab --- /dev/null +++ b/web/workers/osmosis-client/package.json @@ -0,0 +1,16 @@ +{ + "name": "sonr-client", + "version": "0.0.0", + "private": true, + "scripts": { + "deploy": "wrangler deploy", + "dev": "wrangler dev", + "start": "wrangler dev" + }, + "devDependencies": { + "wrangler": "^3.60.3" + }, + "dependencies": { + "sonr-es": "^0.5.3" + } +} diff --git a/web/workers/osmosis-client/src/index.js b/web/workers/osmosis-client/src/index.js new file mode 100644 index 000000000..940c612d0 --- /dev/null +++ b/web/workers/osmosis-client/src/index.js @@ -0,0 +1,45 @@ +export * from "./stub.js"; + +/** + * Welcome to Cloudflare Workers! This is your first Durable Objects application. + * + * - Run `npm run dev` in your terminal to start a development server + * - Open a browser tab at http://localhost:8787/ to see your Durable Object in action + * - Run `npm run deploy` to publish your application + * + * Learn more at https://developers.cloudflare.com/durable-objects + */ + +/** + * Env provides a mechanism to reference bindings declared in wrangler.toml within JavaScript + * + * @typedef {Object} Env + * @property {DurableObjectNamespace} OSMOSIS_DURABLE_CLIENT - The Durable Object namespace binding + */ + + +export default { + /** + * This is the standard fetch handler for a Cloudflare Worker + * + * @param {Request} request - The request submitted to the Worker from the client + * @param {Env} env - The interface to reference bindings declared in wrangler.toml + * @param {ExecutionContext} ctx - The execution context of the Worker + * @returns {Promise} The response to be sent back to the client + */ + async fetch(request, env, ctx) { + // We will create a `DurableObjectId` using the pathname from the Worker request + // This id refers to a unique instance of our 'MyDurableObject' class above + let id = env.OSMOSIS_DURABLE_CLIENT.idFromName(new URL(request.url).pathname); + + // This stub creates a communication channel with the Durable Object instance + // The Durable Object constructor will be invoked upon the first call for a given id + let stub = env.OSMOSIS_DURABLE_CLIENT.get(id); + + // We call the `sayHello()` RPC method on the stub to invoke the method on the remote + // Durable Object instance + let greeting = await stub.sayHello("world"); + + return new Response(greeting); + }, +}; diff --git a/web/workers/osmosis-client/src/stub.js b/web/workers/osmosis-client/src/stub.js new file mode 100644 index 000000000..f2afbbace --- /dev/null +++ b/web/workers/osmosis-client/src/stub.js @@ -0,0 +1,26 @@ +import { DurableObject } from "cloudflare:workers"; + +/** A Durable Object's behavior is defined in an exported Javascript class */ +export class OsmosisDurableClient extends DurableObject { + /** + * The constructor is invoked once upon creation of the Durable Object, i.e. the first call to + * `DurableObjectStub::get` for a given identifier (no-op constructors can be omitted) + * + * @param {DurableObjectState} ctx - The interface for interacting with Durable Object state + * @param {Env} env - The interface to reference bindings declared in wrangler.toml + */ + constructor(ctx, env) { + super(ctx, env); + } + + /** + * The Durable Object exposes an RPC method sayHello which will be invoked when when a Durable + * Object instance receives a request from a Worker via the same method invocation on the stub + * + * @param {string} name - The name provided to a Durable Object instance from a Worker + * @returns {Promise} The greeting to be sent back to the Worker + */ + async sayHello(name) { + return `Hello, ${name}!`; + } +} diff --git a/web/workers/osmosis-client/wrangler.toml b/web/workers/osmosis-client/wrangler.toml new file mode 100644 index 000000000..e9a92ea58 --- /dev/null +++ b/web/workers/osmosis-client/wrangler.toml @@ -0,0 +1,113 @@ +#:schema node_modules/wrangler/config-schema.json +name = "osmosis-client" +main = "src/index.js" +compatibility_date = "2024-11-12" + +# Workers Logs +# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/ +# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs +[observability] +enabled = true + +# Automatically place your workloads in an optimal location to minimize latency. +# If you are running back-end logic in a Worker, running it closer to your back-end infrastructure +# rather than the end user may result in better performance. +# Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement +# [placement] +# mode = "smart" + +# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables) +# Docs: +# - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables +# Note: Use secrets to store sensitive data. +# - https://developers.cloudflare.com/workers/configuration/secrets/ +# [vars] +# MY_VARIABLE = "production_value" + +# Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai +# [ai] +# binding = "AI" + +# Bind an Analytics Engine dataset. Use Analytics Engine to write analytics within your Pages Function. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets +# [[analytics_engine_datasets]] +# binding = "MY_DATASET" + +# Bind a headless browser instance running on Cloudflare's global network. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering +# [browser] +# binding = "MY_BROWSER" + +# Bind a D1 database. D1 is Cloudflare’s native serverless SQL database. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases +# [[d1_databases]] +# binding = "MY_DB" +# database_name = "my-database" +# database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + +# Bind a dispatch namespace. Use Workers for Platforms to deploy serverless functions programmatically on behalf of your customers. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms +# [[dispatch_namespaces]] +# binding = "MY_DISPATCHER" +# namespace = "my-namespace" + +# Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model. +# Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects +[[durable_objects.bindings]] +name = "OSMOSIS_DURABLE_CLIENT" +class_name = "OsmosisDurableClient" + +# Durable Object migrations. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#migrations +[[migrations]] +tag = "v1" +new_classes = ["OsmosisDurableClient"] + +# Bind a Hyperdrive configuration. Use to accelerate access to your existing databases from Cloudflare Workers. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive +# [[hyperdrive]] +# binding = "MY_HYPERDRIVE" +# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + +# Bind a KV Namespace. Use KV as persistent storage for small key-value pairs. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces +# [[kv_namespaces]] +# binding = "MY_KV_NAMESPACE" +# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + +# Bind an mTLS certificate. Use to present a client certificate when communicating with another service. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates +# [[mtls_certificates]] +# binding = "MY_CERTIFICATE" +# certificate_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + +# Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues +# [[queues.producers]] +# binding = "MY_QUEUE" +# queue = "my-queue" + +# Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues +# [[queues.consumers]] +# queue = "my-queue" + +# Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets +# [[r2_buckets]] +# binding = "MY_BUCKET" +# bucket_name = "my-bucket" + +# Bind another Worker service. Use this binding to call another Worker without network overhead. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings +# [[services]] +# binding = "MY_SERVICE" +# service = "my-service" + +# Bind a Vectorize index. Use to store and query vector embeddings for semantic search, classification and other vector search use-cases. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes +# [[vectorize]] +# binding = "MY_INDEX" +# index_name = "my-index" diff --git a/web/workers/sonr-client/.gitignore b/web/workers/sonr-client/.gitignore new file mode 100644 index 000000000..90cfa7c2d --- /dev/null +++ b/web/workers/sonr-client/.gitignore @@ -0,0 +1,5 @@ +node_modules +.DS_Store +.env +dist +out diff --git a/web/workers/sonr-client/README.md b/web/workers/sonr-client/README.md new file mode 100644 index 000000000..40b5fb2c4 --- /dev/null +++ b/web/workers/sonr-client/README.md @@ -0,0 +1,10 @@ +# `sonr-client` + +This is a Cloudflare Workers Durable Object that can be deployed to Cloudflare's edge network. + +It uses `sonr-es` to provide a simple interface to interact with the Sonr network. + +## Usage + +### Deploying to Cloudflare + diff --git a/web/workers/sonr-client/bun.lockb b/web/workers/sonr-client/bun.lockb new file mode 100755 index 000000000..eab8f6254 Binary files /dev/null and b/web/workers/sonr-client/bun.lockb differ diff --git a/web/workers/sonr-client/package.json b/web/workers/sonr-client/package.json new file mode 100644 index 000000000..4dabb65ab --- /dev/null +++ b/web/workers/sonr-client/package.json @@ -0,0 +1,16 @@ +{ + "name": "sonr-client", + "version": "0.0.0", + "private": true, + "scripts": { + "deploy": "wrangler deploy", + "dev": "wrangler dev", + "start": "wrangler dev" + }, + "devDependencies": { + "wrangler": "^3.60.3" + }, + "dependencies": { + "sonr-es": "^0.5.3" + } +} diff --git a/web/workers/sonr-client/src/index.js b/web/workers/sonr-client/src/index.js new file mode 100644 index 000000000..ff8b8ae9f --- /dev/null +++ b/web/workers/sonr-client/src/index.js @@ -0,0 +1,45 @@ +export * from "./stub.js"; + +/** + * Welcome to Cloudflare Workers! This is your first Durable Objects application. + * + * - Run `npm run dev` in your terminal to start a development server + * - Open a browser tab at http://localhost:8787/ to see your Durable Object in action + * - Run `npm run deploy` to publish your application + * + * Learn more at https://developers.cloudflare.com/durable-objects + */ + +/** + * Env provides a mechanism to reference bindings declared in wrangler.toml within JavaScript + * + * @typedef {Object} Env + * @property {DurableObjectNamespace} SONR_DURABLE_CLIENT - The Durable Object namespace binding + */ + + +export default { + /** + * This is the standard fetch handler for a Cloudflare Worker + * + * @param {Request} request - The request submitted to the Worker from the client + * @param {Env} env - The interface to reference bindings declared in wrangler.toml + * @param {ExecutionContext} ctx - The execution context of the Worker + * @returns {Promise} The response to be sent back to the client + */ + async fetch(request, env, ctx) { + // We will create a `DurableObjectId` using the pathname from the Worker request + // This id refers to a unique instance of our 'MyDurableObject' class above + let id = env.SONR_DURABLE_CLIENT.idFromName(new URL(request.url).pathname); + + // This stub creates a communication channel with the Durable Object instance + // The Durable Object constructor will be invoked upon the first call for a given id + let stub = env.SONR_DURABLE_CLIENT.get(id); + + // We call the `sayHello()` RPC method on the stub to invoke the method on the remote + // Durable Object instance + let greeting = await stub.sayHello("world"); + + return new Response(greeting); + }, +}; diff --git a/web/workers/sonr-client/src/stub.js b/web/workers/sonr-client/src/stub.js new file mode 100644 index 000000000..c0ec6bb77 --- /dev/null +++ b/web/workers/sonr-client/src/stub.js @@ -0,0 +1,26 @@ +import { DurableObject } from "cloudflare:workers"; + +/** A Durable Object's behavior is defined in an exported Javascript class */ +export class SonrDurableClient extends DurableObject { + /** + * The constructor is invoked once upon creation of the Durable Object, i.e. the first call to + * `DurableObjectStub::get` for a given identifier (no-op constructors can be omitted) + * + * @param {DurableObjectState} ctx - The interface for interacting with Durable Object state + * @param {Env} env - The interface to reference bindings declared in wrangler.toml + */ + constructor(ctx, env) { + super(ctx, env); + } + + /** + * The Durable Object exposes an RPC method sayHello which will be invoked when when a Durable + * Object instance receives a request from a Worker via the same method invocation on the stub + * + * @param {string} name - The name provided to a Durable Object instance from a Worker + * @returns {Promise} The greeting to be sent back to the Worker + */ + async sayHello(name) { + return `Hello, ${name}!`; + } +} diff --git a/web/workers/sonr-client/wrangler.toml b/web/workers/sonr-client/wrangler.toml new file mode 100644 index 000000000..1ccb2aa5f --- /dev/null +++ b/web/workers/sonr-client/wrangler.toml @@ -0,0 +1,113 @@ +#:schema node_modules/wrangler/config-schema.json +name = "sonr-client" +main = "src/index.js" +compatibility_date = "2024-11-12" + +# Workers Logs +# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/ +# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs +[observability] +enabled = true + +# Automatically place your workloads in an optimal location to minimize latency. +# If you are running back-end logic in a Worker, running it closer to your back-end infrastructure +# rather than the end user may result in better performance. +# Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement +# [placement] +# mode = "smart" + +# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables) +# Docs: +# - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables +# Note: Use secrets to store sensitive data. +# - https://developers.cloudflare.com/workers/configuration/secrets/ +# [vars] +# MY_VARIABLE = "production_value" + +# Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai +# [ai] +# binding = "AI" + +# Bind an Analytics Engine dataset. Use Analytics Engine to write analytics within your Pages Function. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets +# [[analytics_engine_datasets]] +# binding = "MY_DATASET" + +# Bind a headless browser instance running on Cloudflare's global network. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering +# [browser] +# binding = "MY_BROWSER" + +# Bind a D1 database. D1 is Cloudflare’s native serverless SQL database. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases +# [[d1_databases]] +# binding = "MY_DB" +# database_name = "my-database" +# database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + +# Bind a dispatch namespace. Use Workers for Platforms to deploy serverless functions programmatically on behalf of your customers. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms +# [[dispatch_namespaces]] +# binding = "MY_DISPATCHER" +# namespace = "my-namespace" + +# Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model. +# Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects +[[durable_objects.bindings]] +name = "SONR_DURABLE_CLIENT" +class_name = "SonrDurableClient" + +# Durable Object migrations. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#migrations +[[migrations]] +tag = "v2" +renamed_classes = [{ from = "MyDurableObject", to = "SonrDurableClient" }] + +# Bind a Hyperdrive configuration. Use to accelerate access to your existing databases from Cloudflare Workers. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive +# [[hyperdrive]] +# binding = "MY_HYPERDRIVE" +# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + +# Bind a KV Namespace. Use KV as persistent storage for small key-value pairs. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces +# [[kv_namespaces]] +# binding = "MY_KV_NAMESPACE" +# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + +# Bind an mTLS certificate. Use to present a client certificate when communicating with another service. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates +# [[mtls_certificates]] +# binding = "MY_CERTIFICATE" +# certificate_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + +# Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues +# [[queues.producers]] +# binding = "MY_QUEUE" +# queue = "my-queue" + +# Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues +# [[queues.consumers]] +# queue = "my-queue" + +# Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets +# [[r2_buckets]] +# binding = "MY_BUCKET" +# bucket_name = "my-bucket" + +# Bind another Worker service. Use this binding to call another Worker without network overhead. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings +# [[services]] +# binding = "MY_SERVICE" +# service = "my-service" + +# Bind a Vectorize index. Use to store and query vector embeddings for semantic search, classification and other vector search use-cases. +# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes +# [[vectorize]] +# binding = "MY_INDEX" +# index_name = "my-index"