mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
increase default gas
This commit is contained in:
parent
526f3d97e0
commit
9280cf13af
@ -15,7 +15,7 @@ export interface FixedPricedExchange {
|
|||||||
supply: string
|
supply: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_GAS_LIMIT = 200000
|
const DEFAULT_GAS_LIMIT = 300000
|
||||||
|
|
||||||
export class OceanFixedRateExchange {
|
export class OceanFixedRateExchange {
|
||||||
/** Ocean related functions */
|
/** Ocean related functions */
|
||||||
@ -58,21 +58,29 @@ export class OceanFixedRateExchange {
|
|||||||
* @return {Promise<string>} exchangeId
|
* @return {Promise<string>} exchangeId
|
||||||
*/
|
*/
|
||||||
public async create(dataToken: string, rate: string, address: string): Promise<string> {
|
public async create(dataToken: string, rate: string, address: string): Promise<string> {
|
||||||
const estGas = await this.contract.methods
|
let estGas
|
||||||
.create(this.oceanAddress, dataToken, this.web3.utils.toWei(rate))
|
try {
|
||||||
.estimateGas(function (err, estGas) {
|
estGas = await this.contract.methods
|
||||||
if (err) console.log('FixedPriceExchange: ' + err)
|
.create(this.oceanAddress, dataToken, this.web3.utils.toWei(rate))
|
||||||
return estGas
|
.estimateGas(function (err, g) {
|
||||||
})
|
if (err) {
|
||||||
const trxReceipt = await this.contract.methods
|
return DEFAULT_GAS_LIMIT
|
||||||
.create(this.oceanAddress, dataToken, this.web3.utils.toWei(rate))
|
} else {
|
||||||
.send({
|
return g
|
||||||
from: address,
|
}
|
||||||
gas: estGas + 1
|
})
|
||||||
})
|
} catch (e) {
|
||||||
|
estGas = DEFAULT_GAS_LIMIT
|
||||||
|
}
|
||||||
|
|
||||||
let exchangeId = null
|
let exchangeId = null
|
||||||
try {
|
try {
|
||||||
|
const trxReceipt = await this.contract.methods
|
||||||
|
.create(this.oceanAddress, dataToken, this.web3.utils.toWei(rate))
|
||||||
|
.send({
|
||||||
|
from: address,
|
||||||
|
gas: estGas + 1
|
||||||
|
})
|
||||||
exchangeId = trxReceipt.events.ExchangeCreated.returnValues[0]
|
exchangeId = trxReceipt.events.ExchangeCreated.returnValues[0]
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user