Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const getPledges = () => {
const maxAmount = new BigNumber(utils.fromWei(amount));
let currentAmount = new BigNumber('0');
let fullyDonated = true;
donations.every(donation => {
const pledge = pledges.find(n => n.id === donation.pledgeId);
let delegatedAmount = donation.amountRemaining; // 0.1
// The next donation is too big, we have to split it
if (currentAmount.plus(delegatedAmount).isGreaterThan(maxAmount)) {
delegatedAmount = maxAmount.minus(currentAmount);
fullyDonated = false;
// This donation would have value of 0, stop the iteration before it is added
if (delegatedAmount.isEqualTo(new BigNumber('0'))) return fullyDonated;
}
{ delegations.map((d, index) =>
{moment(d.createdAt).format("MM/DD/YYYY")}
{d.delegate > 0 &&
DAC <em>{getTruncatedText(d.delegateEntity.title, 45)}</em>
}
{!d.delegate &&
{d.ownerType.toUpperCase()} <em>{d.ownerEntity.title}</em>
}
Ξ{utils.fromWei(d.amount)}
{getUserName(d.giver)}
{d.giverAddress}
{d.status}
{/* when donated to a dac, allow delegation to campaigns and milestones */}
{(d.delegate > 0 || d.ownerId === currentUser.address )&&
}
<div>
{model.type !== 'milestone' && (
this.setToken(address)}
disabled={model.type === 'milestone'}
/>
)}
{/* TODO: remove this b/c the wallet provider will contain this info */}
{config.homeNetworkName} {selectedToken.symbol} balance:
<em>{utils.fromWei(balance ? balance.toFixed() : '')}</em>
</div>
)}
<span>How much {selectedToken.symbol} do you want to donate?</span>
{validProvider &&
maxAmount.toNumber() > 0 &&
balance.gt(0) && (
<div>
</div>
getGasPrice().then(gasPrice =>
this.setState({
gasPrice: utils.fromWei(gasPrice, 'gwei'),
}),
);
render(){
const { totalDonated, donationCount, maxAmount, campaignsCount, milestonesCount, type, status } = this.props
return(
<div>
<div>
<span><i></i>{donationCount}</span>
<p>people</p>
</div>
<div>
{ maxAmount &&
<span>Ξ{totalDonated && utils.fromWei(totalDonated)} of Ξ {utils.fromWei(maxAmount)}</span>
}
{ !maxAmount &&
<span>Ξ {totalDonated && utils.fromWei(totalDonated)}</span>
}
<p>donated</p>
</div>
<div>
{type === 'dac' &&
<div>
<span><i></i>{campaignsCount}</span>
<p>campaign(s)</p>
</div>
}
</div></div>
selectedObject({ target }) {
const admin = this.props.types.find(t => t._id === target.value[0]);
let maxAmount = utils.fromWei(this.props.donation.amountRemaining);
if (admin && admin.type === Milestone.type) {
const diff = utils
.toBN(admin.maxAmount)
.sub(utils.toBN(admin.totalDonated || 0))
.toString();
if (utils.toBN(diff).lt(utils.toBN(this.props.donation.amountRemaining)))
maxAmount = utils.fromWei(diff);
}
this.setState({ maxAmount, amount: maxAmount, objectsToDelegateTo: target.value });
}
getBalance(unit) {
return this.balance ? utils.fromWei(this.balance, unit || 'ether') : undefined;
}
Transaction {transaction.hash}
<div>
</div>
<dl>
</dl>
);
getMaxAmount() {
const { selectedToken } = this.state;
const { NativeTokenBalance, model } = this.props;
const balance =
selectedToken.symbol === config.nativeTokenName ? NativeTokenBalance : selectedToken.balance;
if (model.maxDonation && balance.gt(model.maxDonation)) return model.maxDonation;
return new BigNumber(utils.fromWei(balance.toFixed()));
}