mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
updates
This commit is contained in:
parent
7cec2e585e
commit
fec3670e6a
@ -11,6 +11,8 @@ export interface FixedPricedExchange {
|
|||||||
supply: string
|
supply: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DEFAULT_GAS_LIMIT = 200000
|
||||||
|
|
||||||
export class OceanFixedRateExchange {
|
export class OceanFixedRateExchange {
|
||||||
/** Ocean related functions */
|
/** Ocean related functions */
|
||||||
public oceanAddress: string = null
|
public oceanAddress: string = null
|
||||||
@ -104,24 +106,14 @@ export class OceanFixedRateExchange {
|
|||||||
.swap(exchangeId, this.web3.utils.toWei(String(dataTokenAmount)))
|
.swap(exchangeId, this.web3.utils.toWei(String(dataTokenAmount)))
|
||||||
.estimateGas(function (err, g) {
|
.estimateGas(function (err, g) {
|
||||||
if (err) {
|
if (err) {
|
||||||
// console.log('FixedPriceExchange: ' + err)
|
return DEFAULT_GAS_LIMIT
|
||||||
return 200000
|
|
||||||
} else {
|
} else {
|
||||||
return g
|
return g
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// console.log('FixedPriceExchange: ' + e)
|
estGas = DEFAULT_GAS_LIMIT
|
||||||
estGas = 200000
|
|
||||||
}
|
}
|
||||||
// console.log('estGas: ' + estGas)
|
|
||||||
/* const estGas = await this.contract.methods
|
|
||||||
.swap(exchangeId, this.web3.utils.toWei(String(dataTokenAmount)))
|
|
||||||
.estimateGas(function (err, estGas) {
|
|
||||||
if (err) console.log('FixedPriceExchange: ' + err)
|
|
||||||
return estGas
|
|
||||||
})
|
|
||||||
*/
|
|
||||||
try {
|
try {
|
||||||
const trxReceipt = await this.contract.methods
|
const trxReceipt = await this.contract.methods
|
||||||
.swap(exchangeId, this.web3.utils.toWei(String(dataTokenAmount)))
|
.swap(exchangeId, this.web3.utils.toWei(String(dataTokenAmount)))
|
||||||
@ -166,12 +158,12 @@ export class OceanFixedRateExchange {
|
|||||||
.estimateGas(function (err, estGas) {
|
.estimateGas(function (err, estGas) {
|
||||||
if (err) {
|
if (err) {
|
||||||
// console.log('FixedPriceExchange: ' + err)
|
// console.log('FixedPriceExchange: ' + err)
|
||||||
return 200000
|
return DEFAULT_GAS_LIMIT
|
||||||
}
|
}
|
||||||
return estGas
|
return estGas
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
estGas = 200000
|
estGas = DEFAULT_GAS_LIMIT
|
||||||
}
|
}
|
||||||
const trxReceipt = await this.contract.methods
|
const trxReceipt = await this.contract.methods
|
||||||
.setRate(exchangeId, this.web3.utils.toWei(String(newRate)))
|
.setRate(exchangeId, this.web3.utils.toWei(String(newRate)))
|
||||||
@ -196,12 +188,12 @@ export class OceanFixedRateExchange {
|
|||||||
.estimateGas(function (err, estGas) {
|
.estimateGas(function (err, estGas) {
|
||||||
if (err) {
|
if (err) {
|
||||||
// console.log('FixedPriceExchange: ' + err)
|
// console.log('FixedPriceExchange: ' + err)
|
||||||
estGas = 200000
|
estGas = DEFAULT_GAS_LIMIT
|
||||||
}
|
}
|
||||||
return estGas
|
return estGas
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
estGas = 200000
|
estGas = DEFAULT_GAS_LIMIT
|
||||||
}
|
}
|
||||||
const trxReceipt = await this.contract.methods.activate(exchangeId).send({
|
const trxReceipt = await this.contract.methods.activate(exchangeId).send({
|
||||||
from: address,
|
from: address,
|
||||||
@ -224,12 +216,12 @@ export class OceanFixedRateExchange {
|
|||||||
.estimateGas(function (err, estGas) {
|
.estimateGas(function (err, estGas) {
|
||||||
if (err) {
|
if (err) {
|
||||||
// console.log('FixedPriceExchange: ' + err)
|
// console.log('FixedPriceExchange: ' + err)
|
||||||
estGas = 200000
|
estGas = DEFAULT_GAS_LIMIT
|
||||||
}
|
}
|
||||||
return estGas
|
return estGas
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
estGas = 200000
|
estGas = DEFAULT_GAS_LIMIT
|
||||||
}
|
}
|
||||||
const trxReceipt = await this.contract.methods.deactivate(exchangeId).send({
|
const trxReceipt = await this.contract.methods.deactivate(exchangeId).send({
|
||||||
from: address,
|
from: address,
|
||||||
@ -292,8 +284,7 @@ export class OceanFixedRateExchange {
|
|||||||
* @return {Promise<String[]>} Exchanges list
|
* @return {Promise<String[]>} Exchanges list
|
||||||
*/
|
*/
|
||||||
public async getExchanges(): Promise<string[]> {
|
public async getExchanges(): Promise<string[]> {
|
||||||
const result = await this.contract.methods.getExchanges().call()
|
return await this.contract.methods.getExchanges().call()
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
@ -13,7 +13,10 @@ import {
|
|||||||
} from '../Instantiable.abstract'
|
} from '../Instantiable.abstract'
|
||||||
import { Compute } from './Compute'
|
import { Compute } from './Compute'
|
||||||
import { OceanPool } from '../balancer/OceanPool'
|
import { OceanPool } from '../balancer/OceanPool'
|
||||||
import { OceanFixedRateExchange, FixedPricedExchange } from '../exchange/FixRateExchange'
|
import {
|
||||||
|
OceanFixedRateExchange,
|
||||||
|
FixedPricedExchange
|
||||||
|
} from '../exchange/FixedRateExchange'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main interface for Ocean Protocol.
|
* Main interface for Ocean Protocol.
|
||||||
|
@ -6,7 +6,7 @@ import { DataTokens } from '../../../src/datatokens/Datatokens'
|
|||||||
import {
|
import {
|
||||||
OceanFixedRateExchange,
|
OceanFixedRateExchange,
|
||||||
FixedPricedExchange
|
FixedPricedExchange
|
||||||
} from '../../../src/exchange/FixRateExchange'
|
} from '../../../src/exchange/FixedRateExchange'
|
||||||
|
|
||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
import factory from '@oceanprotocol/contracts/artifacts/DTFactory.json'
|
import factory from '@oceanprotocol/contracts/artifacts/DTFactory.json'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user