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

more fixes

This commit is contained in:
alexcos20 2020-10-29 04:01:19 -07:00
parent 9900bb4353
commit 694cde2a13
3 changed files with 24 additions and 45 deletions

View File

@ -85,7 +85,7 @@ export class Pool extends PoolFactory {
)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = this.GASLIMIT_DEFAULT
estGas = gasLimitDefault
}
try {
result = await pool.methods
@ -158,7 +158,7 @@ export class Pool extends PoolFactory {
.approve(spender, amount)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = this.GASLIMIT_DEFAULT
estGas = gasLimitDefault
}
try {
@ -549,7 +549,7 @@ export class Pool extends PoolFactory {
)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = this.GASLIMIT_DEFAULT
estGas = gasLimitDefault
}
try {
result = await pool.methods
@ -608,7 +608,7 @@ export class Pool extends PoolFactory {
)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = this.GASLIMIT_DEFAULT
estGas = gasLimitDefault
}
try {
result = await pool.methods
@ -663,7 +663,7 @@ export class Pool extends PoolFactory {
.joinPool(this.web3.utils.toWei(poolAmountOut), weiMaxAmountsIn)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = this.GASLIMIT_DEFAULT
estGas = gasLimitDefault
}
try {
result = await pool.methods
@ -710,7 +710,7 @@ export class Pool extends PoolFactory {
.exitPool(this.web3.utils.toWei(poolAmountIn), weiMinAmountsOut)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = this.GASLIMIT_DEFAULT
estGas = gasLimitDefault
}
try {
result = await pool.methods
@ -753,7 +753,7 @@ export class Pool extends PoolFactory {
)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = this.GASLIMIT_DEFAULT
estGas = gasLimitDefault
}
try {
result = await pool.methods
@ -805,7 +805,7 @@ export class Pool extends PoolFactory {
)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = this.GASLIMIT_DEFAULT
estGas = gasLimitDefault
}
try {
result = await pool.methods
@ -856,7 +856,7 @@ export class Pool extends PoolFactory {
)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = this.GASLIMIT_DEFAULT
estGas = gasLimitDefault
}
try {
result = await pool.methods

View File

@ -99,7 +99,7 @@ export class DataTokens {
.createToken(metadataCacheUri, name, symbol, this.web3.utils.toWei(cap))
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = this.GASLIMIT_DEFAULT
estGas = gasLimitDefault
}
// Invoke createToken function of the contract
@ -144,7 +144,7 @@ export class DataTokens {
.approve(spender, this.web3.utils.toWei(amount))
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = this.GASLIMIT_DEFAULT
estGas = gasLimitDefault
}
const trxReceipt = await datatoken.methods
.approve(spender, this.web3.utils.toWei(amount))
@ -181,7 +181,7 @@ export class DataTokens {
.mint(destAddress, this.web3.utils.toWei(amount))
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = this.GASLIMIT_DEFAULT
estGas = gasLimitDefault
}
const trxReceipt = await datatoken.methods
.mint(destAddress, this.web3.utils.toWei(amount))
@ -253,7 +253,7 @@ export class DataTokens {
.transfer(toAddress, amount)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = this.GASLIMIT_DEFAULT
estGas = gasLimitDefault
}
const trxReceipt = await datatoken.methods.transfer(toAddress, amount).send({
from: address,
@ -287,7 +287,7 @@ export class DataTokens {
.transferFrom(fromAddress, address, this.web3.utils.toWei(amount))
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = this.GASLIMIT_DEFAULT
estGas = gasLimitDefault
}
const trxReceipt = await datatoken.methods
.transferFrom(fromAddress, address, this.web3.utils.toWei(amount))
@ -421,7 +421,7 @@ export class DataTokens {
)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = this.GASLIMIT_DEFAULT
estGas = gasLimitDefault
}
const trxReceipt = await datatoken.methods
.startOrder(

View File

@ -8,12 +8,13 @@ import { didZeroX, Logger, getFairGasPrice } from '../utils'
// Using limited, compress-only version
// See https://github.com/LZMA-JS/LZMA-JS#but-i-dont-want-to-use-web-workers
import { LZMA } from 'lzma/src/lzma-c'
const DEFAULT_GAS_LIMIT = 1000000
/**
* Provides an interface with Metadata Cache.
* Metadata Cache provides an off-chain database store for metadata about data assets.
*/
export class OnChainMetadataCache {
public GASLIMIT_DEFAULT = 1000000
public DDOContractAddress: string
public DDOContractABI: AbiItem | AbiItem[]
public web3: Web3
@ -105,38 +106,21 @@ export class OnChainMetadataCache {
this.logger.error('ERROR: Missing DDOContract')
return null
}
const gasLimitDefault = this.GASLIMIT_DEFAULT
let estGas
/*
try {
estGas = await this.DDOContract.methods
.create(didZeroX(did), flags, data)
.estimateGas(function (err, estGas) {
if (err) {
// console.error('ERROR: OnChainMetadataCacheEstimateGas: ' + err)
return DEFAULT_GAS_LIMIT
}
return estGas
})
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = DEFAULT_GAS_LIMIT
estGas = gasLimitDefault
}
try {
const trxReceipt = await this.DDOContract.methods
.create(didZeroX(did), flags, data)
.send({ from: consumerAccount, gas: estGas + 1 })
return trxReceipt
} catch (e) {
this.logger.error(`ERROR: Failed to publish raw DDO : ${e.message}`)
return null
}
*/
try {
const trxReceipt = await this.DDOContract.methods
.create(didZeroX(did), flags, data)
.send({
from: consumerAccount,
gas: DEFAULT_GAS_LIMIT,
gas: estGas + 1,
gasPrice: await getFairGasPrice(this.web3)
})
return trxReceipt
@ -164,19 +148,14 @@ export class OnChainMetadataCache {
this.logger.error('ERROR: Missing DDOContract')
return null
}
const gasLimitDefault = this.GASLIMIT_DEFAULT
let estGas
try {
estGas = await this.DDOContract.methods
.update(didZeroX(did), flags, data)
.estimateGas(function (err, estGas) {
if (err) {
// console.error('ERROR: OnChainMetadataCacheEstimateGas: ' + err)
return DEFAULT_GAS_LIMIT
}
return estGas
})
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = DEFAULT_GAS_LIMIT
estGas = gasLimitDefault
}
try {
const trxReceipt = await this.DDOContract.methods