Repository navigation
refactor(tokens): replace Token.Info's origin flags with TokenInfoEntry - #1533
Merged
Merged
Conversation
Token.Info carried four parameters that each encoded where the screen was opened from: shortfall, fromDeeplink, asPush and returnAfterBuy. Nothing stopped a caller from combining them in ways that mean nothing, such as a deeplink that returns after a buy. TokenInfoEntry names the origin instead (Wallet, Deeplink, Discovery, Chat, ChatGate), and each origin decides whether the screen is pushed and whether a successful buy pops back. Analytics sources are unchanged: Deeplink still reports Deeplink, and every other origin reports Wallet, as before. shortfall is dropped rather than modelled as a Give origin. Nothing has passed it since 6419a95, when Give's shortfall started going straight to Token.Swap. AppContent still matches the scene key's toString(), now on the entry name instead of "asPush=true".
…r a swap The entries exposed asPush and returnAfterBuy as booleans with defaults, so reading an origin didn't tell you how it behaves, and TokenInfoScreen still decided inline, untested, whether a buy should pop. Each origin now declares its presentation (CardExpand or Push) and afterBuy (Stay or ReturnToOpener) with no defaults. afterSwap() in core turns the entry, the swap purpose and its result into Stay, Pop or OpenDeposit, and the screen only executes that. The rule that only a buy of this currency counts, not the USDF top-up from Add Money, moves with it. TokenInfoEntryTest covers the presentation and after-buy table for every origin and checks TokenInfoEntry.all against the serializer's subclass list. AppContent now reads that list to pick the transition, so an origin left out of it would have got the card-expand transition without anyone noticing.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
AppRoute.Token.Infocarried four parameters that each encoded where the screen was opened from:shortfall,fromDeeplink,asPushandreturnAfterBuy. Callers could combine them in ways that mean nothing, such as a deeplink that returns after a buy, andTokenInfoScreendecided inline, without tests, whether a finished buy should pop.Token.Info(mint, entry = TokenInfoEntry.Wallet)now names the origin, and each origin declares its presentation and what happens after a buy of its currency:Wallet(default)CardExpandStayDeeplinkCardExpandStayDiscoveryPushStayChatPushStayChatGatePushReturnToOpenerTokenInfoEntry.afterSwap(mint, purpose, result)in core turns the entry and a returning swap intoStay,PoporOpenDeposit, and the screen only executes it. The check from #1532 that only a buy of this currency counts, not the USDF top-up from Add Money, moves into that function.TokenInfoEntryTestcovers the table for every origin plus the Add Money, sell, convert, cancel and deposit cases.Analytics sources are unchanged. Discovery, Chat and ChatGate still report Wallet, as they did before.
shortfallis dropped rather than modelled as a Give origin. Nothing has passed it since 6419a95, when Give's shortfall started going straight toToken.Swap. Theshortfallplumbing insideTokenInfoViewModelandCurrencyInfoContentV2now only ever receivesnulland is left for a follow-up.AppContentstill picks the card-expand transition by matching the scene key'stoString(), now againstentry=<name>for eachPushorigin inTokenInfoEntry.all. A test checksallagainst the serializer's subclass list, so an origin missing from it fails the build instead of quietly getting the card transition.