mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
use estimateGas() function in SideStaking
This commit is contained in:
parent
652ec73892
commit
2c0f3ae108
@ -2,7 +2,12 @@ import Web3 from 'web3'
|
|||||||
import { AbiItem } from 'web3-utils/types'
|
import { AbiItem } from 'web3-utils/types'
|
||||||
import { TransactionReceipt } from 'web3-core'
|
import { TransactionReceipt } from 'web3-core'
|
||||||
import { Contract } from 'web3-eth-contract'
|
import { Contract } from 'web3-eth-contract'
|
||||||
import { LoggerInstance, getFairGasPrice, configHelperNetworks } from '../../utils'
|
import {
|
||||||
|
LoggerInstance,
|
||||||
|
getFairGasPrice,
|
||||||
|
configHelperNetworks,
|
||||||
|
estimateGas
|
||||||
|
} from '../../utils'
|
||||||
import BigNumber from 'bignumber.js'
|
import BigNumber from 'bignumber.js'
|
||||||
import SideStakingTemplate from '@oceanprotocol/contracts/artifacts/contracts/pools/ssContracts/SideStaking.sol/SideStaking.json'
|
import SideStakingTemplate from '@oceanprotocol/contracts/artifacts/contracts/pools/ssContracts/SideStaking.sol/SideStaking.json'
|
||||||
import defaultErc20Abi from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json'
|
import defaultErc20Abi from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json'
|
||||||
@ -288,16 +293,7 @@ export class SideStaking {
|
|||||||
const sideStaking =
|
const sideStaking =
|
||||||
contractInstance || new this.web3.eth.Contract(this.ssAbi as AbiItem[], ssAddress)
|
contractInstance || new this.web3.eth.Contract(this.ssAbi as AbiItem[], ssAddress)
|
||||||
|
|
||||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
return estimateGas(account, sideStaking.methods.getVesting, datatokenAddress)
|
||||||
let estGas
|
|
||||||
try {
|
|
||||||
estGas = await sideStaking.methods
|
|
||||||
.getVesting(datatokenAddress)
|
|
||||||
.estimateGas({ from: account }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
|
||||||
} catch (e) {
|
|
||||||
estGas = gasLimitDefault
|
|
||||||
}
|
|
||||||
return estGas
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Send vested tokens available to the publisher address, can be called by anyone
|
/** Send vested tokens available to the publisher address, can be called by anyone
|
||||||
@ -315,12 +311,12 @@ export class SideStaking {
|
|||||||
const sideStaking = new this.web3.eth.Contract(this.ssAbi, ssAddress)
|
const sideStaking = new this.web3.eth.Contract(this.ssAbi, ssAddress)
|
||||||
let result = null
|
let result = null
|
||||||
|
|
||||||
const estGas = await this.estGetVesting(
|
const estGas = await estimateGas(
|
||||||
account,
|
account,
|
||||||
ssAddress,
|
sideStaking.methods.getVesting,
|
||||||
datatokenAddress,
|
datatokenAddress
|
||||||
sideStaking
|
|
||||||
)
|
)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
result = await sideStaking.methods.getVesting(datatokenAddress).send({
|
result = await sideStaking.methods.getVesting(datatokenAddress).send({
|
||||||
from: account,
|
from: account,
|
||||||
@ -352,16 +348,13 @@ export class SideStaking {
|
|||||||
const sideStaking =
|
const sideStaking =
|
||||||
contractInstance || new this.web3.eth.Contract(this.ssAbi as AbiItem[], ssAddress)
|
contractInstance || new this.web3.eth.Contract(this.ssAbi as AbiItem[], ssAddress)
|
||||||
|
|
||||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
return estimateGas(
|
||||||
let estGas
|
account,
|
||||||
try {
|
sideStaking.methods.setPoolSwapFee,
|
||||||
estGas = await sideStaking.methods
|
datatokenAddress,
|
||||||
.setPoolSwapFee(datatokenAddress, poolAddress, swapFee)
|
poolAddress,
|
||||||
.estimateGas({ from: account }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
swapFee
|
||||||
} catch (e) {
|
)
|
||||||
estGas = gasLimitDefault
|
|
||||||
}
|
|
||||||
return estGas
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Send vested tokens available to the publisher address, can be called by anyone
|
/** Send vested tokens available to the publisher address, can be called by anyone
|
||||||
@ -381,14 +374,14 @@ export class SideStaking {
|
|||||||
const sideStaking = new this.web3.eth.Contract(this.ssAbi, ssAddress)
|
const sideStaking = new this.web3.eth.Contract(this.ssAbi, ssAddress)
|
||||||
let result = null
|
let result = null
|
||||||
|
|
||||||
const estGas = await this.estSetPoolSwapFee(
|
const estGas = await estimateGas(
|
||||||
account,
|
account,
|
||||||
ssAddress,
|
sideStaking.methods.setPoolSwapFee,
|
||||||
datatokenAddress,
|
datatokenAddress,
|
||||||
poolAddress,
|
poolAddress,
|
||||||
swapFee,
|
swapFee
|
||||||
sideStaking
|
|
||||||
)
|
)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
result = await sideStaking.methods
|
result = await sideStaking.methods
|
||||||
.setPoolSwapFee(datatokenAddress, poolAddress, swapFee)
|
.setPoolSwapFee(datatokenAddress, poolAddress, swapFee)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user