Skip to content

Commit

Permalink
Added a try catch to have a save donation insert in importing from ch…
Browse files Browse the repository at this point in the history
…aing
  • Loading branch information
aminlatifi committed Oct 31, 2024
1 parent 716556b commit 72325c1
Showing 1 changed file with 32 additions and 28 deletions.
60 changes: 32 additions & 28 deletions src/services/donationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -693,36 +693,40 @@ const ankrTransferHandler = async (transfer: TokenTransfer) => {
return;
}

// insert the donation
const donationId = await getDonationResolver().createDonation(
+transfer.value,
txHash,
QACC_NETWORK_ID,
QACC_DONATION_TOKEN_ADDRESS,
false,
QACC_DONATION_TOKEN_SYMBOL,
projectAddress?.projectId,
+transaction.nonce,
'', // transakId
{
req: { user: { userId: user.id }, auth: {} },
} as ApolloContext,
'',
'', // safeTransactionId
undefined, // draft donation id
undefined, // use donationBox
undefined, // relevant donation tx hash

new Date(transfer.timestamp * 1000),
);
try {
// insert the donation
const donationId = await getDonationResolver().createDonation(
+transfer.value,
txHash,
QACC_NETWORK_ID,
QACC_DONATION_TOKEN_ADDRESS,
false,
QACC_DONATION_TOKEN_SYMBOL,
projectAddress?.projectId,
+transaction.nonce,
'', // transakId
{
req: { user: { userId: user.id }, auth: {} },
} as ApolloContext,
'',
'', // safeTransactionId
undefined, // draft donation id
undefined, // use donationBox
undefined, // relevant donation tx hash

new Date(transfer.timestamp * 1000),
);

await Donation.update(Number(donationId), {
origin: DONATION_ORIGINS.CHAIN,
});
await Donation.update(Number(donationId), {
origin: DONATION_ORIGINS.CHAIN,
});

logger.debug(
`Donation with ID ${donationId} has been created by importing from ankr transfer ${txHash}`,
);
logger.debug(
`Donation with ID ${donationId} has been created by importing from ankr transfer ${txHash}`,
);
} catch (e) {
logger.error('ankrTransferHandler() error', e);
}
};

export async function syncDonationsWithAnkr() {
Expand Down

0 comments on commit 72325c1

Please sign in to comment.