You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds ergo-lib-wasm-browser (^0.24.1) to apps/watcher dependencies
Adds webpack/WASM configuration to apps/watcher/next.config.js (mirrors the experiments block from apps/rosen/next.config.js, plus output.webassemblyModuleFilename needed for output: 'export')
Adds apps/watcher/src/utils/validateErgoAddress.ts — a browser-side Ergo address validator that lazy-loads the WASM module on first use
Refactors the address field in apps/watcher/src/app/actions/@form/withdraw/page.tsx from register('address', { required }) to useController with an async validate rule, mirroring the pattern in apps/rosen/src/hooks/useBridgeForm.ts
Validation behavior
The validator uses Address.from_base58() from ergo-lib-wasm-browser, which accepts both mainnet and testnet Ergo addresses. The issue specifies "an Ergo address" (not "a mainnet Ergo address"), and a Watcher operator may be running a testnet deployment — restricting to mainnet would break testnet operators.
Error messages mirror the Rosen app's useBridgeForm exactly:
Empty input: "Address cannot be empty" (intentional change from the previous "Address is required" to match Rosen)
Invalid address: "Invalid Address"
Unexpected error during validation: "Something went wrong! please try again"
Verification
npm run build for apps/watcher succeeds; the .wasm chunk is emitted to out/_next/static/wasm/
The WASM file is served with Content-Type: application/wasm and HTTP 200 from a static-server smoke test
No new TypeScript errors introduced (verified by comparing npm run type-check output against the pre-PR baseline)
Verification of acceptance conditions (done locally via source inspection):
Error display: Uses react-hook-form's formState.errors.address.message rendered through the shared TextField's helperText prop (same @rosen-bridge/ui-kit component as Rosen). Visual parity follows from the shared component.
Validation logic: Equivalent to Rosen's by construction. Rosen's chain runs server-side: useBridgeForm → Server Action → @rosen-network/base.validateAddress → @rosen-bridge/address-codec → for ERGO_CHAIN: ergoLib.Address.from_base58(address). Our PR runs Address.from_base58(address) directly in the browser via ergo-lib-wasm-browser. Same Rust source, same accept/reject behavior. The Watcher's output: 'export' precludes Server Actions, which is why we go direct-to-WASM.
react-hook-form API:useController with async validate rule, mirroring apps/rosen/src/hooks/useBridgeForm.ts. Empty check ("Address cannot be empty"), validation call, fallback ("Invalid Address"), catch-all ("Something went wrong! please try again") — all identical strings to Rosen's flow.
One small UX delta: we trim whitespace on the input's onBlur before validation. Rosen's ErgoNetwork.toSafeAddress is a no-op pass-through (return address), so where Rosen would reject " 9fuoH... ", our form accepts it. We've kept this small UX improvement intentionally — happy to discuss if there's a reason to revert.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #13.
Changes
ergo-lib-wasm-browser(^0.24.1) toapps/watcherdependenciesapps/watcher/next.config.js(mirrors theexperimentsblock fromapps/rosen/next.config.js, plusoutput.webassemblyModuleFilenameneeded foroutput: 'export')apps/watcher/src/utils/validateErgoAddress.ts— a browser-side Ergo address validator that lazy-loads the WASM module on first useapps/watcher/src/app/actions/@form/withdraw/page.tsxfromregister('address', { required })touseControllerwith an asyncvalidaterule, mirroring the pattern inapps/rosen/src/hooks/useBridgeForm.tsValidation behavior
The validator uses
Address.from_base58()fromergo-lib-wasm-browser, which accepts both mainnet and testnet Ergo addresses. The issue specifies "an Ergo address" (not "a mainnet Ergo address"), and a Watcher operator may be running a testnet deployment — restricting to mainnet would break testnet operators.Error messages mirror the Rosen app's
useBridgeFormexactly:"Address cannot be empty"(intentional change from the previous"Address is required"to match Rosen)"Invalid Address""Something went wrong! please try again"Verification
npm run buildforapps/watchersucceeds; the.wasmchunk is emitted toout/_next/static/wasm/Content-Type: application/wasmand HTTP 200 from a static-server smoke testnpm run type-checkoutput against the pre-PR baseline)Notes for reviewers
ignoreBuildErrorsfrom Next config #8 and can land in either order. Both PRs touchapps/watcher/next.config.jsbut in non-overlapping ways.apps/watcher/src/app/App.tsxuntil RemoveignoreBuildErrorsfrom Next config #8 merges — those errors exist on the currentdevbranch and are exactly what RemoveignoreBuildErrorsfrom Next config #8 fixes. They are not introduced by this PR.