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[])
}
async amountToUnits(
protected async amountToUnits(
token: string,
amount: string,
tokenDecimals?: number
@ -42,7 +42,7 @@ export abstract class SmartContract {
return amountToUnits(this.web3, token, amount, tokenDecimals)
}
async unitsToAmount(
protected async unitsToAmount(
token: string,
amount: string,
tokenDecimals?: number
@ -50,11 +50,15 @@ export abstract class SmartContract {
return unitsToAmount(this.web3, token, amount, tokenDecimals)
}
async getFairGasPrice(): Promise<string> {
protected async getFairGasPrice(): Promise<string> {
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, {
from: account
})

View File

@ -499,7 +499,7 @@ export class NftFactory extends SmartContractWithAddress {
poolParams: PoolCreationParams
): Promise<TransactionReceipt> {
const ercCreateData = this.getErcCreationParams(ercParams)
const poolData = await this.getPoolCreationParams(this.web3, poolParams)
const poolData = await this.getPoolCreationParams(poolParams)
const estGas = await calculateEstimatedGas(
address,
@ -601,7 +601,7 @@ export class NftFactory extends SmartContractWithAddress {
return trxReceipt
}
getErcCreationParams(ercParams: DatatokenCreateParams): any {
private getErcCreationParams(ercParams: DatatokenCreateParams): any {
let name: string, symbol: string
// Generate name & symbol if not present
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
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 {
addresses: [
poolParams.ssContract,

View File

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

View File

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

View File

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