diff --git a/src/balancer/Pool.ts b/src/balancer/Pool.ts index f604972e..8b7e193b 100644 --- a/src/balancer/Pool.ts +++ b/src/balancer/Pool.ts @@ -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 } diff --git a/src/datatokens/Datatokens.ts b/src/datatokens/Datatokens.ts index 9738c394..cb6fef07 100644 --- a/src/datatokens/Datatokens.ts +++ b/src/datatokens/Datatokens.ts @@ -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 } diff --git a/src/exchange/FixedRateExchange.ts b/src/exchange/FixedRateExchange.ts index 5a9225c2..30123c09 100644 --- a/src/exchange/FixedRateExchange.ts +++ b/src/exchange/FixedRateExchange.ts @@ -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 } diff --git a/src/metadatacache/OnChainMetaData.ts b/src/metadatacache/OnChainMetaData.ts index 61282de0..ceb3228c 100644 --- a/src/metadatacache/OnChainMetaData.ts +++ b/src/metadatacache/OnChainMetaData.ts @@ -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 }