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

allow extended FRE (#875)

This commit is contained in:
Alex Coseru 2021-06-30 10:34:21 +03:00 committed by GitHub
parent 293813fbcb
commit 29855184ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -88,6 +88,24 @@ export class OceanFixedRateExchange {
rate: string,
address: string,
amount?: string
): SubscribablePromise<FixedRateCreateProgressStep, TransactionReceipt> {
return this.createExchange(this.oceanAddress, dataToken, rate, address, amount)
}
/**
* Creates new exchange pair between Ocean Token and data token.
* @param {String} dataToken Data Token Contract Address
* @param {Number} rate exchange rate
* @param {String} address User address
* @param {String} amount Optional, amount of datatokens to be approved for the exchange
* @return {Promise<TransactionReceipt>} TransactionReceipt
*/
public createExchange(
baseToken: string,
dataToken: string,
rate: string,
address: string,
amount?: string
): SubscribablePromise<FixedRateCreateProgressStep, TransactionReceipt> {
return new SubscribablePromise(async (observer) => {
observer.next(FixedRateCreateProgressStep.CreatingExchange)
@ -95,7 +113,7 @@ export class OceanFixedRateExchange {
const gasLimitDefault = this.GASLIMIT_DEFAULT
try {
estGas = await this.contract.methods
.create(this.oceanAddress, dataToken, this.web3.utils.toWei(rate))
.create(baseToken, dataToken, this.web3.utils.toWei(rate))
.estimateGas({ from: address }, (err, estGas) =>
err ? gasLimitDefault : estGas
)