Remove logs
This commit is contained in:
parent
ca4d298a02
commit
8c1586ba30
|
@ -27,36 +27,30 @@ class HeaderComponent extends React.PureComponent<Props, State> {
|
|||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<GlobalState>) => {
|
||||
try {
|
||||
console.log('fetchTokens------')
|
||||
const {
|
||||
data: { results: tokenList },
|
||||
} = await fetchTokenList()
|
||||
|
|
|
@ -7,10 +7,8 @@ import { getActiveTokens } from '~/logic/tokens/utils/tokensStorage'
|
|||
import saveTokens from './saveTokens'
|
||||
|
||||
const loadActiveTokens = () => async (dispatch: ReduxDispatch<GlobalState>) => {
|
||||
console.log('loadActiveTokens')
|
||||
try {
|
||||
const tokens: Map<string, TokenProps> = await getActiveTokens()
|
||||
console.log('tokens', tokens)
|
||||
const tokenRecordsList: List<Token> = List(
|
||||
Object.values(tokens).map((token: TokenProps): Token => makeToken(token)),
|
||||
)
|
||||
|
|
|
@ -87,7 +87,6 @@ export const getProviderInfo: Function = async (): Promise<ProviderProps> => {
|
|||
}
|
||||
|
||||
web3 = new Web3(web3Provider)
|
||||
console.log('WEB3 UPDATED!!!!', web3, getWeb3())
|
||||
|
||||
const name = getProviderName(web3)
|
||||
const account = await getAccountFrom(web3)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
|
@ -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)
|
||||
|
|
|
@ -23,7 +23,6 @@ class SafeView extends React.Component<Props> {
|
|||
fetchTokenBalances(safeUrl, activeTokens)
|
||||
|
||||
this.intervalId = setInterval(() => {
|
||||
console.log('checkUpdates')
|
||||
this.checkForUpdates()
|
||||
}, TIMEOUT)
|
||||
}
|
||||
|
|
|
@ -25,13 +25,9 @@ export const addSafe = createAction<string, Function, ActionReturn>(
|
|||
}),
|
||||
)
|
||||
|
||||
const saveSafe = (
|
||||
name: string,
|
||||
address: string,
|
||||
threshold: number,
|
||||
ownersName: string[],
|
||||
ownersAddress: string[],
|
||||
) => (dispatch: ReduxDispatch<GlobalState>) => {
|
||||
const saveSafe = (name: string, address: string, threshold: number, ownersName: string[], ownersAddress: string[]) => (
|
||||
dispatch: ReduxDispatch<GlobalState>,
|
||||
) => {
|
||||
const owners: List<Owner> = buildOwnersFrom(ownersName, ownersAddress)
|
||||
|
||||
const safe: Safe = SafeRecord({
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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<Token>) => async (
|
||||
dispatch: ReduxDispatch<GlobalState>,
|
||||
) => {
|
||||
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)
|
||||
|
|
|
@ -59,7 +59,6 @@ export const safesInitialState = async (): Promise<State> => {
|
|||
export default handleActions<State, *>(
|
||||
{
|
||||
[UPDATE_SAFE]: (state: State, action: ActionType<Function>): State => {
|
||||
console.log('updating safe')
|
||||
const safe = action.payload
|
||||
const safeAddress = safe.address
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ afterAll(() => {
|
|||
console.error = originalError
|
||||
})
|
||||
|
||||
|
||||
const renderLoadSafe = async (localStore: Store<GlobalState>) => {
|
||||
const provider = await getProviderInfo()
|
||||
const walletRecord = makeProvider(provider)
|
||||
|
|
Loading…
Reference in New Issue