fix: validate withdrawal address in watcher (#13)#23
Conversation
|
@odiseusme is attempting to deploy a commit to the rosen-bridge Team on Vercel. A member of the Team first needs to authorize it. |
|
Verification of acceptance conditions (done locally via source inspection):
One small UX delta: we trim whitespace on the input's |
|
I reviewed your #23 merge request. It works, but it’s not efficient. Loading ergo-lib-wasm-browser on the client adds unnecessary overhead. We prefer handling this in the API and returning a simple validation result to the browser. We’re planning to implement this on the API side, so we can continue this merge after that change. |
|
I’m happy to take the API-side implementation on as part of this PR if that’s useful — a validation endpoint returning a simple per-chain result, with the form wired to call it instead of running WASM in the browser. Or if you’d rather build the primitive internally, I’ll wait and adapt the client once it lands. Whichever fits your roadmap — just let me know. |
|
We will implement the API first, and then you can continue. |
|
Sounds good — I'll wait for the API-side validation to land, then refactor this PR to drop the client-side WASM and call the endpoint instead. Ping me here (or link the endpoint) once it's ready and I'll pick it back up. |
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.