Remove MM warning and fix white pending tx page

This commit is contained in:
Victor Baranov 2018-11-09 16:16:16 +03:00
parent 1500ce53c5
commit 7add17a684
3 changed files with 31 additions and 18 deletions

View File

@ -10,10 +10,10 @@ restoreContextAfterImports()
log.setDefaultLevel(process.env.METAMASK_DEBUG ? 'debug' : 'warn')
console.warn('ATTENTION: In an effort to improve user privacy, MetaMask will ' +
'stop exposing user accounts to dapps by default beginning November 2nd, 2018. ' +
'Dapps should call provider.enable() in order to view and use accounts. Please see ' +
'https://bit.ly/2QQHXvF for complete information and up-to-date example code.')
// console.warn('ATTENTION: In an effort to improve user privacy, MetaMask will ' +
// 'stop exposing user accounts to dapps by default beginning November 2nd, 2018. ' +
// 'Dapps should call provider.enable() in order to view and use accounts. Please see ' +
// 'https://bit.ly/2QQHXvF for complete information and up-to-date example code.')
//
// setup plugin communication

View File

@ -600,10 +600,15 @@ PendingTx.prototype.componentWillUnmount = function () {
}
PendingTx.prototype.updateTokenInfo = async function (txParams) {
const tokenParams = await this.tokenInfoGetter(txParams.to)
let tokenParams
try {
tokenParams = await this.tokenInfoGetter(txParams.to)
} catch (e) {
log.error(e)
}
this.setState({
tokenSymbol: tokenParams.symbol,
tokenDecimals: tokenParams.decimals,
tokenSymbol: (tokenParams && tokenParams.symbol),
tokenDecimals: (tokenParams && tokenParams.decimals),
tokenDataRetrieved: true,
})
}

View File

@ -26,24 +26,32 @@ const DEFAULT_DECIMALS = '0'
async function getSymbolFromContract (tokenAddress) {
const token = util.getContractAtAddress(tokenAddress)
try {
const result = await token.symbol()
return result[0]
} catch (error) {
log.warn(`symbol() call for token at address ${tokenAddress} resulted in error:`, error)
if (token.bytecode !== '0x') {
try {
const result = await token.symbol()
return result[0]
} catch (error) {
log.warn(`symbol() call for token at address ${tokenAddress} resulted in error:`, error)
return ''
}
}
return ''
}
async function getDecimalsFromContract (tokenAddress) {
const token = util.getContractAtAddress(tokenAddress)
try {
const result = await token.decimals()
const decimalsBN = result[0]
return decimalsBN && decimalsBN.toString()
} catch (error) {
log.warn(`decimals() call for token at address ${tokenAddress} resulted in error:`, error)
if (token.bytecode !== '0x') {
try {
const result = await token.decimals()
const decimalsBN = result[0]
return decimalsBN && decimalsBN.toString()
} catch (error) {
log.warn(`decimals() call for token at address ${tokenAddress} resulted in error:`, error)
return '0'
}
}
return '0'
}
function getContractMetadata (tokenAddress) {