mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
deleted old pool files
This commit is contained in:
parent
c1033390ef
commit
e5c718604c
@ -1,34 +0,0 @@
|
|||||||
import Web3 from 'web3'
|
|
||||||
import { AbiItem } from 'web3-utils'
|
|
||||||
import { Contract } from 'web3-eth-contract'
|
|
||||||
import defaultPoolABI from '@oceanprotocol/contracts/artifacts/contracts/interfaces/IPool.sol/IPool.json'
|
|
||||||
import defaultERC20ABI from '@oceanprotocol/contracts/artifacts/contracts/interfaces/IERC20.sol/IERC20.json'
|
|
||||||
import { PoolFactory } from './PoolFactory'
|
|
||||||
import { LoggerInstance } from '../../utils'
|
|
||||||
|
|
||||||
export class OceanPool extends PoolFactory {
|
|
||||||
public oceanAddress: string = null
|
|
||||||
public dtAddress: string = null
|
|
||||||
public startBlock: number
|
|
||||||
public vaultABI: AbiItem | AbiItem[]
|
|
||||||
public vaultAddress: string
|
|
||||||
public vault: Contract
|
|
||||||
public poolABI: AbiItem | AbiItem[]
|
|
||||||
public erc20ABI: AbiItem | AbiItem[]
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
web3: Web3,
|
|
||||||
routerAddress: string = null,
|
|
||||||
oceanAddress: string = null,
|
|
||||||
startBlock?: number
|
|
||||||
) {
|
|
||||||
super(web3, routerAddress)
|
|
||||||
|
|
||||||
this.poolABI = defaultPoolABI.abi as AbiItem[]
|
|
||||||
this.erc20ABI = defaultERC20ABI.abi as AbiItem[]
|
|
||||||
this.vault = new this.web3.eth.Contract(this.vaultABI, this.vaultAddress)
|
|
||||||
|
|
||||||
if (startBlock) this.startBlock = startBlock
|
|
||||||
else this.startBlock = 0
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
import Web3 from 'web3'
|
|
||||||
import { AbiItem } from 'web3-utils'
|
|
||||||
import { Contract } from 'web3-eth-contract'
|
|
||||||
import defaultRouterABI from '@oceanprotocol/contracts/artifacts/contracts/interfaces/IFactoryRouter.sol/IFactoryRouter.json'
|
|
||||||
import { LoggerInstance } from '../../utils'
|
|
||||||
import { TransactionReceipt } from 'web3-eth'
|
|
||||||
|
|
||||||
export class PoolFactory {
|
|
||||||
public GASLIMIT_DEFAULT = 1000000
|
|
||||||
public web3: Web3 = null
|
|
||||||
public routerABI: AbiItem | AbiItem[]
|
|
||||||
|
|
||||||
public routerAddress: string
|
|
||||||
|
|
||||||
public router: Contract
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiate PoolFactory.
|
|
||||||
* @param {String} routerAddress
|
|
||||||
* @param {AbiItem | AbiItem[]} routerABI
|
|
||||||
* @param {Web3} web3
|
|
||||||
*/
|
|
||||||
constructor(web3: Web3, routerAddress: string, routerABI?: AbiItem | AbiItem[]) {
|
|
||||||
this.web3 = web3
|
|
||||||
this.routerAddress = routerAddress
|
|
||||||
this.routerABI = routerABI || (defaultRouterABI.abi as AbiItem[])
|
|
||||||
this.router = new this.web3.eth.Contract(this.routerABI, this.routerAddress)
|
|
||||||
}
|
|
||||||
|
|
||||||
public async deployPool(
|
|
||||||
account: string,
|
|
||||||
tokens: string[],
|
|
||||||
weightsInWei: string[],
|
|
||||||
swapFeePercentage: number,
|
|
||||||
swapMarketFee: number,
|
|
||||||
owner: string
|
|
||||||
): Promise<TransactionReceipt> {
|
|
||||||
const gasLimitDefault = this.GASLIMIT_DEFAULT
|
|
||||||
let estGas
|
|
||||||
try {
|
|
||||||
estGas = await this.router.methods
|
|
||||||
.deployPool(tokens, weightsInWei, swapFeePercentage, swapMarketFee, owner)
|
|
||||||
.estimateGas({ from: account }, (err, estGas) => (err ? gasLimitDefault : estGas))
|
|
||||||
} catch (e) {
|
|
||||||
LoggerInstance.log('Error estimate gas deployPool')
|
|
||||||
LoggerInstance.log(e)
|
|
||||||
estGas = gasLimitDefault
|
|
||||||
}
|
|
||||||
return estGas
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user