Page MenuHomePhabricator

[Cashtab][Alias] Update alias-server wrappers to return JSON
ClosedPublic

Authored by emack on Jul 6 2023, 07:28.

Details

Summary

As per feedback from D14212, the wrapper for the alias-server endpoints should be returning the JSON responses directly rather than leaving it to frontend components to parse.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

emack requested review of this revision.Jul 6 2023, 07:28
Fabien added inline comments.
cashtab/src/utils/aliasUtils.js
16 ↗(On Diff #41284)

why are these variables declared at this scope ?

21 ↗(On Diff #41284)

Is !aliasServerResp possible ?

27 ↗(On Diff #41284)

I think return await aliasServerResp.json(); does the same and removes one variable

91 ↗(On Diff #41284)

same questions/remarks

emack marked 4 inline comments as done.

improved error handling for when alias-server is non-responsive, improved code efficient per feedback

cashtab/src/utils/aliasUtils.js
80 ↗(On Diff #41291)

Interesting how this method looks similar to the above one, right ? It's like only the endpoint differs.

Consolidated getAliasDetails and getAliasesForAddress into a single alias-server wrapper, passing in the endpoint and query param as inputs. Unit tests updated accordingly.

One nit, otherwise looks good to me.

cashtab/src/utils/aliasUtils.js
45 ↗(On Diff #41308)

Nit: the function name needs to be updated.
Also it would be good to print the endpoint as well, it will be useful for debugging.

emack marked an inline comment as done.

Updated catch block to log the endpoint output on error

This revision is now accepted and ready to land.Jul 7 2023, 16:31