1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

Remove try...catch from ContractUtils

This commit is contained in:
Miquel A. Cabot 2022-06-21 11:42:55 +02:00
parent 3a1abb2813
commit d387076a08

View File

@ -32,7 +32,6 @@ export async function unitsToAmount(
amount: string,
tokenDecimals?: number
): Promise<string> {
try {
const tokenContract = new web3.eth.Contract(minAbi, token)
let decimals = tokenDecimals || (await tokenContract.methods.decimals().call())
if (decimals === '0') {
@ -45,9 +44,6 @@ export async function unitsToAmount(
BigNumber.config({ EXPONENTIAL_AT: 50 })
return amountFormatted.toString()
} catch (e) {
LoggerInstance.error(`ERROR: FAILED TO CALL DECIMALS(), USING 18' : ${e.message}`)
}
}
export async function amountToUnits(
@ -56,7 +52,6 @@ export async function amountToUnits(
amount: string,
tokenDecimals?: number
): Promise<string> {
try {
const tokenContract = new web3.eth.Contract(minAbi, token)
let decimals = tokenDecimals || (await tokenContract.methods.decimals().call())
if (decimals === '0') {
@ -69,9 +64,6 @@ export async function amountToUnits(
)
return amountFormatted.toString()
} catch (e) {
LoggerInstance.error(`ERROR: FAILED TO CALL DECIMALS(), USING 18', ${e.message}`)
}
}
/**
@ -86,16 +78,11 @@ export async function calculateEstimatedGas(
functionToEstimateGas: Function,
...args: any[]
): Promise<any> {
let estimatedGas = GASLIMIT_DEFAULT
try {
estimatedGas = await functionToEstimateGas.apply(null, args).estimateGas(
const estimatedGas = await functionToEstimateGas.apply(null, args).estimateGas(
{
from: from
},
(err, estGas) => (err ? GASLIMIT_DEFAULT : estGas)
)
} catch (e) {
LoggerInstance.error(`ERROR: Estimate gas failed!`, e)
}
return estimatedGas
}