Added gas estimation before send()
This commit is contained in:
parent
5ce9132830
commit
bdf4c373f8
|
@ -24,9 +24,13 @@ const CreateFunding = ({ refreshTable }) => (
|
|||
onSubmit={async (values, { setSubmitting, resetForm, setStatus }) => {
|
||||
const { funderId, receiverId, tokenAddress, amount } = values
|
||||
const account = await web3.eth.getCoinbase()
|
||||
const args = [funderId, receiverId, tokenAddress, web3.utils.toWei(amount, 'ether')]
|
||||
donate(...args)
|
||||
.send({ from: account })
|
||||
const args = [funderId, receiverId, tokenAddress, web3.utils.toWei(amount, 'ether')];
|
||||
|
||||
const toSend = donate(...args);
|
||||
|
||||
const estimateGas = await toSend.estimateGas();
|
||||
|
||||
toSend.send({ from: account, gas: estimateGas + 2000 })
|
||||
.then(res => {
|
||||
console.log({res})
|
||||
setStatus({
|
||||
|
|
|
@ -64,8 +64,12 @@ class Withdraw extends PureComponent {
|
|||
const { amount } = values
|
||||
const args = isPaying ? [rowData.id] : [rowData.id, toWei(amount)]
|
||||
const sendFn = isPaying ? confirmPayment : withdraw
|
||||
sendFn(...args)
|
||||
.send()
|
||||
|
||||
const toSend = sendFn(...args);
|
||||
|
||||
const estimateGas = await toSend.estimateGas();
|
||||
|
||||
toSend.send({gas: estimateGas + 1000})
|
||||
.then(res => {
|
||||
console.log({res})
|
||||
})
|
||||
|
|
|
@ -4,9 +4,18 @@ import StandardToken from 'Embark/contracts/StandardToken'
|
|||
import web3 from 'Embark/web3'
|
||||
|
||||
export const initVaultAndLP = async () => {
|
||||
const lpInit = await LiquidPledgingMock.methods.initialize(LPVault._address).send()
|
||||
let estimateGas;
|
||||
let toSend;
|
||||
|
||||
|
||||
toSend = LiquidPledgingMock.methods.initialize(LPVault._address);
|
||||
estimateGas = await toSend.estimateGas();
|
||||
const lpInit = await toSend.send({gas: estimateGas + 1000})
|
||||
console.log(lpInit)
|
||||
const vaultInit = await LPVault.methods.initialize(LiquidPledgingMock._address).send()
|
||||
|
||||
toSend = LPVault.methods.initialize(LiquidPledgingMock._address);
|
||||
estimateGas = await toSend.estimateGas();
|
||||
const vaultInit = await toSend.send({gas: estimateGas + 1000})
|
||||
console.log(vaultInit)
|
||||
}
|
||||
|
||||
|
|
|
@ -10,12 +10,12 @@ export const formatPledge = async (pledgePromise, idx) => {
|
|||
}
|
||||
|
||||
export const getAllPledges = async (start = 1) => {
|
||||
const numPledges = await numberOfPledges().call()
|
||||
const numPledges = await LiquidPledgingMock.methods.numberOfPledges().call()
|
||||
const pledges = []
|
||||
for (let i = start; i <= numPledges; i++) {
|
||||
pledges.push(getPledge(i).call())
|
||||
}
|
||||
return Promise.all(pledges.map(formatPledge))
|
||||
return Promise.all(pledges.map(formatPledge))
|
||||
}
|
||||
|
||||
export const appendToExistingPledges = async (pledges, setState) => {
|
||||
|
|
Loading…
Reference in New Issue