Remove logs

This commit is contained in:
Germán Martínez 2019-06-03 13:23:30 +02:00
parent ca4d298a02
commit 8c1586ba30
14 changed files with 190 additions and 56 deletions

View File

@ -27,36 +27,30 @@ class HeaderComponent extends React.PureComponent<Props, State> {
} }
async componentDidMount() { async componentDidMount() {
const { fetchProvider, recurrentFetchProvider } = this.props this.onConnect()
let currentProvider: ProviderProps = await fetchProvider(this.props.openSnackbar)
this.providerListener = setInterval(async () => {
console.log('loop')
currentProvider = await recurrentFetchProvider(currentProvider, this.props.openSnackbar)
}, 2000)
} }
componentDidCatch(error: Error, info: Info) { componentDidCatch(error: Error, info: Info) {
const { openSnackbar } = this.props
this.setState({ hasError: true }) this.setState({ hasError: true })
this.props.openSnackbar(WALLET_ERROR_MSG, 'error') openSnackbar(WALLET_ERROR_MSG, 'error')
logComponentStack(error, info) logComponentStack(error, info)
} }
onDisconnect = () => { onDisconnect = () => {
const { removeProvider } = this.props
clearInterval(this.providerListener) clearInterval(this.providerListener)
this.props.removeProvider(this.props.openSnackbar) removeProvider(this.props.openSnackbar)
} }
onConnect = async () => { onConnect = async () => {
const { fetchProvider, recurrentFetchProvider } = this.props const { fetchProvider, recurrentFetchProvider } = this.props
clearInterval(this.providerListener) clearInterval(this.providerListener)
console.log('onConnect')
let currentProvider: ProviderProps = await fetchProvider(this.props.openSnackbar) let currentProvider: ProviderProps = await fetchProvider(this.props.openSnackbar)
this.providerListener = setInterval(async () => { this.providerListener = setInterval(async () => {
console.log('loopConnect')
currentProvider = await recurrentFetchProvider(currentProvider, this.props.openSnackbar) currentProvider = await recurrentFetchProvider(currentProvider, this.props.openSnackbar)
}, 2000) }, 2000)
} }

View File

