mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Moved interfaces under types and some small fixes (#1253)
* moved interfaces and some fixes * throw proper error messages on try catch blocks in pool class
This commit is contained in:
parent
e087b3e29b
commit
14862f6a3a
@ -1,4 +1,4 @@
|
||||
import { MetadataProof } from '../@types'
|
||||
import { MetadataProof } from '.'
|
||||
|
||||
export interface MetadataAndTokenURI {
|
||||
metaDataState: number
|
@ -6,3 +6,9 @@ export * from './DDO/Metadata'
|
||||
export * from './FileMetadata'
|
||||
export * from './Compute'
|
||||
export * from './Provider'
|
||||
export * from './FixedPrice'
|
||||
export * from './Pool'
|
||||
export * from './Erc20'
|
||||
export * from './Erc721'
|
||||
export * from './Dispenser'
|
||||
export * from './Router'
|
||||
|
@ -13,14 +13,14 @@ import {
|
||||
configHelperNetworks,
|
||||
setContractDefaults
|
||||
} from '../utils'
|
||||
import { Config } from '../models/index.js'
|
||||
import {
|
||||
ProviderFees,
|
||||
FreCreationParams,
|
||||
Erc20CreateParams,
|
||||
PoolCreationParams,
|
||||
DispenserCreationParams
|
||||
} from '../interfaces'
|
||||
import { Config } from '../models/index.js'
|
||||
import { ProviderFees } from '../@types/index.js'
|
||||
} from '../@types/index.js'
|
||||
|
||||
interface Template {
|
||||
templateAddress: string
|
||||
|
@ -5,4 +5,3 @@ export * from './models'
|
||||
export * from './utils'
|
||||
export * from './@types'
|
||||
export * from './provider'
|
||||
export * from './interfaces'
|
||||
|
@ -1,5 +0,0 @@
|
||||
export * from './FixedRateInterface'
|
||||
export * from './PoolInterface'
|
||||
export * from './Erc20Interface'
|
||||
export * from './DispenserInterface'
|
||||
export * from './RouterInterface'
|
@ -4,7 +4,7 @@ import { TransactionReceipt } from 'web3-core'
|
||||
import { AbiItem } from 'web3-utils'
|
||||
import defaultRouter from '@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json'
|
||||
import { getFairGasPrice, setContractDefaults, configHelperNetworks } from '../utils'
|
||||
import { Operation } from '../interfaces/RouterInterface'
|
||||
import { Operation } from '../@types/Router'
|
||||
import { Config } from '../models/index.js'
|
||||
|
||||
/**
|
||||
|
@ -3,25 +3,23 @@ import { AbiItem } from 'web3-utils/types'
|
||||
import { TransactionReceipt } from 'web3-core'
|
||||
import { Contract } from 'web3-eth-contract'
|
||||
import {
|
||||
Logger,
|
||||
getFairGasPrice,
|
||||
configHelperNetworks,
|
||||
setContractDefaults,
|
||||
unitsToAmount,
|
||||
amountToUnits
|
||||
amountToUnits,
|
||||
LoggerInstance
|
||||
} from '../../utils'
|
||||
import BigNumber from 'bignumber.js'
|
||||
import PoolTemplate from '@oceanprotocol/contracts/artifacts/contracts/pools/balancer/BPool.sol/BPool.json'
|
||||
import defaultErc20Abi from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json'
|
||||
|
||||
import {
|
||||
CurrentFees,
|
||||
TokenInOutMarket,
|
||||
AmountsInMaxFee,
|
||||
AmountsOutMaxFee
|
||||
} from '../../interfaces'
|
||||
} from '../../@types'
|
||||
import { Config } from '../../models'
|
||||
import { minAbi } from '../../utils/minAbi'
|
||||
const MaxUint256 =
|
||||
'115792089237316195423570985008687907853269984665640564039457584007913129639934'
|
||||
|
||||
@ -32,19 +30,12 @@ export class Pool {
|
||||
public poolAbi: AbiItem | AbiItem[]
|
||||
public web3: Web3
|
||||
public GASLIMIT_DEFAULT = 1000000
|
||||
private logger: Logger
|
||||
private config: Config
|
||||
|
||||
constructor(
|
||||
web3: Web3,
|
||||
logger: Logger,
|
||||
poolAbi: AbiItem | AbiItem[] = null,
|
||||
config?: Config
|
||||
) {
|
||||
constructor(web3: Web3, poolAbi: AbiItem | AbiItem[] = null, config?: Config) {
|
||||
if (poolAbi) this.poolAbi = poolAbi
|
||||
else this.poolAbi = PoolTemplate.abi as AbiItem[]
|
||||
this.web3 = web3
|
||||
this.logger = logger
|
||||
this.config = config || configHelperNetworks[0]
|
||||
}
|
||||
|
||||
@ -64,7 +55,7 @@ export class Pool {
|
||||
const balance = await token.methods.balanceOf(account).call()
|
||||
result = this.web3.utils.fromWei(balance)
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to get shares of pool : ${e.message}`)
|
||||
LoggerInstance.error(`ERROR: Failed to get shares of pool : ${e.message}`)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@ -131,7 +122,7 @@ export class Pool {
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to set pool swap fee: ${e.message}`)
|
||||
LoggerInstance.error(`ERROR: Failed to set pool swap fee: ${e.message}`)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@ -150,7 +141,7 @@ export class Pool {
|
||||
try {
|
||||
result = await pool.methods.getNumTokens().call()
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to get number of tokens: ${e.message}`)
|
||||
LoggerInstance.error(`ERROR: Failed to get number of tokens: ${e.message}`)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@ -170,7 +161,9 @@ export class Pool {
|
||||
const result = await pool.methods.totalSupply().call()
|
||||
amount = this.web3.utils.fromWei(result)
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to get total supply of pool shares: ${e.message}`)
|
||||
LoggerInstance.error(
|
||||
`ERROR: Failed to get total supply of pool shares: ${e.message}`
|
||||
)
|
||||
}
|
||||
return amount
|
||||
}
|
||||
@ -189,7 +182,9 @@ export class Pool {
|
||||
try {
|
||||
result = await pool.methods.getCurrentTokens().call()
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to get tokens composing this pool: ${e.message}`)
|
||||
LoggerInstance.error(
|
||||
`ERROR: Failed to get tokens composing this pool: ${e.message}`
|
||||
)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@ -208,7 +203,9 @@ export class Pool {
|
||||
try {
|
||||
result = await pool.methods.getFinalTokens().call()
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to get the final tokens composing this pool`)
|
||||
LoggerInstance.error(
|
||||
`ERROR: Failed to get the final tokens composing this pool ${e.message}`
|
||||
)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@ -227,7 +224,7 @@ export class Pool {
|
||||
try {
|
||||
result = await pool.methods.getController().call()
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to get pool controller address: ${e.message}`)
|
||||
LoggerInstance.error(`ERROR: Failed to get pool controller address: ${e.message}`)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@ -246,7 +243,7 @@ export class Pool {
|
||||
try {
|
||||
result = await pool.methods.getBaseTokenAddress().call()
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to get baseToken address: ${e.message}`)
|
||||
LoggerInstance.error(`ERROR: Failed to get baseToken address: ${e.message}`)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@ -265,7 +262,7 @@ export class Pool {
|
||||
try {
|
||||
result = await pool.methods.getDatatokenAddress().call()
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to get datatoken address: ${e.message}`)
|
||||
LoggerInstance.error(`ERROR: Failed to get datatoken address: ${e.message}`)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@ -284,7 +281,9 @@ export class Pool {
|
||||
try {
|
||||
result = await pool.methods._publishMarketCollector().call()
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to get marketFeeCollector address: ${e.message}`)
|
||||
LoggerInstance.error(
|
||||
`ERROR: Failed to get marketFeeCollector address: ${e.message}`
|
||||
)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@ -303,7 +302,7 @@ export class Pool {
|
||||
try {
|
||||
result = await pool.methods._opcCollector().call()
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to get OPF Collector address: ${e.message}`)
|
||||
LoggerInstance.error(`ERROR: Failed to get OPF Collector address: ${e.message}`)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@ -323,7 +322,7 @@ export class Pool {
|
||||
try {
|
||||
result = await pool.methods.isBound(token).call()
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to check whether a token \
|
||||
LoggerInstance.error(`ERROR: Failed to check whether a token \
|
||||
bounded to a pool. ${e.message}`)
|
||||
}
|
||||
return result
|
||||
@ -345,7 +344,7 @@ export class Pool {
|
||||
const result = await pool.methods.getBalance(token).call()
|
||||
amount = await unitsToAmount(this.web3, token, result)
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to get how many tokens \
|
||||
LoggerInstance.error(`ERROR: Failed to get how many tokens \
|
||||
are in the pool: ${e.message}`)
|
||||
}
|
||||
return amount.toString()
|
||||
@ -365,7 +364,9 @@ export class Pool {
|
||||
try {
|
||||
result = await pool.methods.isFinalized().call()
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to check whether pool is finalized: ${e.message}`)
|
||||
LoggerInstance.error(
|
||||
`ERROR: Failed to check whether pool is finalized: ${e.message}`
|
||||
)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@ -385,7 +386,7 @@ export class Pool {
|
||||
const result = await pool.methods.getSwapFee().call()
|
||||
fee = this.web3.utils.fromWei(result)
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to get pool fee: ${e.message}`)
|
||||
LoggerInstance.error(`ERROR: Failed to get pool fee: ${e.message}`)
|
||||
}
|
||||
return fee
|
||||
}
|
||||
@ -406,7 +407,9 @@ export class Pool {
|
||||
const result = await pool.methods.getNormalizedWeight(token).call()
|
||||
weight = this.web3.utils.fromWei(result)
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to get normalized weight of a token: ${e.message}`)
|
||||
LoggerInstance.error(
|
||||
`ERROR: Failed to get normalized weight of a token: ${e.message}`
|
||||
)
|
||||
}
|
||||
return weight
|
||||
}
|
||||
@ -427,7 +430,9 @@ export class Pool {
|
||||
const result = await pool.methods.getDenormalizedWeight(token).call()
|
||||
weight = this.web3.utils.fromWei(result)
|
||||
} catch (e) {
|
||||
this.logger.error('ERROR: Failed to get denormalized weight of a token in pool')
|
||||
LoggerInstance.error(
|
||||
`ERROR: Failed to get denormalized weight of a token in pool ${e.message}`
|
||||
)
|
||||
}
|
||||
return weight
|
||||
}
|
||||
@ -447,7 +452,9 @@ export class Pool {
|
||||
const result = await pool.methods.getTotalDenormalizedWeight().call()
|
||||
weight = this.web3.utils.fromWei(result)
|
||||
} catch (e) {
|
||||
this.logger.error('ERROR: Failed to get total denormalized weight in pool')
|
||||
LoggerInstance.error(
|
||||
`ERROR: Failed to get total denormalized weight in pool ${e.message}`
|
||||
)
|
||||
}
|
||||
return weight
|
||||
}
|
||||
@ -468,7 +475,7 @@ export class Pool {
|
||||
const result = await pool.methods.publishMarketFees(token).call()
|
||||
weight = await unitsToAmount(this.web3, token, result)
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to get market fees for a token: ${e.message}`)
|
||||
LoggerInstance.error(`ERROR: Failed to get market fees for a token: ${e.message}`)
|
||||
}
|
||||
return weight
|
||||
}
|
||||
@ -486,7 +493,9 @@ export class Pool {
|
||||
const currentMarketFees = await pool.methods.getCurrentOPCFees().call()
|
||||
return currentMarketFees
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to get community fees for a token: ${e.message}`)
|
||||
LoggerInstance.error(
|
||||
`ERROR: Failed to get community fees for a token: ${e.message}`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -503,7 +512,9 @@ export class Pool {
|
||||
const currentMarketFees = await pool.methods.getCurrentOPCFees().call()
|
||||
return currentMarketFees
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to get community fees for a token: ${e.message}`)
|
||||
LoggerInstance.error(
|
||||
`ERROR: Failed to get community fees for a token: ${e.message}`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -523,7 +534,9 @@ export class Pool {
|
||||
const result = await pool.methods.communityFees(token).call()
|
||||
weight = await unitsToAmount(this.web3, token, result)
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to get community fees for a token: ${e.message}`)
|
||||
LoggerInstance.error(
|
||||
`ERROR: Failed to get community fees for a token: ${e.message}`
|
||||
)
|
||||
}
|
||||
return weight
|
||||
}
|
||||
@ -580,7 +593,7 @@ export class Pool {
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to swap exact amount in : ${e.message}`)
|
||||
LoggerInstance.error(`ERROR: Failed to swap exact amount in : ${e.message}`)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@ -645,7 +658,7 @@ export class Pool {
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to swap exact amount in : ${e.message}`)
|
||||
LoggerInstance.error(`ERROR: Failed to swap exact amount in : ${e.message}`)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@ -716,7 +729,7 @@ export class Pool {
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to swap exact amount in : ${e.message}`)
|
||||
LoggerInstance.error(`ERROR: Failed to swap exact amount in : ${e.message}`)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@ -841,7 +854,7 @@ export class Pool {
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to swap exact amount in : ${e.message}`)
|
||||
LoggerInstance.error(`ERROR: Failed to swap exact amount in : ${e.message}`)
|
||||
}
|
||||
|
||||
return result
|
||||
@ -963,7 +976,7 @@ export class Pool {
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to swap exact amount out: ${e.message}`)
|
||||
LoggerInstance.error(`ERROR: Failed to swap exact amount out: ${e.message}`)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@ -1047,7 +1060,7 @@ export class Pool {
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to join pool: ${e.message}`)
|
||||
LoggerInstance.error(`ERROR: Failed to join pool: ${e.message}`)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@ -1129,7 +1142,7 @@ export class Pool {
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to exit pool: ${e.message}`)
|
||||
LoggerInstance.error(`ERROR: Failed to exit pool: ${e.message}`)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@ -1215,7 +1228,7 @@ export class Pool {
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to pay tokens in order to \
|
||||
LoggerInstance.error(`ERROR: Failed to pay tokens in order to \
|
||||
join the pool: ${e.message}`)
|
||||
}
|
||||
return result
|
||||
@ -1302,7 +1315,7 @@ export class Pool {
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
} catch (e) {
|
||||
this.logger.error('ERROR: Failed to join swap pool amount out')
|
||||
LoggerInstance.error(`ERROR: Failed to join swap pool amount out ${e.message}`)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@ -1392,7 +1405,7 @@ export class Pool {
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to pay pool shares into the pool: ${e.message}`)
|
||||
LoggerInstance.error(`ERROR: Failed to pay pool shares into the pool: ${e.message}`)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@ -1477,7 +1490,7 @@ export class Pool {
|
||||
gasPrice: await getFairGasPrice(this.web3, this.config)
|
||||
})
|
||||
} catch (e) {
|
||||
this.logger.error('ERROR: Failed to exitswapExternAmountOut')
|
||||
LoggerInstance.error(`ERROR: Failed to exitswapExternAmountOut ${e.message}`)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@ -1514,12 +1527,12 @@ export class Pool {
|
||||
try {
|
||||
decimalsTokenIn = await tokenInContract.methods.decimals().call()
|
||||
} catch (e) {
|
||||
this.logger.error('ERROR: FAILED TO CALL DECIMALS(), USING 18')
|
||||
LoggerInstance.error(`ERROR: FAILED TO CALL DECIMALS(), USING 18 ${e.message}`)
|
||||
}
|
||||
try {
|
||||
decimalsTokenOut = await tokenOutContract.methods.decimals().call()
|
||||
} catch (e) {
|
||||
this.logger.error('ERROR: FAILED TO CALL DECIMALS(), USING 18')
|
||||
LoggerInstance.error(`ERROR: FAILED TO CALL DECIMALS(), USING 18 ${e.message}`)
|
||||
}
|
||||
|
||||
let price = null
|
||||
@ -1529,7 +1542,9 @@ export class Pool {
|
||||
.call()
|
||||
price = new BigNumber(price.toString())
|
||||
} catch (e) {
|
||||
this.logger.error('ERROR: Failed to get spot price of swapping tokenIn to tokenOut')
|
||||
LoggerInstance.error(
|
||||
'ERROR: Failed to get spot price of swapping tokenIn to tokenOut'
|
||||
)
|
||||
}
|
||||
|
||||
let decimalsDiff
|
||||
@ -1573,7 +1588,7 @@ export class Pool {
|
||||
.call()
|
||||
amount = await unitsToAmount(this.web3, tokenIn, result)
|
||||
} catch (e) {
|
||||
this.logger.error('ERROR: Failed to calcInGivenOut')
|
||||
LoggerInstance.error(`ERROR: Failed to calcInGivenOut ${e.message}`)
|
||||
}
|
||||
return amount
|
||||
}
|
||||
@ -1606,7 +1621,7 @@ export class Pool {
|
||||
|
||||
amount = await unitsToAmount(this.web3, tokenOut, result)
|
||||
} catch (e) {
|
||||
this.logger.error('ERROR: Failed to calcOutGivenIn')
|
||||
LoggerInstance.error(`ERROR: Failed to calcOutGivenIn ${e.message}`)
|
||||
}
|
||||
return amount
|
||||
}
|
||||
@ -1632,7 +1647,9 @@ export class Pool {
|
||||
|
||||
amount = await unitsToAmount(this.web3, poolAddress, result)
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to calculate PoolOutGivenSingleIn : ${e.message}`)
|
||||
LoggerInstance.error(
|
||||
`ERROR: Failed to calculate PoolOutGivenSingleIn : ${e.message}`
|
||||
)
|
||||
}
|
||||
return amount
|
||||
}
|
||||
@ -1656,7 +1673,9 @@ export class Pool {
|
||||
|
||||
amount = await unitsToAmount(this.web3, tokenIn, result)
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to calculate SingleInGivenPoolOut : ${e.message}`)
|
||||
LoggerInstance.error(
|
||||
`ERROR: Failed to calculate SingleInGivenPoolOut : ${e.message}`
|
||||
)
|
||||
}
|
||||
return amount
|
||||
}
|
||||
@ -1681,7 +1700,7 @@ export class Pool {
|
||||
.call()
|
||||
amount = await unitsToAmount(this.web3, tokenOut, result)
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to calculate SingleOutGivenPoolIn : ${e}`)
|
||||
LoggerInstance.error(`ERROR: Failed to calculate SingleOutGivenPoolIn : ${e}`)
|
||||
}
|
||||
return amount
|
||||
}
|
||||
@ -1707,7 +1726,9 @@ export class Pool {
|
||||
|
||||
amount = await unitsToAmount(this.web3, poolAddress, result)
|
||||
} catch (e) {
|
||||
this.logger.error(`ERROR: Failed to calculate PoolInGivenSingleOut : ${e.message}`)
|
||||
LoggerInstance.error(
|
||||
`ERROR: Failed to calculate PoolInGivenSingleOut : ${e.message}`
|
||||
)
|
||||
}
|
||||
return amount
|
||||
}
|
||||
|
@ -11,10 +11,10 @@ import {
|
||||
setContractDefaults,
|
||||
configHelperNetworks
|
||||
} from '../utils'
|
||||
import { FreOrderParams, FreCreationParams } from '../interfaces'
|
||||
import { FreOrderParams, FreCreationParams, ProviderFees } from '../@types'
|
||||
import { Nft } from './NFT'
|
||||
import { Config } from '../models/index.js'
|
||||
import { ProviderFees } from '../@types/Provider.js'
|
||||
|
||||
/**
|
||||
* ERC20 ROLES
|
||||
*/
|
||||
|
@ -12,7 +12,7 @@ import {
|
||||
import { Contract } from 'web3-eth-contract'
|
||||
import { MetadataProof } from '../../src/@types'
|
||||
import { Config } from '../models/index.js'
|
||||
import { MetadataAndTokenURI } from '../interfaces/Erc721Interface'
|
||||
import { MetadataAndTokenURI } from '../@types'
|
||||
|
||||
/**
|
||||
* ERC721 ROLES
|
||||
|
@ -2,10 +2,10 @@ import Web3 from 'web3'
|
||||
import BigNumber from 'bignumber.js'
|
||||
import { Contract } from 'web3-eth-contract'
|
||||
import { generateDtName } from './DatatokenName'
|
||||
import { Erc20CreateParams, FreCreationParams, PoolCreationParams } from '../interfaces'
|
||||
import { Erc20CreateParams, FreCreationParams, PoolCreationParams } from '../@types'
|
||||
import { Config } from '../models'
|
||||
import { AbiItem } from 'web3-utils/types'
|
||||
import { minAbi } from './minAbi'
|
||||
import LoggerInstance from './Logger'
|
||||
|
||||
export function setContractDefaults(contract: Contract, config: Config): Contract {
|
||||
if (config) {
|
||||
@ -107,7 +107,7 @@ export async function unitsToAmount(
|
||||
BigNumber.config({ EXPONENTIAL_AT: 50 })
|
||||
return amountFormatted.toString()
|
||||
} catch (e) {
|
||||
this.logger.error('ERROR: FAILED TO CALL DECIMALS(), USING 18')
|
||||
LoggerInstance.error(`ERROR: FAILED TO CALL DECIMALS(), USING 18' : ${e.message}`)
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,6 +126,6 @@ export async function amountToUnits(
|
||||
BigNumber.config({ EXPONENTIAL_AT: 50 })
|
||||
return amountFormatted.toString()
|
||||
} catch (e) {
|
||||
this.logger.error('ERROR: FAILED TO CALL DECIMALS(), USING 18')
|
||||
LoggerInstance.error(`ERROR: FAILED TO CALL DECIMALS(), USING 18', ${e.message}`)
|
||||
}
|
||||
}
|
||||
|
@ -4,15 +4,13 @@ import Aquarius from '../../src/aquarius/Aquarius'
|
||||
import { assert } from 'chai'
|
||||
import { NftFactory, NftCreateData } from '../../src/factories/index'
|
||||
import { Datatoken } from '../../src/tokens/Datatoken'
|
||||
import { Erc20CreateParams } from '../../src/interfaces'
|
||||
import { getHash } from '../../src/utils'
|
||||
import { Nft } from '../../src/tokens/NFT'
|
||||
import Web3 from 'web3'
|
||||
import { SHA256 } from 'crypto-js'
|
||||
import { homedir } from 'os'
|
||||
import fs from 'fs'
|
||||
import console from 'console'
|
||||
import { ProviderFees } from '../../src/@types'
|
||||
import { ProviderFees, Erc20CreateParams } from '../../src/@types'
|
||||
|
||||
const data = JSON.parse(
|
||||
fs.readFileSync(
|
||||
|
@ -3,12 +3,6 @@ import ProviderInstance from '../../src/provider/Provider'
|
||||
import Aquarius from '../../src/aquarius/Aquarius'
|
||||
import { assert } from 'chai'
|
||||
import { NftFactory, NftCreateData } from '../../src/factories/index'
|
||||
import {
|
||||
Erc20CreateParams,
|
||||
PoolCreationParams,
|
||||
FreCreationParams,
|
||||
DispenserCreationParams
|
||||
} from '../../src/interfaces'
|
||||
import { getHash, ZERO_ADDRESS } from '../../src/utils'
|
||||
import { Nft } from '../../src/tokens/NFT'
|
||||
import Web3 from 'web3'
|
||||
@ -16,7 +10,14 @@ import { SHA256 } from 'crypto-js'
|
||||
import { homedir } from 'os'
|
||||
import fs from 'fs'
|
||||
import { AbiItem } from 'web3-utils'
|
||||
import { ValidateMetadata, DDO } from '../../src/@types'
|
||||
import {
|
||||
ValidateMetadata,
|
||||
DDO,
|
||||
Erc20CreateParams,
|
||||
PoolCreationParams,
|
||||
FreCreationParams,
|
||||
DispenserCreationParams
|
||||
} from '../../src/@types'
|
||||
|
||||
const data = JSON.parse(
|
||||
fs.readFileSync(
|
||||
|
@ -3,7 +3,6 @@ import Aquarius from '../../src/aquarius/Aquarius'
|
||||
import { assert } from 'chai'
|
||||
import { NftFactory, NftCreateData } from '../../src/factories/index'
|
||||
import { Datatoken } from '../../src/tokens/Datatoken'
|
||||
import { Erc20CreateParams } from '../../src/interfaces'
|
||||
import { getHash } from '../../src/utils'
|
||||
import { Nft } from '../../src/tokens/NFT'
|
||||
import Web3 from 'web3'
|
||||
@ -11,7 +10,7 @@ import { SHA256 } from 'crypto-js'
|
||||
import { homedir } from 'os'
|
||||
import fs from 'fs'
|
||||
import { downloadFile } from '../../src/utils/FetchHelper'
|
||||
import { ProviderFees } from '../../src/@types/Provider'
|
||||
import { ProviderFees, Erc20CreateParams } from '../../src/@types'
|
||||
|
||||
const data = JSON.parse(
|
||||
fs.readFileSync(
|
||||
|
@ -12,13 +12,13 @@ import FixedRate from '@oceanprotocol/contracts/artifacts/contracts/pools/fixedR
|
||||
import OPFCommunityFeeCollector from '@oceanprotocol/contracts/artifacts/contracts/communityFee/OPFCommunityFeeCollector.sol/OPFCommunityFeeCollector.json'
|
||||
import PoolTemplate from '@oceanprotocol/contracts/artifacts/contracts/pools//balancer/BPool.sol/BPool.json'
|
||||
import { NftFactory, NftCreateData, TokenOrder } from '../../src/factories/NFTFactory'
|
||||
import { ZERO_ADDRESS, signHash } from '../../src/utils'
|
||||
import {
|
||||
ProviderFees,
|
||||
FreCreationParams,
|
||||
Erc20CreateParams,
|
||||
PoolCreationParams
|
||||
} from '../../src/interfaces'
|
||||
import { ZERO_ADDRESS, signHash } from '../../src/utils'
|
||||
import { ProviderFees } from '../../src/@types'
|
||||
} from '../../src/@types'
|
||||
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
|
@ -13,7 +13,7 @@ import OPFCommunityFeeCollector from '@oceanprotocol/contracts/artifacts/contrac
|
||||
import PoolTemplate from '@oceanprotocol/contracts/artifacts/contracts/pools/balancer/BPool.sol/BPool.json'
|
||||
import { NftFactory, NftCreateData } from '../../../src/factories/NFTFactory'
|
||||
import { Router } from '../../../src/pools/Router'
|
||||
import { Erc20CreateParams, PoolCreationParams, Operation } from '../../../src/interfaces'
|
||||
import { Erc20CreateParams, PoolCreationParams, Operation } from '../../../src/@types'
|
||||
|
||||
const { keccak256 } = require('@ethersproject/keccak256')
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
@ -22,7 +22,7 @@ import {
|
||||
TokenInOutMarket,
|
||||
AmountsInMaxFee,
|
||||
AmountsOutMaxFee
|
||||
} from '../../../../src/interfaces'
|
||||
} from '../../../../src/@types'
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
describe('Pool unit test', () => {
|
||||
@ -74,7 +74,7 @@ describe('Pool unit test', () => {
|
||||
await contracts.deployContracts(factoryOwner, FactoryRouter.abi as AbiItem[])
|
||||
|
||||
// initialize Pool instance
|
||||
pool = new Pool(web3, LoggerInstance, PoolTemplate.abi as AbiItem[])
|
||||
pool = new Pool(web3, PoolTemplate.abi as AbiItem[])
|
||||
assert(pool != null)
|
||||
|
||||
daiContract = new web3.eth.Contract(
|
||||
|
@ -14,7 +14,7 @@ import { NftFactory, NftCreateData } from '../../../../src/factories/'
|
||||
import { Datatoken, DispenserParams } from '../../../../src/tokens/'
|
||||
import { Dispenser } from '../../../../src/pools/dispenser/'
|
||||
import { TestContractHandler } from '../../../TestContractHandler'
|
||||
import { Erc20CreateParams } from '../../../../src/interfaces'
|
||||
import { Erc20CreateParams } from '../../../../src/@types'
|
||||
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
|
@ -15,7 +15,7 @@ import PoolTemplate from '@oceanprotocol/contracts/artifacts/contracts/pools/bal
|
||||
import OPFCollector from '@oceanprotocol/contracts/artifacts/contracts/communityFee/OPFCommunityFeeCollector.sol/OPFCommunityFeeCollector.json'
|
||||
import { NftFactory, NftCreateData } from '../../../../src/factories/NFTFactory'
|
||||
import { FixedRateExchange } from '../../../../src/pools/fixedRate/FixedRateExchange'
|
||||
import { FreCreationParams, Erc20CreateParams } from '../../../../src/interfaces'
|
||||
import { FreCreationParams, Erc20CreateParams } from '../../../../src/@types'
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
describe('Fixed Rate unit test', () => {
|
||||
|
@ -22,7 +22,7 @@ import {
|
||||
TokenInOutMarket,
|
||||
AmountsInMaxFee,
|
||||
AmountsOutMaxFee
|
||||
} from '../../../../src/interfaces'
|
||||
} from '../../../../src/@types'
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
describe('SideStaking unit test', () => {
|
||||
@ -78,7 +78,7 @@ describe('SideStaking unit test', () => {
|
||||
await contracts.deployContracts(factoryOwner, FactoryRouter.abi as AbiItem[])
|
||||
|
||||
// initialize Pool instance
|
||||
pool = new Pool(web3, LoggerInstance, PoolTemplate.abi as AbiItem[])
|
||||
pool = new Pool(web3, PoolTemplate.abi as AbiItem[])
|
||||
assert(pool != null)
|
||||
//
|
||||
sideStaking = new SideStaking(web3, SSContract.abi as AbiItem[])
|
||||
|
@ -15,9 +15,8 @@ import { TestContractHandler } from '../../TestContractHandler'
|
||||
import { NftFactory, NftCreateData } from '../../../src/factories/NFTFactory'
|
||||
import { Datatoken, Nft, OrderParams, DispenserParams } from '../../../src/tokens'
|
||||
import { AbiItem } from 'web3-utils'
|
||||
import { FreCreationParams, FreOrderParams } from '../../../src/interfaces'
|
||||
import { ZERO_ADDRESS, signHash } from '../../../src/utils'
|
||||
import { ProviderFees } from '../../../src/@types/Provider.js'
|
||||
import { ProviderFees, FreCreationParams, FreOrderParams } from '../../../src/@types/'
|
||||
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
|
@ -14,7 +14,7 @@ import { NftFactory, NftCreateData } from '../../../src/factories/NFTFactory'
|
||||
import { Nft } from '../../../src/tokens/NFT'
|
||||
import { AbiItem } from 'web3-utils'
|
||||
import sha256 from 'crypto-js/sha256'
|
||||
import { MetadataAndTokenURI } from '../../../src/interfaces/Erc721Interface'
|
||||
import { MetadataAndTokenURI } from '../../../src/@types/Erc721'
|
||||
|
||||
const web3 = new Web3('http://127.0.0.1:8545')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user