diff --git a/src/logic/contracts/safeContracts.js b/src/logic/contracts/safeContracts.js index e2108346..79b3241b 100644 --- a/src/logic/contracts/safeContracts.js +++ b/src/logic/contracts/safeContracts.js @@ -10,8 +10,10 @@ import { ZERO_ADDRESS } from '~/logic/wallets/ethAddresses' let proxyFactoryMaster let safeMaster -const createGnosisSafeContract = (web3: any) => { +const createGnosisSafeContract = async (web3: any) => { + console.log('createGnosisSafeContract') const gnosisSafe = contract(GnosisSafeSol) + console.log('gnosisSafe', gnosisSafe, web3) gnosisSafe.setProvider(web3.currentProvider) return gnosisSafe @@ -75,7 +77,10 @@ export const deploySafeContract = async (safeAccounts: string[], numConfirmation export const getGnosisSafeInstanceAt = async (safeAddress: string) => { const web3 = getWeb3() - const GnosisSafe = getGnosisSafeContract(web3) + 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 204dc54a..af279fa8 100644 --- a/src/logic/tokens/store/actions/fetchTokens.js +++ b/src/logic/tokens/store/actions/fetchTokens.js @@ -12,14 +12,20 @@ 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) @@ -32,6 +38,7 @@ 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 7ca0aa80..620bb9c7 100644 --- a/src/logic/tokens/store/actions/loadActiveTokens.js +++ b/src/logic/tokens/store/actions/loadActiveTokens.js @@ -7,9 +7,10 @@ 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 edd5d304..275dcbe3 100644 --- a/src/logic/wallets/getWeb3.js +++ b/src/logic/wallets/getWeb3.js @@ -87,6 +87,7 @@ 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/routes/open/container/Open.jsx b/src/routes/open/container/Open.jsx index 7d65b08f..ee51b2ff 100644 --- a/src/routes/open/container/Open.jsx +++ b/src/routes/open/container/Open.jsx @@ -34,6 +34,7 @@ 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 bd0a7b68..f784471d 100644 --- a/src/routes/safe/container/index.jsx +++ b/src/routes/safe/container/index.jsx @@ -23,6 +23,7 @@ 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/fetchSafe.js b/src/routes/safe/store/actions/fetchSafe.js index 83fd2774..68b47594 100644 --- a/src/routes/safe/store/actions/fetchSafe.js +++ b/src/routes/safe/store/actions/fetchSafe.js @@ -19,7 +19,9 @@ 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 a9b3d503..24e63a51 100644 --- a/src/routes/safe/store/actions/fetchTokenBalances.js +++ b/src/routes/safe/store/actions/fetchTokenBalances.js @@ -10,16 +10,20 @@ 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) } @@ -30,19 +34,25 @@ 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 => TokenBalanceRecord({ - address: token.address, - balance: await calculateBalanceOf(token.address, safeAddress, token.decimals), - })), + 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 8e90b2cc..7f7ad859 100644 --- a/src/routes/safe/store/reducer/safe.js +++ b/src/routes/safe/store/reducer/safe.js @@ -59,6 +59,7 @@ 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