mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Remove try...catch from SideStaking
This commit is contained in:
parent
792387cc6c
commit
52c5195349
@ -20,14 +20,9 @@ export class SideStaking extends SmartContract {
|
|||||||
datatokenAddress: string
|
datatokenAddress: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const sideStaking = this.getContract(ssAddress)
|
const sideStaking = this.getContract(ssAddress)
|
||||||
let supply = null
|
const supply = await sideStaking.methods
|
||||||
try {
|
|
||||||
supply = await sideStaking.methods
|
|
||||||
.getDatatokenCirculatingSupply(datatokenAddress)
|
.getDatatokenCirculatingSupply(datatokenAddress)
|
||||||
.call()
|
.call()
|
||||||
} catch (e) {
|
|
||||||
LoggerInstance.error(`ERROR: Failed to get: ${e.message}`)
|
|
||||||
}
|
|
||||||
return supply.toString()
|
return supply.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,16 +37,11 @@ export class SideStaking extends SmartContract {
|
|||||||
ssAddress: string,
|
ssAddress: string,
|
||||||
datatokenAddress: string
|
datatokenAddress: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
try {
|
|
||||||
const sideStaking = this.getContract(ssAddress)
|
const sideStaking = this.getContract(ssAddress)
|
||||||
let supply = null
|
const supply = await sideStaking.methods
|
||||||
supply = await sideStaking.methods
|
|
||||||
.getDatatokenCurrentCirculatingSupply(datatokenAddress)
|
.getDatatokenCurrentCirculatingSupply(datatokenAddress)
|
||||||
.call()
|
.call()
|
||||||
return supply.toString()
|
return supply.toString()
|
||||||
} catch (e) {
|
|
||||||
LoggerInstance.error(`ERROR: Failed to get: ${e.message}`)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,12 +55,7 @@ export class SideStaking extends SmartContract {
|
|||||||
datatokenAddress: string
|
datatokenAddress: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const sideStaking = this.getContract(ssAddress)
|
const sideStaking = this.getContract(ssAddress)
|
||||||
let address = null
|
const address = await sideStaking.methods.getPublisherAddress(datatokenAddress).call()
|
||||||
try {
|
|
||||||
address = await sideStaking.methods.getPublisherAddress(datatokenAddress).call()
|
|
||||||
} catch (e) {
|
|
||||||
LoggerInstance.error(`ERROR: Failed to get: ${e.message}`)
|
|
||||||
}
|
|
||||||
return address
|
return address
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,12 +70,7 @@ export class SideStaking extends SmartContract {
|
|||||||
datatokenAddress: string
|
datatokenAddress: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const sideStaking = this.getContract(ssAddress)
|
const sideStaking = this.getContract(ssAddress)
|
||||||
let address = null
|
const address = await sideStaking.methods.getBaseTokenAddress(datatokenAddress).call()
|
||||||
try {
|
|
||||||
address = await sideStaking.methods.getBaseTokenAddress(datatokenAddress).call()
|
|
||||||
} catch (e) {
|
|
||||||
LoggerInstance.error(`ERROR: Failed to get: ${e.message}`)
|
|
||||||
}
|
|
||||||
return address
|
return address
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,12 +85,7 @@ export class SideStaking extends SmartContract {
|
|||||||
datatokenAddress: string
|
datatokenAddress: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const sideStaking = this.getContract(ssAddress)
|
const sideStaking = this.getContract(ssAddress)
|
||||||
let address = null
|
const address = await sideStaking.methods.getPoolAddress(datatokenAddress).call()
|
||||||
try {
|
|
||||||
address = await sideStaking.methods.getPoolAddress(datatokenAddress).call()
|
|
||||||
} catch (e) {
|
|
||||||
LoggerInstance.error(`ERROR: Failed to get: ${e.message}`)
|
|
||||||
}
|
|
||||||
return address
|
return address
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,12 +100,7 @@ export class SideStaking extends SmartContract {
|
|||||||
datatokenAddress: string
|
datatokenAddress: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const sideStaking = this.getContract(ssAddress)
|
const sideStaking = this.getContract(ssAddress)
|
||||||
let balance = null
|
const balance = await sideStaking.methods.getBaseTokenBalance(datatokenAddress).call()
|
||||||
try {
|
|
||||||
balance = await sideStaking.methods.getBaseTokenBalance(datatokenAddress).call()
|
|
||||||
} catch (e) {
|
|
||||||
LoggerInstance.error(`ERROR: Failed to get: ${e.message}`)
|
|
||||||
}
|
|
||||||
return balance
|
return balance
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,12 +117,7 @@ export class SideStaking extends SmartContract {
|
|||||||
tokenDecimals?: number
|
tokenDecimals?: number
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const sideStaking = this.getContract(ssAddress)
|
const sideStaking = this.getContract(ssAddress)
|
||||||
let balance = null
|
let balance = await sideStaking.methods.getDatatokenBalance(datatokenAddress).call()
|
||||||
try {
|
|
||||||
balance = await sideStaking.methods.getDatatokenBalance(datatokenAddress).call()
|
|
||||||
} catch (e) {
|
|
||||||
LoggerInstance.error(`ERROR: Failed to get: ${e.message}`)
|
|
||||||
}
|
|
||||||
balance = await this.unitsToAmount(datatokenAddress, balance, tokenDecimals)
|
balance = await this.unitsToAmount(datatokenAddress, balance, tokenDecimals)
|
||||||
return balance
|
return balance
|
||||||
}
|
}
|
||||||
@ -168,12 +133,7 @@ export class SideStaking extends SmartContract {
|
|||||||
datatokenAddress: string
|
datatokenAddress: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const sideStaking = this.getContract(ssAddress)
|
const sideStaking = this.getContract(ssAddress)
|
||||||
let block = null
|
const block = await sideStaking.methods.getvestingEndBlock(datatokenAddress).call()
|
||||||
try {
|
|
||||||
block = await sideStaking.methods.getvestingEndBlock(datatokenAddress).call()
|
|
||||||
} catch (e) {
|
|
||||||
LoggerInstance.error(`ERROR: Failed to get: ${e.message}`)
|
|
||||||
}
|
|
||||||
return block
|
return block
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,12 +150,7 @@ export class SideStaking extends SmartContract {
|
|||||||
tokenDecimals?: number
|
tokenDecimals?: number
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const sideStaking = this.getContract(ssAddress)
|
const sideStaking = this.getContract(ssAddress)
|
||||||
let amount = null
|
let amount = await sideStaking.methods.getvestingAmount(datatokenAddress).call()
|
||||||
try {
|
|
||||||
amount = await sideStaking.methods.getvestingAmount(datatokenAddress).call()
|
|
||||||
} catch (e) {
|
|
||||||
LoggerInstance.error(`ERROR: Failed to get: ${e.message}`)
|
|
||||||
}
|
|
||||||
amount = await this.unitsToAmount(datatokenAddress, amount, tokenDecimals)
|
amount = await this.unitsToAmount(datatokenAddress, amount, tokenDecimals)
|
||||||
return amount
|
return amount
|
||||||
}
|
}
|
||||||
@ -211,12 +166,7 @@ export class SideStaking extends SmartContract {
|
|||||||
datatokenAddress: string
|
datatokenAddress: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const sideStaking = this.getContract(ssAddress)
|
const sideStaking = this.getContract(ssAddress)
|
||||||
let block = null
|
const block = await sideStaking.methods.getvestingLastBlock(datatokenAddress).call()
|
||||||
try {
|
|
||||||
block = await sideStaking.methods.getvestingLastBlock(datatokenAddress).call()
|
|
||||||
} catch (e) {
|
|
||||||
LoggerInstance.error(`ERROR: Failed to get: ${e.message}`)
|
|
||||||
}
|
|
||||||
return block
|
return block
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,12 +183,7 @@ export class SideStaking extends SmartContract {
|
|||||||
tokenDecimals?: number
|
tokenDecimals?: number
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const sideStaking = this.getContract(ssAddress)
|
const sideStaking = this.getContract(ssAddress)
|
||||||
let amount = null
|
let amount = await sideStaking.methods.getvestingAmountSoFar(datatokenAddress).call()
|
||||||
try {
|
|
||||||
amount = await sideStaking.methods.getvestingAmountSoFar(datatokenAddress).call()
|
|
||||||
} catch (e) {
|
|
||||||
LoggerInstance.error(`ERROR: Failed to get: ${e.message}`)
|
|
||||||
}
|
|
||||||
amount = await this.unitsToAmount(datatokenAddress, amount, tokenDecimals)
|
amount = await this.unitsToAmount(datatokenAddress, amount, tokenDecimals)
|
||||||
return amount
|
return amount
|
||||||
}
|
}
|
||||||
@ -257,7 +202,6 @@ export class SideStaking extends SmartContract {
|
|||||||
estimateGas?: G
|
estimateGas?: G
|
||||||
): Promise<G extends false ? TransactionReceipt : number> {
|
): Promise<G extends false ? TransactionReceipt : number> {
|
||||||
const sideStaking = this.getContract(ssAddress)
|
const sideStaking = this.getContract(ssAddress)
|
||||||
let vesting = null
|
|
||||||
|
|
||||||
const estGas = await calculateEstimatedGas(
|
const estGas = await calculateEstimatedGas(
|
||||||
account,
|
account,
|
||||||
@ -266,15 +210,11 @@ export class SideStaking extends SmartContract {
|
|||||||
)
|
)
|
||||||
if (estimateGas) return estGas
|
if (estimateGas) return estGas
|
||||||
|
|
||||||
try {
|
const vesting = await sideStaking.methods.getVesting(datatokenAddress).send({
|
||||||
vesting = await sideStaking.methods.getVesting(datatokenAddress).send({
|
|
||||||
from: account,
|
from: account,
|
||||||
gas: estGas + 1,
|
gas: estGas + 1,
|
||||||
gasPrice: await this.getFairGasPrice()
|
gasPrice: await this.getFairGasPrice()
|
||||||
})
|
})
|
||||||
} catch (e) {
|
|
||||||
LoggerInstance.error('ERROR: Failed to join swap pool amount out')
|
|
||||||
}
|
|
||||||
return vesting
|
return vesting
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,7 +234,6 @@ export class SideStaking extends SmartContract {
|
|||||||
estimateGas?: G
|
estimateGas?: G
|
||||||
): Promise<G extends false ? TransactionReceipt : number> {
|
): Promise<G extends false ? TransactionReceipt : number> {
|
||||||
const sideStaking = this.getContract(ssAddress)
|
const sideStaking = this.getContract(ssAddress)
|
||||||
let fee = null
|
|
||||||
|
|
||||||
const estGas = await calculateEstimatedGas(
|
const estGas = await calculateEstimatedGas(
|
||||||
account,
|
account,
|
||||||
@ -305,17 +244,13 @@ export class SideStaking extends SmartContract {
|
|||||||
)
|
)
|
||||||
if (estimateGas) return estGas
|
if (estimateGas) return estGas
|
||||||
|
|
||||||
try {
|
const fee = await sideStaking.methods
|
||||||
fee = await sideStaking.methods
|
|
||||||
.setPoolSwapFee(datatokenAddress, poolAddress, swapFee)
|
.setPoolSwapFee(datatokenAddress, poolAddress, swapFee)
|
||||||
.send({
|
.send({
|
||||||
from: account,
|
from: account,
|
||||||
gas: estGas + 1,
|
gas: estGas + 1,
|
||||||
gasPrice: await this.getFairGasPrice()
|
gasPrice: await this.getFairGasPrice()
|
||||||
})
|
})
|
||||||
} catch (e) {
|
|
||||||
LoggerInstance.error('ERROR: Failed to join swap pool amount out')
|
|
||||||
}
|
|
||||||
return fee
|
return fee
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,12 +261,7 @@ export class SideStaking extends SmartContract {
|
|||||||
*/
|
*/
|
||||||
public async getRouter(ssAddress: string): Promise<string> {
|
public async getRouter(ssAddress: string): Promise<string> {
|
||||||
const sideStaking = this.getContract(ssAddress)
|
const sideStaking = this.getContract(ssAddress)
|
||||||
let router = null
|
const router = await sideStaking.methods.router().call()
|
||||||
try {
|
|
||||||
router = await sideStaking.methods.router().call()
|
|
||||||
} catch (e) {
|
|
||||||
LoggerInstance.error(`ERROR: Failed to get Router address: ${e.message}`)
|
|
||||||
}
|
|
||||||
return router
|
return router
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user