Migrate to hero ledger gateway client #6

Merged
emre merged 6 commits from development_gateway_client into development 2026-02-27 08:54:06 +00:00
Member

Migrate all Hero Ledger operations from the backend proxy to the browser-native heroledger_gateway_client, and add encrypted mnemonic vault storage using Web Crypto API.

Changes

Gateway client migration (Phase 1-2)

  • Add heroledger_gateway_client dependency (WASM-compatible, from lhumina_code/hero_ledger)
  • Create heroledger.rs wrapper with typed methods: account activation, existence check, SPORE balance/transfer, marketplace listings, token registration
  • Initialize gateway client on wallet connect via set_credentials_from_mnemonic()
  • Migrate all frontend components to use gateway client directly instead of backend API calls

Encrypted vault integration (Phase 3)

  • Enable vault feature: bump web-sys to 0.3.90, wasm-bindgen to 0.2.113
  • Vault wrapper methods: vault_save, vault_load, vault_list, vault_exists, vault_remove
  • Login modal: "Unlock Vault" tab when saved entries exist, password-based decryption
  • Post-login prompt: "Save to Browser Vault?" with AES-256-GCM encryption (PBKDF2 key derivation)
  • Identity page: vault status card with save/remove controls

Backend cleanup (Phase 4-5)

  • Delete near_tx.rs entirely (-271 lines)
  • Remove all Hero Ledger API handlers from api.rs (~-842 lines)
  • Remove Hero Ledger state from state.rs (NearConfig, pending stores, http_client)
  • Remove all 11 /heroledger/* routes from main.rs
  • Remove sha2, bs58, reqwest from backend deps
  • Remove all Hero Ledger types from shared/src/lib.rs (~-130 lines)
  • Remove all Hero Ledger API wrappers from frontend api.rs

Tests and CI

  • Bash curl-based smoke tests for all backend API endpoints (scripts/smoke-test.sh)
  • Server lifecycle runner (scripts/run-smoke-tests.sh)
  • Forgejo CI workflow (.forgejo/workflows/test.yml): compile, clippy, fmt, unit tests
  • Makefile targets: test-all, smoke-test

Net impact

  • ~1,200 lines removed, ~900 lines added (net reduction with vault + tests)
  • Backend is now purely a TFChain proxy — no Hero Ledger code remains
  • No more server-side NEAR session management
  • Mnemonic can be securely stored in browser vault (PBKDF2 + AES-256-GCM)

Testing

  • cargo check -p portal-backend — clean
  • cargo check -p portal-frontend --target wasm32-unknown-unknown — clean
  • cargo fmt --all -- --check — clean
  • Smoke test script covers all 15+ backend endpoints

Closes #5

Migrate all Hero Ledger operations from the backend proxy to the browser-native `heroledger_gateway_client`, and add encrypted mnemonic vault storage using Web Crypto API. ## Changes ### Gateway client migration (Phase 1-2) - Add `heroledger_gateway_client` dependency (WASM-compatible, from `lhumina_code/hero_ledger`) - Create `heroledger.rs` wrapper with typed methods: account activation, existence check, SPORE balance/transfer, marketplace listings, token registration - Initialize gateway client on wallet connect via `set_credentials_from_mnemonic()` - Migrate all frontend components to use gateway client directly instead of backend API calls ### Encrypted vault integration (Phase 3) - Enable `vault` feature: bump `web-sys` to 0.3.90, `wasm-bindgen` to 0.2.113 - Vault wrapper methods: `vault_save`, `vault_load`, `vault_list`, `vault_exists`, `vault_remove` - Login modal: "Unlock Vault" tab when saved entries exist, password-based decryption - Post-login prompt: "Save to Browser Vault?" with AES-256-GCM encryption (PBKDF2 key derivation) - Identity page: vault status card with save/remove controls ### Backend cleanup (Phase 4-5) - Delete `near_tx.rs` entirely (-271 lines) - Remove all Hero Ledger API handlers from `api.rs` (~-842 lines) - Remove Hero Ledger state from `state.rs` (NearConfig, pending stores, http_client) - Remove all 11 `/heroledger/*` routes from `main.rs` - Remove `sha2`, `bs58`, `reqwest` from backend deps - Remove all Hero Ledger types from `shared/src/lib.rs` (~-130 lines) - Remove all Hero Ledger API wrappers from frontend `api.rs` ### Tests and CI - Bash curl-based smoke tests for all backend API endpoints (`scripts/smoke-test.sh`) - Server lifecycle runner (`scripts/run-smoke-tests.sh`) - Forgejo CI workflow (`.forgejo/workflows/test.yml`): compile, clippy, fmt, unit tests - Makefile targets: `test-all`, `smoke-test` ## Net impact - ~1,200 lines removed, ~900 lines added (net reduction with vault + tests) - Backend is now purely a TFChain proxy — no Hero Ledger code remains - No more server-side NEAR session management - Mnemonic can be securely stored in browser vault (PBKDF2 + AES-256-GCM) ## Testing - `cargo check -p portal-backend` — clean - `cargo check -p portal-frontend --target wasm32-unknown-unknown` — clean - `cargo fmt --all -- --check` — clean - Smoke test script covers all 15+ backend endpoints Closes #5
Replace all backend Hero Ledger proxy code with direct browser-to-gateway
communication using heroledger_gateway_client. This eliminates the
prepare/sign/submit dance (~1,400 lines removed net) and collapses
all ledger operations into single gateway client calls.

Frontend:
- Add heroledger_gateway_client dependency (WASM-compatible)
- New heroledger.rs wrapper with typed methods for all gateway operations
- New config.rs for gateway URL configuration
- Migrate pre-registration, SPORE transfers, marketplace registration,
  and account detection to use gateway client directly
- Remove ED25519/SLIP-10 crypto code from signing.rs (gateway handles internally)
- Clean up api.rs: remove all Hero Ledger API wrapper functions

Backend:
- Delete near_tx.rs entirely (-271 lines)
- Remove all 11 /heroledger/* route handlers from api.rs (-846 lines)
- Remove NearConfig, PendingNodeRegistration, http_client from state.rs
- Remove mod near_tx and heroledger routes from main.rs
- Remove sha2, bs58, reqwest dependencies

Shared:
- Remove all Hero Ledger request/response types from lib.rs (-130 lines)

Note: Vault integration (encrypted mnemonic storage) deferred due to
web-sys version incompatibility (needs 0.3.88, project resolves 0.3.85).

Closes #5

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
feat: add encrypted vault integration, smoke tests, and CI workflow
Some checks failed
Test / check (pull_request) Failing after 1m29s
caa598d1a3
Enable the vault feature in heroledger_gateway_client for encrypted
mnemonic storage in browser localStorage (PBKDF2 + AES-256-GCM via
Web Crypto API). Login modal now offers "Unlock Vault" tab when saved
entries exist, and prompts to save after mnemonic login. Identity page
shows vault status with save/remove controls.

Also adds bash curl-based smoke tests for all backend API endpoints,
a Forgejo CI workflow (test.yml) for compile/lint/format/test checks,
and Makefile targets (test-all, smoke-test).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fix: gate vault methods behind wasm32 cfg for cargo test
Some checks failed
Test / check (pull_request) Failing after 1m43s
ff47071fbb
The vault module in heroledger_gateway_client is only compiled for
wasm32 targets (uses Web Crypto API). Add cfg(not(wasm32)) stubs so
`cargo test --all` compiles the frontend on the host target.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fix: install clippy and rustfmt in CI workflow
All checks were successful
Test / check (pull_request) Successful in 1m54s
9626a54351
The --profile minimal rustup installation only includes rustc, rust-std,
and cargo. Add explicit `rustup component add clippy rustfmt` so the
Clippy and Format check steps work.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mik-tf changed title from WIP: Migrate to hero ledger gateway client to Migrate to hero ledger gateway client 2026-02-26 23:39:27 +00:00
fix: resolve RefCell borrow panic across async await points
Some checks failed
Test / check (pull_request) Failing after 1m30s
0264b90dd2
Wrap GatewayClient in Option to prevent "RefCell already mutably borrowed"
panics when Dioxus re-renders during suspended futures. Add HandleExt trait
with async-safe helpers that take/put client around await points.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
style: fix rustfmt formatting
All checks were successful
Test / check (pull_request) Successful in 1m50s
d0ee3e8885
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
emre merged commit 863f704eae into development 2026-02-27 08:54:06 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mycelium/www_migrate_mycelium!6
No description provided.