From 52e1cde2e7695ee62d02fc9533f6c36a6b8bd374 Mon Sep 17 00:00:00 2001 From: nachosan Date: Tue, 22 Nov 2022 11:59:41 -0300 Subject: [PATCH 1/6] added missing type to activity detail --- android/app/build.gradle | 2 +- src/constants/business.ts | 8 ++++++ .../Profile/modals/ActivityDetail/index.tsx | 4 +-- src/screens/tabs/components/utils.js | 28 ++++++++++++++----- src/translations/en/index.js | 2 ++ 5 files changed, 34 insertions(+), 10 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index b5098fdc..428edca7 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -152,7 +152,7 @@ android { applicationId "co.psychedelic.plug" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 26 + versionCode 27 versionName "0.4.0" resValue "string", "build_config_package", "co.psychedelic.plug" buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() diff --git a/src/constants/business.ts b/src/constants/business.ts index 8629f1d3..31608f28 100644 --- a/src/constants/business.ts +++ b/src/constants/business.ts @@ -15,6 +15,14 @@ export const ACTIVITY_TYPES = { PLUG: 'PLUG', BURN: 'BURN', MINT: 'MINT', + TRANSFERFROM: 'TRANSFERFROM', + DIRECT_BUY: 'DIRECTBUY', + MAKE_LISTING: 'MAKELISTING', + CANCEL_LISTING: 'CANCELLISTING', + MAKE_OFFER: 'MAKEOFFER', + ACCEPT_OFFER: 'ACCEPTOFFER', + CANCEL_OFFER: 'CANCELOFFER', + DENY_OFFER: 'DENYOFFER', }; export const ACTIVITY_STATUS = { diff --git a/src/screens/tabs/Profile/modals/ActivityDetail/index.tsx b/src/screens/tabs/Profile/modals/ActivityDetail/index.tsx index 7e3663a0..45cbcba3 100644 --- a/src/screens/tabs/Profile/modals/ActivityDetail/index.tsx +++ b/src/screens/tabs/Profile/modals/ActivityDetail/index.tsx @@ -9,9 +9,9 @@ import useCustomToast from '@/hooks/useCustomToast'; import { Contact, Transaction } from '@/interfaces/redux'; import { useAppSelector } from '@/redux/hooks'; import ActivityItem from '@/screens/tabs/components/ActivityItem'; +import { getTransactionDetailType } from '@/screens/tabs/components/utils'; import { isOwnAddress, validateICNSName } from '@/utils/ids'; import shortAddress from '@/utils/shortAddress'; -import { capitalize } from '@/utils/strings'; import styles from './styles'; @@ -55,7 +55,7 @@ function ActivityDetail({ modalRef, activity, onClosed }: Props) { ? [ { title: t('activity.details.trxType'), - value: capitalize(activity.type?.toLocaleLowerCase()), + value: getTransactionDetailType(activity.type), }, { title: t('activity.details.from'), diff --git a/src/screens/tabs/components/utils.js b/src/screens/tabs/components/utils.js index fae1cc6c..2fd47eaa 100644 --- a/src/screens/tabs/components/utils.js +++ b/src/screens/tabs/components/utils.js @@ -31,6 +31,7 @@ export const getTypeIcon = type => { case ACTIVITY_TYPES.BURN: return ACTIVITY_IMAGES.BURN; case ACTIVITY_TYPES.SEND: + case ACTIVITY_TYPES.TRANSFERFROM: return ACTIVITY_IMAGES.SEND; case ACTIVITY_TYPES.MINT: return ACTIVITY_IMAGES.MINT; @@ -39,22 +40,35 @@ export const getTypeIcon = type => { } }; +export const getTransactionDetailType = type => { + switch (type) { + case ACTIVITY_TYPES.RECEIVE: + case ACTIVITY_TYPES.SEND: + case ACTIVITY_TYPES.TRANSFERFROM: + return t('transactionTypes.transfer'); + default: + return `${capitalize(type?.toLowerCase())}`; + } +}; + export const getTitle = (type, symbol) => { switch (type) { - case 'DIRECTBUY': + case ACTIVITY_TYPES.DIRECT_BUY: return t('transactionTypes.buyNTF'); - case 'MAKELISTING': + case ACTIVITY_TYPES.MAKE_LISTING: return t('transactionTypes.listNFT'); - case 'CANCELLISTING': + case ACTIVITY_TYPES.CANCEL_LISTING: return t('transactionTypes.cancelListingNFT'); - case 'MAKEOFFER': + case ACTIVITY_TYPES.MAKE_OFFER: return t('transactionTypes.makeOfferNFT'); - case 'ACCEPTOFFER': + case ACTIVITY_TYPES.ACCEPT_OFFER: return t('transactionTypes.acceptOfferNFT'); - case 'CANCELOFFER': + case ACTIVITY_TYPES.CANCEL_OFFER: return t('transactionTypes.cancelOfferNFT'); - case 'DENYOFFER': + case ACTIVITY_TYPES.DENY_OFFER: return t('transactionTypes.denyOfferNFT'); + case ACTIVITY_TYPES.TRANSFERFROM: + return `${t('transactionTypes.send')} ${symbol ?? ''}`; default: if (type.includes('Liquidity')) { return type; diff --git a/src/translations/en/index.js b/src/translations/en/index.js index c5281ae3..66e0add0 100644 --- a/src/translations/en/index.js +++ b/src/translations/en/index.js @@ -99,6 +99,8 @@ const translations = { acceptOfferNFT: 'Accept Offer', cancelOfferNFT: 'Cancel Offer', denyOfferNFT: 'Deny Offer', + transfer: 'Transfer', + send: 'Send', }, reviewSend: { to: 'To', From ee9b945203a4b20b34b53defefe6f1ef063645ec Mon Sep 17 00:00:00 2001 From: nachosan Date: Tue, 22 Nov 2022 12:14:47 -0300 Subject: [PATCH 2/6] Replaced touch component in toast --- src/components/common/Toast/index.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/common/Toast/index.tsx b/src/components/common/Toast/index.tsx index 1fc50083..b058d07e 100644 --- a/src/components/common/Toast/index.tsx +++ b/src/components/common/Toast/index.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { View } from 'react-native'; +import { Pressable, View } from 'react-native'; import LinearGradient from 'react-native-linear-gradient'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { useToast } from 'react-native-toast-notifications'; @@ -12,7 +12,6 @@ import InfoIcon from '@/icons/svg/InfoIcon.svg'; import SuccessIcon from '@/icons/svg/SuccessIcon.svg'; import Text from '../Text'; -import Touchable from '../Touchable'; import styles from './styles'; export enum ToastTypes { @@ -61,9 +60,9 @@ function Toast({ title, message, type, id }: ToastProps) { {title} - + - + {message && ( From 805f7680e4eed08ce5e0d359e6a86c817f8059c1 Mon Sep 17 00:00:00 2001 From: nachosan Date: Tue, 22 Nov 2022 12:36:22 -0300 Subject: [PATCH 3/6] Added temporal fix to warning with modals --- patches/react-native+0.70.3.patch | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 patches/react-native+0.70.3.patch diff --git a/patches/react-native+0.70.3.patch b/patches/react-native+0.70.3.patch new file mode 100644 index 00000000..72c39604 --- /dev/null +++ b/patches/react-native+0.70.3.patch @@ -0,0 +1,15 @@ +diff --git a/node_modules/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js b/node_modules/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js +index 6a343d8..474b2ec 100644 +--- a/node_modules/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js ++++ b/node_modules/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js +@@ -111,6 +111,10 @@ class KeyboardAvoidingView extends React.Component { + this._initialFrameHeight = this._frame.height; + } + ++ if (this.props.onLayout) { ++ event.persist(); ++ } ++ + if (wasFrameNull) { + await this._updateBottomIfNecessary(); + } From 767274023cdf78b34f7303ad132d484f8f8f761c Mon Sep 17 00:00:00 2001 From: nachosan Date: Tue, 22 Nov 2022 12:40:56 -0300 Subject: [PATCH 4/6] Changed already imported message --- src/screens/tabs/Profile/utils.ts | 2 +- src/translations/en/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/screens/tabs/Profile/utils.ts b/src/screens/tabs/Profile/utils.ts index 66e881b0..e3c90ac0 100644 --- a/src/screens/tabs/Profile/utils.ts +++ b/src/screens/tabs/Profile/utils.ts @@ -5,7 +5,7 @@ export const getPemImportError = (error: string) => { case 'invalid-key': return t('createImportAccount.invalidKey'); case 'added-account': - return t('createImportAccount.addedAccount'); + return t('createImportAccount.alreadyImported'); default: return t('createImportAccount.importError'); } diff --git a/src/translations/en/index.js b/src/translations/en/index.js index 66e0add0..55363c75 100644 --- a/src/translations/en/index.js +++ b/src/translations/en/index.js @@ -346,7 +346,7 @@ const translations = { importPem: 'PEM File', create: 'Create', invalidKey: 'Invalid key. Please, try again.', - addedAccount: 'Account already added.', + alreadyImported: 'This account is already imported', importError: 'There was an error while importing the account. Please try again.', }, From 92fb8de73fd89215c6590d4739818c3e791980c6 Mon Sep 17 00:00:00 2001 From: nachosan Date: Tue, 22 Nov 2022 12:53:51 -0300 Subject: [PATCH 5/6] Comparing account types to show selected account --- src/screens/tabs/Profile/modals/Accounts/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/screens/tabs/Profile/modals/Accounts/index.tsx b/src/screens/tabs/Profile/modals/Accounts/index.tsx index 5bdfdd8a..8397476c 100644 --- a/src/screens/tabs/Profile/modals/Accounts/index.tsx +++ b/src/screens/tabs/Profile/modals/Accounts/index.tsx @@ -158,7 +158,10 @@ function Accounts({ modalRef }: Props) { }; const renderAccountItem = (account: Wallet, index: number) => { - const isSelectedAccount = currentWallet?.principal === account.principal; + const isSelectedAccount = + currentWallet?.principal === account.principal && + currentWallet?.type === account.type; + const handleOpenAccountOptions = () => openAccountOptions(account); const selectedAccountProps = { From 2253b8fba36795955942eced68eadff8ef6667f1 Mon Sep 17 00:00:00 2001 From: nachosan Date: Wed, 23 Nov 2022 14:51:46 -0300 Subject: [PATCH 6/6] Changed logic when adding custom collection --- src/redux/slices/user.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/redux/slices/user.ts b/src/redux/slices/user.ts index 39c0b63e..15015b91 100644 --- a/src/redux/slices/user.ts +++ b/src/redux/slices/user.ts @@ -363,7 +363,7 @@ export const addCustomToken = createAsyncThunk< logo, }); - const assets = [ + const assets: Asset[] = [ ...user.assets, formatAsset(registeredToken, icp.icpPrice), ]; @@ -465,17 +465,19 @@ export const addCustomCollection = createAsyncThunk< const state = getState(); const instance = KeyRing.getInstance(); try { - const registeredCollection = recursiveParseBigint( - await instance?.registerNFT(nft) + const isAlreadyAdded = !!state.user.collections.find( + collection => collection.canisterId === nft.canisterId ); - const totalCollections = [ - ...state.user.collections, - registeredCollection, - ] as Collection[]; + if (isAlreadyAdded) { + onFailure('The NFT is already registered'); + return state.user.collections; + } + + const nfts = await instance.getNFTs({ refresh: true }); onSuccess(); - return totalCollections; + return (nfts || []).map(item => recursiveParseBigint(item)); } catch (e: any) { onFailure(e.message); console.log('Error while adding custom collection:', e);