Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1341] feat: Allow QR code scanning of "transfer_hotspot_v2" transactions #1342

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
13 changes: 10 additions & 3 deletions src/features/wallet/send/SendScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ const SendScreen = ({ route }: Props) => {
const rootNavigation = useNavigation<RootNavigationProp>()
const tabNavigation = useNavigation<MainTabNavigationProp>()
const scanResult = route?.params?.scanResult
const hotspotAddress = route?.params?.hotspotAddress
const isSeller = route?.params?.isSeller
const isPinVerified = route?.params?.pinVerified

let { hotspotAddress, isSeller, type } = route?.params ?? {}
if (scanResult?.hotspotAddress) {
hotspotAddress = scanResult.hotspotAddress as string
}
if (scanResult?.isSeller) isSeller = scanResult.isSeller as boolean
if (scanResult?.type) type = scanResult.type

const isPinRequiredForPayment = useSelector(
(state: RootState) => state.app.isPinRequiredForPayment,
)
Expand All @@ -34,8 +40,9 @@ const SendScreen = ({ route }: Props) => {
const permanentPaymentAddress = useSelector(
(state: RootState) => state.app.permanentPaymentAddress,
)

// If "Deploy Mode" is enabled, only allow payment transactions
const type = isDeployModeEnabled ? 'payment' : route?.params?.type
if (isDeployModeEnabled) type = 'payment'
// If "Deploy Mode" is enabled without a permanent payment address, disable all payments
const isDeployModePaymentsDisabled =
isDeployModeEnabled && !permanentPaymentAddress
Expand Down
15 changes: 13 additions & 2 deletions src/features/wallet/send/SendView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import {
AppLink,
AppLinkPayment,
AppLinkCategoryType,
AppLinkTransfer,
} from '../../../providers/appLinkTypes'
import { MainTabNavigationProp } from '../../../navigation/main/tabTypes'
import { isDataOnly } from '../../../utils/hotspotUtils'
Expand Down Expand Up @@ -160,7 +161,9 @@ const SendView = ({
useAsync(async () => {
if (type === 'transfer' && hotspotAddress && blockHeight) {
const gateway = await getHotspotDetails(hotspotAddress)
if (isDataOnly(gateway)) {
const canSkipActivityCheck =
isDataOnly(gateway) || scanResult?.skipActivityCheck
if (canSkipActivityCheck) {
setLastReportedActivity('')
setHasValidActivity(true)
setStalePocBlockCount(0)
Expand Down Expand Up @@ -237,6 +240,11 @@ const SendView = ({
): scanRes is AppLinkPayment => {
return scanRes.type === 'payment' && scanRes.payees !== undefined
}
const isAppLinkTransfer = (
scanRes: AppLink | AppLinkPayment | AppLinkTransfer,
): scanRes is AppLinkTransfer => {
return scanRes.type === 'transfer'
}
if (isAppLinkPayment(scanResult)) {
scannedSendDetails = scanResult.payees.map(
({ address, amount: scanAmount, memo = '' }, i) => {
Expand All @@ -259,7 +267,10 @@ const SendView = ({
scannedSendDetails = [
{
id: 'transfer0',
address: scanResult.address,
address:
isAppLinkTransfer(scanResult) && scanResult.newOwnerAddress
? scanResult.newOwnerAddress
: scanResult.address,
addressAlias: '',
addressLoading: false,
amount,
Expand Down
5 changes: 4 additions & 1 deletion src/navigation/navigator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { LockScreenRequestType } from './main/tabTypes'
import {
AppLink,
AppLinkPayment,
AppLinkTransfer,
LinkWalletRequest,
SignHotspotRequest,
} from '../providers/appLinkTypes'
Expand All @@ -17,7 +18,9 @@ const lock = (params: {
navigationRef.current?.navigate('LockScreen', params)
}

const send = (params: { scanResult: AppLink | AppLinkPayment }) => {
const send = (params: {
scanResult: AppLink | AppLinkPayment | AppLinkTransfer
}) => {
navigationRef.current?.navigate('Send', params)
}

Expand Down
Loading