Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion app/config/feature-flags-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,29 @@ import { useAppConfig } from "@app/hooks"
import { useLevel } from "@app/graphql/level-context"

const DeviceAccountEnabledKey = "deviceAccountEnabledRestAuth"
const BridgeTopupEnabledKey = "bridgeTopupEnabled"

type FeatureFlags = {
deviceAccountEnabled: boolean
bridgeTopupEnabled: boolean
}

type RemoteConfig = {
[DeviceAccountEnabledKey]: boolean
[BridgeTopupEnabledKey]: boolean
}

const defaultRemoteConfig: RemoteConfig = {
deviceAccountEnabledRestAuth: true,
// Client kill switch for the Bridge top-up / KYC flow. Default OFF: keep the
// bridge queries dark until the backend bridge is confirmed enabled for the
// cohort, then flip in Firebase Remote Config. Gates TopupCashout / AccountType.
bridgeTopupEnabled: false,
}

const defaultFeatureFlags = {
deviceAccountEnabled: false,
bridgeTopupEnabled: false,
}

getRemoteConfig().setDefaults(defaultRemoteConfig)
Expand Down Expand Up @@ -48,7 +56,10 @@ export const FeatureFlagContextProvider: React.FC<React.PropsWithChildren> = ({
const deviceAccountEnabledRestAuth = getRemoteConfig()
.getValue(DeviceAccountEnabledKey)
.asBoolean()
setRemoteConfig({ deviceAccountEnabledRestAuth })
const bridgeTopupEnabled = getRemoteConfig()
.getValue(BridgeTopupEnabledKey)
.asBoolean()
setRemoteConfig({ deviceAccountEnabledRestAuth, bridgeTopupEnabled })
} catch (err) {
console.error("Error fetching remote config: ", err)
} finally {
Expand All @@ -60,6 +71,8 @@ export const FeatureFlagContextProvider: React.FC<React.PropsWithChildren> = ({
const featureFlags = {
deviceAccountEnabled:
remoteConfig.deviceAccountEnabledRestAuth || galoyInstance.id === "Local",
bridgeTopupEnabled:
remoteConfig.bridgeTopupEnabled || galoyInstance.id === "Local",
}

if (!remoteConfigReady && currentLevel === "NonAuth") {
Expand Down
6 changes: 5 additions & 1 deletion app/screens/account-upgrade-flow/AccountType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { ProgressSteps } from "@app/components/account-upgrade-flow"
import { useLevel } from "@app/graphql/level-context"
import { useActivityIndicator } from "@app/hooks"
import { useI18nContext } from "@app/i18n/i18n-react"
import { useFeatureFlags } from "@app/config/feature-flags-context"

// store
import { useAppDispatch } from "@app/store/redux"
Expand All @@ -33,18 +34,21 @@ const AccountType: React.FC<Props> = ({ navigation }) => {
const { LL } = useI18nContext()
const { currentLevel } = useLevel()
const { toggleActivityIndicator } = useActivityIndicator()
const { bridgeTopupEnabled } = useFeatureFlags()

const [bridgeKycModalVisible, setBridgeKycModalVisible] = useState(false)

const [initiateBridgeKyc] = useBridgeInitiateKycMutation()
const { data: kycStatusData, refetch: refetchKycStatus } = useBridgeKycStatusQuery({
fetchPolicy: "cache-and-network",
skip: !bridgeTopupEnabled,
})

useFocusEffect(
useCallback(() => {
if (!bridgeTopupEnabled) return
refetchKycStatus()
}, [refetchKycStatus]),
}, [bridgeTopupEnabled, refetchKycStatus]),
)

const bridgeKycStatus = kycStatusData?.bridgeKycStatus
Expand Down
7 changes: 6 additions & 1 deletion app/screens/topup-cashout-flow/TopupCashout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
} from "@app/graphql/generated"
import { useActivityIndicator } from "@app/hooks"
import { useLevel } from "@app/graphql/level-context"
import { useFeatureFlags } from "@app/config/feature-flags-context"

type Props = StackScreenProps<RootStackParamList, "TopupCashout">

Expand All @@ -37,6 +38,7 @@ const TopupCashout: React.FC<Props> = ({ navigation }) => {
const { currentLevel } = useLevel()
const { colors } = useTheme().theme
const { toggleActivityIndicator } = useActivityIndicator()
const { bridgeTopupEnabled } = useFeatureFlags()

const [topupModalVisible, setTopupModalVisible] = useState(false)
const [settleModalVisible, setSettleModalVisible] = useState(false)
Expand All @@ -48,17 +50,20 @@ const TopupCashout: React.FC<Props> = ({ navigation }) => {

const { data: kycStatusData, refetch: refetchKycStatus } = useBridgeKycStatusQuery({
fetchPolicy: "cache-and-network",
skip: !bridgeTopupEnabled,
})
const { data: externalAccountsData, refetch: refetchExternalAccounts } =
useBridgeExternalAccountsQuery({
fetchPolicy: "cache-and-network",
skip: !bridgeTopupEnabled,
})

useFocusEffect(
useCallback(() => {
if (!bridgeTopupEnabled) return
refetchKycStatus()
refetchExternalAccounts()
}, [refetchKycStatus, refetchExternalAccounts]),
}, [bridgeTopupEnabled, refetchKycStatus, refetchExternalAccounts]),
)

const onRefresh = useCallback(async () => {
Expand Down
Loading