Skip to content

Commit

Permalink
fix(mobile): Inscriptions fixes (#667)
Browse files Browse the repository at this point in the history
* fix(mobile): Add missing translation

* fix(mobile): Disable comment encryption by default

* fix(mobile): Parse comment param from inscription transfer deeplink

* fix(mobile): Scan inscription-transfer deeplink QR at send screen correctly

* fix(mobile): Dismiss Keyboard before going to Confirm step
  • Loading branch information
voloshinskii authored Jan 12, 2024
1 parent 3432d24 commit a797ab1
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 10 deletions.
2 changes: 2 additions & 0 deletions packages/mobile/src/core/NFTSend/NFTSend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { Toast } from '$store';
import axios from 'axios';
import { useWallet } from '$hooks/useWallet';
import { useUnlockVault } from '$core/ModalContainer/NFTOperations/useUnlockVault';
import { Keyboard } from 'react-native';

interface Props {
route: RouteProp<AppStackParamList, AppStackRouteNames.NFTSend>;
Expand Down Expand Up @@ -119,6 +120,7 @@ export const NFTSend: FC<Props> = (props) => {
messages.current = nftTransferMessages;
setConsequences(response);

Keyboard.dismiss();
await delay(100);

stepViewRef.current?.go(NFTSendSteps.CONFIRM);
Expand Down
10 changes: 3 additions & 7 deletions packages/mobile/src/core/Send/steps/AddressStep/AddressStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useSuggestedAddresses } from '../../hooks/useSuggestedAddresses';
import { useReanimatedKeyboardHeight } from '$hooks/useKeyboardHeight';
import { Ton } from '$libs/Ton';
import { Button, FormItem } from '$uikit';
import { asyncDebounce, formatInputAmount, parseTonLink } from '$utils';
import { asyncDebounce, formatInputAmount, isTransferOp, parseTonLink } from '$utils';
import React, {
FC,
memo,
Expand Down Expand Up @@ -51,7 +51,7 @@ const AddressStepComponent: FC<AddressStepProps> = (props) => {
setRecipient,
changeBlockchain,
active,
enableEncryption = true,
enableEncryption = false, // TODO: replace with true here when encryption will be ready
setRecipientAccountInfo,
setAmount,
setComment,
Expand Down Expand Up @@ -139,11 +139,7 @@ const AddressStepComponent: FC<AddressStepProps> = (props) => {
setDnsLoading(false);
}

if (
link.match &&
link.operation === 'transfer' &&
Address.isValid(link.address)
) {
if (link.match && isTransferOp(link.operation) && Address.isValid(link.address)) {
if (
setAmount &&
link.query.amount &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { t } from '@tonkeeper/shared/i18n';
import { openScanQR } from '$navigation';
import { WordHintsPopupRef } from '$shared/components/ImportWalletForm/WordHintsPopup';
import { Icon, Input, Loader, Text } from '$uikit';
import { isAndroid, ns, parseTonLink } from '$utils';
import { isAndroid, isTransferOp, ns, parseTonLink } from '$utils';
import React, {
FC,
memo,
Expand Down Expand Up @@ -134,8 +134,7 @@ const AddressInputComponent: FC<Props> = (props) => {
const handleScanQR = useCallback(() => {
openScanQR(async (code: string) => {
const link = parseTonLink(code);

if (link.match && link.operation === 'transfer' && !Address.isValid(link.address)) {
if (link.match && isTransferOp(link.operation) && !Address.isValid(link.address)) {
Toast.fail(t('transfer_deeplink_address_error'));
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ export function useDeeplinkingResolvers() {
currency: inscription.ticker,
currencyAdditionalParams: { type: inscription.type },
address,
comment,
withGoBack: resolveParams.withGoBack,
tokenType: TokenType.Inscription,
redirectToActivity: resolveParams.redirectToActivity,
Expand Down
9 changes: 9 additions & 0 deletions packages/mobile/src/utils/parseTonLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ const prefixes = [
'tonkeeper://',
];

export enum TransferOperationType {
InscriptionTransfer = 'inscription-transfer',
Transfer = 'transfer',
}

export function isTransferOp(operation: string): operation is TransferOperationType {
return (Object.values(TransferOperationType) as string[]).includes(operation);
}

type ParsedTonLink = {
match: boolean;
address: string;
Expand Down
1 change: 1 addition & 0 deletions packages/shared/i18n/locales/tonkeeper/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
"confirm_sending_submit" : "Confirm and Send",
"confirm_sending_title" : "Confirm sending",
"confirmSendModal" : {
"refund": "Refund",
"network_fee" : "Network fee",
"title" : "Confirm action",
"to_your_address" : "To your address",
Expand Down
1 change: 1 addition & 0 deletions packages/shared/i18n/locales/tonkeeper/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@
"confirm_sending_submit" : "Подтвердить и отправить",
"confirm_sending_title" : "Перевод",
"confirmSendModal" : {
"refund": "Возврат",
"network_fee" : "Комиссия сети",
"title" : "Подтвердить действие",
"to_your_address" : "На ваш адрес",
Expand Down

0 comments on commit a797ab1

Please sign in to comment.