Skip to content

Commit

Permalink
Merge branch 'develop' into feature/eip1559-base-edit-gas-fee-screen
Browse files Browse the repository at this point in the history
* develop:
  Remove Picker deprecation warning (#2709)
  Don't render swap router address in recents (#2823)
  bumped version (#2843)
  Lionbridge latest translations for secret recovery phrase and subtitle files (#2743)
  • Loading branch information
rickycodes committed Jun 29, 2021
2 parents 925ee16 + eebce6b commit 5ffa183
Show file tree
Hide file tree
Showing 49 changed files with 6,116 additions and 3,323 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ android {
applicationId "io.metamask"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 750
versionName "2.5.0"
versionCode 751
versionName "2.6.0"
multiDexEnabled true
testBuildType System.getProperty('testBuildType', 'debug')
missingDimensionStrategy "minReactNative", "minReactNative46"
Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/AddCustomCollectible/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { isSmartContractAddress } from '../../../util/transactions';
import Device from '../../../util/Device';
import { connect } from 'react-redux';
import AnalyticsV2 from '../../../util/analyticsV2';
import { toLowerCaseCompare } from '../../../util/general';
import { toLowerCaseEquals } from '../../../util/general';

const styles = StyleSheet.create({
wrapper: {
Expand Down Expand Up @@ -169,7 +169,7 @@ class AddCustomCollectible extends PureComponent {
const { selectedAddress } = this.props;
try {
const owner = await AssetsContractController.getOwnerOf(address, tokenId);
return toLowerCaseCompare(owner, selectedAddress);
return toLowerCaseEquals(owner, selectedAddress);
} catch (e) {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/AssetSearch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { strings } from '../../../../locales/i18n';
import contractMap from '@metamask/contract-metadata';
import Fuse from 'fuse.js';
import Icon from 'react-native-vector-icons/FontAwesome';
import { toLowerCaseCompare } from '../../../util/general';
import { toLowerCaseEquals } from '../../../util/general';

const styles = StyleSheet.create({
searchSection: {
Expand Down Expand Up @@ -68,7 +68,7 @@ export default class AssetSearch extends PureComponent {
handleSearch = searchQuery => {
this.setState({ searchQuery });
const fuseSearchResult = fuse.search(searchQuery);
const addressSearchResult = contractList.filter(token => toLowerCaseCompare(token.address, searchQuery));
const addressSearchResult = contractList.filter(token => toLowerCaseEquals(token.address, searchQuery));
const results = [...addressSearchResult, ...fuseSearchResult];
this.props.onSearch({ searchQuery, results });
};
Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/CollectibleContractOverview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { toggleCollectibleContractModal } from '../../../actions/modals';
import { connect } from 'react-redux';
import collectiblesTransferInformation from '../../../util/collectibles-transfer';
import { newAssetTransaction } from '../../../actions/transaction';
import { toLowerCaseCompare } from '../../../util/general';
import { toLowerCaseEquals } from '../../../util/general';

const styles = StyleSheet.create({
wrapper: {
Expand Down Expand Up @@ -86,7 +86,7 @@ class CollectibleContractOverview extends PureComponent {
onSend = () => {
const { collectibleContract, collectibles } = this.props;
const collectible = collectibles.find(collectible =>
toLowerCaseCompare(collectible.address, collectibleContract.address)
toLowerCaseEquals(collectible.address, collectibleContract.address)
);
this.props.newAssetTransaction(collectible);
this.props.navigation.navigate('SendFlowView');
Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/CollectibleContracts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import CollectibleModal from '../CollectibleModal';
import { favoritesCollectiblesObjectSelector } from '../../../reducers/collectibles';
import Text from '../../Base/Text';
import AppConstants from '../../../core/AppConstants';
import { toLowerCaseCompare } from '../../../util/general';
import { toLowerCaseEquals } from '../../../util/general';

const styles = StyleSheet.create({
wrapper: {
Expand Down Expand Up @@ -97,7 +97,7 @@ const CollectibleContracts = ({ collectibleContracts, collectibles, navigation,
const renderCollectibleContract = useCallback(
(item, index) => {
const contractCollectibles = collectibles?.filter(collectible =>
toLowerCaseCompare(collectible.address, item.address)
toLowerCaseEquals(collectible.address, item.address)
);
return (
<CollectibleContractElement
Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/EthInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { getTicker, getNormalizedTxState } from '../../../util/transactions';
import FontAwesome from 'react-native-vector-icons/FontAwesome';
import Device from '../../../util/Device';
import NetworkMainAssetLogo from '../NetworkMainAssetLogo';
import { toLowerCaseCompare } from '../../../util/general';
import { toLowerCaseEquals } from '../../../util/general';

const styles = StyleSheet.create({
root: {
Expand Down Expand Up @@ -284,7 +284,7 @@ class EthInput extends PureComponent {
break;
case 'CONTRACT_COLLECTIBLE_TRANSACTION': {
const collectiblesToShow = collectibles.filter(collectible =>
toLowerCaseCompare(collectible.address, transaction.selectedAsset.address)
toLowerCaseEquals(collectible.address, transaction.selectedAsset.address)
);
this.setState({
assets: collectiblesToShow
Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/PaymentRequest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import Device from '../../../util/Device';
import currencySymbols from '../../../util/currency-symbols.json';
import { NetworksChainId } from '@metamask/controllers';
import { getTicker } from '../../../util/transactions';
import { toLowerCaseCompare } from '../../../util/general';
import { toLowerCaseEquals } from '../../../util/general';

const KEYBOARD_OFFSET = 120;
const styles = StyleSheet.create({
Expand Down Expand Up @@ -343,7 +343,7 @@ class PaymentRequest extends PureComponent {
}

const fuseSearchResult = fuse.search(searchInputValue);
const addressSearchResult = contractList.filter(token => toLowerCaseCompare(token.address, searchInputValue));
const addressSearchResult = contractList.filter(token => toLowerCaseEquals(token.address, searchInputValue));
const results = [...addressSearchResult, ...fuseSearchResult];
this.setState({ searchInputValue, results });
};
Expand Down
3 changes: 2 additions & 1 deletion app/components/UI/SelectComponent/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { ScrollView, StyleSheet, Text, View, TouchableOpacity, Picker } from 'react-native';
import { ScrollView, StyleSheet, Text, View, TouchableOpacity } from 'react-native';
import { Picker } from '@react-native-community/picker';
import { fontStyles, colors, baseStyles } from '../../../styles/common';
import Icon from 'react-native-vector-icons/MaterialIcons';
import Modal from 'react-native-modal';
Expand Down
6 changes: 3 additions & 3 deletions app/components/UI/Swaps/QuotesView.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import useBalance from './utils/useBalance';
import useGasPrice from './utils/useGasPrice';
import { trackErrorAsAnalytics } from '../../../util/analyticsV2';
import { decodeApproveData, getTicker } from '../../../util/transactions';
import { toLowerCaseCompare } from '../../../util/general';
import { toLowerCaseEquals } from '../../../util/general';
import { swapsTokensSelector } from '../../../reducers/swaps';

const POLLING_INTERVAL = AppConstants.SWAPS.POLLING_INTERVAL;
Expand Down Expand Up @@ -294,8 +294,8 @@ function SwapsQuotesView({
);

/* Get tokens from the tokens list */
const sourceToken = swapsTokens?.find(token => toLowerCaseCompare(token.address, sourceTokenAddress));
const destinationToken = swapsTokens?.find(token => toLowerCaseCompare(token.address, destinationTokenAddress));
const sourceToken = swapsTokens?.find(token => toLowerCaseEquals(token.address, sourceTokenAddress));
const destinationToken = swapsTokens?.find(token => toLowerCaseEquals(token.address, destinationTokenAddress));

const hasConversionRate =
Boolean(destinationToken) &&
Expand Down
10 changes: 5 additions & 5 deletions app/components/UI/Swaps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import SlippageModal from './components/SlippageModal';
import useBalance from './utils/useBalance';
import useBlockExplorer from './utils/useBlockExplorer';
import InfoModal from './components/InfoModal';
import { toLowerCaseCompare } from '../../../util/general';
import { toLowerCaseEquals } from '../../../util/general';

const styles = StyleSheet.create({
screen: {
Expand Down Expand Up @@ -161,11 +161,11 @@ function SwapsAmountView({
const [isInitialLoadingTokens, setInitialLoadingTokens] = useState(false);
const [, setLoadingTokens] = useState(false);
const [isSourceSet, setIsSourceSet] = useState(() =>
Boolean(swapsTokens?.find(token => toLowerCaseCompare(token.address, initialSource)))
Boolean(swapsTokens?.find(token => toLowerCaseEquals(token.address, initialSource)))
);

const [sourceToken, setSourceToken] = useState(() =>
swapsTokens?.find(token => toLowerCaseCompare(token.address, initialSource))
swapsTokens?.find(token => toLowerCaseEquals(token.address, initialSource))
);
const [destinationToken, setDestinationToken] = useState(null);
const [hasDismissedTokenAlert, setHasDismissedTokenAlert] = useState(true);
Expand All @@ -192,7 +192,7 @@ function SwapsAmountView({
InteractionManager.runAfterInteractions(() => {
const parameters = {
source: initialSource === SWAPS_NATIVE_ADDRESS ? 'MainView' : 'TokenView',
activeCurrency: swapsTokens?.find(token => toLowerCaseCompare(token.address, initialSource))
activeCurrency: swapsTokens?.find(token => toLowerCaseEquals(token.address, initialSource))
?.symbol,
chain_id: chainId
};
Expand Down Expand Up @@ -248,7 +248,7 @@ function SwapsAmountView({
useEffect(() => {
if (!isSourceSet && initialSource && swapsTokens && !sourceToken) {
setIsSourceSet(true);
setSourceToken(swapsTokens.find(token => toLowerCaseCompare(token.address, initialSource)));
setSourceToken(swapsTokens.find(token => toLowerCaseEquals(token.address, initialSource)));
}
}, [initialSource, isSourceSet, sourceToken, swapsTokens]);

Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/TransactionEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import contractMap from '@metamask/contract-metadata';
import { safeToChecksumAddress } from '../../../util/address';
import TransactionTypes from '../../../core/TransactionTypes';
import { MAINNET } from '../../../constants/network';
import { toLowerCaseCompare } from '../../../util/general';
import { toLowerCaseEquals } from '../../../util/general';

const EDIT = 'edit';
const REVIEW = 'review';
Expand Down Expand Up @@ -381,7 +381,7 @@ class TransactionEditor extends PureComponent {
const { selectedAddress } = this.props;
try {
const owner = await AssetsContractController.getOwnerOf(address, tokenId);
const isOwner = toLowerCaseCompare(owner, selectedAddress);
const isOwner = toLowerCaseEquals(owner, selectedAddress);
if (!isOwner) {
return strings('transaction.invalid_collectible_ownership');
}
Expand Down
6 changes: 3 additions & 3 deletions app/components/UI/TransactionElement/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import contractMap from '@metamask/contract-metadata';
import { toChecksumAddress } from 'ethereumjs-util';
import { swapsUtils } from '@metamask/swaps-controller';
import { isSwapsNativeAsset } from '../Swaps/utils';
import { toLowerCaseCompare } from '../../../util/general';
import { toLowerCaseEquals } from '../../../util/general';

const { getSwapsContractAddress } = swapsUtils;

Expand Down Expand Up @@ -139,7 +139,7 @@ function getCollectibleTransfer(args) {
let actionKey;
const [, tokenId] = decodeTransferData('transfer', data);
const ticker = getTicker(args.ticker);
const collectible = collectibleContracts.find(collectible => toLowerCaseCompare(collectible.address, to));
const collectible = collectibleContracts.find(collectible => toLowerCaseEquals(collectible.address, to));
if (collectible) {
actionKey = `${strings('transactions.sent')} ${collectible.name}`;
} else {
Expand Down Expand Up @@ -335,7 +335,7 @@ function decodeTransferFromTx(args) {
selectedAddress
} = args;
const [addressFrom, addressTo, tokenId] = decodeTransferData('transferFrom', data);
const collectible = collectibleContracts.find(collectible => toLowerCaseCompare(collectible.address, to));
const collectible = collectibleContracts.find(collectible => toLowerCaseEquals(collectible.address, to));
let actionKey = args.actionKey;
if (collectible) {
actionKey = `${strings('transactions.sent')} ${collectible.name}`;
Expand Down
4 changes: 2 additions & 2 deletions app/components/Views/Asset/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getNetworkNavbarOptions } from '../../UI/Navbar';
import Engine from '../../../core/Engine';
import { safeToChecksumAddress } from '../../../util/address';
import { addAccountTimeFlagFilter } from '../../../util/transactions';
import { toLowerCaseCompare } from '../../../util/general';
import { toLowerCaseEquals } from '../../../util/general';

const styles = StyleSheet.create({
wrapper: {
Expand Down Expand Up @@ -146,7 +146,7 @@ class Asset extends PureComponent {
) {
if (isTransfer)
return this.props.tokens.find(({ address }) =>
toLowerCaseCompare(address, transferInformation.contractAddress)
toLowerCaseEquals(address, transferInformation.contractAddress)
);
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions app/components/Views/Collectible/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Engine from '../../../core/Engine';
import Modal from 'react-native-modal';
import CollectibleContractInformation from '../../UI/CollectibleContractInformation';
import { toggleCollectibleContractModal } from '../../../actions/modals';
import { toLowerCaseCompare } from '../../../util/general';
import { toLowerCaseEquals } from '../../../util/general';

const styles = StyleSheet.create({
wrapper: {
Expand Down Expand Up @@ -76,7 +76,7 @@ class Collectible extends PureComponent {
const address = params.address;
const { collectibles } = this.props;
const filteredCollectibles = collectibles.filter(collectible =>
toLowerCaseCompare(collectible.address, address)
toLowerCaseEquals(collectible.address, address)
);
filteredCollectibles.map(collectible => {
if (!collectible.name || collectible.name === '') {
Expand Down
8 changes: 4 additions & 4 deletions app/components/Views/Login/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import ErrorBoundary from '../ErrorBoundary';
import WarningExistingUserModal from '../../UI/WarningExistingUserModal';
import Icon from 'react-native-vector-icons/FontAwesome';
import { trackErrorAsAnalytics } from '../../../util/analyticsV2';
import { tlc, toLowerCaseCompare } from '../../../util/general';
import { tlc, toLowerCaseEquals } from '../../../util/general';

const isTextDelete = text => tlc(text) === 'delete';
const deviceHeight = Device.getDeviceHeight();
Expand Down Expand Up @@ -314,8 +314,8 @@ class Login extends PureComponent {
// Should we force people to enable passcode / biometrics?
const error = e.toString();
if (
toLowerCaseCompare(error, WRONG_PASSWORD_ERROR) ||
toLowerCaseCompare(error, WRONG_PASSWORD_ERROR_ANDROID)
toLowerCaseEquals(error, WRONG_PASSWORD_ERROR) ||
toLowerCaseEquals(error, WRONG_PASSWORD_ERROR_ANDROID)
) {
this.setState({ loading: false, error: strings('login.invalid_password') });

Expand All @@ -328,7 +328,7 @@ class Login extends PureComponent {
'In order to proceed, you need to turn Passcode on or any biometrics authentication method supported in your device (FaceID, TouchID or Fingerprint)'
);
this.setState({ loading: false });
} else if (toLowerCaseCompare(error, VAULT_ERROR)) {
} else if (toLowerCaseEquals(error, VAULT_ERROR)) {
this.setState({
loading: false,
error: CLEAN_VAULT_ERROR
Expand Down
20 changes: 16 additions & 4 deletions app/components/Views/SendFlow/AddressList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
TRANSFER_FUNCTION_SIGNATURE,
TRANSFER_FROM_FUNCTION_SIGNATURE
} from '../../../../util/transactions';
import { swapsUtils } from '@metamask/swaps-controller';
import { toLowerCaseEquals } from '../../../../util/general';

const styles = StyleSheet.create({
root: {
Expand Down Expand Up @@ -97,7 +99,11 @@ class AddressList extends PureComponent {
* Whether it only has to render address book
*/
onlyRenderAddressBook: PropTypes.bool,
reloadAddressList: PropTypes.bool
reloadAddressList: PropTypes.bool,
/**
* Chain id
*/
chainId: PropTypes.string
};

state = {
Expand Down Expand Up @@ -153,7 +159,7 @@ class AddressList extends PureComponent {
};

getRecentAddresses = inputSearch => {
const { transactions, network, identities, onAccountPress, onAccountLongPress } = this.props;
const { transactions, network, identities, onAccountPress, onAccountLongPress, chainId } = this.props;
const recents = [];
const parsedRecents = [];
if (!inputSearch) {
Expand All @@ -171,7 +177,12 @@ class AddressList extends PureComponent {
}
const checksummedTo = safeToChecksumAddress(to);
if (recents.length > 2) return;
if (!recents.includes(checksummedTo) && !Object.keys(identities).includes(checksummedTo)) {
const swapsContractAddress = swapsUtils.getSwapsContractAddress(chainId);
if (
!recents.includes(checksummedTo) &&
!Object.keys(identities).includes(checksummedTo) &&
!toLowerCaseEquals(checksummedTo, swapsContractAddress)
) {
recents.push(checksummedTo);
if (this.networkAddressBook[checksummedTo]) {
parsedRecents.push(
Expand Down Expand Up @@ -297,7 +308,8 @@ const mapStateToProps = state => ({
addressBook: state.engine.backgroundState.AddressBookController.addressBook,
identities: state.engine.backgroundState.PreferencesController.identities,
network: state.engine.backgroundState.NetworkController.network,
transactions: state.engine.backgroundState.TransactionController.transactions
transactions: state.engine.backgroundState.TransactionController.transactions,
chainId: state.engine.backgroundState.NetworkController.provider.chainId
});

export default connect(mapStateToProps)(AddressList);
5 changes: 4 additions & 1 deletion app/components/Views/SendFlow/AddressList/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ describe('AddressList', () => {
engine: {
backgroundState: {
NetworkController: {
network: '1'
network: '1',
provider: {
chainId: '1'
}
},
AddressBookController: {
addressBook: {
Expand Down
4 changes: 2 additions & 2 deletions app/components/Views/SendFlow/Amount/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import { ANALYTICS_EVENT_OPTS } from '../../../../util/analytics';
import dismissKeyboard from 'react-native/Libraries/Utilities/dismissKeyboard';
import NetworkMainAssetLogo from '../../../UI/NetworkMainAssetLogo';
import { isMainNet } from '../../../../util/networks';
import { toLowerCaseCompare } from '../../../../util/general';
import { toLowerCaseEquals } from '../../../../util/general';

const { hexToBN, BNToHex } = util;

Expand Down Expand Up @@ -425,7 +425,7 @@ class Amount extends PureComponent {
} = this.props;
try {
const owner = await AssetsContractController.getOwnerOf(address, tokenId);
const isOwner = toLowerCaseCompare(owner, selectedAddress);
const isOwner = toLowerCaseEquals(owner, selectedAddress);
if (!isOwner) {
return strings('transaction.invalid_collectible_ownership');
}
Expand Down
Loading

0 comments on commit 5ffa183

Please sign in to comment.