Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions indexer/src/kadena-server/config/graphql-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,8 @@ export type Transfer = Node & {
receiverAccount: Scalars['String']['output'];
requestKey: Scalars['String']['output'];
senderAccount: Scalars['String']['output'];
/** The token id if this is a poly-fungible transfer. */
tokenId?: Maybe<Scalars['String']['output']>;
/** The transaction that initiated this transfer. */
transaction?: Maybe<Transaction>;
};
Expand Down Expand Up @@ -3701,6 +3703,7 @@ export type TransferResolvers<
receiverAccount?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
requestKey?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
senderAccount?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
tokenId?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
transaction?: Resolver<Maybe<ResolversTypes['Transaction']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
Expand Down
5 changes: 5 additions & 0 deletions indexer/src/kadena-server/config/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,11 @@ type Transfer implements Node {
receiverAccount: String!
requestKey: String!
senderAccount: String!

"""
The token id if this is a poly-fungible transfer.
"""
tokenId: String
"""
The transaction that initiated this transfer.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ export default class TransferDbRepository implements TransferRepository {

if (hasTokenId) {
queryParams.push('marmalade-v2.ledger');
queryParams.push('marmalade.ledger');
const op = operator(queryParams.length);
queryParams.push('marmalade.ledger');
conditions += `\n${op} transfers.modulename IN ($${queryParams.length - 1}, $${queryParams.length})`;
}

Expand Down Expand Up @@ -157,7 +157,8 @@ export default class TransferDbRepository implements TransferRepository {
transfers.modulehash as "moduleHash",
transfers.requestkey as "requestKey",
transfers."orderIndex" as "orderIndex",
td.pactid as "pactId"
td.pactid as "pactId",
transfers."tokenId" as "tokenId"
from filtered_block b
join "Transactions" t on b.id = t."blockId"
join "Transfers" transfers on transfers."transactionId" = t.id
Expand Down Expand Up @@ -192,7 +193,8 @@ export default class TransferDbRepository implements TransferRepository {
transfers.modulehash as "moduleHash",
transfers.requestkey as "requestKey",
transfers."orderIndex" as "orderIndex",
td.pactid as "pactId"
td.pactid as "pactId",
transfers."tokenId" as "tokenId"
from filtered_transaction t
join "Blocks" b on b.id = t."blockId"
join "Transfers" transfers on transfers."transactionId" = t.id
Expand All @@ -216,7 +218,8 @@ export default class TransferDbRepository implements TransferRepository {
transfers.modulehash as "moduleHash",
transfers.requestkey as "requestKey",
transfers."orderIndex" as "orderIndex",
td.pactid as "pactId"
td.pactid as "pactId",
transfers."tokenId" as "tokenId"
from "Transfers" transfers
join "Transactions" t on t.id = transfers."transactionId"
join "Blocks" b on b."id" = t."blockId"
Expand Down Expand Up @@ -430,7 +433,8 @@ export default class TransferDbRepository implements TransferRepository {
transfers.modulehash as "moduleHash",
transfers.requestkey as "requestKey",
transfers."orderIndex" as "orderIndex",
td.pactid as "pactId"
td.pactid as "pactId",
transfers."tokenId" as "tokenId"
from "Blocks" b
join "Transactions" transactions on b.id = transactions."blockId"
join "Transfers" transfers on transfers."transactionId" = transactions.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const schema = zod.object({
senderAccount: zod.string(),
requestKey: zod.string(),
pactId: zod.string().nullable(),
tokenId: zod.string().nullable().optional(),
});

/**
Expand Down Expand Up @@ -94,6 +95,7 @@ function validate(row: any): TransferOutput {
senderAccount: res.senderAccount,
transferId: res.id.toString(),
pactId: res.pactId,
tokenId: res.tokenId,
};
}

Expand Down
50 changes: 50 additions & 0 deletions indexer/tests/integration/builders/nft-transfers.builder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { gql } from 'graphql-request';

export const getNftTransfersQuery = (params: any): string => {
if (Object.keys(params).length === 0) {
throw new Error('No parameters provided to getNftTransfersQuery.');
}

const query = Object.entries(params)
.map(([key, value]) => `${key}: ${typeof value === 'string' ? `"${value}"` : value}`)
.join(', ');

const queryGql = gql`
query {
transfers(${query}) {
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
edges {
cursor
node {
amount
block {
chainId
}
creationTime
crossChainTransfer {
id
}
id
tokenId
moduleHash
moduleName
orderIndex
receiverAccount
requestKey
senderAccount
transaction {
id
}
}
}
}
}
`;

return queryGql;
};
Loading