Skip to content

Commit fd257f5

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/graph/arbitrary-query-execution
2 parents 18a8f55 + 4f75333 commit fd257f5

File tree

7 files changed

+94
-34
lines changed

7 files changed

+94
-34
lines changed

.changeset/good-seals-jump.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@kadena/graph-client': patch
3+
---
4+
5+
Added missing links in block overview

.changeset/six-avocados-smoke.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@kadena/graph': patch
3+
---
4+
5+
Added relation between transaction and transfer; applied some logic in
6+
transaction column code: it now returns 'cont' when null

packages/apps/graph-client/src/pages/block/overview/[hash].tsx

+15-5
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ import {
1111
Accordion,
1212
Box,
1313
Breadcrumbs,
14+
Link,
1415
Notification,
1516
Table,
1617
} from '@kadena/react-ui';
18+
1719
import { useRouter } from 'next/router';
1820
import React from 'react';
1921

@@ -26,6 +28,10 @@ const Block: React.FC = () => {
2628

2729
const { data: confirmationDepthData } = useGetMaximumConfirmationDepthQuery();
2830

31+
const viewAllTransactionsPage: string = `${routes.BLOCK_TRANSACTIONS}/${
32+
router.query.hash as string
33+
}`;
34+
2935
return (
3036
<div>
3137
<Breadcrumbs.Root>
@@ -115,7 +121,13 @@ const Block: React.FC = () => {
115121
<Table.Td>
116122
<strong>Parent</strong>
117123
</Table.Td>
118-
<Table.Td>{data.block.parentHash}</Table.Td>
124+
<Table.Td>
125+
<Link
126+
href={`${routes.BLOCK_OVERVIEW}/${data.block.parentHash}`}
127+
>
128+
{data.block.parentHash}
129+
</Link>
130+
</Table.Td>
119131
</Table.Tr>
120132
<Table.Tr>
121133
<Table.Td>
@@ -156,7 +168,7 @@ const Block: React.FC = () => {
156168
</Table.Td>
157169
<Table.Td>{data.block.payloadHash}</Table.Td>
158170
</Table.Tr>
159-
<Table.Tr>
171+
<Table.Tr url={viewAllTransactionsPage}>
160172
<Table.Td>
161173
<strong>No. of transactions</strong>
162174
</Table.Td>
@@ -211,9 +223,7 @@ const Block: React.FC = () => {
211223

212224
{data.block.transactions.totalCount > 0 && (
213225
<CompactTransactionsTable
214-
viewAllHref={`${routes.BLOCK_TRANSACTIONS}/${
215-
router.query.hash as string
216-
}`}
226+
viewAllHref={viewAllTransactionsPage}
217227
transactions={data.block.transactions}
218228
description="All transactions present in this block"
219229
/>

packages/apps/graph/generated-schema.graphql

+3-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ type Transaction implements Node {
190190
badResult: String
191191
block: Block
192192
chainId: BigInt!
193-
code: String
193+
code: String!
194194
continuation: String
195195
creationTime: DateTime!
196196
data: String
@@ -212,6 +212,7 @@ type Transaction implements Node {
212212
senderAccount: String
213213
step: BigInt
214214
transactionId: BigInt
215+
transfers: [Transfer!]
215216
ttl: BigInt!
216217
}
217218

@@ -228,4 +229,5 @@ type Transfer implements Node {
228229
receiverAccount: String!
229230
requestKey: String!
230231
senderAccount: String!
232+
transaction: Transaction
231233
}

packages/apps/graph/prisma/schema.prisma

+29-27
Original file line numberDiff line numberDiff line change
@@ -81,32 +81,33 @@ model Signer {
8181
}
8282

8383
model Transaction {
84-
badResult Json? @map("badresult")
85-
blockHash String @map("block")
86-
chainId BigInt @map("chainid")
87-
code String? @db.VarChar
84+
badResult Json? @map("badresult")
85+
blockHash String @map("block")
86+
chainId BigInt @map("chainid")
87+
code String? @db.VarChar
8888
continuation Json?
89-
creationTime DateTime @map("creationtime") @db.Timestamptz(6)
89+
creationTime DateTime @map("creationtime") @db.Timestamptz(6)
9090
data Json?
9191
gas BigInt
92-
gasLimit BigInt @map("gaslimit")
93-
gasPrice Float @map("gasprice")
94-
goodResult Json? @map("goodresult")
92+
gasLimit BigInt @map("gaslimit")
93+
gasPrice Float @map("gasprice")
94+
goodResult Json? @map("goodresult")
9595
height BigInt
96-
logs String? @db.VarChar
96+
logs String? @db.VarChar
9797
metadata Json?
98-
nonce String @db.VarChar
99-
eventCount BigInt? @map("num_events")
100-
pactId String? @map("pactid") @db.VarChar
101-
proof String? @db.VarChar
102-
requestKey String @map("requestkey") @db.VarChar
98+
nonce String @db.VarChar
99+
eventCount BigInt? @map("num_events")
100+
pactId String? @map("pactid") @db.VarChar
101+
proof String? @db.VarChar
102+
requestKey String @map("requestkey") @db.VarChar
103103
rollback Boolean?
104-
senderAccount String @map("sender") @db.VarChar
104+
senderAccount String @map("sender") @db.VarChar
105105
step BigInt?
106106
ttl BigInt
107-
transactionId BigInt? @map("txid")
107+
transactionId BigInt? @map("txid")
108108
events Event[]
109-
block Block @relation(fields: [blockHash], references: [hash], onDelete: NoAction, onUpdate: NoAction)
109+
block Block @relation(fields: [blockHash], references: [hash], onDelete: NoAction, onUpdate: NoAction)
110+
transfers Transfer[]
110111
111112
@@id([blockHash, requestKey], map: "transaction_pkey")
112113
@@index([height])
@@ -115,17 +116,18 @@ model Transaction {
115116
}
116117

117118
model Transfer {
118-
amount Decimal @db.Decimal
119-
blockHash String @map("block") @db.VarChar
120-
chainId BigInt @map("chainid")
121-
senderAccount String @map("from_acct") @db.VarChar
119+
amount Decimal @db.Decimal
120+
blockHash String @map("block") @db.VarChar
121+
chainId BigInt @map("chainid")
122+
senderAccount String @map("from_acct") @db.VarChar
122123
height BigInt
123-
orderIndex BigInt @map("idx")
124-
moduleHash String @map("modulehash") @db.VarChar
125-
moduleName String @map("modulename") @db.VarChar
126-
requestKey String @map("requestkey") @db.VarChar
127-
receiverAccount String @map("to_acct") @db.VarChar
128-
blocks Block @relation(fields: [blockHash], references: [hash], onDelete: NoAction, onUpdate: NoAction)
124+
orderIndex BigInt @map("idx")
125+
moduleHash String @map("modulehash") @db.VarChar
126+
moduleName String @map("modulename") @db.VarChar
127+
requestKey String @map("requestkey") @db.VarChar
128+
receiverAccount String @map("to_acct") @db.VarChar
129+
blocks Block @relation(fields: [blockHash], references: [hash], onDelete: NoAction, onUpdate: NoAction)
130+
Transaction Transaction? @relation(fields: [blockHash, requestKey], references: [blockHash, requestKey], onDelete: NoAction, onUpdate: NoAction)
129131
130132
@@id([blockHash, chainId, orderIndex, moduleHash, requestKey])
131133
@@index([senderAccount, height(sort: Desc), orderIndex], map: "transfers_senderAccount_height_orderIndex")

packages/apps/graph/src/graph/objects/Transaction.ts

+20-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ export default builder.prismaNode('Transaction', {
1515
},
1616
}),
1717
chainId: t.expose('chainId', { type: 'BigInt' }),
18-
code: t.exposeString('code', { nullable: true }),
18+
// code: t.exposeString('code', { nullable: true }),
19+
code: t.string({
20+
resolve({ code }) {
21+
return code === null ? JSON.stringify('cont') : JSON.stringify(code);
22+
},
23+
}),
1924
continuation: t.string({
2025
nullable: true,
2126
resolve({ continuation }) {
@@ -91,5 +96,19 @@ export default builder.prismaNode('Transaction', {
9196
});
9297
},
9398
}),
99+
100+
transfers: t.prismaField({
101+
type: ['Transfer'],
102+
nullable: true,
103+
// eslint-disable-next-line @typescript-eslint/typedef
104+
resolve(query, parent, args, context, info) {
105+
return prismaClient.transfer.findMany({
106+
where: {
107+
requestKey: parent.requestKey,
108+
blockHash: parent.blockHash,
109+
},
110+
});
111+
},
112+
}),
94113
}),
95114
});

packages/apps/graph/src/graph/objects/Transfer.ts

+16
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,21 @@ export default builder.prismaNode('Transfer', {
2828
});
2929
},
3030
}),
31+
32+
transaction: t.prismaField({
33+
type: 'Transaction',
34+
nullable: true,
35+
// eslint-disable-next-line @typescript-eslint/typedef
36+
resolve(query, parent, args, context, info) {
37+
return prismaClient.transaction.findUnique({
38+
where: {
39+
blockHash_requestKey: {
40+
blockHash: parent.blockHash,
41+
requestKey: parent.requestKey,
42+
},
43+
},
44+
});
45+
},
46+
}),
3147
}),
3248
});

0 commit comments

Comments
 (0)