refactor: update devbox configuration and scripts

This commit is contained in:
Prad Nukala 2024-11-25 13:54:33 -05:00
parent 1568844255
commit e04d071ca7
63 changed files with 1069 additions and 202 deletions

View File

@ -286,7 +286,10 @@ testnet-basic: setup-testnet
sh-testnet: mod-tidy sh-testnet: mod-tidy
CHAIN_ID="sonr-testnet-1" BLOCK_TIME="1000ms" CLEAN=true sh scripts/test_node.sh 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 ### ### help ###

34
deploy/local/devbox.json Normal file
View File

@ -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"]
}
}
}

251
deploy/local/devbox.lock Normal file
View File

@ -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"
}
}
}
}
}

View File

@ -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

View File

@ -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"
]
}
}
}

View File

@ -3,7 +3,7 @@ version: "0.6"
processes: processes:
ipfs: ipfs:
namespace: testnet namespace: testnet
command: "sh scripts/setup_ipfs.sh" command: "devbox run start:ipfs"
background: true background: true
availability: availability:
restart: never restart: never
@ -12,7 +12,7 @@ processes:
sonr: sonr:
namespace: testnet namespace: testnet
background: true background: true
command: "make sh-testnet" command: "devbox run start:testnet"
restart: never restart: never
max_restarts: 1 max_restarts: 1
depends: depends:

View File

@ -1,42 +1,17 @@
{ {
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.12.0/.schema/devbox.schema.json", "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.12.0/.schema/devbox.schema.json",
"packages": [ "packages": ["go@1.22", "bun@latest", "ipfs@latest", "templ@latest"],
"go@1.22",
"bun@latest",
"ipfs@latest",
"air@latest",
"templ@latest"
],
"env": { "env": {
"GOPATH": "$HOME/go", "GOPATH": "$HOME/go",
"PATH": "./build:$HOME/go/bin:$PATH", "PATH": "./build:$HOME/go/bin:$PATH",
"CHAIN_ID": "sonr-testnet-1", "TEMPL_EXPERIMENT": "rawgo"
"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": { "shell": {
"init_hook": ["./scripts/init_env.sh"],
"scripts": { "scripts": {
"gen:pkl": [ "start-local": ["cd deploy/local && devbox services up"],
"make gen-pkl" "start-testnet": ["cd deploy/testnet && devbox services up"],
], "start-gex": ["go install github.com/cosmos/gex@latest", "gex"]
"gen:templ": [
"make gen-templ"
],
"buf-push": [
"cd ./proto && bunx buf dep update && bunx buf build && bunx buf push"
]
} }
} }
} }

View File

@ -1,54 +1,6 @@
{ {
"lockfile_version": "1", "lockfile_version": "1",
"packages": { "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": { "bun@latest": {
"last_modified": "2024-10-23T04:36:58Z", "last_modified": "2024-10-23T04:36:58Z",
"resolved": "github:NixOS/nixpkgs/dfffb2e7a52d29a0ef8e21ec8a0f30487b227f1a#bun", "resolved": "github:NixOS/nixpkgs/dfffb2e7a52d29a0ef8e21ec8a0f30487b227f1a#bun",
@ -149,17 +101,7 @@
"last_modified": "2023-02-24T09:01:09Z", "last_modified": "2023-02-24T09:01:09Z",
"resolved": "github:NixOS/nixpkgs/7d0ed7f2e5aea07ab22ccb338d27fbe347ed2f11#ipfs", "resolved": "github:NixOS/nixpkgs/7d0ed7f2e5aea07ab22ccb338d27fbe347ed2f11#ipfs",
"source": "devbox-search", "source": "devbox-search",
"version": "0.17.0", "version": "0.17.0"
"systems": {
"aarch64-darwin": {
"outputs": [
{
"path": "/nix/store/1azparhiwjzxgpkswpqnapzw0bfb7vl7-kubo-0.17.0",
"default": true
}
]
}
}
}, },
"templ@latest": { "templ@latest": {
"last_modified": "2024-10-13T23:44:06Z", "last_modified": "2024-10-13T23:44:06Z",

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package credentials package credentials
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package payments package payments

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package storage package storage
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package auth package auth
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package auth package auth
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package auth package auth
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package auth package auth
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package auth package auth
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package auth package auth
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package landing package landing
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package landing package landing
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package landing package landing

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package landing package landing
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package landing package landing
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package landing package landing
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package landing package landing
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package landing package landing
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package ui package ui
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package ui package ui
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package ui package ui
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package ui package ui
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package ui package ui
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package ui package ui
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package ui package ui
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package ui package ui
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package ui package ui
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package pages package pages
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package pages package pages
//lint:file-ignore SA4006 This context is only used if a nested component is present. //lint:file-ignore SA4006 This context is only used if a nested component is present.

View File

@ -1,6 +1,6 @@
// Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778 // templ: version: v0.2.793
package pages package pages

View File

@ -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.

28
scripts/init_env.sh Normal file → Executable file
View File

@ -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 '["*"]'

View File

@ -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

View File

@ -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"

@ -1 +0,0 @@
Subproject commit 712a041f4fa040be8c53ca0c701f961c59a22233

@ -1 +0,0 @@
Subproject commit e9529062bc943894e14b67a48a665b0f7e4aabb4

@ -1 +0,0 @@
Subproject commit d002aa61f0fed83c3227c146d329b58927975b5d

5
web/workers/noble-client/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
node_modules
.DS_Store
.env
dist
out

View File

@ -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

View File

@ -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"
}
}

View File

@ -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<Response>} 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);
},
};

View File

@ -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<string>} The greeting to be sent back to the Worker
*/
async sayHello(name) {
return `Hello, ${name}!`;
}
}

View File

@ -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 Cloudflares 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 Cloudflares 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"

5
web/workers/osmosis-client/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
node_modules
.DS_Store
.env
dist
out

View File

@ -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

View File

@ -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"
}
}

View File

@ -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<Response>} 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);
},
};

View File

@ -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<string>} The greeting to be sent back to the Worker
*/
async sayHello(name) {
return `Hello, ${name}!`;
}
}

View File

@ -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 Cloudflares 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 Cloudflares 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"

5
web/workers/sonr-client/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
node_modules
.DS_Store
.env
dist
out

View File

@ -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

BIN
web/workers/sonr-client/bun.lockb Executable file

Binary file not shown.

View File

@ -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"
}
}

View File

@ -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<Response>} 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);
},
};

View File

@ -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<string>} The greeting to be sent back to the Worker
*/
async sayHello(name) {
return `Hello, ${name}!`;
}
}

View File

@ -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 Cloudflares 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 Cloudflares 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"