diff --git a/indexer/src/kadena-server/config/graphql-types.ts b/indexer/src/kadena-server/config/graphql-types.ts index 29956e80..2dc28c4f 100644 --- a/indexer/src/kadena-server/config/graphql-types.ts +++ b/indexer/src/kadena-server/config/graphql-types.ts @@ -1400,13 +1400,14 @@ export type TransactionSignature = { export type TransactionSummary = { __typename?: 'TransactionSummary'; + badResult?: Maybe; 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']; }; @@ -3672,13 +3673,14 @@ export type TransactionSummaryResolvers< ParentType extends ResolversParentTypes['TransactionSummary'] = ResolversParentTypes['TransactionSummary'], > = { + badResult?: Resolver, ParentType, ContextType>; canonical?: Resolver; - chainId?: Resolver; - creationTime?: Resolver; + chainId?: Resolver; + creationTime?: Resolver; gas?: Resolver; gasLimit?: Resolver; gasPrice?: Resolver; - height?: Resolver; + height?: Resolver; requestKey?: Resolver; sender?: Resolver; __isTypeOf?: IsTypeOfResolverFn; diff --git a/indexer/src/kadena-server/config/schema.graphql b/indexer/src/kadena-server/config/schema.graphql index 5353c125..403358af 100644 --- a/indexer/src/kadena-server/config/schema.graphql +++ b/indexer/src/kadena-server/config/schema.graphql @@ -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! diff --git a/indexer/src/kadena-server/repository/application/transaction-repository.ts b/indexer/src/kadena-server/repository/application/transaction-repository.ts index 0320a775..a49ebc99 100644 --- a/indexer/src/kadena-server/repository/application/transaction-repository.ts +++ b/indexer/src/kadena-server/repository/application/transaction-repository.ts @@ -112,15 +112,16 @@ export type TransactionOutput = Omit & { }; 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; }; /** diff --git a/indexer/src/kadena-server/repository/infra/repository/transaction-db-repository.ts b/indexer/src/kadena-server/repository/infra/repository/transaction-db-repository.ts index 1c6be118..fb2a8764 100644 --- a/indexer/src/kadena-server/repository/infra/repository/transaction-db-repository.ts +++ b/indexer/src/kadena-server/repository/infra/repository/transaction-db-repository.ts @@ -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. @@ -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 }); diff --git a/indexer/src/kadena-server/repository/infra/schema-validator/transaction-summary-schema-validator.ts b/indexer/src/kadena-server/repository/infra/schema-validator/transaction-summary-schema-validator.ts new file mode 100644 index 00000000..5f2926f7 --- /dev/null +++ b/indexer/src/kadena-server/repository/infra/schema-validator/transaction-summary-schema-validator.ts @@ -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 }; diff --git a/indexer/tests/integration/fixtures/transactions-by-pact-code/transactions-by-pact-code.fixture.001.ts b/indexer/tests/integration/fixtures/transactions-by-pact-code/transactions-by-pact-code.fixture.001.ts index fd3a95d5..c49d6af0 100644 --- a/indexer/tests/integration/fixtures/transactions-by-pact-code/transactions-by-pact-code.fixture.001.ts +++ b/indexer/tests/integration/fixtures/transactions-by-pact-code/transactions-by-pact-code.fixture.001.ts @@ -11,13 +11,14 @@ export const transactionsByPactCodeFixture001 = { { cursor: 'MTc1NTExMTcyNDozMTM5NDkyODI=', node: { + badResult: null, canonical: true, - chainId: '2', - creationTime: '1755111724', + chainId: 2, + creationTime: '2025-08-13T19:02:04.000Z', gas: '15529', gasLimit: '80300', gasPrice: '0.0000001', - height: '6087403', + height: 6087403, requestKey: 'NSsHVpnOi0c67Q0GzqJsrC_IW7m1xR2UHifq3Ki4Mj8', sender: 'k:1801d7f61f01e5f4dd61b851bf58d78dbb4e7e47822b5c3fe1cacf2085e6caef', }, @@ -25,13 +26,14 @@ export const transactionsByPactCodeFixture001 = { { cursor: 'MTc1NTEwNjY1NDozMTM5MzU2OTU=', node: { + badResult: null, canonical: true, - chainId: '2', - creationTime: '1755106654', + chainId: 2, + creationTime: '2025-08-13T17:37:34.000Z', gas: '49555', gasLimit: '80300', gasPrice: '0.0000001', - height: '6087235', + height: 6087235, requestKey: 'f2AxAh6jUJIVPidn_fgRzddi0MKHsM_IRiQmbglq0Fs', sender: 'k:22dab5d2f1e393e428eb7515879436662f7b4f7868767ddb1becc77b39e33d1b', }, @@ -39,13 +41,14 @@ export const transactionsByPactCodeFixture001 = { { cursor: 'MTc1NTEwNjU4OTozMTM5MzU1MDU=', node: { + badResult: null, canonical: true, - chainId: '2', - creationTime: '1755106589', + chainId: 2, + creationTime: '2025-08-13T17:36:29.000Z', gas: '14780', gasLimit: '80300', gasPrice: '0.0000001', - height: '6087231', + height: 6087231, requestKey: '30f3l3eJul_JacnaAcQxB6ppqnPlcPPEc_lzBne4eTk', sender: 'k:22dab5d2f1e393e428eb7515879436662f7b4f7868767ddb1becc77b39e33d1b', }, @@ -53,13 +56,14 @@ export const transactionsByPactCodeFixture001 = { { cursor: 'MTc1NTA2OTI2NTozMTM4NDAyOTA=', node: { + badResult: null, canonical: true, - chainId: '8', - creationTime: '1755069265', + chainId: 8, + creationTime: '2025-08-13T07:14:25.000Z', gas: '26097', gasLimit: '150000', gasPrice: '0.00000001', - height: '6085989', + height: 6085989, requestKey: 'kPdQSS2VwlABYDcWL96GRgxtLH6RX3aZsvR9byPG2rI', sender: 'k:4f40ed48b79aef0ceccbf4c649c8d3c142acecc85076a971e7b3b3d53286a67d', }, @@ -67,13 +71,14 @@ export const transactionsByPactCodeFixture001 = { { cursor: 'MTc1NTA1MTYyODozMTM3ODY3NTM=', node: { + badResult: null, canonical: true, - chainId: '0', - creationTime: '1755051628', + chainId: 0, + creationTime: '2025-08-13T02:20:28.000Z', gas: '399', gasLimit: '1000', gasPrice: '0.0000001', - height: '6085392', + height: 6085392, requestKey: 'ohL27SAJfuo-DnV6BVivKap7KIYh3HsNjhAfXQ3CywY', sender: 'k:622ffb74b3cfd91a45e3031a11f59f1ff93bfe14da87c1b33b6612530fa924c2', }, @@ -81,13 +86,14 @@ export const transactionsByPactCodeFixture001 = { { cursor: 'MTc1NTA0NDg0MjozMTM3NjE4MzA=', node: { + badResult: null, canonical: true, - chainId: '2', - creationTime: '1755044842', + chainId: 2, + creationTime: '2025-08-13T00:27:22.000Z', gas: '107271', gasLimit: '120000', gasPrice: '0.00000001', - height: '6085164', + height: 6085164, requestKey: 'B1PkDUZAHmnAo4Qz_0l4HYhxoF1aV5acZgShmhMPKuE', sender: 'k:35fe76ea8f40caa2bb660b3236132f339dfdac2586a3d2a9d63ea96ee91202ad', }, @@ -95,13 +101,14 @@ export const transactionsByPactCodeFixture001 = { { cursor: 'MTc1NTAzMDg5NjozMTM3MjUzNzY=', node: { + badResult: null, canonical: true, - chainId: '2', - creationTime: '1755030896', + chainId: 2, + creationTime: '2025-08-12T20:34:56.000Z', gas: '106981', gasLimit: '120000', gasPrice: '0.00000001', - height: '6084703', + height: 6084703, requestKey: '4VMDAjkppoI_wYhZboWDACoCvRvnb3W7aQZWr8aYyLM', sender: 'k:35fe76ea8f40caa2bb660b3236132f339dfdac2586a3d2a9d63ea96ee91202ad', }, @@ -109,13 +116,14 @@ export const transactionsByPactCodeFixture001 = { { cursor: 'MTc1NTAyOTA0NTozMTM3MjExMTY=', node: { + badResult: null, canonical: true, - chainId: '0', - creationTime: '1755029045', + chainId: 0, + creationTime: '2025-08-12T20:04:05.000Z', gas: '399', gasLimit: '1000', gasPrice: '0.0000001', - height: '6084649', + height: 6084649, requestKey: 'MBd1dydPzHm5BtrEi6qpebIGext5zdYWv3HbsP2heY4', sender: 'k:2cb99920f6b2af1e87d43ab32124c5df210d89110d127b7250f8508b8cbffd73', }, @@ -123,13 +131,14 @@ export const transactionsByPactCodeFixture001 = { { cursor: 'MTc1NTAyODIzNzozMTM3MTkwNDI=', node: { + badResult: null, canonical: true, - chainId: '2', - creationTime: '1755028237', + chainId: 2, + creationTime: '2025-08-12T19:50:37.000Z', gas: '106981', gasLimit: '120000', gasPrice: '0.00000001', - height: '6084622', + height: 6084622, requestKey: '32tEuE6o8kVbPX_ECaGlo5PPQmd8CpUgHOb0-OEkPUI', sender: 'k:35fe76ea8f40caa2bb660b3236132f339dfdac2586a3d2a9d63ea96ee91202ad', }, @@ -137,13 +146,14 @@ export const transactionsByPactCodeFixture001 = { { cursor: 'MTc1NTAwODI3MDozMTM2NjU5ODE=', node: { + badResult: null, canonical: true, - chainId: '8', - creationTime: '1755008270', + chainId: 8, + creationTime: '2025-08-12T14:17:50.000Z', gas: '550', gasLimit: '5000', gasPrice: '0.000001', - height: '6083959', + height: 6083959, requestKey: 'rnZa6aAIkabL5BbTLbRJ8s2f-ZrZimipGC7AYpTeNTw', sender: 'k:470ea61ff9130e156f3c3f4789ab2c43fb334ea89cbeb75fe5161ed2fd2b7cd1', }, @@ -151,13 +161,14 @@ export const transactionsByPactCodeFixture001 = { { cursor: 'MTc1NTAwODI1MjozMTM2NjU5NjA=', node: { + badResult: null, canonical: true, - chainId: '8', - creationTime: '1755008252', + chainId: 8, + creationTime: '2025-08-12T14:17:32.000Z', gas: '550', gasLimit: '5000', gasPrice: '0.000001', - height: '6083958', + height: 6083958, requestKey: 'iooWHKROOdziDTcIu6r0iQV_6GKfx3fgwoB-zPLGyx4', sender: 'k:470ea61ff9130e156f3c3f4789ab2c43fb334ea89cbeb75fe5161ed2fd2b7cd1', }, @@ -165,13 +176,14 @@ export const transactionsByPactCodeFixture001 = { { cursor: 'MTc1NTAwODIzNzozMTM2NjU4NDg=', node: { + badResult: null, canonical: true, - chainId: '8', - creationTime: '1755008237', + chainId: 8, + creationTime: '2025-08-12T14:17:17.000Z', gas: '550', gasLimit: '5000', gasPrice: '0.000001', - height: '6083957', + height: 6083957, requestKey: 'XHybf013hk7yIB1_R3lrtXsdQZEkOMj-xYpggfNLo0E', sender: 'k:470ea61ff9130e156f3c3f4789ab2c43fb334ea89cbeb75fe5161ed2fd2b7cd1', }, @@ -179,13 +191,14 @@ export const transactionsByPactCodeFixture001 = { { cursor: 'MTc1NTAwODIxMzozMTM2NjU4NDc=', node: { + badResult: null, canonical: true, - chainId: '8', - creationTime: '1755008213', + chainId: 8, + creationTime: '2025-08-12T14:16:53.000Z', gas: '550', gasLimit: '5000', gasPrice: '0.000001', - height: '6083957', + height: 6083957, requestKey: '12mFMyBLvdPZm9Y-zvSaUFLXi2NnBno6H5vnO0KgixQ', sender: 'k:470ea61ff9130e156f3c3f4789ab2c43fb334ea89cbeb75fe5161ed2fd2b7cd1', }, @@ -193,13 +206,14 @@ export const transactionsByPactCodeFixture001 = { { cursor: 'MTc1NTAwODE1MzozMTM2NjU3MjI=', node: { + badResult: null, canonical: true, - chainId: '8', - creationTime: '1755008153', + chainId: 8, + creationTime: '2025-08-12T14:15:53.000Z', gas: '550', gasLimit: '5000', gasPrice: '0.000001', - height: '6083953', + height: 6083953, requestKey: 'ipHJE3ewcE66G42XJ-vk9MJ3hLedN56GcfnXI4gRnvY', sender: 'k:470ea61ff9130e156f3c3f4789ab2c43fb334ea89cbeb75fe5161ed2fd2b7cd1', }, @@ -207,13 +221,14 @@ export const transactionsByPactCodeFixture001 = { { cursor: 'MTc1NTAwODEzOTozMTM2NjU3MTg=', node: { + badResult: null, canonical: true, - chainId: '8', - creationTime: '1755008139', + chainId: 8, + creationTime: '2025-08-12T14:15:39.000Z', gas: '550', gasLimit: '5000', gasPrice: '0.000001', - height: '6083953', + height: 6083953, requestKey: '_LCLZ9jbBR7Qd-Ph3sQ7xNwmwoBFhH52YBYwghaRF3E', sender: 'k:470ea61ff9130e156f3c3f4789ab2c43fb334ea89cbeb75fe5161ed2fd2b7cd1', }, @@ -221,13 +236,14 @@ export const transactionsByPactCodeFixture001 = { { cursor: 'MTc1NTAwODExMDozMTM2NjU3MTc=', node: { + badResult: null, canonical: true, - chainId: '8', - creationTime: '1755008110', + chainId: 8, + creationTime: '2025-08-12T14:15:10.000Z', gas: '550', gasLimit: '5000', gasPrice: '0.000001', - height: '6083953', + height: 6083953, requestKey: 'xJC_ErFBcf3Vu_MYZAq-PYmA1i2IkUC0Sf36M9pYPdk', sender: 'k:470ea61ff9130e156f3c3f4789ab2c43fb334ea89cbeb75fe5161ed2fd2b7cd1', }, @@ -235,13 +251,14 @@ export const transactionsByPactCodeFixture001 = { { cursor: 'MTc1NDk2OTM0MjozMTM1NjIxMzI=', node: { + badResult: null, canonical: true, - chainId: '0', - creationTime: '1754969342', + chainId: 0, + creationTime: '2025-08-12T03:29:02.000Z', gas: '399', gasLimit: '1000', gasPrice: '0.0000001', - height: '6082659', + height: 6082659, requestKey: 'yrD6mTO-gEy55Xc3ORQAMdUXnIk0g0-HQYS9OIFGNAM', sender: 'k:0221bf3b1c74095b9b3c08cd06d5326e7034e7a0826672806bc7f375770a86d0', }, @@ -249,13 +266,14 @@ export const transactionsByPactCodeFixture001 = { { cursor: 'MTc1NDkzOTMwNjozMTM0NzE0Njg=', node: { + badResult: null, canonical: true, - chainId: '0', - creationTime: '1754939306', + chainId: 0, + creationTime: '2025-08-11T19:08:26.000Z', gas: '399', gasLimit: '1000', gasPrice: '0.0000001', - height: '6081657', + height: 6081657, requestKey: 'Aob-u1aOSJFgrVijD9R7dD3mPOcW03sQ4SXJ6bK35OU', sender: 'k:942b29a22c1e24f66410195ee0d9d0e8c752e4a5ab70e465866f8707ba4ee837', }, @@ -263,13 +281,14 @@ export const transactionsByPactCodeFixture001 = { { cursor: 'MTc1NDkyMTUzNTozMTM0MjQzNjg=', node: { + badResult: null, canonical: true, - chainId: '2', - creationTime: '1754921535', + chainId: 2, + creationTime: '2025-08-11T14:12:15.000Z', gas: '49555', gasLimit: '80300', gasPrice: '0.0000001', - height: '6081065', + height: 6081065, requestKey: '0-EhQQPDfy7I5FwSeNd4VhGz_yV6_6aG4_f3bFizE8A', sender: 'k:22dab5d2f1e393e428eb7515879436662f7b4f7868767ddb1becc77b39e33d1b', }, @@ -277,13 +296,14 @@ export const transactionsByPactCodeFixture001 = { { cursor: 'MTc1NDg0MTE2NzozMTMxOTUxNjI=', node: { + badResult: null, canonical: true, - chainId: '0', - creationTime: '1754841167', + chainId: 0, + creationTime: '2025-08-10T15:52:47.000Z', gas: '206', gasLimit: '1000', gasPrice: '0.0000001', - height: '6078390', + height: 6078390, requestKey: 'fuaIBUoWjIG4JFbznXbLJ5v4AOZnEenxatx_GfUE_Kc', sender: 'k:570a9d82acf68a4bdb0a803ae56f892d4328e1ad0630618efb11128469bd80f3', },