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

Remove try...catch from Dispenser

This commit is contained in:
Miquel A. Cabot 2022-06-21 11:59:05 +02:00
parent e5cdeee702
commit bf1eab7df8

View File

@ -17,16 +17,11 @@ export class Dispenser extends SmartContractWithAddress {
* @return {Promise<FixedPricedExchange>} Exchange details
*/
public async status(dtAdress: string): Promise<DispenserToken> {
try {
const status: DispenserToken = await this.contract.methods.status(dtAdress).call()
status.maxTokens = this.web3.utils.fromWei(status.maxTokens)
status.maxBalance = this.web3.utils.fromWei(status.maxBalance)
status.balance = this.web3.utils.fromWei(status.balance)
return status
} catch (e) {
LoggerInstance.warn(`No dispenser available for datatoken: ${dtAdress}`)
}
return null
}
/**
@ -89,7 +84,6 @@ export class Dispenser extends SmartContractWithAddress {
address: string,
estimateGas?: G
): Promise<G extends false ? TransactionReceipt : number> {
try {
const estGas = await calculateEstimatedGas(
address,
this.contract.methods.activate,
@ -111,10 +105,6 @@ export class Dispenser extends SmartContractWithAddress {
gasPrice: await this.getFairGasPrice()
})
return trxReceipt
} catch (e) {
LoggerInstance.error(`ERROR: Failed to activate dispenser: ${e.message}`)
}
return null
}
/**
@ -128,7 +118,6 @@ export class Dispenser extends SmartContractWithAddress {
address: string,
estimateGas?: G
): Promise<G extends false ? TransactionReceipt : number> {
try {
const estGas = await calculateEstimatedGas(
address,
this.contract.methods.deactivate,
@ -142,10 +131,6 @@ export class Dispenser extends SmartContractWithAddress {
gasPrice: await this.getFairGasPrice()
})
return trxReceipt
} catch (e) {
LoggerInstance.error(`ERROR: Failed to activate dispenser: ${e.message}`)
}
return null
}
/**
@ -161,7 +146,6 @@ export class Dispenser extends SmartContractWithAddress {
newAllowedSwapper: string,
estimateGas?: G
): Promise<G extends false ? TransactionReceipt : number> {
try {
const estGas = await calculateEstimatedGas(
address,
this.contract.methods.setAllowedSwapper,
@ -178,10 +162,6 @@ export class Dispenser extends SmartContractWithAddress {
gasPrice: await this.getFairGasPrice()
})
return trxReceipt
} catch (e) {
LoggerInstance.error(`ERROR: Failed to activate dispenser: ${e.message}`)
}
return null
}
/**
@ -210,7 +190,6 @@ export class Dispenser extends SmartContractWithAddress {
)
if (estimateGas) return estGas
try {
const trxReceipt = await this.contract.methods
.dispense(dtAddress, this.web3.utils.toWei(amount), destination)
.send({
@ -219,10 +198,6 @@ export class Dispenser extends SmartContractWithAddress {
gasPrice: await this.getFairGasPrice()
})
return trxReceipt
} catch (e) {
LoggerInstance.error(`ERROR: Failed to dispense tokens: ${e.message}`)
}
return null
}
/**
@ -243,17 +218,12 @@ export class Dispenser extends SmartContractWithAddress {
)
if (estimateGas) return estGas
try {
const trxReceipt = await this.contract.methods.ownerWithdraw(dtAddress).send({
from: address,
gas: estGas + 1,
gasPrice: await this.getFairGasPrice()
})
return trxReceipt
} catch (e) {
LoggerInstance.error(`ERROR: Failed to withdraw tokens: ${e.message}`)
}
return null
}
/**