migrate the age assurance data reads to the session clients

getOtherRequiredData's getPreferences read moves onto the sdk action, which
also unblocks fetchActorDeclarationRecord - its only caller - so the record
read moves to the pds client too.

The prefetch and refetch entry points now take the transport they need
rather than an agent: the appview client for getState and device signals,
the account client for preferences and the declaration record. The session
bundle still carries only an agent, so the three session call sites derive
both clients from it; the full bundle rework is a later slice. The standalone
config read stays on its own unauthenticated agent.
This commit is contained in:
Samuel Newman
2026-08-04 01:58:31 +03:00
parent 17c17b4543
commit 755ce365f6
6 changed files with 102 additions and 79 deletions
@@ -6,7 +6,7 @@ import {Trans} from '@lingui/react/macro'
import {retry} from '#/lib/async/retry'
import {wait} from '#/lib/async/wait'
import {useAgent} from '#/state/session'
import {useAppviewClient} from '#/state/session'
import {atoms as a, useTheme, web} from '#/alf'
import {AgeAssuranceBadge} from '#/components/ageAssurance/AgeAssuranceBadge'
import {Button, ButtonText} from '#/components/Button'
@@ -84,7 +84,7 @@ export function Inner({}: {optimisticState?: AgeAssuranceRedirectDialogState}) {
const t = useTheme()
const ax = useAnalytics()
const {_} = useLingui()
const agent = useAgent()
const appviewClient = useAppviewClient()
const polling = useRef(false)
const unmounted = useRef(false)
const control = useAgeAssuranceRedirectDialogControl()
@@ -104,10 +104,10 @@ export function Inner({}: {optimisticState?: AgeAssuranceRedirectDialogState}) {
5,
() => true,
async () => {
if (!agent.session) return
if (!appviewClient.did) return
if (unmounted.current) return
const data = await refetchAgeAssuranceServerState({agent})
const data = await refetchAgeAssuranceServerState({appviewClient})
if (data?.state.status !== 'assured') {
throw new Error(
@@ -122,7 +122,7 @@ export function Inner({}: {optimisticState?: AgeAssuranceRedirectDialogState}) {
)
.then(async data => {
if (!data) return
if (!agent.session) return
if (!appviewClient.did) return
if (unmounted.current) return
setSuccess(true)
@@ -138,7 +138,7 @@ export function Inner({}: {optimisticState?: AgeAssuranceRedirectDialogState}) {
return () => {
unmounted.current = true
}
}, [ax, agent, control])
}, [ax, appviewClient, control])
if (success) {
return (