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

Merge branch 'issue-1474-refactoring-move-functions-from-utils-to-classes' into issue-1474-refactoring-refactor-estimategas

This commit is contained in:
Miquel A. Cabot 2022-06-13 09:57:42 +02:00
commit e52c8a10e0
5 changed files with 16 additions and 12 deletions

View File

@ -34,7 +34,7 @@ export abstract class SmartContract {
this.abi = abi || (this.getDefaultAbi() as AbiItem[]) this.abi = abi || (this.getDefaultAbi() as AbiItem[])
} }
async amountToUnits( protected async amountToUnits(
token: string, token: string,
amount: string, amount: string,
tokenDecimals?: number tokenDecimals?: number
@ -42,7 +42,7 @@ export abstract class SmartContract {
return amountToUnits(this.web3, token, amount, tokenDecimals) return amountToUnits(this.web3, token, amount, tokenDecimals)
} }
async unitsToAmount( protected async unitsToAmount(
token: string, token: string,
amount: string, amount: string,
tokenDecimals?: number tokenDecimals?: number
@ -50,11 +50,15 @@ export abstract class SmartContract {
return unitsToAmount(this.web3, token, amount, tokenDecimals) return unitsToAmount(this.web3, token, amount, tokenDecimals)
} }
async getFairGasPrice(): Promise<string> { protected async getFairGasPrice(): Promise<string> {
return getFairGasPrice(this.web3, this.config) return getFairGasPrice(this.web3, this.config)
} }
getContract(address: string, account?: string, abi?: AbiItem | AbiItem[]): Contract { protected getContract(
address: string,
account?: string,
abi?: AbiItem | AbiItem[]
): Contract {
const contract = new this.web3.eth.Contract(abi || this.abi, address, { const contract = new this.web3.eth.Contract(abi || this.abi, address, {
from: account from: account
}) })

View File

@ -499,7 +499,7 @@ export class NftFactory extends SmartContractWithAddress {
poolParams: PoolCreationParams poolParams: PoolCreationParams
): Promise<TransactionReceipt> { ): Promise<TransactionReceipt> {
const ercCreateData = this.getErcCreationParams(ercParams) const ercCreateData = this.getErcCreationParams(ercParams)
const poolData = await this.getPoolCreationParams(this.web3, poolParams) const poolData = await this.getPoolCreationParams(poolParams)
const estGas = await calculateEstimatedGas( const estGas = await calculateEstimatedGas(
address, address,
@ -601,7 +601,7 @@ export class NftFactory extends SmartContractWithAddress {
return trxReceipt return trxReceipt
} }
getErcCreationParams(ercParams: DatatokenCreateParams): any { private getErcCreationParams(ercParams: DatatokenCreateParams): any {
let name: string, symbol: string let name: string, symbol: string
// Generate name & symbol if not present // Generate name & symbol if not present
if (!ercParams.name || !ercParams.symbol) { if (!ercParams.name || !ercParams.symbol) {
@ -621,7 +621,7 @@ export class NftFactory extends SmartContractWithAddress {
} }
} }
getFreCreationParams(freParams: FreCreationParams): any { private getFreCreationParams(freParams: FreCreationParams): any {
if (!freParams.allowedConsumer) freParams.allowedConsumer = ZERO_ADDRESS if (!freParams.allowedConsumer) freParams.allowedConsumer = ZERO_ADDRESS
const withMint = freParams.withMint ? 1 : 0 const withMint = freParams.withMint ? 1 : 0
@ -643,7 +643,7 @@ export class NftFactory extends SmartContractWithAddress {
} }
} }
async getPoolCreationParams(web3: Web3, poolParams: PoolCreationParams): Promise<any> { private async getPoolCreationParams(poolParams: PoolCreationParams): Promise<any> {
return { return {
addresses: [ addresses: [
poolParams.ssContract, poolParams.ssContract,

View File

@ -677,7 +677,7 @@ export class FixedRateExchange extends SmartContractWithAddress {
* Get Router address set in fixed rate contract * Get Router address set in fixed rate contract
* @return {String} * @return {String}
*/ */
async getRouter(): Promise<string> { public async getRouter(): Promise<string> {
let result = null let result = null
try { try {
result = await this.contract.methods.router().call() result = await this.contract.methods.router().call()

View File

@ -274,7 +274,7 @@ export class SideStaking extends SmartContract {
* @param {String} datatokenAddress datatokenAddress * @param {String} datatokenAddress datatokenAddress
* @return {TransactionReceipt} * @return {TransactionReceipt}
*/ */
async setPoolSwapFee( private async setPoolSwapFee(
account: string, account: string,
ssAddress: string, ssAddress: string,
datatokenAddress: string, datatokenAddress: string,
@ -311,7 +311,7 @@ export class SideStaking extends SmartContract {
* @param {String} ssAddress side staking contract address * @param {String} ssAddress side staking contract address
* @return {String} * @return {String}
*/ */
async getRouter(ssAddress: string): Promise<string> { public async getRouter(ssAddress: string): Promise<string> {
const sideStaking = this.getContract(ssAddress) const sideStaking = this.getContract(ssAddress)
let result = null let result = null
try { try {

View File

@ -847,7 +847,7 @@ export class Datatoken extends SmartContract {
return returnValues return returnValues
} }
getFreOrderParams(freParams: FreOrderParams): any { private getFreOrderParams(freParams: FreOrderParams): any {
return { return {
exchangeContract: freParams.exchangeContract, exchangeContract: freParams.exchangeContract,
exchangeId: freParams.exchangeId, exchangeId: freParams.exchangeId,