Skip to content

feat(flipcash): wire SetUsername through the profile service layer - #1320

Merged
bmc08gt merged 2 commits into
code/cashfrom
feat/profile-set-username
Aug 24, 2026
Merged

feat(flipcash): wire SetUsername through the profile service layer#1320
bmc08gt merged 2 commits into
code/cashfrom
feat/profile-set-username

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

The Profile service gained a SetUsername RPC upstream. This vendors the proto change and builds out the write path; UserProfile.username and the read path already landed in #1316.

Proto

profile/v1/profile_service.protoSetUsername(SetUsernameRequest) → SetUsernameResponse, re-vendored from flipcash2-protobuf-api at HEAD. opencode was already current. The response Result enum is OK, INVALID_USERNAME, DENIED, ALREADY_TAKEN, FAILED_MODERATED, INSUFFICIENT_BALANCE, RESERVED_WORD, with flagged_category set only on FAILED_MODERATED.

Service layer

Api → Service → Repository → Controller, following the existing setDisplayName chain (closest analogue: same auth, same moderation-category shape). ProfileController.setUsername merges the new handle into the locally cached profile on success, so anything observing the profile — a setup flow deciding which steps remain, for instance — sees it without waiting for a refresh.

SetUsernameError has a case per non-OK result. Unrecognized and Other are NotifiableError; the rest are not.

No Hilt changes — ProfileRepository is already bound in FlipcashModule.

Error reporting change to setDisplayName

InternalProfileRepository.setUsername skips ErrorUtils.handleError for the five results that represent the server answering a user's choice of handle rather than a fault: InvalidUsername, AlreadyTaken, ReservedWord, FailedModerated, InsufficientBalance. AlreadyTaken in particular will be routine once a claim UI exists, and routing it through error tracking would be noise.

setDisplayName now does the same for InvalidDisplayName and FailedModerated, so the two paths behave alike. This is a behavior change to existing code: those two cases previously reached ErrorUtils.handleError, which drives a TopBarManager toast when isDisplayErrors is on, alongside the Bugsnag report. Its only caller, NameEntryViewModel, already handles every failure itself — a per-category alert for FailedModerated and a catch-all else — so what this removes is a duplicate report, not the user's feedback. Denied, Unrecognized, and Other still report on both paths.

Not included

No UI. Nothing calls ProfileController.setUsername yet — this is the plumbing for a username-claim flow, and INSUFFICIENT_BALANCE suggests that flow will need a price and a payment step to design against.

Adds the Profile service's SetUsername RPC with its request and response
messages. Vendored from flipcash2-protobuf-api at HEAD; opencode was
already current.
Adds the Api, Service, Repository, and Controller methods for the new
SetUsername RPC, following the setDisplayName chain. On success the
controller merges the username into the locally cached profile so
observers see it without waiting for a refresh.

SetUsernameError covers each non-OK result: InvalidUsername, Denied,
AlreadyTaken, FailedModerated (carrying the flagged category),
InsufficientBalance, ReservedWord, plus Unrecognized and Other.

InternalProfileRepository skips ErrorUtils.handleError for the results
that are the server answering a user's choice of handle rather than a
fault — InvalidUsername, AlreadyTaken, ReservedWord, FailedModerated,
InsufficientBalance. setDisplayName gets the same treatment for
InvalidDisplayName and FailedModerated; its only caller,
NameEntryViewModel, already renders its own alert for every failure, so
this drops a duplicate report path rather than user-facing feedback.
@github-actions github-actions Bot added type: feature New functionality area: network gRPC, connectivity, API, exchange rates and removed type: feature New functionality labels Aug 24, 2026
@bmc08gt
bmc08gt merged commit 4305a17 into code/cash Aug 24, 2026
3 checks passed
bmc08gt added a commit that referenced this pull request Aug 24, 2026
* chore(protos): update flipcash protobuf definitions

Adds UserFlags.username_min_balance, the USDF amount in quarks a user
must hold across all currencies before setting a username. Vendored from
flipcash2-protobuf-api at HEAD; opencode was already current.

* feat(userflags): surface the username minimum balance flag

Maps UserFlags.username_min_balance through to the domain model and the
debug flag editor as a read-only entry. It gates the username claim flow
added in #1320, which has no UI yet, so nothing reads it so far.

The default is Fiat.Zero rather than Fiat.MAX_VALUE. This is a minimum
balance to hold, like minimumHolderValue, not a price to pay like
newCurrencyPurchaseAmount. An absent flag should leave the gate open and
let the server answer with INSUFFICIENT_BALANCE, not hard-block a claim
the server would have allowed.

CachedFlags also carries the field, since its toDomain() reconstructs the
whole UserFlags. It defaults to zero quarks so payloads cached before this
change still decode -- UserFlagsCoordinator drops the entire cached flag
set when decodeFromString fails, so an undefaulted field would blank the
flags on the first launch after upgrade.

ReadOnlyEntry holds a Boolean, so the amount goes in readOnlyTextEntries
formatted with Fiat.FormattingRule.Truncated, matching WithdrawalFeeAmount.
@bmc08gt
bmc08gt deleted the feat/profile-set-username branch August 27, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: network gRPC, connectivity, API, exchange rates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant