Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'Something went wrong with your donation.',
`${etherscanUrl}tx/${txHash} => ${e}`,
);
});
return;
// const gas = 30400;
// const data = currentUser.giverId
// ? givethBridge.$contract.methods.donate(currentUser.giverId, adminId).encodeABI()
// : givethBridge.$contract.methods
// .donateAndCreateGiver(currentUser.address, adminId)
// .encodeABI();
const to = givethBridge.$address;
const query = `?to=${to}&value=${value}&gasLimit=25400&data=${data}&gasPrice=${utils.toWei(
gasPrice,
'gwei',
)}`;
this.setState({
modalVisible: true,
});
React.swal({
className: 'swal-huge',
title: "You're almost there...",
content: React.swal.msg(
<div>
<p>
It’s great to see that you want to donate, however we don't support donating
directly in the dapp yet. Use the followng information to donate via
{/* <a href="{`https://mycrypto.com/${query}#send-transaction`}"> */}</a></p></div>
const updateMilestone = (file) => {
const constructedModel = {
title: model.title,
description: model.description,
summary: getTruncatedText(this.state.summary, 100),
maxAmount: utils.toWei(model.maxAmount),
ownerAddress: this.props.currentUser.address,
reviewerAddress: model.reviewerAddress,
recipientAddress: model.recipientAddress,
completionDeadline: this.state.completionDeadline,
image: file,
campaignId: this.state.campaignId,
status: this.state.status // make sure not to change status!
};
if(this.props.isNew){
const createMilestone = () => {
feathersClient.service('milestones').create(Object.assign({}, constructedModel, {
txHash,
pluginAddress: '0x0000000000000000000000000000000000000000',
totalDonated: 0,
donationCount: 0,
milestone.ownerAddress,
utils.toWei(milestone.maxAmount.toFixed()),
milestone.token.foreignAddress,
5 * 24 * 60 * 60, // 5 days in seconds
{ from, $extraGas: extraGas() },
);
} else {
// default to creating a BridgedMilestone
tx = milestoneFactory.newBridgedMilestone(
milestone.title,
profileHash || '',
milestone.parentProjectId,
milestone.reviewerAddress,
milestone.recipientAddress,
milestone.ownerAddress,
milestone.isCapped ? utils.toWei(milestone.maxAmount.toFixed()) : 0,
milestone.token.foreignAddress,
5 * 24 * 60 * 60, // 5 days in seconds
{ from, $extraGas: extraGas() },
);
}
return tx;
}
milestone.ownerAddress,
milestone.isCapped ? utils.toWei(milestone.maxAmount.toFixed()) : 0,
milestone.token.foreignAddress,
5 * 24 * 60 * 60, // 5 days in seconds
{ from, $extraGas: extraGas() },
);
} else if (milestone instanceof LPPCappedMilestone) {
tx = lppCappedMilestoneFactory.newMilestone(
milestone.title,
profileHash || '',
milestone.parentProjectId,
milestone.reviewerAddress,
milestone.recipientAddress,
milestone.campaignReviewerAddress,
milestone.ownerAddress,
utils.toWei(milestone.maxAmount.toFixed()),
milestone.token.foreignAddress,
5 * 24 * 60 * 60, // 5 days in seconds
{ from, $extraGas: extraGas() },
);
} else {
// default to creating a BridgedMilestone
tx = milestoneFactory.newBridgedMilestone(
milestone.title,
profileHash || '',
milestone.parentProjectId,
milestone.reviewerAddress,
milestone.recipientAddress,
milestone.ownerAddress,
milestone.isCapped ? utils.toWei(milestone.maxAmount.toFixed()) : 0,
milestone.token.foreignAddress,
5 * 24 * 60 * 60, // 5 days in seconds
donateWithBridge(model) {
const { currentUser } = this.props;
const { adminId } = this.props.model;
const { gasPrice, account, givethBridge, etherscanUrl } = this.state;
const value = utils.toWei(model.amount);
const opts = { value, gas: DONATION_GAS, from: account };
let method;
if (currentUser) {
// TODO do we want to donate in the name of the rinkeby account automatically?
method =
currentUser.giverId > 0
? givethBridge.donate(currentUser.giverId, adminId, opts)
: givethBridge.donateAndCreateGiver(currentUser.address, adminId, opts);
} else {
method = givethBridge.donateAndCreateGiver(account, adminId, opts);
}
let txHash;
method
.on('transactionHash', async transactionHash => {
.then(resp => {
// let gasPrice = resp.safeLow * 1.1;
// hack: temp while network gas is so erratic
let gasPrice = resp.average;
gasPrice = gasPrice > resp.average ? resp.average : gasPrice;
// div by 10 b/c https://ethgasstation.info/json/ethgasAPI.json returns price in gwei * 10
// we're only interested in gwei.
// we round to prevent errors relating to too many decimals
gasPrice = Math.round(gasPrice) / 10;
// sometimes the API is down, we need to return a gasprice or the dapp breaks
if (!gasPrice) gasPrice = config.defaultGasPrice;
return utils.toWei(`${gasPrice}`, 'gwei');
});
export const ether = value => new utils.BN(utils.toWei(value, 'ether'));
{this.state.totalDonated < this.state.maxAmount && (
<p>Amount requested:{this.state.maxAmount} ETH</p>
)}
<p>
Campaign:
{campaign.title}{' '}
</p>
{this.isActiveMilestone() && (
)}
<div>
<div>
<div>
<div>
{(isOwner(ownerAddress, currentUser) ||
isOwner(campaign.ownerAddress, currentUser)) &&
['Proposed', 'Rejected', 'InProgress', 'NeedsReview'].includes(status) && (
<span></span></div></div></div></div>
.then(network => {
etherScanUrl = network.etherscan;
const _amountRemainingInWei = utils.toWei(donation.amountRemaining.toFixed());
return network.liquidPledging
.transfer(
donation.ownerId,
donation.pledgeId,
_amountRemainingInWei,
donation.intendedProjectId,
{
from: address,
$extraGas: extraGas(),
},
)
.once('transactionHash', hash => {
txHash = hash;
updateExistingDonation(donation, _amountRemainingInWei, Donation.COMMITTED);
function updateExistingDonation(donation, amount, status) {
const mutation = {
pendingAmountRemaining: utils.toWei(
new BigNumber(donation.amountRemaining).minus(new BigNumber(utils.fromWei(amount))).toFixed(),
),
};
if (status) {
mutation.status = status;
}
return feathersClient
.service('donations')
.patch(donation.id, mutation)
.catch(err => {
ErrorPopup('Unable to update the donation in feathers', err);
});
}