Skip to content
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
14 changes: 8 additions & 6 deletions indexer/src/kadena-server/config/graphql-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1400,13 +1400,14 @@ export type TransactionSignature = {

export type TransactionSummary = {
__typename?: 'TransactionSummary';
badResult?: Maybe<Scalars['String']['output']>;
canonical: Scalars['Boolean']['output'];
chainId: Scalars['String']['output'];
creationTime: Scalars['String']['output'];
chainId: Scalars['BigInt']['output'];
creationTime: Scalars['DateTime']['output'];
gas: Scalars['String']['output'];
gasLimit: Scalars['String']['output'];
gasPrice: Scalars['String']['output'];
height: Scalars['String']['output'];
height: Scalars['BigInt']['output'];
requestKey: Scalars['String']['output'];
sender: Scalars['String']['output'];
};
Expand Down Expand Up @@ -3672,13 +3673,14 @@ export type TransactionSummaryResolvers<
ParentType extends
ResolversParentTypes['TransactionSummary'] = ResolversParentTypes['TransactionSummary'],
> = {
badResult?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
canonical?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType>;
chainId?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
creationTime?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
chainId?: Resolver<ResolversTypes['BigInt'], ParentType, ContextType>;
creationTime?: Resolver<ResolversTypes['DateTime'], ParentType, ContextType>;
gas?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
gasLimit?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
gasPrice?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
height?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
height?: Resolver<ResolversTypes['BigInt'], ParentType, ContextType>;
requestKey?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
sender?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
Expand Down
7 changes: 4 additions & 3 deletions indexer/src/kadena-server/config/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,11 @@ type QueryTransactionsByPactCodeConnectionEdge {

type TransactionSummary {
requestKey: String!
height: String!
chainId: String!
height: BigInt!
chainId: BigInt!
canonical: Boolean!
creationTime: String!
creationTime: DateTime!
badResult: String
sender: String!
gas: String!
gasLimit: String!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,16 @@ export type TransactionOutput = Omit<Transaction, 'cmd'> & {
};

export type TransactionByPactCodeOutput = {
creationTime: string;
requestKey: string;
chainId: string;
height: string;
height: any;
chainId: any;
canonical: boolean;
creationTime: Date;
badResult: any;
sender: string;
gas: string;
gasLimit: string;
gasPrice: string;
sender: string;
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { signerMetaValidator } from '../schema-validator/signer-schema-validator
import BlockDbRepository from './block-db-repository';
import TransactionQueryBuilder from '../query-builders/transaction-query-builder';
import { isNullOrUndefined } from '@/utils/helpers';
import { transactionSummaryValidator } from '@/kadena-server/repository/infra/schema-validator/transaction-summary-schema-validator';

/**
* Database-specific implementation of the TransactionRepository interface.
Expand Down Expand Up @@ -279,10 +280,9 @@ export default class TransactionDbRepository implements TransactionRepository {

const { rows } = await rootPgPool.query(query, queryParams);

// Create edges for paginated result and apply sorting
const edges = rows.slice(0, limit).map(tx => ({
cursor: `${tx.creationTime.toString()}:${tx.id.toString()}`,
node: tx,
node: transactionSummaryValidator.validate(tx),
}));

return getPageInfo({ edges, order, limit, after, before });
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { TransactionByPactCodeOutput } from '@/kadena-server/repository/application/transaction-repository';
import { z } from 'zod';

const schema = z.object({
requestKey: z.string(),
height: z.number(),
chainId: z.number(),
canonical: z.boolean(),
creationTime: z.string(),
result: z.any(),
sender: z.string(),
gas: z.string(),
gasLimit: z.string(),
gasPrice: z.string(),
});

function validate(row: any): TransactionByPactCodeOutput {
const res = schema.parse(row);
const isSuccess = row.result.status === 'success';
return {
requestKey: res.requestKey,
height: res.height,
chainId: res.chainId,
canonical: res.canonical,
creationTime: new Date(Number(res.creationTime) * 1000),
badResult: !isSuccess ? JSON.stringify(res.result.error) : null,
sender: res.sender,
gas: res.gas,
gasLimit: res.gasLimit,
gasPrice: res.gasPrice,
};
}

export const transactionSummaryValidator = { validate };
Loading