diff --git a/src/common/common.js b/src/common/common.js index 30b3bc40..dcf6f401 100644 --- a/src/common/common.js +++ b/src/common/common.js @@ -630,7 +630,7 @@ const common = { const rskEndpoint = chainId === TESTNET.NETWORK_VERSION ? TESTNET.RSK_END_POINT : MAINNET.RSK_END_POINT; const rsk3 = new Rsk3(rskEndpoint); rsk3.getCode(address).then((code) => { - if (code !== '0x00' || code !== '0x0' || code != '0x') { + if (code !== '0x00' || code !== '0x0' || code !== '0x') { resolve(true); } else { resolve(false); @@ -710,7 +710,7 @@ const common = { const { inputs, names, types, method, } = inputData; - const params = { }; + const params = {}; _.forEach(inputs, (inputValue, index) => { const key = this.uppercaseFirstLetter(names[index]); const type = types[index]; @@ -854,6 +854,19 @@ const common = { } return false; }, + + /** + * Returns the address ready to show to the user. Applies checksum if needed by the nerworkId. + * Only considers Rootstock network + * @param {string} address + * @param {string} network + */ + toChecksumAddressIfNeeded(address, network) { + if (network.toLowerCase() === 'rootstock') { + return Rsk3.utils.toChecksumAddress(address, MAINNET.NETWORK_VERSION); + } + return address; + }, }; export default common; diff --git a/src/common/parse.js b/src/common/parse.js index 01998f6d..4a439383 100644 --- a/src/common/parse.js +++ b/src/common/parse.js @@ -251,9 +251,9 @@ class ParseHelper { */ static async fetchTransactions(symbol, type, address, skipCount, fetchCount) { const queryFrom = new Parse.Query(ParseTransaction); - queryFrom.equalTo('from', address); + queryFrom.equalTo('from', address.toLowerCase()); const queryTo = new Parse.Query(ParseTransaction); - queryTo.equalTo('to', address); + queryTo.equalTo('to', address.toLowerCase()); const query = Parse.Query.or(queryFrom, queryTo) .equalTo('type', type) .equalTo('symbol', symbol) @@ -261,7 +261,7 @@ class ParseHelper { const results = await query.skip(skipCount).limit(fetchCount).find(); const transactions = _.map(results, (item) => { const transaction = parseDataUtil.getTransaction(item); - const isSender = address === transaction.from; + const isSender = address.toLowerCase() === transaction.from.toLowerCase(); return parseDataUtil.getTransactionViewData(transaction, isSender); }); return transactions; @@ -272,7 +272,7 @@ class ParseHelper { * @param {*} tokens */ static async subscribeTransactions(tokens) { - const addresses = _.uniq(_.map(tokens, 'address')); + const addresses = (_.uniq(_.map(tokens, 'address'))).map((address) => address.toLowerCase()); const queryFrom = new Parse.Query(ParseTransaction); queryFrom.containedIn('from', addresses); const queryTo = new Parse.Query(ParseTransaction); diff --git a/src/common/wallet/walletManager.js b/src/common/wallet/walletManager.js index f06967d9..17149545 100644 --- a/src/common/wallet/walletManager.js +++ b/src/common/wallet/walletManager.js @@ -165,7 +165,7 @@ class WalletManager { _.each(tokenInstances, (token) => { const newToken = token; - const matchedToken = _.find(updatedItems, (item) => item.address === token.address && item.symbol === token.symbol && item.type === token.type); + const matchedToken = _.find(updatedItems, (item) => item.address.toLowerCase() === token.address.toLowerCase() && item.symbol === token.symbol && item.type === token.type); if (matchedToken) { // update balance diff --git a/src/pages/wallet/transaction.js b/src/pages/wallet/transaction.js index ab58e858..7794a0f8 100644 --- a/src/pages/wallet/transaction.js +++ b/src/pages/wallet/transaction.js @@ -130,6 +130,7 @@ class Transaction extends Component { isRefreshing: false, from, to, + chain, }; } @@ -199,9 +200,12 @@ class Transaction extends Component { render() { const { navigation } = this.props; const { - transactionState, transactionId, amount, dateTime, memo, confirmations, title, stateIcon, isRefreshing, from, to, + transactionState, transactionId, amount, dateTime, memo, confirmations, title, stateIcon, isRefreshing, from, to, chain, } = this.state; + const fromChecksum = common.toChecksumAddressIfNeeded(from, chain); + const toChecksum = common.toChecksumAddressIfNeeded(to, chain); + const txStateText = strings(`txState.${transactionState}`); const refreshControl = ( @@ -237,14 +241,14 @@ class Transaction extends Component { <View style={styles.sectionContainer}> <Loc style={[styles.sectionTitle]} text="page.wallet.transaction.from" /> <TouchableOpacity style={[styles.copyView]} onPress={this.onFromPress}> - <Text style={[styles.copyText]}>{from}</Text> + <Text style={[styles.copyText]}>{fromChecksum}</Text> <Image style={styles.copyIcon} source={references.images.copyIcon} /> </TouchableOpacity> </View> <View style={styles.sectionContainer}> <Loc style={[styles.sectionTitle]} text="page.wallet.transaction.to" /> <TouchableOpacity style={[styles.copyView]} onPress={this.onToPress}> - <Text style={[styles.copyText]}>{to}</Text> + <Text style={[styles.copyText]}>{toChecksum}</Text> <Image style={styles.copyIcon} source={references.images.copyIcon} /> </TouchableOpacity> </View> @@ -279,6 +283,7 @@ Transaction.propTypes = { navigate: PropTypes.func.isRequired, dispatch: PropTypes.func.isRequired, goBack: PropTypes.func.isRequired, + // eslint-disable-next-line react/forbid-prop-types state: PropTypes.object.isRequired, }).isRequired, addNotification: PropTypes.func.isRequired,