refactor: import web3ReadOnly as web3

This commit is contained in:
fernandomg 2020-05-26 08:19:09 -03:00
parent bce4cf60e0
commit 1947f1c470
3 changed files with 3 additions and 8 deletions

View File

@ -1,5 +1,5 @@
//
import { web3ReadOnly } from 'src/logic/wallets/getWeb3'
import { web3ReadOnly as web3 } from 'src/logic/wallets/getWeb3'
/**
* Generates a batch request for grouping RPC calls
@ -12,7 +12,6 @@ import { web3ReadOnly } from 'src/logic/wallets/getWeb3'
* @returns {Promise<[*]>}
*/
const generateBatchRequests = ({ abi, address, batch, context, methods }: any): any => {
const web3 = web3ReadOnly
const contractInstance = new web3.eth.Contract(abi, address)
const localBatch = batch ? null : new web3.BatchRequest()

View File

@ -1,4 +1,4 @@
import { web3ReadOnly } from 'src/logic/wallets/getWeb3'
import { web3ReadOnly as web3 } from 'src/logic/wallets/getWeb3'
// SAFE METHODS TO ITS ID
// https://github.com/gnosis/safe-contracts/blob/development/test/safeMethodNaming.js
@ -53,7 +53,6 @@ const METHOD_TO_ID = {
}
export const decodeParamsFromSafeMethod = (data) => {
const web3 = web3ReadOnly
const [methodId, params] = [data.slice(0, 10), data.slice(10)]
switch (methodId) {
@ -110,7 +109,6 @@ const isSafeMethod = (methodId: string) => {
}
export const decodeMethods = (data: string) => {
const web3 = web3ReadOnly
const [methodId, params] = [data.slice(0, 10), data.slice(10)]
if (isSafeMethod(methodId)) {

View File

@ -3,7 +3,7 @@ import generateBatchRequests from 'src/logic/contracts/generateBatchRequests'
import { getStandardTokenContract, getTokenInfos } from 'src/logic/tokens/store/actions/fetchTokens'
import { makeToken } from 'src/logic/tokens/store/model/token'
import { ALTERNATIVE_TOKEN_ABI } from 'src/logic/tokens/utils/alternativeAbi'
import { web3ReadOnly } from 'src/logic/wallets/getWeb3'
import { web3ReadOnly as web3 } from 'src/logic/wallets/getWeb3'
import { isEmptyData } from 'src/routes/safe/store/actions/transactions/utils/transactionHelpers'
export const ETH_ADDRESS = '0x000'
@ -29,8 +29,6 @@ export const isAddressAToken = async (tokenAddress) => {
// } catch {
// return 'Not a token address'
// }
const web3 = web3ReadOnly
const call = await web3.eth.call({ to: tokenAddress, data: web3.utils.sha3('totalSupply()') })
return call !== '0x'