diff --git a/src/components/Header/index.jsx b/src/components/Header/index.jsx index 4542a2cd..98fa0bf6 100644 --- a/src/components/Header/index.jsx +++ b/src/components/Header/index.jsx @@ -27,36 +27,30 @@ class HeaderComponent extends React.PureComponent { } async componentDidMount() { - const { fetchProvider, recurrentFetchProvider } = this.props - - let currentProvider: ProviderProps = await fetchProvider(this.props.openSnackbar) - this.providerListener = setInterval(async () => { - console.log('loop') - currentProvider = await recurrentFetchProvider(currentProvider, this.props.openSnackbar) - }, 2000) + this.onConnect() } componentDidCatch(error: Error, info: Info) { + const { openSnackbar } = this.props this.setState({ hasError: true }) - this.props.openSnackbar(WALLET_ERROR_MSG, 'error') + openSnackbar(WALLET_ERROR_MSG, 'error') logComponentStack(error, info) } onDisconnect = () => { + const { removeProvider } = this.props clearInterval(this.providerListener) - this.props.removeProvider(this.props.openSnackbar) + removeProvider(this.props.openSnackbar) } onConnect = async () => { const { fetchProvider, recurrentFetchProvider } = this.props clearInterval(this.providerListener) - console.log('onConnect') let currentProvider: ProviderProps = await fetchProvider(this.props.openSnackbar) this.providerListener = setInterval(async () => { - console.log('loopConnect') currentProvider = await recurrentFetchProvider(currentProvider, this.props.openSnackbar) }, 2000) } diff --git a/src/logic/contracts/safeContracts.js b/src/logic/contracts/safeContracts.js index 79b3241b..16c6bf2f 100644 --- a/src/logic/contracts/safeContracts.js +++ b/src/logic/contracts/safeContracts.js @@ -11,9 +11,7 @@ let proxyFactoryMaster let safeMaster const createGnosisSafeContract = async (web3: any) => { - console.log('createGnosisSafeContract') const gnosisSafe = contract(GnosisSafeSol) - console.log('gnosisSafe', gnosisSafe, web3) gnosisSafe.setProvider(web3.currentProvider) return gnosisSafe @@ -77,10 +75,7 @@ export const deploySafeContract = async (safeAccounts: string[], numConfirmation export const getGnosisSafeInstanceAt = async (safeAddress: string) => { const web3 = getWeb3() - console.log('web3', web3) const GnosisSafe = await getGnosisSafeContract(web3) - console.log('GnosisSafe', GnosisSafe) - console.log('safeAddress', safeAddress) const gnosisSafe = await GnosisSafe.at(safeAddress) return gnosisSafe diff --git a/src/logic/tokens/store/actions/fetchTokens.js b/src/logic/tokens/store/actions/fetchTokens.js index af279fa8..04d8a1c3 100644 --- a/src/logic/tokens/store/actions/fetchTokens.js +++ b/src/logic/tokens/store/actions/fetchTokens.js @@ -12,20 +12,14 @@ import { ensureOnce } from '~/utils/singleton' import saveTokens from './saveTokens' const createStandardTokenContract = async () => { - console.log('createStandardTokenContract') const web3 = getWeb3() - console.log('web3', web3) const erc20Token = await contract(StandardToken) - console.log('erc20Token', erc20Token) erc20Token.setProvider(web3.currentProvider) - console.log('erc20Token', erc20Token) return erc20Token } const createHumanFriendlyTokenContract = async () => { - console.log('createHumanFriendlyTokenContract') const web3 = getWeb3() - console.log('web3', web3) const humanErc20Token = await contract(HumanFriendlyToken) humanErc20Token.setProvider(web3.currentProvider) @@ -38,7 +32,6 @@ export const getStandardTokenContract = ensureOnce(createStandardTokenContract) export const fetchTokens = () => async (dispatch: ReduxDispatch) => { try { - console.log('fetchTokens------') const { data: { results: tokenList }, } = await fetchTokenList() diff --git a/src/logic/tokens/store/actions/loadActiveTokens.js b/src/logic/tokens/store/actions/loadActiveTokens.js index 620bb9c7..e93e35fd 100644 --- a/src/logic/tokens/store/actions/loadActiveTokens.js +++ b/src/logic/tokens/store/actions/loadActiveTokens.js @@ -7,10 +7,8 @@ import { getActiveTokens } from '~/logic/tokens/utils/tokensStorage' import saveTokens from './saveTokens' const loadActiveTokens = () => async (dispatch: ReduxDispatch) => { - console.log('loadActiveTokens') try { const tokens: Map = await getActiveTokens() - console.log('tokens', tokens) const tokenRecordsList: List = List( Object.values(tokens).map((token: TokenProps): Token => makeToken(token)), ) diff --git a/src/logic/wallets/getWeb3.js b/src/logic/wallets/getWeb3.js index 275dcbe3..edd5d304 100644 --- a/src/logic/wallets/getWeb3.js +++ b/src/logic/wallets/getWeb3.js @@ -87,7 +87,6 @@ export const getProviderInfo: Function = async (): Promise => { } web3 = new Web3(web3Provider) - console.log('WEB3 UPDATED!!!!', web3, getWeb3()) const name = getProviderName(web3) const account = await getAccountFrom(web3) diff --git a/src/logic/wallets/store/actions/fetchProvider.js b/src/logic/wallets/store/actions/fetchProvider.js index ef6c0805..db33eab7 100644 --- a/src/logic/wallets/store/actions/fetchProvider.js +++ b/src/logic/wallets/store/actions/fetchProvider.js @@ -44,13 +44,12 @@ const handleProviderNotification = (openSnackbar: Function, provider: ProviderPr 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() if (JSON.stringify(currentProvider) !== JSON.stringify(newProvider)) { - console.log('provider updated') - console.log(JSON.stringify(currentProvider)) - console.log(JSON.stringify(newProvider)) handleProviderNotification(openSnackbar, newProvider) processProviderResponse(dispatch, newProvider) } @@ -60,7 +59,6 @@ export const recurrentFetchProvider = (currentProvider: ProviderProps, openSnack export default (openSnackbar: Function) => async (dispatch: ReduxDispatch<*>) => { const provider: ProviderProps = await getProviderInfo() - console.log('initial provider', provider) handleProviderNotification(openSnackbar, provider) processProviderResponse(dispatch, provider) diff --git a/src/routes/load/components/OwnerList/index.jsx b/src/routes/load/components/OwnerList/index.jsx new file mode 100644 index 00000000..0a51c8d9 --- /dev/null +++ b/src/routes/load/components/OwnerList/index.jsx @@ -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 { + 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 ( + + + + {`This Safe has ${owners.length} owners. Optional: Provide a name for each owner.`} + + + + + NAME + ADDRESS + + + + { owners.map((x, index) => ( + + + + + + + + + {owners[index]} + + + + + + + + )) } + + + ) + } +} + +const OwnerListPage = withStyles(styles)(OwnerListComponent) + +const OwnerList = ({ network }: LayoutProps) => (controls: React$Node, { values }: Object) => ( + + + + + +) + +export default OwnerList diff --git a/src/routes/open/container/Open.jsx b/src/routes/open/container/Open.jsx index ee51b2ff..7d65b08f 100644 --- a/src/routes/open/container/Open.jsx +++ b/src/routes/open/container/Open.jsx @@ -34,7 +34,6 @@ export const createSafe = async (values: Object, userAccount: string, addSafe: A await checkReceiptStatus(safe.tx) const safeAddress = safe.logs[0].args.proxy - console.log('createSafe') const safeContract = await getGnosisSafeInstanceAt(safeAddress) addSafe(name, safeContract.address, numConfirmations, owners, accounts) diff --git a/src/routes/safe/container/index.jsx b/src/routes/safe/container/index.jsx index f784471d..bd0a7b68 100644 --- a/src/routes/safe/container/index.jsx +++ b/src/routes/safe/container/index.jsx @@ -23,7 +23,6 @@ class SafeView extends React.Component { fetchTokenBalances(safeUrl, activeTokens) this.intervalId = setInterval(() => { - console.log('checkUpdates') this.checkForUpdates() }, TIMEOUT) } diff --git a/src/routes/safe/store/actions/addSafe.js b/src/routes/safe/store/actions/addSafe.js index 0753e14d..97f3a312 100644 --- a/src/routes/safe/store/actions/addSafe.js +++ b/src/routes/safe/store/actions/addSafe.js @@ -25,13 +25,9 @@ export const addSafe = createAction( }), ) -const saveSafe = ( - name: string, - address: string, - threshold: number, - ownersName: string[], - ownersAddress: string[], -) => (dispatch: ReduxDispatch) => { +const saveSafe = (name: string, address: string, threshold: number, ownersName: string[], ownersAddress: string[]) => ( + dispatch: ReduxDispatch, +) => { const owners: List = buildOwnersFrom(ownersName, ownersAddress) const safe: Safe = SafeRecord({ diff --git a/src/routes/safe/store/actions/fetchSafe.js b/src/routes/safe/store/actions/fetchSafe.js index 68b47594..83fd2774 100644 --- a/src/routes/safe/store/actions/fetchSafe.js +++ b/src/routes/safe/store/actions/fetchSafe.js @@ -19,9 +19,7 @@ const buildOwnersFrom = ( }) export const buildSafe = async (safeAddress: string, safeName: string) => { - console.log('build1') const gnosisSafe = await getGnosisSafeInstanceAt(safeAddress) - console.log('build2', gnosisSafe) const ethBalance = await getBalanceInEtherOf(safeAddress) const threshold = Number(await gnosisSafe.getThreshold()) diff --git a/src/routes/safe/store/actions/fetchTokenBalances.js b/src/routes/safe/store/actions/fetchTokenBalances.js index 24e63a51..d9dbcd91 100644 --- a/src/routes/safe/store/actions/fetchTokenBalances.js +++ b/src/routes/safe/store/actions/fetchTokenBalances.js @@ -10,20 +10,15 @@ import updateSafe from './updateSafe' import { ETH_ADDRESS } from '~/logic/tokens/utils/tokenHelpers' export const calculateBalanceOf = async (tokenAddress: string, safeAddress: string, decimals: number = 18) => { - console.log('calculateBalanceOf start', tokenAddress, safeAddress, decimals) if (tokenAddress === ETH_ADDRESS) { - console.log('calculateBalanceOf eth') return '0' } - console.log('calculateBalanceOf continue') const erc20Token = await getStandardTokenContract() - console.log('calculateBalanceOf end', erc20Token) let balance = 0 try { const token = await erc20Token.at(tokenAddress) balance = await token.balanceOf(safeAddress) - console.log('tokenAddress', balance) } catch (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) => async ( dispatch: ReduxDispatch, ) => { - console.log('fetchTokenBalances') if (!safeAddress || !tokens || !tokens.size) { return } - console.log('fetchTokenBalances tokens', tokens) try { const withBalances = await Promise.all( - tokens.map(async token => { + tokens.map(async (token) => { const balance = await calculateBalanceOf(token.address, safeAddress, token.decimals) - console.log('balance', token.address, balance) return TokenBalanceRecord({ address: token.address, balance, }) - }) + }), ) - console.log('fetchTokenBalances withBalances', withBalances) dispatch(updateSafe({ address: safeAddress, balances: List(withBalances) })) - console.log('fetchTokenBalances end') } catch (err) { // eslint-disable-next-line console.error('Error while loading active tokens from storage:', err) diff --git a/src/routes/safe/store/reducer/safe.js b/src/routes/safe/store/reducer/safe.js index 7f7ad859..8e90b2cc 100644 --- a/src/routes/safe/store/reducer/safe.js +++ b/src/routes/safe/store/reducer/safe.js @@ -59,7 +59,6 @@ export const safesInitialState = async (): Promise => { export default handleActions( { [UPDATE_SAFE]: (state: State, action: ActionType): State => { - console.log('updating safe') const safe = action.payload const safeAddress = safe.address diff --git a/src/test/safe.dom.load.test.js b/src/test/safe.dom.load.test.js index d909127b..7b07b7ed 100644 --- a/src/test/safe.dom.load.test.js +++ b/src/test/safe.dom.load.test.js @@ -30,7 +30,6 @@ afterAll(() => { console.error = originalError }) - const renderLoadSafe = async (localStore: Store) => { const provider = await getProviderInfo() const walletRecord = makeProvider(provider)