@ -11,9 +11,7 @@ let proxyFactoryMaster
let safeMaster let safeMaster
const createGnosisSafeContract = async (web3: any) => { const createGnosisSafeContract = async (web3: any) => {
console.log('createGnosisSafeContract')
const gnosisSafe = contract(GnosisSafeSol) const gnosisSafe = contract(GnosisSafeSol)
console.log('gnosisSafe', gnosisSafe, web3)
gnosisSafe.setProvider(web3.currentProvider) gnosisSafe.setProvider(web3.currentProvider)
return gnosisSafe return gnosisSafe
@ -77,10 +75,7 @@ export const deploySafeContract = async (safeAccounts: string[], numConfirmation
export const getGnosisSafeInstanceAt = async (safeAddress: string) => { export const getGnosisSafeInstanceAt = async (safeAddress: string) => {
const web3 = getWeb3() const web3 = getWeb3()
console.log('web3', web3)
const GnosisSafe = await getGnosisSafeContract(web3) const GnosisSafe = await getGnosisSafeContract(web3)
console.log('GnosisSafe', GnosisSafe)
console.log('safeAddress', safeAddress)
const gnosisSafe = await GnosisSafe.at(safeAddress) const gnosisSafe = await GnosisSafe.at(safeAddress)
return gnosisSafe return gnosisSafe

View File

@ -12,20 +12,14 @@ import { ensureOnce } from '~/utils/singleton'
import saveTokens from './saveTokens' import saveTokens from './saveTokens'
const createStandardTokenContract = async () => { const createStandardTokenContract = async () => {
console.log('createStandardTokenContract')
const web3 = getWeb3() const web3 = getWeb3()
console.log('web3', web3)
const erc20Token = await contract(StandardToken) const erc20Token = await contract(StandardToken)
console.log('erc20Token', erc20Token)
erc20Token.setProvider(web3.currentProvider) erc20Token.setProvider(web3.currentProvider)
console.log('erc20Token', erc20Token)
return erc20Token return erc20Token
} }
const createHumanFriendlyTokenContract = async () => { const createHumanFriendlyTokenContract = async () => {
console.log('createHumanFriendlyTokenContract')
const web3 = getWeb3() const web3 = getWeb3()
console.log('web3', web3)
const humanErc20Token = await contract(HumanFriendlyToken) const humanErc20Token = await contract(HumanFriendlyToken)
humanErc20Token.setProvider(web3.currentProvider) humanErc20Token.setProvider(web3.currentProvider)
@ -38,7 +32,6 @@ export const getStandardTokenContract = ensureOnce(createStandardTokenContract)
export const fetchTokens = () => async (dispatch: ReduxDispatch<GlobalState>) => { export const fetchTokens = () => async (dispatch: ReduxDispatch<GlobalState>) => {
try { try {
console.log('fetchTokens------')
const { const {
data: { results: tokenList }, data: { results: tokenList },
} = await fetchTokenList() } = await fetchTokenList()

View File

@ -7,10 +7,8 @@ import { getActiveTokens } from '~/logic/tokens/utils/tokensStorage'
import saveTokens from './saveTokens' import saveTokens from './saveTokens'
const loadActiveTokens = () => async (dispatch: ReduxDispatch<GlobalState>) => { const loadActiveTokens = () => async (dispatch: ReduxDispatch<GlobalState>) => {
console.log('loadActiveTokens')
try { try {
const tokens: Map<string, TokenProps> = await getActiveTokens() const tokens: Map<string, TokenProps> = await getActiveTokens()
console.log('tokens', tokens)
const tokenRecordsList: List<Token> = List( const tokenRecordsList: List<Token> = List(
Object.values(tokens).map((token: TokenProps): Token => makeToken(token)), Object.values(tokens).map((token: TokenProps): Token => makeToken(token)),
) )

View File

@ -87,7 +87,6 @@ export const getProviderInfo: Function = async (): Promise<ProviderProps> => {
} }
web3 = new Web3(web3Provider) web3 = new Web3(web3Provider)
console.log('WEB3 UPDATED!!!!', web3, getWeb3())
const name = getProviderName(web3) const name = getProviderName(web3)
const account = await getAccountFrom(web3) const account = await getAccountFrom(web3)

View File

@ -44,13 +44,12 @@ const handleProviderNotification = (openSnackbar: Function, provider: ProviderPr
openSnackbar(msg, variant) openSnackbar(msg, variant)
} }
export const recurrentFetchProvider = (currentProvider: ProviderProps, openSnackbar: Function) => async (dispatch: ReduxDispatch<*>) => { export const recurrentFetchProvider = (currentProvider: ProviderProps, openSnackbar: Function) => async (
dispatch: ReduxDispatch<*>,
) => {
const newProvider: ProviderProps = await getProviderInfo() const newProvider: ProviderProps = await getProviderInfo()
if (JSON.stringify(currentProvider) !== JSON.stringify(newProvider)) { if (JSON.stringify(currentProvider) !== JSON.stringify(newProvider)) {
console.log('provider updated')
console.log(JSON.stringify(currentProvider))
console.log(JSON.stringify(newProvider))
handleProviderNotification(openSnackbar, newProvider) handleProviderNotification(openSnackbar, newProvider)
processProviderResponse(dispatch, newProvider) processProviderResponse(dispatch, newProvider)
} }
@ -60,7 +59,6 @@ export const recurrentFetchProvider = (currentProvider: ProviderProps, openSnack
export default (openSnackbar: Function) => async (dispatch: ReduxDispatch<*>) => { export default (openSnackbar: Function) => async (dispatch: ReduxDispatch<*>) => {
const provider: ProviderProps = await getProviderInfo() const provider: ProviderProps = await getProviderInfo()
console.log('initial provider', provider)
handleProviderNotification(openSnackbar, provider) handleProviderNotification(openSnackbar, provider)
processProviderResponse(dispatch, provider) processProviderResponse(dispatch, provider)

View File

@ -0,0 +1,177 @@
// @flow
import * as React from 'react'
import Block from '~/components/layout/Block'
import { withStyles } from '@material-ui/core/styles'
import Field from '~/components/forms/Field'
import { required } from '~/components/forms/validator'
import TextField from '~/components/forms/TextField'
import OpenInNew from '@material-ui/icons/OpenInNew'
import Identicon from '~/components/Identicon'
import OpenPaper from '~/components/Stepper/OpenPaper'
import Col from '~/components/layout/Col'
import Row from '~/components/layout/Row'
import Link from '~/components/layout/Link'
import Paragraph from '~/components/layout/Paragraph'
import Hairline from '~/components/layout/Hairline'
import {
xs, sm, md, lg, border, secondary,
} from '~/theme/variables'
import { getOwnerNameBy } from '~/routes/open/components/fields'
import { getEtherScanLink, getWeb3 } from '~/logic/wallets/getWeb3'
import { FIELD_LOAD_ADDRESS } from '~/routes/load/components/fields'
import { getGnosisSafeContract } from '~/logic/contracts/safeContracts'
const openIconStyle = {
height: '16px',
color: secondary,
}
const styles = () => ({
details: {
padding: lg,
borderRight: `solid 1px ${border}`,
height: '100%',
},
owners: {
display: 'flex',
justifyContent: 'flex-start',
},
ownerNames: {
maxWidth: '400px',
},
ownerAddresses: {
alignItems: 'center',
marginLeft: `${sm}`,
},
address: {
paddingLeft: '6px',
},
open: {
paddingLeft: sm,
width: 'auto',
'&:hover': {
cursor: 'pointer',
},
},
title: {
padding: `${md} ${lg}`,
},
owner: {
padding: `0 ${lg}`,
marginBottom: '12px',
},
header: {
padding: `${sm} ${lg}`,
},
name: {
marginRight: `${sm}`,
},
})
type LayoutProps = {
network: string,
}
type Props = LayoutProps & {
values: Object,
classes: Object,
}
type State = {
owners: Array,
}
class OwnerListComponent extends React.PureComponent<Props, State> {
state = {
owners: [],
}
mounted = false
componentDidMount = async () => {
this.mounted = true
const { values } = this.props
const safeAddress = values[FIELD_LOAD_ADDRESS]
const web3 = getWeb3()
const GnosisSafe = getGnosisSafeContract(web3)
const gnosisSafe = await GnosisSafe.at(safeAddress)
const owners = await gnosisSafe.getOwners()
if (!owners) {
return
}
if (this.mounted) {
this.setState(() => ({ owners: owners.sort() }))
}
}
componentWillUnmount() {
this.mounted = false
}
render() {
const { network, classes } = this.props
const { owners } = this.state
return (
<React.Fragment>
<Block className={classes.title}>
<Paragraph noMargin size="md" color="primary">
{`This Safe has ${owners.length} owners. Optional: Provide a name for each owner.`}
</Paragraph>
</Block>
<Hairline />
<Row className={classes.header}>
<Col xs={4}>NAME</Col>
<Col xs={8}>ADDRESS</Col>
</Row>
<Hairline />
<Block margin="md" padding="md">
{ owners.map((x, index) => (
<Row key={`owner${(index)}`} className={classes.owner}>
<Col xs={4}>
<Field
className={classes.name}
name={getOwnerNameBy(index)}
component={TextField}
type="text"
validate={required}
defaultValue={`Owner #${index + 1}`}
placeholder="Owner Name*"
text="Owner Name"
/>
</Col>
<Col xs={7}>
<Row className={classes.ownerAddresses}>
<Identicon address={owners[index]} diameter={32} />
<Paragraph size="md" color="disabled" noMargin className={classes.address}>
{owners[index]}
</Paragraph>
<Link className={classes.open} to={getEtherScanLink(owners[index], network)} target="_blank">
<OpenInNew style={openIconStyle} />
</Link>
</Row>
</Col>
</Row>
)) }
</Block>
</React.Fragment>
)
}
}
const OwnerListPage = withStyles(styles)(OwnerListComponent)
const OwnerList = ({ network }: LayoutProps) => (controls: React$Node, { values }: Object) => (
<React.Fragment>
<OpenPaper controls={controls} padding={false}>
<OwnerListPage network={network} values={values} />
</OpenPaper>
</React.Fragment>
)
export default OwnerList

View File

@ -34,7 +34,6 @@ export const createSafe = async (values: Object, userAccount: string, addSafe: A
await checkReceiptStatus(safe.tx) await checkReceiptStatus(safe.tx)
const safeAddress = safe.logs[0].args.proxy const safeAddress = safe.logs[0].args.proxy
console.log('createSafe')
const safeContract = await getGnosisSafeInstanceAt(safeAddress) const safeContract = await getGnosisSafeInstanceAt(safeAddress)
addSafe(name, safeContract.address, numConfirmations, owners, accounts) addSafe(name, safeContract.address, numConfirmations, owners, accounts)

View File

@ -23,7 +23,6 @@ class SafeView extends React.Component<Props> {
fetchTokenBalances(safeUrl, activeTokens) fetchTokenBalances(safeUrl, activeTokens)
this.intervalId = setInterval(() => { this.intervalId = setInterval(() => {
console.log('checkUpdates')
this.checkForUpdates() this.checkForUpdates()
}, TIMEOUT) }, TIMEOUT)
} }

View File

@ -25,13 +25,9 @@ export const addSafe = createAction<string, Function, ActionReturn>(
}), }),
) )
const saveSafe = ( const saveSafe = (name: string, address: string, threshold: number, ownersName: string[], ownersAddress: string[]) => (
name: string, dispatch: ReduxDispatch<GlobalState>,
address: string, ) => {
threshold: number,
ownersName: string[],
ownersAddress: string[],
) => (dispatch: ReduxDispatch<GlobalState>) => {
const owners: List<Owner> = buildOwnersFrom(ownersName, ownersAddress) const owners: List<Owner> = buildOwnersFrom(ownersName, ownersAddress)
const safe: Safe = SafeRecord({ const safe: Safe = SafeRecord({

View File

@ -19,9 +19,7 @@ const buildOwnersFrom = (
}) })
export const buildSafe = async (safeAddress: string, safeName: string) => { export const buildSafe = async (safeAddress: string, safeName: string) => {
console.log('build1')
const gnosisSafe = await getGnosisSafeInstanceAt(safeAddress) const gnosisSafe = await getGnosisSafeInstanceAt(safeAddress)
console.log('build2', gnosisSafe)
const ethBalance = await getBalanceInEtherOf(safeAddress) const ethBalance = await getBalanceInEtherOf(safeAddress)
const threshold = Number(await gnosisSafe.getThreshold()) const threshold = Number(await gnosisSafe.getThreshold())

View File

@ -10,20 +10,15 @@ import updateSafe from './updateSafe'
import { ETH_ADDRESS } from '~/logic/tokens/utils/tokenHelpers' import { ETH_ADDRESS } from '~/logic/tokens/utils/tokenHelpers'
export const calculateBalanceOf = async (tokenAddress: string, safeAddress: string, decimals: number = 18) => { export const calculateBalanceOf = async (tokenAddress: string, safeAddress: string, decimals: number = 18) => {
console.log('calculateBalanceOf start', tokenAddress, safeAddress, decimals)
if (tokenAddress === ETH_ADDRESS) { if (tokenAddress === ETH_ADDRESS) {
console.log('calculateBalanceOf eth')
return '0' return '0'
} }
console.log('calculateBalanceOf continue')
const erc20Token = await getStandardTokenContract() const erc20Token = await getStandardTokenContract()
console.log('calculateBalanceOf end', erc20Token)
let balance = 0 let balance = 0
try { try {
const token = await erc20Token.at(tokenAddress) const token = await erc20Token.at(tokenAddress)
balance = await token.balanceOf(safeAddress) balance = await token.balanceOf(safeAddress)
console.log('tokenAddress', balance)
} catch (err) { } catch (err) {
console.error('Failed to fetch token balances: ', err) console.error('Failed to fetch token balances: ', err)
} }
@ -34,25 +29,20 @@ export const calculateBalanceOf = async (tokenAddress: string, safeAddress: stri
const fetchTokenBalances = (safeAddress: string, tokens: List<Token>) => async ( const fetchTokenBalances = (safeAddress: string, tokens: List<Token>) => async (
dispatch: ReduxDispatch<GlobalState>, dispatch: ReduxDispatch<GlobalState>,
) => { ) => {
console.log('fetchTokenBalances')
if (!safeAddress || !tokens || !tokens.size) { if (!safeAddress || !tokens || !tokens.size) {
return return
} }
console.log('fetchTokenBalances tokens', tokens)
try { try {
const withBalances = await Promise.all( const withBalances = await Promise.all(
tokens.map(async token => { tokens.map(async (token) => {
const balance = await calculateBalanceOf(token.address, safeAddress, token.decimals) const balance = await calculateBalanceOf(token.address, safeAddress, token.decimals)
console.log('balance', token.address, balance)
return TokenBalanceRecord({ return TokenBalanceRecord({
address: token.address, address: token.address,
balance, balance,
}) })
}) }),
) )
console.log('fetchTokenBalances withBalances', withBalances)
dispatch(updateSafe({ address: safeAddress, balances: List(withBalances) })) dispatch(updateSafe({ address: safeAddress, balances: List(withBalances) }))
console.log('fetchTokenBalances end')
} catch (err) { } catch (err) {
// eslint-disable-next-line // eslint-disable-next-line
console.error('Error while loading active tokens from storage:', err) console.error('Error while loading active tokens from storage:', err)

View File

@ -59,7 +59,6 @@ export const safesInitialState = async (): Promise<State> => {
export default handleActions<State, *>( export default handleActions<State, *>(
{ {
[UPDATE_SAFE]: (state: State, action: ActionType<Function>): State => { [UPDATE_SAFE]: (state: State, action: ActionType<Function>): State => {
console.log('updating safe')
const safe = action.payload const safe = action.payload
const safeAddress = safe.address const safeAddress = safe.address

View File

@ -30,7 +30,6 @@ afterAll(() => {
console.error = originalError console.error = originalError
}) })
const renderLoadSafe = async (localStore: Store<GlobalState>) => { const renderLoadSafe = async (localStore: Store<GlobalState>) => {
const provider = await getProviderInfo() const provider = await getProviderInfo()
const walletRecord = makeProvider(provider) const walletRecord = makeProvider(provider)