Skip to content

Commit 50b2635

Browse files
committed
refactor: added token id field in the transfers query for the case where isNft = true
1 parent 30b7c12 commit 50b2635

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

indexer/src/kadena-server/config/graphql-types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,8 @@ export type Transfer = Node & {
14341434
receiverAccount: Scalars['String']['output'];
14351435
requestKey: Scalars['String']['output'];
14361436
senderAccount: Scalars['String']['output'];
1437+
/** The token id if this is a poly-fungible transfer. */
1438+
tokenId?: Maybe<Scalars['String']['output']>;
14371439
/** The transaction that initiated this transfer. */
14381440
transaction?: Maybe<Transaction>;
14391441
};
@@ -3701,6 +3703,7 @@ export type TransferResolvers<
37013703
receiverAccount?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
37023704
requestKey?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
37033705
senderAccount?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
3706+
tokenId?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
37043707
transaction?: Resolver<Maybe<ResolversTypes['Transaction']>, ParentType, ContextType>;
37053708
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
37063709
};

indexer/src/kadena-server/config/schema.graphql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,11 @@ type Transfer implements Node {
10561056
receiverAccount: String!
10571057
requestKey: String!
10581058
senderAccount: String!
1059+
1060+
"""
1061+
The token id if this is a poly-fungible transfer.
1062+
"""
1063+
tokenId: String
10591064
"""
10601065
The transaction that initiated this transfer.
10611066
"""

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ export default class TransferDbRepository implements TransferRepository {
157157
transfers.modulehash as "moduleHash",
158158
transfers.requestkey as "requestKey",
159159
transfers."orderIndex" as "orderIndex",
160-
td.pactid as "pactId"
160+
td.pactid as "pactId",
161+
transfers."tokenId" as "tokenId",
161162
from filtered_block b
162163
join "Transactions" t on b.id = t."blockId"
163164
join "Transfers" transfers on transfers."transactionId" = t.id
@@ -192,7 +193,8 @@ export default class TransferDbRepository implements TransferRepository {
192193
transfers.modulehash as "moduleHash",
193194
transfers.requestkey as "requestKey",
194195
transfers."orderIndex" as "orderIndex",
195-
td.pactid as "pactId"
196+
td.pactid as "pactId",
197+
transfers."tokenId" as "tokenId"
196198
from filtered_transaction t
197199
join "Blocks" b on b.id = t."blockId"
198200
join "Transfers" transfers on transfers."transactionId" = t.id
@@ -216,7 +218,8 @@ export default class TransferDbRepository implements TransferRepository {
216218
transfers.modulehash as "moduleHash",
217219
transfers.requestkey as "requestKey",
218220
transfers."orderIndex" as "orderIndex",
219-
td.pactid as "pactId"
221+
td.pactid as "pactId",
222+
transfers."tokenId" as "tokenId"
220223
from "Transfers" transfers
221224
join "Transactions" t on t.id = transfers."transactionId"
222225
join "Blocks" b on b."id" = t."blockId"
@@ -430,7 +433,8 @@ export default class TransferDbRepository implements TransferRepository {
430433
transfers.modulehash as "moduleHash",
431434
transfers.requestkey as "requestKey",
432435
transfers."orderIndex" as "orderIndex",
433-
td.pactid as "pactId"
436+
td.pactid as "pactId",
437+
transfers."tokenId" as "tokenId"
434438
from "Blocks" b
435439
join "Transactions" transactions on b.id = transactions."blockId"
436440
join "Transfers" transfers on transfers."transactionId" = transactions.id

indexer/src/kadena-server/repository/infra/schema-validator/transfer-schema-validator.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const schema = zod.object({
3636
senderAccount: zod.string(),
3737
requestKey: zod.string(),
3838
pactId: zod.string().nullable(),
39+
tokenId: zod.string().nullable().optional(),
3940
});
4041

4142
/**
@@ -94,6 +95,7 @@ function validate(row: any): TransferOutput {
9495
senderAccount: res.senderAccount,
9596
transferId: res.id.toString(),
9697
pactId: res.pactId,
98+
tokenId: res.tokenId,
9799
};
98100
}
99101

0 commit comments

Comments
 (0)