Skip to content

Commit 79c028b

Browse files
authored
Merge pull request #440 from hack-a-chain-software/kadena-tests-3
tests: added one test case for missing mandatory queries
2 parents a598c54 + 44cd369 commit 79c028b

17 files changed

+1068
-7
lines changed

indexer/src/kadena-server/repository/infra/repository/block-db-repository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ export default class BlockDbRepository implements BlockRepository {
697697
`SELECT COUNT(*) as "totalCount"
698698
FROM "Blocks" b
699699
JOIN "Transactions" t ON t."blockId" = b.id
700-
WHERE b.hash = $1`,
700+
WHERE b.hash = $1 AND t.sender != 'coinbase'`,
701701
[blockHash],
702702
);
703703

indexer/src/kadena-server/repository/infra/repository/transfer-db-repository.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ export default class TransferDbRepository implements TransferRepository {
133133
let query = '';
134134

135135
if (blockHash) {
136+
if (requestKey) {
137+
queryParams.push(requestKey);
138+
conditions += `\nAND t.requestkey = $${queryParams.length}`;
139+
}
136140
queryParams.push(blockHash);
137141
query = `
138142
WITH filtered_block AS (
@@ -163,6 +167,11 @@ export default class TransferDbRepository implements TransferRepository {
163167
LIMIT $1
164168
`;
165169
} else if (requestKey) {
170+
if (blockHash) {
171+
queryParams.push(blockHash);
172+
conditions += `\nAND b.hash = $${queryParams.length}`;
173+
}
174+
166175
queryParams.push(requestKey);
167176
query = `
168177
WITH filtered_transaction AS (

indexer/src/kadena-server/resolvers/fields/block/transactions-block-resolver.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const transactionsBlockResolver: BlockResolvers<ResolverContext>['transac
2424
const { first, last, before, after } = args;
2525
const output = await context.transactionRepository.getTransactions({
2626
blockHash: hash,
27+
isCoinbase: false,
2728
first,
2829
last,
2930
before,
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { gql } from 'graphql-request';
2+
3+
export const blocksFromDepthQueryGql = gql`
4+
query blocksFromDepth($minimumDepth: Int!, $chainIds: [String!]!) {
5+
blocksFromDepth(minimumDepth: $minimumDepth, chainIds: $chainIds, first: 20) {
6+
edges {
7+
node {
8+
chainId
9+
creationTime
10+
difficulty
11+
hash
12+
epoch
13+
events {
14+
totalCount
15+
pageInfo {
16+
hasNextPage
17+
hasPreviousPage
18+
}
19+
edges {
20+
node {
21+
chainId
22+
height
23+
id
24+
moduleName
25+
name
26+
orderIndex
27+
parameters
28+
parameterText
29+
qualifiedName
30+
requestKey
31+
}
32+
}
33+
}
34+
flags
35+
hash
36+
height
37+
id
38+
minerAccount {
39+
accountName
40+
balance
41+
chainId
42+
fungibleName
43+
guard {
44+
... on KeysetGuard {
45+
keys
46+
predicate
47+
raw
48+
}
49+
}
50+
id
51+
}
52+
neighbors {
53+
chainId
54+
hash
55+
}
56+
nonce
57+
parent {
58+
chainId
59+
}
60+
payloadHash
61+
powHash
62+
target
63+
transactions {
64+
totalCount
65+
pageInfo {
66+
hasNextPage
67+
hasPreviousPage
68+
}
69+
edges {
70+
node {
71+
id
72+
}
73+
}
74+
}
75+
weight
76+
}
77+
}
78+
}
79+
}
80+
`;
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { gql } from 'graphql-request';
2+
3+
export const blocksFromHeightQueryGql = gql`
4+
query blocksFromHeight($startHeight: Int!, $endHeight: Int) {
5+
blocksFromHeight(startHeight: $startHeight, endHeight: $endHeight, first: 20) {
6+
edges {
7+
node {
8+
chainId
9+
creationTime
10+
difficulty
11+
epoch
12+
events {
13+
totalCount
14+
pageInfo {
15+
hasNextPage
16+
hasPreviousPage
17+
}
18+
edges {
19+
node {
20+
chainId
21+
height
22+
id
23+
moduleName
24+
name
25+
orderIndex
26+
parameters
27+
parameterText
28+
qualifiedName
29+
requestKey
30+
}
31+
}
32+
}
33+
flags
34+
hash
35+
height
36+
id
37+
minerAccount {
38+
accountName
39+
balance
40+
chainId
41+
fungibleName
42+
guard {
43+
... on KeysetGuard {
44+
keys
45+
predicate
46+
raw
47+
}
48+
}
49+
id
50+
}
51+
neighbors {
52+
chainId
53+
hash
54+
}
55+
nonce
56+
parent {
57+
chainId
58+
}
59+
payloadHash
60+
powHash
61+
target
62+
transactions {
63+
totalCount
64+
pageInfo {
65+
hasNextPage
66+
hasPreviousPage
67+
}
68+
edges {
69+
node {
70+
id
71+
}
72+
}
73+
}
74+
weight
75+
}
76+
}
77+
}
78+
}
79+
`;
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { gql } from 'graphql-request';
2+
3+
export const completedBlockHeightsQueryGql = gql`
4+
query completedBlockHeights($completedHeights: Boolean) {
5+
completedBlockHeights(completedHeights: $completedHeights, first: 20) {
6+
edges {
7+
node {
8+
chainId
9+
creationTime
10+
difficulty
11+
hash
12+
epoch
13+
events {
14+
totalCount
15+
pageInfo {
16+
hasNextPage
17+
hasPreviousPage
18+
}
19+
edges {
20+
node {
21+
chainId
22+
height
23+
id
24+
moduleName
25+
name
26+
orderIndex
27+
parameters
28+
parameterText
29+
qualifiedName
30+
requestKey
31+
}
32+
}
33+
}
34+
flags
35+
hash
36+
height
37+
id
38+
minerAccount {
39+
accountName
40+
balance
41+
chainId
42+
fungibleName
43+
guard {
44+
... on KeysetGuard {
45+
keys
46+
predicate
47+
raw
48+
}
49+
}
50+
id
51+
}
52+
neighbors {
53+
chainId
54+
hash
55+
}
56+
nonce
57+
parent {
58+
chainId
59+
}
60+
payloadHash
61+
powHash
62+
target
63+
transactions {
64+
totalCount
65+
pageInfo {
66+
hasNextPage
67+
hasPreviousPage
68+
}
69+
edges {
70+
node {
71+
id
72+
}
73+
}
74+
}
75+
weight
76+
}
77+
}
78+
}
79+
}
80+
`;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { gql } from 'graphql-request';
2+
3+
export const fungibleAccountsByPublicKeyQueryGql = gql`
4+
query fungibleAccountsByPublicKey($publicKey: String!) {
5+
fungibleAccountsByPublicKey(publicKey: $publicKey) {
6+
fungibleName
7+
accountName
8+
totalBalance
9+
chainAccounts {
10+
id
11+
accountName
12+
balance
13+
chainId
14+
fungibleName
15+
guard {
16+
... on KeysetGuard {
17+
keys
18+
predicate
19+
raw
20+
}
21+
}
22+
}
23+
}
24+
}
25+
`;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { gql } from 'graphql-request';
2+
3+
export const fungibleChainAccountQueryGql = gql`
4+
query {
5+
fungibleChainAccount(
6+
accountName: "k:1dc186034e79417a93f5cf05a99874c0a3681936faaf3d5963f77b262218fe82"
7+
chainId: "0"
8+
) {
9+
id
10+
accountName
11+
balance
12+
chainId
13+
fungibleName
14+
guard {
15+
... on KeysetGuard {
16+
keys
17+
predicate
18+
raw
19+
}
20+
}
21+
}
22+
}
23+
`;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { gql } from 'graphql-request';
2+
3+
export const fungibleChainAccountsByPublicKeyQueryGql = gql`
4+
query fungibleChainAccountsByPublicKey($publicKey: String!, $chainId: String!) {
5+
fungibleChainAccountsByPublicKey(publicKey: $publicKey, chainId: $chainId) {
6+
id
7+
accountName
8+
balance
9+
chainId
10+
fungibleName
11+
guard {
12+
... on KeysetGuard {
13+
keys
14+
predicate
15+
raw
16+
}
17+
}
18+
}
19+
}
20+
`;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { gql } from 'graphql-request';
2+
3+
export const graphConfigurationQueryGql = gql`
4+
query {
5+
graphConfiguration {
6+
minimumBlockHeight
7+
version
8+
}
9+
}
10+
`;

0 commit comments

Comments
 (0)