{event?.node ? (
- formatCode(event.node.parameterText)
+ formatCode(event.node.parameters || '""')
) : (
N/A
diff --git a/packages/apps/graph/.graphqlrc.yml b/packages/apps/graph/.graphqlrc.yml
deleted file mode 100644
index e0c5e735f1..0000000000
--- a/packages/apps/graph/.graphqlrc.yml
+++ /dev/null
@@ -1 +0,0 @@
-schema: ./src/__generated__/graphql.schema.json
diff --git a/packages/apps/graph/Updates-graphql-hackachain.md b/packages/apps/graph/Updates-graphql-hackachain.md
new file mode 100644
index 0000000000..1ea14bc3e6
--- /dev/null
+++ b/packages/apps/graph/Updates-graphql-hackachain.md
@@ -0,0 +1,62 @@
+- [ ] Marcos Update descriptions of the fields
+
+- [ ] Marcos [log] ✖ Field Block.difficulty changed type from BigInt! to BigInt
+- [ ] Marcos [log] ✖ Field Block.flags changed type from Decimal! to NonNegativeFloat!
+- [ ] Marcos [log] ✖ Field Block.nonce changed type from Decimal! to NonNegativeFloat!
+- [x] Albert [log] ✖ Field Block.target changed type from Decimal! to String!
+- [x] Albert [log] ✖ Field Block.weight changed type from Decimal! to String!
+[log] ✖ Type Decimal was removed
+- [x] Albert [log] ✖ Field incrementedId was removed from object type Event
+- [ ] Marcos [log] ✖ Field Event.name changed type from String! to String
+- [x] Albert [log] ✖ Field parameterText was removed from object type Event
+- [ ] Marcos [log] ✖ Field FungibleAccount.totalBalance changed type from Decimal! to NonNegativeFloat!
+- [ ] Marcos [log] ✖ Field version was removed from object type GraphConfiguration
+- [ ] Marcos [log] ✖ Guard object type no longer implements IGuard interface
+ For now, use the IGuard interface with only the KeysetGuard implements IGuard.
+
+ """
+ A guard. Has values `keys`, `predicate` to provide backwards compatibility for `KeysetGuard`.
+ """
+ interface IGuard {
+ raw: String!
+ }
+
+ type KeysetGuard implements IGuard {
+ keys: [String!]!
+ predicate: String!
+ raw: String!
+ }
+- [ ] Marcos for next version we need the different guards to be implemented
+
+- [x] Albert [log] ✖ Type MinerKey was removed
+
+- [ ] Marcos [log] ✖ Field chainAccounts was removed from object type NonFungibleAccount
+ Reintroduce NonFungibleAccount.chainAccounts
+ [log] ✖ Field guard was removed from object type NonFungibleTokenBalance
+
+- [x] Albert [log] ✖ Type PositiveFloat was removed
+- [x] Albert [log] ✖ Field Query.fungibleChainAccount changed type from FungibleChainAccount to [FungibleChainAccount!]!
+- [x] Albert [log] ✖ Argument chainId: String! was removed from field Query.fungibleChainAccount
+
+- [ ] Marcos [log] ✖ Argument parametersFilter: String was removed from field Subscription.events
+ https://www.prisma.io/docs/orm/prisma-client/special-fields-and-types/working-with-json-fields#filter-on-object-property
+ Add complexity information to the queries, and limit complexity for production servers
+
+- [ ] Marcos [log] ✖ Type for argument chainIds on field Subscription.newBlocks changed from [String!] to [String]!
+- [x] Albert [log] ✖ Field metadata was removed from object type TransactionResult
+- [ ] Marcos [log] ✖ Field Transfer.amount changed type from Decimal! to NonNegativeFloat!
+- [x] Albert [log] ⚠ Argument chainIds: [String!] added to field Query.fungibleChainAccount
+
+
+
+
+[log]
+Detected the following changes (150) between schemas:
+
+- [ ] Albert [log] ✖ Field FungibleChainAccount.guard changed type from Guard! to KeysetGuard!
+- [ ] Albert [log] ✖ Type Guard was removed
+- [ ] Albert [log] ✖ Field keys (deprecated) was removed from interface IGuard
+- [ ] Albert [log] ✖ Field predicate (deprecated) was removed from interface IGuard
+
+[log] ✖ Field moduleHash was removed from object type Transfer
+[log] ✖ Field requestKey was removed from object type Transfer
diff --git a/packages/apps/graph/generated-schema.graphql b/packages/apps/graph/generated-schema.graphql
index 9870c1c6e1..ce2a878c14 100644
--- a/packages/apps/graph/generated-schema.graphql
+++ b/packages/apps/graph/generated-schema.graphql
@@ -30,11 +30,11 @@ type Block implements Node {
"""The proof of work hash."""
powHash: String!
- target: Decimal!
+ target: String!
"""Default page size is 20."""
transactions(after: String, before: String, first: Int, last: Int): BlockTransactionsConnection!
- weight: Decimal!
+ weight: String!
}
type BlockEventsConnection {
@@ -105,7 +105,6 @@ type Event implements Node {
"""The height of the block where the event was emitted."""
height: BigInt!
id: ID!
- incrementedId: Int!
moduleName: String!
name: String!
@@ -113,7 +112,6 @@ type Event implements Node {
The order index of this event, in the case that there are multiple events in one transaction.
"""
orderIndex: BigInt!
- parameterText: String!
parameters: String
"""
@@ -244,14 +242,6 @@ interface IGuard {
raw: String!
}
-"""The account of the miner that solved a block."""
-type MinerKey implements Node {
- block: Block!
- blockHash: String!
- id: ID!
- key: String!
-}
-
"""Information about the network."""
type NetworkInfo {
"""The version of the API."""
@@ -374,9 +364,6 @@ type PageInfo {
startCursor: String
}
-"""Floats that will have a value greater than 0."""
-scalar PositiveFloat
-
type Query {
"""Retrieve a block by hash."""
block(hash: String!): Block
@@ -387,7 +374,7 @@ type Query {
before: String
"""Default: all chains"""
- chainIds: [String!]
+ chainIds: [String!] = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"]
first: Int
last: Int
minimumDepth: Int!
@@ -399,7 +386,7 @@ type Query {
before: String
"""Default: all chains"""
- chainIds: [String!]
+ chainIds: [String!] = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"]
endHeight: Int
first: Int
last: Int
@@ -414,7 +401,7 @@ type Query {
before: String
"""Default: all chains"""
- chainIds: [String!]
+ chainIds: [String!] = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"]
"""Retrieve blocks from completed heights only. Default: true"""
completedHeights: Boolean = true
@@ -425,9 +412,9 @@ type Query {
"""
Retrieve events by qualifiedName (e.g. `coin.TRANSFER`). Default page size is 20.
-
+
The parametersFilter is a stringified JSON object that matches the [JSON object property filters](https://www.prisma.io/docs/orm/prisma-client/special-fields-and-types/working-with-json-fields#filter-on-object-property) from Prisma.
-
+
An example of such a filter parameter value: `events(parametersFilter: "{\"array_starts_with\": \"k:abcdefg\"}")`
"""
events(after: String, before: String, blockHash: String, chainId: String, first: Int, last: Int, maxHeight: Int, minHeight: Int, minimumDepth: Int, orderIndex: Int, parametersFilter: String, qualifiedEventName: String!, requestKey: String): QueryEventsConnection!
@@ -435,7 +422,7 @@ type Query {
"""
Retrieve an fungible specific account by its name and fungible, such as coin.
"""
- fungibleAccount(accountName: String!, fungibleName: String): FungibleAccount
+ fungibleAccount(accountName: String!, fungibleName: String = "coin"): FungibleAccount
"""Retrieve an account by public key."""
fungibleAccountsByPublicKey(fungibleName: String, publicKey: String!): [FungibleAccount!]!
@@ -443,7 +430,7 @@ type Query {
"""
Retrieve an account by its name and fungible, such as coin, on a specific chain.
"""
- fungibleChainAccount(accountName: String!, chainId: String!, fungibleName: String): FungibleChainAccount
+ fungibleChainAccount(accountName: String!, chainIds: [String!]! = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"], fungibleName: String = "coin"): [FungibleChainAccount!]
"""Retrieve a chain account by public key."""
fungibleChainAccountsByPublicKey(chainId: String!, fungibleName: String, publicKey: String!): [FungibleChainAccount!]!
@@ -602,10 +589,10 @@ type Subscription {
events(chainId: String, minimumDepth: Int, parametersFilter: String, qualifiedEventName: String!): [Event!]
"""Subscribe to new blocks."""
- newBlocks(chainIds: [String!]): [Block!]
+ newBlocks(chainIds: [String!] = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"]): [Block!]
"""Subscribe to new blocks from a specific depth."""
- newBlocksFromDepth(chainIds: [String!]!, minimumDepth: Int!): [Block!]
+ newBlocksFromDepth(chainIds: [String!] = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"], minimumDepth: Int!): [Block!]
"""Listen for a transaction by request key."""
transaction(chainId: String, requestKey: String!): Transaction
@@ -676,12 +663,8 @@ type TransactionResult {
"""The transaction result when it was successful. Formatted as raw JSON."""
goodResult: String
- """The height of the block this transaction belongs to."""
- height: BigInt!
-
"""Identifier to retrieve the logs for the execution of the transaction."""
logs: String
- metadata: String
transactionId: BigInt
transfers(after: String, before: String, first: Int, last: Int): TransactionResultTransfersConnection!
}
@@ -716,15 +699,12 @@ type TransactionSignature {
type Transfer implements Node {
amount: Decimal!
block: Block!
- blockHash: String!
- chainId: BigInt!
creationTime: DateTime!
"""
The counterpart of the crosschain-transfer. `null` when it is not a cross-chain-transfer.
"""
crossChainTransfer: Transfer
- height: BigInt!
id: ID!
moduleHash: String!
moduleName: String!
diff --git a/packages/apps/graph/src/graph/builder.ts b/packages/apps/graph/src/graph/builder.ts
index 371f52b58a..647ae7caba 100644
--- a/packages/apps/graph/src/graph/builder.ts
+++ b/packages/apps/graph/src/graph/builder.ts
@@ -18,7 +18,6 @@ import {
BigIntResolver,
DateTimeResolver,
NonNegativeFloatResolver,
- PositiveFloatResolver,
} from 'graphql-scalars';
import type { IncomingMessage } from 'http';
import { prismaClient } from '../db/prisma-client';
@@ -60,10 +59,6 @@ interface IDefaultTypesExtension {
Input: number;
Output: number;
};
- PositiveFloat: {
- Input: number;
- Output: number;
- };
};
}
@@ -183,7 +178,6 @@ const SCALARS = [
['BigInt', BigIntResolver],
['DateTime', DateTimeResolver],
['Decimal', NonNegativeFloatResolver],
- ['PositiveFloat', PositiveFloatResolver],
] as const;
// add the custom scalars
diff --git a/packages/apps/graph/src/graph/index.ts b/packages/apps/graph/src/graph/index.ts
index 8e52ab550b..9e194cbe59 100644
--- a/packages/apps/graph/src/graph/index.ts
+++ b/packages/apps/graph/src/graph/index.ts
@@ -7,7 +7,6 @@ import './objects/gas-limit-estimation';
import './objects/graph-configuration';
import './objects/guard';
import './objects/keyset-guard';
-import './objects/miner-key';
import './objects/network-info';
import './objects/non-fungible-account';
import './objects/non-fungible-chain-account';
diff --git a/packages/apps/graph/src/graph/objects/block.ts b/packages/apps/graph/src/graph/objects/block.ts
index f72b7678d1..2a6ec9370e 100644
--- a/packages/apps/graph/src/graph/objects/block.ts
+++ b/packages/apps/graph/src/graph/objects/block.ts
@@ -40,8 +40,8 @@ export default builder.prismaNode(Prisma.ModelName.Block, {
powHash: t.exposeString('powHash', {
description: 'The proof of work hash.',
}),
- target: t.expose('target' as never, { type: 'Decimal' }),
- weight: t.expose('weight' as never, { type: 'Decimal' }),
+ target: t.expose('target' as never, { type: 'String' }),
+ weight: t.expose('weight' as never, { type: 'String' }),
nonce: t.expose('nonce' as never, { type: 'Decimal' }),
flags: t.expose('flags' as never, { type: 'Decimal' }),
minerAccount: t.field({
diff --git a/packages/apps/graph/src/graph/objects/event.ts b/packages/apps/graph/src/graph/objects/event.ts
index 447af248a6..daed685dc7 100644
--- a/packages/apps/graph/src/graph/objects/event.ts
+++ b/packages/apps/graph/src/graph/objects/event.ts
@@ -12,7 +12,6 @@ export default builder.prismaNode(Prisma.ModelName.Event, {
select: {},
fields: (t) => ({
// database fields
- incrementedId: t.exposeInt('id'),
chainId: t.expose('chainId', { type: 'BigInt' }),
height: t.expose('height', {
type: 'BigInt',
@@ -25,7 +24,6 @@ export default builder.prismaNode(Prisma.ModelName.Event, {
}),
moduleName: t.exposeString('moduleName'),
name: t.exposeString('name'),
- parameterText: t.exposeString('parameterText'),
parameters: t.string({
nullable: true,
select: {
diff --git a/packages/apps/graph/src/graph/objects/fungible-account.ts b/packages/apps/graph/src/graph/objects/fungible-account.ts
index b04f65501e..ec5db4f0d3 100644
--- a/packages/apps/graph/src/graph/objects/fungible-account.ts
+++ b/packages/apps/graph/src/graph/objects/fungible-account.ts
@@ -12,10 +12,8 @@ import { builder } from '../builder';
import { fungibleAccountDetailsLoader } from '../data-loaders/fungible-account-details';
import { dotenv } from '@utils/dotenv';
-import type {
- IFungibleAccount,
- IFungibleChainAccount,
-} from '../types/graphql-types';
+import { isDefined } from '@utils/isDefined';
+import type { IFungibleAccount } from '../types/graphql-types';
import {
FungibleAccountName,
FungibleChainAccountName,
@@ -320,7 +318,6 @@ export const getTransactions = async (
goodresult AS "good_result",
height,
logs,
- metadata,
nonce,
num_events AS "event_count",
pactid AS "pact_id",
@@ -357,7 +354,6 @@ export const getTransactions = async (
goodresult AS "good_result",
height,
logs,
- metadata,
nonce,
num_events AS "event_count",
pactid AS "pact_id",
@@ -412,7 +408,6 @@ export const getTransactions = async (
goodresult AS "good_result",
height,
logs,
- metadata,
nonce,
num_events AS "event_count",
pactid AS "pact_id",
@@ -460,7 +455,6 @@ export const getTransactions = async (
goodresult AS "good_result",
height,
logs,
- metadata,
nonce,
num_events AS "event_count",
pactid AS "pact_id",
@@ -546,9 +540,7 @@ export default builder.node(
});
}),
)
- ).filter(
- (chainAccount) => chainAccount !== null,
- ) as IFungibleChainAccount[];
+ ).filter(isDefined);
} catch (error) {
throw normalizeError(error);
}
@@ -584,7 +576,7 @@ export default builder.node(
},
}),
transactions: t.prismaConnection({
- description: 'Default page size is 20.',
+ description: 'Default page size is 20.',
type: Prisma.ModelName.Transaction,
cursor: 'blockHash_requestKey',
edgesNullable: false,
@@ -630,7 +622,7 @@ export default builder.node(
},
}),
transfers: t.prismaConnection({
- description: 'Default page size is 20.',
+ description: 'Default page size is 20.',
type: Prisma.ModelName.Transfer,
cursor: 'blockHash_chainId_orderIndex_moduleHash_requestKey',
edgesNullable: false,
diff --git a/packages/apps/graph/src/graph/objects/fungible-chain-account.ts b/packages/apps/graph/src/graph/objects/fungible-chain-account.ts
index e99c48e4d3..c6c5cb67b5 100644
--- a/packages/apps/graph/src/graph/objects/fungible-chain-account.ts
+++ b/packages/apps/graph/src/graph/objects/fungible-chain-account.ts
@@ -71,7 +71,7 @@ export default builder.node(
}),
balance: t.exposeFloat('balance'),
transactions: t.prismaConnection({
- description:
+ description:
'Transactions that the current account is sender of. Default page size is 20.',
type: Prisma.ModelName.Transaction,
cursor: 'blockHash_requestKey',
@@ -109,7 +109,7 @@ export default builder.node(
},
}),
transfers: t.prismaConnection({
- description: 'Default page size is 20.',
+ description: 'Default page size is 20.',
type: Prisma.ModelName.Transfer,
edgesNullable: false,
cursor: 'blockHash_chainId_orderIndex_moduleHash_requestKey',
diff --git a/packages/apps/graph/src/graph/objects/miner-key.ts b/packages/apps/graph/src/graph/objects/miner-key.ts
deleted file mode 100644
index c38e938bf8..0000000000
--- a/packages/apps/graph/src/graph/objects/miner-key.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import { prismaClient } from '@db/prisma-client';
-import { Prisma } from '@prisma/client';
-import { COMPLEXITY } from '@services/complexity';
-import { normalizeError } from '@utils/errors';
-import { builder } from '../builder';
-
-export default builder.prismaNode(Prisma.ModelName.MinerKey, {
- description: 'The account of the miner that solved a block.',
- id: { field: 'blockHash_key' },
- select: {},
- fields: (t) => ({
- blockHash: t.exposeString('blockHash'),
- key: t.exposeString('key'),
- block: t.prismaField({
- type: Prisma.ModelName.Block,
- nullable: false,
- complexity: COMPLEXITY.FIELD.PRISMA_WITHOUT_RELATIONS,
- select: {
- blocks: true,
- blockHash: true,
- },
- async resolve(query, parent) {
- try {
- return (
- parent.blocks ||
- (await prismaClient.block.findUniqueOrThrow({
- ...query,
- where: {
- hash: parent.blockHash,
- },
- }))
- );
- } catch (error) {
- throw normalizeError(error);
- }
- },
- }),
- }),
-});
diff --git a/packages/apps/graph/src/graph/objects/non-fungible-account.ts b/packages/apps/graph/src/graph/objects/non-fungible-account.ts
index 73e22b898f..6eac57a411 100644
--- a/packages/apps/graph/src/graph/objects/non-fungible-account.ts
+++ b/packages/apps/graph/src/graph/objects/non-fungible-account.ts
@@ -6,13 +6,11 @@ import {
getDefaultConnectionComplexity,
} from '@services/complexity';
import { normalizeError } from '@utils/errors';
+import { isDefined } from '@utils/isDefined';
import { builder } from '../builder';
import { nonFungibleChainCheck } from '../data-loaders/non-fungible-chain-check';
import { tokenDetailsLoader } from '../data-loaders/token-details';
-import type {
- INonFungibleAccount,
- INonFungibleChainAccount,
-} from '../types/graphql-types';
+import type { INonFungibleAccount } from '../types/graphql-types';
import {
NonFungibleAccountName,
NonFungibleChainAccountName,
@@ -68,9 +66,7 @@ export default builder.node(
});
}),
)
- ).filter(
- (chainAccount) => chainAccount !== null,
- ) as INonFungibleChainAccount[];
+ ).filter(isDefined);
} catch (error) {
throw normalizeError(error);
}
@@ -92,7 +88,7 @@ export default builder.node(
},
}),
transactions: t.prismaConnection({
- description:
+ description:
'Default page size is 20. Note that custom token related transactions are not included.',
type: Prisma.ModelName.Transaction,
cursor: 'blockHash_requestKey',
diff --git a/packages/apps/graph/src/graph/objects/non-fungible-chain-account.ts b/packages/apps/graph/src/graph/objects/non-fungible-chain-account.ts
index 9b0f7d1878..c99c2a3a0d 100644
--- a/packages/apps/graph/src/graph/objects/non-fungible-chain-account.ts
+++ b/packages/apps/graph/src/graph/objects/non-fungible-chain-account.ts
@@ -57,7 +57,7 @@ export default builder.node(
},
}),
transactions: t.prismaConnection({
- description:
+ description:
'Default page size is 20. Note that custom token related transactions are not included.',
type: Prisma.ModelName.Transaction,
cursor: 'blockHash_requestKey',
diff --git a/packages/apps/graph/src/graph/objects/transaction-result.ts b/packages/apps/graph/src/graph/objects/transaction-result.ts
index a2566fcd1d..5f609494bc 100644
--- a/packages/apps/graph/src/graph/objects/transaction-result.ts
+++ b/packages/apps/graph/src/graph/objects/transaction-result.ts
@@ -36,16 +36,11 @@ const TransactionResult = builder.objectType('TransactionResult', {
'The transaction result when it was successful. Formatted as raw JSON.',
nullable: true,
}),
- height: t.expose('height', {
- description: 'The height of the block this transaction belongs to.',
- type: 'BigInt',
- }),
logs: t.exposeString('logs', {
description:
'Identifier to retrieve the logs for the execution of the transaction.',
nullable: true,
}),
- metadata: t.exposeString('metadata', { nullable: true }),
eventCount: t.expose('eventCount', { type: 'BigInt', nullable: true }),
transactionId: t.expose('transactionId', {
type: 'BigInt',
@@ -67,7 +62,7 @@ const TransactionResult = builder.objectType('TransactionResult', {
}),
events: t.prismaConnection({
- type: Prisma.ModelName.Event,
+ type: Prisma.ModelName.Event,
cursor: 'blockHash_orderIndex_requestKey',
complexity: (args) => ({
field: getDefaultConnectionComplexity({
@@ -95,7 +90,7 @@ const TransactionResult = builder.objectType('TransactionResult', {
},
}),
transfers: t.prismaConnection({
- type: Prisma.ModelName.Transfer,
+ type: Prisma.ModelName.Transfer,
cursor: 'blockHash_chainId_orderIndex_moduleHash_requestKey',
complexity: (args) => ({
field: getDefaultConnectionComplexity({
diff --git a/packages/apps/graph/src/graph/objects/transaction.ts b/packages/apps/graph/src/graph/objects/transaction.ts
index bd33d95707..33d458360e 100644
--- a/packages/apps/graph/src/graph/objects/transaction.ts
+++ b/packages/apps/graph/src/graph/objects/transaction.ts
@@ -110,7 +110,6 @@ export default builder.prismaNode(Prisma.ModelName.Transaction, {
: null,
height: parent.height,
logs: parent.logs,
- metadata: parent.metadata ? JSON.stringify(parent.metadata) : null,
eventCount: parent.eventCount,
transactionId: parent.transactionId,
blockHash: parent.blockHash,
diff --git a/packages/apps/graph/src/graph/objects/transfer.ts b/packages/apps/graph/src/graph/objects/transfer.ts
index be22da787a..27b9085f99 100644
--- a/packages/apps/graph/src/graph/objects/transfer.ts
+++ b/packages/apps/graph/src/graph/objects/transfer.ts
@@ -12,10 +12,7 @@ export default builder.prismaNode(Prisma.ModelName.Transfer, {
fields: (t) => ({
// database fields
amount: t.expose('amount' as never, { type: 'Decimal' }),
- blockHash: t.exposeString('blockHash'),
- chainId: t.expose('chainId', { type: 'BigInt' }),
senderAccount: t.exposeString('senderAccount'),
- height: t.expose('height', { type: 'BigInt' }),
orderIndex: t.expose('orderIndex', {
type: 'BigInt',
description:
diff --git a/packages/apps/graph/src/graph/query/blocks-from-depth.ts b/packages/apps/graph/src/graph/query/blocks-from-depth.ts
index 74bf5b6997..e9d9ab008c 100644
--- a/packages/apps/graph/src/graph/query/blocks-from-depth.ts
+++ b/packages/apps/graph/src/graph/query/blocks-from-depth.ts
@@ -1,4 +1,5 @@
import { prismaClient } from '@db/prisma-client';
+import { CHAINS } from '@kadena/chainweb-node-client';
import type { Block } from '@prisma/client';
import { getDefaultConnectionComplexity } from '@services/complexity';
import {
@@ -6,6 +7,7 @@ import {
getConfirmationDepth,
} from '@services/depth-service';
import { normalizeError } from '@utils/errors';
+import { networkData } from '@utils/network';
import { builder } from '../builder';
import GQLBlock from '../objects/block';
@@ -21,7 +23,7 @@ builder.queryField('blocksFromDepth', (t) =>
},
}),
chainIds: t.arg.stringList({
- required: false,
+ defaultValue: [...CHAINS],
description: 'Default: all chains',
validate: {
minLength: 1,
diff --git a/packages/apps/graph/src/graph/query/blocks-from-height.ts b/packages/apps/graph/src/graph/query/blocks-from-height.ts
index 4bb4dec19b..40247ba193 100644
--- a/packages/apps/graph/src/graph/query/blocks-from-height.ts
+++ b/packages/apps/graph/src/graph/query/blocks-from-height.ts
@@ -1,4 +1,5 @@
import { prismaClient } from '@db/prisma-client';
+import { CHAINS } from '@kadena/chainweb-node-client';
import { getDefaultConnectionComplexity } from '@services/complexity';
import { normalizeError } from '@utils/errors';
import { networkData } from '@utils/network';
@@ -24,7 +25,7 @@ builder.queryField('blocksFromHeight', (t) =>
},
}),
chainIds: t.arg.stringList({
- required: false,
+ defaultValue: [...CHAINS],
description: 'Default: all chains',
validate: {
minLength: 1,
diff --git a/packages/apps/graph/src/graph/query/completed-block-heights.ts b/packages/apps/graph/src/graph/query/completed-block-heights.ts
index aae7e8314b..aeb5f13a05 100644
--- a/packages/apps/graph/src/graph/query/completed-block-heights.ts
+++ b/packages/apps/graph/src/graph/query/completed-block-heights.ts
@@ -1,4 +1,5 @@
import { prismaClient } from '@db/prisma-client';
+import { CHAINS } from '@kadena/chainweb-node-client';
import { COMPLEXITY } from '@services/complexity';
import { normalizeError } from '@utils/errors';
import { networkData } from '@utils/network';
@@ -24,7 +25,7 @@ builder.queryField('completedBlockHeights', (t) =>
},
}),
chainIds: t.arg.stringList({
- required: false,
+ defaultValue: [...CHAINS],
description: 'Default: all chains',
validate: {
minLength: 1,
diff --git a/packages/apps/graph/src/graph/query/events.ts b/packages/apps/graph/src/graph/query/events.ts
index a5254fcdc6..49250f2f58 100644
--- a/packages/apps/graph/src/graph/query/events.ts
+++ b/packages/apps/graph/src/graph/query/events.ts
@@ -67,9 +67,9 @@ const generateEventsFilter = async (args: {
builder.queryField('events', (t) =>
t.prismaConnection({
description: `Retrieve events by qualifiedName (e.g. \`coin.TRANSFER\`). Default page size is 20.
-
+
The parametersFilter is a stringified JSON object that matches the [JSON object property filters](https://www.prisma.io/docs/orm/prisma-client/special-fields-and-types/working-with-json-fields#filter-on-object-property) from Prisma.
-
+
An example of such a filter parameter value: \`events(parametersFilter: "{\\"array_starts_with\\": \\"k:abcdefg\\"}")\``,
edgesNullable: false,
args: {
diff --git a/packages/apps/graph/src/graph/query/fungible-account.ts b/packages/apps/graph/src/graph/query/fungible-account.ts
index 17c5413c23..aa812b45f9 100644
--- a/packages/apps/graph/src/graph/query/fungible-account.ts
+++ b/packages/apps/graph/src/graph/query/fungible-account.ts
@@ -1,9 +1,9 @@
import { getFungibleChainAccount } from '@services/account-service';
import { dotenv } from '@utils/dotenv';
+import { isDefined } from '@utils/isDefined';
import { networkData } from '@utils/network';
import { builder } from '../builder';
import FungibleAccount from '../objects/fungible-account';
-import type { IFungibleChainAccount } from '../types/graphql-types';
import { FungibleAccountName } from '../types/graphql-types';
builder.queryField('fungibleAccount', (t) =>
@@ -19,7 +19,7 @@ builder.queryField('fungibleAccount', (t) =>
},
}),
fungibleName: t.arg.string({
- required: false,
+ defaultValue: dotenv.DEFAULT_FUNGIBLE_NAME,
validate: {
minLength: 1,
},
@@ -32,14 +32,12 @@ builder.queryField('fungibleAccount', (t) =>
networkData.chainIds.map(async (chainId) => {
return getFungibleChainAccount({
chainId: chainId,
- fungibleName: args.fungibleName || dotenv.DEFAULT_FUNGIBLE_NAME,
+ fungibleName: args.fungibleName as string,
accountName: args.accountName,
});
}),
)
- ).filter(
- (chainAccount) => chainAccount !== null,
- ) as IFungibleChainAccount[];
+ ).filter(isDefined);
if (chainAccounts.length === 0) {
return null;
@@ -48,7 +46,7 @@ builder.queryField('fungibleAccount', (t) =>
return {
__typename: FungibleAccountName,
accountName: args.accountName,
- fungibleName: args.fungibleName || dotenv.DEFAULT_FUNGIBLE_NAME,
+ fungibleName: args.fungibleName as string,
chainAccounts: chainAccounts,
totalBalance: 0,
transactions: [],
diff --git a/packages/apps/graph/src/graph/query/fungible-accounts-by-public-key.ts b/packages/apps/graph/src/graph/query/fungible-accounts-by-public-key.ts
index b97644a48a..8e3de801f8 100644
--- a/packages/apps/graph/src/graph/query/fungible-accounts-by-public-key.ts
+++ b/packages/apps/graph/src/graph/query/fungible-accounts-by-public-key.ts
@@ -1,10 +1,10 @@
import { prismaClient } from '@db/prisma-client';
import { getFungibleChainAccount } from '@services/account-service';
import { normalizeError } from '@utils/errors';
+import { isDefined } from '@utils/isDefined';
import { networkData } from '@utils/network';
import { builder } from '../builder';
import FungibleAccount from '../objects/fungible-account';
-import type { IFungibleChainAccount } from '../types/graphql-types';
import { FungibleAccountName } from '../types/graphql-types';
builder.queryField('fungibleAccountsByPublicKey', (t) =>
@@ -49,7 +49,7 @@ builder.queryField('fungibleAccountsByPublicKey', (t) =>
}),
),
)
- ).filter(Boolean) as IFungibleChainAccount[];
+ ).filter(isDefined);
return {
__typename: FungibleAccountName,
diff --git a/packages/apps/graph/src/graph/query/fungible-chain-account.ts b/packages/apps/graph/src/graph/query/fungible-chain-account.ts
index 4d22bbfab0..dfe538f52c 100644
--- a/packages/apps/graph/src/graph/query/fungible-chain-account.ts
+++ b/packages/apps/graph/src/graph/query/fungible-chain-account.ts
@@ -2,8 +2,10 @@ import { getFungibleChainAccount } from '@services/account-service';
import { COMPLEXITY } from '@services/complexity';
import { dotenv } from '@utils/dotenv';
import { normalizeError } from '@utils/errors';
+import { isDefined } from '@utils/isDefined';
import { builder } from '../builder';
import FungibleChainAccount from '../objects/fungible-chain-account';
+import { CHAINS } from '@kadena/chainweb-node-client';
builder.queryField('fungibleChainAccount', (t) =>
t.field({
@@ -17,28 +19,38 @@ builder.queryField('fungibleChainAccount', (t) =>
},
}),
fungibleName: t.arg.string({
- required: false,
+ defaultValue: dotenv.DEFAULT_FUNGIBLE_NAME,
validate: {
minLength: 1,
},
}),
- chainId: t.arg.string({
+ chainIds: t.arg.stringList({
+ defaultValue: [...CHAINS],
required: true,
validate: {
minLength: 1,
+ items: {
+ minLength: 1,
+ },
},
}),
},
- type: FungibleChainAccount,
+ type: [FungibleChainAccount],
nullable: true,
complexity: COMPLEXITY.FIELD.CHAINWEB_NODE,
async resolve(__parent, args) {
try {
- return await getFungibleChainAccount({
- chainId: args.chainId,
- fungibleName: args.fungibleName || dotenv.DEFAULT_FUNGIBLE_NAME,
- accountName: args.accountName,
- });
+ return (
+ await Promise.all(
+ args.chainIds.map((chainId) =>
+ getFungibleChainAccount({
+ chainId: chainId,
+ fungibleName: args.fungibleName as string,
+ accountName: args.accountName,
+ }),
+ ),
+ )
+ ).filter(isDefined);
} catch (error) {
throw normalizeError(error);
}
diff --git a/packages/apps/graph/src/graph/query/fungible-chain-accounts-by-public-key.ts b/packages/apps/graph/src/graph/query/fungible-chain-accounts-by-public-key.ts
index 52bd8c72a1..d9ef4cd95d 100644
--- a/packages/apps/graph/src/graph/query/fungible-chain-accounts-by-public-key.ts
+++ b/packages/apps/graph/src/graph/query/fungible-chain-accounts-by-public-key.ts
@@ -1,9 +1,9 @@
import { prismaClient } from '@db/prisma-client';
import { getFungibleChainAccount } from '@services/account-service';
import { normalizeError } from '@utils/errors';
+import { isDefined } from '@utils/isDefined';
import { builder } from '../builder';
import FungibleChainAccount from '../objects/fungible-chain-account';
-import type { IFungibleChainAccount } from '../types/graphql-types';
builder.queryField('fungibleChainAccountsByPublicKey', (t) =>
t.field({
@@ -51,7 +51,7 @@ builder.queryField('fungibleChainAccountsByPublicKey', (t) =>
});
}),
)
- ).filter(Boolean) as IFungibleChainAccount[];
+ ).filter(isDefined);
return fungibleChainAccounts;
} catch (error) {
diff --git a/packages/apps/graph/src/graph/subscription/new-blocks-from-depth.ts b/packages/apps/graph/src/graph/subscription/new-blocks-from-depth.ts
index ad6fe5ef5a..a209b4febf 100644
--- a/packages/apps/graph/src/graph/subscription/new-blocks-from-depth.ts
+++ b/packages/apps/graph/src/graph/subscription/new-blocks-from-depth.ts
@@ -5,6 +5,7 @@ import { nullishOrEmpty } from '@utils/nullish-or-empty';
import type { IContext } from '../builder';
import { builder } from '../builder';
import GQLBlock from '../objects/block';
+import { CHAINS } from '@kadena/chainweb-node-client';
builder.subscriptionField('newBlocksFromDepth', (t) =>
t.field({
@@ -18,7 +19,7 @@ builder.subscriptionField('newBlocksFromDepth', (t) =>
},
}),
chainIds: t.arg.stringList({
- required: true,
+ defaultValue: [...CHAINS],
validate: {
minLength: 1,
items: {
@@ -29,7 +30,7 @@ builder.subscriptionField('newBlocksFromDepth', (t) =>
},
nullable: true,
subscribe: (__root, args, context) =>
- iteratorFn(args.chainIds, args.minimumDepth, context),
+ iteratorFn(args.chainIds as string[], args.minimumDepth, context),
resolve: (parent) => parent,
}),
);
diff --git a/packages/apps/graph/src/graph/subscription/new-blocks.ts b/packages/apps/graph/src/graph/subscription/new-blocks.ts
index f0e45381ec..392b9aadd5 100644
--- a/packages/apps/graph/src/graph/subscription/new-blocks.ts
+++ b/packages/apps/graph/src/graph/subscription/new-blocks.ts
@@ -5,13 +5,14 @@ import { nullishOrEmpty } from '@utils/nullish-or-empty';
import type { IContext } from '../builder';
import { builder } from '../builder';
import GQLBlock from '../objects/block';
+import { CHAINS } from '@kadena/chainweb-node-client';
builder.subscriptionField('newBlocks', (t) =>
t.field({
description: 'Subscribe to new blocks.',
args: {
chainIds: t.arg.stringList({
- required: false,
+ defaultValue: [...CHAINS],
validate: {
minLength: 1,
items: {
diff --git a/packages/apps/graph/src/graph/types/graphql-types.ts b/packages/apps/graph/src/graph/types/graphql-types.ts
index 1e77744209..c32ad59323 100644
--- a/packages/apps/graph/src/graph/types/graphql-types.ts
+++ b/packages/apps/graph/src/graph/types/graphql-types.ts
@@ -134,7 +134,6 @@ export interface ITransactionResult {
goodResult: string | null;
height: bigint;
logs: string | null;
- metadata: string | null;
eventCount: bigint | null;
transactionId: bigint | null;
}
diff --git a/packages/apps/graph/src/services/git/path.ts b/packages/apps/graph/src/services/git/path.ts
index b34d554102..ac3717596d 100644
--- a/packages/apps/graph/src/services/git/path.ts
+++ b/packages/apps/graph/src/services/git/path.ts
@@ -1,3 +1,4 @@
+import { isDefined } from '@utils/isDefined';
import {
mkdirSync,
readdirSync,
@@ -52,7 +53,7 @@ export async function flattenFolder(
// if file, rename to include parent folder name
if (basePath === currentPath) continue;
const relativePath = currentPath.replace(basePath, '');
- const folderChain = relativePath.split('/').filter(Boolean).join('.');
+ const folderChain = relativePath.split('/').filter(isDefined).join('.');
const newFilePath = join(
basePath,
`${basename(folderChain)}.${basename(file)}`,
diff --git a/packages/apps/graph/src/utils/isDefined.ts b/packages/apps/graph/src/utils/isDefined.ts
new file mode 100644
index 0000000000..65b70a05df
--- /dev/null
+++ b/packages/apps/graph/src/utils/isDefined.ts
@@ -0,0 +1,11 @@
+/**
+ * Wrapper for filter(Boolean) that also narrows the type.
+ * @example `[].filter(isDefined)` is equal to `[].filter(Boolean)`.
+ * @param value - The value to check.
+ * @returns `true` if the value is defined, `false` otherwise.
+ */
+export function isDefined(
+ value: T | null | undefined,
+): value is NonNullable {
+ return Boolean(value);
+}
diff --git a/packages/apps/rwa-demo/codegen-sdk.yml b/packages/apps/rwa-demo/codegen-sdk.yml
index 3f0b027fbe..323d38721b 100644
--- a/packages/apps/rwa-demo/codegen-sdk.yml
+++ b/packages/apps/rwa-demo/codegen-sdk.yml
@@ -1,6 +1,6 @@
overwrite: true
-# schema: ./node_modules/@kadena/graph/generated-schema.graphql
-schema: https://graph.kadena.network/graphql
+schema: ./node_modules/@kadena/graph/generated-schema.graphql
+# schema: https://graph.kadena.network/graphql
generates:
./src/__generated__/sdk.ts:
documents: 'src/**/*.graph.(ts|tsx)'
|