Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/directus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,26 @@ export async function processNewContribution(
},
})
);
console.log({ response })

const contribution = {
sender: getAddress(sender),
hypercert_id: hypercertId.toLowerCase(),
amount: amount,
amount: Math.trunc(amount),
txid: txId,
date_created: new Date().toISOString(),
comment: comment,
} as Contribution;
console.log({ contribution })
// create a contribution record in Directus
await createContribution(contribution);
await createContribution(contribution)

// update the funded amount of the hypercert in server memory
await updateFundedAmount(hypercertId, amount);
// add the contribution to the cache
await updateContribution(hypercertId, contribution);
} catch (error) {

console.error(`[server] failed to process new contribution: ${error}`);
throw new Error(`[server] failed to process new contribution: ${error}`);
}
Expand All @@ -101,8 +104,7 @@ export async function createContribution(contribution: Contribution) {
try {
const response = await client.request(readItem("users", user.address));
console.log(
`[Directus] user ${user.address} exist: ${
response.address === user.address ? "true" : "false"
`[Directus] user ${user.address} exist: ${response.address === user.address ? "true" : "false"
}`
);
} catch (err) {
Expand Down Expand Up @@ -211,7 +213,7 @@ export const updateCMSReports = async (): Promise<CMSContent[]> => {
);
CMSReports = response as CMSContent[];
console.log("[Directus] fetched CMS contents: ", CMSReports.length);

return CMSReports;
} catch (error) {
console.error(`[Directus] Failed to fetch CMS contents: ${error}`);
Expand Down Expand Up @@ -466,7 +468,7 @@ export const getViemClient = (): PublicClient => {
if (viemClient) {
return viemClient;
}

viemClient = createPublicClient({
chain: optimism,
transport: http(process.env.JSON_RPC_ENDPOINT ? process.env.JSON_RPC_ENDPOINT : undefined),
Expand Down
Loading