From b1a916632c3621ab24a75529785147eb21b68d0e Mon Sep 17 00:00:00 2001 From: Albert G <516972+alber70g@users.noreply.github.com> Date: Thu, 16 Jan 2025 16:53:52 +0100 Subject: [PATCH] feat(graph): update schema to represent correct structure in preparation of transition to kadindexer.io/graphql --- packages/e2e/e2e-graph/queries/getAccount.ts | 12 +++-- .../e2e/e2e-graph/queries/getTransactions.ts | 16 ++++-- packages/e2e/e2e-graph/tests/account.test.ts | 6 ++- .../e2e/e2e-graph/tests/transaction.test.ts | 53 +++++++++++++++---- 4 files changed, 67 insertions(+), 20 deletions(-) diff --git a/packages/e2e/e2e-graph/queries/getAccount.ts b/packages/e2e/e2e-graph/queries/getAccount.ts index 6bbefab91ec..7e1175769bf 100644 --- a/packages/e2e/e2e-graph/queries/getAccount.ts +++ b/packages/e2e/e2e-graph/queries/getAccount.ts @@ -66,17 +66,23 @@ export function getAccountQuery(accountName: string) { } result { ... on TransactionResult { - height + block { + height + } } } } fragment CoreTransferFields on Transfer { amount - chainId senderAccount - height requestKey receiverAccount + transaction { + block { + chainId + height + } + } }`, variables: { fungibleName: 'coin', accountName: accountName }, operationName: 'getAccount', diff --git a/packages/e2e/e2e-graph/queries/getTransactions.ts b/packages/e2e/e2e-graph/queries/getTransactions.ts index d6452a2d28a..53c1c095e01 100644 --- a/packages/e2e/e2e-graph/queries/getTransactions.ts +++ b/packages/e2e/e2e-graph/queries/getTransactions.ts @@ -45,20 +45,28 @@ export function getTransactionsQuery(accountName: string) { edges { node { amount - chainId id receiverAccount requestKey senderAccount + transaction { + block { + chainId + } + } crossChainTransfer { amount - blockHash - chainId id moduleName receiverAccount requestKey senderAccount + transaction { + block { + chainId + hash + } + } } } } @@ -123,7 +131,7 @@ export function getTransactionsByRequestKeySubscription( } ...on TransactionResult { badResult - goodResult + goodResult } } } diff --git a/packages/e2e/e2e-graph/tests/account.test.ts b/packages/e2e/e2e-graph/tests/account.test.ts index d294e2eee35..bfa30d87711 100644 --- a/packages/e2e/e2e-graph/tests/account.test.ts +++ b/packages/e2e/e2e-graph/tests/account.test.ts @@ -49,13 +49,15 @@ test('Query: getAccount by AccountName', async ({ request }) => { { node: { amount: 100, - chainId: 0, crossChainTransfer: null, - height: accountCreationResult.metaData?.blockHeight, receiverAccount: testAccount.account, requestKey: accountCreationResult.reqKey, senderAccount: sender00Account.account, transaction: { + block: { + height: accountCreationResult.metaData?.blockHeight, + chainId: 0, + }, cmd: { payload: {}, }, diff --git a/packages/e2e/e2e-graph/tests/transaction.test.ts b/packages/e2e/e2e-graph/tests/transaction.test.ts index 6af3d231a88..23dff17406c 100644 --- a/packages/e2e/e2e-graph/tests/transaction.test.ts +++ b/packages/e2e/e2e-graph/tests/transaction.test.ts @@ -145,7 +145,11 @@ test.describe('Query: getTransactions', () => { { node: { amount: 0.00000736, - chainId: 0, + transaction: { + block: { + chainId: 0, + }, + }, crossChainTransfer: null, receiverAccount: devnetMiner.account, requestKey: transfer.reqKey, @@ -158,7 +162,11 @@ test.describe('Query: getTransactions', () => { { node: { amount: 20, - chainId: 0, + transaction: { + block: { + chainId: 0, + }, + }, crossChainTransfer: null, receiverAccount: targetAccount.account, requestKey: transfer.reqKey, @@ -275,7 +283,11 @@ test.describe('Query: getTransactions', () => { { node: { amount: 0.00000478, - chainId: 1, + transaction: { + block: { + chainId: 1, + }, + }, receiverAccount: devnetMiner.account, requestKey: transfer.reqKey, senderAccount: sourceAccount.account, @@ -288,7 +300,11 @@ test.describe('Query: getTransactions', () => { { node: { amount: 20, - chainId: 1, + transaction: { + block: { + chainId: 1, + }, + }, receiverAccount: targetAccount.account, requestKey: transfer.reqKey, senderAccount: '', @@ -297,8 +313,6 @@ test.describe('Query: getTransactions', () => { ), crossChainTransfer: { amount: 20, - blockHash: continuationBlockHash, - chainId: 0, moduleName: 'coin', receiverAccount: '', requestKey: transfer.continuation?.pactId, @@ -306,6 +320,12 @@ test.describe('Query: getTransactions', () => { id: base64Encode( `Transfer:["${continuationBlockHash}","0","2","${coinModuleHash}","${transfer.continuation?.pactId}"]`, ), + transaction: { + block: { + blockHash: continuationBlockHash, + chainId: 0, + }, + }, }, }, }, @@ -354,7 +374,11 @@ test.describe('Query: getTransactions', () => { { node: { amount: 0.00000621, - chainId: 0, + transaction: { + block: { + chainId: 0, + }, + }, receiverAccount: devnetMiner.account, requestKey: transfer.continuation?.pactId, senderAccount: sourceAccount.account, @@ -367,7 +391,11 @@ test.describe('Query: getTransactions', () => { { node: { amount: 20, - chainId: 0, + transaction: { + block: { + chainId: 0, + }, + }, receiverAccount: '', requestKey: transfer.continuation?.pactId, // feels like this should be the transfer.reqKey senderAccount: sourceAccount.account, @@ -375,9 +403,6 @@ test.describe('Query: getTransactions', () => { `Transfer:["${continuationBlockHash}","0","2","${coinModuleHash}","${transfer.continuation?.pactId}"]`, // feels like this should not be the continuation block has and pactId ), crossChainTransfer: { - amount: 20, - blockHash: transfer.metaData?.blockHash, - chainId: 1, moduleName: 'coin', receiverAccount: targetAccount.account, requestKey: transfer.reqKey, @@ -385,6 +410,12 @@ test.describe('Query: getTransactions', () => { id: base64Encode( `Transfer:["${transfer.metaData?.blockHash}","1","1","${coinModuleHash}","${transfer.reqKey}"]`, // feels like this should be the continuation block has and pactId? ), + transaction: { + block: { + blockHash: transfer.metaData?.blockHash, + chainId: 1, + }, + }, }, }, },