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

Remove try...catch from Datatoken

This commit is contained in:
Miquel A. Cabot 2022-06-21 12:02:58 +02:00
parent 59eb56b9ee
commit 792387cc6c

View File

@ -491,7 +491,7 @@ export class Datatoken extends SmartContract {
estimateGas?: G
): Promise<G extends false ? TransactionReceipt : number> {
const dtContract = this.getContract(dtAddress)
try {
const estGas = await calculateEstimatedGas(
address,
dtContract.methods.transfer,
@ -507,10 +507,6 @@ export class Datatoken extends SmartContract {
gasPrice: await this.getFairGasPrice()
})
return trxReceipt
} catch (e) {
LoggerInstance.error(`ERROR: Failed to transfer tokens: ${e.message}`)
throw new Error(`Failed Failed to transfer tokens: ${e.message}`)
}
}
/** Start Order: called by payer or consumer prior ordering a service consume on a marketplace.
@ -539,7 +535,7 @@ export class Datatoken extends SmartContract {
consumeMarketFeeAmount: '0'
}
}
try {
const estGas = await calculateEstimatedGas(
address,
dtContract.methods.startOrder,
@ -558,10 +554,6 @@ export class Datatoken extends SmartContract {
gasPrice: await this.getFairGasPrice()
})
return trxReceipt
} catch (e) {
LoggerInstance.error(`ERROR: Failed to start order : ${e.message}`)
throw new Error(`Failed to start order: ${e.message}`)
}
}
/** Reuse Order: called by payer or consumer having a valid order, but with expired provider access.
@ -581,7 +573,7 @@ export class Datatoken extends SmartContract {
estimateGas?: G
): Promise<G extends false ? TransactionReceipt : number> {
const dtContract = this.getContract(dtAddress)
try {
const estGas = await calculateEstimatedGas(
address,
dtContract.methods.reuseOrder,
@ -590,18 +582,12 @@ export class Datatoken extends SmartContract {
)
if (estimateGas) return estGas
const trxReceipt = await dtContract.methods
.reuseOrder(orderTxId, providerFees)
.send({
const trxReceipt = await dtContract.methods.reuseOrder(orderTxId, providerFees).send({
from: address,
gas: estGas + 1,
gasPrice: await this.getFairGasPrice()
})
return trxReceipt
} catch (e) {
LoggerInstance.error(`ERROR: Failed to call reuse order order : ${e.message}`)
throw new Error(`Failed to start order: ${e.message}`)
}
}
/** Buys 1 DT from the FRE and then startsOrder, while burning that DT
@ -619,7 +605,7 @@ export class Datatoken extends SmartContract {
estimateGas?: G
): Promise<G extends false ? TransactionReceipt : number> {
const dtContract = this.getContract(dtAddress, null, this.abiEnterprise)
try {
const freContractParams = this.getFreOrderParams(freParams)
const estGas = await calculateEstimatedGas(
@ -638,10 +624,6 @@ export class Datatoken extends SmartContract {
gasPrice: await this.getFairGasPrice()
})
return trxReceipt
} catch (e) {
LoggerInstance.error(`ERROR: Failed to buy DT From Fre And Order : ${e.message}`)
throw new Error(`Failed to buy DT From Fre And Order: ${e.message}`)
}
}
/** Gets DT from dispenser and then startsOrder, while burning that DT
@ -659,7 +641,7 @@ export class Datatoken extends SmartContract {
estimateGas?: G
): Promise<G extends false ? TransactionReceipt : number> {
const dtContract = this.getContract(dtAddress, null, this.abiEnterprise)
try {
const estGas = await calculateEstimatedGas(
address,
dtContract.methods.buyFromDispenserAndOrder,
@ -676,10 +658,6 @@ export class Datatoken extends SmartContract {
gasPrice: await this.getFairGasPrice()
})
return trxReceipt
} catch (e) {
LoggerInstance.error(`ERROR: Failed to buy DT From Fre And Order : ${e.message}`)
throw new Error(`Failed to buy DT From Fre And Order: ${e.message}`)
}
}
/** setData