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