Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix metamask bug #557

Merged
merged 2 commits into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/balancer/Pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
16 changes: 10 additions & 6 deletions src/datatokens/Datatokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
12 changes: 7 additions & 5 deletions src/exchange/FixedRateExchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,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
}
Expand Down Expand Up @@ -150,7 +152,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
}
Expand Down Expand Up @@ -197,7 +199,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
}
Expand Down Expand Up @@ -229,7 +231,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
}
Expand Down Expand Up @@ -259,7 +261,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
}
Expand Down
8 changes: 6 additions & 2 deletions src/metadatacache/OnChainMetaData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down