Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Bid.logIndex to schema, handlers, and tests #320

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,9 @@ type Bid @entity {
"The timestamp of the bid"
timestamp: BigInt!

"The log index of the event triggering bid update"
logIndex: BigInt!

updatedAt: BigInt!
}

Expand Down
2 changes: 2 additions & 0 deletions src/ram-lib-mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ export function handleBidCreated(event: BidCreated): void {
bid.isRemoved = false;
bid.slotIndex = event.params.slotIndex;
bid.timestamp = event.block.timestamp;
bid.logIndex = event.logIndex;
bid.updatedAt = event.block.timestamp;
bid.save();
}
Expand Down Expand Up @@ -395,6 +396,7 @@ export function handleBidToppedUp(event: BidToppedUp): void {
bid.slotIndex = event.params.newSlotIndex;
bid.value = bidValue;
bid.timestamp = event.block.timestamp;
bid.logIndex = event.logIndex;
bid.updatedAt = event.block.timestamp;
bid.save();
}
Expand Down
1 change: 1 addition & 0 deletions src/sea-lib-mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ function createBidFromValidEvent<T>(event: T): void {
bid.winningBid = true;
bid.isRemoved = false;
bid.timestamp = event.block.timestamp;
bid.logIndex = event.logIndex;
bid.updatedAt = event.block.timestamp;
bid.save();
}
1 change: 1 addition & 0 deletions tests/e2e/runner/__tests__/graphql/get-bids.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ fragment BidDetails on Bid {
value
winningBid
timestamp
logIndex
updatedAt
}

Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/runner/__tests__/minter-suite-v2/ram-lib.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ describe("RAMLib event handling", () => {
expect(bidRes.winningBid).toBe(false);
expect(bidRes.isRemoved).toBe(false);
expect(bidRes.timestamp).toBe(auctionBidTimestamp.toString());
expect(bidRes.logIndex).toBeDefined();
expect(bidRes.updatedAt).toBe(auctionBidTimestamp.toString());
expect(bidRes.project.id).toBe(`${genArt721CoreAddress.toLowerCase()}-0`);
expect(bidRes.minter.id).toBe(minterRAMV0Address.toLowerCase());
Expand Down Expand Up @@ -380,6 +381,7 @@ describe("RAMLib event handling", () => {
expect(toppedUpBidRes.value).toBe(slot12price.toString());
expect(toppedUpBidRes.updatedAt).toBe(auctionBid2Timestamp.toString());
expect(toppedUpBidRes.timestamp).toBe(auctionBid2Timestamp.toString());
expect(toppedUpBidRes.logIndex).toBeDefined();
});
});

Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/runner/__tests__/minter-suite-v2/sea-lib.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ describe("SEALib event handling", () => {
expect(bidRes.winningBid).toBe(true);
expect(bidRes.isRemoved).toBe(false);
expect(bidRes.timestamp).toBe(auctionBidTimestamp.toString());
expect(bidRes.logIndex).toBeDefined();
expect(bidRes.updatedAt).toBe(auctionBidTimestamp.toString());
expect(bidRes.project.id).toBe(`${genArt721CoreAddress.toLowerCase()}-1`);
expect(bidRes.minter.id).toBe(minterSEAV1Address.toLowerCase());
Expand Down Expand Up @@ -564,6 +565,7 @@ describe("SEALib event handling", () => {
expect(bidRes.timestamp).toBe(
auctionSettledBidCreatedTimestamp.toString()
);
expect(bidRes.logIndex).toBeDefined();
expect(bidRes.updatedAt).toBe(
auctionSettledBidCreatedTimestamp.toString()
);
Expand Down