Skip to content

feat(idea/vara-eth/backend): prepare for indexing injected transactions#2478

Open
osipov-mit wants to merge 11 commits into
mainfrom
do-prepare-for-injected-tx-indexing
Open

feat(idea/vara-eth/backend): prepare for indexing injected transactions#2478
osipov-mit wants to merge 11 commits into
mainfrom
do-prepare-for-injected-tx-indexing

Conversation

@osipov-mit
Copy link
Copy Markdown
Member

No description provided.

@osipov-mit osipov-mit requested a review from vraja-nayaka May 12, 2026 10:19
@osipov-mit osipov-mit added the D6-vara-eth-idea Vara.Eth Idea label May 12, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the InjectedTransactionsModule and performs a significant refactor across the explorer and indexer to use bytea database columns (represented via PgByteaString) for hex data. Key changes include the addition of the InjectedTransaction entity, a new ParseByteaPipe for hex validation, and the standardization of response DTOs using class-transformer. Feedback identifies a critical need to lowercase hex strings in toBytea for consistent PostgreSQL comparisons and points out a type mismatch for the nullable valueToReceive field. Additionally, the removal of the order field from PaginationDto is flagged as a breaking API change, and it is recommended that the ParseByteaPipe include explicit hex validation to prevent database errors.

import { Transform } from 'class-transformer';

// TODO: consider moving these functions to a separate `common` package
export const toBytea = (hex: string): PgByteaString => `\\x${hex.replace(/^0x/i, '')}` as PgByteaString;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The toBytea function should convert the hex string to lowercase. The indexer stores these values as lowercased hex strings in the bytea columns. Since bytea comparisons in PostgreSQL are binary, a case mismatch (e.g., \xABC vs \xabc) will result in failed lookups.

Suggested change
export const toBytea = (hex: string): PgByteaString => `\\x${hex.replace(/^0x/i, '')}` as PgByteaString;
export const toBytea = (hex: string): PgByteaString => "\\x" + hex.replace(/^0x/i, '').toLowerCase() as PgByteaString;

program?: Program;

@Column({ type: 'bigint', name: 'value_to_receive', nullable: true })
valueToReceive: bigint;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The valueToReceive property is marked as nullable: true in the @column decorator, but the TypeScript type does not reflect this. It should be bigint | null to ensure type safety when handling null values from the database.

Suggested change
valueToReceive: bigint;
valueToReceive: bigint | null;

@IsOptional()
@IsIn(['asc', 'desc'])
order?: 'asc' | 'desc' = 'desc';
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The removal of the order field from PaginationDto is a breaking change for the API. It removes the ability for clients to specify a custom sort order (asc/desc), which was previously supported across multiple endpoints. If this was intentional, ensure that the API documentation is updated to reflect that sorting is now hardcoded to DESC.

Comment on lines +8 to +10
transform(value: string): PgByteaString {
return toBytea(value);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The ParseByteaPipe should validate that the input string is a valid hexadecimal string before calling toBytea. Passing an invalid hex string will result in a malformed bytea literal (e.g., \xZZZ), which will cause a database error and likely return a 500 Internal Server Error instead of a 400 Bad Request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

D6-vara-eth-idea Vara.Eth Idea

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant