Skip to content

Commit

Permalink
Merge branch 'release'
Browse files Browse the repository at this point in the history
* release:
  Make sure token and intendedProjectId are stored when retrieving donation from Transfer event
  • Loading branch information
vojtechsimetka committed Nov 30, 2018
2 parents 1a8fbb2 + 7a0caae commit fe28485
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/blockchain/pledges.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,12 @@ const pledges = (app, liquidPledging) => {
return donationService.patch(donations[0]._id, mutation);
}

async function newDonation(pledgeId, amount, ts, txHash) {
async function newDonation(app, pledgeId, amount, ts, txHash) {
const pledge = await liquidPledging.getPledge(pledgeId);
const giver = await getPledgeAdmin(pledge.owner);

const token = app.get('tokenWhitelist').find(t => t.foreignAddress === pledge.token)

const mutation = {
giverAddress: giver.admin.address, // giver is a user type
amount,
Expand All @@ -286,6 +288,8 @@ const pledges = (app, liquidPledging) => {
status: DonationStatus.WAITING, // waiting for delegation by owner
mined: true,
createdAt: ts,
token: token,
intendedProjectId: pledge.intendedProject,
txHash,
};

Expand Down Expand Up @@ -474,7 +478,7 @@ const pledges = (app, liquidPledging) => {
const txHash = event.transactionHash;
const ts = await getBlockTimestamp(web3, event.blockNumber);
if (Number(from) === 0) {
const [err] = await toWrapper(newDonation(to, amount, ts, txHash));
const [err] = await toWrapper(newDonation(app, to, amount, ts, txHash));

if (err) {
logger.error('newDonation error ->', err);
Expand Down

0 comments on commit fe28485

Please sign in to comment.