refactor: support for mockgatehub in local environment#2188
refactor: support for mockgatehub in local environment#2188
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors local development to support MockGatehub + a new local/ Docker stack, and adjusts wallet frontend/backend configuration to work correctly when running inside containers (middleware/SSR using internal hostnames).
Changes:
- Add a new
local/docker-compose stack (Postgres/Redis/Rafiki/Mockgatehub) plus helper scripts and env examples. - Update wallet frontend middleware + HTTP client to call the backend via an internal Docker hostname on the server.
- Add backend support for overriding GateHub base URLs via
GATEHUB_API_BASE_URL, and add a couple of GateHub service race-condition guards.
Reviewed changes
Copilot reviewed 24 out of 26 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-workspace.yaml | Adds e2e workspace entry. |
| pnpm-lock.yaml | Adds lock entries for the new e2e importer + Playwright deps. |
| packages/wallet/frontend/src/utils/helpers.ts | Changes amount formatting truncation logic. |
| packages/wallet/frontend/src/middleware.ts | Replaces userService call with direct fetch to internal backend URL. |
| packages/wallet/frontend/src/lib/httpClient.ts | Switches server-side base URL to internal backend hostname. |
| packages/wallet/frontend/next.config.js | Introduces BACKEND_INTERNAL_URL env mapping + env override for features flag. |
| packages/wallet/frontend/Dockerfile.dev | Adds build args/ENV for Next public env vars. |
| packages/wallet/backend/src/middleware/withSession.ts | Adjusts cookie domain logic (avoid Domain=localhost). |
| packages/wallet/backend/src/gatehub/service.ts | Adds early-return checks to reduce concurrent customer/account creation. |
| packages/wallet/backend/src/gatehub/client.ts | Uses GATEHUB_API_BASE_URL when provided (e.g., Mockgatehub). |
| packages/wallet/backend/src/config/env.ts | Adds GATEHUB_API_BASE_URL env var. |
| local/scripts/rafiki-setup.js | New script to configure Rafiki tenant/assets/liquidity. |
| local/init/dbinit.sql | New local DB init for multiple service DBs/users. |
| local/docker-compose.yml | New local compose stack including Mockgatehub. |
| local/.gitignore | Ignores local pg data artifacts. |
| local/.env.example | New example env for the local compose stack. |
| docker/temp/private-key.pem | Removes committed key material. |
| docker/prod/kratos.yml | Removed legacy prod docker config. |
| docker/prod/docker-compose.yml | Removed legacy prod docker config. |
| docker/prod/.env.example | Removed legacy prod env example. |
| docker/identity.schema.json | Removed legacy Kratos identity schema. |
| docker/entrypoint.sh | Removed legacy Kratos entrypoint. |
| docker/dev/kratos.yml | Removed legacy dev docker config. |
| docker/dev/docker-compose.yml | Removed legacy dev docker config. |
| docker/dev/.env.example | Removed legacy dev env example. |
| .github/copilot-instructions.md | Adds repo instructions (currently still referencing removed docker/dev/*). |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const scaledValue = Number(`${value}e-${assetScale}`) | ||
| const flooredValue = | ||
| Math.floor(Math.round(scaledValue * 10 ** displayScale)) / | ||
| Math.floor(Math.round(scaledValue * 10 ** (displayScale + 4)) / 10 ** 4) / |
There was a problem hiding this comment.
why + 4 is added here?
There was a problem hiding this comment.
I was messing around, forgot to take it out.
I was fighting with some floating point issues causing my tests to fail. I think we can live without it.
| } | ||
| if (cookieVal) { | ||
| try { | ||
| const meRes = await fetch(`${backendUrl}/me`, { |
There was a problem hiding this comment.
use existent service method for the request await userService.me( ${cookieName}=${req.cookies.get(cookieName)?.value} )
There was a problem hiding this comment.
will now use use userService.me() instead of raw fetch
There was a problem hiding this comment.
package.json scripts need to be updated based on the new docker compose file
There was a problem hiding this comment.
update compose path to ./local/docker-compose.yml, remove stale prod scripts
| const key = line.slice(0, idx).trim() | ||
| const value = line.slice(idx + 1).trim() | ||
| result[key] = value | ||
| } |
There was a problem hiding this comment.
new line before return and after block
There was a problem hiding this comment.
add braces to one-line if statements, added blank line before return
local/scripts/rafiki-setup.js
Outdated
| // ---- helpers --------------------------------------------------------------- | ||
| function loadDotEnv(envPath) { | ||
| const result = {} | ||
| if (!fs.existsSync(envPath)) return result |
There was a problem hiding this comment.
use blocks for one line if statements as well.
| const scaledValue = Number(`${value}e-${assetScale}`) | ||
| const flooredValue = | ||
| Math.floor(Math.round(scaledValue * 10 ** displayScale)) / | ||
| Math.floor(Math.round(scaledValue * 10 ** displayScale) / 10 ** 4) / |
There was a problem hiding this comment.
is this change needed?
There was a problem hiding this comment.
Good point. Thank you.
formatAmount is now the same as that of main.
Introduces various changes to the packages to allow for a local environment where we can easily change between pointing to the real Gatehub Sandbox environment, or to a locally hosted mock instance of MockGatehub.
This is part of the greater effort of implementing real Continuous Integration for this project to allow for long term maintenance.