-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug fix 189 balance #192
Bug fix 189 balance #192
Conversation
chrisfenos
commented
Sep 25, 2018
- Balance is loaded async
- Ether - ERC20 abstracted to scripts directory for modularity
- Balance Reducer created to track tokens and balances
…into bugFix-189-balance
…this is triggered in recover wallet -> will allow the main page to have an accurate balance before the user needs to refresh.
…mount of tokens for that symbol based on the private key
… string of all the symbols we hold in our wallet to the api and return then entire price matrix
…eds to be refactored.
src/reducers/wallet/Balance.js
Outdated
let quant = state.walletTokens[0][key[1]]; | ||
let usdPrice = state.tokenConversions["ETH"].USD; | ||
let total = quant*usdPrice; | ||
return { ...state, initialBalance: total }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic should happen outside of the reducer. Move it to the appropriate action
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GregTheGreek done
|
||
const ethers = require('ethers'); | ||
|
||
const processAllTokenBalances = async (privateKey, dataSet) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function has a lot of console.log()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GregTheGreek fixed
src/scripts/tokenBalances.js
Outdated
key = Object.keys(dataSet[i]); | ||
const contract = new ethers.Contract(key[1], ERC20ABI, provider); //key[1] is contract address | ||
const tokenBalance = await contract.balanceOf(wallet.address); | ||
key = Object.keys(dataSet[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is also on line 39
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please check for all the console.logs
src/scripts/tokenBalances.js
Outdated
const contract = new ethers.Contract(contractAdd, ERC20ABI, provider); | ||
const tokenBalance = await contract.balanceOf(wallet.address); | ||
const parsedTokenBalance = String(tokenBalance); | ||
console.log('Token Balance', parsedTokenBalance); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/screens/main/portfolio/index.js
Outdated
() => { | ||
this.tokenBalanceLoop(); | ||
}); | ||
console.log('List refreshed'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GregTheGreek done
tokenObj.symbol = dataSet[i].symbol; | ||
if (dataSet[i].contractAddress === '') { | ||
await this.getEthereumBalance(wallet.address) | ||
.then((response) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GregTheGreek done