Add temporary logs

This commit is contained in:
Germán Martínez 2019-05-17 18:17:24 +02:00
parent 800955fbe6
commit ca4d298a02
9 changed files with 40 additions and 11 deletions

View File

@ -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

View File

@ -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<GlobalState>) => {
try {
console.log('fetchTokens------')
const {
data: { results: tokenList },
} = await fetchTokenList()

View File

@ -7,9 +7,10 @@ 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)),
)

View File

@ -87,6 +87,7 @@ 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)

View File

@ -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)

View File

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

View File

@ -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())

View File

@ -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<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 => 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)

View File

@ -59,6 +59,7 @@ 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