Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
refactor: uses lowercased addresses to interact with the server
Browse files Browse the repository at this point in the history
- and process them as lowercased as well
  • Loading branch information
itofarina committed May 11, 2021
1 parent 6b2a768 commit 75e778a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/common/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,17 +251,17 @@ 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)
.descending('createdAt');
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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/common/wallet/walletManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 75e778a

Please sign in to comment.