Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
unixvb committed Aug 5, 2022
2 parents d27fb08 + 3602d00 commit e3aa4f0
Show file tree
Hide file tree
Showing 65 changed files with 557 additions and 176 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 319
versionName "1.2"
versionName "1.3"
missingDimensionStrategy 'react-native-camera', 'general'
// TODO: remove after Flipper update (0.140.0 does not work without code bellow)
configurations.all {
Expand Down
2 changes: 1 addition & 1 deletion ios/TempleWallet/Debug-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.2</string>
<string>1.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/TempleWallet/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.2</string>
<string>1.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/TempleWalletTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.2</string>
<string>1.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
6 changes: 5 additions & 1 deletion src/api.service.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import axios from 'axios';

import { TEMPLE_WALLET_API } from './utils/env.utils';
import { isDcpNode } from './utils/network.utils';

export const bakingBadApi = axios.create({ baseURL: 'https://api.baking-bad.org/v2' });

export const tzktApi = axios.create({ baseURL: 'https://api.mainnet.tzkt.io/v1' });
const tzktApi = axios.create({ baseURL: 'https://api.mainnet.tzkt.io/v1' });
const dcpTzktApi = axios.create({ baseURL: 'https://explorer.tlnt.net:8001/v1' });

export const getTzktApi = (selectedRpcUrl: string) => (isDcpNode(selectedRpcUrl) ? dcpTzktApi : tzktApi);

export const templeWalletApi = axios.create({ baseURL: TEMPLE_WALLET_API });

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React, { FC } from 'react';
import { View } from 'react-native';

import { useNetworkInfo } from '../../../hooks/use-network-info.hook';
import { useNonZeroAmounts } from '../../../hooks/use-non-zero-amounts.hook';
import { ActivityGroup, emptyActivity } from '../../../interfaces/activity.interface';
import { useSelectedRpcUrlSelector } from '../../../store/settings/settings-selectors';
import { formatSize } from '../../../styles/format-size';
import { tzktUrl } from '../../../utils/linking.util';
import { Divider } from '../../divider/divider';
Expand All @@ -23,6 +25,9 @@ export const ActivityGroupItem: FC<Props> = ({ group }) => {
const styles = useActivityGroupItemStyles();
const nonZeroAmounts = useNonZeroAmounts(group);

const selectedRpcUrl = useSelectedRpcUrlSelector();
const { isTezosNode } = useNetworkInfo();

const firstActivity = group[0] ?? emptyActivity;

return (
Expand All @@ -34,7 +39,7 @@ export const ActivityGroupItem: FC<Props> = ({ group }) => {
<View style={styles.exploreContainer}>
<PublicKeyHashText publicKeyHash={firstActivity.hash} />
<Divider size={formatSize(4)} />
<ExternalLinkButton url={tzktUrl(firstActivity.hash)} />
<ExternalLinkButton url={tzktUrl(selectedRpcUrl, firstActivity.hash)} />
</View>
</View>
<Divider size={formatSize(8)} />
Expand All @@ -47,7 +52,7 @@ export const ActivityGroupItem: FC<Props> = ({ group }) => {
<ActivityTime timestamp={firstActivity.timestamp} />
</View>

<ActivityGroupDollarAmountChange nonZeroAmounts={nonZeroAmounts} />
{isTezosNode && <ActivityGroupDollarAmountChange nonZeroAmounts={nonZeroAmounts} />}
</View>
<Divider size={formatSize(16)} />
</View>
Expand Down
5 changes: 4 additions & 1 deletion src/components/asset-amount-input/asset-amount-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { FC, memo, useCallback, useEffect, useMemo, useRef, useState } fr
import { Text, TextInput, View } from 'react-native';

import { emptyFn } from '../../config/general';
import { useNetworkInfo } from '../../hooks/use-network-info.hook';
import { useNumericInput } from '../../hooks/use-numeric-input.hook';
import { useTokenExchangeRateGetter } from '../../hooks/use-token-exchange-rate-getter.hook';
import { useFiatCurrencySelector } from '../../store/settings/settings-selectors';
Expand Down Expand Up @@ -72,6 +73,8 @@ const AssetAmountInputComponent: FC<AssetAmountInputProps> = ({
const styles = useAssetAmountInputStyles();
const colors = useColors();

const { isTezosNode } = useNetworkInfo();

const amountInputRef = useRef<TextInput>(null);

const [inputTypeIndex, setInputTypeIndex] = useState(0);
Expand Down Expand Up @@ -170,7 +173,7 @@ const AssetAmountInputComponent: FC<AssetAmountInputProps> = ({
<>
<View style={styles.headerContainer}>
<Label label={label} />
{toUsdToggle && hasExchangeRate && (
{isTezosNode && toUsdToggle && hasExchangeRate && (
<TextSegmentControl
width={formatSize(158)}
selectedIndex={inputTypeIndex}
Expand Down
5 changes: 4 additions & 1 deletion src/components/asset-value-text/asset-value-text.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { FC } from 'react';
import { StyleProp, Text, TextStyle } from 'react-native';

import { useNetworkInfo } from '../../hooks/use-network-info.hook';
import { TokenMetadataInterface } from '../../token/interfaces/token-metadata.interface';
import { getDollarValue } from '../../utils/balance.utils';
import { isDefined } from '../../utils/is-defined';
Expand All @@ -23,7 +24,9 @@ export const AssetValueText: FC<Props> = ({
showSymbol = true,
convertToDollar = false
}) => {
const hideText = convertToDollar && !isDefined(asset.exchangeRate);
const { isTezosNode } = useNetworkInfo();

const hideText = convertToDollar && (!isDefined(asset.exchangeRate) || !isTezosNode);

const visibleAmount = getDollarValue(amount, asset, convertToDollar ? asset.exchangeRate : 1);
const visibleSymbol = showSymbol ? asset.symbol : undefined;
Expand Down
1 change: 1 addition & 0 deletions src/components/icon/assets/tokens/film.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/components/icon/icon-name.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export enum IconNameEnum {
QuipuSwapDark = 'QuipuSwapDark',
Close = 'Close',
TezToken = 'TezToken',
FilmToken = 'FilmToken',
TzBtcToken = 'TzBtcToken',
NoNameToken = 'NoNameToken',
InfoFilled = 'InfoFilled',
Expand Down
2 changes: 2 additions & 0 deletions src/components/icon/icon-name.map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import TempleLogoWithTextIcon from './assets/temple-logo-with-text.svg';
import TempleLogoIcon from './assets/temple-logo.svg';
import TerminalIcon from './assets/terminal.svg';
import TezWalletIcon from './assets/tez-wallet.svg';
import FilmTokenIcon from './assets/tokens/film.svg';
import NoNameTokenIcon from './assets/tokens/no-name.svg';
import SwapTokenPlaceholderIcon from './assets/tokens/swap-token-placeholder.svg';
import TezTokenIcon from './assets/tokens/tez.svg';
Expand Down Expand Up @@ -136,6 +137,7 @@ export const iconNameMap: Record<IconNameEnum, FC<SvgProps>> = {
[IconNameEnum.SoonBadge]: SoonBadgeIcon,
[IconNameEnum.Close]: CloseIcon,
[IconNameEnum.TezToken]: TezTokenIcon,
[IconNameEnum.FilmToken]: FilmTokenIcon,
[IconNameEnum.TzBtcToken]: TzBtcTokenIcon,
[IconNameEnum.InfoFilled]: InfoFilledIcon,
/** topup icons **/
Expand Down
8 changes: 5 additions & 3 deletions src/components/styled-numberic-input/styled-numeric-input.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React, { FC } from 'react';

import { emptyFn } from '../../config/general';
import { useNetworkInfo } from '../../hooks/use-network-info.hook';
import { useNumericInput } from '../../hooks/use-numeric-input.hook';
import { TEZ_TOKEN_METADATA } from '../../token/data/tokens-metadata';
import { StyledTextInput } from '../styled-text-input/styled-text-input';
import { StyledNumericInputProps } from './styled-numeric-input.props';

export const StyledNumericInput: FC<StyledNumericInputProps> = ({
value,
decimals = TEZ_TOKEN_METADATA.decimals,
decimals,
editable,
placeholder,
isError,
Expand All @@ -17,9 +17,11 @@ export const StyledNumericInput: FC<StyledNumericInputProps> = ({
onFocus,
onChange = emptyFn
}) => {
const { metadata } = useNetworkInfo();

const { stringValue, handleBlur, handleFocus, handleChange } = useNumericInput(
value,
decimals,
decimals ?? metadata.decimals,
onChange,
onBlur,
onFocus
Expand Down
8 changes: 7 additions & 1 deletion src/components/token-equity-value/token-equity-value.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import React, { FC } from 'react';
import { Text, View } from 'react-native';

import { useHideBalance } from '../../hooks/hide-balance/hide-balance.hook';
import { useNetworkInfo } from '../../hooks/use-network-info.hook';
import { useTotalBalance } from '../../hooks/use-total-balance';
import { formatSize } from '../../styles/format-size';
import { TokenInterface } from '../../token/interfaces/token.interface';
import { AssetEquityText } from '../asset-equity-text/asset-equity-text';
import { AssetValueText } from '../asset-value-text/asset-value-text';
import { Divider } from '../divider/divider';
import { HideBalance } from '../hide-balance/hide-balance';
import { IconNameEnum } from '../icon/icon-name.enum';
import { TouchableIcon } from '../icon/touchable-icon/touchable-icon';
Expand All @@ -22,10 +24,12 @@ interface Props {
export const TokenEquityValue: FC<Props> = ({ token, showTokenValue = true }) => {
const styles = useTokenEquityValueStyles();

const { isTezosNode } = useNetworkInfo();

const { toggleHideBalance, isBalanceHidden } = useHideBalance();
const totalBalance = useTotalBalance();

return (
return isTezosNode ? (
<View style={styles.container}>
<View style={styles.header}>
<TouchableIcon
Expand Down Expand Up @@ -57,5 +61,7 @@ export const TokenEquityValue: FC<Props> = ({ token, showTokenValue = true }) =>
</HideBalance>
)}
</View>
) : (
<Divider />
);
};
8 changes: 7 additions & 1 deletion src/components/token-icon/token-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { View } from 'react-native';
import FastImage, { Source } from 'react-native-fast-image';
import { SvgCssUri } from 'react-native-svg';

import { useNetworkInfo } from '../../hooks/use-network-info.hook';
import { formatSizeScaled } from '../../styles/format-size';
import { useColors } from '../../styles/use-colors';
import { TokenMetadataInterface } from '../../token/interfaces/token-metadata.interface';
import { formatImgUri, isImgUriSvg } from '../../utils/image.utils';
import { isDefined } from '../../utils/is-defined';
Expand All @@ -20,6 +22,10 @@ export const TokenIcon: FC<Props> = ({ iconName, thumbnailUri, size = formatSize
const [isLoading, setIsLoading] = useState(true);
const [isFailed, setIsFailed] = useState(false);

const colors = useColors();

const { metadata } = useNetworkInfo();

const isShowPlaceholder = useMemo(() => isLoading || isFailed, [isLoading, isFailed]);
const style = useMemo(
() => [isShowPlaceholder && TokenIconStyles.hiddenImage, { width: size, height: size }],
Expand All @@ -36,7 +42,7 @@ export const TokenIcon: FC<Props> = ({ iconName, thumbnailUri, size = formatSize
return (
<View style={[TokenIconStyles.container, { borderRadius: size / 2 }]}>
{isDefined(iconName) ? (
<Icon name={iconName} size={size} />
<Icon name={iconName} color={metadata.iconName === iconName ? colors.black : undefined} size={size} />
) : isString(thumbnailUri) ? (
isImgUriSvg(thumbnailUri) ? (
<SvgCssUri width={size} height={size} uri={thumbnailUri} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { Text } from 'react-native';
import { TouchableOpacity } from 'react-native-gesture-handler';

import { delegationApy } from '../../config/general';
import { useNetworkInfo } from '../../hooks/use-network-info.hook';
import { ScreensEnum } from '../../navigator/enums/screens.enum';
import { useNavigation } from '../../navigator/hooks/use-navigation.hook';
import { useSelectedBakerSelector } from '../../store/baking/baking-selectors';
import { TokenInterface } from '../../token/interfaces/token.interface';
import { Divider } from '../divider/divider';
import { useTokenScreenContentContainerStyles } from './token-screen-content-container.styles';

interface Props {
Expand All @@ -20,8 +22,10 @@ export const TokenHeader: FC<Props> = ({ showHistoryComponent, token }) => {
const [, isBakerSelected] = useSelectedBakerSelector();
const isTezos = token.address === '';

const { isTezosNode } = useNetworkInfo();

if (showHistoryComponent && isTezos === true) {
return (
return isTezosNode ? (
<TouchableOpacity style={styles.delegateContainer} onPress={() => navigate(ScreensEnum.Delegation)}>
{isBakerSelected ? (
<Text style={styles.delegateText}>Rewards & Redelegate</Text>
Expand All @@ -31,6 +35,8 @@ export const TokenHeader: FC<Props> = ({ showHistoryComponent, token }) => {
</Text>
)}
</TouchableOpacity>
) : (
<Divider />
);
}

Expand Down
18 changes: 7 additions & 11 deletions src/form/form-numeric-input/form-numeric-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { FC } from 'react';

import { StyledNumericInput } from '../../components/styled-numberic-input/styled-numeric-input';
import { StyledNumericInputProps } from '../../components/styled-numberic-input/styled-numeric-input.props';
import { TEZ_TOKEN_METADATA } from '../../token/data/tokens-metadata';
import { useNetworkInfo } from '../../hooks/use-network-info.hook';
import { hasError } from '../../utils/has-error';
import { isDefined } from '../../utils/is-defined';
import { ErrorMessage } from '../error-message/error-message';
Expand All @@ -15,22 +15,18 @@ interface Props extends Pick<StyledNumericInputProps, 'decimals' | 'editable' |
maxValue?: BigNumber;
}

export const FormNumericInput: FC<Props> = ({
name,
maxValue,
decimals = TEZ_TOKEN_METADATA.decimals,
editable,
placeholder,
isShowCleanButton
}) => {
export const FormNumericInput: FC<Props> = ({ name, maxValue, decimals, editable, placeholder, isShowCleanButton }) => {
const [field, meta, helpers] = useField<BigNumber | undefined>(name);
const isError = hasError(meta);

const { metadata } = useNetworkInfo();
const decimalsWithFallback = decimals ?? metadata.decimals;

return (
<>
<StyledNumericInput
value={field.value}
decimals={decimals}
decimals={decimalsWithFallback}
editable={editable}
placeholder={placeholder}
isError={isError}
Expand All @@ -42,7 +38,7 @@ export const FormNumericInput: FC<Props> = ({
{isDefined(maxValue) && (
<FormNumericInputButtons
maxValue={maxValue}
onButtonPress={newValue => helpers.setValue(newValue.decimalPlaces(decimals))}
onButtonPress={newValue => helpers.setValue(newValue.decimalPlaces(decimalsWithFallback))}
/>
)}
</>
Expand Down
6 changes: 5 additions & 1 deletion src/hooks/migration/useStorageMigration.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { useDispatch } from 'react-redux';
import {
migrateAccountsState,
migrateIsShownDomainName,
addDcpRpc,
migrateQuipuApy,
migrateTokensMetadata,
migrateTokenSuggestion
migrateTokenSuggestion,
addDcpTokensMetadata
} from '../../store/migration/migration-actions';

export const useStorageMigration = () => {
Expand All @@ -18,5 +20,7 @@ export const useStorageMigration = () => {
dispatch(migrateIsShownDomainName());
dispatch(migrateQuipuApy());
dispatch(migrateAccountsState());
dispatch(addDcpRpc());
dispatch(addDcpTokensMetadata());
}, []);
};
Loading

0 comments on commit e3aa4f0

Please sign in to comment.