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

fix metamask bug (#557)

* fix metamask bug

* more estimateGas updates
This commit is contained in:
Alex Coseru 2021-01-21 17:12:36 +02:00 committed by GitHub
parent 316c3f5010
commit 84e39d7222
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 23 deletions

View File

@ -83,7 +83,7 @@ export class Pool extends PoolFactory {
baseTokenWeight,
swapFee
)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: account }, (err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = gasLimitDefault
}
@ -175,7 +175,7 @@ export class Pool extends PoolFactory {
try {
estGas = await token.methods
.approve(spender, amount)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: account }, (err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = gasLimitDefault
}
@ -566,7 +566,7 @@ export class Pool extends PoolFactory {
this.web3.utils.toWei(minAmountOut),
maxPrice ? this.web3.utils.toWei(maxPrice) : MaxUint256
)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: account }, (err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
this.logger.log('Error estimate gas swapExactAmountIn')
this.logger.log(e)
@ -627,7 +627,7 @@ export class Pool extends PoolFactory {
this.web3.utils.toWei(minAmountOut),
maxPrice ? this.web3.utils.toWei(maxPrice) : MaxUint256
)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: account }, (err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = gasLimitDefault
this.logger.log('Error estimate gas swapExactAmountIn')
@ -684,7 +684,7 @@ export class Pool extends PoolFactory {
try {
estGas = await pool.methods
.joinPool(this.web3.utils.toWei(poolAmountOut), weiMaxAmountsIn)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: account }, (err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = gasLimitDefault
}
@ -731,7 +731,7 @@ export class Pool extends PoolFactory {
try {
estGas = await pool.methods
.exitPool(this.web3.utils.toWei(poolAmountIn), weiMinAmountsOut)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: account }, (err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = gasLimitDefault
}
@ -774,7 +774,7 @@ export class Pool extends PoolFactory {
this.web3.utils.toWei(tokenAmountIn),
this.web3.utils.toWei(minPoolAmountOut)
)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: account }, (err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = gasLimitDefault
}
@ -826,7 +826,7 @@ export class Pool extends PoolFactory {
this.web3.utils.toWei(poolAmountOut),
this.web3.utils.toWei(maxAmountIn)
)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: account }, (err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = gasLimitDefault
}
@ -877,7 +877,7 @@ export class Pool extends PoolFactory {
this.web3.utils.toWei(poolAmountIn),
this.web3.utils.toWei(minTokenAmountOut)
)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: account }, (err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = gasLimitDefault
}
@ -930,7 +930,7 @@ export class Pool extends PoolFactory {
this.web3.utils.toWei(tokenAmountOut),
this.web3.utils.toWei(maxPoolAmountIn)
)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: account }, (err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = gasLimitDefault
}

View File

@ -98,7 +98,7 @@ export class DataTokens {
try {
estGas = await factory.methods
.createToken(metadataCacheUri, name, symbol, this.web3.utils.toWei(cap))
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = gasLimitDefault
}
@ -143,7 +143,7 @@ export class DataTokens {
try {
estGas = await datatoken.methods
.approve(spender, this.web3.utils.toWei(amount))
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = gasLimitDefault
}
@ -181,7 +181,9 @@ export class DataTokens {
try {
estGas = await datatoken.methods
.mint(toAddress || address, this.web3.utils.toWei(amount))
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: address }, (err, estGas) =>
err ? gasLimitDefault : estGas
)
} catch (e) {
estGas = gasLimitDefault
}
@ -255,7 +257,7 @@ export class DataTokens {
try {
estGas = await datatoken.methods
.transfer(toAddress, amount)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = gasLimitDefault
}
@ -289,7 +291,7 @@ export class DataTokens {
try {
estGas = await datatoken.methods
.transferFrom(fromAddress, address, this.web3.utils.toWei(amount))
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = gasLimitDefault
}
@ -423,7 +425,9 @@ export class DataTokens {
String(serviceId),
mpFeeAddress
)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: address }, (err, estGas) =>
err ? gasLimitDefault : estGas
)
} catch (e) {
estGas = gasLimitDefault
}

View File

@ -96,7 +96,9 @@ export class OceanFixedRateExchange {
try {
estGas = await this.contract.methods
.create(this.oceanAddress, dataToken, this.web3.utils.toWei(rate))
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: address }, (err, estGas) =>
err ? gasLimitDefault : estGas
)
} catch (e) {
estGas = gasLimitDefault
}
@ -152,7 +154,7 @@ export class OceanFixedRateExchange {
try {
estGas = await this.contract.methods
.swap(exchangeId, this.web3.utils.toWei(String(dataTokenAmount)))
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = gasLimitDefault
}
@ -199,7 +201,7 @@ export class OceanFixedRateExchange {
try {
estGas = await this.contract.methods
.setRate(exchangeId, this.web3.utils.toWei(String(newRate)))
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = gasLimitDefault
}
@ -231,7 +233,7 @@ export class OceanFixedRateExchange {
try {
estGas = await this.contract.methods
.toggleExchangeState(exchangeId)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = gasLimitDefault
}
@ -261,7 +263,7 @@ export class OceanFixedRateExchange {
try {
estGas = await this.contract.methods
.toggleExchangeState(exchangeId)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: address }, (err, estGas) => (err ? gasLimitDefault : estGas))
} catch (e) {
estGas = gasLimitDefault
}

View File

@ -111,7 +111,9 @@ export class OnChainMetadata {
try {
estGas = await this.DDOContract.methods
.create(didZeroX(did), flags, data)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: consumerAccount }, (err, estGas) =>
err ? gasLimitDefault : estGas
)
} catch (e) {
estGas = gasLimitDefault
}
@ -153,7 +155,9 @@ export class OnChainMetadata {
try {
estGas = await this.DDOContract.methods
.update(didZeroX(did), flags, data)
.estimateGas((err, estGas) => (err ? gasLimitDefault : estGas))
.estimateGas({ from: consumerAccount }, (err, estGas) =>
err ? gasLimitDefault : estGas
)
} catch (e) {
estGas = gasLimitDefault
}