Skip to content

Commit

Permalink
Merge pull request #330 from JoinColony/fix/4074-stakes-created-at
Browse files Browse the repository at this point in the history
fix: use blockchain time for 'createdAt' field for stakes
  • Loading branch information
Nortsova authored Feb 6, 2025
2 parents 844f5a3 + de36c36 commit 0b9580e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/handlers/expenditures/expenditureMadeViaStake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ import { EventHandler } from '~types';
import { getExpenditureDatabaseId, output, toNumber, verbose } from '~utils';
import { getUserStakeDatabaseId } from '~utils/stakes';
import { getExpenditureFromDB } from './helpers';
import { getBlockChainTimestampISODate } from '../../utils/dates';

export const handleExpenditureMadeViaStake: EventHandler = async (
event,
listener,
) => {
const { transactionHash, contractAddress } = event;
const { transactionHash, contractAddress, timestamp } = event;
const { expenditureId, stake, creator } = event.args;
const convertedExpenditureId = toNumber(expenditureId);
const { colonyAddress } = listener as ExtensionEventListener;
Expand All @@ -45,6 +46,8 @@ export const handleExpenditureMadeViaStake: EventHandler = async (

const stakeDatabaseId = getUserStakeDatabaseId(creator, transactionHash);

const currentBlockChainTime = getBlockChainTimestampISODate(timestamp);

await mutate<UpdateExpenditureMutation, UpdateExpenditureMutationVariables>(
UpdateExpenditureDocument,
{
Expand All @@ -68,6 +71,7 @@ export const handleExpenditureMadeViaStake: EventHandler = async (
colonyAddress,
isClaimed: false,
type: UserStakeType.StakedExpenditure,
createdAt: currentBlockChainTime,
},
},
);
Expand Down

0 comments on commit 0b9580e

Please sign in to comment.