Compare commits

..
8 Commits
Author SHA1 Message Date
github-actions[bot] 866468c002 bump: version 0.6.1 → 0.6.2 2025-01-06 19:00:34 +00:00
7f3aa01bd5 feature/1220 origin handle exists method (#1243)
* feat: add docs and CI workflow for publishing to onsonr.dev

* (refactor): Move hway,motr executables to their own repos

* feat: simplify devnet and testnet configurations

* refactor: update import path for didcrypto package

* docs(networks): Add README with project overview, architecture, and community links

* refactor: Move network configurations to deploy directory

* build: update golang version to 1.23

* refactor: move logger interface to appropriate package

* refactor: Move devnet configuration to networks/devnet

* chore: improve release process with date variable

* (chore): Move Crypto Library

* refactor: improve code structure and readability in DID module

* feat: integrate Trunk CI checks

* ci: optimize CI workflow by removing redundant build jobs

* feat: integrate Trunk CI checks, simplify devnet and testnet configurations, add docs and CI for onsonr.dev publishing, automate releases using Taskfile and GitHub Actions, and add Reddit release notification

* ci: Trigger release validation on pull requests

* ci: Migrate GoReleaser configuration to Makefiles

* chore: update CI workflow permissions and rename job

* refactor: remove unnecessary docker push steps from release process

* feat: automate release process using Taskfile and GitHub Actions

* fix: change shebang from bash to sh

* chore: update setup script shebang to bash

* chore: remove unnecessary setup-env step from release process

* test: improve test descriptions and naming for clarity

* refactor: rename workflow files for clarity

* refactor: rename post-merge workflow file

* refactor: Move race and coverage tests to separate workflow

* refactor: simplify merge group trigger

* chore: prevent accidental release overwriting of existing tags

* test: rename GoReleaser Dry Run step to GoReleaser Test

* fix: correct GitHub Actions workflow for version bumping

* fix: Correct tag validation in CI workflow

* refactor: simplify GitHub Actions workflow for version checking

* test: replace version check with make command

* chore: update setup-python action to v5

* test: rename workflow job and remove unnecessary steps

* feat: enable workflow on merge group events

---------

Signed-off-by: Prad Nukala <prad@sonr.io>
Co-authored-by: Darp Alakun <i@prad.nu>
2025-01-06 14:00:11 -05:00
root 2f65b1c283 refactor: simplify release process and remove unnecessary tasks 2025-01-06 13:12:38 -05:00
root 48f7b5d5cc chore: update version number to 0.6.1 2025-01-06 13:09:38 -05:00
d26d3d7b4d feature/1220 origin handle exists method (#1242)
* feat: add docs and CI workflow for publishing to onsonr.dev

* (refactor): Move hway,motr executables to their own repos

* feat: simplify devnet and testnet configurations

* refactor: update import path for didcrypto package

* docs(networks): Add README with project overview, architecture, and community links

* refactor: Move network configurations to deploy directory

* build: update golang version to 1.23

* refactor: move logger interface to appropriate package

* refactor: Move devnet configuration to networks/devnet

* chore: improve release process with date variable

* (chore): Move Crypto Library

* refactor: improve code structure and readability in DID module

* feat: integrate Trunk CI checks

* ci: optimize CI workflow by removing redundant build jobs

* feat: integrate Trunk CI checks, simplify devnet and testnet configurations, add docs and CI for onsonr.dev publishing, automate releases using Taskfile and GitHub Actions, and add Reddit release notification

* ci: Trigger release validation on pull requests

* ci: Migrate GoReleaser configuration to Makefiles

* chore: update CI workflow permissions and rename job

---------

Co-authored-by: Darp Alakun <i@prad.nu>
2025-01-06 17:24:48 +00:00
807b2e86ec feature/1220 origin handle exists method (#1241)
* feat: add docs and CI workflow for publishing to onsonr.dev

* (refactor): Move hway,motr executables to their own repos

* feat: simplify devnet and testnet configurations

* refactor: update import path for didcrypto package

* docs(networks): Add README with project overview, architecture, and community links

* refactor: Move network configurations to deploy directory

* build: update golang version to 1.23

* refactor: move logger interface to appropriate package

* refactor: Move devnet configuration to networks/devnet

* chore: improve release process with date variable

* (chore): Move Crypto Library

* refactor: improve code structure and readability in DID module

* feat: integrate Trunk CI checks

* ci: optimize CI workflow by removing redundant build jobs

---------

Co-authored-by: Darp Alakun <i@prad.nu>
2025-01-06 17:06:10 +00:00
root 9bd5e41fa0 docs: add .gitignore entries for Aider generated files 2025-01-03 11:44:12 -05:00
Prad Nukala 2ae32b2f64 refactor: remove devcontainer configuration 2025-01-01 16:21:42 -05:00
489 changed files with 8255 additions and 12764 deletions
+2 -2
View File
@@ -2,7 +2,7 @@
name = "cz_conventional_commits"
tag_format = "v$version"
version_scheme = "semver"
version = "0.6.0"
update_changelog_on_bump = false
version = "0.6.2"
update_changelog_on_bump = true
major_version_zero = true
changelog_file = "CHANGELOG.md"
-17
View File
@@ -1,17 +0,0 @@
FROM jetpackio/devbox:latest
# Installing your devbox project
WORKDIR /code
USER root:root
RUN mkdir -p /code && chown ${DEVBOX_USER}:${DEVBOX_USER} /code
USER ${DEVBOX_USER}:${DEVBOX_USER}
# Copy devbox configuration files
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.json devbox.json
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.lock devbox.lock
RUN devbox run -- echo "Installed Packages."
RUN devbox shellenv --init-hook >> ~/.profile
-89
View File
@@ -1,89 +0,0 @@
{
"name": "Devbox Remote Container",
"build": {
"dockerfile": "./Dockerfile",
"context": ".."
},
"customizations": {
"vscode": {
"settings": {},
"extensions": [
"jetpack-io.devbox"
]
}
},
"remoteUser": "devbox",
"forwardPorts": [
1317,
26657,
9090,
3000,
80,
5000
],
"portsAttributes": {
"1317": {
"label": "sonr-api",
"onAutoForward": "notify"
},
"26657": {
"label": "sonr-rpc",
"onAutoForward": "notify"
},
"9090": {
"label": "sonr-grpc",
"onAutoForward": "silent"
},
"3000": {
"label": "hway-frontend",
"onAutoForward": "silent"
},
"80": {
"label": "ipfs-gateway",
"onAutoForward": "silent"
},
"5000": {
"label": "ipfs-api",
"onAutoForward": "silent"
}
},
"features": {
"ghcr.io/michidk/devcontainers-features/bun:1": {
"version": "latest"
},
"ghcr.io/cirolosapio/devcontainers-features/alpine-ohmyzsh:0": {
"version": "latest"
},
"ghcr.io/guiyomh/features/golangci-lint:0": {
"version": "latest"
},
"ghcr.io/meaningful-ooo/devcontainer-features/homebrew:2": {
"version": "latest"
},
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"version": "latest"
},
"ghcr.io/devcontainers/features/github-cli:1": {
"version": "latest"
},
"ghcr.io/devcontainers/features/go:1": {
"version": "latest",
"go": "1.23"
},
"ghcr.io/devcontainers/features/rust:1": {
"version": "latest",
"rust": "1.73"
},
"ghcr.io/jpawlowski/devcontainer-features/codespaces-dotfiles:1": {
"version": "latest"
},
"ghcr.io/duduribeiro/devcontainer-features/neovim:1": {
"version": "latest"
},
"ghcr.io/dlouwers/devcontainer-features/devbox:1": {
"version": "latest"
},
"ghcr.io/devcontainers/features/sshd:1": {
"version": "latest"
}
}
-32
View File
@@ -1,32 +0,0 @@
version: "3"
vars:
VERSION:
sh: git describe --tags --abbrev=0
COMMIT:
sh: git rev-parse --short HEAD
ROOT:
sh: git rev-parse --show-toplevel
OS:
sh: uname -s
tasks:
date:
desc: Returns date in YEAR.WEEK.DAY format
cmds:
- |
YEAR=$(date +%Y)
WEEK=$(date +%V)
DAY=$(date +%u)
echo "${YEAR}.${WEEK}.${DAY}"
vars:
DATE: '{{default "" .CLI_ARGS}}'
silent: true
release:
desc: Create a new release with formatted date
cmds:
- go install github.com/goreleaser/goreleaser/v2@latest
- RELEASE_DATE=$(task date) goreleaser release --clean -f {{.ROOT}}/.goreleaser.yaml
silent: true
-281
View File
@@ -1,281 +0,0 @@
# To get started with Dependabot version updates, you'll need to specify which
#
#
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "monthly"
]]]]
+52 -303
View File
@@ -2,9 +2,6 @@
"scopes": [
"core-chain",
"core-ibc",
"sonr-hway",
"sonr-matrix",
"sonr-motr",
"x-did",
"x-dwn",
"x-svc",
@@ -16,35 +13,19 @@
],
"docs": [
{
"keywords": [
"github",
"actions",
"workflows",
"syntax"
],
"keywords": ["github", "actions", "workflows", "syntax"],
"url": "https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions"
},
{
"keywords": [
"cosmos",
"tooling",
"cosmovisor"
],
"keywords": ["cosmos", "tooling", "cosmovisor"],
"url": "https://docs.cosmos.network/v0.50/build/tooling/cosmovisor"
},
{
"keywords": [
"process-compose",
"configuration"
],
"keywords": ["process-compose", "configuration"],
"url": "https://f1bonacc1.github.io/process-compose/configuration/"
},
{
"keywords": [
"taskfile",
"cli",
"reference"
],
"keywords": ["taskfile", "cli", "reference"],
"url": "https://taskfile.dev/reference/cli"
},
{
@@ -52,250 +33,115 @@
"url": "https://taskfile.dev/reference/schema"
},
{
"keywords": [
"taskfile",
"templating",
"reference"
],
"keywords": ["taskfile", "templating", "reference"],
"url": "https://taskfile.dev/reference/templating/"
},
{
"keywords": [
"mkdocs",
"material",
"reference"
],
"keywords": ["mkdocs", "material", "reference"],
"url": "https://squidfunk.github.io/mkdocs-material/reference/"
},
{
"keywords": [
"pkl",
"language",
"reference"
],
"keywords": ["pkl", "language", "reference"],
"url": "https://pkl-lang.org/main/current/language-reference/index.html"
},
{
"keywords": [
"pwa",
"service-workers",
"web"
],
"keywords": ["pwa", "service-workers", "web"],
"url": "https://web.dev/learn/pwa/service-workers/"
},
{
"keywords": [
"service-workers",
"web",
"api"
],
"keywords": ["service-workers", "web", "api"],
"url": "https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API"
},
{
"keywords": [
"web-authentication",
"web",
"api"
],
"keywords": ["web-authentication", "web", "api"],
"url": "https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API"
},
{
"keywords": [
"sdk",
"modules",
"cosmos",
"manager"
],
"keywords": ["sdk", "modules", "cosmos", "manager"],
"url": "https://docs.cosmos.network/v0.50/build/building-modules/module-manager"
},
{
"keywords": [
"sdk",
"modules",
"cosmos",
"messages",
"queries"
],
"keywords": ["sdk", "modules", "cosmos", "messages", "queries"],
"url": "https://docs.cosmos.network/v0.50/build/building-modules/messages-and-queries"
},
{
"keywords": [
"sdk",
"modules",
"messages",
"service",
"cosmos"
],
"keywords": ["sdk", "modules", "messages", "service", "cosmos"],
"url": "https://docs.cosmos.network/v0.50/build/building-modules/msg-services"
},
{
"keywords": [
"sdk",
"modules",
"services",
"cosmos",
"query"
],
"keywords": ["sdk", "modules", "services", "cosmos", "query"],
"url": "https://docs.cosmos.network/v0.50/build/building-modules/query-services"
},
{
"keywords": [
"cosmos",
"depinject",
"modules",
"sdk"
],
"keywords": ["cosmos", "depinject", "modules", "sdk"],
"url": "https://docs.cosmos.network/v0.50/build/building-modules/depinject"
},
{
"keywords": [
"ibc",
"apps",
"sdk",
"interchain-accounts"
],
"keywords": ["ibc", "apps", "sdk", "interchain-accounts"],
"url": "https://ibc.cosmos.network/v8/apps/interchain-accounts/overview/"
},
{
"keywords": [
"ibc",
"apps",
"sdk",
"transfer"
],
"keywords": ["ibc", "apps", "sdk", "transfer"],
"url": "https://ibc.cosmos.network/v8/apps/transfer/overview/"
},
{
"keywords": [
"osmosis",
"modules",
"ibc",
"assets"
],
"keywords": ["osmosis", "modules", "ibc", "assets"],
"url": "https://docs.osmosis.zone/osmosis-core/asset-info/"
},
{
"keywords": [
"ibc",
"osmosis",
"tokenfactory",
"modules",
"assets"
],
"keywords": ["ibc", "osmosis", "tokenfactory", "modules", "assets"],
"url": "https://docs.osmosis.zone/osmosis-core/modules/tokenfactory"
},
{
"keywords": [
"ibc",
"mint",
"cctp",
"noble",
"assets"
],
"keywords": ["ibc", "mint", "cctp", "noble", "assets"],
"url": "https://docs.noble.xyz/cctp/mint"
},
{
"keywords": [
"ibc",
"relayer",
"nomic",
"assets"
],
"keywords": ["ibc", "relayer", "nomic", "assets"],
"url": "https://docs.nomic.io/network/ibc-relayer"
},
{
"keywords": [
"ibc",
"cctp",
"noble",
"mint_forward",
"assets"
],
"keywords": ["ibc", "cctp", "noble", "mint_forward", "assets"],
"url": "https://docs.noble.xyz/cctp/mint_forward"
},
{
"keywords": [
"evmos",
"erc20",
"assets"
],
"keywords": ["evmos", "erc20", "assets"],
"url": "https://docs.evmos.org/protocol/modules/erc20"
},
{
"keywords": [
"nomic",
"nbtc",
"assets"
],
"keywords": ["nomic", "nbtc", "assets"],
"url": "https://docs.nomic.io/nbtc"
},
{
"keywords": [
"mpc",
"wallet",
"cryptography",
"capability",
"invokation"
],
"keywords": ["mpc", "wallet", "cryptography", "capability", "invokation"],
"url": "https://csrc.nist.gov/CSRC/media/Events/NTCW19/papers/paper-DKLS.pdf"
},
{
"keywords": [
"ucan",
"spec",
"cryptography",
"authorization"
],
"keywords": ["ucan", "spec", "cryptography", "authorization"],
"url": "https://raw.githubusercontent.com/ucan-wg/spec/refs/heads/main/README.md"
},
{
"keywords": [
"zero-knowledge",
"proofs",
"cryptography",
"privacy"
],
"keywords": ["zero-knowledge", "proofs", "cryptography", "privacy"],
"url": "https://eprint.iacr.org/2021/1672.pdf"
},
{
"keywords": [
"gateway",
"http",
"sse"
],
"keywords": ["gateway", "http", "sse"],
"url": "https://echo.labstack.com/docs/cookbook/sse"
},
{
"keywords": [
"gateway",
"http",
"websocket"
],
"keywords": ["gateway", "http", "websocket"],
"url": "https://echo.labstack.com/docs/cookbook/websocket"
},
{
"keywords": [
"gateway",
"http",
"subdomain"
],
"keywords": ["gateway", "http", "subdomain"],
"url": "https://echo.labstack.com/docs/cookbook/subdomain"
},
{
"keywords": [
"tigerbeetle",
"models",
"oracle"
],
"keywords": ["tigerbeetle", "models", "oracle"],
"url": "https://docs.tigerbeetle.com/coding/data-modeling"
},
{
"keywords": [
"tigerbeetle",
"two=phase",
"transfers",
"oracle"
],
"keywords": ["tigerbeetle", "two=phase", "transfers", "oracle"],
"url": "https://docs.tigerbeetle.com/coding/two-phase-transfers"
},
{
@@ -309,12 +155,7 @@
"url": "https://docs.tigerbeetle.com/coding/reliable-transaction-submission"
},
{
"keywords": [
"currency",
"exchange",
"tigerbeetle",
"oracle"
],
"keywords": ["currency", "exchange", "tigerbeetle", "oracle"],
"url": "https://docs.tigerbeetle.com/coding/recipes/currency-exchange"
},
{
@@ -328,171 +169,79 @@
"url": "https://docs.tigerbeetle.com/coding/recipes/balance-conditional-transfers"
},
{
"keywords": [
"tigerbeetle",
"account",
"oracle"
],
"keywords": ["tigerbeetle", "account", "oracle"],
"url": "https://docs.tigerbeetle.com/reference/account"
},
{
"keywords": [
"tigerbeetle",
"transfer",
"oracle"
],
"keywords": ["tigerbeetle", "transfer", "oracle"],
"url": "https://docs.tigerbeetle.com/reference/transfer"
},
{
"keywords": [
"substreams",
"packages",
"consumer",
"oracle"
],
"keywords": ["substreams", "packages", "consumer", "oracle"],
"url": "https://docs.substreams.dev/documentation/consume/packages"
},
{
"keywords": [
"substreams",
"deploy",
"service",
"oracle"
],
"keywords": ["substreams", "deploy", "service", "oracle"],
"url": "https://docs.substreams.dev/documentation/consume/sql/deployable-services/local-service"
},
{
"keywords": [
"substreams",
"tutorial",
"cosmos",
"injective"
],
"keywords": ["substreams", "tutorial", "cosmos", "injective"],
"url": "https://docs.substreams.dev/tutorials/cosmos/injective/foundational"
},
{
"keywords": [
"worker",
"http",
"jwt"
],
"keywords": ["worker", "http", "jwt"],
"url": "https://echo.labstack.com/docs/cookbook/jwt"
},
{
"keywords": [
"worker",
"http",
"secure"
],
"keywords": ["worker", "http", "secure"],
"url": "https://echo.labstack.com/docs/middleware/secure"
},
{
"keywords": [
"worker",
"http",
"service-workers",
"web",
"api"
],
"keywords": ["worker", "http", "service-workers", "web", "api"],
"url": "https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API"
},
{
"keywords": [
"synapse",
"matrix",
"configuration",
"usage"
],
"keywords": ["synapse", "matrix", "configuration", "usage"],
"url": "https://element-hq.github.io/synapse/latest/usage/configuration/config_documentation.html"
},
{
"keywords": [
"cosmos",
"protobuf",
"orm",
"sdk"
],
"keywords": ["cosmos", "protobuf", "orm", "sdk"],
"url": "https://docs.cosmos.network/v0.50/build/packages/orm"
},
{
"keywords": [
"cosmos",
"sdk",
"modules",
"auth"
],
"keywords": ["cosmos", "sdk", "modules", "auth"],
"url": "https://docs.cosmos.network/v0.50/build/modules/auth"
},
{
"keywords": [
"cosmos",
"sdk",
"modules",
"bank"
],
"keywords": ["cosmos", "sdk", "modules", "bank"],
"url": "https://docs.cosmos.network/v0.50/build/modules/bank"
},
{
"keywords": [
"cosmos",
"modules",
"authz",
"sdk"
],
"keywords": ["cosmos", "modules", "authz", "sdk"],
"url": "https://docs.cosmos.network/v0.50/build/modules/authz"
},
{
"keywords": [
"cosmos",
"protobuf",
"collections",
"sdk"
],
"keywords": ["cosmos", "protobuf", "collections", "sdk"],
"url": "https://docs.cosmos.network/v0.50/build/packages/collections"
},
{
"keywords": [
"cosmos",
"modules",
"gov",
"sdk"
],
"keywords": ["cosmos", "modules", "gov", "sdk"],
"url": "https://docs.cosmos.network/v0.50/build/modules/gov"
},
{
"keywords": [
"cosmos",
"modules",
"staking",
"sdk"
],
"keywords": ["cosmos", "modules", "staking", "sdk"],
"url": "https://docs.cosmos.network/v0.50/build/modules/staking"
},
{
"keywords": [
"cosmos",
"protobuf",
"annotations",
"sdk"
],
"keywords": ["cosmos", "protobuf", "annotations", "sdk"],
"url": "https://docs.cosmos.network/v0.50/build/building-modules/protobuf-annotations"
},
{
"keywords": [
"cosmos",
"sdk",
"modules",
"group"
],
"keywords": ["cosmos", "sdk", "modules", "group"],
"url": "https://docs.cosmos.network/v0.50/build/modules/group"
},
{
"keywords": [
"cosmos",
"sdk",
"modules",
"nft"
],
"keywords": ["cosmos", "sdk", "modules", "nft"],
"url": "https://docs.cosmos.network/v0.50/build/modules/nft"
}
],
@@ -1,12 +1,16 @@
name: Perform Checks on PR
name: Check PR
on:
pull_request:
merge_group:
permissions:
contents: read # for TimonVS/pr-labeler-action to read config file
pull-requests: write # for TimonVS/pr-labeler-action to add labels in PR
jobs:
tidy-pr:
name: Tidy PR
verify-pr:
name: Test Lints
if: github.event_name == 'pull_request'
permissions:
contents: read # for TimonVS/pr-labeler-action to read config file
@@ -16,17 +20,18 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Required to fetch all history for merging
- uses: TimonVS/pr-labeler-action@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
configuration-path: .github/pr-labeler.yml # optional, .github/pr-labeler.yml is the default value
- name: Trunk Check
uses: trunk-io/trunk-action@v1
test-builds:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
name: Run Build Tests
name: Test Builds
steps:
- name: Checkout repository
uses: actions/checkout@v4
@@ -41,15 +46,11 @@ jobs:
check-latest: true
- name: Run Sonrd Build
run: make build
- name: Run Hway Build
run: make build-hway
- name: Run Motr Build
run: make build-motr
test-unit:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
name: Run Unit Tests
name: Test Unit
steps:
- name: Checkout repository
uses: actions/checkout@v4
@@ -64,47 +65,10 @@ jobs:
check-latest: true
- run: make test-unit
test-race:
runs-on: ubuntu-latest
if: github.event_name == 'merge_group'
name: Run Race Tests
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: onsonr/sonr
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-go@v5
with:
go-version: "1.23"
check-latest: true
- run: make test-race
test-cover:
runs-on: ubuntu-latest
if: github.event_name == 'merge_group'
name: Run Coverage Tests
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: onsonr/sonr
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-go@v5
with:
go-version: "1.23"
check-latest: true
- run: make test-cover
validate-release:
if: github.event_name == 'merge_group'
if: github.event_name == 'merge_group' || github.event_name == 'pull_request'
runs-on: ubuntu-latest
name: Verify Release Config
name: Test Version
steps:
- name: Checkout repository
uses: actions/checkout@v4
@@ -118,28 +82,17 @@ jobs:
go-version: "1.23"
check-latest: true
- name: Commitizen Dry Run
uses: commitizen-tools/commitizen-action@master
- name: Install Python
uses: actions/setup-python@v5
with:
push: false
dry_run: true
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main
python-version: "3.x"
- name: Version Check
run: make validate-tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check GoReleaser Config
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: GoReleaser Dry Run
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --snapshot --clean --skip=publish
run: make release-check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+68
View File
@@ -0,0 +1,68 @@
name: Merge Group
on:
merge_group:
permissions:
contents: read # for TimonVS/pr-labeler-action to read config file
pull-requests: write # for TimonVS/pr-labeler-action to add labels in PR
jobs:
test-race:
runs-on: ubuntu-latest
if: github.event_name == 'merge_group'
name: Test Race
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: onsonr/sonr
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-go@v5
with:
go-version: "1.23"
check-latest: true
- run: make test-race
test-cover:
runs-on: ubuntu-latest
if: github.event_name == 'merge_group'
name: Test Coverage
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: onsonr/sonr
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-go@v5
with:
go-version: "1.23"
check-latest: true
- run: make test-cover
test-release:
runs-on: ubuntu-latest
name: Test Release
if: github.event_name == 'merge_group'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
repository: onsonr/sonr
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-go@v5
with:
go-version: "1.23"
check-latest: true
- name: Release Dry Run
run: make release-dry
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -1,4 +1,4 @@
name: Bump Version on Merge
name: Post Merge
on:
pull_request:
types: [closed]
@@ -9,6 +9,7 @@ permissions:
jobs:
bump-version:
name: Cz Bump
if: |
github.event.pull_request.merged == true &&
github.event.pull_request.user.login != 'dependabot[bot]' &&
@@ -16,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
ssh-key: "${{ secrets.COMMIT_KEY }}"
@@ -26,6 +27,7 @@ jobs:
with:
push: false
increment: patch
branch: main
- name: Push using ssh
run: |
+66
View File
@@ -0,0 +1,66 @@
name: New Release
on:
release:
types: [published]
permissions:
contents: write
issues: write
jobs:
buf_push:
name: Publish Protobufs
runs-on: ubuntu-latest
steps:
# Run `git checkout`
- uses: actions/checkout@v4
# Install the `buf` CLI
- uses: bufbuild/buf-setup-action@v1
# Push only the Input in `proto` to the BSR
- uses: bufbuild/buf-push-action@v1
continue-on-error: true
with:
input: proto
buf_token: ${{ secrets.BUF_TOKEN }}
container-push:
name: Publish Docker Images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/onsonr/sonr:latest
docs-push:
runs-on: ubuntu-latest
name: Publish Tech Docs
steps:
- uses: actions/checkout@v4
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- run: pip install mkdocs-material
- run: mkdocs gh-deploy --force
@@ -1,4 +1,4 @@
name: Versioned Release
name: New Tag
on:
pull_request:
@@ -14,7 +14,7 @@ permissions:
jobs:
new-release:
name: Run GoReleaser on New Tag
name: Create Release
if: startsWith(github.ref, 'refs/tags/')
permissions: write-all
runs-on: ubuntu-latest
@@ -37,14 +37,8 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Install Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser
run: task release
run: make release
env:
GITHUB_TOKEN: ${{ secrets.GH_RELEASER_TOKEN }}
GITHUB_PERSONAL_AUTH_TOKEN: ${{ secrets.GH_RELEASER_TOKEN }}
@@ -55,4 +49,3 @@ jobs:
REDDIT_SECRET: ${{ secrets.REDDIT_SECRET }}
REDDIT_USERNAME: ${{ secrets.REDDIT_USERNAME }}
REDDIT_PASSWORD: ${{ secrets.REDDIT_PASSWORD }}
-24
View File
@@ -1,24 +0,0 @@
name: Publish Assets on Release
on:
release:
types: [published]
permissions:
contents: write
issues: write
jobs:
buf_push:
name: Publish to buf.build/onsonr/sonr
runs-on: ubuntu-latest
steps:
# Run `git checkout`
- uses: actions/checkout@v4
# Install the `buf` CLI
- uses: bufbuild/buf-setup-action@v1
# Push only the Input in `proto` to the BSR
- uses: bufbuild/buf-push-action@v1
continue-on-error: true
with:
input: proto
buf_token: ${{ secrets.BUF_TOKEN }}
+3
View File
@@ -1,3 +1,6 @@
# Aider related generated files
.aider-context
# Binaries
.task
no
+6 -82
View File
@@ -2,15 +2,11 @@
version: 2
project_name: sonr
before:
hooks:
- echo "Release date is {{ .Env.RELEASE_DATE }}"
builds:
- id: motr
main: ./cmd/motr
binary: app
goos:
- js
goarch:
- wasm
- id: sonr
main: ./cmd/sonrd
binary: sonrd
@@ -36,27 +32,6 @@ builds:
- netgo
- ledger
- id: hway
main: ./cmd/hway
binary: hway
goos:
- linux
- darwin
goarch:
- amd64
- arm64
mod_timestamp: "{{ .CommitTimestamp }}"
flags:
- -mod=readonly
- -trimpath
goamd64:
- v1
tags:
- netgo
ldflags:
- -X main.version={{.Version}}
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}
archives:
- id: sonr
builds: [sonr]
@@ -69,41 +44,7 @@ archives:
- src: README*
wrap_in_directory: true
- id: hway
builds: [hway]
name_template: >-
hway_{{ .Os }}_{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
format: tar.gz
files:
- src: README*
wrap_in_directory: true
nfpms:
- id: hway
package_name: hway
file_name_template: "hway_{{ .Os }}_{{ .Arch }}{{ .ConventionalExtension }}"
builds: [hway]
vendor: Sonr
homepage: "https://onsonr.dev"
maintainer: "Sonr <support@onsonr.dev>"
description: "Sonr Highway is a decentralized, permissionless, and censorship-resistant identity network proxy."
license: "Apache 2.0"
formats:
- rpm
- deb
- apk
dependencies:
- ipfs
contents:
- src: README*
dst: /usr/share/doc/hway
bindir: /usr/bin
section: net
priority: optional
# Add these lines to match build config
- id: sonr
package_name: sonrd
file_name_template: "sonrd_{{ .Os }}_{{ .Arch }}{{ .ConventionalExtension }}"
@@ -128,23 +69,6 @@ nfpms:
# Add these lines to match build config
brews:
- name: hway
ids: [hway]
commit_author:
name: goreleaserbot
email: bot@goreleaser.com
directory: Formula
caveats: "Run a local hway node and access it with the hway proxy"
homepage: "https://onsonr.dev"
description: "Sonr is a decentralized, permissionless, and censorship-resistant identity network."
dependencies:
- name: ipfs
repository:
owner: onsonr
name: homebrew-tap
branch: master
token: "{{ .Env.GITHUB_PERSONAL_AUTH_TOKEN }}"
- name: sonr
ids: [sonr]
commit_author:
@@ -152,7 +76,7 @@ brews:
email: bot@goreleaser.com
directory: Formula
caveats: "Run a local sonr node and access it with the hway proxy"
homepage: "https://onsonr.dev"
homepage: "https://onson.dev"
description: "Sonr is a decentralized, permissionless, and censorship-resistant identity network."
dependencies:
- name: ipfs
@@ -166,7 +90,7 @@ release:
github:
owner: onsonr
name: sonr
name_template: 'Release {{ .Env.RELEASE_DATE }}'
name_template: "{{ .Tag }} | {{ .Env.RELEASE_DATE }}"
draft: false
replace_existing_draft: true
replace_existing_artifacts: true
+9
View File
@@ -0,0 +1,9 @@
*out
*logs
*actions
*notifications
*tools
plugins
user_trunk.yaml
user.yaml
tmp
+27
View File
@@ -0,0 +1,27 @@
linters:
disable:
- unused # Disables unreachable code checking
run:
# Exclude test files from analysis
tests: false
# Define which files and directories to exclude
issues:
exclude-rules:
# Exclude all test files
- path: _test\.go
linters:
- all
# Exclude specific directories
exclude-dirs:
- api/did/v1
- api/dwn/v1
- api/svc/v1
- internal
# Exclude specific file patterns
exclude-files:
- ".*\\.pb\\.go$"
- ".*_templ\\.go$"
+4
View File
@@ -0,0 +1,4 @@
# Following source doesn't work in most setups
ignored:
- SC1090
- SC1091
+2
View File
@@ -0,0 +1,2 @@
# Prettier friendly markdownlint config (all formatting rules disabled)
extends: markdownlint/style/prettier
+1
View File
@@ -0,0 +1 @@
edition = "2021"
+7
View File
@@ -0,0 +1,7 @@
enable=all
source-path=SCRIPTDIR
disable=SC2154
# If you're having issues with shellcheck following source, disable the errors via:
# disable=SC1090
# disable=SC1091
+7
View File
@@ -0,0 +1,7 @@
rules:
quoted-strings:
required: only-when-needed
extra-allowed: ["{|}"]
key-duplicates: {}
octal-values:
forbid-implicit-octal: true
+41
View File
@@ -0,0 +1,41 @@
# This file controls the behavior of Trunk: https://docs.trunk.io/cli
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
version: 0.1
cli:
version: 1.22.8
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
plugins:
sources:
- id: trunk
ref: v1.6.6
uri: https://github.com/trunk-io/plugins
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
runtimes:
enabled:
- go@1.23.0
- node@18.20.5
- python@3.10.8
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint:
enabled:
- actionlint@1.7.6
- checkov@3.2.347
- clippy@1.65.0
- git-diff-check
- gofmt@1.20.4
- golangci-lint@1.62.2
- hadolint@2.12.1-beta
# - markdownlint@0.43.0
- osv-scanner@1.9.2
- prettier@3.4.2
- rustfmt@1.65.0
# - shellcheck@0.10.0
# - shfmt@3.6.0
- taplo@0.9.3
- trufflehog@3.88.0
actions:
enabled:
- trunk-announce
- trunk-check-pre-push
- trunk-fmt-pre-commit
- trunk-upgrade-available
+43 -5
View File
@@ -1,3 +1,41 @@
## v0.6.2 (2025-01-06)
### Refactor
- simplify release process and remove unnecessary tasks
- remove devcontainer configuration
## v0.6.1 (2024-12-30)
### Feat
- convert highway sink schema to SQLite
- **scopes**: add Web Authentication API documentation
- add install script for Sonr binaries
### Fix
- Handle only 500 errors in ErrorHandler
- Return only on 500 errors in error handler
- update sqlc queries to match schema and use SQLite conventions
- Rename DecodeWasmContext to decodeWasmContext
- resolve lint errors in WASMMiddleware function
- prevent automatic version bumps from dependabot
- correct merge workflow to increment patch version
### Refactor
- remove outdated scopes
- remove unnecessary seed message
- Update sqlc queries to match schema and sqlite conventions
- move gateway and vault components to new locations
- **scopes**: simplify scopes.json structure
- **scopes**: rename and reorganize scopes
- **api**: remove unused Allocate RPC from Query service
- remove postgresql tasks
- remove unused AI PR body generator step
- simplify Taskfile and remove unused chain configurations
## v0.6.0 (2024-12-24)
### Feat
@@ -22,7 +60,7 @@
- optimize GitHub Actions workflow triggers (#1204)
- Move embed
## v0.5.27 (2024-12-16)
## v0.1.6 (2024-12-16)
## v0.5.26 (2024-12-13)
@@ -475,7 +513,7 @@
- **cta**: Fix typo in CTA title
- change bento section title to reflect security focus
- adjust hero image dimensions
- **Input**: Change type from to
- **Input**: Change type from to
- update hero image height in config.pkl
### Refactor
@@ -507,7 +545,7 @@
- remove old changelog entries
- rename buf-publish.yml to publish-assets.yml
- remove unused field from
- remove unused field from
- remove unnecessary checkout in scheduled-release workflow
- rename build ID to sonr
- remove unnecessary release existence check
@@ -626,7 +664,7 @@
- extract root command creation to separate file
- move ipfs setup to function
- remove unnecessary proxy config
- rename script to
- rename script to
- move DWN proxy server logic to separate file
- use htmx instead of dwn for vault client
- remove unused environment variables
@@ -634,7 +672,7 @@
- use staking keeper in DID keeper
- remove unused dependencies
- remove unused image building workflow
- add field to
- add field to
- Update KeyKind Enum to have proper naming conventions
- Update `DIDNamespace` to have proper naming convention
- expose ports directly in docker-compose
View File
+3 -1
View File
@@ -1,4 +1,4 @@
FROM golang:1.22-alpine AS go-builder
FROM golang:1.23-alpine AS go-builder
SHELL ["/bin/sh", "-ecuxo", "pipefail"]
@@ -31,6 +31,8 @@ RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make build \
# --------------------------------------------------------
FROM debian:11-slim
LABEL org.opencontainers.image.source https://github.com/onsonr/sonr
COPY --from=go-builder /code/build/sonrd /usr/bin/sonrd
# Install dependencies for Debian 11
+42 -8
View File
@@ -8,14 +8,16 @@ SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g')
BINDIR ?= $(GOPATH)/bin
SIMAPP = ./app
PC_PORT_NUM=42069
PC_LOG_FILE=./sonr.log
PC_SOCKET_PATH=/tmp/sonr-net.sock
# Fetch from env
RELEASE_DATE ?= $(shell date +%Y).$(shell date +%V).$(shell date +%u)
VERSION ?= $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT ?= $(shell git log -1 --format='%H')
OS ?= $(shell uname -s)
ROOT ?= $(shell git rev-parse --show-toplevel)
# for dockerized protobuf tools
DOCKER := $(shell which docker)
HTTPS_GIT := github.com/onsonr/sonr.git
PROCESS_COMPOSE := $(shell which process-compose)
export GO111MODULE = on
@@ -107,8 +109,14 @@ install: go.sum
install-hway: go.sum
go install -mod=readonly ./cmd/hway
release: fmt-date
@go install github.com/goreleaser/goreleaser/v2@latest
RELEASE_DATE=$(RELEASE_DATE) goreleaser release --clean
########################################
### Tools & dependencies
########################################
go-mod-cache: go.sum
@echo "--> Download go modules to local cache"
@@ -134,12 +142,9 @@ clean:
distclean: clean
rm -rf vendor/
init-env:
@echo "Installing process-compose"
sh scripts/init_env.sh
########################################
### Testing
########################################
test: test-unit
test-all: test-race test-cover test-system
@@ -310,6 +315,35 @@ sh-testnet: mod-tidy
.PHONY: setup-testnet set-testnet-configs testnet testnet-basic sh-testnet dop-testnet
###############################################################################
### extra utils ###
###############################################################################
push-docker:
@docker build -t ghcr.io/onsonr/sonr:latest .
@docker tag ghcr.io/onsonr/sonr:latest ghcr.io/onsonr/sonr:$(VERSION)
@docker push ghcr.io/onsonr/sonr:latest
@docker push ghcr.io/onsonr/sonr:$(VERSION)
status:
@gh run ls -L 3
@gum format -- "# Sonr ($OS-$VERSION)" "- ($(COMMIT)) $ROOT" "- $(RELEASE_DATE)"
@sleep 3
release:
@go install github.com/goreleaser/goreleaser/v2@latest
@RELEASE_DATE=$(RELEASE_DATE) goreleaser release --clean
release-dry:
@go install github.com/goreleaser/goreleaser/v2@latest
@RELEASE_DATE=$(RELEASE_DATE) goreleaser release --snapshot --clean --skip=publish
release-check:
@go install github.com/goreleaser/goreleaser/v2@latest
@RELEASE_DATE=$(RELEASE_DATE) goreleaser check
validate-tag:
@sh ./scripts/validate_tag.sh
###############################################################################
### help ###
###############################################################################
-73
View File
@@ -1,73 +0,0 @@
version: "3"
vars:
VERSION:
sh: git describe --tags --abbrev=0
COMMIT:
sh: git rev-parse --short HEAD
ROOT:
sh: git rev-parse --show-toplevel
OS:
sh: uname -s
# DOPPLER_TOKEN:
# sh: skate get DOPPLER_NETWORK
# includes:
# deps: https://raw.githubusercontent.com/onsonr/taskfiles/main/taskfiles/deps.yml
# gen: https://raw.githubusercontent.com/onsonr/taskfiles/main/taskfiles/gen.yml
# hway: https://raw.githubusercontent.com/onsonr/taskfiles/main/taskfiles/hway.yml
# ipfs: https://raw.githubusercontent.com/onsonr/taskfiles/main/taskfiles/ipfs.yml
# issue: https://raw.githubusercontent.com/onsonr/taskfiles/main/taskfiles/ghpm.yml
# procs: https://raw.githubusercontent.com/onsonr/taskfiles/main/taskfiles/procs.yml
# postgres: https://raw.githubusercontent.com/onsonr/taskfiles/main/taskfiles/postgres.yml
# sonrd: https://raw.githubusercontent.com/onsonr/taskfiles/main/taskfiles/sonrd.yml
#
tasks:
default:
cmds:
- gh run ls -L 3
- gum format -- "# Sonr ({{.OS}}-{{.VERSION}})" " - ({{.COMMIT}}) {{.ROOT}}"
- task -l -j | jq -r '.tasks[].name' | fzf --height=16 | xargs task
silent: true
# start:
# desc: Start the Network
# silent: true
# cmds:
# - task: postgres:reset
# - task: ipfs:init
# - task: ipfs:mount
# - task: sonrd:install
# - task: hway:build
# - task: procs:up
#
# status:
# desc: Check the status of the Network
# silent: true
# cmds:
# - task: procs:attach
#
# stop:
# desc: Stop the Network
# silent: true
# cmds:
# - task: procs:down
date:
desc: Returns date in YEAR.WEEK.DAY format
cmds:
- |
YEAR=$(date +%Y)
WEEK=$(date +%V)
DAY=$(date +%u)
echo "${YEAR}.${WEEK}.${DAY}"
vars:
DATE: '{{default "" .CLI_ARGS}}'
silent: true
release:
desc: Create a new release with formatted date
cmds:
- go install github.com/goreleaser/goreleaser/v2@latest
- RELEASE_DATE=$(task date) goreleaser release --clean
silent: true
-93
View File
@@ -1,93 +0,0 @@
package main
import (
"fmt"
"log"
"net/http"
"os"
"strings"
"github.com/onsonr/sonr/gateway"
"github.com/onsonr/sonr/internal/common"
"github.com/spf13/cobra"
)
// Command line flags
var (
servePort int // Gateway http entry point (default 3000)
chainID string // Current chain ID (default sonr-testnet-1)
ipfsGatewayURL string // IPFS gateway URL (default localhost:8080)
sonrAPIURL string // Sonr API URL (default localhost:1317)
sonrGrpcURL string // Sonr gRPC URL (default localhost:9090)
sonrRPCURL string // Sonr RPC URL (default localhost:26657)
psqlHost string // PostgresSQL Host Flag
psqlPort string // PostgresSQL Port Flag
psqlUser string // PostgresSQL User Flag
psqlPass string // PostgresSQL Password Flag
psqlDB string // PostgresSQL Database Flag
)
func rootCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "hway",
Short: "Sonr DID gateway",
Run: func(cmd *cobra.Command, args []string) {
env, err := loadEnvImplFromArgs(args)
if err != nil {
panic(err)
}
ipc, err := common.NewIPFS()
if err != nil {
panic(err)
}
dbq, err := setupPostgresDB()
if err != nil {
panic(err)
}
e, err := gateway.New(env, ipc, dbq)
if err != nil {
panic(err)
}
if err := e.Start(fmt.Sprintf(":%d", env.GetServePort())); err != http.ErrServerClosed {
log.Fatal(err)
os.Exit(1)
return
}
},
}
cmd.Flags().IntVar(&servePort, "serve-port", 3000, "Port to serve the gateway on")
cmd.Flags().StringVar(&chainID, "chain-id", "sonr-testnet-1", "Chain ID")
cmd.Flags().StringVar(&ipfsGatewayURL, "ipfs-gateway-url", "localhost:8080", "IPFS gateway URL")
cmd.Flags().StringVar(&sonrAPIURL, "sonr-api-url", "localhost:1317", "Sonr API URL")
cmd.Flags().StringVar(&sonrGrpcURL, "sonr-grpc-url", "localhost:9090", "Sonr gRPC URL")
cmd.Flags().StringVar(&sonrRPCURL, "sonr-rpc-url", "localhost:26657", "Sonr RPC URL")
cmd.Flags().StringVar(&psqlHost, "psql-host", "localhost", "PostgresSQL Host")
cmd.Flags().StringVar(&psqlPort, "psql-port", "5432", "PostgresSQL Port")
cmd.Flags().StringVar(&psqlUser, "psql-user", "highway_user", "PostgresSQL User")
cmd.Flags().StringVar(&psqlPass, "psql-pass", "highway_password123", "PostgresSQL Password")
cmd.Flags().StringVar(&psqlDB, "psql-db", "highway", "PostgresSQL Database")
return cmd
}
func formatPsqlDSN() string {
if psqlHost == "" {
return ""
}
host := psqlHost
port := "5432"
if parts := strings.Split(psqlHost, ":"); len(parts) == 2 {
host = parts[0]
port = parts[1]
}
dsn := fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=verify-full",
host, port, psqlUser, psqlPass, psqlDB)
log.Printf("Attempting to connect to PostgreSQL with DSN: host=%s port=%s user=%s dbname=%s",
host, port, psqlUser, psqlDB) // Don't log the password
return dsn
}
-49
View File
@@ -1,49 +0,0 @@
package main
import (
"context"
_ "embed"
"fmt"
"os"
"github.com/jackc/pgx/v5"
config "github.com/onsonr/sonr/internal/config/hway"
hwayorm "github.com/onsonr/sonr/internal/database/hwayorm"
)
// main is the entry point for the application
func main() {
cmd := rootCmd()
if err := cmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
os.Exit(0)
}
func loadEnvImplFromArgs(args []string) (config.Hway, error) {
cmd := rootCmd()
if err := cmd.ParseFlags(args); err != nil {
return nil, err
}
env := &config.HwayImpl{
ServePort: servePort,
ChainId: chainID,
IpfsGatewayUrl: ipfsGatewayURL,
SonrApiUrl: sonrAPIURL,
SonrGrpcUrl: sonrGrpcURL,
SonrRpcUrl: sonrRPCURL,
PsqlDSN: formatPsqlDSN(),
}
return env, nil
}
func setupPostgresDB() (*hwayorm.Queries, error) {
pgdsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s sslmode=disable", psqlHost, psqlUser, psqlPass, psqlDB)
conn, err := pgx.Connect(context.Background(), pgdsn)
if err != nil {
return nil, err
}
return hwayorm.New(conn), nil
}
-259
View File
@@ -1,259 +0,0 @@
//go:build js && wasm
// +build js,wasm
package main
import (
"bytes"
"context"
"database/sql"
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"net/http/httptest"
"strings"
"sync"
"syscall/js"
_ "github.com/ncruces/go-sqlite3/driver"
_ "github.com/ncruces/go-sqlite3/embed"
"github.com/onsonr/sonr/internal/config/motr"
"github.com/onsonr/sonr/internal/database/motrorm"
sink "github.com/onsonr/sonr/internal/database/sink"
vault "github.com/onsonr/sonr/vault"
)
var (
// Global buffer pool to reduce allocations
bufferPool = sync.Pool{
New: func() interface{} {
return new(bytes.Buffer)
},
}
// Cached JS globals
jsGlobal = js.Global()
jsUint8Array = jsGlobal.Get("Uint8Array")
jsResponse = jsGlobal.Get("Response")
jsPromise = jsGlobal.Get("Promise")
jsWasmHTTP = jsGlobal.Get("wasmhttp")
)
func main() {
configString := "TODO"
config, _ := loadConfig(configString)
dbq, err := createDB()
if err != nil {
log.Fatal(err)
return
}
e, err := vault.New(config, dbq)
if err != nil {
log.Fatal(err)
return
}
serveFetch(e)
}
// loadConfig loads the config from the given JSON string
func loadConfig(configString string) (*motr.Config, error) {
var config motr.Config
err := json.Unmarshal([]byte(configString), &config)
return &config, err
}
// createDB initializes and returns a configured database connection
func createDB() (*motrorm.Queries, error) {
db, err := sql.Open("sqlite3", ":memory:")
if err != nil {
return nil, err
}
// create tables
if _, err := db.ExecContext(context.Background(), sink.SchemaVaultSQL); err != nil {
return nil, err
}
return motrorm.New(db), nil
}
// serveFetch serves HTTP requests with optimized handler management
func serveFetch(handler http.Handler) func() {
h := handler
if h == nil {
h = http.DefaultServeMux
}
// Optimize prefix handling
prefix := strings.TrimRight(jsWasmHTTP.Get("path").String(), "/")
if prefix != "" {
mux := http.NewServeMux()
mux.Handle(prefix+"/", http.StripPrefix(prefix, h))
h = mux
}
// Create request handler function
cb := js.FuncOf(func(_ js.Value, args []js.Value) interface{} {
promise, resolve, reject := newPromiseOptimized()
go handleRequest(h, args[1], resolve, reject)
return promise
})
jsWasmHTTP.Call("setHandler", cb)
return cb.Release
}
// handleRequest processes the request with panic recovery
func handleRequest(h http.Handler, jsReq js.Value, resolve, reject func(interface{})) {
defer func() {
if r := recover(); r != nil {
var errMsg string
if err, ok := r.(error); ok {
errMsg = fmt.Sprintf("wasmhttp: panic: %+v", err)
} else {
errMsg = fmt.Sprintf("wasmhttp: panic: %v", r)
}
reject(errMsg)
}
}()
recorder := newResponseRecorder()
h.ServeHTTP(recorder, buildRequest(jsReq))
resolve(recorder.jsResponse())
}
// buildRequest creates an http.Request from JS Request
func buildRequest(jsReq js.Value) *http.Request {
// Get request body
arrayBuffer, err := awaitPromiseOptimized(jsReq.Call("arrayBuffer"))
if err != nil {
panic(err)
}
// Create body buffer
jsBody := jsUint8Array.New(arrayBuffer)
bodyLen := jsBody.Get("length").Int()
body := make([]byte, bodyLen)
js.CopyBytesToGo(body, jsBody)
// Create request
req := httptest.NewRequest(
jsReq.Get("method").String(),
jsReq.Get("url").String(),
bytes.NewReader(body),
)
// Set headers efficiently
headers := jsReq.Get("headers")
headersIt := headers.Call("entries")
for {
entry := headersIt.Call("next")
if entry.Get("done").Bool() {
break
}
pair := entry.Get("value")
req.Header.Set(pair.Index(0).String(), pair.Index(1).String())
}
return req
}
// ResponseRecorder with optimized buffer handling
type ResponseRecorder struct {
*httptest.ResponseRecorder
buffer *bytes.Buffer
}
func newResponseRecorder() *ResponseRecorder {
return &ResponseRecorder{
ResponseRecorder: httptest.NewRecorder(),
buffer: bufferPool.Get().(*bytes.Buffer),
}
}
// jsResponse creates a JS Response with optimized memory usage
func (rr *ResponseRecorder) jsResponse() js.Value {
defer func() {
rr.buffer.Reset()
bufferPool.Put(rr.buffer)
}()
res := rr.Result()
defer res.Body.Close()
// Prepare response body
body := js.Undefined()
if res.ContentLength != 0 {
if _, err := io.Copy(rr.buffer, res.Body); err != nil {
panic(err)
}
bodyBytes := rr.buffer.Bytes()
body = jsUint8Array.New(len(bodyBytes))
js.CopyBytesToJS(body, bodyBytes)
}
// Prepare response init object
init := make(map[string]interface{}, 3)
if res.StatusCode != 0 {
init["status"] = res.StatusCode
}
if len(res.Header) > 0 {
headers := make(map[string]interface{}, len(res.Header))
for k, v := range res.Header {
if len(v) > 0 {
headers[k] = v[0]
}
}
init["headers"] = headers
}
return jsResponse.New(body, init)
}
// newPromiseOptimized creates a new JavaScript Promise with optimized callback handling
func newPromiseOptimized() (js.Value, func(interface{}), func(interface{})) {
var (
resolve func(interface{})
reject func(interface{})
promiseFunc = js.FuncOf(func(_ js.Value, args []js.Value) interface{} {
resolve = func(v interface{}) { args[0].Invoke(v) }
reject = func(v interface{}) { args[1].Invoke(v) }
return js.Undefined()
})
)
defer promiseFunc.Release()
return jsPromise.New(promiseFunc), resolve, reject
}
// awaitPromiseOptimized waits for Promise resolution with optimized channel handling
func awaitPromiseOptimized(promise js.Value) (js.Value, error) {
done := make(chan struct{})
var (
result js.Value
err error
)
thenFunc := js.FuncOf(func(_ js.Value, args []js.Value) interface{} {
result = args[0]
close(done)
return nil
})
defer thenFunc.Release()
catchFunc := js.FuncOf(func(_ js.Value, args []js.Value) interface{} {
err = js.Error{Value: args[0]}
close(done)
return nil
})
defer catchFunc.Release()
promise.Call("then", thenFunc).Call("catch", catchFunc)
<-done
return result, err
}
@@ -16,7 +16,7 @@ import (
"git.sr.ht/~sircmpwn/go-bare"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
type structMarshal struct {
@@ -13,7 +13,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
func TestNewAccumulator100(t *testing.T) {
@@ -12,7 +12,7 @@ import (
"git.sr.ht/~sircmpwn/go-bare"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
// SecretKey is the secret alpha only held by the accumulator manager.
@@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
func TestSecretKeyMarshal(t *testing.T) {
@@ -10,7 +10,7 @@ import (
"fmt"
"math"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
// dad constructs two polynomials - dA(x) and dD(x)
@@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
func TestEvaluatePolyG1(t *testing.T) {
@@ -14,7 +14,7 @@ import (
"git.sr.ht/~sircmpwn/go-bare"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
type proofParamsMarshal struct {
@@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
func TestProofParamsMarshal(t *testing.T) {
@@ -12,7 +12,7 @@ import (
"git.sr.ht/~sircmpwn/go-bare"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
// MembershipWitness contains the witness c and the value y respect to the accumulator state.
@@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
func Test_Membership_Witness_New(t *testing.T) {
@@ -10,7 +10,7 @@ import (
"github.com/pkg/errors"
"golang.org/x/crypto/sha3"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
// generators contains a list of points to be used as generators for bulletproofs.
@@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require"
"golang.org/x/crypto/sha3"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
func TestGeneratorsHappyPath(t *testing.T) {
@@ -9,7 +9,7 @@ package bulletproof
import (
"github.com/pkg/errors"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
// innerProduct takes two lists of scalars (a, b) and performs the dot product returning a single scalar.
@@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
func TestInnerProductHappyPath(t *testing.T) {
@@ -11,7 +11,7 @@ import (
"github.com/gtank/merlin"
"github.com/pkg/errors"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
// InnerProductProver is the struct used to create InnerProductProofs
@@ -7,7 +7,7 @@ import (
"github.com/gtank/merlin"
"github.com/stretchr/testify/require"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
func TestIPPHappyPath(t *testing.T) {
@@ -4,7 +4,7 @@ import (
"github.com/gtank/merlin"
"github.com/pkg/errors"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
// InnerProductVerifier is the struct used to verify inner product proofs
@@ -7,7 +7,7 @@ import (
"github.com/gtank/merlin"
"github.com/stretchr/testify/require"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
func TestIPPVerifyHappyPath(t *testing.T) {
@@ -6,7 +6,7 @@ import (
"github.com/gtank/merlin"
"github.com/pkg/errors"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
// BatchProve proves that a list of scalars v are in the range n.
@@ -7,7 +7,7 @@ import (
"github.com/gtank/merlin"
"github.com/stretchr/testify/require"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
func TestRangeBatchProverHappyPath(t *testing.T) {
@@ -4,7 +4,7 @@ import (
"github.com/gtank/merlin"
"github.com/pkg/errors"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
// VerifyBatched verifies a given batched range proof.
@@ -7,7 +7,7 @@ import (
"github.com/gtank/merlin"
"github.com/stretchr/testify/require"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
func TestRangeBatchVerifyHappyPath(t *testing.T) {
@@ -14,7 +14,7 @@ import (
"github.com/gtank/merlin"
"github.com/pkg/errors"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
// RangeProver is the struct used to create RangeProofs
@@ -7,7 +7,7 @@ import (
"github.com/gtank/merlin"
"github.com/stretchr/testify/require"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
func TestRangeProverHappyPath(t *testing.T) {
@@ -4,7 +4,7 @@ import (
"github.com/gtank/merlin"
"github.com/pkg/errors"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
// RangeVerifier is the struct used to verify RangeProofs
@@ -7,7 +7,7 @@ import (
"github.com/gtank/merlin"
"github.com/stretchr/testify/require"
"github.com/onsonr/sonr/internal/crypto/core/curves"
"github.com/onsonr/sonr/crypto/core/curves"
)
func TestRangeVerifyHappyPath(t *testing.T) {
@@ -19,7 +19,7 @@ import (
bls12377 "github.com/consensys/gnark-crypto/ecc/bls12-377"
"golang.org/x/crypto/sha3"
"github.com/onsonr/sonr/internal/crypto/core"
"github.com/onsonr/sonr/crypto/core"
)
// See 'r' = https://eprint.iacr.org/2018/962.pdf Figure 16
@@ -13,9 +13,9 @@ import (
"golang.org/x/crypto/sha3"
"github.com/onsonr/sonr/internal/crypto/core/curves/native"
"github.com/onsonr/sonr/internal/crypto/core/curves/native/bls12381"
"github.com/onsonr/sonr/internal/crypto/internal"
"github.com/onsonr/sonr/crypto/core/curves/native"
"github.com/onsonr/sonr/crypto/core/curves/native/bls12381"
"github.com/onsonr/sonr/crypto/internal"
)
var bls12381modulus = bhex("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab")
@@ -16,7 +16,7 @@ import (
"math/big"
"sync"
"github.com/onsonr/sonr/internal/crypto/core/curves/native/bls12381"
"github.com/onsonr/sonr/crypto/core/curves/native/bls12381"
)
var (
@@ -12,10 +12,10 @@ import (
"fmt"
"math/big"
"github.com/onsonr/sonr/internal/crypto/core"
"github.com/onsonr/sonr/crypto/core"
"github.com/dustinxie/ecc"
"github.com/onsonr/sonr/internal/crypto/internal"
"github.com/onsonr/sonr/crypto/internal"
)
var curveNameToID = map[string]byte{
@@ -15,8 +15,8 @@ import (
"github.com/btcsuite/btcd/btcec/v2"
"github.com/stretchr/testify/require"
"github.com/onsonr/sonr/internal/crypto/core"
tt "github.com/onsonr/sonr/internal/crypto/internal"
"github.com/onsonr/sonr/crypto/core"
tt "github.com/onsonr/sonr/crypto/internal"
)
func TestIsIdentity(t *testing.T) {
@@ -18,9 +18,9 @@ import (
"github.com/btcsuite/btcd/btcec/v2"
"github.com/bwesterb/go-ristretto"
"github.com/onsonr/sonr/internal/crypto/core"
"github.com/onsonr/sonr/internal/crypto/core/curves/native/bls12381"
"github.com/onsonr/sonr/internal/crypto/internal"
"github.com/onsonr/sonr/crypto/core"
"github.com/onsonr/sonr/crypto/core/curves/native/bls12381"
"github.com/onsonr/sonr/crypto/internal"
)
type EcScalar interface {
@@ -19,7 +19,7 @@ import (
"github.com/bwesterb/go-ristretto"
ed "github.com/bwesterb/go-ristretto/edwards25519"
"github.com/onsonr/sonr/internal/crypto/internal"
"github.com/onsonr/sonr/crypto/internal"
)
type ScalarEd25519 struct {
@@ -15,7 +15,7 @@ import (
ed "filippo.io/edwards25519"
"github.com/stretchr/testify/require"
"github.com/onsonr/sonr/internal/crypto/internal"
"github.com/onsonr/sonr/crypto/internal"
)
func TestScalarEd25519Random(t *testing.T) {
@@ -9,8 +9,8 @@ import (
"github.com/btcsuite/btcd/btcec/v2"
mod "github.com/onsonr/sonr/internal/crypto/core"
"github.com/onsonr/sonr/internal/crypto/internal"
mod "github.com/onsonr/sonr/crypto/core"
"github.com/onsonr/sonr/crypto/internal"
)
func BenchmarkK256(b *testing.B) {
@@ -15,11 +15,11 @@ import (
"github.com/btcsuite/btcd/btcec/v2"
"github.com/onsonr/sonr/internal/crypto/core/curves/native"
secp256k1 "github.com/onsonr/sonr/internal/crypto/core/curves/native/k256"
"github.com/onsonr/sonr/internal/crypto/core/curves/native/k256/fp"
"github.com/onsonr/sonr/internal/crypto/core/curves/native/k256/fq"
"github.com/onsonr/sonr/internal/crypto/internal"
"github.com/onsonr/sonr/crypto/core/curves/native"
secp256k1 "github.com/onsonr/sonr/crypto/core/curves/native/k256"
"github.com/onsonr/sonr/crypto/core/curves/native/k256/fp"
"github.com/onsonr/sonr/crypto/core/curves/native/k256/fq"
"github.com/onsonr/sonr/crypto/internal"
)
var (
@@ -3,7 +3,7 @@ package bls12381
import (
"math/bits"
"github.com/onsonr/sonr/internal/crypto/core/curves/native"
"github.com/onsonr/sonr/crypto/core/curves/native"
)
var fqModulusBytes = [native.FieldBytes]byte{0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x5b, 0xfe, 0xff, 0x02, 0xa4, 0xbd, 0x53, 0x05, 0xd8, 0xa1, 0x09, 0x08, 0xd8, 0x39, 0x33, 0x48, 0x7d, 0x9d, 0x29, 0x53, 0xa7, 0xed, 0x73}
@@ -6,8 +6,8 @@ import (
"io"
"math/big"
"github.com/onsonr/sonr/internal/crypto/core/curves/native"
"github.com/onsonr/sonr/internal/crypto/internal"
"github.com/onsonr/sonr/crypto/core/curves/native"
"github.com/onsonr/sonr/crypto/internal"
)
// fp field element mod p
@@ -14,7 +14,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/onsonr/sonr/internal/crypto/internal"
"github.com/onsonr/sonr/crypto/internal"
)
func TestFpSetOne(t *testing.T) {
@@ -5,7 +5,7 @@ import (
"math/big"
"sync"
"github.com/onsonr/sonr/internal/crypto/core/curves/native"
"github.com/onsonr/sonr/crypto/core/curves/native"
)
type Fq [native.FieldLimbs]uint64
@@ -14,8 +14,8 @@ import (
"github.com/stretchr/testify/require"
"github.com/onsonr/sonr/internal/crypto/core/curves/native"
"github.com/onsonr/sonr/internal/crypto/internal"
"github.com/onsonr/sonr/crypto/core/curves/native"
"github.com/onsonr/sonr/crypto/internal"
)
func TestFqSetOne(t *testing.T) {
@@ -7,8 +7,8 @@ import (
"github.com/pkg/errors"
"github.com/onsonr/sonr/internal/crypto/core/curves/native"
"github.com/onsonr/sonr/internal/crypto/internal"
"github.com/onsonr/sonr/crypto/core/curves/native"
"github.com/onsonr/sonr/crypto/internal"
)
var (
@@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/onsonr/sonr/internal/crypto/core/curves/native"
"github.com/onsonr/sonr/crypto/core/curves/native"
)
func TestG1IsOnCurve(t *testing.T) {
@@ -7,8 +7,8 @@ import (
"github.com/pkg/errors"
"github.com/onsonr/sonr/internal/crypto/core/curves/native"
"github.com/onsonr/sonr/internal/crypto/internal"
"github.com/onsonr/sonr/crypto/core/curves/native"
"github.com/onsonr/sonr/crypto/internal"
)
var (
@@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/onsonr/sonr/internal/crypto/core/curves/native"
"github.com/onsonr/sonr/crypto/core/curves/native"
)
func TestG2IsOnCurve(t *testing.T) {
@@ -3,8 +3,8 @@ package bls12381
import (
"io"
"github.com/onsonr/sonr/internal/crypto/core/curves/native"
"github.com/onsonr/sonr/internal/crypto/internal"
"github.com/onsonr/sonr/crypto/core/curves/native"
"github.com/onsonr/sonr/crypto/internal"
)
// GtFieldBytes is the number of bytes needed to represent this field
@@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/onsonr/sonr/internal/crypto/core/curves/native"
"github.com/onsonr/sonr/crypto/core/curves/native"
)
func TestSinglePairing(t *testing.T) {
@@ -5,7 +5,7 @@ import (
"fmt"
"math/big"
"github.com/onsonr/sonr/internal/crypto/internal"
"github.com/onsonr/sonr/crypto/internal"
)
// FieldLimbs is the number of limbs needed to represent this field
@@ -10,7 +10,7 @@ import (
"math/big"
"sync"
"github.com/onsonr/sonr/internal/crypto/core/curves/native"
"github.com/onsonr/sonr/crypto/core/curves/native"
)
var (
@@ -14,8 +14,8 @@ import (
"github.com/stretchr/testify/require"
"github.com/onsonr/sonr/internal/crypto/core/curves/native"
"github.com/onsonr/sonr/internal/crypto/internal"
"github.com/onsonr/sonr/crypto/core/curves/native"
"github.com/onsonr/sonr/crypto/internal"
)
func TestFpSetOne(t *testing.T) {
@@ -10,7 +10,7 @@ import (
"math/big"
"sync"
"github.com/onsonr/sonr/internal/crypto/core/curves/native"
"github.com/onsonr/sonr/crypto/core/curves/native"
)
var (
@@ -14,8 +14,8 @@ import (
"github.com/stretchr/testify/require"
"github.com/onsonr/sonr/internal/crypto/core/curves/native"
"github.com/onsonr/sonr/internal/crypto/internal"
"github.com/onsonr/sonr/crypto/core/curves/native"
"github.com/onsonr/sonr/crypto/internal"
)
func TestFqSetOne(t *testing.T) {

Some files were not shown because too many files have changed in this diff Show More