mirror of
https://github.com/dap-ps/discover.git
synced 2025-02-07 06:54:49 +00:00
fix: estimate gas
This commit is contained in:
parent
e2c989dd32
commit
86d1f6cfb2
@ -259,8 +259,7 @@ class DiscoverService extends BlockchainService {
|
||||
|
||||
try {
|
||||
return broadcastContractFn(
|
||||
ConnectedDiscoverContract.methods.withdraw(id, tokenAmount.toString())
|
||||
.send,
|
||||
ConnectedDiscoverContract.methods.withdraw(id, tokenAmount.toString()),
|
||||
this.sharedContext.account,
|
||||
)
|
||||
} catch (error) {
|
||||
@ -281,8 +280,7 @@ class DiscoverService extends BlockchainService {
|
||||
|
||||
try {
|
||||
const tx = await broadcastContractFn(
|
||||
ConnectedDiscoverContract.methods.setMetadata(id, uploadedMetadata)
|
||||
.send,
|
||||
ConnectedDiscoverContract.methods.setMetadata(id, uploadedMetadata),
|
||||
this.sharedContext.account,
|
||||
)
|
||||
|
||||
|
@ -1,11 +1,15 @@
|
||||
export const broadcastContractFn = (contractMethod, account) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
contractMethod({ from: account })
|
||||
.on('transactionHash', hash => {
|
||||
resolve(hash)
|
||||
})
|
||||
.on('error', error => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
return contractMethod
|
||||
.estimateGas({ from: account })
|
||||
.then(estimatedGas => {
|
||||
contractMethod
|
||||
.send({ from: account, gas: estimatedGas + 1000 })
|
||||
.on('transactionHash', hash => {
|
||||
resolve(hash)
|
||||
})
|
||||
.on('error', error => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
.catch(error => reject)
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ class SNTService extends BlockchainService {
|
||||
spender,
|
||||
amount.toString(),
|
||||
callData,
|
||||
).send,
|
||||
),
|
||||
this.sharedContext.account,
|
||||
)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user